Merge branch 'master' into new_result_processing

This commit is contained in:
mrfry 2020-11-19 13:38:20 +01:00
commit e0c2e92578

View file

@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
// @version 2.0.1.18
// @version 2.0.1.21
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
@ -101,6 +101,11 @@
var lastestVersion = ''
var subjInfo
// array, where elems are added to shadow-root, but its position should be at target.
var updatableElements = [] // { elem: ..., target: ... }
var elementUpdaterInterval = -1
const overlayElemUpdateInterval = 2 // seconds
if (getVal('ISDEVEL')) {
console.log('Moodle script running in developement mode!')
infoExpireTime = 1
@ -512,15 +517,21 @@
overlay.appendChild(toAppend)
}
function createHoverOver(target) {
function createHoverOver(appendTo) {
const overlayElement = document.createElement('div')
overlay.append(overlayElement)
updatableElements.push({ elem: overlayElement, target: appendTo })
if (elementUpdaterInterval === -1) {
elementUpdaterInterval = setInterval(() => {
updatableElements.forEach(({ elem, target }) => {
let currX, currY, currWidth, currHeight
let { left, top, width, height } = target.getBoundingClientRect()
left += window.scrollX
top += window.scrollY
SetStyle(overlayElement, {
SetStyle(elem, {
pointerEvents: 'none',
userSelect: 'none',
position: 'absolute',
@ -530,6 +541,9 @@
width: width + 'px',
height: height - 10 + 'px',
})
})
}, overlayElemUpdateInterval * 1000)
}
return overlayElement
}
@ -1285,6 +1299,25 @@
mainDiv.style.top = mousePosition.y + offset[1] + 'px'
}
})
const xrow = document.createElement('div')
SetStyle(xrow, {
height: '20px',
display: 'flex',
justifyContent: 'flex-end',
})
mainDiv.appendChild(xrow)
const xButton = CreateNodeWithText(xrow, '❌', 'div')
SetStyle(xButton, {
margin: '5px',
cursor: 'pointer',
})
xButton.addEventListener('mousedown', e => {
e.stopPropagation()
mainDiv.parentNode.removeChild(mainDiv)
})
// ------------------------------------------------------------------
var matchPercent = msgItem[0][0].p
if (isSimpleMessage) {
@ -1400,8 +1433,6 @@
percentTextBox.innerText = relevantQuestion.p + '%'
}
var buttonMargin = '2px 2px 2px 2px' // uniform button margin
if (msgItem[currItem].length > 1) {
const buttonStyle = {
color: 'white',
backgroundColor: 'transparent',
@ -1409,7 +1440,10 @@
border: 'none',
fontSize: '30px',
cursor: 'pointer',
userSelect: 'none',
}
var buttonMargin = '2px 2px 2px 2px' // uniform button margin
if (msgItem[currItem].length > 1) {
// PREV SUGG BUTTON ------------------------------------------------------------------------------------------------------------
var prevSuggButton = CreateNodeWithText(
prevSuggestionCell,
@ -1443,8 +1477,8 @@
} else {
// if there are multiple items to display
// PREV QUESTION BUTTON ------------------------------------------------------------------------------------------------------------
var prevButton = CreateNodeWithText(prevQuestionCell, '^', 'button')
prevButton.style.margin = buttonMargin // fancy margin
var prevButton = CreateNodeWithText(prevQuestionCell, '⬆️', 'div')
SetStyle(prevButton, buttonStyle)
// event listener
prevButton.addEventListener('click', function() {
@ -1452,8 +1486,8 @@
SetQuestionText()
})
// NEXT QUESTION BUTTON ------------------------------------------------------------------------------------------------------------
var nextButton = CreateNodeWithText(nextQuestionCell, 'ˇ', 'button')
nextButton.style.margin = buttonMargin // fancy margin
var nextButton = CreateNodeWithText(nextQuestionCell, '⬇️', 'div')
SetStyle(nextButton, buttonStyle)
// event listener
nextButton.addEventListener('click', function() {