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

Content deleted Content added
Undid revision 1057122235 by Opencooper (talk)
trying to support see tables that point to other entries
Line 414:
// Wiktionary adds readings as furigana
var headword = parsed.find(".headword:lang(ja)").first();
var seeTable = parsed.find(".Jpan ruby").first();
var kanji = "";
var kana = "";
if (headword.length) {
// Wiktionary already binds their kana, so we have to undo the process to get
// the constituent parts, at least with the current markup
var childNodes = headword[0].childNodes;
for (let i = 0;var ichildNodes <= headword[0].childNodes.length; i++) {
for (let i = 0; i < childNodes.length; i++) {
if (childNodes[i].nodeName == "RUBY") {
var ruby = $ if (childNodes[i]).nodeName //== convert back to JQuery for"RUBY") convenience{
var ruby = $(childNodes[i]); // convert back to JQuery for convenience
ruby.children("rp").remove();
kana += ruby.children("rtrp").detach().textremove();
kanjikana += ruby.children("rt").detach().text();
kanji += ruby.text();
} else if (childNodes[i].nodeType == 3) { // "#text"
kanji += childNodes[i].nodeValue;
kana += childNodes[i].nodeValue;
}
}
} else if (seeTable.length) {
kanji = seeTable.children("rb").text();
rubykana = seeTable.children("rprt").removetext();
} else {
return;
}
 
if (kanji != wikidataKanji) { return; }