User:Alex 21/script-seriesoverview.js

// $(function($) {	setTimeout(function { $.when( mw.loader.using( ['mediawiki.util']), $.ready ).then(function {			var portletlink = mw.util.addPortletLink('p-tv', '#', 'Series overview');			$(portletlink).click( function(e) { e.preventDefault; // Find overview table var overview = document.getElementById('seriesoverview'); if (overview === null) { var k = 0; var alltables = document.getElementById('mw-content-text').getElementsByTagName('table'); overview = alltables[k]; var className = overview.className; while (so_tableIndexOf(className,"ambox") || so_tableIndexOf(className,"infobox") || so_tableIndexOf(className,"mw-collapsible")) { k++; overview = alltables[k]; className = overview.className; }				}				// Define parameters var df = 0; var _i = 1; var endExist = false; var episodesCol; var SpecialSplit = [' ',' ']; // 0: Special; 1: Split var headerBase = 3; var network_double = 0; var network_single = 0; var infoheaderonly = 0; var auxheaders = 0; var dateReg = /(([^\s]*)\s)?(([^\s,]*))?.*(\d{4})/; // Begin template var _template_head = ""; copyContent(_template); alert("Copied! Now go to the editing page and paste over the raw code."); // Function: Remove reference function so_ref(cell,comment) { if (comment) { if (cell.innerHTML.indexOf("/g,""); }				}				// Function: Raw link to wiki link function so_link(link) { if (link === undefined || link.href === undefined) return link; var nwlink = link.href.replace("https://en.wikipedia.org/wiki/","").replace("_", " "); return "")+link.innerHTML+""; }				// Function: Remove reference from data function so_dateref(cell) { return (cell.innerHTML.indexOf('<')>=0 ? cell.innerHTML.substr(0, cell.innerHTML.indexOf('<')) : cell.innerHTML).split(' ').join(' '); }				// Function: Bold and italic text to wiki function so_wiki(text) { return text.replace(/(.*)<\/i>/g, "$1").replace(/(.*)<\/b>/g, "$1"); }				// Function: Dates to wiki templates function so_startend(cell,se,df) { var monthNumber = new Date(Date.parse(cell[1]+" 1, 2005")).getMonth+1; return ""; }				// Function: Chceck if classname contains single class function so_tableIndexOf(className,content) { return (className.indexOf(content) >= 0); }				// Function: Check if text contains TBA, TBD, N/A function so_tba(text) { text = text.toLowerCase; return text.indexOf("tba") < 0 && text.indexOf("tbd") < 0 &&  text.indexOf("n/a") < 0; }				// Function: Get value of ThisKey function so_ThisKey(_i,SpecialSplit) { var ThisKey = _i+SpecialSplit[1]+SpecialSplit[0]; if (ThisKey.indexOf(' ') != -1) { var spaces = ThisKey.length-ThisKey.replace(/\s/g,'').length; ThisKey = ThisKey.replace(/\s/g,''); for (a = 0; a < spaces; a++) ThisKey += ' '; }					return ThisKey; }			});		});	},600); }); //