Content deleted Content added
Opencooper (talk | contribs) reuse our regexes |
Opencooper (talk | contribs) comment |
||
(15 intermediate revisions by the same user not shown) | |||
Line 51:
https://en.wikipedia.org/wiki/Ninjō - No interlanguage, but wiktionary
https://en.wikipedia.org/wiki/Seiza - Interlanguage failed, but wiktionary
https://en.wikipedia.org/wiki/Epsomite - No interlanguage, but wiktionary "see" Table
https://en.wikipedia.org/wiki/Bakayaro!_I%27m_Plenty_Mad - only part of parenthesis extracted
Line 213 ⟶ 214:
function parseKanaClaim(response) {
var kana;
nativeLabel: "P1705",
kana = response.claims.P1814[0].mainsnak.datavalue.value;▼
officialName: "P1448",
} else if (response.claims.P1476 && response.claims.P1476[0].qualifiers▼
nameInNativeLanguage: "P1559"
&& response.claims.P1476[0].qualifiers.P1814) {▼
var nameInKana = "P1814";
kana = response.claims.P1476[0].qualifiers.P1814[0].datavalue.value;▼
// Try getting nameInKana as a qualifier to some properties
&& response.claims.P1705[0].qualifiers.P1814) {▼
for (var prop in properties) {
var pnum = properties[prop];
if (response.claims[pnum]) {
if (kanji.replace(/ /g, "") == wikidataKanji.replace(/ /g, "")
break;
}
}
}
// Try getting nameInKana as a general claim
if (!kana && response.claims[nameInKana]) {
prop = "nameInKana";
}
// We couldn't find nameInKana
if (!kana) {
getInterlanguage();
return;
Line 232 ⟶ 252:
displayKana(kana);
$("#kanjiInfo").addClass("kanjiInfo-wikidata");
$("#kanjiInfo").addClass("kanjiInfo-wikidata-" + prop);
}
Line 248 ⟶ 269:
success: function(response) {
var pageId = mw.config.get( 'wgArticleId' );
var
var langlinks = page ? page.langlinks : undefined;
var jaLabel;
if (langlinks) {
Line 393 ⟶ 415:
// 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) {
for (let i = 0; i < childNodes.length; i++) {
var ruby = $(childNodes[i]); // convert back to JQuery for convenience
ruby.children("rp").remove();▼
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();
} else {
return;
}
▲ if (kanji != wikidataKanji) { return; }
if (kana) {
|