mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Passive mode
This commit is contained in:
parent
65819a44b8
commit
b9beca75a2
1 changed files with 77 additions and 31 deletions
|
@ -89,7 +89,11 @@
|
||||||
donate: 'Donate',
|
donate: 'Donate',
|
||||||
search: 'Keresés ...',
|
search: 'Keresés ...',
|
||||||
loading: 'Betöltés ...',
|
loading: 'Betöltés ...',
|
||||||
noServer: 'Nem elérhető a szerver!'
|
noServer: 'Nem elérhető a szerver!',
|
||||||
|
passiveModeActivated: 'Passzív mód bekapcsolva, nem lesz mostantól a szerver piszkálva',
|
||||||
|
passiveModeDeactivated: 'Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!',
|
||||||
|
passiveMode: 'Passzív mód',
|
||||||
|
passiveModeMenuBoxText: 'Passzív mód aktív'
|
||||||
}
|
}
|
||||||
|
|
||||||
var texts = huTexts
|
var texts = huTexts
|
||||||
|
@ -676,12 +680,22 @@
|
||||||
// : }}}
|
// : }}}
|
||||||
|
|
||||||
// : Main function {{{
|
// : Main function {{{
|
||||||
|
let timerStarted = false
|
||||||
|
|
||||||
Main()
|
Main()
|
||||||
function Main () {
|
function Main () {
|
||||||
'use strict'
|
'use strict'
|
||||||
console.time('main')
|
console.time('main')
|
||||||
|
timerStarted = true
|
||||||
|
|
||||||
Init(function () {
|
Init(AfterLoad)
|
||||||
|
|
||||||
|
if (forceTestPage || forceResultPage || forceDefaultPage) {
|
||||||
|
if (document.getElementById('scriptMessage')) { document.getElementById('scriptMessage').style.background = 'green' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function AfterLoad () {
|
||||||
var url = location.href // eslint-disable-line
|
var url = location.href // eslint-disable-line
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -706,12 +720,10 @@
|
||||||
if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys
|
if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys
|
||||||
Log(texts.consoleErrorInfo)
|
Log(texts.consoleErrorInfo)
|
||||||
|
|
||||||
|
if (timerStarted) {
|
||||||
console.log('Moodle Test Script run time:')
|
console.log('Moodle Test Script run time:')
|
||||||
console.timeEnd('main')
|
console.timeEnd('main')
|
||||||
})
|
timerStarted = false
|
||||||
|
|
||||||
if (forceTestPage || forceResultPage || forceDefaultPage) {
|
|
||||||
if (document.getElementById('scriptMessage')) { document.getElementById('scriptMessage').style.background = 'green' }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// : }}}
|
// : }}}
|
||||||
|
@ -750,6 +762,12 @@
|
||||||
}
|
}
|
||||||
VersionActions()
|
VersionActions()
|
||||||
if (!url.includes('.pdf')) { ShowMenu() }
|
if (!url.includes('.pdf')) { ShowMenu() }
|
||||||
|
if (!getVal('skipLoad')) {
|
||||||
|
ConnectToServer(cwith)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ConnectToServer (cwith) {
|
||||||
GetXHRInfos().then((inf) => {
|
GetXHRInfos().then((inf) => {
|
||||||
lastestVersion = inf.version
|
lastestVersion = inf.version
|
||||||
motd = inf.motd
|
motd = inf.motd
|
||||||
|
@ -1468,14 +1486,16 @@
|
||||||
SetStyle(donateLink, buttonStyle)
|
SetStyle(donateLink, buttonStyle)
|
||||||
|
|
||||||
donateLink.addEventListener('click', function () {
|
donateLink.addEventListener('click', function () {
|
||||||
location.href = serverAdress + 'donate' // eslint-disable-line
|
openInTab(serverAdress + 'donate', {
|
||||||
|
active: true
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
addEventListener(window, 'resize', function () {
|
addEventListener(window, 'resize', function () {
|
||||||
menuButtonDiv.style.top = (window.innerHeight - 70) + 'px'
|
menuButtonDiv.style.top = (window.innerHeight - 70) + 'px'
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: add this only after stuff loaded ( or not loaded )
|
// INFO DIV ---------------------------------------------------------------------------------
|
||||||
let infoDiv = CreateNodeWithText(menuButtonDiv, texts.loading, 'div')
|
let infoDiv = CreateNodeWithText(menuButtonDiv, texts.loading, 'div')
|
||||||
infoDiv.setAttribute('id', 'infoMainDiv')
|
infoDiv.setAttribute('id', 'infoMainDiv')
|
||||||
SetStyle(infoDiv, {
|
SetStyle(infoDiv, {
|
||||||
|
@ -1483,6 +1503,32 @@
|
||||||
margin: '5px'
|
margin: '5px'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// passive button ----------------------------------------------------------------------------------------------------------------
|
||||||
|
let passiveButton = CreateNodeWithText(buttonCell, texts.passiveMode, 'button')
|
||||||
|
SetStyle(passiveButton, buttonStyle)
|
||||||
|
|
||||||
|
let setPassiveButtonState = (isPassive) => {
|
||||||
|
if (isPassive) {
|
||||||
|
ConnectToServer(AfterLoad)
|
||||||
|
} else {
|
||||||
|
infoDiv.innerText = texts.passiveModeMenuBoxText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPassiveButtonState(getVal('skipLoad'))
|
||||||
|
|
||||||
|
passiveButton.addEventListener('click', function () {
|
||||||
|
let sl = getVal('skipLoad')
|
||||||
|
setVal('skipLoad', !sl)
|
||||||
|
setPassiveButtonState(sl)
|
||||||
|
|
||||||
|
if (!sl) {
|
||||||
|
ShowMessage({
|
||||||
|
m: texts.passiveModeActivated,
|
||||||
|
isSimple: true
|
||||||
|
}, 6)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
appedtTo.appendChild(menuButtonDiv)
|
appedtTo.appendChild(menuButtonDiv)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Exception(e, 'script error at showing menu:')
|
Exception(e, 'script error at showing menu:')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue