User:Wasted Time R/scripts/jlsuncite.js

/* User:Wasted Time R/scripts/jlsuncite.js */

function jlsuncite { //var apiurl = mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml'; //var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null; //xmlhttp.open('GET',apiurl, false); //xmlhttp.send(null); //alert(xmlhttp.responseXML.getElementById('14').childNodes[0].nodeValue);

var txt = document.editform.wpTextbox1.value; var sortkey = ''; // Save the position of the editbox scrollbar var scrollPosition = document.editform.wpTextbox1.scrollTop;

// create an array of all the cite news instances var citenewsarr = txt.match(/\{\{\s*cite\s+news\s+.+?\}\}/ig); if (!citenewsarr) { alert('There are no cite news instances to change!'); return; } else { alert('There are ' + citenewsarr.length + ' cite news instances to change.'); }

for (i = 0; i < citenewsarr.length; i++) { var citenews = citenewsarr[i]; if (i == 0) alert('The citenews instance is: ' + citenews);

// parse for the individual pieces var url = citenews.match(/\|\s*url\s*=(.+?)\s*\|/); if (i == 0) alert('... the url has length ' + url.length + ' and is: ' + url); }

// Now that we know that everything is OK, we can proceed with modifying the content of External //txt = txt.replace("External","Externaljls"); document.editform.wpTextbox1.value=txt; // Restore scroll position document.editform.wpTextbox1.scrollTop = scrollPosition; }

$(function {  if(document.forms.editform) {    mw.util.addPortletLink('p-cactions', 'javascript:jlsuncite', 'jlsuncite', 'ca-jlsuncite', , , document.getElementById('ca-purge'));  } });

/* */