User:Opencooper/showKanji-dev.js: Difference between revisions

Content deleted Content added
rework to handle bound headwords
fix looping
Line 387:
// Wiktionary already binds their kana, so we have to undo the process to get
// the constituent parts, at least with the current markup
forvar (childchildNodes in= headword[0].childNodes) {;
for (let i = 0; i < childNodes.length; i++) {
if (childchildNodes[i].nodeName == "RUBY") {
var ruby = $(childchildNodes[i]) // convert back to JQuery for convenience
ruby.children("rp").remove();
var kana = ruby.children("rt").detach().text();
var kanji = ruby.text();
} else if (childchildNodes[i].nodeType == 3) { // "#text"
kanji += childchildNodes[i].nodeValue;
kana += childchildNodes[i].nodeValue;
}
}