// (C) Andrea Giammarchi - JSL 1.4b
var undefined;
function $JSL(){
this.inArray=function(){
var tmp=false,i=arguments.length;
while(i&&!tmp)tmp=arguments===arguments;
return tmp;
};
this.has=function(str){return $JSL.inArray(str,$has)};
this.random=function(elm){
var tmp=$JSL.$random();
while(typeof(elm)!=="undefined")tmp=$JSL.$random();
return tmp;
};
this.$random=function(){return (Math.random()*1234567890).toString()};
this.reverse=function(str){return str.split("").reverse().join("")};
this.replace=function(str){
var tmp=str.split(""),i=tmp.length;
while(i>0)tmp=$JSL.$replace(tmp);
return tmp.join("");
};
this.$replace=function(tmp){
var i=tmp.length===1?tmp.charCodeAt(0):0;
switch(i) {
case 8 :tmp="\\b";break;
case 10 :tmp="\\n";break;
case 11 :tmp="\\v";break;
case 12 :tmp="\\f";break;
case 13 :tmp="\\r";break;
case 34 :tmp="\\\"";break;
case 92 :tmp="\\\\";break;
default:
tmp=tmp.replace(/(||)/g,function(a,b){return "\\x"+$JSL.charCodeAt(b)}).
replace(/()/g,function(a,b){b=$JSL.charCodeAt(b);return b.length<4?"\\u0"+b:"\\u"+b});
break;
};
return tmp;
};
this.charCodeAt=function(str){return $JSL.$charCodeAt(str.charCodeAt(0))};
this.$charCodeAt=function(i){
var str=i.toString(16).toUpperCase();
return str.length<2?"0"+str:str;
};
this.$toSource=function(elm){return elm.toSource().replace(/^(\(new \w+\()(+)(\)\))$/,"$2")};
this.$toInternalSource=function(elm){
var tmp=null;
switch(elm.constructor) {
case Boolean:
case Number:
tmp=elm;
break;
case String:
tmp=$JSL.$toSource(elm);
break;
default:
tmp=elm.toSource();
break;
};
return tmp;
};
this.getElementsByTagName=function(scope,i,elm,str){
var tmp=$JSL.$getElementsByTagName(scope),j=tmp.length,$tmp=;
while(i<j){if(tmp===elm||elm==="*")$tmp.push($JSL.$getElementsByName(tmp));++i};
if(!$tmp.item){if(!$JSL.has("item"))$has.push("item");$tmp.item=function(tmp){return this}};
return $tmp;
};
this.$getElementsByTagName=function(scope){return scope.layers||scope.all};
this.$getElementsByName=function(elm) {
if(!elm.getElementsByTagName) elm.getElementsByTagName=document.getElementsByTagName;
return elm;
};
this.encodeURI=function(str){return str.replace(/"/g,"%22").replace(/\\/g,"%5C")};
this.$encodeURI=function(str){return $JSL.$charCodeAt(str)};
this.$encodeURIComponent=function(a,b){
var i=b.charCodeAt(0),str=;
if(i<128) str.push(i);
else if(i<2048) str.push(0xC0+(i>>6),0x80+(i&0x3F));
else if(i<65536) str.push(0xE0+(i>>12),0x80+(i>>6&0x3F),0x80+(i&0x3F));
else str.push(0xF0+(i>>18),0x80+(i>>12&0x3F),0x80+(i>>6&0x3F),0x80+(i&0x3F));
return "%"+str.map($JSL.$encodeURI).join("%");
};
this.$decodeURIComponent=function(a,b,c,d,e){
var i=0;
if(e) i=parseInt(e.substr(1,2),16);
else if(d)i=((parseInt(d.substr(1,2),16)-0xC0)<<6)+(parseInt(d.substr(4,2),16)-0x80);
else if(c)i=((parseInt(c.substr(1,2),16)-0xE0)<<12)+((parseInt(c.substr(4,2),16)-0x80)<<6)+(parseInt(c.substr(7,2),16)-0x80);
else i=((parseInt(b.substr(1,2),16)-0xF0)<<18)+((parseInt(b.substr(4,2),16)-0x80)<<12)+((parseInt(b.substr(7,2),16)-0x80)<<6)+(parseInt(b.substr(10,2),16)-0x80);
return String.fromCharCode(i);
};
var $has=;
if(!Object.prototype.toSource){$has="toSource";Object.prototype.toSource=function(){
var str=;
switch(this.constructor) {
case Boolean:
str.push("(new Boolean(",this,"))");
break;
case Number:
str.push("(new Number(",this,"))");
break;
case String:
str.push("(new String(\"",$JSL.replace(this),"\"))");
break;
case Date:
str.push("(new Date(",this.getTime(),"))");
break;
case Error().constructor:
str.push("(new Error(",$JSL.$toSource(this.message),",",$JSL.$toSource(this.fileName),",",this.lineNumber,"))");
break;
case Function:
str.push("(",$JSL.$replace(this.toString()),")");
break;
case Array:
var i=0,j=this.length;
while(i<j) str.push($JSL.$toInternalSource(this));
str="];
break;
default:
var i=0,tmp;
for(i in this){if(i!=="toSource")
str.push($JSL.$toSource(i)+":"+$JSL.$toInternalSource(this));
};
str=;
break;
};
return str.join("");
}};
if(!Function.prototype.apply){$has="apply";Function.prototype.apply=function(){
var i=arguments.length===2?arguments.length:0,str,tmp=,elm=(""+this).replace(/+/,"function");
if(!arguments)arguments={};
while(i)tmp.unshift("arguments");
do{str="__".concat($JSL.random(arguments).replace(/\./,"_"),"__")}while(new RegExp(str).test(elm));
eval("var ".concat(str,"=arguments;tmp=(",elm.replace(/()\bthis\b()/g,"$1".concat(str,"$2")),")(",tmp.join(","),")"));
return tmp;
}};
if(!Function.prototype.call){$has="call";Function.prototype.call=function(){
var i=arguments.length,tmp=;
while(i>1)tmp.unshift(arguments);
return this.apply((i?arguments:{}),tmp);
}};
if(!Array.prototype.pop){$has="pop";Array.prototype.pop=function(){
var a=this.length,r=this;
if(a>=0)this.length=a;
return r;
}};
if(!Array.prototype.push){$has="push";Array.prototype.push=function(){
var a=0,b=arguments.length,r=this.length;
while(a<b)this=arguments;
return r;
}};
if(!Array.prototype.shift){$has="shift";Array.prototype.shift=function(){
this.reverse();
var r=this.pop();
this.reverse();
return r;
}};
if(!Array.prototype.splice){$has="splice";Array.prototype.splice=function(){
var a,b,c,d=arguments.length,tmp=,r=;
if(d>1){
arguments=parseInt(arguments);
arguments=parseInt(arguments);
c=arguments+arguments;
for(a=0,b=this.length;a<b;a++){
if(a<arguments||a>=c){
if(a===c&&d>2){
for(a=2;a<d;a++)tmp.push(arguments);
a=c;
};
tmp.push(this);
}
else
r.push(this);
};
for(a=0,b=tmp.length;a<b;a++)
this=tmp;
this.length = a;
};
return r;
}};
if(!Array.prototype.unshift){$has="unshift";Array.prototype.unshift=function(){
var i=arguments.length;
this.reverse();
while(i>0)this.push(arguments);
this.reverse();
return this.length;
}};
if(!Array.prototype.indexOf){$has="indexOf";Array.prototype.indexOf=function(elm,i){
var j=this.length;
if(!i)i=0;
if(i>=0){while(i<j){if(this===elm){
i=i-1+j;j=i-j;
}}}
else
j=this.indexOf(elm,j+i);
return j!==this.length?j:-1;
}};
if(!Array.prototype.lastIndexOf){$has="lastIndexOf";Array.prototype.lastIndexOf=function(elm,i){
var j=-1;
if(!i)i=this.length;
if(i>=0){do{if(this===elm){
j=i+1;i=0;
}}while(i>0)}
else if(i>-this.length)
j=this.lastIndexOf(elm,this.length+i);
return j;
}};
if(!Array.prototype.every){$has="every";Array.prototype.every=function(callback,elm){
var b=false,i=0,j=this.length;
if(!elm){ while(i<j&&!b) b=!callback(this||this.charAt(i),i++,this)}
else { while(i<j&&!b) b=!callback.apply(elm,||this.charAt(i),i++,this]);}
return !b;
}};
if(!Array.prototype.filter){$has="filter";Array.prototype.filter=function(callback,elm){
var r=,i=0,j=this.length;
if(!elm){while(i<j){if(callback(this,i++,this))
r.push(this);
}} else {while(i<j){if(callback.apply(elm,,i++,this]))
r.push(this);
}}
return r;
}};
if(!Array.prototype.forEach){$has="forEach";Array.prototype.forEach=function(callback,elm){
var i=0,j=this.length;
if(!elm){ while(i<j) callback(this,i++,this)}
else { while(i<j) callback.apply(elm,,i++,this]);}
}};
if(!Array.prototype.map){$has="map";Array.prototype.map=function(callback,elm){
var r=,i=0,j=this.length;
if(!elm){ while(i<j) r.push(callback(this,i++,this))}
else { while(i<j) r.push(callback.apply(elm,,i++,this]));}
return r;
}};
if(!Array.prototype.some){$has="some";Array.prototype.some=function(callback,elm){
var b=false,i=0,j=this.length;
if(!elm){ while(i<j&&!b) b=callback(this,i++,this)}
else { while(i<j&&!b) b=callback.apply(elm,,i++,this]);}
return b;
}};
if(!String.prototype.lastIndexOf){if(!this.inArray("lastIndexOf",$has))$has="lastIndexOf";String.prototype.lastIndexOf=function(elm,i){
var str=$JSL.reverse(this),elm=$JSL.reverse(elm),r=str.indexOf(elm,i);
return r<0?r:this.length-r;
}};
if("aa".replace(/\w/g,function(){return arguments+" "})!=="0 1 "){$has="replace";String.prototype.replace=function(replace){return function(reg,func){
var r="",tmp=$JSL.random(String);
String.prototype=replace;
if(func.constructor!==Function)
r=this(reg,func);
else {
function getMatches(reg,pos,a) {
function io() {
var a=reg.indexOf("(",pos),b=a;
while(a>0&®.charAt(--a)==="\\"){};
pos=b!==-1?b+1:b;
return (b-a)%2===1?1:0;
};
do{a+=io()}while(pos!==-1);
return a;
};
function $replace(str){
var j=str.length-1;
while(j>0)str='"'+str.substr(1,str.length-2)(/(\\|")/g,'\\$1')+'"';
return str.join("");
};
var p=-1,i=getMatches(""+reg,0,0),args=,$match=this.match(reg),elm=$JSL.$random()(/\./,'_AG_');
while(this.indexOf(elm)!==-1)elm=$JSL.$random()(/\./,'_AG_');
while(i)args=.join("");
if(!args.length)r="$match,(p=this.indexOf($match,p+1)),this";
else r="$match,"+args.join(",")+",(p=this.indexOf($match,p+1)),this";
r=eval('(reg,'"'+elm+',func('+r+'),'+elm+'"')+'"')+elm).split(elm))(/\n/g,'\\n')(/\r/g,'\\r')+'].join("")');
};
delete String.prototype;
return r;
}}(String.prototype.replace)};
if((new Date().getYear()).toString().length===4){$has="getYear";Date.prototype.getYear=function(){
return this.getFullYear()-1900;
}};
};$JSL=new $JSL();
if(typeof(encodeURI)==="undefined"){function encodeURI(str){
var elm=/(|||)/g;
return $JSL.encodeURI(str.toString().replace(elm,$JSL.$encodeURIComponent));
}};
if(typeof(encodeURIComponent)==="undefined"){function encodeURIComponent(str){
var elm=/()/g;
return $JSL.encodeURI(encodeURI(str).replace(elm,function(a,b){return "%"+$JSL.charCodeAt(b)}));
}};
if(typeof(decodeURIComponent)==="undefined"){function decodeURIComponent(str){
var elm=/(%F%E%%)|(%E%%)|(%%)|(%{2})/g;
return str.toString().replace(elm,$JSL.$decodeURIComponent);
}};
if(typeof(decodeURI)==="undefined"){function decodeURI(str){
return decodeURIComponent(str);
}};
if(!document.getElementById){document.getElementById=function(elm){
return $JSL.$getElementsByName($JSL.$getElementsByTagName(this));
}};
if(!document.getElementsByTagName){document.getElementsByTagName=function(elm){
return $JSL.getElementsByTagName(this,0,elm.toUpperCase(),"tagName");
}};
if(!document.getElementsByName){document.getElementsByName=function(elm){
return $JSL.getElementsByTagName(this,0,elm,"name");
}};
if(typeof(XMLHttpRequest)==="undefined"){XMLHttpRequest=function(){
var tmp=null,elm=navigator.userAgent;
if(elm.toUpperCase().indexOf("MSIE 4")<0&&window.ActiveXObject)
tmp=elm.indexOf("MSIE 5")<0?new ActiveXObject("Msxml2.XMLHTTP"):new ActiveXObject("Microsoft.XMLHTTP");
return tmp;
}};
if(typeof(Error)==="undefined")Error=function(){};
Error = function(base){return function(message){
var tmp=new base();
tmp.message=message||"";
if(!tmp.fileName)
tmp.fileName=document.location.href;
if(!tmp.lineNumber)
tmp.lineNumber=0;
if(!tmp.stack)
tmp.stack="Error()@:0\n(\""+this.message+"\")@"+tmp.fileName+":"+this.lineNumber+"\n@"+tmp.fileName+":"+this.lineNumber;
if(!tmp.name)
tmp.name="Error";
return tmp;
}}(Error);
/**
* Will escape a string to be used in a RegExp
*/
RegExp.escape = function( text, space_fix ) {
if ( !arguments.callee.sRE ) {
arguments.callee.sRE = /(\/|\.|\*|\+|\?|\||\(|\)|\|\{|\}|\\|\$|\^)/g;
}
text = text.replace( arguments.callee.sRE , '\\$1' );
// Special Mediawiki escape, underscore/space is the same, often at lest:
if( space_fix ) {
text = text.replace( / |_/g, '' );
}
return text;
}
namespaces = {
'-2': 'Media',
'-1': 'Special',
'0' : '',
'1' : 'Talk',
'2' : 'User',
'3' : 'User_talk',
'4' : 'Project',
'5' : 'Project talk',
'6' : 'Image',
'7' : 'Image talk',
'8' : 'MediaWiki',
'9' : 'MediaWiki talk',
'10': 'Template',
'11': 'Template talk',
'12': 'Help',
'13': 'Help talk',
'14': 'Category',
'15': 'Category talk',
'100': 'Portal',
'101': 'Portal talk'
};
/**
* Helper functions to get the month as a string instead of a number
*/
Date.monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];
Date.monthNamesAbbrev = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
];
Date.prototype.getMonthName = function() {
return Date.monthNames;
}
Date.prototype.getMonthNameAbbrev = function() {
return Date.monthNamesAbbrev;
}
Date.prototype.getUTCMonthName = function() {
return Date.monthNames;
}
Date.prototype.getUTCMonthNameAbbrev = function() {
return Date.monthNamesAbbrev;
}
// Simple helper functions to see what groups a user might belong
function userIsInGroup( group ) {
return ( wgUserGroups != null && wgUserGroups.indexOf( group ) != -1 ) || ( wgUserGroups == null && group == 'anon' );
}
function userIsAnon() {
return 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) << 24) + (parseInt(iparr) << 16) + (parseInt(iparr) << 8) + (parseInt(iparr));
var netmask = 0xffffffff << network.split('/');
var netarr = network.split('/').split('.');
var net = (parseInt(netarr) << 24) + (parseInt(netarr) << 16) + (parseInt(netarr) << 8) + (parseInt(netarr));
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
*
* Optional parameter to exists, get and equals, can define another query string, but remember that that string wont be cached.
*/
function QueryString() {}
QueryString.init = function(str) {
var params = {};
if( QueryString.params != null && !str ) {
return;
}
if ( !str ) {
QueryString.params = {};
}
var queryString = str || location.search.substring(1);
if(queryString.length == 0) {
return;
}
if( !str ) {
QueryString.str = queryString;
}
queryString.replace(/\+/, ' ');
var args = queryString.split('&');
for( var i in args ) {
if( typeof( args ) != 'string' ) {
continue;
}
var pair = args.split( '=' );
var key = decodeURIComponent( pair ), value = key;
if( pair.length == 2 ) {
value = decodeURIComponent( pair );
}
params = value;
}
if( !str ) {
QueryString.params = params;
}
return params;
}
QueryString.get = function(key, str) {
if( str ) {
var val = QueryString.init(str);
return val ? val : null;
} else if( QueryString.params == null ) {
QueryString.init();
}
return QueryString.params ? QueryString.params : null;
};
QueryString.exists = function(key, str) {
if( str ) {
return QueryString.init(str) ? true : false;
} else if( QueryString.params == null ) {
QueryString.init();
}
return QueryString.params ? true : false;
}
QueryString.equals = function(key, value, str) {
if (str ) {
return QueryString.init(str) == value ? true : false;
} else if( QueryString.params == null ) {
QueryString.init();
}
return QueryString.params == value ? true : false;
}
QueryString.toString = function() {
if( QueryString.str == null ) {
QueryString.init();
}
return QueryString.str ? QueryString.str : null;
}
QueryString.create = function( arr ) {
var resarr = Array();
for( var i in arr ) {
if( typeof arr == 'object' ){
var v = Array();
for(var j in arr ) {
v = encodeURIComponent( arr );
}
resarr.push( encodeURIComponent( i ) + '=' + v.join('|') );
} else {
resarr.push( encodeURIComponent( i ) + '=' + encodeURIComponent( arr ) );
}
}
return resarr.join('&');
}
QueryString.params = null;
QueryString.str = null;
/**
* Simple exception handling
*/
Exception = function( str ) {
this.str = str || '';
}
Exception.prototype.what = function() {
return this.str;
}
/**
* Status updating class
*/
Status = function() {}
/*
Initiate an element to be a status window, it will remove all it's childs
*/
Status.init = function( elem ) {
if( !( elem instanceof Element ) ) {
throw new Exception( 'object not an instance of Element' );
}
Status.elem = elem;
Status.currentNode = null;
while( elem.hasChildNodes() ) {
elem.removeChild( elem.firstChild );
}
}
// Private function
Status.append = function( obj, node ) {
if( Status.elem == null ) {
throw new Exception( 'no initialized object found' );
}
if ( ! ( obj instanceof Array ) ) {
obj = ;
}
node = node || Status.currentNode;
for( var i in obj ) {
if( typeof obj == 'string' ) {
node.appendChild( document.createTextNode( obj ) );
} else if( obj instanceof Element ) {
node.appendChild( obj );
}
}
}
Status.error = function( obj ) {
Status.currentNode = document.createElement( 'div' );
Status.currentNode.style.color = 'OrangeRed';
Status.currentNode.style.fontWeight = '900';
Status.append( obj );
Status.elem.appendChild( Status.currentNode );
return Status.currentNode;
}
Status.warn = function( obj ) {
Status.currentNode = document.createElement( 'div' );
Status.currentNode.style.color = 'OrangeRed';
Status.append( obj );
Status.elem.appendChild( Status.currentNode );
return Status.currentNode;
}
Status.info = function( obj ) {
Status.currentNode = document.createElement( 'div' );
Status.currentNode.style.color = 'ForestGreen';
Status.append( obj );
Status.elem.appendChild( Status.currentNode );
return Status.currentNode;
}
Status.debug = function( obj , level ) {
level = level || 1;
if( Status.debugLevel >= level ) {
Status.currentNode = document.createElement( 'div' );
Status.currentNode.style.color = 'DimGray';
Status.append( "Debug (" + level + "): " );
Status.append( obj );
Status.elem.appendChild( Status.currentNode );
return Status.currentNode;
} else {
return null;
}
}
Status.debugLevel = 0;
Status.status = function( obj ) {
Status.currentNode = document.createElement( 'div' );
Status.currentNode.style.color = 'SteelBlue';
Status.append( obj );
Status.elem.appendChild( Status.currentNode );
return Status.currentNode;
}
Status.progress = function ( obj, node ) {
Status.append( obj, node );
}
// Simple helper function to create a simple node
function htmlNode( type, content, color ) {
var node = document.createElement( type );
if( color ) {
node.style.color = color;
}
node.appendChild( document.createTextNode( content ) );
return node;
}
// A simple dragable window
function SimpleWindow( width, height ) {
this.width = width;
this.height = height;
this.frame = document.createElement( 'div' );
SimpleWindow.frames.push( this.frame );
this.topbar = document.createElement( 'div' );
this.topbarover = document.createElement( 'div' );
this.closeButton = document.createElement( 'span' );
this.frame.appendChild( this.topbar );
this.topbarover.appendChild( this.closeButton );
this.frame.style.zIndex = 100;
this.frame.style.width = width + 'px';
this.frame.style.height = height + 'px';
this.frame.style.position = 'fixed';
this.frame.style.background = 'AliceBlue';
this.frame.style.border = '2px ridge Black';
this.frame.simpleWindow = this;
this.frame.addEventListener( 'mousedown', this.focus, true );
this.closeButton.appendChild( document.createTextNode( '' ) );
this.closeButton.style.position = 'absolute';
this.closeButton.style.fontWeight = '100';
this.closeButton.style.fontSize = '0.7em';
this.closeButton.style.top = '0px';
this.closeButton.style.left = '0px';
this.closeButton.style.cursor = 'pointer';
this.closeButton.simpleWindow = this;
this.closeButton.addEventListener( 'click', this.close, false );
this.topbar.style.width = '100%';
this.topbar.style.height = '20px';
this.topbar.style.background = 'LightSteelBlue';
this.topbar.style.position = 'absolute';
this.topbar.style.fontWeight = '900';
this.topbar.style.fontSize = '1em';
this.topbar.style.fontFamily = 'sans-serif';
this.topbar.style.textAlign = 'center';
this.topbar.style.verticalAlign = 'baseline';
this.topbar.style.top = '0px';
this.topbar.style.left = '0px';
this.topbarover.style.width = '100%';
this.topbarover.style.height = '24px';
this.topbarover.style.position = 'absolute';
this.topbarover.style.top = '0px';
this.topbarover.style.left = '0px';
this.topbarover.simpleWindow = this;
this.topbarover.addEventListener( 'mousedown', this.beginMove, true );
}
SimpleWindow.prototype.focus = function(e) {
for( var i in SimpleWindow.frames ) {
SimpleWindow.frames.style.zIndex = 99;
}
this.simpleWindow.frame.style.zIndex = 100;
}
SimpleWindow.prototype.display = function() {
this.title = this.title || "Title";
this.content = this.content || document.createTextNode( "" );
this.topbar.appendChild( document.createTextNode( this.title ) );
var content = document.createElement( 'div' );
content.style.position = 'relative';
content.style.top = '20px';
content.style.height = ( this.height - 20 ) + 'px';
content.style.overflow = 'auto';
content.appendChild( this.content );
this.frame.appendChild( content );
this.frame.appendChild( this.topbarover );
this.frame.style.width = this.width + 'px';
this.frame.style.height = this.height + 'px';
this.frame.style.top = (window.innerHeight - this.height )/2 + 'px' ;
this.frame.style.left = (window.innerWidth - this.width )/2 + 'px';
document.getElementsByTagName('body').appendChild( this.frame );
}
SimpleWindow.prototype.close = function(e) {
if( e ) {
this.simpleWindow.frame.parentNode.removeChild(this.simpleWindow.frame);
} else {
this.frame.parentNode.removeChild(this.frame);
}
}
SimpleWindow.prototype.setWidth = function( width ) {
this.width = width;
}
SimpleWindow.prototype.setHeight = function( height ) {
this.height = height;
}
SimpleWindow.prototype.setTitle = function( title ) {
this.title = title;
}
SimpleWindow.prototype.setContent = function( content ) {
this.content = content;
}
SimpleWindow.frames = ;
SimpleWindow.prototype.currentObject = null;
SimpleWindow.prototype.beginMove = function(e) {
if( e.button != 0 ) {
return;
}
this.simpleWindow.initX = e.layerX;
this.simpleWindow.initY = e.layerY;
this.simpleWindow.lastX = e.clientX;
this.simpleWindow.lastY = e.clientY;
SimpleWindow.currentObject = this.simpleWindow;
window.addEventListener( 'mousemove', SimpleWindow.moveWindow, false );
window.addEventListener( 'mouseup', function(e) {
SimpleWindow.currentObject = null;
window.removeEventListener( 'mousemove', SimpleWindow.moveWindow, false );
window.removeEventListener( 'mouseup', SimpleWindow.moveWindow, false );
}, false );
}
SimpleWindow.moveWindow = function(e) {
if( SimpleWindow.currentObject == null ) {
return;
}
var y = e.clientY - SimpleWindow.currentObject.initY;
var x = e.clientX - SimpleWindow.currentObject.initX;
SimpleWindow.currentObject.frame.style.top = y + 'px';
SimpleWindow.currentObject.frame.style.left = x + 'px';
e.stopPropagation();
}