this.text = this.text.replace( allTemplates[i], '', 'g' );
}
}  
},
getText: function {
return this.text;
}
}  
// Simple helper functions to see what groups a user might belong  
function userIsInGroup( group ) {  
return ( mw.config.get('wgUserGroups') != null && mw.config.get('wgUserGroups').indexOf( group ) != -1 ) || ( mw.config.get('wgUserGroups') == null && group == 'anon' );
}  
function userIsAnon {
return mw.config.get('wgUserGroups') == null;
}  
// AOL Proxy IP Addresses (2007-02-03)
var AOLNetworks = [
'64.12.96.0/19',
'149.174.160.0/20',
'152.163.240.0/21',
'152.163.248.0/22',
'152.163.252.0/23',
'152.163.96.0/22',
'152.163.100.0/23',
'195.93.32.0/22',
'195.93.48.0/22',
'195.93.64.0/19',
'195.93.96.0/19',
'195.93.16.0/20',
'198.81.0.0/22',
'198.81.16.0/20',
'198.81.8.0/23',
'202.67.64.128/25',
'205.188.192.0/20',
'205.188.208.0/23',
'205.188.112.0/20',
'205.188.146.144/30',
'207.200.112.0/21',
];  
// AOL Client IP Addresses (2007-02-03)
var AOLClients = [
'172.128.0.0/10',
'172.192.0.0/12',
'172.208.0.0/14',
'202.67.66.0/23',
'172.200.0.0/15',
'172.202.0.0/15',
'172.212.0.0/14',
'172.216.0.0/16',
'202.67.68.0/22',
'202.67.72.0/21',
'202.67.80.0/20',
'202.67.96.0/19',
];  
/**
- ipadress is in the format 1.2.3.4 and network is in the format 1.2.3.4/5
- /  
function isInNetwork( ipaddress, network ) {
var iparr = ipaddress.split('.');
var ip = (parseInt(iparr[0]) << 24) + (parseInt(iparr[1]) << 16) + (parseInt(iparr[2]) << 8) + (parseInt(iparr[3]));  
var netmask = 0xffffffff << network.split('/')[1];  
var netarr = network.split('/')[0].split('.');
var net = (parseInt(netarr[0]) << 24) + (parseInt(netarr[1]) << 16) + (parseInt(netarr[2]) << 8) + (parseInt(netarr[3]));  
return (ip & netmask) == net;
}  
/* Returns true if given string contains a valid IP-address, that is, from 0.0.0.0 to 255.255.255.255*/
function isIPAddress( string ){
var res = /(\d{1,4})\.(\d{1,3})\.(\d{1,3})\.(\d{1,4})/.exec( string );
return res != null && res.slice( 1, 5 ).every( function( e ) { return e < 256; } );
}  
/**
- Maps the querystring to an object
-
- Functions:
-
- QueryString.exists(key)
- returns true if the particular key is set
- QueryString.get(key)
- returns the value associated to the key
- QueryString.equals(key, value)
- returns true if the value associated with given key equals given value
- QueryString.toString
- returns the query string as a string
- QueryString.create( hash )
- creates an querystring and encodes strings via encodeURIComponent and joins arrays with |
-
- In static context, the value of location.search.substring(1), else the value given to the constructor is going to be used. The mapped hash is saved in the object.
-
- Example:
-
- var value = QueryString.get('key');
- var obj = new QueryString('foo=bar&baz=quux');
- value = obj.get('foo');
- /
function QueryString(qString) {
this.string = qString;
this.params = {};  
if( qString.length == 0 ) {
return;
}  
qString.replace(/\+/, ' ');
var args = qString.split('&');  
for( var i = 0; i < args.length; ++i ) {
var pair = args[i].split( '=' );
var key = decodeURIComponent( pair[0] ), value = key;  
if( pair.length == 2 ) {
value = decodeURIComponent( pair[1] );
}  
this.params[key] = value;
}
}  
QueryString.static = null;  
QueryString.staticInit = function {
if( QueryString.static == null ) {
QueryString.static = new QueryString(location.search.substring(1));
}
}  
QueryString.get = function(key) {
QueryString.staticInit;
return QueryString.static.get(key);
};  
QueryString.prototype.get = function(key) {
return this.params[key] ? this.params[key] : null;
};  
QueryString.exists = function(key) {
QueryString.staticInit;
return QueryString.static.exists(key);
}  
QueryString.prototype.exists = function(key) {
return this.params[key] ? true : false;
}  
QueryString.equals = function(key, value) {
QueryString.staticInit;
return QueryString.static.equals(key, value);
}  
QueryString.prototype.equals = function(key, value) {
return this.params[key] == value ? true : false;
}  
QueryString.toString = function {
QueryString.staticInit;
return QueryString.static.toString;
}  
QueryString.prototype.toString = function {
return this.string ? this.string : null;
}  
QueryString.create = function( arr ) {
var resarr = Array;
for( var i in arr ) {
if( typeof arr[i] == 'undefined' ) {
continue;
}
if( arr[i] instanceof Array ){
var v = Array;
for(var j = 0; j < arr[i].length; ++j ) {
v[j] = encodeURIComponent( arr[i][j] );
}
resarr.push( encodeURIComponent( i ) + '=' + v.join('|') );
} else {
resarr.push( encodeURIComponent( i ) + '=' + encodeURIComponent( arr[i] ) );
}
}  
return resarr.join('&');
}
QueryString.prototype.create = QueryString.create;  
/**
- Simple exception handling
- /  
Exception = function( message ) {
this.message = message || '';
this.name = "Exception";
}  
Exception.prototype.what = function {
return this.message;
}  
function Status( text, stat, type ) {
this.text = this.codify(text);
this.stat = this.codify(stat);
this.type = type || 'status';
this.generate;
if( stat ) {
this.render;
}
}
Status.init = function( root ) {
if( !( root instanceof Element ) ) {
throw new Exception( 'object not an instance of Element' );
}
while( root.hasChildNodes ) {
root.removeChild( root.firstChild );
}
Status.root = root;  
var cssNode = document.createElement('style');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.appendChild( document.createTextNode("")); // Safari bugfix
document.getElementsByTagName("head")[0].appendChild(cssNode);
var styles = cssNode.sheet ? cssNode.sheet : cssNode.stylesSheet;
styles.insertRule(".tw_status_status { color: SteelBlue; }", 0);
styles.insertRule(".tw_status_info { color: ForestGreen; }", 0);
styles.insertRule(".tw_status_warn { color: OrangeRed; }", 0);
styles.insertRule(".tw_status_error { color: OrangeRed; font-weight: 900; }", 0);
}
Status.root = null;  
Status.prototype = {
stat: null,
text: null,
type: 'status',
target: null,
node: null,
linked: false,
link: function {
if( ! this.linked && Status.root ) {
Status.root.appendChild( this.node );
this.linked = true;
}
},
unlink: function {
if( this.linked ) {
Status.root.removeChild( this.node );
this.linked = false;
}
},
codify: function( obj ) {
if ( ! ( obj instanceof Array ) ) {
obj = [ obj ];
}
var result;
result = document.createDocumentFragment;
for( var i = 0; i < obj.length; ++i ) {
if( typeof obj[i] == 'string' ) {
result.appendChild( document.createTextNode( obj[i] ) );
} else if( obj[i] instanceof Element ) {
result.appendChild( obj[i] );
} // Else cosmic radiation made something shit
}
return result;  
},
update: function( status, type ) {
this.stat = this.codify( status );
if( type ) {
this.type = type;
}
this.render;
},
generate: function {
this.node = document.createElement( 'div' );
this.node.appendChild( document.createElement('span') ).appendChild( this.text );
this.node.appendChild( document.createElement('span') ).appendChild( document.createTextNode( ': ' ) );
this.target = this.node.appendChild( document.createElement( 'span' ) );
this.target.appendChild( document.createTextNode( '' ) ); // dummy node
},
render: function {
this.node.className = 'tw_status_' + this.type;
while( this.target.hasChildNodes ) {
this.target.removeChild( this.target.firstChild );
}
this.target.appendChild( this.stat );
this.link;
},
status: function( status ) {
this.update( status, 'status');
},
info: function( status ) {
this.update( status, 'info');
},
warn: function( status ) {
this.update( status, 'warn');
},
error: function( status ) {
this.update( status, 'error');
}
}  
Status.status = function( text, status ) {
return new Status( text, status, 'status' );
}
Status.info = function( text, status ) {
return new Status( text, status, 'info' );
}
Status.warn = function( text, status ) {
return new Status( text, status, 'error' );
}
Status.error = function( text, status ) {
return new Status( text, status, 'error' );
}  
// Simple helper function to create a simple node