Browse Source

changed var to let

master
Lurkars 5 years ago
parent
commit
604fd3871b
  1. 34
      js/interface.js

34
js/interface.js

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

Loading…
Cancel
Save