mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Passive mode fix, console.log removes, passing xmlhttprequest errors to reject()
This commit is contained in:
parent
acdb692f12
commit
b5d83f0bde
1 changed files with 19 additions and 18 deletions
|
@ -775,11 +775,9 @@
|
|||
document.getElementById('infoMainDiv').innerText = `${subjInfo.subjects} tárgy, ${subjInfo.questions} kérdés`
|
||||
// FIXME: if cwith() throws an unhandled error it sais server is not avaible
|
||||
cwith()
|
||||
}).catch((err) => {
|
||||
}).catch(() => {
|
||||
document.getElementById('menuButtonDiv').style.backgroundColor = 'red'
|
||||
document.getElementById('infoMainDiv').innerText = texts.noServer
|
||||
console.log(err)
|
||||
console.log('haaaaaaaa')
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1507,9 +1505,13 @@
|
|||
let passiveButton = CreateNodeWithText(buttonCell, texts.passiveMode, 'button')
|
||||
SetStyle(passiveButton, buttonStyle)
|
||||
|
||||
let setPassiveButtonState = (isPassive) => {
|
||||
if (isPassive) {
|
||||
ConnectToServer(AfterLoad)
|
||||
let setPassiveButtonState = (isPassive, connect) => {
|
||||
menuButtonDiv.style.background = '#262626'
|
||||
if (!isPassive) {
|
||||
infoDiv.innerText = texts.loading
|
||||
if (connect) {
|
||||
ConnectToServer(AfterLoad)
|
||||
}
|
||||
} else {
|
||||
infoDiv.innerText = texts.passiveModeMenuBoxText
|
||||
}
|
||||
|
@ -1517,11 +1519,11 @@
|
|||
setPassiveButtonState(getVal('skipLoad'))
|
||||
|
||||
passiveButton.addEventListener('click', function () {
|
||||
let sl = getVal('skipLoad')
|
||||
setVal('skipLoad', !sl)
|
||||
setPassiveButtonState(sl)
|
||||
let sl = !getVal('skipLoad')
|
||||
setVal('skipLoad', sl)
|
||||
setPassiveButtonState(sl, true)
|
||||
|
||||
if (!sl) {
|
||||
if (sl) {
|
||||
ShowMessage({
|
||||
m: texts.passiveModeActivated,
|
||||
isSimple: true
|
||||
|
@ -1573,8 +1575,8 @@
|
|||
resolve(JSON.parse(response.responseText))
|
||||
},
|
||||
onerror: (e) => {
|
||||
console.log('GET ERROR', e)
|
||||
reject(new Error('get error'))
|
||||
Log('Info get Error', e)
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -1604,8 +1606,8 @@
|
|||
}
|
||||
},
|
||||
onerror: (e) => {
|
||||
console.log('GET ERROR', e)
|
||||
reject(new Error('get error'))
|
||||
Log('Question answer get error', e)
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -1621,12 +1623,11 @@
|
|||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
onerror: function (response) {
|
||||
Log('XMLHTTP request POST error')
|
||||
reject(new Error('unhandled error'))
|
||||
onerror: function (e) {
|
||||
Log('Data send error', e)
|
||||
reject(e)
|
||||
},
|
||||
onload: (resp) => {
|
||||
console.log(resp.responseText)
|
||||
resolve(JSON.parse(resp.responseText))
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue