| Server IP : 127.0.0.1 / Your IP : 216.73.216.48 Web Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 System : Windows NT DESKTOP-3H4FHQJ 10.0 build 19045 (Windows 10) AMD64 User : win 10 ( 0) PHP Version : 8.2.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/xampp/htdocs-coblaa/cb_image/ |
Upload File : |
//require('./db.php');
const wheel = document.getElementById("wheel");
const spinBtn = document.getElementById("spin-btn");
const finalValue = document.getElementById("final-value");
const won_amt = document.getElementById("won_amt");
//Object that stores values of minimum and maximum angle for a value
const rotationValues = [
{ minDegree: 0, maxDegree: 30, value: 0 },
{ minDegree: 31, maxDegree: 90, value: 100 },
{ minDegree: 91, maxDegree: 150, value: 250 },
{ minDegree: 151, maxDegree: 210, value: 0 },
{ minDegree: 211, maxDegree: 270, value: 150 },
{ minDegree: 271, maxDegree: 330, value: 50 },
{ minDegree: 331, maxDegree: 360, value: 0 },
];
//Size of each piece
const data = [16, 16, 16, 16, 16, 16];
//background color for each piece
var pieColors = [
"#db7093",
"#20b2aa",
"#d63e92",
"#daa520",
"#ff340f",
"#ff7f50",
]; /*
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: [100, 0, 50, 150, 0, 250],
//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
const valueGenerator = (angleValue) => {
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>Won Ugx: ${i.value}</p>`;
won_amt.innerHTML = `<h3>${i.value}</h3>`;
won_amt2 = document.querySelector('h3').innerHTML;
document.querySelector('h3').style.display="none";
my_id = document.getElementById('my_id').value;
ipuser = document.getElementById('ipuser').value;
spin_temps = document.getElementById('spin_temps2').innerHTML;
var spin_cont = 1;
if(spin_temps == 1){document.getElementById('spin_temps2').innerHTML =2;spin_cont=2;}
if(spin_temps == 2){document.getElementById('spin_temps2').innerHTML =3;spin_cont=3;}
if(spin_temps ==0){document.getElementById('spin_temps2').innerHTML =1; spin_cont=1;}
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","auto_page.php?ipuser="+ipuser+"&&my_id="+my_id+"&&won_amt2="+won_amt2+"&&spin_cont="+spin_cont+"&&status=insert_spin_tempts",false);
xmlhttp.send(null);
rty = document.getElementById("temps3").innerHTML =xmlhttp.responseText;
if(spin_cont ==3){
display_spin_chances();
close_spin_area();
cliam_spin_reward();
document.getElementById('reward_out').style.display="block";
document.getElementById('reward_out').innerHTML="You Recived "+won_amt2+"/=";
document.getElementById('spin_now_btn').style.display="none";
}
spinBtn.disabled = false;
break;
}
}
};
//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;
//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);
});