Wikipedia:Monobook.js/MonobookCompleto.js/Monobook: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Esporto globali
Esporto funzioni e ne rimuovo alcune inutilizzate
Riga 21:
pulsantiImmagine["cgr"] = '//upload.wikimedia.org/wikipedia/commons/d/d9/Button_uncorrect.png';
pulsantiHotkey["cgr"] = '';
 
 
function curled(text) {
return "{{" + text + "}}";
}
 
function curled1(text) {
return "{{" + text;
}
 
function curled2(text) {
return text + "}}";
}
 
function bracket(text) {
return "<" + text + ">";
}
 
//Funzioni per fare le query al DB con api.php
var wpajax = {
http: function(bundle) {
// mandatory: bundle.url
// optional: bundle.async
// optional: bundle.method
// optional: bundle.headers
// optional: bundle.data
// optional: bundle.onSuccess (xmlhttprequest, bundle)
// optional: bundle.onFailure (xmlhttprequest, bundle)
// optional: bundle.otherStuff OK too, passed to onSuccess and onFailure
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttp = false
}
}
}
 
if (xmlhttp) {
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4)
wpajax.httpComplete(xmlhttp, bundle);
};
xmlhttp.open(bundle.method ? bundle.method : "GET", bundle.url, bundle.async == false ? false : true);
if (bundle.headers) {
for (var field in bundle.headers)
xmlhttp.setRequestHeader(field, bundle.headers[field]);
}
xmlhttp.send(bundle.data ? bundle.data : null);
}
return xmlhttp;
},
 
httpComplete: function(xmlhttp, bundle) {
if (xmlhttp.status == 200 || xmlhttp.status == 302) {
if (bundle.onSuccess)
bundle.onSuccess(xmlhttp, bundle);
} else if (bundle.onFailure) {
bundle.onFailure(xmlhttp, bundle);
} else {
// A activer en debug mode ?
// alert(xmlhttp.statusText);
}
}
};
 
// Parser
if (document.implementation.createDocument) {
var gml_xmlparser = new DOMParser();
}
 
function gml_XMLParse(string) {
if (document.implementation.createDocument) {
return gml_xmlparser.parseFromString(string, "text/xml");
} else if (window.ActiveXObject) {
var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM");
gml_xmldoc.async = "false";
ret = gml_xmldoc.loadXML(string);
if (!ret)
return null;
return gml_xmldoc.documentElement;
}
return null;
}
 
// HTMLize
String.prototype.htmlize = function() {
var chars = new Array('&', '<', '>', '"');
var entities = new Array('amp', 'lt', 'gt', 'quot');
var regex = new RegExp();
var string = this;
for (var i = 0; i < chars.length; i++) {
regex.compile(chars[i], "g");
string = string.replace(regex, '&' + entities[i] + ';');
}
return string;
}
 
/**** Carica le funzioni personalizzate ****/