Little bit of code refactoring.
master
lostheaven92 2016-10-17 19:41:29 +01:00
parent 5794584975
commit 9aaccf79f8
1 changed files with 39 additions and 42 deletions

View File

@ -4,49 +4,55 @@
(function(){
"use strict";
"use strict";
var difficulty;
var selectedMode;
var difficulty;
var selectedMode;
$( document ).ready(function() {
var NUM_STUDENTS = 3;
var numbers = new Array(2140727, 2140730, 2110117);
var names = new Array("Alberto", "Jéssica", "Paulo");
$( document ).ready(function() {
var NUM_STUDENTS = 3;
var numbers = new Array(2140727, 2140730, 2110117);
var names = new Array("Alberto", "Jéssica", "Paulo");
// jQuery Code
$(".col-xs-6:last-child").hide(); //Hide do ultimo author
// jQuery Code
$(".col-xs-6:last-child").hide(); //Hide do ultimo author
changeProjectAuthors(NUM_STUDENTS, numbers, names);
// LISTENERS creation
cellsOnInsertListener();
changeProjectAuthors(NUM_STUDENTS, numbers, names);
// LISTENERS creation
cellsOnInsertListener();
// Evento do botão "New Game"
$("#btn-new").click(function() {
event.preventDefault();
$("#loading").removeClass("invisible");
cleanBoard(); //limpar tabela
callAPIRest(); //callapirest para chamar o board
});
});
function changeProjectAuthors(numStudents, numbers, names){
for (var i = 1; i <= numStudents; i++)
changeAuthor(i, numbers[i-1], names[i-1]);
}
function changeProjectAuthors(numStudents, numbers, names){
for (var i = 1; i <= numStudents; i++)
changeAuthor(i, numbers[i-1], names[i-1]);
}
function changeAuthor(curAuthor, number, name){
var photoSize = 400;
function changeAuthor(curAuthor, number, name){
var photoSize = 400;
if(curAuthor < 1 || curAuthor > 3)
return;
if(curAuthor < 1 || curAuthor > 3)
return;
var identifier = ".col-xs-6:nth-child("+(curAuthor+1)+")";
var identifier = ".col-xs-6:nth-child("+(curAuthor+1)+")";
// TODO: Instead of making 3 jQuery successive calls, store in a variable the access of parent's div.
// Change students' photo size
$(identifier+" img").css('height', photoSize).css('width', photoSize);
// Change students' number
$(identifier+" .caption h3").text(number);
// Change students' name
$(identifier+" .caption p").text(name);
}
// TODO: Instead of making 3 jQuery successive calls, store in a variable the access of parent's div.
// Change students' photo size
$(identifier+" img").css('height', photoSize).css('width', photoSize);
// Change students' number
$(identifier+" .caption h3").text(number);
// Change students' name
$(identifier+" .caption p").text(name);
}
function callAPIRest(){
var mode = $("#select-mode option:selected").val();
$.get("http://198.211.118.123:8080/board/"+mode)
@ -67,25 +73,14 @@
}).fail(function() {
console.log("FAIL CALLING API REST")
});
}
function cleanBoard(){
$("input.with-value").val('')
$("input.with-value").removeClass('with-value');
$("input:disabled.initial").removeAttr("disabled").val('')
}
$("#btn-new").click(function() {
event.preventDefault();
$("#loading").removeClass("invisible");
cleanBoard(); //limpar tabela
callAPIRest(); //callapirest para chamar o board
});
function delay5Seconds(functionToExecute){
setTimeout(functionToExecute, 5000);
}
@ -117,9 +112,11 @@
// Se a linha ou a coluna estiverem preenchidas, faz animação
if(isFullRow($rowCollection))
// animate($rowCollection);
;
if(isFullCol($colCollection))
// animate($colCollection);
;
// TODO: Verificar se o quadrante está completo para mostrar animação
// isFullQuadrant();