Dropdown box question getting fix, small design changes

This commit is contained in:
YourFriendlyNeighborhoodDealer 2019-03-05 08:23:28 +01:00
parent b646640993
commit 69e32bd3bc

33
main.js
View file

@ -23,12 +23,12 @@
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 = const lastChangeLog =
'- Passzív mód: ha bepipálod a menü gomb alatt, akkor nem tölti be minden alkalommal a kérdéseket.\n - Pár lényeges bugfix\n - Ha találkoztok bugokkal, akkor pls report! thanx'; '- Passzív mód: ha bepipálod a menü gomb alatt, akkor nem tölti be minden alkalommal a kérdéseket (csak csendben vár).\n - Pár lényeges bugfix\n - Ha találkoztok bugokkal, akkor pls report! thanx';
const serverAdress = "https://qmining.tk/"; const serverAdress = "https://qmining.tk/";
// forcing pages for testing. unless you test, do not set these to true! // forcing pages for testing. unless you test, do not set these to true!
// only one of these should be true for testing // only one of these should be true for testing
const forceTestPage = false; const forceTestPage = true;
const forceResultPage = false; const forceResultPage = false;
const forceDefaultPage = false; const forceDefaultPage = false;
const logElementGetting = false; const logElementGetting = false;
@ -38,7 +38,7 @@ const motdShowCount = 3;
var motd = ""; var motd = "";
var lastestVersion = ""; var lastestVersion = "";
const minMatchAmmount = 60; const minMatchAmmount = 55;
const lengthDiffMultiplier = 10; const lengthDiffMultiplier = 10;
//: Class descriptions {{{ //: Class descriptions {{{
@ -264,7 +264,14 @@ function Main() {
function GetAllQuestionsDropdown() { function GetAllQuestionsDropdown() {
if (logElementGetting) if (logElementGetting)
Log("getting dropdown question"); Log("getting dropdown question");
return document.getElementById("responseform").getElementsByTagName("p")[0].innerText; let items = document.getElementById("responseform").getElementsByTagName("p")[0].childNodes;
let r = "";
items.forEach((item) => {
if (item.tagName == undefined)
r += item.nodeValue;
});
return r;
} }
function GetAllQuestionsQtext() { function GetAllQuestionsQtext() {
@ -772,8 +779,13 @@ function ReadFile(cwith) {
var resource = ""; var resource = "";
try { try {
resource = GM_getResourceText("data"); // getting data from txt resource = GM_getResourceText("data"); // getting data from txt
if (resource == null) { if (resource == undefined) {
return; // TODO show some msg what happened
ShowMessage({
m: "Nem lehetett beolvasni a fájlt :c Ellenőrizd az elérési utat, vagy a fájl jogosultságokat",
isSimple: true
});
return;
} }
if (EmptyOrWhiteSpace(resource)) { if (EmptyOrWhiteSpace(resource)) {
throw { throw {
@ -812,7 +824,6 @@ function ReadNetDB(cwith, useNetDB) {
/* /*
* Returns a question database from the given data. * Returns a question database from the given data.
* Parameter should be raw read file in string with "\n"-s * Parameter should be raw read file in string with "\n"-s
* TODO: ??? -s are not listed as errors, tho works correctly
* */ * */
function ParseRawData(data) { function ParseRawData(data) {
@ -1112,7 +1123,6 @@ function HandleQuiz() {
answers.push(r); answers.push(r);
HighLightAnswer(result, j); // highlights the answer for the current result HighLightAnswer(result, j); // highlights the answer for the current result
} }
console.log(GetAnswerOptions());
ShowAnswers(answers); ShowAnswers(answers);
} }
@ -1741,6 +1751,8 @@ function ShowMenu() {
menuButtonDiv.style.left = window.innerWidth - buttonWidth * 1.5 + 'px'; menuButtonDiv.style.left = window.innerWidth - buttonWidth * 1.5 + 'px';
menuButtonDiv.style.zIndex = 999999; // TO THE MAX menuButtonDiv.style.zIndex = 999999; // TO THE MAX
menuButtonDiv.style.position = "fixed"; menuButtonDiv.style.position = "fixed";
// menuButtonDiv.style.borderStyle = "solid";
// menuButtonDiv.style.borderWidth = "1px";
// design // design
menuButtonDiv.style.textAlign = "center"; menuButtonDiv.style.textAlign = "center";
@ -1751,8 +1763,9 @@ function ShowMenu() {
// menu text // menu text
// var menuTextBox = CreateNodeWithText(menuButtonDiv, "Kérdések\nMenü"); // var menuTextBox = CreateNodeWithText(menuButtonDiv, "Kérdések\nMenü");
var menuButton = CreateNodeWithText(menuButtonDiv, "Helper Menu", "button"); var menuButton = CreateNodeWithText(menuButtonDiv, "Kérdések Menu", "button");
menuButton.style.width = buttonWidth + 'px'; menuButton.style.width = buttonWidth + 'px';
menuButton.style.border = 'none';
menuButton.style.height = buttonHeight - 20 + 'px'; menuButton.style.height = buttonHeight - 20 + 'px';
menuButton.style.background = "#222d32"; // background color menuButton.style.background = "#222d32"; // background color
menuButton.style.color = "#ffffff"; // background color menuButton.style.color = "#ffffff"; // background color
@ -2007,7 +2020,6 @@ function ShowMenuList() {
var xButton = CreateNodeWithText(buttonCell, "Bezárás", "button"); var xButton = CreateNodeWithText(buttonCell, "Bezárás", "button");
xButton.style.position = ""; xButton.style.position = "";
xButton.style.background = "white";
xButton.style.left = 10 + 'px'; xButton.style.left = 10 + 'px';
xButton.style.margin = "5px 5px 5px 5px"; // fancy margin xButton.style.margin = "5px 5px 5px 5px"; // fancy margin
xButton.style.top = menuDiv.offsetHeight + 'px'; xButton.style.top = menuDiv.offsetHeight + 'px';
@ -2019,7 +2031,6 @@ function ShowMenuList() {
var helpButton = CreateNodeWithText(buttonCell, "Help", "button"); var helpButton = CreateNodeWithText(buttonCell, "Help", "button");
helpButton.style.position = ""; helpButton.style.position = "";
helpButton.style.background = "white";
helpButton.style.left = 10 + 'px'; helpButton.style.left = 10 + 'px';
helpButton.style.margin = "5px 5px 5px 5px"; // fancy margin helpButton.style.margin = "5px 5px 5px 5px"; // fancy margin
helpButton.style.top = menuDiv.offsetHeight + 'px'; helpButton.style.top = menuDiv.offsetHeight + 'px';