var tokens = 25; var numberOfRotations = 1; var currentRotation = 0; var speed = 10; var wheels, wheels_cur, wheels_tar; //var choices = ["чанта","раница","мишка","USB памет","лакомство","шоколад","коледна играчка"]; var choices = getChoices(); var win = ''; function getChoices() { return ['Слушалки Lenovo','Lenovo фен сет','Бонбони Lindt'] } function MakeEm(){ var i, slots, a_wheel; slots = document.getElementById("slot_machine"); slots.innerHTML = ""; a_wheel = ""; slots.innerHTML += a_wheel; wheels = document.getElementsByName("wheel"); wheels_cur = new Array(wheels.length); wheels_tar = new Array(wheels.length); var x; for(x=0;x currentRotation){ wheels_cur[x] = 0; currentRotation++; done = false; } } } GraphEm(); if (numberOfRotations <= currentRotation) { for (x = 0; x < wheels.length; x++) { if (wheels_tar[x] == wheels_cur[x]) { wheels[x].selectedIndex = 2; } } } if(done){ PayEm(); currentRotation = 1; } else{ speed += 3; //може да се ползва 2 или 1 за по малко забавяне setTimeout("NudgeEm(" + speed + ");",speed); } } function GraphEm(){ var x; var y; var opt; for(x = 0;x < wheels.length;x++){ CleanEm(wheels[x]); for(y = 0;y < 5;y++){ opt = ((choices.length - 1) + wheels_cur[x] - 1 + y) % choices.length; wheels[x].options[y] = new Option(choices[opt],choices[opt]); } } } function CleanEm(elem){ var i; for(i=elem.options.length-1;i>=0;i--){ elem.options[i] = null; } } function PayEm(){ var x; for (x = 0; x < wheels.length; x++) { win = wheels[x].options[2].value; } FlashEm(40); setTimeout('updateOrder()',2000); // call the function (agent) for setting the present in the order ID // and in that agent update the URL } function updateOrder() { location.href="/campaign/xmas2012.nsf/a-update-order?openagent&oid=" + document.getElementById("orderid").value + "&uid=" + document.getElementById("userid").value + "&p=" + win; } function FlashEm(num){ var msg = document.getElementById("slot_machine"); if (msg.style.borderColor != "red") { msg.style.borderStyle = "dotted"; msg.style.borderColor = "red"; } else { msg.style.borderStyle = "dashed"; msg.style.borderColor = "yellow"; } if(num == 0){ msg.style.borderStyle = "solid"; msg.style.borderColor = "#640000"; } else { setTimeout("FlashEm(" + (num - 1) + ");",100); } } function ChargeEm(){ var getprice = false; $.ajax({ type: 'GET', async: false, cache: false, url:'/campaign/xmas2012.nsf/validateData?open&id=' + document.getElementById("orderid").value + '&uid=' + document.getElementById("userid").value, success: function(data){ if (data.split('!~')[1] == "True"){ getprice = true; } } }); if (getprice) { // backend check if the order number is valid or the order is kato za podaruk SpinEm(); document.getElementById("initial-spin").style.display = 'none'; document.getElementById("spinner").style.display = 'inline'; } else { alert('Невалиден клиентски/поръчков номер или вече използван номер на поръчка...') //alert('В момента се извършва обновяване на системата, моля опитайте по-късно...') } }