Changeset View
Changeset View
Standalone View
Standalone View
src/activities/gletters/gletters.js
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 68 | function start(items_, uppercaseOnly_, _mode) { | |||
---|---|---|---|---|---|
71 | mode = _mode; | 71 | mode = _mode; | ||
72 | currentLevel = 0; | 72 | currentLevel = 0; | ||
73 | currentSubLevel = 0; | 73 | currentSubLevel = 0; | ||
74 | 74 | | |||
75 | var locale = items.locale == "system" ? "$LOCALE" : items.locale | 75 | var locale = items.locale == "system" ? "$LOCALE" : items.locale | ||
76 | 76 | | |||
77 | // register the voices for the locale | 77 | // register the voices for the locale | ||
78 | GCompris.DownloadManager.updateResource(GCompris.DownloadManager.getVoicesResourceForLocale(GCompris.ApplicationInfo.getVoicesLocale(items.locale))); | 78 | GCompris.DownloadManager.updateResource(GCompris.DownloadManager.getVoicesResourceForLocale(GCompris.ApplicationInfo.getVoicesLocale(items.locale))); | ||
79 | 79 | if(!items.levels) | |||
80 | items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( | 80 | items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( | ||
81 | items.ourActivity.dataSetUrl + "default-"+locale+".json")); | 81 | items.ourActivity.dataSetUrl + "default-"+locale+".json")); | ||
82 | else | ||||
scagarwal: @AkshayCHD The code misses starting and closing braces. Do add them. | |||||
83 | items.wordlist.loadFromJSON(items.levels); | ||||
82 | // If wordlist is empty, we try to load from short locale and if not present again, we switch to default one | 84 | // If wordlist is empty, we try to load from short locale and if not present again, we switch to default one | ||
83 | var localeUnderscoreIndex = locale.indexOf('_') | 85 | var localeUnderscoreIndex = locale.indexOf('_') | ||
84 | // probably exist a better way to see if the list is empty | 86 | // probably exist a better way to see if the list is empty | ||
85 | if(items.wordlist.maxLevel == 0) { | 87 | if(items.wordlist.maxLevel == 0) { | ||
86 | var localeShort; | 88 | var localeShort; | ||
87 | // We will first look again for locale xx (without _XX if exist) | 89 | // We will first look again for locale xx (without _XX if exist) | ||
88 | if(localeUnderscoreIndex > 0) { | 90 | if(localeUnderscoreIndex > 0) { | ||
89 | localeShort = locale.substring(0, localeUnderscoreIndex) | 91 | localeShort = locale.substring(0, localeUnderscoreIndex) | ||
90 | } | 92 | } | ||
91 | else { | 93 | else { | ||
92 | localeShort = locale; | 94 | localeShort = locale; | ||
93 | } | 95 | } | ||
94 | // If not found, we will use the default file | 96 | // If not found, we will use the default file | ||
95 | items.wordlist.useDefault = true | 97 | items.wordlist.useDefault = true | ||
98 | if(!items.levels) | ||||
96 | items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( | 99 | items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( | ||
97 | items.ourActivity.dataSetUrl + "default-"+localeShort+".json")); | 100 | items.ourActivity.dataSetUrl + "default-"+localeShort+".json")); | ||
101 | else | ||||
@AkshayCHD The code misses starting and closing braces. Do add them. scagarwal: @AkshayCHD The code misses starting and closing braces. Do add them. | |||||
102 | items.wordlist.loadFromJSON(items.levels); | ||||
98 | // We remove the using of default file for next time we enter this function | 103 | // We remove the using of default file for next time we enter this function | ||
99 | items.wordlist.useDefault = false | 104 | items.wordlist.useDefault = false | ||
100 | } | 105 | } | ||
101 | maxLevel = items.wordlist.maxLevel; | 106 | maxLevel = items.wordlist.maxLevel; | ||
102 | droppedWords = new Array(); | 107 | droppedWords = new Array(); | ||
103 | initLevel(); | 108 | initLevel(); | ||
104 | } | 109 | } | ||
105 | 110 | | |||
106 | function stop() { | 111 | function stop() { | ||
107 | deleteWords(); | 112 | deleteWords(); | ||
108 | wordComponent = null | 113 | wordComponent = null | ||
109 | items.wordDropTimer.stop(); | 114 | items.wordDropTimer.stop(); | ||
110 | } | 115 | } | ||
111 | 116 | | |||
112 | function initLevel() { | 117 | function initLevel() { | ||
118 | if(items.levels) | ||||
119 | items.instructionText = items.levels[currentLevel].objective | ||||
@AkshayCHD The code misses starting and closing braces. Do add them. scagarwal: @AkshayCHD The code misses starting and closing braces. Do add them. | |||||
113 | items.audioVoices.clearQueue() | 120 | items.audioVoices.clearQueue() | ||
114 | items.bar.level = currentLevel + 1; | 121 | items.bar.level = currentLevel + 1; | ||
115 | wgMaxFallingItems = 3 | 122 | wgMaxFallingItems = 3 | ||
116 | successRate = 1.0 | 123 | successRate = 1.0 | ||
117 | 124 | | |||
118 | // initialize level | 125 | // initialize level | ||
119 | deleteWords(); | 126 | deleteWords(); | ||
120 | level = items.wordlist.getLevelWordList(currentLevel + 1); | 127 | level = items.wordlist.getLevelWordList(currentLevel + 1); | ||
▲ Show 20 Lines • Show All 285 Lines • ▼ Show 20 Line(s) | |||||
406 | 413 | | |||
407 | function playLetter(letter) { | 414 | function playLetter(letter) { | ||
408 | var locale = GCompris.ApplicationInfo.getVoicesLocale(items.locale) | 415 | var locale = GCompris.ApplicationInfo.getVoicesLocale(items.locale) | ||
409 | 416 | | |||
410 | items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices-$CA/"+locale+"/alphabet/" | 417 | items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices-$CA/"+locale+"/alphabet/" | ||
411 | + Core.getSoundFilenamForChar(letter))) | 418 | + Core.getSoundFilenamForChar(letter))) | ||
412 | } | 419 | } | ||
413 | 420 | | |||
414 | | ||||
415 | function focusTextInput() { | 421 | function focusTextInput() { | ||
416 | if (!GCompris.ApplicationInfo.isMobile && items && items.textinput) | 422 | if (!GCompris.ApplicationInfo.isMobile && items && items.textinput) | ||
417 | items.textinput.forceActiveFocus(); | 423 | items.textinput.forceActiveFocus(); | ||
418 | } | 424 | } |
@AkshayCHD The code misses starting and closing braces. Do add them.