mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
peer selector improvements
This commit is contained in:
parent
2ee9731fdf
commit
28a2ffdaca
1 changed files with 14 additions and 7 deletions
|
@ -105,6 +105,7 @@
|
|||
const motdShowCount = 5 // Ammount of times to show motd
|
||||
let infoExpireTime = 60 * 5 // Every n seconds basic info should be (re)loaded from server
|
||||
let p2pInfoExpireTime = 60 * 60 * 24
|
||||
let loggedIn = false
|
||||
const messageOpacityDelta = 0.1
|
||||
const minMessageOpacity = 0.2
|
||||
|
||||
|
@ -1686,6 +1687,7 @@
|
|||
NoUserAction()
|
||||
return
|
||||
}
|
||||
loggedIn = true
|
||||
lastestVersion = inf.version.replace(/\n/g, '')
|
||||
motd = inf.motd
|
||||
if (getUid() !== inf.uid) {
|
||||
|
@ -1780,7 +1782,10 @@
|
|||
return getPeerUrl(x) === getPeerUrl(peer)
|
||||
})
|
||||
if (!peerAlreadyExists) {
|
||||
setVal('peers', JSON.stringify([peer, ...peers]))
|
||||
setJSONVal('peers', [peer, ...peers])
|
||||
SafeGetElementById('peerSelector', (elem) => {
|
||||
updatePeerSelector(elem)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1851,6 +1856,7 @@
|
|||
SafeGetElementById('peerSelector', (elem) => {
|
||||
elem.style.display = ''
|
||||
})
|
||||
loggedIn = false
|
||||
}
|
||||
|
||||
function addNewHost() {
|
||||
|
@ -1872,6 +1878,9 @@
|
|||
SafeGetElementById('hostInputContainer', (elem) => {
|
||||
elem.style.display = 'flex'
|
||||
})
|
||||
SafeGetElementById('loginDiv', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
}
|
||||
|
||||
function addHost(val) {
|
||||
|
@ -2786,7 +2795,7 @@
|
|||
margin: '4px 0px',
|
||||
})
|
||||
|
||||
const peers = getJSONVal('peers')
|
||||
const peers = getJSONVal('peers') || []
|
||||
|
||||
peers.forEach((peer, i) => {
|
||||
const option = document.createElement('option')
|
||||
|
@ -2853,8 +2862,6 @@
|
|||
resetMenu()
|
||||
SafeGetElementById('peerSelector', (elem) => {
|
||||
elem.style.display = ''
|
||||
})
|
||||
SafeGetElementById('peerSelector', (elem) => {
|
||||
updatePeerSelector(elem)
|
||||
})
|
||||
SafeGetElementById('infoMainDiv', (elem) => {
|
||||
|
@ -2862,6 +2869,9 @@
|
|||
elem.innerText = `${subjInfo.subjects.toLocaleString()} tárgy, ${subjInfo.questions.toLocaleString()} kérdés`
|
||||
}
|
||||
})
|
||||
if (!loggedIn) {
|
||||
NoUserAction()
|
||||
}
|
||||
},
|
||||
},
|
||||
connectButton: {
|
||||
|
@ -2937,9 +2947,6 @@
|
|||
function updatePeerSelector(selector) {
|
||||
try {
|
||||
const peers = getJSONVal('peers')
|
||||
if (serverToUse) {
|
||||
peers.push(serverToUse)
|
||||
}
|
||||
|
||||
const selectedPeer = getJSONVal('serverToUse')
|
||||
const selectedIndex = peers.findIndex((x) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue