Implementacija funkcionalnosti brezplačnega dnevnega vrtenja
Deploy to Test Server / deploy (push) Failing after 9s
Deploy to Test Server / deploy (push) Failing after 9s
This commit is contained in:
1 parent
175f79e303
commit
d77be150d9
7 files changed
+366
-149
No files matched your search
+33
-12
@@ -20,6 +20,7 @@ jQuery(document).ready(function($) {
|
||||
var isSpinning = false;
|
||||
var accumulatedRotation = 0;
|
||||
var wheelSpins = wof_data.spins_left;
|
||||
var dailySpinAvailable = wof_data.daily_spin_available;
|
||||
var l10n = wof_data.l10n;
|
||||
|
||||
// Nastavitve animacije
|
||||
@@ -58,11 +59,7 @@ jQuery(document).ready(function($) {
|
||||
showPrizePopup(prize);
|
||||
isSpinning = false;
|
||||
|
||||
if (wheelSpins > 0) {
|
||||
spinButton.prop('disabled', false).text(l10n.spin_button);
|
||||
} else {
|
||||
spinButton.prop('disabled', true).text(l10n.no_spins_left);
|
||||
}
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
// Prikaz nagrade
|
||||
@@ -81,9 +78,31 @@ jQuery(document).ready(function($) {
|
||||
}
|
||||
}
|
||||
|
||||
// Posodobitev stanja gumba
|
||||
function updateButtonState() {
|
||||
if (isSpinning) return;
|
||||
|
||||
if (dailySpinAvailable) {
|
||||
spinButton.prop('disabled', false).text(l10n.free_daily_spin || 'FREE DAILY SPIN');
|
||||
} else if (wheelSpins > 0) {
|
||||
spinButton.prop('disabled', false).text(l10n.spin_button);
|
||||
} else {
|
||||
spinButton.prop('disabled', true).text(l10n.no_spins_left);
|
||||
}
|
||||
}
|
||||
|
||||
// Klik na gumb za vrtenje
|
||||
spinButton.on('click', function() {
|
||||
if (isSpinning || wheelSpins <= 0) return;
|
||||
if (isSpinning) return;
|
||||
|
||||
var spinType = 'paid'; // Privzeto je plačan
|
||||
|
||||
// Preveri, ali najprej porabimo dnevnega
|
||||
if (dailySpinAvailable) {
|
||||
spinType = 'daily';
|
||||
} else if (wheelSpins <= 0) {
|
||||
return; // Ničesar za porabiti
|
||||
}
|
||||
|
||||
isSpinning = true;
|
||||
spinButton.prop('disabled', true).text(l10n.spinning);
|
||||
@@ -97,10 +116,16 @@ jQuery(document).ready(function($) {
|
||||
},
|
||||
data: {
|
||||
wheel_id: wof_data.wheel_id,
|
||||
spin_type: spinType
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
window.wof_spin_result = response.data;
|
||||
|
||||
// Posodobimo stanje
|
||||
if (spinType === 'daily') {
|
||||
dailySpinAvailable = false;
|
||||
}
|
||||
wheelSpins = response.data.remaining_spins;
|
||||
updateSpinsCounter();
|
||||
|
||||
@@ -131,17 +156,13 @@ jQuery(document).ready(function($) {
|
||||
function handleError(message) {
|
||||
resultDiv.html('<p>' + message + '</p>').addClass('error').fadeIn(300);
|
||||
isSpinning = false;
|
||||
if(wheelSpins > 0){
|
||||
spinButton.prop('disabled', false).text(l10n.spin_button);
|
||||
}
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
// Inicializacija
|
||||
function init() {
|
||||
updateSpinsCounter();
|
||||
if (wheelSpins <= 0) {
|
||||
spinButton.prop('disabled', true).text(l10n.no_spins_left);
|
||||
}
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
Reference in new issue
Block a user