| 1 |
// JavaScript |
| 2 |
jQuery(function($) { |
| 3 |
|
| 4 |
var wc_check = 'same'; |
| 5 |
var intervalId = setInterval(function(){ |
| 6 |
if (typeof uscesL10n === "undefined" || typeof uscesL10n.cart_url === "undefined") { |
| 7 |
clearInterval(intervalId); |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if( 'same' != wc_check ){ |
| 12 |
if( 'different' == wc_check || 'timeover' == wc_check || 'entrydiff' == wc_check ){ |
| 13 |
alert( uscesL10n.check_mes ); |
| 14 |
location.href = uscesL10n.cart_url; |
| 15 |
}else{ |
| 16 |
return false; |
| 17 |
} |
| 18 |
} |
| 19 |
wc2confirm.check(); |
| 20 |
|
| 21 |
}, 10000); |
| 22 |
|
| 23 |
|
| 24 |
wc2confirm = { |
| 25 |
settings: { |
| 26 |
url: uscesL10n.ajaxurl, |
| 27 |
type: 'POST', |
| 28 |
cache: false, |
| 29 |
data: {} |
| 30 |
}, |
| 31 |
|
| 32 |
check : function() { |
| 33 |
if (typeof uscesL10n === "undefined" || typeof uscesL10n.cart_url === "undefined") { |
| 34 |
return false; |
| 35 |
} |
| 36 |
var s = wc2confirm.settings; |
| 37 |
s.data = { |
| 38 |
'action' : 'welcart_confirm_check', |
| 39 |
'uscesid' : uscesL10n.uscesid, |
| 40 |
'wc_condition' : uscesL10n.condition, |
| 41 |
'wc_nonce' : uscesL10n.wc_nonce |
| 42 |
}; |
| 43 |
$.ajax( s ).done(function( response ){ |
| 44 |
data = response.data.replace(/(^\s+)|(\s+$)|(^\r\n)|(\r\n$)|(^\n+)|(\n+$)/g, ""); |
| 45 |
wc_check = data; |
| 46 |
}).fail(function( msg ){ |
| 47 |
console.log( msg ); |
| 48 |
}); |
| 49 |
return false; |
| 50 |
} |
| 51 |
}; |
| 52 |
}); |
| 53 |
|
| 54 |
|