mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Added localisation
This commit is contained in:
parent
9923055c7e
commit
b343a92b41
4 changed files with 48 additions and 30 deletions
0
.gitmodules
vendored
Normal file → Executable file
0
.gitmodules
vendored
Normal file → Executable file
0
README.md
Normal file → Executable file
0
README.md
Normal file → Executable file
0
license
Normal file → Executable file
0
license
Normal file → Executable file
78
stable.user.js
Normal file → Executable file
78
stable.user.js
Normal file → Executable file
|
@ -58,7 +58,6 @@
|
||||||
|
|
||||||
var data // all data, which is in the resource txt
|
var data // all data, which is in the resource txt
|
||||||
var addEventListener // add event listener function
|
var addEventListener // add event listener function
|
||||||
const lastChangeLog = '- "Húzza a megfelelő helyre ..." kérdés lekezelése\n- Kód refactor\n- Ha valami elszállt: <a href="https://qmining.frylabs.net">feedback</a> pls'
|
|
||||||
const serverAdress = 'https://qmining.frylabs.net/'
|
const serverAdress = 'https://qmining.frylabs.net/'
|
||||||
// const serverAdress = 'http://localhost:8080/'
|
// const serverAdress = 'http://localhost:8080/'
|
||||||
|
|
||||||
|
@ -74,6 +73,30 @@
|
||||||
var motd = ''
|
var motd = ''
|
||||||
var lastestVersion = ''
|
var lastestVersion = ''
|
||||||
|
|
||||||
|
const huTexts = {
|
||||||
|
lastChangeLog: '- "Húzza a megfelelő helyre ..." kérdés lekezelése\n- Kód refactor\n- Ha valami elszállt: <a href="https://qmining.frylabs.net">feedback</a> pls',
|
||||||
|
passiveModeActivated: 'Passzív mód bekapcsolva, mostantól kérdések nem lesznek szervertől letöltve.',
|
||||||
|
passiveModeDeactivated: 'Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!',
|
||||||
|
passiveModeActiveOnTest: 'Passzív mód bekapcsolva, válaszok megjelenítéséhez menü gomb alatt kapcsold ki, és frissíts!',
|
||||||
|
fatalError: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
|
||||||
|
consoleErrorInfo: 'Itteni hibák 100% a moodle hiba. Kivéve, ha oda van írva hogy script error ;) Ha ilyesmi szerepel itt, akkor olvasd el a segítség szekciót!',
|
||||||
|
freshStartWarning: '<h1>Moodle teszt userscript:<h1><h3>1.5.0 verzió: a script mostantól XMLHTTP kéréseket küld szerver fele! Erre a userscript futtató kiegészitőd is figyelmeztetni fog! Ha ez történik, a script rendes működése érdekében engedélyezd (Always allow domain)! Ha nem akarod, hogy ez történjen, akkor ne engedélyezd, vagy a menüben válaszd ki a "helyi fájl használata" opciót!</h3> <h3>Elküldött adatok: minden teszt után a kérdés-válasz páros. Fogadott adatok: Az összes eddig ismert kérdés. Érdemes help-et elolvasni!!!</h3><h5>Ez az ablak frissités után eltűnik. Ha nem, akkor a visza gombbal próbálkozz.</h5>',
|
||||||
|
couldntLoadData: 'Nem sikerült betölteni az adatokat, előfordulhat hogy nem elérhető a szerver! Segítségért kattints!',
|
||||||
|
noResult: 'Nincs találat :( Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez! Előfordulhat, hogy a tárgyat nem válsztottad ki a menüben.',
|
||||||
|
videoHelp: 'Miután elindítottad: Play/pause: space. Seek: Bal/jobb nyíl.',
|
||||||
|
menuButtonText: 'Kérdések Menu',
|
||||||
|
passiveModeText: 'Passzív mód',
|
||||||
|
passiveModeActivePopupMenuText: 'Passszív mód bekapcsolva. Kapcsold ki a kérdések betöltéséhez!',
|
||||||
|
couldntLoadDataPopupMenuText: 'A kérdéseket nem lehetett beolvasni, ellenőrizd hogy elérhető-e a szerver',
|
||||||
|
showGreetingOnEveryPage: 'Üdvözlő üzenet mutatása minden oldalon',
|
||||||
|
close: 'Bezárás',
|
||||||
|
help: 'Help',
|
||||||
|
websiteBugreport: 'Weboldal / Bug report',
|
||||||
|
donate: 'Donate'
|
||||||
|
}
|
||||||
|
|
||||||
|
var texts = huTexts
|
||||||
|
|
||||||
const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */
|
const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */
|
||||||
|
|
||||||
// : question-classes {{{
|
// : question-classes {{{
|
||||||
|
@ -933,7 +956,7 @@
|
||||||
if (count === -2 && subjCount === -2 && skipLoad) {
|
if (count === -2 && subjCount === -2 && skipLoad) {
|
||||||
if (url.includes('/quiz/') && url.includes('attempt.php')) {
|
if (url.includes('/quiz/') && url.includes('attempt.php')) {
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: 'Passzív mód bekapcsolva, válaszok megjelenítéséhez menü gomb alatt kapcsold ki, és frissíts!',
|
m: texts.passiveModeActiveOnTest,
|
||||||
isSimple: true
|
isSimple: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -949,7 +972,7 @@
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
|
m: texts.fatalError,
|
||||||
isSimple: true
|
isSimple: true
|
||||||
}, undefined, () => {
|
}, undefined, () => {
|
||||||
OpenErrorPage(e)
|
OpenErrorPage(e)
|
||||||
|
@ -958,9 +981,7 @@
|
||||||
Exception(e, 'script error at main:')
|
Exception(e, 'script error at main:')
|
||||||
}
|
}
|
||||||
if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys
|
if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys
|
||||||
Log(
|
Log(texts.consoleErrorInfo)
|
||||||
'Itteni hibák 100% a moodle hiba. Kivéve, ha oda van írva hogy script error ;) Ha ilyesmi szerepel itt, akkor olvasd el a segítség szekciót!'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
console.log('Moodle Test Script run time:')
|
console.log('Moodle Test Script run time:')
|
||||||
console.timeEnd('main')
|
console.timeEnd('main')
|
||||||
|
@ -1045,9 +1066,7 @@
|
||||||
setVal('firstRun', false)
|
setVal('firstRun', false)
|
||||||
ShowHelp() // showing help
|
ShowHelp() // showing help
|
||||||
|
|
||||||
document.write(
|
document.write(texts.freshStartWarning)
|
||||||
'<h1>Moodle teszt userscript:<h1><h3>1.5.0 verzió: a script mostantól XMLHTTP kéréseket küld szerver fele! Erre a userscript futtató kiegészitőd is figyelmeztetni fog! Ha ez történik, a script rendes működése érdekében engedélyezd (Always allow domain)! Ha nem akarod, hogy ez történjen, akkor ne engedélyezd, vagy a menüben válaszd ki a "helyi fájl használata" opciót!</h3> <h3>Elküldött adatok: minden teszt után a kérdés-válasz páros. Fogadott adatok: Az összes eddig ismert kérdés. Érdemes help-et elolvasni!!!</h3><h5>Ez az ablak frissités után eltűnik. Ha nem, akkor a visza gombbal próbálkozz.</h5>'
|
|
||||||
)
|
|
||||||
document.close()
|
document.close()
|
||||||
throw new Error('something, so this stuff stops')
|
throw new Error('something, so this stuff stops')
|
||||||
}
|
}
|
||||||
|
@ -1122,7 +1141,7 @@
|
||||||
Log('Couldt parse data!')
|
Log('Couldt parse data!')
|
||||||
Log(e)
|
Log(e)
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: 'Nem sikerült betölteni az adatokat! Kattints a manualért',
|
m: texts.couldntLoadData,
|
||||||
isSimple: true
|
isSimple: true
|
||||||
}, undefined, ShowHelp)
|
}, undefined, ShowHelp)
|
||||||
}
|
}
|
||||||
|
@ -1185,6 +1204,7 @@
|
||||||
|
|
||||||
// : UI handling {{{
|
// : UI handling {{{
|
||||||
function HandleUI (url, count, subjCount) {
|
function HandleUI (url, count, subjCount) {
|
||||||
|
// FIXME: normal string building with localisation :/
|
||||||
var newVersion = false // if the script is newer than last start
|
var newVersion = false // if the script is newer than last start
|
||||||
var loaded = count !== -1 // if script could load stuff
|
var loaded = count !== -1 // if script could load stuff
|
||||||
|
|
||||||
|
@ -1193,12 +1213,11 @@
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log('Some weird error trying to set new verison')
|
Log('Some weird error trying to set new verison')
|
||||||
}
|
}
|
||||||
newVersion = true // TODO
|
|
||||||
var greetMsg = '' // message to show at the end
|
var greetMsg = '' // message to show at the end
|
||||||
var timeout = null // the timeout. if null, it wont be hidden
|
var timeout = null // the timeout. if null, it wont be hidden
|
||||||
// no new version, nothing loaded
|
// no new version, nothing loaded
|
||||||
if (!newVersion && !loaded) { // --------------------------------------------------------------------------------------------------------------
|
if (!newVersion && !loaded) { // --------------------------------------------------------------------------------------------------------------
|
||||||
greetMsg = 'Hiba a @resource tagnál, vagy a fileval van gond! (Lehet át lett helyezve, vagy üres, vagy nincs tárgy kiválasztva) Vagy válaszd a netes adatok használatát menüben. Ellenőrizd az elérési utat, vagy hogy a Tampermonkey bővítmény eléri-e a fájlokat. Ha netes forrást használsz, akkor nem elérhető a szerver! Segítségért kattints!'
|
greetMsg = texts.couldntLoadData
|
||||||
}
|
}
|
||||||
var showSplash = (getVal('showSplash') === undefined) || getVal('showSplash') // getting value, if splash screen should be shown. Its true, if its undefined, or true
|
var showSplash = (getVal('showSplash') === undefined) || getVal('showSplash') // getting value, if splash screen should be shown. Its true, if its undefined, or true
|
||||||
// no new version, everything loaded, and show splash is enabled. otherwise something happened, so showing it
|
// no new version, everything loaded, and show splash is enabled. otherwise something happened, so showing it
|
||||||
|
@ -1226,16 +1245,16 @@
|
||||||
timeout = undefined
|
timeout = undefined
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
greetMsg += ' Az adatfájlban nem adtál meg nevet. Vagy nem elérhető a szerver. Katt a helpért!'
|
greetMsg += ' nem elérhető a szerver. Katt a helpért!'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// new version, nothing loaded
|
// new version, nothing loaded
|
||||||
if (newVersion && !loaded) { // --------------------------------------------------------------------------------------------------------------
|
if (newVersion && !loaded) { // --------------------------------------------------------------------------------------------------------------
|
||||||
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. Új verzió!\n Írd át a @resouce tagnál az elírési utat! Kivéve ha üres a file, akkor töltsd fel :) Nincs kérdés betöltve! Segítséghez kattints. Changelog:\n' + lastChangeLog // showing changelog too
|
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. Új verzió!\n Írd át a @resouce tagnál az elírési utat! Kivéve ha üres a file, akkor töltsd fel :) Nincs kérdés betöltve! Segítséghez kattints. Changelog:\n' + texts.lastChangeLog // showing changelog too
|
||||||
}
|
}
|
||||||
// new version, everything loaded -> set lastVerson to current
|
// new version, everything loaded -> set lastVerson to current
|
||||||
if (newVersion && loaded) { // --------------------------------------------------------------------------------------------------------------
|
if (newVersion && loaded) { // --------------------------------------------------------------------------------------------------------------
|
||||||
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. ' + count + ' kérdés és ' + subjCount + ' tárgy betöltve. Verzió frissítve ' + info().script.version + '-re. Changelog:\n' + lastChangeLog
|
greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. ' + count + ' kérdés és ' + subjCount + ' tárgy betöltve. Verzió frissítve ' + info().script.version + '-re. Changelog:\n' + texts.lastChangeLog
|
||||||
setVal('lastVerson', info().script.version) // setting lastVersion
|
setVal('lastVerson', info().script.version) // setting lastVersion
|
||||||
}
|
}
|
||||||
if (!SUtils.EmptyOrWhiteSpace(motd)) {
|
if (!SUtils.EmptyOrWhiteSpace(motd)) {
|
||||||
|
@ -1316,7 +1335,7 @@
|
||||||
ShowMessage(answers)
|
ShowMessage(answers)
|
||||||
} else {
|
} else {
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: 'Nincs találat :( Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez! Előfordulhat, hogy a tárgyat nem válsztottad ki a menüben.',
|
m: texts.noResult,
|
||||||
isSimple: true
|
isSimple: true
|
||||||
}, undefined, function () {
|
}, undefined, function () {
|
||||||
OpenErrorPage({
|
OpenErrorPage({
|
||||||
|
@ -1338,6 +1357,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowSaveQuizDialog (addedQ, allQ, allOutput, output, sendSuccess, sentData) {
|
function ShowSaveQuizDialog (addedQ, allQ, allOutput, output, sendSuccess, sentData) {
|
||||||
|
// FIXME: normal string building with localisation :/
|
||||||
var msg = ''
|
var msg = ''
|
||||||
if (addedQ > 0) {
|
if (addedQ > 0) {
|
||||||
msg = 'Klikk ide a nyers adatokhoz. ' + addedQ + ' új kérdés!'
|
msg = 'Klikk ide a nyers adatokhoz. ' + addedQ + ' új kérdés!'
|
||||||
|
@ -1581,8 +1601,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
var toadd = MPM.GetVideoElement()
|
var toadd = MPM.GetVideoElement()
|
||||||
var node = CreateNodeWithText(toadd,
|
var node = CreateNodeWithText(toadd, texts.videoHelp)
|
||||||
'Miután elindítottad: Play/pause: space. Seek: Bal/jobb nyíl.')
|
|
||||||
node.style.margin = '5px 5px 5px 5px' // fancy margin
|
node.style.margin = '5px 5px 5px 5px' // fancy margin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1890,7 +1909,7 @@
|
||||||
// menu text
|
// menu text
|
||||||
// var menuTextBox = CreateNodeWithText(menuButtonDiv, "Kérdések\nMenü");
|
// var menuTextBox = CreateNodeWithText(menuButtonDiv, "Kérdések\nMenü");
|
||||||
|
|
||||||
var menuButton = CreateNodeWithText(menuButtonDiv, 'Kérdések Menu', 'button')
|
var menuButton = CreateNodeWithText(menuButtonDiv, texts.menuButtonText, 'button')
|
||||||
menuButton.style.width = buttonWidth + 'px'
|
menuButton.style.width = buttonWidth + 'px'
|
||||||
menuButton.style.border = 'none'
|
menuButton.style.border = 'none'
|
||||||
menuButton.style.height = buttonHeight - 20 + 'px'
|
menuButton.style.height = buttonHeight - 20 + 'px'
|
||||||
|
@ -1921,9 +1940,9 @@
|
||||||
setVal('skipLoad', questionsTickBox.checked)
|
setVal('skipLoad', questionsTickBox.checked)
|
||||||
var msg = ''
|
var msg = ''
|
||||||
if (getVal('skipLoad')) {
|
if (getVal('skipLoad')) {
|
||||||
msg = 'Passzív mód bekapcsolva, mostantól kérdések nem lesznek szervertől letöltve.'
|
msg = texts.passiveModeActivated
|
||||||
} else {
|
} else {
|
||||||
msg = 'Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!'
|
msg = texts.passiveModeDeactivated
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
|
@ -1931,8 +1950,7 @@
|
||||||
isSimple: true
|
isSimple: true
|
||||||
}, 6)
|
}, 6)
|
||||||
})
|
})
|
||||||
var loadDataCheckBoxText = CreateNodeWithText(questionsTickBox,
|
var loadDataCheckBoxText = CreateNodeWithText(questionsTickBox, texts.passiveModeText, 'span')
|
||||||
'Passzív mód', 'span')
|
|
||||||
loadDataCheckBoxText.style.fontSize = '12px'
|
loadDataCheckBoxText.style.fontSize = '12px'
|
||||||
|
|
||||||
menuButtonDiv.appendChild(loadDataCheckBoxText)
|
menuButtonDiv.appendChild(loadDataCheckBoxText)
|
||||||
|
@ -2088,11 +2106,11 @@
|
||||||
|
|
||||||
if (getVal('skipLoad')) {
|
if (getVal('skipLoad')) {
|
||||||
textBox = CreateNodeWithText(noDataRowCell,
|
textBox = CreateNodeWithText(noDataRowCell,
|
||||||
'Passszív mód bekapcsolva. Kapcsold ki a kérdések betöltéséhez!'
|
texts.passiveModeActivePopupMenuText
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
textBox = CreateNodeWithText(noDataRowCell,
|
textBox = CreateNodeWithText(noDataRowCell,
|
||||||
'A kérdéseket nem lehetett beolvasni, ellenőrizd hogy elérhető-e a szerver'
|
texts.couldntLoadDataPopupMenuText
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
textBox.style.margin = fiveMargin // fancy margin
|
textBox.style.margin = fiveMargin // fancy margin
|
||||||
|
@ -2116,7 +2134,7 @@
|
||||||
setVal('showSplash', splashTickBox.checked)
|
setVal('showSplash', splashTickBox.checked)
|
||||||
}) // adding clicktextNode
|
}) // adding clicktextNode
|
||||||
|
|
||||||
CreateNodeWithText(splashTickboxCell, 'Üdvözlő üzenet mutatása minden oldalon', 'span')
|
CreateNodeWithText(splashTickboxCell, texts.showGreetingOnEveryPage, 'span')
|
||||||
|
|
||||||
// setting up buttons
|
// setting up buttons
|
||||||
var buttonRow = tbl.insertRow()
|
var buttonRow = tbl.insertRow()
|
||||||
|
@ -2134,7 +2152,7 @@
|
||||||
cursor: 'pointer'
|
cursor: 'pointer'
|
||||||
}
|
}
|
||||||
// x button ------------------------------------------------------------------------------------------------------------------------------
|
// x button ------------------------------------------------------------------------------------------------------------------------------
|
||||||
let xButton = CreateNodeWithText(buttonCell, 'Bezárás', 'button')
|
let xButton = CreateNodeWithText(buttonCell, texts.close, 'button')
|
||||||
Object.keys(buttonStyle).sort().forEach((key) => {
|
Object.keys(buttonStyle).sort().forEach((key) => {
|
||||||
xButton.style[key] = buttonStyle[key]
|
xButton.style[key] = buttonStyle[key]
|
||||||
})
|
})
|
||||||
|
@ -2143,7 +2161,7 @@
|
||||||
CloseMenu()
|
CloseMenu()
|
||||||
}) // adding clicktextNode
|
}) // adding clicktextNode
|
||||||
// help button ----------------------------------------------------------------------------------------------------------------
|
// help button ----------------------------------------------------------------------------------------------------------------
|
||||||
let helpButton = CreateNodeWithText(buttonCell, 'Help', 'button')
|
let helpButton = CreateNodeWithText(buttonCell, texts.help, 'button')
|
||||||
Object.keys(buttonStyle).sort().forEach((key) => {
|
Object.keys(buttonStyle).sort().forEach((key) => {
|
||||||
helpButton.style[key] = buttonStyle[key]
|
helpButton.style[key] = buttonStyle[key]
|
||||||
})
|
})
|
||||||
|
@ -2154,7 +2172,7 @@
|
||||||
|
|
||||||
// site link ----------------------------------------------------------------------------------------------------------------
|
// site link ----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
let siteLink = CreateNodeWithText(buttonCell, 'Weboldal / Bug report', 'button')
|
let siteLink = CreateNodeWithText(buttonCell, texts.websiteBugreport, 'button')
|
||||||
Object.keys(buttonStyle).sort().forEach((key) => {
|
Object.keys(buttonStyle).sort().forEach((key) => {
|
||||||
siteLink.style[key] = buttonStyle[key]
|
siteLink.style[key] = buttonStyle[key]
|
||||||
})
|
})
|
||||||
|
@ -2165,7 +2183,7 @@
|
||||||
|
|
||||||
// donate link ----------------------------------------------------------------------------------------------------------------
|
// donate link ----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
let donateLink = CreateNodeWithText(buttonCell, 'Donate', 'button')
|
let donateLink = CreateNodeWithText(buttonCell, texts.donate, 'button')
|
||||||
Object.keys(buttonStyle).sort().forEach((key) => {
|
Object.keys(buttonStyle).sort().forEach((key) => {
|
||||||
donateLink.style[key] = buttonStyle[key]
|
donateLink.style[key] = buttonStyle[key]
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue