MediaWiki:Common.js: Difference between revisions

From Zymonic
Content added Content deleted
No edit summary
No edit summary
Line 8: Line 8:
if (all_links[i].parentNode.parentNode.className == "mw-parser-output") {
if (all_links[i].parentNode.parentNode.className == "mw-parser-output") {
var title_name = all_links[i].title;
var title_name = all_links[i].title;
titles.forEach(arraydup)
titles.forEach(arraydup);
if (title_name !== '') {
if (title_name !== '') {
titles.push(title_name);
titles.push(title_name);

Revision as of 23:08, 3 September 2018

/* Any JavaScript here will be loaded for all users on every page load. */
$(function () {
    var get_links_element = document.getElementById("get_links");
    var titles = [];
    var all_links = document.links;
    var i;
    for (i = 0; i < all_links.length; i++) {
        if (all_links[i].parentNode.parentNode.className == "mw-parser-output") {
        	var title_name = all_links[i].title;
        	titles.forEach(arraydup);
        	if (title_name !== '') {
        		titles.push(title_name);
        	}
        }
       
    }
    get_links_element.innerHTML = titles;
    
    function arraydup(item) {
        if (item == title_name) {
            title_name = '';
        }
    }
	
}());