( charCount: number, input: string, corrected: string, inputCharacters: string[], wordCharacters: string[], correctedCharacters: string[], containsKorean: boolean, )
| 1249 | } |
| 1250 | |
| 1251 | function buildWordLettersHTML( |
| 1252 | charCount: number, |
| 1253 | input: string, |
| 1254 | corrected: string, |
| 1255 | inputCharacters: string[], |
| 1256 | wordCharacters: string[], |
| 1257 | correctedCharacters: string[], |
| 1258 | containsKorean: boolean, |
| 1259 | ): string { |
| 1260 | let out = ""; |
| 1261 | for (let c = 0; c < charCount; c++) { |
| 1262 | let correctedChar; |
| 1263 | try { |
| 1264 | correctedChar = !containsKorean |
| 1265 | ? correctedCharacters[c] |
| 1266 | : Hangul.assemble(corrected.split(""))[c]; |
| 1267 | } catch (e) { |
| 1268 | correctedChar = undefined; |
| 1269 | } |
| 1270 | let extraCorrected = ""; |
| 1271 | const historyWord: string = !containsKorean |
| 1272 | ? corrected |
| 1273 | : Hangul.assemble(corrected.split("")); |
| 1274 | if ( |
| 1275 | c + 1 === charCount && |
| 1276 | historyWord !== undefined && |
| 1277 | historyWord.length > input.length |
| 1278 | ) { |
| 1279 | extraCorrected = "extraCorrected"; |
| 1280 | } |
| 1281 | |
| 1282 | let displayLetter = inputCharacters[c]; |
| 1283 | if (displayLetter === " ") { |
| 1284 | displayLetter = "_"; |
| 1285 | } |
| 1286 | |
| 1287 | if (Config.mode === "zen" || wordCharacters[c] !== undefined) { |
| 1288 | if (Config.mode === "zen" || inputCharacters[c] === wordCharacters[c]) { |
| 1289 | if ( |
| 1290 | correctedChar === inputCharacters[c] || |
| 1291 | correctedChar === undefined |
| 1292 | ) { |
| 1293 | out += `<letter class="correct ${extraCorrected}">${displayLetter}</letter>`; |
| 1294 | } else { |
| 1295 | out += `<letter class="corrected ${extraCorrected}">${ |
| 1296 | displayLetter |
| 1297 | }</letter>`; |
| 1298 | } |
| 1299 | } else { |
| 1300 | if (inputCharacters[c] === getCurrentInput()) { |
| 1301 | out += `<letter class='correct ${extraCorrected}'>${ |
| 1302 | wordCharacters[c] |
| 1303 | }</letter>`; |
| 1304 | } else if (inputCharacters[c] === undefined) { |
| 1305 | out += `<letter>${wordCharacters[c]}</letter>`; |
| 1306 | } else { |
| 1307 | out += `<letter class="incorrect ${extraCorrected}">${ |
| 1308 | wordCharacters[c] |
no test coverage detected