changed var to let
This commit is contained in:
+17
-17
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
function Interface() {
|
function Interface() {
|
||||||
|
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
// Event Objects for callbacks
|
// Event Objects for callbacks
|
||||||
self.events = {};
|
self.events = {};
|
||||||
@@ -49,8 +49,8 @@ function Interface() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// add click events for dices
|
// add click events for dices
|
||||||
for (var diceIndex = 0; diceIndex < 6; diceIndex++) {
|
for (let diceIndex = 0; diceIndex < 6; diceIndex++) {
|
||||||
var diceContainer = self.dices[diceIndex];
|
let diceContainer = self.dices[diceIndex];
|
||||||
diceContainer.diceIndex = diceIndex;
|
diceContainer.diceIndex = diceIndex;
|
||||||
diceContainer.addEventListener("click", function () {
|
diceContainer.addEventListener("click", function () {
|
||||||
if (self.playing && !this.classList.contains('disabled')) {
|
if (self.playing && !this.classList.contains('disabled')) {
|
||||||
@@ -86,7 +86,7 @@ Interface.prototype.on = function(event, callback) {
|
|||||||
* fire events and execute callbacks
|
* fire events and execute callbacks
|
||||||
*/
|
*/
|
||||||
Interface.prototype.fireEvent = function (event, data) {
|
Interface.prototype.fireEvent = function (event, data) {
|
||||||
var callbacks = this.events[event];
|
let callbacks = this.events[event];
|
||||||
if (callbacks) {
|
if (callbacks) {
|
||||||
callbacks.forEach(function (callback) {
|
callbacks.forEach(function (callback) {
|
||||||
callback(data);
|
callback(data);
|
||||||
@@ -98,11 +98,11 @@ Interface.prototype.fireEvent = function(event, data) {
|
|||||||
* Set dices
|
* Set dices
|
||||||
*/
|
*/
|
||||||
Interface.prototype.setDices = function (dices) {
|
Interface.prototype.setDices = function (dices) {
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
for (var diceIndex = 0; diceIndex < 6; diceIndex++) {
|
for (let diceIndex = 0; diceIndex < 6; diceIndex++) {
|
||||||
var dice = dices[diceIndex];
|
let dice = dices[diceIndex];
|
||||||
var diceContainer = self.dices[diceIndex];
|
let diceContainer = self.dices[diceIndex];
|
||||||
diceContainer.innerHTML = dice.value + 1;
|
diceContainer.innerHTML = dice.value + 1;
|
||||||
|
|
||||||
if (dice.disabled) {
|
if (dice.disabled) {
|
||||||
@@ -130,9 +130,9 @@ Interface.prototype.setDices = function(dices) {
|
|||||||
* fire dices animation
|
* fire dices animation
|
||||||
*/
|
*/
|
||||||
Interface.prototype.animateDices = function (dices, timeout, callback) {
|
Interface.prototype.animateDices = function (dices, timeout, callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
for (var diceIndex = 0; diceIndex < 6; diceIndex++) {
|
for (let diceIndex = 0; diceIndex < 6; diceIndex++) {
|
||||||
var dice = dices[diceIndex];
|
let dice = dices[diceIndex];
|
||||||
if (!dice.disabled && !dice.selected) {
|
if (!dice.disabled && !dice.selected) {
|
||||||
self.dices[diceIndex].classList.add("animate");
|
self.dices[diceIndex].classList.add("animate");
|
||||||
self.dices[diceIndex].classList.add("duration" + diceIndex);
|
self.dices[diceIndex].classList.add("duration" + diceIndex);
|
||||||
@@ -140,7 +140,7 @@ Interface.prototype.animateDices = function(dices, timeout, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
for (var diceIndex = 0; diceIndex < 6; diceIndex++) {
|
for (let diceIndex = 0; diceIndex < 6; diceIndex++) {
|
||||||
self.dices[diceIndex].classList.remove("animate");
|
self.dices[diceIndex].classList.remove("animate");
|
||||||
}
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@@ -209,8 +209,8 @@ Interface.prototype.setPlaying = function(playing) {
|
|||||||
*/
|
*/
|
||||||
Interface.prototype.setPlayer = function (player) {
|
Interface.prototype.setPlayer = function (player) {
|
||||||
this.playerScore.innerHTML = player.score;
|
this.playerScore.innerHTML = player.score;
|
||||||
var zilchs = '';
|
let zilchs = '';
|
||||||
for (var i = 0; i < player.zilch; i++) {
|
for (let i = 0; i < player.zilch; i++) {
|
||||||
zilchs += '<div class="point"></div>';
|
zilchs += '<div class="point"></div>';
|
||||||
}
|
}
|
||||||
this.playerZilch.innerHTML = zilchs;
|
this.playerZilch.innerHTML = zilchs;
|
||||||
@@ -222,8 +222,8 @@ Interface.prototype.setPlayer = function(player) {
|
|||||||
*/
|
*/
|
||||||
Interface.prototype.setCpu = function (cpu) {
|
Interface.prototype.setCpu = function (cpu) {
|
||||||
this.cpuScore.innerHTML = cpu.score;
|
this.cpuScore.innerHTML = cpu.score;
|
||||||
var zilchs = '';
|
let zilchs = '';
|
||||||
for (var i = 0; i < cpu.zilch; i++) {
|
for (let i = 0; i < cpu.zilch; i++) {
|
||||||
zilchs += '<div class="point"></div>';
|
zilchs += '<div class="point"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ Interface.prototype.setCpu = function(cpu) {
|
|||||||
* show message with timeout and callback
|
* show message with timeout and callback
|
||||||
*/
|
*/
|
||||||
Interface.prototype.showMessage = function (message, timeout, callback) {
|
Interface.prototype.showMessage = function (message, timeout, callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
self.message.innerHTML = '<p>' + message + '</p>';
|
self.message.innerHTML = '<p>' + message + '</p>';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user