Greet message formatting

This commit is contained in:
MrFry 2020-01-27 11:16:44 +01:00
parent ccc6e849cf
commit 9bd0fa65e5

View file

@ -57,13 +57,13 @@
/* eslint-enable */ /* eslint-enable */
var addEventListener // add event listener function var addEventListener // add event listener function
// const serverAdress = 'https://qmining.frylabs.net/' const serverAdress = 'https://qmining.frylabs.net/'
const serverAdress = 'http://localhost:8080/' // const serverAdress = 'http://localhost:8080/'
// forcing pages for testing. unless you test, do not set these to true! // forcing pages for testing. unless you test, do not set these to true!
// only one of these should be true for testing // only one of these should be true for testing
const forceTestPage = false const forceTestPage = false
const forceResultPage = true const forceResultPage = false
const forceDefaultPage = false const forceDefaultPage = false
const logElementGetting = false const logElementGetting = false
const log = true const log = true
@ -746,23 +746,12 @@
} catch (e) { } catch (e) {
Log('Some weird error trying to set new verison') Log('Some weird error trying to set new verison')
} }
var greetMsg = '' // message to show at the end
var timeout = null // the timeout. if null, it wont be hidden let showMOTD = false
if (lastestVersion !== undefined && info().script.version !== lastestVersion) {
timeout = 5
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. '
greetMsg += 'Új verzió elérhető: ' + lastestVersion
timeout = undefined
}
if (newVersion) { // --------------------------------------------------------------------------------------------------------------
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. Verzió frissítve ' + info().script.version + '-re. Changelog:\n' + texts.lastChangeLog
setVal('lastVerson', info().script.version) // setting lastVersion
}
if (!SUtils.EmptyOrWhiteSpace(motd)) { if (!SUtils.EmptyOrWhiteSpace(motd)) {
var prevmotd = getVal('motd') var prevmotd = getVal('motd')
if (prevmotd !== motd) { if (prevmotd !== motd) {
greetMsg += '\nMOTD:\n' + motd showMOTD = true
timeout = null
setVal('motdcount', motdShowCount) setVal('motdcount', motdShowCount)
setVal('motd', motd) setVal('motd', motd)
} else { } else {
@ -774,12 +763,32 @@
motdcount-- motdcount--
if (motdcount > 0) { if (motdcount > 0) {
greetMsg += '\nMOTD:\n' + motd showMOTD = true
timeout = null
setVal('motdcount', motdcount) setVal('motdcount', motdcount)
} }
} }
} }
let isNewVersionAvaible = lastestVersion !== undefined && info().script.version !== lastestVersion
var greetMsg = '' // message to show at the end
var timeout = null // the timeout. if null, it wont be hidden
if (isNewVersionAvaible || newVersion || showMOTD) {
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. '
}
if (isNewVersionAvaible) {
timeout = 5
greetMsg += 'Új verzió elérhető: ' + lastestVersion
timeout = undefined
}
if (newVersion) { // --------------------------------------------------------------------------------------------------------------
greetMsg += 'Verzió frissítve ' + info().script.version + '-re. Changelog:\n' + texts.lastChangeLog
setVal('lastVerson', info().script.version) // setting lastVersion
}
if (showMOTD) {
greetMsg += '\nMOTD:\n' + motd
timeout = null
}
ShowMessage({ ShowMessage({
m: greetMsg, m: greetMsg,
isSimple: true isSimple: true