diff --git a/main.js b/main.js index 001207f..8fae5a8 100644 --- a/main.js +++ b/main.js @@ -22,7 +22,7 @@ var data; // all data, which is in the resource txt var addEventListener; // add event listener function -var lastChangeLog = '- Csak egy plusz weboldal gomb a menüben.'; // TODO +var lastChangeLog = '- Kérdések adatstruktúra változtatás. Ha jól csináltam, akkor semmit se kellene észrevenni. \n Ha nem, akkor weboldalon lehet hibát jelezni!'; var serverAdress = "http://questionmining.tk/"; // forcing pages for testing. unless you test, do not set these to true! @@ -224,7 +224,6 @@ class QuestionDB { //: Main function {{{ function Main() { 'use strict'; - console.clear(); // TODO Init(function(count) { var url = location.href; try { @@ -825,7 +824,11 @@ function ParseRawData(data) { // dont allow overwriting // ?!>>> if (!currQuestion.HasImage()) { - currQuestion.I = JSON.parse(currData); + try { + currQuestion.I = JSON.parse(currData); + } catch (e) { + currQuestion.I = [currData]; + } } ExpectedIdentifier = ['?', '+']; continue; @@ -886,8 +889,6 @@ function NLoad(resource, cwith) { allCount += j; r.AddSubject(s); } - console.log(r); - console.log(rt); data = r; count = allCount + 1; // couse starting with -1 to show errors } catch (e) { @@ -1035,7 +1036,6 @@ function HandleUI(url, count) { timeout = null; GM_setValue("motdcount", motdcount); } - } } ShowMessage({ @@ -1098,7 +1098,7 @@ function ShowSaveQuizDialog(addedQ, allQ, allOutput, output, sendSuccess, sentDa function SearchSameQuestion(questionData, quiz, i) { var r = questionData.Search(quiz[i]); - return r.length; + return r.length == 0 ? -1 : r.length; } // this should get the image url from a result page @@ -1157,11 +1157,8 @@ function SaveQuiz(quiz, questionData) { allOutput += toAdd; // adding to all allQ++; } - console.log("QUIZ:"); - console.log(quiz); - console.log(newQuestions); // TODO: test this var sendSuccess = false; - var sentData = "undefined"; + var sentData = {}; try { var subj = "NOSUBJ"; try { @@ -1171,10 +1168,10 @@ function SaveQuiz(quiz, questionData) { } var useNetDB = GM_getValue("useNetDB"); if (useNetDB != undefined && useNetDB == 1) { - sentData = "datatoadd=alldata<=>" + JSON.stringify(quiz) + "<#>data<=>" + JSON.stringify( - newQuestions) + "<#>subj<=>" + subj; - console.log(sentData); // TODO - SendXHRMessage(sentData); + sentData.allData = quiz; + sentData.data = newQuestions; + sentData.subj = subj; + SendXHRMessage("datatoadd=" + JSON.stringify(sentData)); sendSuccess = true; } } catch (e) {