mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
eslint format, site match order change
This commit is contained in:
parent
00ceb74ba7
commit
27211c7bc8
1 changed files with 119 additions and 118 deletions
237
stable.user.js
237
stable.user.js
|
@ -55,9 +55,8 @@
|
||||||
// @match https://itc.semmelweis.hu/moodle/*
|
// @match https://itc.semmelweis.hu/moodle/*
|
||||||
// @match https://moodle.gtk.uni-pannon.hu/*
|
// @match https://moodle.gtk.uni-pannon.hu/*
|
||||||
// @match https://oktatas.mai.kvk.uni-obuda.hu/*
|
// @match https://oktatas.mai.kvk.uni-obuda.hu/*
|
||||||
// @match https://qmining.frylabs.net/*
|
|
||||||
// @match http://qmining.frylabs.net/*
|
|
||||||
// @noframes
|
// @noframes
|
||||||
|
// @match https://qmining.frylabs.net/*
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @grant GM_getResourceText
|
// @grant GM_getResourceText
|
||||||
// @grant GM_info
|
// @grant GM_info
|
||||||
|
@ -75,7 +74,7 @@
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
// : }}}
|
// : }}}
|
||||||
|
|
||||||
;(function() {
|
;(function () {
|
||||||
// : ESLINT bs {{{
|
// : ESLINT bs {{{
|
||||||
|
|
||||||
// eslint-disable-line
|
// eslint-disable-line
|
||||||
|
@ -250,7 +249,7 @@
|
||||||
if (select.length > 0) {
|
if (select.length > 0) {
|
||||||
// test: 2c1d92a7-0ea2-4990-9451-7f19299bbbe4
|
// test: 2c1d92a7-0ea2-4990-9451-7f19299bbbe4
|
||||||
const question = []
|
const question = []
|
||||||
Array.from(elem.childNodes).forEach(cn => {
|
Array.from(elem.childNodes).forEach((cn) => {
|
||||||
if (cn.nodeValue) {
|
if (cn.nodeValue) {
|
||||||
question.push(cn.nodeValue)
|
question.push(cn.nodeValue)
|
||||||
}
|
}
|
||||||
|
@ -265,8 +264,8 @@
|
||||||
|
|
||||||
if (img.tagName === 'IMG') {
|
if (img.tagName === 'IMG') {
|
||||||
promises.push(
|
promises.push(
|
||||||
new Promise(resolve => {
|
new Promise((resolve) => {
|
||||||
digestMessage(getBase64Image(img)).then(res => {
|
digestMessage(getBase64Image(img)).then((res) => {
|
||||||
resolve({
|
resolve({
|
||||||
type: 'img',
|
type: 'img',
|
||||||
val: res,
|
val: res,
|
||||||
|
@ -312,7 +311,7 @@
|
||||||
|
|
||||||
function getLegacyImageID(imgArray) {
|
function getLegacyImageID(imgArray) {
|
||||||
try {
|
try {
|
||||||
return imgArray.map(img => {
|
return imgArray.map((img) => {
|
||||||
if (!img.src.includes('brokenfile')) {
|
if (!img.src.includes('brokenfile')) {
|
||||||
let filePart = img.src.split('/')
|
let filePart = img.src.split('/')
|
||||||
filePart = filePart[filePart.length - 1]
|
filePart = filePart[filePart.length - 1]
|
||||||
|
@ -350,7 +349,7 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
getQuizData()
|
getQuizData()
|
||||||
.then(readQuestions => {
|
.then((readQuestions) => {
|
||||||
if (readQuestions.length === 0) {
|
if (readQuestions.length === 0) {
|
||||||
warn('readQuestions length is zero, no questions found on page!')
|
warn('readQuestions length is zero, no questions found on page!')
|
||||||
ShowMessage(
|
ShowMessage(
|
||||||
|
@ -366,7 +365,7 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const questions = readQuestions.map(question => {
|
const questions = readQuestions.map((question) => {
|
||||||
return {
|
return {
|
||||||
Q: question.question,
|
Q: question.question,
|
||||||
possibleAnswers: question.possibleAnswers,
|
possibleAnswers: question.possibleAnswers,
|
||||||
|
@ -385,7 +384,7 @@
|
||||||
|
|
||||||
log(sentData)
|
log(sentData)
|
||||||
|
|
||||||
post('ask', sentData).then(results => {
|
post('ask', sentData).then((results) => {
|
||||||
removeLoadingMessage()
|
removeLoadingMessage()
|
||||||
ShowAnswers(
|
ShowAnswers(
|
||||||
results.map((res, i) => {
|
results.map((res, i) => {
|
||||||
|
@ -397,7 +396,7 @@
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
warn(err)
|
warn(err)
|
||||||
warn('Error in handleQuiz()')
|
warn('Error in handleQuiz()')
|
||||||
})
|
})
|
||||||
|
@ -410,7 +409,7 @@
|
||||||
document.getElementsByTagName('form')[0].childNodes[0].childNodes
|
document.getElementsByTagName('form')[0].childNodes[0].childNodes
|
||||||
)
|
)
|
||||||
// test: e2c01ff4-d97a-4ab9-8f7f-e28812541097
|
// test: e2c01ff4-d97a-4ab9-8f7f-e28812541097
|
||||||
const notOnlyTextNodes = questionNodes.every(node => {
|
const notOnlyTextNodes = questionNodes.every((node) => {
|
||||||
return node.tagName !== undefined
|
return node.tagName !== undefined
|
||||||
})
|
})
|
||||||
return notOnlyTextNodes && questionNodes.length > 0
|
return notOnlyTextNodes && questionNodes.length > 0
|
||||||
|
@ -439,7 +438,7 @@
|
||||||
function getQuestionNodes() {
|
function getQuestionNodes() {
|
||||||
try {
|
try {
|
||||||
let questionNodes
|
let questionNodes
|
||||||
Object.keys(questionNodeVariants).some(key => {
|
Object.keys(questionNodeVariants).some((key) => {
|
||||||
const variant = questionNodeVariants[key]
|
const variant = questionNodeVariants[key]
|
||||||
if (variant.criteria()) {
|
if (variant.criteria()) {
|
||||||
questionNodes = variant.getter()
|
questionNodes = variant.getter()
|
||||||
|
@ -460,7 +459,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuizData() {
|
function getQuizData() {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
// TODO: dropdown in question
|
// TODO: dropdown in question
|
||||||
// TODO: get possible answers too
|
// TODO: get possible answers too
|
||||||
const promises = []
|
const promises = []
|
||||||
|
@ -477,7 +476,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(result => {
|
.then((result) => {
|
||||||
const errorsRemoved = result.reduce((acc, res) => {
|
const errorsRemoved = result.reduce((acc, res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
acc.push(res)
|
acc.push(res)
|
||||||
|
@ -486,7 +485,7 @@
|
||||||
}, [])
|
}, [])
|
||||||
resolve(errorsRemoved)
|
resolve(errorsRemoved)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
warn('Error in handleQuiz()')
|
warn('Error in handleQuiz()')
|
||||||
warn(err)
|
warn(err)
|
||||||
})
|
})
|
||||||
|
@ -515,7 +514,7 @@
|
||||||
const select = node.getElementsByTagName('select')[0]
|
const select = node.getElementsByTagName('select')[0]
|
||||||
if (select) {
|
if (select) {
|
||||||
const options = []
|
const options = []
|
||||||
Array.from(select).forEach(opt => {
|
Array.from(select).forEach((opt) => {
|
||||||
if (!emptyOrWhiteSpace(opt.innerText)) {
|
if (!emptyOrWhiteSpace(opt.innerText)) {
|
||||||
options.push([{ type: 'txt', val: opt.innerText }])
|
options.push([{ type: 'txt', val: opt.innerText }])
|
||||||
}
|
}
|
||||||
|
@ -526,7 +525,7 @@
|
||||||
} else if (answerRoot.tagName === 'DIV') {
|
} else if (answerRoot.tagName === 'DIV') {
|
||||||
const answers = Array.from(answerRoot.childNodes)
|
const answers = Array.from(answerRoot.childNodes)
|
||||||
|
|
||||||
answers.forEach(answer => {
|
answers.forEach((answer) => {
|
||||||
if (answer.tagName) {
|
if (answer.tagName) {
|
||||||
promises.push(getTextPromisesFromNode(answer))
|
promises.push(getTextPromisesFromNode(answer))
|
||||||
}
|
}
|
||||||
|
@ -537,7 +536,7 @@
|
||||||
const answers = Array.from(answerRoot.childNodes[0].childNodes)
|
const answers = Array.from(answerRoot.childNodes[0].childNodes)
|
||||||
// test: 002203ca-581b-445c-b45d-85374f212e8e NOT WORING
|
// test: 002203ca-581b-445c-b45d-85374f212e8e NOT WORING
|
||||||
|
|
||||||
answers.forEach(answer => {
|
answers.forEach((answer) => {
|
||||||
if (answer.tagName) {
|
if (answer.tagName) {
|
||||||
// test: 817434df-a103-4edc-870e-c9ac953404dc
|
// test: 817434df-a103-4edc-870e-c9ac953404dc
|
||||||
promises.push(
|
promises.push(
|
||||||
|
@ -559,7 +558,7 @@
|
||||||
function getImgNodesFromArray(arr) {
|
function getImgNodesFromArray(arr) {
|
||||||
return arr.reduce((acc, x) => {
|
return arr.reduce((acc, x) => {
|
||||||
if (Array.isArray(x)) {
|
if (Array.isArray(x)) {
|
||||||
x.forEach(y => {
|
x.forEach((y) => {
|
||||||
if (y.type === 'img') {
|
if (y.type === 'img') {
|
||||||
acc.push(y.node)
|
acc.push(y.node)
|
||||||
}
|
}
|
||||||
|
@ -575,34 +574,34 @@
|
||||||
|
|
||||||
const rootVariants = {
|
const rootVariants = {
|
||||||
qtext: {
|
qtext: {
|
||||||
criteria: node => {
|
criteria: (node) => {
|
||||||
return node.getElementsByClassName('qtext').length > 0
|
return node.getElementsByClassName('qtext').length > 0
|
||||||
},
|
},
|
||||||
getter: node => {
|
getter: (node) => {
|
||||||
return node.getElementsByClassName('qtext')[0]
|
return node.getElementsByClassName('qtext')[0]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
subquestion: {
|
subquestion: {
|
||||||
criteria: node => {
|
criteria: (node) => {
|
||||||
return node.getElementsByClassName('subquestion').length > 0
|
return node.getElementsByClassName('subquestion').length > 0
|
||||||
},
|
},
|
||||||
getter: node => {
|
getter: (node) => {
|
||||||
return node.getElementsByClassName('subquestion')[0].parentNode
|
return node.getElementsByClassName('subquestion')[0].parentNode
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
// test: 002203ca-581b-445c-b45d-85374f212e8e
|
// test: 002203ca-581b-445c-b45d-85374f212e8e
|
||||||
criteria: node => {
|
criteria: (node) => {
|
||||||
return node.getElementsByClassName('content').length > 0
|
return node.getElementsByClassName('content').length > 0
|
||||||
},
|
},
|
||||||
getter: node => {
|
getter: (node) => {
|
||||||
const content = node.getElementsByClassName('content')[0].childNodes[0]
|
const content = node.getElementsByClassName('content')[0].childNodes[0]
|
||||||
const pNodes = Array.from(content.childNodes).filter(node => {
|
const pNodes = Array.from(content.childNodes).filter((node) => {
|
||||||
return node.tagName === 'P'
|
return node.tagName === 'P'
|
||||||
})
|
})
|
||||||
|
|
||||||
const parent = document.createElement('div')
|
const parent = document.createElement('div')
|
||||||
pNodes.forEach(node => {
|
pNodes.forEach((node) => {
|
||||||
parent.appendChild(node.cloneNode(true))
|
parent.appendChild(node.cloneNode(true))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -614,7 +613,7 @@
|
||||||
function getQuestionRootNode(node) {
|
function getQuestionRootNode(node) {
|
||||||
try {
|
try {
|
||||||
let qtextNode
|
let qtextNode
|
||||||
Object.keys(rootVariants).some(key => {
|
Object.keys(rootVariants).some((key) => {
|
||||||
const variant = rootVariants[key]
|
const variant = rootVariants[key]
|
||||||
if (variant.criteria(node)) {
|
if (variant.criteria(node)) {
|
||||||
qtextNode = variant.getter(node)
|
qtextNode = variant.getter(node)
|
||||||
|
@ -635,14 +634,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuestionPromiseForSingleQuestion(node) {
|
function getQuestionPromiseForSingleQuestion(node) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
try {
|
try {
|
||||||
const qtextNode = getQuestionRootNode(node)
|
const qtextNode = getQuestionRootNode(node)
|
||||||
const questionPromises = getTextPromisesFromNode(qtextNode)
|
const questionPromises = getTextPromisesFromNode(qtextNode)
|
||||||
const possibleAnswerPromises = getPossibleAnswersFromTest(node)
|
const possibleAnswerPromises = getPossibleAnswersFromTest(node)
|
||||||
|
|
||||||
const unflattenedPossibleAnswerPromises = possibleAnswerPromises
|
const unflattenedPossibleAnswerPromises = possibleAnswerPromises
|
||||||
? possibleAnswerPromises.map(x => {
|
? possibleAnswerPromises.map((x) => {
|
||||||
return Promise.all(x)
|
return Promise.all(x)
|
||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
|
@ -655,7 +654,7 @@
|
||||||
const questionText = removeUnnecesarySpaces(
|
const questionText = removeUnnecesarySpaces(
|
||||||
question.reduce(makeTextFromElements, []).join(' ')
|
question.reduce(makeTextFromElements, []).join(' ')
|
||||||
)
|
)
|
||||||
const possibleAnswers = possibleAnswerArray.map(x => {
|
const possibleAnswers = possibleAnswerArray.map((x) => {
|
||||||
return removeUnnecesarySpaces(
|
return removeUnnecesarySpaces(
|
||||||
x.reduce(makeTextFromElements, []).join(' ')
|
x.reduce(makeTextFromElements, []).join(' ')
|
||||||
)
|
)
|
||||||
|
@ -684,7 +683,7 @@
|
||||||
success: true,
|
success: true,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
warn('Error in getQuestionPromiseForSingleQuestion()')
|
warn('Error in getQuestionPromiseForSingleQuestion()')
|
||||||
warn(err)
|
warn(err)
|
||||||
resolve({ success: false })
|
resolve({ success: false })
|
||||||
|
@ -701,7 +700,7 @@
|
||||||
if (hashedImages.length > 0) {
|
if (hashedImages.length > 0) {
|
||||||
return {
|
return {
|
||||||
type: 'image',
|
type: 'image',
|
||||||
hashedImages: hashedImages.map(x => {
|
hashedImages: hashedImages.map((x) => {
|
||||||
return x.val
|
return x.val
|
||||||
}),
|
}),
|
||||||
images: legacyImages,
|
images: legacyImages,
|
||||||
|
@ -722,7 +721,7 @@
|
||||||
function getResultNodes() {
|
function getResultNodes() {
|
||||||
try {
|
try {
|
||||||
let resultNodes
|
let resultNodes
|
||||||
Object.keys(resultNodeVariants).some(key => {
|
Object.keys(resultNodeVariants).some((key) => {
|
||||||
const variant = resultNodeVariants[key]
|
const variant = resultNodeVariants[key]
|
||||||
if (variant.criteria()) {
|
if (variant.criteria()) {
|
||||||
resultNodes = variant.getter()
|
resultNodes = variant.getter()
|
||||||
|
@ -743,7 +742,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuiz() {
|
function getQuiz() {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
const promises = []
|
const promises = []
|
||||||
const questionNodes = getResultNodes()
|
const questionNodes = getResultNodes()
|
||||||
// let questionNodes = Array.from(
|
// let questionNodes = Array.from(
|
||||||
|
@ -762,7 +761,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(result => {
|
.then((result) => {
|
||||||
const errorsRemoved = result.reduce((acc, res) => {
|
const errorsRemoved = result.reduce((acc, res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
acc.push(res)
|
acc.push(res)
|
||||||
|
@ -771,7 +770,7 @@
|
||||||
}, [])
|
}, [])
|
||||||
resolve(errorsRemoved)
|
resolve(errorsRemoved)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
warn('Error in getQuiz()')
|
warn('Error in getQuiz()')
|
||||||
warn(err)
|
warn(err)
|
||||||
})
|
})
|
||||||
|
@ -780,7 +779,7 @@
|
||||||
|
|
||||||
function getPromisesThatMeetsRequirements(getters, node) {
|
function getPromisesThatMeetsRequirements(getters, node) {
|
||||||
let res
|
let res
|
||||||
Object.keys(getters).some(key => {
|
Object.keys(getters).some((key) => {
|
||||||
const getter = getters[key]
|
const getter = getters[key]
|
||||||
if (getter.requirement(node)) {
|
if (getter.requirement(node)) {
|
||||||
try {
|
try {
|
||||||
|
@ -798,7 +797,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuizFromNode(node) {
|
function getQuizFromNode(node) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
try {
|
try {
|
||||||
const questionPromises = getPromisesThatMeetsRequirements(
|
const questionPromises = getPromisesThatMeetsRequirements(
|
||||||
questionGetters,
|
questionGetters,
|
||||||
|
@ -835,7 +834,7 @@
|
||||||
result.data.possibleAnswers = possibleAnswers
|
result.data.possibleAnswers = possibleAnswers
|
||||||
resolve(result)
|
resolve(result)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
warn('Error in getQuizFromNode()')
|
warn('Error in getQuizFromNode()')
|
||||||
warn(err)
|
warn(err)
|
||||||
resolve({ success: false })
|
resolve({ success: false })
|
||||||
|
@ -852,7 +851,7 @@
|
||||||
if (images && images.length > 0) {
|
if (images && images.length > 0) {
|
||||||
return {
|
return {
|
||||||
type: 'image',
|
type: 'image',
|
||||||
hashedImages: images.map(x => {
|
hashedImages: images.map((x) => {
|
||||||
return x.val
|
return x.val
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -866,10 +865,10 @@
|
||||||
const questionGetters = {
|
const questionGetters = {
|
||||||
getSimpleQuestion: {
|
getSimpleQuestion: {
|
||||||
description: 'Basic question getter',
|
description: 'Basic question getter',
|
||||||
requirement: node => {
|
requirement: (node) => {
|
||||||
return node.getElementsByClassName('qtext').length > 0
|
return node.getElementsByClassName('qtext').length > 0
|
||||||
},
|
},
|
||||||
getterFunction: node => {
|
getterFunction: (node) => {
|
||||||
const question = node.getElementsByClassName('qtext')[0]
|
const question = node.getElementsByClassName('qtext')[0]
|
||||||
return getTextPromisesFromNode(question)
|
return getTextPromisesFromNode(question)
|
||||||
},
|
},
|
||||||
|
@ -879,23 +878,23 @@
|
||||||
const answerGetters = {
|
const answerGetters = {
|
||||||
getSimpleAnswer: {
|
getSimpleAnswer: {
|
||||||
description: 'Basic answer getter',
|
description: 'Basic answer getter',
|
||||||
requirement: node => {
|
requirement: (node) => {
|
||||||
return node.getElementsByClassName('rightanswer').length > 0
|
return node.getElementsByClassName('rightanswer').length > 0
|
||||||
},
|
},
|
||||||
getterFunction: node => {
|
getterFunction: (node) => {
|
||||||
const answer = node.getElementsByClassName('rightanswer')[0]
|
const answer = node.getElementsByClassName('rightanswer')[0]
|
||||||
return getTextPromisesFromNode(answer)
|
return getTextPromisesFromNode(answer)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
noCorrect: {
|
noCorrect: {
|
||||||
description: 'Gets correct answer, even if the correct is not shown',
|
description: 'Gets correct answer, even if the correct is not shown',
|
||||||
requirement: node => {
|
requirement: (node) => {
|
||||||
return (
|
return (
|
||||||
node.getElementsByClassName('rightanswer').length === 0 &&
|
node.getElementsByClassName('rightanswer').length === 0 &&
|
||||||
node.getElementsByClassName('answer').length > 0
|
node.getElementsByClassName('answer').length > 0
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
getterFunction: node => {
|
getterFunction: (node) => {
|
||||||
const possibleAnswers = getPossibleAnswers(node)
|
const possibleAnswers = getPossibleAnswers(node)
|
||||||
|
|
||||||
if (getIfSolutionIsCorrect(node)) {
|
if (getIfSolutionIsCorrect(node)) {
|
||||||
|
@ -903,7 +902,7 @@
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
type: 'txt',
|
type: 'txt',
|
||||||
val: possibleAnswers.find(x => {
|
val: possibleAnswers.find((x) => {
|
||||||
return x.selectedByUser === false
|
return x.selectedByUser === false
|
||||||
}).text,
|
}).text,
|
||||||
},
|
},
|
||||||
|
@ -918,7 +917,7 @@
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
type: 'txt',
|
type: 'txt',
|
||||||
val: possibleAnswers.find(x => {
|
val: possibleAnswers.find((x) => {
|
||||||
return x.selectedByUser === true
|
return x.selectedByUser === true
|
||||||
}).text,
|
}).text,
|
||||||
},
|
},
|
||||||
|
@ -928,30 +927,30 @@
|
||||||
},
|
},
|
||||||
getDropdownAnswer: {
|
getDropdownAnswer: {
|
||||||
description: 'Dropdown answer getter',
|
description: 'Dropdown answer getter',
|
||||||
requirement: node => {
|
requirement: (node) => {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
getterFunction: node => {
|
getterFunction: (node) => {
|
||||||
// TODO dropdown kérdés.html
|
// TODO dropdown kérdés.html
|
||||||
return 'asd'
|
return 'asd'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getTextareaAnswer: {
|
getTextareaAnswer: {
|
||||||
description: 'Get complex answer',
|
description: 'Get complex answer',
|
||||||
requirement: node => {
|
requirement: (node) => {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
getterFunction: node => {
|
getterFunction: (node) => {
|
||||||
// TODO Ugrás... bug.html
|
// TODO Ugrás... bug.html
|
||||||
return 'asd'
|
return 'asd'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getDragBoxAnswer: {
|
getDragBoxAnswer: {
|
||||||
description: 'Get complex answer',
|
description: 'Get complex answer',
|
||||||
requirement: node => {
|
requirement: (node) => {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
getterFunction: node => {
|
getterFunction: (node) => {
|
||||||
// TODO dragboxes
|
// TODO dragboxes
|
||||||
return 'asd'
|
return 'asd'
|
||||||
},
|
},
|
||||||
|
@ -991,7 +990,7 @@
|
||||||
const select = node.getElementsByTagName('select')[0]
|
const select = node.getElementsByTagName('select')[0]
|
||||||
if (select) {
|
if (select) {
|
||||||
const options = []
|
const options = []
|
||||||
Array.from(select.childNodes).forEach(opt => {
|
Array.from(select.childNodes).forEach((opt) => {
|
||||||
if (!emptyOrWhiteSpace(opt.innerText)) {
|
if (!emptyOrWhiteSpace(opt.innerText)) {
|
||||||
options.push(opt.innerText)
|
options.push(opt.innerText)
|
||||||
}
|
}
|
||||||
|
@ -1007,10 +1006,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function digestMessage(message) {
|
function digestMessage(message) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
const encoder = new TextEncoder()
|
const encoder = new TextEncoder()
|
||||||
const data = encoder.encode(message)
|
const data = encoder.encode(message)
|
||||||
crypto.subtle.digest('SHA-256', data).then(buf => {
|
crypto.subtle.digest('SHA-256', data).then((buf) => {
|
||||||
let res = String.fromCharCode.apply(null, new Uint8Array(buf))
|
let res = String.fromCharCode.apply(null, new Uint8Array(buf))
|
||||||
res = btoa(res)
|
res = btoa(res)
|
||||||
.replace(/=/g, '')
|
.replace(/=/g, '')
|
||||||
|
@ -1098,7 +1097,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const getHostHandler = {
|
const getHostHandler = {
|
||||||
apply: function() {
|
apply: function () {
|
||||||
const result = apply(...arguments)
|
const result = apply(...arguments)
|
||||||
return result === shadowRootNewHost ? shadowRootHost : result
|
return result === shadowRootNewHost ? shadowRootHost : result
|
||||||
},
|
},
|
||||||
|
@ -1274,7 +1273,7 @@
|
||||||
if (!sideLinks) {
|
if (!sideLinks) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Array.from(sideLinks.childNodes).forEach(link => {
|
Array.from(sideLinks.childNodes).forEach((link) => {
|
||||||
link.addEventListener('mousedown', () => {
|
link.addEventListener('mousedown', () => {
|
||||||
FillFeedbackCID(url, link)
|
FillFeedbackCID(url, link)
|
||||||
})
|
})
|
||||||
|
@ -1316,13 +1315,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addEventListener = (function() {
|
addEventListener = (function () {
|
||||||
if (document.addEventListener) {
|
if (document.addEventListener) {
|
||||||
return function(element, event, handler) {
|
return function (element, event, handler) {
|
||||||
element.addEventListener(event, handler, false)
|
element.addEventListener(event, handler, false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return function(element, event, handler) {
|
return function (element, event, handler) {
|
||||||
element.attachEvent('on' + event, handler)
|
element.attachEvent('on' + event, handler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1338,13 +1337,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function Auth(pw) {
|
function Auth(pw) {
|
||||||
post('login', { pw: pw, script: true }).then(res => {
|
post('login', { pw: pw, script: true }).then((res) => {
|
||||||
if (res.result === 'success') {
|
if (res.result === 'success') {
|
||||||
ConnectToServer(AfterLoad)
|
ConnectToServer(AfterLoad)
|
||||||
clearAllMessages()
|
clearAllMessages()
|
||||||
resetMenu()
|
resetMenu()
|
||||||
} else {
|
} else {
|
||||||
SafeGetElementById('infoMainDiv', elem => {
|
SafeGetElementById('infoMainDiv', (elem) => {
|
||||||
elem.innerText = texts.invalidPW + pw
|
elem.innerText = texts.invalidPW + pw
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1352,16 +1351,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetMenu() {
|
function resetMenu() {
|
||||||
SafeGetElementById('scriptMenuDiv', elem => {
|
SafeGetElementById('scriptMenuDiv', (elem) => {
|
||||||
elem.style.backgroundColor = '#262626'
|
elem.style.backgroundColor = '#262626'
|
||||||
})
|
})
|
||||||
SafeGetElementById('retryContainer', elem => {
|
SafeGetElementById('retryContainer', (elem) => {
|
||||||
elem.style.display = 'none'
|
elem.style.display = 'none'
|
||||||
})
|
})
|
||||||
SafeGetElementById('loginDiv', elem => {
|
SafeGetElementById('loginDiv', (elem) => {
|
||||||
elem.style.display = 'none'
|
elem.style.display = 'none'
|
||||||
})
|
})
|
||||||
SafeGetElementById('infoMainDiv', elem => {
|
SafeGetElementById('infoMainDiv', (elem) => {
|
||||||
elem.innerText = texts.loading
|
elem.innerText = texts.loading
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1369,7 +1368,7 @@
|
||||||
function ConnectToServer(cwith) {
|
function ConnectToServer(cwith) {
|
||||||
clearAllMessages()
|
clearAllMessages()
|
||||||
GetXHRInfos()
|
GetXHRInfos()
|
||||||
.then(inf => {
|
.then((inf) => {
|
||||||
if (inf.result === 'nouser') {
|
if (inf.result === 'nouser') {
|
||||||
NoUserAction()
|
NoUserAction()
|
||||||
return
|
return
|
||||||
|
@ -1401,25 +1400,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function NoUserAction() {
|
function NoUserAction() {
|
||||||
SafeGetElementById('scriptMenuDiv', elem => {
|
SafeGetElementById('scriptMenuDiv', (elem) => {
|
||||||
elem.style.backgroundColor = '#44cc00'
|
elem.style.backgroundColor = '#44cc00'
|
||||||
})
|
})
|
||||||
SafeGetElementById('infoMainDiv', elem => {
|
SafeGetElementById('infoMainDiv', (elem) => {
|
||||||
elem.innerText = ''
|
elem.innerText = ''
|
||||||
})
|
})
|
||||||
SafeGetElementById('loginDiv', elem => {
|
SafeGetElementById('loginDiv', (elem) => {
|
||||||
elem.style.display = 'flex'
|
elem.style.display = 'flex'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function NoServerAction() {
|
function NoServerAction() {
|
||||||
SafeGetElementById('scriptMenuDiv', elem => {
|
SafeGetElementById('scriptMenuDiv', (elem) => {
|
||||||
elem.style.backgroundColor = 'red'
|
elem.style.backgroundColor = 'red'
|
||||||
})
|
})
|
||||||
SafeGetElementById('infoMainDiv', elem => {
|
SafeGetElementById('infoMainDiv', (elem) => {
|
||||||
elem.innerText = texts.noServer
|
elem.innerText = texts.noServer
|
||||||
})
|
})
|
||||||
SafeGetElementById('retryContainer', elem => {
|
SafeGetElementById('retryContainer', (elem) => {
|
||||||
elem.style.display = 'flex'
|
elem.style.display = 'flex'
|
||||||
})
|
})
|
||||||
log(texts.noServerConsoleMessage)
|
log(texts.noServerConsoleMessage)
|
||||||
|
@ -1501,7 +1500,7 @@
|
||||||
function PrepareAnswers(result) {
|
function PrepareAnswers(result) {
|
||||||
const { answers, question } = result
|
const { answers, question } = result
|
||||||
if (answers.length > 0) {
|
if (answers.length > 0) {
|
||||||
return answers.map(answer => {
|
return answers.map((answer) => {
|
||||||
const { Q, A, data } = answer.q
|
const { Q, A, data } = answer.q
|
||||||
let msg = Q + '\n' + A
|
let msg = Q + '\n' + A
|
||||||
|
|
||||||
|
@ -1564,7 +1563,7 @@
|
||||||
texts.noResult,
|
texts.noResult,
|
||||||
|
|
||||||
undefined,
|
undefined,
|
||||||
function() {
|
function () {
|
||||||
OpenErrorPage({
|
OpenErrorPage({
|
||||||
message: 'No result found',
|
message: 'No result found',
|
||||||
question: Array.isArray(answers[0])
|
question: Array.isArray(answers[0])
|
||||||
|
@ -1581,7 +1580,7 @@
|
||||||
// : Quiz saving {{{
|
// : Quiz saving {{{
|
||||||
|
|
||||||
function HandleResults() {
|
function HandleResults() {
|
||||||
getQuiz().then(res => {
|
getQuiz().then((res) => {
|
||||||
SaveQuiz(res, ShowSaveQuizDialog) // saves the quiz questions and answers
|
SaveQuiz(res, ShowSaveQuizDialog) // saves the quiz questions and answers
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1603,7 @@
|
||||||
msg,
|
msg,
|
||||||
|
|
||||||
null,
|
null,
|
||||||
function() {
|
function () {
|
||||||
let towrite = ''
|
let towrite = ''
|
||||||
try {
|
try {
|
||||||
towrite += '</p>Elküldött adatok:</p> ' + JSON.stringify(sentData)
|
towrite += '</p>Elküldött adatok:</p> ' + JSON.stringify(sentData)
|
||||||
|
@ -1639,7 +1638,7 @@
|
||||||
log('unable to get subject name :c')
|
log('unable to get subject name :c')
|
||||||
}
|
}
|
||||||
log('SENT DATA', sentData)
|
log('SENT DATA', sentData)
|
||||||
post('isAdding', sentData).then(res => {
|
post('isAdding', sentData).then((res) => {
|
||||||
next(res.success, sentData, res.totalNewQuestions)
|
next(res.success, sentData, res.totalNewQuestions)
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1708,7 +1707,7 @@
|
||||||
// this function adds basic hotkeys for video controll.
|
// this function adds basic hotkeys for video controll.
|
||||||
function AddVideoHotkeys() {
|
function AddVideoHotkeys() {
|
||||||
var seekTime = 20
|
var seekTime = 20
|
||||||
document.addEventListener('keydown', function(e) {
|
document.addEventListener('keydown', function (e) {
|
||||||
try {
|
try {
|
||||||
var video = getVideo()
|
var video = getVideo()
|
||||||
var keyCode = e.keyCode // getting keycode
|
var keyCode = e.keyCode // getting keycode
|
||||||
|
@ -1748,7 +1747,7 @@
|
||||||
// : Show message, and script menu stuff {{{
|
// : Show message, and script menu stuff {{{
|
||||||
|
|
||||||
function clearAllMessages() {
|
function clearAllMessages() {
|
||||||
overlay.querySelectorAll('#scriptMessage').forEach(x => x.remove())
|
overlay.querySelectorAll('#scriptMessage').forEach((x) => x.remove())
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConvertedMessageNode(message) {
|
function getConvertedMessageNode(message) {
|
||||||
|
@ -1756,7 +1755,7 @@
|
||||||
const resultNode = document.createElement('p')
|
const resultNode = document.createElement('p')
|
||||||
messageNode.innerHTML = message.replace(/\n/g, '</br>')
|
messageNode.innerHTML = message.replace(/\n/g, '</br>')
|
||||||
|
|
||||||
Array.from(messageNode.childNodes).forEach(node => {
|
Array.from(messageNode.childNodes).forEach((node) => {
|
||||||
if (node.tagName === 'A') {
|
if (node.tagName === 'A') {
|
||||||
const linkNode = document.createElement('span')
|
const linkNode = document.createElement('span')
|
||||||
SetStyle(linkNode, {
|
SetStyle(linkNode, {
|
||||||
|
@ -1765,7 +1764,7 @@
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
})
|
})
|
||||||
linkNode.innerText = node.innerText
|
linkNode.innerText = node.innerText
|
||||||
linkNode.addEventListener('mousedown', e => {
|
linkNode.addEventListener('mousedown', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
openInTab(node.href, {
|
openInTab(node.href, {
|
||||||
active: true,
|
active: true,
|
||||||
|
@ -1787,7 +1786,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let currOpacity = getVal(`${elem.id}_opacity`) || 1
|
let currOpacity = getVal(`${elem.id}_opacity`) || 1
|
||||||
elem.addEventListener('wheel', e => {
|
elem.addEventListener('wheel', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const isUp = e.deltaY < 0
|
const isUp = e.deltaY < 0
|
||||||
if (isUp) {
|
if (isUp) {
|
||||||
|
@ -1871,7 +1870,7 @@
|
||||||
let offset = [0, 0]
|
let offset = [0, 0]
|
||||||
let mousePosition
|
let mousePosition
|
||||||
if (movingEnabled) {
|
if (movingEnabled) {
|
||||||
mainDiv.addEventListener('mousedown', e => {
|
mainDiv.addEventListener('mousedown', (e) => {
|
||||||
isMouseDown = true
|
isMouseDown = true
|
||||||
offset = [
|
offset = [
|
||||||
mainDiv.offsetLeft - e.clientX,
|
mainDiv.offsetLeft - e.clientX,
|
||||||
|
@ -1881,7 +1880,7 @@
|
||||||
mainDiv.addEventListener('mouseup', () => {
|
mainDiv.addEventListener('mouseup', () => {
|
||||||
isMouseDown = false
|
isMouseDown = false
|
||||||
})
|
})
|
||||||
mainDiv.addEventListener('mousemove', e => {
|
mainDiv.addEventListener('mousemove', (e) => {
|
||||||
if (isMouseDown) {
|
if (isMouseDown) {
|
||||||
mousePosition = {
|
mousePosition = {
|
||||||
x: e.clientX,
|
x: e.clientX,
|
||||||
|
@ -1901,7 +1900,7 @@
|
||||||
display: 'inline',
|
display: 'inline',
|
||||||
margin: '3px',
|
margin: '3px',
|
||||||
})
|
})
|
||||||
xButton.addEventListener('mousedown', e => {
|
xButton.addEventListener('mousedown', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
mainDiv.parentNode.removeChild(mainDiv)
|
mainDiv.parentNode.removeChild(mainDiv)
|
||||||
})
|
})
|
||||||
|
@ -1916,7 +1915,7 @@
|
||||||
const mesageNode = getConvertedMessageNode(simpleMessageText)
|
const mesageNode = getConvertedMessageNode(simpleMessageText)
|
||||||
|
|
||||||
simpleMessageParagrapg.appendChild(mesageNode)
|
simpleMessageParagrapg.appendChild(mesageNode)
|
||||||
mesageNode.addEventListener('mousedown', e => {
|
mesageNode.addEventListener('mousedown', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
})
|
})
|
||||||
SetStyle(mesageNode, {
|
SetStyle(mesageNode, {
|
||||||
|
@ -1924,9 +1923,11 @@
|
||||||
cursor: funct ? 'pointer' : 'auto',
|
cursor: funct ? 'pointer' : 'auto',
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.from(mesageNode.getElementsByTagName('a')).forEach(anchorElem => {
|
Array.from(mesageNode.getElementsByTagName('a')).forEach(
|
||||||
anchorElem.style.color = 'lightblue'
|
(anchorElem) => {
|
||||||
})
|
anchorElem.style.color = 'lightblue'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
mainDiv.appendChild(simpleMessageParagrapg) // adding text box to main div
|
mainDiv.appendChild(simpleMessageParagrapg) // adding text box to main div
|
||||||
} else {
|
} else {
|
||||||
|
@ -2003,7 +2004,7 @@
|
||||||
'ur question goes here, mister OwO'
|
'ur question goes here, mister OwO'
|
||||||
)
|
)
|
||||||
|
|
||||||
questionTextElement.addEventListener('mousedown', e => {
|
questionTextElement.addEventListener('mousedown', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2022,7 +2023,7 @@
|
||||||
return msgItem[currItem][currRelevantQuestion]
|
return msgItem[currItem][currRelevantQuestion]
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChangeCurrItemIndex = to => {
|
const ChangeCurrItemIndex = (to) => {
|
||||||
currItem += to
|
currItem += to
|
||||||
if (currItem < 0) {
|
if (currItem < 0) {
|
||||||
currItem = 0
|
currItem = 0
|
||||||
|
@ -2033,7 +2034,7 @@
|
||||||
currRelevantQuestion = 0
|
currRelevantQuestion = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChangeCurrRelevantQuestionIndex = to => {
|
const ChangeCurrRelevantQuestionIndex = (to) => {
|
||||||
currRelevantQuestion += to
|
currRelevantQuestion += to
|
||||||
if (currRelevantQuestion < 0) {
|
if (currRelevantQuestion < 0) {
|
||||||
currRelevantQuestion = 0
|
currRelevantQuestion = 0
|
||||||
|
@ -2080,7 +2081,7 @@
|
||||||
prevSuggButton.title = 'Előző lehetséges válasz'
|
prevSuggButton.title = 'Előző lehetséges válasz'
|
||||||
SetStyle(prevSuggButton, buttonStyle)
|
SetStyle(prevSuggButton, buttonStyle)
|
||||||
|
|
||||||
prevSuggButton.addEventListener('mousedown', function(e) {
|
prevSuggButton.addEventListener('mousedown', function (e) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
ChangeCurrRelevantQuestionIndex(-1)
|
ChangeCurrRelevantQuestionIndex(-1)
|
||||||
SetQuestionText()
|
SetQuestionText()
|
||||||
|
@ -2094,7 +2095,7 @@
|
||||||
nextSuggButton.title = 'Következő lehetséges válasz'
|
nextSuggButton.title = 'Következő lehetséges válasz'
|
||||||
SetStyle(nextSuggButton, buttonStyle)
|
SetStyle(nextSuggButton, buttonStyle)
|
||||||
|
|
||||||
nextSuggButton.addEventListener('mousedown', function(e) {
|
nextSuggButton.addEventListener('mousedown', function (e) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
ChangeCurrRelevantQuestionIndex(1)
|
ChangeCurrRelevantQuestionIndex(1)
|
||||||
SetQuestionText()
|
SetQuestionText()
|
||||||
|
@ -2111,7 +2112,7 @@
|
||||||
prevButton.title = 'Előző kérdés'
|
prevButton.title = 'Előző kérdés'
|
||||||
|
|
||||||
// event listener
|
// event listener
|
||||||
prevButton.addEventListener('click', function() {
|
prevButton.addEventListener('click', function () {
|
||||||
ChangeCurrItemIndex(-1)
|
ChangeCurrItemIndex(-1)
|
||||||
SetQuestionText()
|
SetQuestionText()
|
||||||
})
|
})
|
||||||
|
@ -2121,7 +2122,7 @@
|
||||||
nextButton.title = 'Előző kérdés'
|
nextButton.title = 'Előző kérdés'
|
||||||
|
|
||||||
// event listener
|
// event listener
|
||||||
nextButton.addEventListener('click', function() {
|
nextButton.addEventListener('click', function () {
|
||||||
ChangeCurrItemIndex(1)
|
ChangeCurrItemIndex(1)
|
||||||
SetQuestionText()
|
SetQuestionText()
|
||||||
})
|
})
|
||||||
|
@ -2134,18 +2135,18 @@
|
||||||
// addEventListener(window, 'scroll', function () {
|
// addEventListener(window, 'scroll', function () {
|
||||||
// mainDiv.style.top = (pageYOffset + startFromTop) + 'px';
|
// mainDiv.style.top = (pageYOffset + startFromTop) + 'px';
|
||||||
// })
|
// })
|
||||||
addEventListener(window, 'resize', function() {
|
addEventListener(window, 'resize', function () {
|
||||||
mainDiv.style.left = (window.innerWidth - width) / 2 + 'px'
|
mainDiv.style.left = (window.innerWidth - width) / 2 + 'px'
|
||||||
})
|
})
|
||||||
var timeOut
|
var timeOut
|
||||||
if (timeout && timeout > 0) {
|
if (timeout && timeout > 0) {
|
||||||
// setting timeout if not zero or null
|
// setting timeout if not zero or null
|
||||||
timeOut = setTimeout(function() {
|
timeOut = setTimeout(function () {
|
||||||
mainDiv.parentNode.removeChild(mainDiv)
|
mainDiv.parentNode.removeChild(mainDiv)
|
||||||
}, timeout * 1000)
|
}, timeout * 1000)
|
||||||
}
|
}
|
||||||
// middle click close event listener
|
// middle click close event listener
|
||||||
addEventListener(mainDiv, 'mousedown', function(e) {
|
addEventListener(mainDiv, 'mousedown', function (e) {
|
||||||
if (e.which === 2) {
|
if (e.which === 2) {
|
||||||
mainDiv.parentNode.removeChild(mainDiv)
|
mainDiv.parentNode.removeChild(mainDiv)
|
||||||
if (timeOut) {
|
if (timeOut) {
|
||||||
|
@ -2185,7 +2186,7 @@
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
})
|
})
|
||||||
|
|
||||||
addEventListener(scriptMenuDiv, 'mousedown', function(e) {
|
addEventListener(scriptMenuDiv, 'mousedown', function (e) {
|
||||||
if (e.which === 2) {
|
if (e.which === 2) {
|
||||||
scriptMenuDiv.parentNode.removeChild(scriptMenuDiv)
|
scriptMenuDiv.parentNode.removeChild(scriptMenuDiv)
|
||||||
}
|
}
|
||||||
|
@ -2203,7 +2204,7 @@
|
||||||
fontSize: '18px',
|
fontSize: '18px',
|
||||||
})
|
})
|
||||||
|
|
||||||
xButton.addEventListener('mousedown', e => {
|
xButton.addEventListener('mousedown', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
scriptMenuDiv.parentNode.removeChild(scriptMenuDiv)
|
scriptMenuDiv.parentNode.removeChild(scriptMenuDiv)
|
||||||
})
|
})
|
||||||
|
@ -2220,7 +2221,7 @@
|
||||||
fontSize: '30px',
|
fontSize: '30px',
|
||||||
})
|
})
|
||||||
|
|
||||||
mailButton.addEventListener('mousedown', e => {
|
mailButton.addEventListener('mousedown', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
if (userSpecificMotd && !userSpecificMotd.seen) {
|
if (userSpecificMotd && !userSpecificMotd.seen) {
|
||||||
mailButton.innerText = '📭'
|
mailButton.innerText = '📭'
|
||||||
|
@ -2258,7 +2259,7 @@
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(menuButtons).forEach(key => {
|
Object.keys(menuButtons).forEach((key) => {
|
||||||
const buttonData = menuButtons[key]
|
const buttonData = menuButtons[key]
|
||||||
const button = CreateNodeWithText(
|
const button = CreateNodeWithText(
|
||||||
buttonContainer,
|
buttonContainer,
|
||||||
|
@ -2267,7 +2268,7 @@
|
||||||
)
|
)
|
||||||
SetStyle(button, buttonStyle)
|
SetStyle(button, buttonStyle)
|
||||||
if (buttonData.onClick) {
|
if (buttonData.onClick) {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function () {
|
||||||
buttonData.onClick()
|
buttonData.onClick()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2308,7 +2309,7 @@
|
||||||
loginContainer.appendChild(loginButton)
|
loginContainer.appendChild(loginButton)
|
||||||
loginButton.innerText = texts.login
|
loginButton.innerText = texts.login
|
||||||
SetStyle(loginButton, buttonStyle)
|
SetStyle(loginButton, buttonStyle)
|
||||||
loginButton.addEventListener('click', function() {
|
loginButton.addEventListener('click', function () {
|
||||||
Auth(loginInput.value)
|
Auth(loginInput.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2333,7 +2334,7 @@
|
||||||
color: '#ffffff',
|
color: '#ffffff',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
})
|
})
|
||||||
retryButton.addEventListener('click', function() {
|
retryButton.addEventListener('click', function () {
|
||||||
scriptMenuDiv.style.background = '#262626'
|
scriptMenuDiv.style.background = '#262626'
|
||||||
infoDiv.innerText = texts.loading
|
infoDiv.innerText = texts.loading
|
||||||
retryContainer.style.display = 'none'
|
retryContainer.style.display = 'none'
|
||||||
|
@ -2390,7 +2391,7 @@
|
||||||
|
|
||||||
// : }}}
|
// : }}}
|
||||||
|
|
||||||
const assert = val => {
|
const assert = (val) => {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
throw new Error('Assertion failed')
|
throw new Error('Assertion failed')
|
||||||
}
|
}
|
||||||
|
@ -2450,7 +2451,7 @@
|
||||||
function SetStyle(target, style) {
|
function SetStyle(target, style) {
|
||||||
Object.keys(style)
|
Object.keys(style)
|
||||||
.sort()
|
.sort()
|
||||||
.forEach(key => {
|
.forEach((key) => {
|
||||||
target.style[key] = style[key]
|
target.style[key] = style[key]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2502,7 +2503,7 @@
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
onload: function(response) {
|
onload: function (response) {
|
||||||
try {
|
try {
|
||||||
setVal('lastInfoCheckTime', now)
|
setVal('lastInfoCheckTime', now)
|
||||||
const res = JSON.parse(response.responseText)
|
const res = JSON.parse(response.responseText)
|
||||||
|
@ -2515,7 +2516,7 @@
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onerror: e => {
|
onerror: (e) => {
|
||||||
log('Info get Error', e)
|
log('Info get Error', e)
|
||||||
reject(e)
|
reject(e)
|
||||||
},
|
},
|
||||||
|
@ -2549,11 +2550,11 @@
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
onerror: function(e) {
|
onerror: function (e) {
|
||||||
log('Data send error', e)
|
log('Data send error', e)
|
||||||
reject(e)
|
reject(e)
|
||||||
},
|
},
|
||||||
onload: resp => {
|
onload: (resp) => {
|
||||||
try {
|
try {
|
||||||
const res = JSON.parse(resp.responseText)
|
const res = JSON.parse(resp.responseText)
|
||||||
resolve(res)
|
resolve(res)
|
||||||
|
@ -2571,7 +2572,7 @@
|
||||||
function OpenErrorPage(e) {
|
function OpenErrorPage(e) {
|
||||||
const queries = []
|
const queries = []
|
||||||
try {
|
try {
|
||||||
Object.keys(e).forEach(key => {
|
Object.keys(e).forEach((key) => {
|
||||||
if (e[key]) {
|
if (e[key]) {
|
||||||
queries.push(`${key}=${encodeURIComponent(e[key])}`)
|
queries.push(`${key}=${encodeURIComponent(e[key])}`)
|
||||||
queries.push('db=all')
|
queries.push('db=all')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue