From 8755905a33d875e5feb16ce28701adcc08111b76 Mon Sep 17 00:00:00 2001 From: gonzalezL Date: Thu, 6 Dec 2018 02:49:37 -0500 Subject: [PATCH] Dashboard Refactor #1.5 --- web/dashboard.html | 102 +++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 59 deletions(-) diff --git a/web/dashboard.html b/web/dashboard.html index c480f1c..fbf38a0 100644 --- a/web/dashboard.html +++ b/web/dashboard.html @@ -333,67 +333,40 @@
Total Score = ${item.score}%
`; console.log(currentExam); $.ajax( { - type: "POST", - url: BASE_URL + "test", - data: JSON.stringify( - { - "token": token - }), - dataType: "json", - success: function (data, textStatus, jqXHR) - { - console.log("reloadJSON success") - - userJSON = data; - - if(pageToLoad === 0) // Home, deleteExam, addExam (G) + type: "POST", + url: BASE_URL + "test", + data: JSON.stringify( { - clearPage(); - } - else if(pageToLoad === 1) //dropdown, testGrid + "token": token + }), + dataType: "json", + success: function (data, textStatus, jqXHR) { - console.log() - currentExam = userJSON.find(item => item.id === currentExam.id); - loadSidebar(); - } - else // addExam (S) - { - currentExam = userJSON.find(item => item.id === currentExam.id); - loadTerminal(); - } + console.log("reloadJSON success") - /* - if(isTeacher) - { - if(pageToLoad === 0) + userJSON = data; + + if(pageToLoad === 0) // Home, deleteExam, addExam (G) { - outer = userJSON; - fillGrid(userJSON); - $('#sidebar').hide(); - $('#pageContent').hide(); + clearPage(); } - else if(pageToLoad === 1) // leave currently selected exam + else if(pageToLoad === 1) //dropdown, testGrid { - outer = outer.inner.find(item => item.id === userJSON.id); - loadTerminal(userJSON, outer); + console.log() + currentExam = userJSON.find(item => item.id === currentExam.id); + loadSidebar(); } - } - else - { - if(pageToLoad === 0) + else // addExam (S) { - outer = userJSON; - fillNavBar(userJSON.inner); - $('#pageContent').hide(); + currentExam = userJSON.find(item => item.id === currentExam.id); + loadTerminal(); } - } - console.log(userJSON);*/ - }, - error: function (jqXHR, textStatus, errorThrown) - { - console.log("connection error"); - } + }, + error: function (jqXHR, textStatus, errorThrown) + { + console.log("connection error"); + } }); } @@ -401,15 +374,26 @@
Total Score = ${item.score}%
`; // DOCUMENT READY $(document).ready(function () { - //RUN FOR MOCK DATA + $.ajax( { - isTeacher = 1; - console.log(`load ${isTeacher}`); - userJSON = isTeacher? teacherJSON : studentJSON; - } - console.log($('#sidebar').is(":visible")); - clearPage(); - + type: "POST", + url: BASE_URL + "test", + data: JSON.stringify( + { + "token": token + }), + dataType: "json", + success: function (data, textStatus, jqXHR) + { + userMode = ($.isArray(data))? 1:0; + userJSON = data; + clearPage(); + }, + error: function (jqXHR, textStatus, errorThrown) + { + console.log("connection error"); + } + }); // Sidebar clicked => load this table