Hello, you have come here looking for the meaning of the word
User:Hippietrail/wfMsgCentre.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word
User:Hippietrail/wfMsgCentre.js, but we will also tell you about its etymology, its characteristics and you will know how to say
User:Hippietrail/wfMsgCentre.js in singular and plural. Everything you need to know about the word
User:Hippietrail/wfMsgCentre.js you have here. The definition of the word
User:Hippietrail/wfMsgCentre.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition of
User:Hippietrail/wfMsgCentre.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
//importScript('User:Hippietrail/hippajax.js');
document.write('<script type="text/javascript" src="https://en.wiktionary.org/w/index.php?title=User:Hippietrail/hippajax.js&action=raw&ctype=text/javascript"><\/script>');
// uppercase first char, leave rest as is
function ucfirst(t) {
return t.charAt(0).toUpperCase() + t.substring(1);
}
// convert a full mediawiki page title into an href
function makehref(arg) {
return arg.match(/^http:/) ? arg : wgArticlePath.replace('$1', arg);
}
// factory
function wfMsgCentreFactory() {
}
wfMsgCentreFactory.create = function() {
if (true) {
if (true) {
// fast, supports message cache; needs newer api.php with amlang
return new wfMsgCentre_allmsgs();
} else {
// fast but doesn't support message cache; works on older api.php
return new wfMsgCentre_proprev();
}
} else {
// not as fast but supports message cache and doesn't need api.php
return new wfMsgCentre_actraw();
}
}
// overall base class
function wfMsgCentre() {
}
// non-api-derived class
wfMsgCentre_actraw.prototype = new wfMsgCentre();
wfMsgCentre_actraw.constructor = wfMsgCentre_actraw;
function wfMsgCentre_actraw() {
if (window.console) console.log('action raw\n');
wfMsgCentre.call(this);
}
wfMsgCentre_actraw.prototype.batch = function(msgarray) {
function getmsg(title, forcontent) {
function on200(req) {
var v = req.responseText;
var x = msgarray;
if (x.xform != undefined)
v = x.xform(v);
x.obj = v;
};
var urls = [
wgScriptPath + '/index.php?usemsgcache=yes&action=raw&title=MediaWiki:' + ucfirst(title) + '/' + wgUserLanguage,
wgScriptPath + '/index.php?usemsgcache=yes&action=raw&title=MediaWiki:' + ucfirst(title)
];
var index = 0;
if (!forcontent || wgUserLanguage == wgContentLanguage)
index = 1;
ajax(urls, on200, on400);
function on400() {
index++;
if (index < urls.length)
ajax(urls, on200, on400);
};
};
for (var m in msgarray) {
getmsg(m, msgarray.forcontent);
}
}
// api base class
wfMsgCentre_api.prototype = new wfMsgCentre();
wfMsgCentre_api.constructor = wfMsgCentre_api;
function wfMsgCentre_api() {
wfMsgCentre.call(this);
}
wfMsgCentre_api.prototype.batch = function(msgarray) {
var that = this;
function on200(req) {
var rt = eval('(' + req.responseText + ')');
that.handleresponse(msgarray, rt);
};
var url = this.buildurl(msgarray);
if (url != null) {
ajax(url, on200, function(){});
} else {
if (console != undefined) console.log('no titles\n');
}
}
// api-derived classes
// class which uses api.php to get the raw content of several mediawiki: namespace pages at once
// there is no way to access messages in the message cache but not in the mediawiki: namespace
wfMsgCentre_proprev.prototype = new wfMsgCentre_api();
wfMsgCentre_proprev.constructor = wfMsgCentre_proprev;
function wfMsgCentre_proprev() {
if (window.console) console.log('prop revisions\n');
wfMsgCentre_api.call(this);
this.buildurl = function(msgarray) {
var titles = '';
for (var i in msgarray) {
if (titles) titles += '|';
titles += 'MediaWiki:' + i;
if (msgarray && wgUserLanguage != wgContentLanguage) {
if (titles) titles += '|';
titles += 'MediaWiki:' + i + '/' + wgUserLanguage;
}
}
if (titles)
return wgScriptPath + '/api.php?format=json&action=query&prop=revisions&rvprop=content&titles=' + titles;
else
return null;
}
}
wfMsgCentre_proprev.prototype.handleresponse = function(msgarray, response) {
// TODO handle error result
var pages = response.query.pages;
for (var p in pages) {
if (pages.missing == undefined) {
var t = pages.title;
var v = pages.revisions;
// strip any prefix and suffix
t = t.substring(10);
var lio = t.lastIndexOf('/' + wgUserLanguage);
if (lio != -1)
t = t.substring(0,lio);
var x = msgarray;
// TODO don't set nonlocalized text over localized
if (x.xform != undefined)
v = x.xform(v);
x.obj = v;
}
}
}
// class which uses api.php to call wfGetMsg for several messages at once
// there is no way to access messages in the message cache but not in the mediawiki: namespace
wfMsgCentre_allmsgs.prototype = new wfMsgCentre_api();
wfMsgCentre_allmsgs.constructor = wfMsgCentre_allmsgs;
function wfMsgCentre_allmsgs() {
if (window.console) console.log('all messages\n');
wfMsgCentre_api.call(this);
this.buildurl = function(msgarray) {
var titles = '';
for (var i in msgarray) {
if (titles) titles += '|';
titles += i;
}
if (titles)
return wgScriptPath + '/api.php?format=json&action=query&meta=allmessages&ammessages=' + titles + '&amlang=' + wgUserLanguage;
else
return null;
}
}
wfMsgCentre_allmsgs.prototype.handleresponse = function(msgarray, response) {
// TODO handle error result
var qam = response.query.allmessages;
for (var i in qam) {
var t = qam.name;
var v = qam;
if (v != '<' + t + '>') {
var x = msgarray;
if (x.xform != undefined)
v = x.xform(v);
x.obj = v;
}
}
}