From ff25bff70e4cfd51fbbac8efce49501b8f00401a Mon Sep 17 00:00:00 2001 From: MrFry Date: Mon, 7 Oct 2019 11:23:31 +0200 Subject: [PATCH] Refactored error url generation --- CHANGELOG | 13 ------------- main.js | 51 +++++++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 35 deletions(-) delete mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 8ce9856..0000000 --- a/CHANGELOG +++ /dev/null @@ -1,13 +0,0 @@ -1.6.0.0: - Added JSON data format - Old one should still work -1.6.1.0: - Changed server domain name - Fixed not found data file "brick" -1.6.1.5: - Question answering/getting/parsing improvements - Passive mode -1.6.1.6: - Fixed question saving match percent -1.6.2.0: - Document element getting refactoring diff --git a/main.js b/main.js index cc0f04c..61db4e1 100644 --- a/main.js +++ b/main.js @@ -855,24 +855,8 @@ function Main () { ShowMessage({ m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!', isSimple: true - }, undefined, function () { - let path = 'lred' - try { - if (e.message || e.stack) { - path += '?' - } - if (e.message) { - path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&' - } - if (e.stack) { - path += 'stack:' + SUtils.SimplifyStack(e.stack) - } - } catch (e) { - Exception(e, 'error at setting error stack/msg link') - } - openInTab(serverAdress + path, { - active: true - }) + }, undefined, () => { + OpenErrorPage(e) }) Exception(e, 'script error at main:') @@ -1228,7 +1212,7 @@ function HandleQuiz () { if (r !== undefined) { answers.push(r) } HighLightAnswer(result, j) // highlights the answer for the current result } - ShowAnswers(answers) + ShowAnswers(answers, q.q) } function PrepareAnswers (result, j) { @@ -1254,7 +1238,7 @@ function PrepareAnswers (result, j) { } } -function ShowAnswers (answers) { +function ShowAnswers (answers, question) { assert(answers) if (answers.length > 0) { // if there are more than 0 answer @@ -1264,8 +1248,9 @@ function ShowAnswers (answers) { m: 'Nincs találat :( Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez! Előfordulhat, hogy a tárgyat nem válsztottad ki a menüben.', isSimple: true }, undefined, function () { - openInTab(serverAdress + 'lred', { - active: true + OpenErrorPage({ + message: 'No result found', + stack: question // TODO: test this }) }) } @@ -2198,6 +2183,28 @@ var assert = (val) => { if (!val) { throw new Error('Assertion failed') } } +function OpenErrorPage (e) { + let path = 'lred' + try { + if (e.message || e.stack) { + path += '?' + } + if (e.message) { + path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&' + } + if (e.stack) { + path += 'stack:' + SUtils.SimplifyStack(e.stack) + } + path = SUtils.RemoveSpecialChars(path) + } catch (e) { + Exception(e, 'error at setting error stack/msg link') + } + path = path.replace(/ /g, '_') + openInTab(serverAdress + path, { + active: true + }) +} + // : }}} // : Help {{{