diff --git a/stable.user.js b/stable.user.js index aefdc4b..393dc6c 100755 --- a/stable.user.js +++ b/stable.user.js @@ -308,19 +308,16 @@ // : Test page processing functions {{{ function handleQuiz() { - const { removeMessage: removeLoadingMessage } = ShowMessage({ - m: texts.loadingAnswer, - isSimple: true, - }) + const { removeMessage: removeLoadingMessage } = ShowMessage( + texts.loadingAnswer + ) getQuizData() .then(readQuestions => { if (readQuestions.length === 0) { ShowMessage( - { - m: texts.unableToParseTestQuestion, - isSimple: true, - }, + texts.unableToParseTestQuestion, + undefined, () => { OpenErrorPage({ @@ -1003,10 +1000,8 @@ } } catch (e) { ShowMessage( - { - m: texts.fatalError, - isSimple: true, - }, + texts.fatalError, + undefined, () => { OpenErrorPage(e) @@ -1104,7 +1099,7 @@ post('login', { pw: pw, script: true }).then(res => { if (res.result === 'success') { ConnectToServer(AfterLoad) - ClearAllMessages() + clearAllMessages() resetMenu() } else { SafeGetElementById('infoMainDiv', elem => { @@ -1133,7 +1128,7 @@ } function ConnectToServer(cwith) { - ClearAllMessages() + clearAllMessages() GetXHRInfos() .then(inf => { if (inf.result === 'nouser') { @@ -1145,12 +1140,13 @@ if (getUid() !== inf.uid) { setVal('userId', inf.uid) } - userSpecificMotd = { - show: inf.userShouldGetUserSpecificMOTD, - text: inf.userSpecificMotd, - } + userSpecificMotd = inf.userSpecificMotd subjInfo = inf.subjinfo setVal('userId', inf.uid) + + overlay.querySelector('#mailButton').innerText = userSpecificMotd.seen + ? '📭' + : '📬' overlay.querySelector('#infoMainDiv').innerText = `${ subjInfo.subjects } tárgy, ${subjInfo.questions} kérdés. User ID: ${getUid()}` @@ -1227,14 +1223,13 @@ function HandleUI(url) { const newVersion = info().script.version !== getVal('lastVerson') const showMOTD = shouldShowMotd() - const showUserSpecificMOTD = userSpecificMotd.show const isNewVersionAvaible = lastestVersion !== undefined && info().script.version !== lastestVersion let timeout = null const greetMsg = [] - if (isNewVersionAvaible || newVersion || showMOTD || showUserSpecificMOTD) { + if (isNewVersionAvaible || newVersion || showMOTD) { greetMsg.push(texts.scriptName + info().script.version) } if (isNewVersionAvaible) { @@ -1253,16 +1248,10 @@ greetMsg.push(texts.motd + motd) timeout = null } - if (showUserSpecificMOTD) { - greetMsg.push(texts.userMOTD + userSpecificMotd.text) - timeout = null - } ShowMessage( - { - m: greetMsg.join('\n'), - isSimple: true, - }, + greetMsg.join('\n'), + timeout ) } @@ -1328,10 +1317,8 @@ ShowMessage(answers) } else { ShowMessage( - { - m: texts.noResult, - isSimple: true, - }, + texts.noResult, + undefined, function() { OpenErrorPage({ @@ -1370,10 +1357,8 @@ } // showing a message wit the click event, and the generated page ShowMessage( - { - m: msg, - isSimple: true, - }, + msg, + null, function() { let towrite = '' @@ -1393,10 +1378,7 @@ try { let sentData = {} if (quiz.length === 0) { - ShowMessage({ - m: texts.noParseableQuestionResult, - isSimple: true, - }) + ShowMessage(texts.noParseableQuestionResult) return } try { @@ -1530,7 +1512,7 @@ // : Show message, and script menu stuff {{{ - function ClearAllMessages() { + function clearAllMessages() { overlay.querySelectorAll('#scriptMessage').forEach(x => x.remove()) } @@ -1599,9 +1581,8 @@ let defMargin = '0px 5px' let isSimpleMessage = false let simpleMessageText = '' - if (msgItem.isSimple) { - // parsing msgItem for easier use - simpleMessageText = msgItem.m + if (typeof msgItem === 'string') { + simpleMessageText = msgItem if (simpleMessageText === '') { // if msg is empty return @@ -1985,6 +1966,32 @@ menuButtonDiv.parentNode.removeChild(menuButtonDiv) }) + const mailButton = CreateNodeWithText(menuButtonDiv, '📭', 'div') + mailButton.setAttribute('id', 'mailButton') + SetStyle(mailButton, { + fontSize: '30px', + cursor: 'pointer', + position: 'absolute', + left: '0px', + bottom: '0px', + display: 'inline', + margin: '5px', + }) + mailButton.addEventListener('mousedown', e => { + e.stopPropagation() + if (!userSpecificMotd.seen) { + mailButton.innerText = '📭' + clearAllMessages() + ShowMessage( + 'Üzenet oldal készítéjétől (csak te látod):\n' + + userSpecificMotd.msg + ) + post('infos', { + userSpecificMotdSeen: true, + }) + } + }) + var tbl = document.createElement('table') tbl.style.margin = '5px 5px 5px 5px' tbl.style.textAlign = 'left'