User:DStoykov/defaultsort.js: Difference between revisions

Content deleted Content added
No edit summary
m Remove legacy globals per phab:T72470 (via WP:JWB)
 
(4 intermediate revisions by 2 users not shown)
Line 2:
 
function defaultsort() {
//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 category links
if (txt.match(/\{\{\s*defaultsort/i)) {
Line 47 ⟶ 49:
}
document.editform.wpTextbox1.value=txt;
// Restore scroll position
document.editform.wpTextbox1.scrollTop = scrollPosition;
}
 
addOnloadHook$(function () {
if(document.forms.editform) {
mw.util.addPortletLink('p-cactions', 'javascript:defaultsort()', 'defaultsort', 'ca-defaultsort', '', '', document.getElementById('ca-purge'));
}
});