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`
|
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
|
// FIXME: if cwith() throws an unhandled error it sais server is not avaible
|
||||||
cwith()
|
cwith()
|
||||||
}).catch((err) => {
|
}).catch(() => {
|
||||||
document.getElementById('menuButtonDiv').style.backgroundColor = 'red'
|
document.getElementById('menuButtonDiv').style.backgroundColor = 'red'
|
||||||
document.getElementById('infoMainDiv').innerText = texts.noServer
|
document.getElementById('infoMainDiv').innerText = texts.noServer
|
||||||
console.log(err)
|
|
||||||
console.log('haaaaaaaa')
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,9 +1505,13 @@
|
||||||
let passiveButton = CreateNodeWithText(buttonCell, texts.passiveMode, 'button')
|
let passiveButton = CreateNodeWithText(buttonCell, texts.passiveMode, 'button')
|
||||||
SetStyle(passiveButton, buttonStyle)
|
SetStyle(passiveButton, buttonStyle)
|
||||||
|
|
||||||
let setPassiveButtonState = (isPassive) => {
|
let setPassiveButtonState = (isPassive, connect) => {
|
||||||
if (isPassive) {
|
menuButtonDiv.style.background = '#262626'
|
||||||
|
if (!isPassive) {
|
||||||
|
infoDiv.innerText = texts.loading
|
||||||
|
if (connect) {
|
||||||
ConnectToServer(AfterLoad)
|
ConnectToServer(AfterLoad)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
infoDiv.innerText = texts.passiveModeMenuBoxText
|
infoDiv.innerText = texts.passiveModeMenuBoxText
|
||||||
}
|
}
|
||||||
|
@ -1517,11 +1519,11 @@
|
||||||
setPassiveButtonState(getVal('skipLoad'))
|
setPassiveButtonState(getVal('skipLoad'))
|
||||||
|
|
||||||
passiveButton.addEventListener('click', function () {
|
passiveButton.addEventListener('click', function () {
|
||||||
let sl = getVal('skipLoad')
|
let sl = !getVal('skipLoad')
|
||||||
setVal('skipLoad', !sl)
|
setVal('skipLoad', sl)
|
||||||
setPassiveButtonState(sl)
|
setPassiveButtonState(sl, true)
|
||||||
|
|
||||||
if (!sl) {
|
if (sl) {
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: texts.passiveModeActivated,
|
m: texts.passiveModeActivated,
|
||||||
isSimple: true
|
isSimple: true
|
||||||
|
@ -1573,8 +1575,8 @@
|
||||||
resolve(JSON.parse(response.responseText))
|
resolve(JSON.parse(response.responseText))
|
||||||
},
|
},
|
||||||
onerror: (e) => {
|
onerror: (e) => {
|
||||||
console.log('GET ERROR', e)
|
Log('Info get Error', e)
|
||||||
reject(new Error('get error'))
|
reject(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1604,8 +1606,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onerror: (e) => {
|
onerror: (e) => {
|
||||||
console.log('GET ERROR', e)
|
Log('Question answer get error', e)
|
||||||
reject(new Error('get error'))
|
reject(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1621,12 +1623,11 @@
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
},
|
},
|
||||||
onerror: function (response) {
|
onerror: function (e) {
|
||||||
Log('XMLHTTP request POST error')
|
Log('Data send error', e)
|
||||||
reject(new Error('unhandled error'))
|
reject(e)
|
||||||
},
|
},
|
||||||
onload: (resp) => {
|
onload: (resp) => {
|
||||||
console.log(resp.responseText)
|
|
||||||
resolve(JSON.parse(resp.responseText))
|
resolve(JSON.parse(resp.responseText))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue