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
|
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 infoExpireTime = 60 * 5 // Every n seconds basic info should be (re)loaded from server
|
||||||
let p2pInfoExpireTime = 60 * 60 * 24
|
let p2pInfoExpireTime = 60 * 60 * 24
|
||||||
|
let loggedIn = false
|
||||||
const messageOpacityDelta = 0.1
|
const messageOpacityDelta = 0.1
|
||||||
const minMessageOpacity = 0.2
|
const minMessageOpacity = 0.2
|
||||||
|
|
||||||
|
@ -1686,6 +1687,7 @@
|
||||||
NoUserAction()
|
NoUserAction()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
loggedIn = true
|
||||||
lastestVersion = inf.version.replace(/\n/g, '')
|
lastestVersion = inf.version.replace(/\n/g, '')
|
||||||
motd = inf.motd
|
motd = inf.motd
|
||||||
if (getUid() !== inf.uid) {
|
if (getUid() !== inf.uid) {
|
||||||
|
@ -1780,7 +1782,10 @@
|
||||||
return getPeerUrl(x) === getPeerUrl(peer)
|
return getPeerUrl(x) === getPeerUrl(peer)
|
||||||
})
|
})
|
||||||
if (!peerAlreadyExists) {
|
if (!peerAlreadyExists) {
|
||||||
setVal('peers', JSON.stringify([peer, ...peers]))
|
setJSONVal('peers', [peer, ...peers])
|
||||||
|
SafeGetElementById('peerSelector', (elem) => {
|
||||||
|
updatePeerSelector(elem)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1851,6 +1856,7 @@
|
||||||
SafeGetElementById('peerSelector', (elem) => {
|
SafeGetElementById('peerSelector', (elem) => {
|
||||||
elem.style.display = ''
|
elem.style.display = ''
|
||||||
})
|
})
|
||||||
|
loggedIn = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNewHost() {
|
function addNewHost() {
|
||||||
|
@ -1872,6 +1878,9 @@
|
||||||
SafeGetElementById('hostInputContainer', (elem) => {
|
SafeGetElementById('hostInputContainer', (elem) => {
|
||||||
elem.style.display = 'flex'
|
elem.style.display = 'flex'
|
||||||
})
|
})
|
||||||
|
SafeGetElementById('loginDiv', (elem) => {
|
||||||
|
elem.style.display = 'none'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHost(val) {
|
function addHost(val) {
|
||||||
|
@ -2786,7 +2795,7 @@
|
||||||
margin: '4px 0px',
|
margin: '4px 0px',
|
||||||
})
|
})
|
||||||
|
|
||||||
const peers = getJSONVal('peers')
|
const peers = getJSONVal('peers') || []
|
||||||
|
|
||||||
peers.forEach((peer, i) => {
|
peers.forEach((peer, i) => {
|
||||||
const option = document.createElement('option')
|
const option = document.createElement('option')
|
||||||
|
@ -2853,8 +2862,6 @@
|
||||||
resetMenu()
|
resetMenu()
|
||||||
SafeGetElementById('peerSelector', (elem) => {
|
SafeGetElementById('peerSelector', (elem) => {
|
||||||
elem.style.display = ''
|
elem.style.display = ''
|
||||||
})
|
|
||||||
SafeGetElementById('peerSelector', (elem) => {
|
|
||||||
updatePeerSelector(elem)
|
updatePeerSelector(elem)
|
||||||
})
|
})
|
||||||
SafeGetElementById('infoMainDiv', (elem) => {
|
SafeGetElementById('infoMainDiv', (elem) => {
|
||||||
|
@ -2862,6 +2869,9 @@
|
||||||
elem.innerText = `${subjInfo.subjects.toLocaleString()} tárgy, ${subjInfo.questions.toLocaleString()} kérdés`
|
elem.innerText = `${subjInfo.subjects.toLocaleString()} tárgy, ${subjInfo.questions.toLocaleString()} kérdés`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (!loggedIn) {
|
||||||
|
NoUserAction()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
connectButton: {
|
connectButton: {
|
||||||
|
@ -2937,9 +2947,6 @@
|
||||||
function updatePeerSelector(selector) {
|
function updatePeerSelector(selector) {
|
||||||
try {
|
try {
|
||||||
const peers = getJSONVal('peers')
|
const peers = getJSONVal('peers')
|
||||||
if (serverToUse) {
|
|
||||||
peers.push(serverToUse)
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedPeer = getJSONVal('serverToUse')
|
const selectedPeer = getJSONVal('serverToUse')
|
||||||
const selectedIndex = peers.findIndex((x) => {
|
const selectedIndex = peers.findIndex((x) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue