var TicketID;
var UUID;
var PrizeText;
function ShowLogin() {
jQuery("#LoadPopupLogin form")[0].reset();
jQuery.fancybox.open({
padding: 0,
src: '#LoadPopupLogin',
type: 'inline',
touch: false,
animationEffect: 'fade',
modal: true
});
jQuery('#SpinWheel').show();
return false;
}
jQuery('document').ready(function () {
TicketID = 0;
UUID = '';
PrizeText = '';
ShowLogin();
jQuery('#LoadPopupLogin form').submit(function () {
jQuery.ajax({
url: 'https://bizimcark.com/sorgula',
type: 'post',
data: jQuery("#LoadPopupLogin form").serialize(),
success: function (data) {
data = JSON.parse(data);
if (data.success == 0) {
swal(
'Hata',
data.msg,
'error'
);
jQuery("#LoadPopupLogin form")[0].reset();
return false;
} else {
TicketID = data.success[0];
UUID = data.success[1];
jQuery.fancybox.close();
return false;
}
}
});
return false;
});
});
wheelSpinning = false;
var theWheel = new Winwheel({
'drawMode': 'image',
'imageOverlay': true,
'outerRadius': 0,
'numSegments': 12,
'animation': {
'type': 'spinToStop',
'duration': 7,
'spins': 14,
'callbackFinished': 'alertPrize()'
}
});
var firstImg = new Image();
firstImg.onload = function () {
theWheel.wheelImage = firstImg;
theWheel.draw();
};
firstImg.src = "https://bizimcark.com/assets/img/73b012342af8abd619f14abbd2f57c6e.png";
function alertPrize() {
var winningSegment = theWheel.getIndicatedSegment();
if (PrizeText === 'PAS') {
jQuery.fancybox.open({
padding: 0,
src: '#LoadPopupLose',
type: 'inline',
touch: true,
animationEffect: 'fade',
opts: {
afterClose: function (instance, current) {
ShowLogin();
}
}
});
} else {
jQuery('#LoadPopupWin').find('h3').html(PrizeText + ' KAZANDINIZ
Ana Sayfaya Dön');
jQuery.fancybox.open({
padding: 0,
src: '#LoadPopupWin',
type: 'inline',
touch: true,
animationEffect: 'fade',
opts: {
afterClose: function (instance, current) {
jQuery('#LoadPopupWin').find('h3').html('
Ana Sayfaya Dön');
ShowLogin();
}
}
});
}
wheelSpinning = false;
return false;
}
function calculatePrizeOnServer() {
jQuery.ajax({
url: 'https://bizimcark.com/cevir',
type: 'POST',
data: {
formTicketID: TicketID,
formUUID: UUID
},
dataType: "json",
success: function (data) {
var segmentNumber = data.success;
if (segmentNumber > 0) {
PrizeText = data.msg;
var stopAt = theWheel.getRandomForSegment(segmentNumber);
theWheel.animation.stopAngle = stopAt;
theWheel.startAnimation();
} else {
swal(
'Hata',
data.msg,
'error'
);
jQuery("#LoadPopupLogin form")[0].reset();
jQuery('#LoadPopupWin').find('h3').html('
Ana Sayfaya Dön');
ShowLogin();
return false;
}
}
});
}
jQuery('#SpinWheel').click(function () {
if (wheelSpinning === false) {
wheelSpinning = true;
theWheel.stopAnimation(false);
theWheel.rotationAngle = 0;
theWheel.draw();
calculatePrizeOnServer();
jQuery('#SpinWheel').hide();
return false;
}
});