mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-10-27 20:47:29 +08:00
14 lines
412 B
JavaScript
14 lines
412 B
JavaScript
this.makemeahanzi.lookupCharacter = (character, callback) => {
|
|
if (!character) return;
|
|
const part = Math.floor(character.charCodeAt(0) / 256);
|
|
$.get(`characters/part-${part}.txt`, (response, code) => {
|
|
if (code !== 'success') throw new Error(code);
|
|
const data = JSON.parse(response);
|
|
for (let row of data) {
|
|
if (row.character === character) {
|
|
callback(row);
|
|
}
|
|
}
|
|
});
|
|
}
|