-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-lang.js
More file actions
55 lines (55 loc) · 1.59 KB
/
Copy pathscript-lang.js
File metadata and controls
55 lines (55 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function getCharItemByCharacter(char) {
var c = null;
for (var i = 0; i < sections.length; i++) {
if (sections[i].type = "character") {
c = sections[i].list.find(element => element.character === char);
if (c) return c;
}
}
if (!c) {
c = new Character(0, '', '', '');
}
return c;
}
function getPronunciationString(word) {
var _returnString = '';
for (var i = 0; i < word.length; i++) {
var _item = getCharItemByCharacter(word.charAt(i));
if ((_item) && (i != 0)) {
_returnString += '.';
}
if (_item) {
_returnString += _item.pronunciation;
} else {
_returnString += ' ';
}
}
return _returnString;
}
function load_lang(language, sections) {
var first_section_initialized = false;
for (var i = 0; i < language.sections.length; i++) {
var temp_section = new Section(language.sections[i].value, language.sections[i].type);
sections.push(temp_section);
if (!language.sections[i].disabled) {
if (!first_section_initialized) {
section = temp_section.title;
load_section(language.value, temp_section, function() {
hideAnswer();
item = getNotSoRandomListItem(temp_section.list, item_history, history_limit);
buildGUI(item, getActiveSection().type);
})
first_section_initialized = true;
} else {
load_section(language.value, temp_section)
}
}
}
}
function load_section(lang, section, custom_function) {
load_asset(
"https://learn-lang.glitch.me/assets/" + lang + "-" + section.title + ".JSON",
section.list,
custom_function
);
}