worked on #14, now show:random gets a random english word with translation and querries it with an aux array
This commit is contained in:
parent
2e235e575f
commit
ce1c8c7bbb
8
main.js
8
main.js
@ -1,6 +1,7 @@
|
||||
let json = null;
|
||||
|
||||
let searchDictionary = {};
|
||||
let auxTranslatedDictionaryArray = [];
|
||||
|
||||
let header = null;
|
||||
let main = null;
|
||||
@ -229,7 +230,10 @@ function loadDictionary() {
|
||||
|
||||
//add: translations, meanings
|
||||
for (let o = 0; o < values[i].length; o++) {
|
||||
if (values[i][o].hasOwnProperty("translation")){searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"], true))};
|
||||
if (values[i][o].hasOwnProperty("translation")){
|
||||
searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"], true))
|
||||
auxTranslatedDictionaryArray.push(stripWord(values[i][o]["translation"], true))
|
||||
};
|
||||
if (values[i][o].hasOwnProperty("meaning")) searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"], true));
|
||||
}
|
||||
} catch (e) {
|
||||
@ -309,7 +313,7 @@ function doSearch(state = true) {
|
||||
}
|
||||
|
||||
//Manage search methods
|
||||
val = (val.indexOf("show:random") !== -1) ? random.choice(list(searchDictionary.values())) : val;
|
||||
val = (val.indexOf("show:random") !== -1) ? auxTranslatedDictionaryArray[(Math.floor(Math.random() * auxTranslatedDictionaryArray.length))] : val;
|
||||
val = (val.indexOf("show:all") !== -1) ? "" : val;
|
||||
|
||||
//Results
|
||||
|
Loading…
x
Reference in New Issue
Block a user