diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js index 9b70688f1..35c4eb298 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js @@ -6,4 +6,16 @@ * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ -(function (b, c) { var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; $.throttle = a = function (e, f, j, i) { var h, d = 0; if (typeof f !== "boolean") { i = j; j = f; f = c } function g() { var o = this, m = +new Date() - d, n = arguments; function l() { d = +new Date(); j.apply(o, n) } function k() { h = c } if (i && !h) { l() } h && clearTimeout(h); if (i === c && m > e) { l() } else { if (f !== true) { h = setTimeout(i ? k : l, i === c ? e - m : e) } } } if ($.guid) { g.guid = j.guid = j.guid || $.guid++ } return g }; $.debounce = function (d, e, f) { return f === c ? a(d, e, false) : a(d, f, e !== false) } })(this); \ No newline at end of file +(function(b, c) { + // eslint-disable-next-line prefer-const + let $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; $.throttle = a = function(e, f, j, i) { + // eslint-disable-next-line max-statements-per-line + let h, d = 0; if (typeof f !== 'boolean') { i = j; j = f; f = c; } function g() { + // eslint-disable-next-line prefer-const, max-statements-per-line + let o = this, m = +new Date() - d, n = arguments; function l() { d = +new Date(); j.apply(o, n); } function k() { h = c; } if (i && !h) { l(); } h && clearTimeout(h); if (i === c && m > e) { l(); } + else if (f !== true) { h = setTimeout(i ? k : l, i === c ? e - m : e); } + // eslint-disable-next-line max-statements-per-line + } if ($.guid) { g.guid = j.guid = j.guid || $.guid++; } return g; + // eslint-disable-next-line max-statements-per-line + }; $.debounce = function(d, e, f) { return f === c ? a(d, e, false) : a(d, f, e !== false); }; +})(this); \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js index faff7195e..b9bcbea2e 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js @@ -1,91 +1,92 @@ -var tableauQuestion = [ +// eslint-disable-next-line no-unused-vars +const tableauQuestion = [ { - question: "If you're going 80 km/h, and you're approaching a residential area you must:", - propositionA: "You accelerate", - propositionB: "You keep your speed, if you do not pass other vehicles", - propositionC: "You slow down", - propositionD: "You keep your speed", - reponse: "C" + question: 'If you\'re going 80 km/h, and you\'re approaching a residential area you must:', + propositionA: 'You accelerate', + propositionB: 'You keep your speed, if you do not pass other vehicles', + propositionC: 'You slow down', + propositionD: 'You keep your speed', + reponse: 'C', }, { - question: "If you're turning right at a traffic light, but see a pedestrian crossing what do you do:", - propositionA: "You pass the pedestrian", - propositionB: "You check that there is no other vehicles around", - propositionC: "You wait until the pedestrian has crossed", - propositionD: "You shoot the pedestrian and continue to drive", - reponse: "C" + question: 'If you\'re turning right at a traffic light, but see a pedestrian crossing what do you do:', + propositionA: 'You pass the pedestrian', + propositionB: 'You check that there is no other vehicles around', + propositionC: 'You wait until the pedestrian has crossed', + propositionD: 'You shoot the pedestrian and continue to drive', + reponse: 'C', }, { - question: "Without any prior indication, the speed in a residential area is: __ km/h", - propositionA: "30 km/h", - propositionB: "50 km/h", - propositionC: "40 km/h", - propositionD: "60 km/h", - reponse: "B" + question: 'Without any prior indication, the speed in a residential area is: __ km/h', + propositionA: '30 km/h', + propositionB: '50 km/h', + propositionC: '40 km/h', + propositionD: '60 km/h', + reponse: 'B', }, { - question: "Before every lane change you must:", - propositionA: "Check your mirrors", - propositionB: "Check your blind spots", - propositionC: "Signal your intentions", - propositionD: "All of the above", - reponse: "D" + question: 'Before every lane change you must:', + propositionA: 'Check your mirrors', + propositionB: 'Check your blind spots', + propositionC: 'Signal your intentions', + propositionD: 'All of the above', + reponse: 'D', }, { - question: "What blood alcohol level is classified as driving while intoxicated?", - propositionA: "0.05%", - propositionB: "0.18%", - propositionC: "0.08%", - propositionD: "0.06%", - reponse: "C" + question: 'What blood alcohol level is classified as driving while intoxicated?', + propositionA: '0.05%', + propositionB: '0.18%', + propositionC: '0.08%', + propositionD: '0.06%', + reponse: 'C', }, { - question: "When can you continue to drive at a traffic light?", - propositionA: "When it is green", - propositionB: "When there is nobody in the intersection", - propositionC: "You are in a school zone", - propositionD: "When it is green and / or red and you're turning right", - reponse: "D" + question: 'When can you continue to drive at a traffic light?', + propositionA: 'When it is green', + propositionB: 'When there is nobody in the intersection', + propositionC: 'You are in a school zone', + propositionD: 'When it is green and / or red and you\'re turning right', + reponse: 'D', }, { - question: "A pedestrian has a do not cross signal, what do you do?", - propositionA: "You let them pass", - propositionB: "You observe before continuing", - propositionC: "You wave to tell them to cross", - propositionD: "You continue because your traffic light is green", - reponse: "D" + question: 'A pedestrian has a do not cross signal, what do you do?', + propositionA: 'You let them pass', + propositionB: 'You observe before continuing', + propositionC: 'You wave to tell them to cross', + propositionD: 'You continue because your traffic light is green', + reponse: 'D', }, { - question: "What is allowed when passing another vehicle", - propositionA: "You follow it closely to pass it faster", - propositionB: "You pass it without leaving the roadway", - propositionC: "You drive on the opposite side of the road to pass", - propositionD: "You exceed the speed limit to pass them", - reponse: "C" + question: 'What is allowed when passing another vehicle', + propositionA: 'You follow it closely to pass it faster', + propositionB: 'You pass it without leaving the roadway', + propositionC: 'You drive on the opposite side of the road to pass', + propositionD: 'You exceed the speed limit to pass them', + reponse: 'C', }, { - question: "You are driving on a highway which indicates a maximum speed of 120 km/h. But most trafficers drive at 125 km/h, so you should not drive faster than:", - propositionA: "120 km/h", - propositionB: "125 km/h", - propositionC: "130 km/h", - propositionD: "110 km/h", - reponse: "A" + question: 'You are driving on a highway which indicates a maximum speed of 120 km/h. But most trafficers drive at 125 km/h, so you should not drive faster than:', + propositionA: '120 km/h', + propositionB: '125 km/h', + propositionC: '130 km/h', + propositionD: '110 km/h', + reponse: 'A', }, { - question: "When you are overtaken by another vehicle it is important NOT to:", - propositionA: "Slow Down", - propositionB: "Check your mirrors", - propositionC: "Watch other drivers", - propositionD: "Increase your speed", - reponse: "D" + question: 'When you are overtaken by another vehicle it is important NOT to:', + propositionA: 'Slow Down', + propositionB: 'Check your mirrors', + propositionC: 'Watch other drivers', + propositionD: 'Increase your speed', + reponse: 'D', }, -] \ No newline at end of file +]; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js index 05681796e..d5c0953b9 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js @@ -1,91 +1,92 @@ -var tableauQuestion = [ +// eslint-disable-next-line no-unused-vars +const tableauQuestion = [ { - question: "Se stai andando a 80 km/h, e ti stai avvicinando a una zona residenziale devi::", - propositionA: "Accellerare", - propositionB: "Mantieni la velocità, se non sorpassi altri veicoli", - propositionC: "Rallenti", - propositionD: "Mantieni la velocità", - reponse: "C" + question: 'Se stai andando a 80 km/h, e ti stai avvicinando a una zona residenziale devi::', + propositionA: 'Accellerare', + propositionB: 'Mantieni la velocità, se non sorpassi altri veicoli', + propositionC: 'Rallenti', + propositionD: 'Mantieni la velocità', + reponse: 'C', }, { - question: "Se al semaforo stai svoltando a destra, ma vedi un pedone cosa fai:", - propositionA: "Superi il pedone", - propositionB: "Controlli che non ci siano altri veicoli in giro", - propositionC: "Aspetti che il pedone abbia attraversato", - propositionD: "Spari al pedone e continui a guidare", - reponse: "C" + question: 'Se al semaforo stai svoltando a destra, ma vedi un pedone cosa fai:', + propositionA: 'Superi il pedone', + propositionB: 'Controlli che non ci siano altri veicoli in giro', + propositionC: 'Aspetti che il pedone abbia attraversato', + propositionD: 'Spari al pedone e continui a guidare', + reponse: 'C', }, { - question: "Senza alcuna indicazione preventiva, la velocità in una zona residenziale è: __ km/h", - propositionA: "30 km/h", - propositionB: "50 km/h", - propositionC: "40 km/h", - propositionD: "60 km/h", - reponse: "B" + question: 'Senza alcuna indicazione preventiva, la velocità in una zona residenziale è: __ km/h', + propositionA: '30 km/h', + propositionB: '50 km/h', + propositionC: '40 km/h', + propositionD: '60 km/h', + reponse: 'B', }, { - question: "Prima di ogni cambio si corsia devi:", - propositionA: "Controllare gli specchietti", - propositionB: "Controllare i punti ciechi", - propositionC: "Segnalare le tue intenzioni", - propositionD: "Tutte le risposte sono esatte", - reponse: "D" + question: 'Prima di ogni cambio si corsia devi:', + propositionA: 'Controllare gli specchietti', + propositionB: 'Controllare i punti ciechi', + propositionC: 'Segnalare le tue intenzioni', + propositionD: 'Tutte le risposte sono esatte', + reponse: 'D', }, { - question: "Quale livello di alcol nel sangue è classificato come guida in stato di ebbrezza?", - propositionA: "0.05%", - propositionB: "0.18%", - propositionC: "0.08%", - propositionD: "0.06%", - reponse: "C" + question: 'Quale livello di alcol nel sangue è classificato come guida in stato di ebbrezza?', + propositionA: '0.05%', + propositionB: '0.18%', + propositionC: '0.08%', + propositionD: '0.06%', + reponse: 'C', }, { - question: "Quando puoi continuare a guidare a un semaforo?", - propositionA: "Quando è verde", - propositionB: "Quando non c'è nessuno all'incrocio", - propositionC: "Quando sei in una zona scolastca", - propositionD: "Quando è verde e/o rosso e stai girando a destra", - reponse: "D" + question: 'Quando puoi continuare a guidare a un semaforo?', + propositionA: 'Quando è verde', + propositionB: 'Quando non c\'è nessuno all\'incrocio', + propositionC: 'Quando sei in una zona scolastca', + propositionD: 'Quando è verde e/o rosso e stai girando a destra', + reponse: 'D', }, { - question: "Un pedone ha un segnale di non attraversare, cosa fai?", - propositionA: "Li lasci passare", - propositionB: "Osservi prima di continuare", - propositionC: "Fai la mano per dire loro di attraversare", - propositionD: "Continui perchè il tuo semaforo è verde", - reponse: "D" + question: 'Un pedone ha un segnale di non attraversare, cosa fai?', + propositionA: 'Li lasci passare', + propositionB: 'Osservi prima di continuare', + propositionC: 'Fai la mano per dire loro di attraversare', + propositionD: 'Continui perchè il tuo semaforo è verde', + reponse: 'D', }, { - question: "Cosa è consentito quando si supera un'altro veicolo", - propositionA: "Lo segui da vicino per superarlo velocemente", - propositionB: "Lo passi senza lasciare la carreggiata", - propositionC: "Si guida sul lato opposto della strada per passare", - propositionD: "Si supera il limite di velocità per superarli", - reponse: "C" + question: 'Cosa è consentito quando si supera un\'altro veicolo', + propositionA: 'Lo segui da vicino per superarlo velocemente', + propositionB: 'Lo passi senza lasciare la carreggiata', + propositionC: 'Si guida sul lato opposto della strada per passare', + propositionD: 'Si supera il limite di velocità per superarli', + reponse: 'C', }, { - question: "Stai guidando su un'autostrada che indica una velocità massima di 120 km/h. Ma la maggior parte dei trafficanti guida a 125 km/h, quindi non dovresti guidare più veloce di:", - propositionA: "120 km/h", - propositionB: "125 km/h", - propositionC: "130 km/h", - propositionD: "110 km/h", - reponse: "A" + question: 'Stai guidando su un\'autostrada che indica una velocità massima di 120 km/h. Ma la maggior parte dei trafficanti guida a 125 km/h, quindi non dovresti guidare più veloce di:', + propositionA: '120 km/h', + propositionB: '125 km/h', + propositionC: '130 km/h', + propositionD: '110 km/h', + reponse: 'A', }, { - question: "Quando vieni sorpassato da un altro veicolo è importane NON:", - propositionA: "Rallentare", - propositionB: "Controllare gli specchietti", - propositionC: "Guardare gli altri automobilisti", - propositionD: "Aumentare la tua velocità", - reponse: "D" + question: 'Quando vieni sorpassato da un altro veicolo è importane NON:', + propositionA: 'Rallentare', + propositionB: 'Controllare gli specchietti', + propositionC: 'Guardare gli altri automobilisti', + propositionD: 'Aumentare la tua velocità', + reponse: 'D', }, -] \ No newline at end of file +]; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js index 551f3bfb2..0bc20543a 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js @@ -1,16 +1,21 @@ // question variables -var questionNumber = 1; -var userAnswer = []; -var goodAnswer = []; -var questionUsed = []; -var nbQuestionToAnswer = 10; // don't forget to change the progress bar max value in html -var nbAnswerNeeded = 5; // out of nbQuestionToAnswer -var nbPossibleQuestions = 10; // number of questions in database questions.js -var lastClick = 0; +let questionNumber = 1; +let userAnswer = []; +let goodAnswer = []; +let questionUsed = []; +// eslint-disable-next-line no-inline-comments +const nbQuestionToAnswer = 10; // don't forget to change the progress bar max value in html +// eslint-disable-next-line no-inline-comments +const nbAnswerNeeded = 5; // out of nbQuestionToAnswer +// eslint-disable-next-line no-inline-comments +const nbPossibleQuestions = 10; // number of questions in database questions.js +// eslint-disable-next-line no-unused-vars +const lastClick = 0; function getRandomQuestion() { - var random = Math.floor(Math.random() * nbPossibleQuestions); + let random = Math.floor(Math.random() * nbPossibleQuestions); + // eslint-disable-next-line no-constant-condition while (true) { if (questionUsed.indexOf(random) === -1) { break; @@ -26,45 +31,45 @@ function getRandomQuestion() { // Partial Functions function closeMain() { - $(".home").css("display", "none"); + $('.home').css('display', 'none'); } function openMain() { - $(".home").css("display", "block"); + $('.home').css('display', 'block'); } function closeAll() { - $(".body").css("display", "none"); + $('.body').css('display', 'none'); } function openQuestionnaire() { - $(".questionnaire-container").css("display", "block"); - var randomQuestion = getRandomQuestion(); - - $("#questionNumero").html("Question: " + questionNumber); - $("#question").html(tableauQuestion[randomQuestion].question); - $(".answerA").html(tableauQuestion[randomQuestion].propositionA); - $(".answerB").html(tableauQuestion[randomQuestion].propositionB); - $(".answerC").html(tableauQuestion[randomQuestion].propositionC); - $(".answerD").html(tableauQuestion[randomQuestion].propositionD); + $('.questionnaire-container').css('display', 'block'); + const randomQuestion = getRandomQuestion(); + + $('#questionNumero').html('Question: ' + questionNumber); + $('#question').html(tableauQuestion[randomQuestion].question); + $('.answerA').html(tableauQuestion[randomQuestion].propositionA); + $('.answerB').html(tableauQuestion[randomQuestion].propositionB); + $('.answerC').html(tableauQuestion[randomQuestion].propositionC); + $('.answerD').html(tableauQuestion[randomQuestion].propositionD); $('input[name=question]').attr('checked', false); goodAnswer.push(tableauQuestion[randomQuestion].reponse); - $(".questionnaire-container .progression").val(questionNumber - 1); + $('.questionnaire-container .progression').val(questionNumber - 1); } function openResultGood() { - $(".resultGood").css("display", "block"); + $('.resultGood').css('display', 'block'); } function openResultBad() { - $(".resultBad").css("display", "block"); + $('.resultBad').css('display', 'block'); } function openContainer() { - $(".question-container").css("display", "block"); + $('.question-container').css('display', 'block'); } function closeContainer() { - $(".question-container").css("display", "none"); + $('.question-container').css('display', 'none'); } // Listen for NUI Events -window.addEventListener('message', function (event) { - var item = event.data; +window.addEventListener('message', function(event) { + const item = event.data; // Open & Close main window if (item.openQuestion == true) { @@ -78,18 +83,18 @@ window.addEventListener('message', function (event) { } // Open sub-windows / partials - if (item.openSection == "question") { + if (item.openSection == 'question') { closeAll(); openQuestionnaire(); } }); // Handle Button Presses -$(".btnQuestion").click(function () { +$('.btnQuestion').click(function() { $.post('http://bpt_dmvschool/question', JSON.stringify({})); }); -$(".btnClose").click(function () { +$('.btnClose').click(function() { $.post('http://bpt_dmvschool/close', JSON.stringify({})); userAnswer = []; goodAnswer = []; @@ -97,7 +102,7 @@ $(".btnClose").click(function () { questionNumber = 1; }); -$(".btnKick").click(function () { +$('.btnKick').click(function() { $.post('http://bpt_dmvschool/kick', JSON.stringify({})); userAnswer = []; goodAnswer = []; @@ -106,19 +111,20 @@ $(".btnKick").click(function () { }); // Handle Form Submits -$("#question-form").submit(function (e) { +$('#question-form').submit(function(e) { e.preventDefault(); if (questionNumber != nbQuestionToAnswer) { - //question 1 to 9: pushing answer in array + // question 1 to 9: pushing answer in array closeAll(); userAnswer.push($('input[name="question"]:checked').val()); questionNumber++; openQuestionnaire(); - } else { + } + else { // question 10: comparing arrays and sending number of good answers userAnswer.push($('input[name="question"]:checked').val()); - var nbGoodAnswer = 0; + let nbGoodAnswer = 0; for (i = 0; i < nbQuestionToAnswer; i++) { if (userAnswer[i] == goodAnswer[i]) { nbGoodAnswer++; @@ -128,7 +134,8 @@ $("#question-form").submit(function (e) { closeAll(); if (nbGoodAnswer >= nbAnswerNeeded) { openResultGood(); - } else { + } + else { openResultBad(); } }