Content deleted Content added
Opencooper (talk | contribs) add |
Opencooper (talk | contribs) convert all to halfwidth |
||
Line 78:
if (jaLabel) {
jaLabel = jaLabel.toHalfWidth();
console.log("showKanji-dev.js: kanji: " + jaLabel);
buildRegexes(jaLabel);
Line 220 ⟶ 221:
}
wikitext = wikitext.replace(/\{\{.*?\}\}/g, "{{}}"); // Remove templates
wikitext = wikitext.toHalfWidth();
console.log("showKanji-dev.js: lead: " + wikitext);
Line 238 ⟶ 240:
$("#kanjiInfo rt").addClass("kanjiInfo-jawiki");
}
// Adapted from:
// http://ilog4.blogspot.com/2015/09/javascript-convert-full-width-and-half.html
// https://stackoverflow.com/a/20488304/1995949
// https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms
String.prototype.toHalfWidth = function() {
return this.replace(/[\uff01-\uff5d]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)});
};
function displayKana(kana) {
|