Completely remove prototype.js from Mibew

This commit is contained in:
Dmitriy Simushev 2013-02-26 15:59:36 +00:00
parent 6c1852e094
commit 4b7614caec
2 changed files with 0 additions and 587 deletions

View File

@ -1,27 +0,0 @@
/*
This file is part of Mibew Messenger project.
http://mibew.org
Copyright (c) 2005-2011 Mibew Messenger Community
License: http://mibew.org/license.php
*/
var Class={create:function(){return function(){this.initialize.apply(this,arguments)}},inherit:function(a,b,c){Object.extend(Object.extend(a.prototype,b.prototype),c)}};Object.extend=function(a,b){for(property in b)a[property]=b[property];return a};Object.prototype.extend=function(a){return Object.extend.apply(this,[this,a])};Function.prototype.bind=function(a){var b=this;return function(){return b.apply(a,arguments)}};
Function.prototype.bindAsEventListener=function(a){var b=this;return function(c){b.call(a,c||window.event)}};Number.prototype.toColorPart=function(){var a=this.toString(16);return 16>this?"0"+a:a};var Try={these:function(){for(var a,b=0;b<arguments.length;b++){var c=arguments[b];try{a=c();break}catch(d){}}return a}},PeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={initialize:function(a,b){this.callback=a;this.frequency=b;this.currentlyExecuting=!1;this.registerCallback()},registerCallback:function(){setInterval(this.onTimerEvent.bind(this),1E3*this.frequency)},onTimerEvent:function(){if(!this.currentlyExecuting)try{this.currentlyExecuting=!0,this.callback()}finally{this.currentlyExecuting=!1}}};
function findObj(a){var b;if(!(b=document[a])&&document.all)b=document.all[a];!b&&document.getElementById&&(b=document.getElementById(a));if(!b&&!document.all&&document.getElementsByName){b=document.getElementsByName(a);if(0==b.length)return null;if(1==b.length)return b[0]}return b}Array.prototype.push||(Array.prototype.push=function(){for(var a=this.length,b=0;b<arguments.length;b++)this[a+b]=arguments[b];return this.length});
function $(){for(var a=[],b=0;b<arguments.length;b++){var c=arguments[b];"string"==typeof c&&(c=findObj(c));if(1==arguments.length)return c;a.push(c)}return a}
var Ajax={getTransport:function(){return Try.these(function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new XMLHttpRequest})||!1},getXml:function(a){return a&&200<=a.status&&300>a.status&&(a=a.responseXML)&&a.documentElement?a.documentElement:null},getError:function(a){return a.statusText||"connection error N"+a.status},emptyFunction:function(){},Base:function(){}};
Ajax.Base.prototype={setOptions:function(a){this._options={_method:"post",asynchronous:!0,parameters:""}.extend(a||{})},getStatus:function(){try{return this.transport.status||0}catch(a){return 0}},responseIsSuccess:function(){var a=this.getStatus();return!a||200<=a&&300>a},responseIsFailure:function(){return!this.responseIsSuccess()}};Ajax.Request=Class.create();Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];
Class.inherit(Ajax.Request,Ajax.Base,{initialize:function(a,b){this.transport=Ajax.getTransport();this.setOptions(b);this.transportTimer={};this.finished=!1;this.request(a)},request:function(a){var b=this._options.parameters||"";0<b.length&&(b+="&_=");try{"get"==this._options._method&&0<b.length&&(a+="?"+b);this.transport.open(this._options._method.toUpperCase(),a,this._options.asynchronous);this._options.asynchronous&&(this.transport.onreadystatechange=this.onStateChange.bind(this),this._options.timeout&&
(this.transportTimer=setTimeout(this.handleTimeout.bind(this),this._options.timeout)));this.setRequestHeaders();var c=this._options.postBody?this._options.postBody:b;this.transport.send("post"==this._options._method?c:null)}catch(d){this.dispatchException(d)}},setRequestHeaders:function(){var a=["X-Requested-With","XMLHttpRequest"];"post"==this._options._method&&(a.push("Content-type","application/x-www-form-urlencoded"),this.transport.overrideMimeType&&2005>(navigator.userAgent.match("/Gecko/(d{4})/")||
[0,2005])[1]&&a.push("Connection","close"));this._options.requestHeaders&&a.push.apply(a,this._options.requestHeaders);for(var b=0;b<a.length;b+=2)this.transport.setRequestHeader(a[b],a[b+1])},onStateChange:function(){1!=this.transport.readyState&&this.respondToReadyState(this.transport.readyState)},handleTimeout:function(){this.finished||(this.finished=!0,(this._options.onTimeout||Ajax.emptyFunction)(this))},respondToReadyState:function(a){if("Complete"==Ajax.Request.Events[a]){try{this.finished||
(this.finished=!0,this._options.timeout&&clearTimeout(this.transportTimer),(this._options.onComplete||Ajax.emptyFunction)(this.transport))}catch(b){this.dispatchException(b)}this.transport.onreadystatechange=Ajax.emptyFunction}},dispatchException:function(a){(this._options.onException||Ajax.emptyFunction)(this,a)}});
var EventHelper={register:function(a,b,c){var d=a[b];a[b]="function"!=typeof d?c:function(){d();c()}}},Behaviour={list:[],register:function(a){Behaviour.list.push(a)},init:function(){EventHelper.register(window,"onload",function(){Behaviour.apply()})},apply:function(){for(h=0;sheet=Behaviour.list[h];h++)for(selector in sheet)if(list=document.getElementsBySelector(selector))for(i=0;element=list[i];i++)sheet[selector](element)}};Behaviour.init();
function getAllChildren(a){return a.all?a.all:a.getElementsByTagName("*")}
document.getElementsBySelector=function(a){if(!document.getElementsByTagName)return[];a=a.split(" ");for(var b=Array(document),c=0;c<a.length;c++)if(token=a[c].replace(/^\s+/,"").replace(/\s+$/,""),-1<token.indexOf("#")){var d=token.split("#"),f=d[0],b=document.getElementById(d[1]);if(null==b||f&&b.nodeName.toLowerCase()!=f)return[];b=Array(b)}else if(-1<token.indexOf(".")){d=token.split(".");f=d[0];d=d[1];f||(f="*");for(var g=[],j=0,n=0;n<b.length;n++){var m;m="*"==f?getAllChildren(b[n]):b[n].getElementsByTagName(f);
if(null!=m)for(var p=0;p<m.length;p++)g[j++]=m[p]}b=[];for(j=f=0;j<g.length;j++)g[j].className&&g[j].className.match(RegExp("\\b"+d+"\\b"))&&(b[f++]=g[j])}else{if(!b[0])return;f=token;g=[];for(n=j=0;n<b.length;n++){m=b[n].getElementsByTagName(f);for(p=0;p<m.length;p++)g[j++]=m[p]}b=g}return b};
var NodeUtils={getNodeValue:function(a,b){var c=a.getElementsByTagName(b);if(0==c.length)return"";var c=c[0].childNodes,d="";for(i=0;i<c.length;i++)d+=c[i].nodeValue;return d},getNodeText:function(a){a=a.childNodes;var b="";for(i=0;i<a.length;i++)b+=a[i].nodeValue;return b},getAttrValue:function(a,b){for(k=0;k<a.attributes.length;k++)if(a.attributes[k].nodeName==b)return a.attributes[k].nodeValue;return null}},CommonUtils={getRow:function(a,b){var c=b.rows[a];if(null!=c)return c;if(null!=b.rows.head)return null;
for(k=0;k<b.rows.length;k++)if(b.rows[k].id==a)return b.rows[k];return null},getCell:function(a,b,c){var d=b.cells[a];if(null!=d)return d;if(null!=c.rows.head)return null;for(k=0;k<b.cells.length;k++)if(b.cells[k].id==a)return b.cells[k];return null},insertCell:function(a,b,c,d,f,g){a=a.insertCell(-1);a.id=b;d&&(a.align=d);a.className=c;f&&(a.height=f);a.innerHTML=g}};
function playSound(a){var b=document.createElement("div");-1!=navigator.userAgent.toLowerCase().indexOf("opera")&&(b.style="position: absolute; left: 0px; top: -200px;");document.body.appendChild(b);b.innerHTML='<audio autoplay src="'+a+'"><embed src="'+a+'" hidden="true" autostart="true" loop="false"></audio>'}function htmlescape(a){return a.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace('"',"&quot;")}var ClientForm=Class.create();
ClientForm.prototype={initialize:function(a){this.emailPattern=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;this.form=a;this.localizedStrings=null},emailIsValid:function(a){return null!=a&&-1==a.value.search(this.emailPattern)?!1:!0},changeGroup:function(a,b,c){document.getElementById(b).innerHTML=c[a.selectedIndex]},checkFields:function(){return null},localize:function(a){this.localizedStrings=
a},submit:function(){var a=this.checkFields();null===a?this.form.submit():""!=a&&alert(a)}};

View File

@ -1,560 +0,0 @@
/**
* @preserve This file is part of Mibew Messenger project.
* http://mibew.org
*
* Copyright (c) 2005-2011 Mibew Messenger Community
* License: http://mibew.org/license.php
*/
/*
* common.js Based on Prototype JavaScript framework, version 1.3.1
* http://prototype.conio.net/ (c) 2005 Sam Stephenson <sam@conio.net>
*/
//- getEl, myAgent, myRealAgent
//- localized
//- onComplete, showonline
//- threadParams, servl, frequency, user, threadid, token, cssfile
//- updaterOptions, url, company, agentservl, noclients, wroot, havemenu, showpopup, ignorectrl, istatus
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
};
},
inherit: function(child,parent,body) {
Object.extend(Object.extend(child.prototype, parent.prototype), body );
}
};
Object.extend = function(destination, source) {
for (property in source) {
destination[property] = source[property];
}
return destination;
};
Object.prototype.extend = function(_object) {
return Object.extend.apply(this, [this, _object]);
};
Function.prototype.bind = function(_object) {
var __method = this;
return function() {
return __method.apply(_object, arguments);
}
};
Function.prototype.bindAsEventListener = function(_object) {
var __method = this;
return function(event) {
__method.call(_object, event || window.event);
}
};
Number.prototype.toColorPart = function() {
var digits = this.toString(16);
if (this < 16) return '0' + digits;
return digits;
};
var Try = {
these: function() {
var returnValue;
for (var i = 0; i < arguments.length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) {}
}
return returnValue;
}
};
/*--------------------------------------------------------------------------*/
var PeriodicalExecuter = Class.create();
PeriodicalExecuter.prototype = {
initialize: function(callback, frequency) {
this.callback = callback;
this.frequency = frequency;
this.currentlyExecuting = false;
this.registerCallback();
},
registerCallback: function() {
setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
onTimerEvent: function() {
if (!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.callback();
} finally {
this.currentlyExecuting = false;
}
}
}
};
/*--------------------------------------------------------------------------*/
function findObj( id )
{
var x;
if( !( x = document[ id ] ) && document.all ) x = document.all[ id ];
if( !x && document.getElementById ) x = document.getElementById( id );
if( !x && !document.all && document.getElementsByName )
{
x = document.getElementsByName( id );
if( x.length == 0 ) return null;
if( x.length == 1 ) return x[ 0 ];
}
return x;
}
if (!Array.prototype.push) {
Array.prototype.push = function() {
var startLength = this.length;
for (var i = 0; i < arguments.length; i++)
this[startLength + i] = arguments[i];
return this.length;
};
}
function $() {
var elems = new Array();
for (var i = 0; i < arguments.length; i++) {
var elem = arguments[i];
if (typeof elem == 'string')
elem = findObj(elem);
if (arguments.length == 1)
return elem;
elems.push(elem);
}
return elems;
}
var Ajax = {
getTransport: function() {
return Try.these(
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
function() {return new XMLHttpRequest()}
) || false;
},
getXml: function(_response) {
if( _response &&
_response.status >= 200 &&
_response.status < 300 ) {
var xmlDoc = _response.responseXML;
if( xmlDoc && xmlDoc.documentElement )
return xmlDoc.documentElement;
}
return null;
},
getError: function(_response) {
return _response.statusText || "connection error N" + _response.status;
},
emptyFunction: function() {}
};
Ajax.Base = function() {};
Ajax.Base.prototype = {
setOptions: function(_options) {
this._options = {
_method: 'post',
asynchronous: true,
parameters: ''
}.extend(_options || {});
},
getStatus: function() {
try {
return this.transport.status || 0;
} catch (e) { return 0 }
},
responseIsSuccess: function() {
var status = this.getStatus();
return !status || (status >= 200 && status < 300);
},
responseIsFailure: function() {
return !this.responseIsSuccess();
}
};
Ajax.Request = Class.create();
Ajax.Request.Events =
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
Class.inherit( Ajax.Request, Ajax.Base, {
initialize: function(url, _options) {
this.transport = Ajax.getTransport();
this.setOptions(_options);
this.transportTimer = {};
this.finished = false;
this.request(url);
},
request: function(url) {
var parameters = this._options.parameters || '';
if (parameters.length > 0) parameters += '&_=';
try {
if (this._options._method == 'get' && parameters.length > 0)
url += '?' + parameters;
this.transport.open(this._options._method.toUpperCase(), url, this._options.asynchronous);
if (this._options.asynchronous) {
this.transport.onreadystatechange = this.onStateChange.bind(this);
if(this._options.timeout) {
this.transportTimer = setTimeout(this.handleTimeout.bind(this), this._options.timeout);
}
}
this.setRequestHeaders();
var pbody = this._options.postBody ? this._options.postBody : parameters;
this.transport.send(this._options._method == 'post' ? pbody : null);
} catch (e) {
this.dispatchException(e);
}
},
setRequestHeaders: function() {
var requestHeaders =
['X-Requested-With', 'XMLHttpRequest'];
if (this._options._method == 'post') {
requestHeaders.push('Content-type',
'application/x-www-form-urlencoded');
/* Force "Connection: close" for older Mozilla browsers to work
* around a bug where XMLHttpRequest sends an incorrect
* Content-length header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType &&
(navigator.userAgent.match("/Gecko\/(\d{4})/") || [0,2005])[1] < 2005)
requestHeaders.push('Connection', 'close');
}
if (this._options.requestHeaders)
requestHeaders.push.apply(requestHeaders, this._options.requestHeaders);
for (var i = 0; i < requestHeaders.length; i += 2)
this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
},
onStateChange: function() {
var readystate = this.transport.readyState;
if (readystate != 1)
this.respondToReadyState(this.transport.readyState);
},
handleTimeout: function() {
if(this.finished) { return; }
this.finished = true;
(this._options.onTimeout || Ajax.emptyFunction)(this);
},
respondToReadyState: function(readystate) {
var event = Ajax.Request.Events[readystate];
if (event == 'Complete') {
try {
if(!this.finished) {
this.finished = true;
if(this._options.timeout) { clearTimeout(this.transportTimer); }
(this._options.onComplete || Ajax.emptyFunction)(this.transport);
}
} catch (e) {
this.dispatchException(e);
}
/* Avoid memory leak in MSIE: clean up the oncomplete event handler */
this.transport.onreadystatechange = Ajax.emptyFunction;
}
},
dispatchException: function(exception) {
(this._options.onException || Ajax.emptyFunction)(this, exception);
}
});
var EventHelper = {
register : function(obj, ev,func){
var oldev = obj[ev];
if (typeof oldev != 'function') {
obj[ev] = func;
} else {
obj[ev] = function() {
oldev();
func();
}
}
}
};
/*
Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
of Simon Willison (see comments by Simon below).
http://ripcord.co.nz/behaviour/
*/
var Behaviour = {
list : new Array,
register : function(sheet){
Behaviour.list.push(sheet);
},
init : function(){
EventHelper.register(window, 'onload', function(){
Behaviour.apply();
});
},
apply : function(){
for (h=0;sheet=Behaviour.list[h];h++){
for (selector in sheet) {
list = document.getElementsBySelector(selector);
if (!list)
continue;
for( i = 0; element = list[i]; i++ ) {
sheet[selector]( element );
}
}
}
}
};
Behaviour.init();
function getAllChildren(e) {
// Returns all children of element. Workaround required for IE5/Windows. Ugh.
return e.all ? e.all : e.getElementsByTagName('*');
}
document.getElementsBySelector = function(selector) {
// Attempt to fail gracefully in lesser browsers
if (!document.getElementsByTagName) {
return new Array();
}
// Split selector in to tokens
var tokens = selector.split(' ');
var currentContext = new Array(document);
for (var i = 0; i < tokens.length; i++) {
token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
if (token.indexOf('#') > -1) {
// Token is an ID selector
var bits = token.split('#');
var tag_name = bits[0];
var id = bits[1];
var element = document.getElementById(id);
if (element == null || tag_name && element.nodeName.toLowerCase() != tag_name ) {
// tag with that ID not found, return false
return new Array();
}
// Set currentContext to contain just this element
currentContext = new Array(element);
continue; // Skip to next token
}
if (token.indexOf('.') > -1) {
// Token contains a class selector
var bits = token.split('.');
var tag_name = bits[0];
var class_name = bits[1];
if (!tag_name) {
tag_name = '*';
}
// Get elements matching tag, filter them for class selector
var found = new Array;
var foundCount = 0;
for (var h = 0; h < currentContext.length; h++) {
var elements;
if (tag_name == '*') {
elements = getAllChildren(currentContext[h]);
} else {
elements = currentContext[h].getElementsByTagName(tag_name);
}
if( elements == null )
continue;
for (var j = 0; j < elements.length; j++) {
found[foundCount++] = elements[j];
}
}
currentContext = new Array;
var currentContextIndex = 0;
for (var k = 0; k < found.length; k++) {
if (found[k].className && found[k].className.match(new RegExp("\\b"+class_name+"\\b"))) {
currentContext[currentContextIndex++] = found[k];
}
}
continue; // Skip to next token
}
// [evgeny] code for attribute selection is removed...
if (!currentContext[0]){
return;
}
// If we get here, token is JUST an element (not a class or ID selector)
tag_name = token;
var found = new Array;
var foundCount = 0;
for (var h = 0; h < currentContext.length; h++) {
var elements = currentContext[h].getElementsByTagName(tag_name);
for (var j = 0; j < elements.length; j++) {
found[foundCount++] = elements[j];
}
}
currentContext = found;
}
return currentContext;
};
var NodeUtils = {
getNodeValue: function(parent,name) {
var nodes = parent.getElementsByTagName( name );
if( nodes.length == 0 )
return "";
nodes = nodes[0].childNodes;
var reslt = "";
for( i = 0; i < nodes.length; i++ )
reslt += nodes[i].nodeValue;
return reslt;
},
getNodeText: function(_node) {
var _nodes = _node.childNodes;
var _text = "";
for( i = 0; i < _nodes.length; i++ )
_text += _nodes[i].nodeValue;
return _text;
},
getAttrValue: function(parent,name) {
for( k=0; k < parent.attributes.length; k++ )
if( parent.attributes[k].nodeName == name )
return parent.attributes[k].nodeValue;
return null;
}
};
var CommonUtils = {
getRow: function(_id,_table) {
var _row = _table.rows[_id];
if( _row != null )
return _row;
if( _table.rows['head'] != null )
return null;
for( k=0; k < _table.rows.length; k++ ) {
if( _table.rows[k].id == _id )
return _table.rows[k];
}
return null;
},
getCell: function(_id,_row,_table) {
var _cell = _row.cells[_id];
if( _cell != null )
return _cell;
if( _table.rows['head'] != null )
return null;
for( k=0; k < _row.cells.length; k++ ) {
if( _row.cells[k].id == _id )
return _row.cells[k];
}
return null;
},
insertCell: function(_row,_id,_className,_align,_height, _inner) {
var cell = _row.insertCell(-1);
cell.id = _id;
if(_align)
cell.align = _align;
cell.className = _className;
if(_height)
cell.height = _height;
cell.innerHTML = _inner;
}
};
function playSound(wav_file) {
var player = document.createElement("div");
var agt = navigator.userAgent.toLowerCase();
if(agt.indexOf('opera') != -1) {
player.style = "position: absolute; left: 0px; top: -200px;";
}
document.body.appendChild(player);
player.innerHTML = '<audio autoplay src="'+wav_file+'"><embed src="'+wav_file+'" hidden="true" autostart="true" loop="false"></audio>';
}
function htmlescape(str) {
return str.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;').replace('"','&quot;');
}
var ClientForm = Class.create();
ClientForm.prototype = {
initialize: function(form) {
this.emailPattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
this.form = form;
this.localizedStrings = null;
},
emailIsValid: function(emailField) {
if( emailField != null && emailField.value.search(this.emailPattern) == -1 ) {
return false;
}
return true;
},
changeGroup: function(groupField, descriptionFieldId, descriptions) {
document.getElementById(descriptionFieldId).innerHTML = descriptions[groupField.selectedIndex];
},
checkFields: function() {
return null;
},
localize: function(localizedStrings) {
this.localizedStrings = localizedStrings;
},
submit: function() {
var error = this.checkFields();
if(error === null){
this.form.submit();
}else{
if(error != '') {
alert(error);
}
}
}
}