<script src="../../tweenmax.js"></script>
<script>
var nb = 13;
- var currentPos = 0;
+ var currentIndex = 0;
var spinning = false;
+ var index = 0;
+
+ var list = [];
+ for (var i = 0; i < nb; i++) {
+ list.push(i);
+ }
+ list = shuffle(list);
+ var currentPos=list[0]+nb;
+
$(function () {
- var index = 0;
updateCurrentPos()
$("#spin").on('click', function () {
spinning = true;
$("#results img").removeClass('visible');
currentPos = normIdx(currentPos);
- var newpos = nb + (currentPos + Math.ceil(Math.random() * 9));
+ currentIndex = (currentIndex + 1) % nb;
+ var newpos = -nb+list[currentIndex];
+
setTimeout(function () {
var pos = normIdx(newpos);
$("#i" + pos).addClass('visible');
return (nb + i) % nb;
}
+ function shuffle(a) {
+ var j, x, i;
+ for (i = a.length - 1; i > 0; i--) {
+ j = Math.floor(Math.random() * (i + 1));
+ x = a[i];
+ a[i] = a[j];
+ a[j] = x;
+ }
+ return a;
+ }
</script>
</body>
</html>
\ No newline at end of file