Jump to content

User:Opencooper/nihongo.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$( mw.util.addPortletLink( 'p-cactions', "#", 'Nihongo', 'hStrings', 'Display nihongo template parameters', 'n') )
.click(
function highlightStrings() {
	// Don't run outside of viewing articles
	if (!((mw.config.get( 'wgCanonicalNamespace' ) === '' && mw.config.get( 'wgAction' ) === 'view'))
		  ) {
		return;
	}

    
    // Get wikitext
    // API docs: https://www.mediawiki.org/wiki/API:Revisions
    $.ajax({
        url: "https://ja.wikipedia.org/w/api.php",
        data: {
            action: "query",
            prop: "revisions",
            format: "json",
            titles: mw.config.get("wgPageName"),
            rvprop: "content",
            rvslots: "main",
            origin: "*"
        },
        success: parseWikitext
    });
}
);

function parseWikitext(response) {
	var pageText = response.query.pages[0].revisions[0].slots.main.content;
	
	// parseLang(pageText);
	// parseLang-ja(pageText);
	// parseTransl(pageText);
	parseNihongo(pageText);
/*	parseNihongo2(pageText);
	parseNihongo3(pageText);
	parseNihongo-s(pageText); */
	// parseNihongo_foot(pageText);
}