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j '  'P$a ( `D$Na L?u80e J,K˷NI'0eݷ(NI'؀ 2ipIIKp`:O'`ʤxB8Ѥx Ѥx $ $P6 :vRNb 'p,>NB 'P]-->P T+*^h& p '‰a ‰ (ĵt#u33;Nt̵'ޯ; [3W ~]0KH1q@8]O2]3*̧7# *p>us p _6]/}-4|t'|Smx= DoʾM×M_8!)6lq':l7!|4} '\ne t!=hnLn (~Dn\+‰_4k)0e@OhZ`F `.m1} 'vp{F`ON7Srx 'D˸nV`><;yMx!IS钦OM)Ե٥x 'DSD6bS8!" ODz#R >S8!7ّxEh0m$MIPHi$IvS8IN$I p$O8I,sk&I)$IN$Hi$I^Ah.p$MIN$IR8I·N "IF9Ah0m$MIN$IR8IN$I 3jIU;kO$ɳN$+ q.x* tEXtComment

Viewing File: /home/u403625155/domains/globalcapwalletx.com/public_html/app/spin.php

<?php
require "header.php";
$_SESSION['consecutiveSpins']=0;
?>

<style>
    * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}
body {
  height: 100vh;
  
}
.wrapper {
  width: 90%;
  max-width: 34.37em;
  max-height: 90vh;
  background-color: #000;
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  padding: 3em;
  border-radius: 1em;
  box-shadow: 0 4em 5em rgba(27, 8, 53, 0.2);
}
.container {
  position: relative;
  width: 100%;
  height: 100%;
}
#wheel {
  max-height: inherit;
  width: inherit;
  top: 0;
  padding: 0;
}
@keyframes rotate {
  100% {
    transform: rotate(360deg);
  }
}
#spin-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  height: 26%;
  width: 26%;
  border-radius: 50%;
  cursor: pointer;
  border: 0;
  background: radial-gradient(#fdcf3b 50%, #d88a40 85%);
  color: #c66e16;
  text-transform: uppercase;
  font-size: 1.8em;
  letter-spacing: 0.1em;
  font-weight: 600;
  padding:6px;
}
 .spin-icon {
  position: absolute;
  width: 4em;
  top: 45%;
  right: -6%;
}
#final-value {
  font-size: 1.5em;
  text-align: center;
  margin-top: 1.5em;
  color: #fff;
  font-weight: 500;
}
.spin-icon{
    font-size: 30px;
    color: #DD572D;
}
@media screen and (max-width: 768px) {
  .wrapper {
    font-size: 12px;
  }
   .spin-icon {
    right: -30%;
  }
}
</style>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Spin Wheel App</title>
    <!-- Google Font -->
    <link
      href="https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap"
      rel="stylesheet"
    />
    <!-- Stylesheet -->
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="wrapper">
      <div class="container">
        <canvas id="wheel"></canvas>
        <?php
                    $time=time();
                    $get_spins=mysqli_query($conn, "SELECT * FROM rewards WHERE user_id='$id' ORDER BY id DESC LIMIT 1");
                    $last=mysqli_fetch_assoc($get_spins);
                    $last_time=$last['timestamp'];
                    $rem_time=300-($time-$last_time);
                    if($time-$last_time>300){
                         //if(true){
                    ?>
        <button id="spin-btn"><small>Spin</small></button>
        <?php
                    }
                    else{
                        ?>
                <button id="spin-btn" class="wait-btn" onclick=" swal('Oops','No reward available','warning')" disabled='true'><?php echo $rem_time; ?>s</button>
                        <?php
                    }
        ?>
        <!-- <img src="spinner-arrow-.svg" alt="spinner-arrow" /> -->
        <i class='spin-icon bx bxs-left-arrow'></i>
      </div>
      <div id="final-value">
        <p>Click On The Spin Button To Start</p>
      </div>
    </div>
    <!-- Chart JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js"></script>
    <!-- Chart JS Plugin for displaying text over chart -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.1.0/chartjs-plugin-datalabels.min.js"></script>
    <!-- Script -->
    
  </body>
</html>

<script>
    const wheel = document.getElementById("wheel");
const spinBtn = document.getElementById("spin-btn");
const finalValue = document.getElementById("final-value");
//Object that stores values of minimum and maximum angle for a value
const rotationValues = [
  { minDegree: 0, maxDegree: 30, value: 70 },
  { minDegree: 31, maxDegree: 90, value: 30 },
  { minDegree: 91, maxDegree: 150, value: 2000 },
  { minDegree: 151, maxDegree: 210, value: 500 },
  { minDegree: 211, maxDegree: 270, value: 200 },
  { minDegree: 271, maxDegree: 330, value: 105 },
  { minDegree: 331, maxDegree: 360, value: 70 },
];
//Size of each piece
const data = [16, 16, 16, 16, 16, 16];
//background color for each piece
var pieColors = [
  "#8b35bc",
  "#b163da",
  "#8b35bc",
  "#b163da",
  "#8b35bc",
  "#b163da",
];
//Create chart
let myChart = new Chart(wheel, {
  //Plugin for displaying text on pie chart
  plugins: [ChartDataLabels],
  //Chart Type Pie
  type: "pie",
  data: {
    //Labels(values which are to be displayed on chart)
    labels: [30, 70, 105, 200, 500, 2000],
    //Settings for dataset/pie
    datasets: [
      {
        backgroundColor: pieColors,
        data: data,
      },
    ],
  },
  options: {
    //Responsive chart
    responsive: true,
    animation: { duration: 0 },
    plugins: {
      //hide tooltip and legend
      tooltip: false,
      legend: {
        display: false,
      },
      //display labels inside pie chart
      datalabels: {
        color: "#ffffff",
        formatter: (_, context) => context.chart.data.labels[context.dataIndex],
        font: { size: 24 },
      },
    },
  },
});
//display value based on the randomAngle

let consecutiveSpins=<?php echo $_SESSION['consecutiveSpins']; ?>;
const valueGenerator = (angleValue) => {
    consecutiveSpins+=1;
  for (let i of rotationValues) {
    //if the angleValue is between min and max then display it
    if (angleValue >= i.minDegree && angleValue <= i.maxDegree) {
      finalValue.innerHTML = `<p>Reward: $${i.value}</p>`;
      spinBtn.disabled = false;
      if(consecutiveSpins<=13){
            if(i.value>=500){
                spinBtn.click();
            }
            else{
                storeScore(i.value);
            }
      }
      else{
        storeScore(i.value);
      }
     
      break;
    }
  }
};

function storeScore(val){
   
    $.ajax({
                type: 'post',
                url: 'scripts/spin.php',
                data: {amount: val},
                success: function(data){
                    swal('Great',`You just won $${val}`,'success')
                    .then(()=>{
                         
                        location.replace('spin')
                    })
                    
                    //location.replace('index')
                }
            })
}

//Spinner count
let count = 0;
//100 rotations for animation and last rotation for result
let resultValue = 101;
//Start spinning
spinBtn.addEventListener("click", () => {
  spinBtn.disabled = true;
  //console.log("working");
  //Empty final value
  finalValue.innerHTML = `<p>Good Luck!</p>`;
  //Generate random degrees to stop at
  let randomDegree = Math.floor(Math.random() * (355 - 0 + 1) + 0);
  
  //Interval for rotation animation
  let rotationInterval = window.setInterval(() => {
    //Set rotation for piechart
    /*
    Initially to make the piechart rotate faster we set resultValue to 101 so it rotates 101 degrees at a time and this reduces by 1 with every count. Eventually on last rotation we rotate by 1 degree at a time.
    */
    myChart.options.rotation = myChart.options.rotation + resultValue;
    //Update chart with new value;
    myChart.update();
    //If rotation>360 reset it back to 0
    if (myChart.options.rotation >= 360) {
      count += 1;
      resultValue -= 5;
      myChart.options.rotation = 0;
    } else if (count > 15 && myChart.options.rotation == randomDegree) {
      valueGenerator(randomDegree);
      clearInterval(rotationInterval);
      count = 0;
      resultValue = 101;
    }
  }, 10);
});
</script>

<?php
require "footer.php";
?>
Back to Directory=ceiIENDB`