Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Show more questions
- * */
- var cruzadinha = {
- perguntas: [
- {
- "id": "0",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Pessoal",
- "status" : "none"
- },
- {
- "id": "1",
- "Pergunta": "Em que ano você nasceu?",
- "Categoria": "Pessoal",
- "status" : "none"
- },
- {
- "id": "2",
- "Pergunta": "Quantos anos você tem?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "3",
- "Pergunta": "Como é seu primeiro nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "4",
- "Pergunta": "O nome de sua filha do meio?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "5",
- "Pergunta": "O nome do seu primeiro cachorro?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "6",
- "Pergunta": "Quantos anos vc trabalhou pela primeira vez?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "7",
- "Pergunta": "Seu esporte favorito?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "8",
- "Pergunta": "Com qual idade voce andou de bicicleta?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "9",
- "Pergunta": "Como é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "10",
- "Pergunta": "Como é seu dasd nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "11",
- "Pergunta": "Como é seu asdas nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "12",
- "Pergunta": "Como é seuasdads nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "13",
- "Pergunta": "Comoadsdasdas é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- },
- {
- "id": "14",
- "Pergunta": "Comoasddaddsa é seu nome?",
- "Categoria": "Facil",
- "status" : "none"
- }
- ],
- perguntasSelecionadas: [],
- init: function(){
- this.cacheDom();
- this.populaPergunta();
- this.adicionarPerguntas();
- this.excluirPerguntas();
- },
- cacheDom: function (){
- this.$listaPerguntas = $('.lista-perguntas');
- },
- populaPergunta: function () {
- for(var x = 0; x < 10; x++) {
- $('<li>'+this.perguntas[x].Pergunta+'<a class="exclude" data-id="'+this.perguntas[x].id+'">--Excluir</a></li>').prependTo(this.$listaPerguntas).hide().fadeIn();
- this.perguntas[x].status = 'select';
- this.perguntasSelecionadas.push(this.perguntas[x]);
- }
- },
- adicionarPerguntas: function () {
- var self = this;
- $(document).on('click','.btn-questions', function () {
- var maxRepetion = 0;
- if(self.perguntas.length > 10) {
- for (var x = 0; x < self.perguntas.length; x++) {
- if (self.perguntas[x].status === 'none') {
- $('<li>' + self.perguntas[x].Pergunta + '<a class="exclude" data-id="' + self.perguntas[x].id + '">--Excluir</a></li>').appendTo(self.$listaPerguntas).hide().fadeIn();
- self.perguntas[x].status = 'select';
- self.perguntasSelecionadas.push(self.perguntas[x]);
- maxRepetion++;
- if (maxRepetion > 5) {
- return;
- }
- }
- }
- }else{
- alert("Acabou as perguntas caraio");
- }
- })
- },
- excluirPerguntas: function () {
- var self = this;
- function removePergunta(btn){
- for (var x = 0; x < self.perguntas.length; x++) {
- if (self.perguntas[x].id === $(btn).attr('data-id')) {
- $(btn).parent().fadeOut();
- $(btn).parent().remove();
- self.perguntas.splice(self.perguntas.indexOf(self.perguntas[x]), 1);
- self.perguntasSelecionadas.splice(self.perguntasSelecionadas.indexOf(self.perguntas[x]), 1);
- break;
- }
- }
- }
- $(document).on('click','.exclude', function () {
- if(self.perguntas.length > 10){
- if(self.perguntasSelecionadas.length === 10) {
- removePergunta($(this));
- for (var y = 0; y < self.perguntas.length; y++) {
- if (self.perguntas[y].status === 'none') {
- $('<li>' + self.perguntas[y].Pergunta + '<a class="exclude" data-id="' + self.perguntas[y].id + '">--Excluir</a></li>').appendTo(self.$listaPerguntas).hide().fadeIn();
- self.perguntas[y].status = 'select';
- self.perguntasSelecionadas.push(self.perguntas[y]);
- return;
- }
- }
- }else if(self.perguntasSelecionadas.length > 10){
- removePergunta(this);
- } else{
- alert("Minimo 10 perguntas viado");
- }
- }else{
- alert("Acabou as perguntas carai");
- }
- })
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement