Content deleted Content added
Opencooper (talk | contribs) temp |
Opencooper (talk | contribs) rework to handle bound headwords |
||
Line 381:
// Wiktionary adds readings as furigana
var headword = parsed.find(".headword:lang(ja)
headword.children("rp").remove();▼
var
var kana = "";
if (headword.text() != wikidataKanji) { return; }▼
// Wiktionary already binds their kana, so we have to undo the process to get
// the constituent parts, at least with the current markup
for (child in headword[0].childNodes) {
if (child.nodeName == "RUBY") {
var ruby = $(child) // convert back to JQuery for convenience
var kana = ruby.children("rt").detach().text();
var kanji = ruby.text();
} else if (child.nodeType == 3) { // "#text"
kanji += child.nodeValue;
kana += child.nodeValue;
}
}
if (kana) {
Line 391 ⟶ 406:
// Extra stuff just for fun
var definition = headword
$("#kanjiInfo").prop("title", definition);
}
|