removed not used javascript files

This commit is contained in:
Ralf Becker 2009-07-07 09:58:20 +00:00
parent 6570199588
commit a81931ca08
102 changed files with 15 additions and 16573 deletions

View File

@ -1,334 +0,0 @@
/***************************************************************************\
* eGroupWare - API *
* http://www.egroupware.org *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* sponsored by Thyamad - http://www.thyamad.com *
* ------------------------------------------------------------------------- *
* Javascript connector (XMLHTTP object interfacing) *
* ------------------------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\***************************************************************************/
function cConnector()
{
/* Public Attributes */
this.requests = new Array();
this.progressContents = new Array();
this.visible = false;
var _this = this;
this.nReqs = 0;
/* Private Attributes */
this._progressBox = null;
this._progressHolder = document.createElement('span');
/* Removed display of connecting status
this.setProgressBox('loading_box',true);
this.setProgressContent(1,GLOBALS['messages']['jsapi']['connector_1']);
this.setProgressContent(2,GLOBALS['messages']['jsapi']['connector_2']);
this.setProgressContent(3,GLOBALS['messages']['jsapi']['connector_3']);*/
this._progressHolder.style.visibility = 'hidden';
// this._progressHolder.style.backgroundColor = '#db7e22';
}
cConnector.prototype.newRequest = function (id, target, method, handler, data)
{
var _this = this;
if (this.requests[id] && this.requests[id] != null)
{
// TODO: Study better ways to do this...
return;
this.requests[id].abort();
delete this.requests[id];
setTimeout(function() { _this.newRequest(id, target, method, handler, data); }, 100);
return;
}
this.nReqs++;
document.body.style.cursor = 'progress';
var oxmlhttp = null;
try
{
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType('text/xml');
}
catch (e)
{
try
{
oxmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e1)
{
try
{
oxmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (e2)
{
oxmlhttp = null;
}
}
}
if (!oxmlhttp)
{
return false;
}
this.requests[id] = oxmlhttp;
var _this = this;
var sub_handler = function ()
{
try
{
_this._setProgressState(oxmlhttp.readyState);
if (oxmlhttp.readyState == 4 )//&& oxmlhttp.channel.status == 0)
{
if (!oxmlhttp || !oxmlhttp.status)
{
return;
}
if (dynapi.debug)
{
dynapi.debug.print('\nServer Message Arrived:\n\n'+oxmlhttp.responseText+'\n\n');
}
switch (oxmlhttp.status)
{
case 200:
if (typeof(handler) == 'function')
{
handler(oxmlhttp.responseText);
}
delete _this.requests[id];
_this.nReqs--;
if (!_this.nReqs) document.body.style.cursor = '';
break;
case 404:
alert('Page Not Found!');
break;
default:
//alert('Some problem while accessing the server. The status is '+oxmlhttp.status);
}
}
}
catch (e)
{
_this.nReqs--;
if (!_this.nReqs) document.body.style.cursor = '';
delete _this.requests[id];
// TODO: Handle of special exceptions must be made by API
// Exception 0x80040111 => trying to access a component without permission to do so
if (e && typeof(e) == 'object' && e.result && e.result == 0x80040111)
{
return;
}
showMessage(e);
}
}
try
{
if (method == '' || method == 'GET')
{
if (typeof(handler) == 'function')
{
oxmlhttp.onreadystatechange = sub_handler;
}
oxmlhttp.open("GET",target,true);
oxmlhttp.send(null);
}
else if (method == 'POST')
{
if (typeof(handler) == 'function')
{
oxmlhttp.onreadystatechange = sub_handler;
}
oxmlhttp.open("POST",target, true);
// oxmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
// viniciuscb commented here, messages should be in xmlrpc
oxmlhttp.setRequestHeader('Content-Type','text/xml');
oxmlhttp.send(data);
//oxmlhttp.setRequestHeader('Content-Type','multipart/form-data; boundary=-----------------------------1156053686807595044986274307');
//oxmlhttp.setRequestHeader('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5');
}
}
catch(e)
{
showMessage(e);
}
return true;
}
cConnector.prototype.cancelRequest = function (id)
{
if (!this.requests[id])
{
return false;
}
this.requests[id].abort();
}
cConnector.prototype.setProgressContent = function (state, content)
{
switch (state)
{
case 0:
case 'UNINITIALIZED':
this.progressContents[0] = content;
break;
case 1:
case 'LOADING':
this.progressContents[1] = content;
break;
case 2:
case 'LOADED':
this.progressContents[2] = content;
break;
case 3:
case 'INTERACTIVE':
this.progressContents[3] = content;
break;
case 4:
case 'COMPLETED':
this.progressContents[4] = content;
break;
default:
throw('INVALID STATE!');
}
}
cConnector.prototype.setProgressHolder = function (holder)
{
var objHolder;
if (typeof(holder) == 'string')
{
objHolder = Element(holder);
}
else if (typeof(holder) == 'object')
{
objHolder = holder;
}
else
{
return false;
}
objHolder.appendChild(this._progressHolder);
}
cConnector.prototype.setProgressBox = function (box, auto)
{
var objBox;
if (typeof(box) == 'string')
{
objBox = Element(box);
}
else if (typeof(box) == 'object')
{
objBox = box;
}
else
{
return false;
}
this._progressBox = objBox;
this._progressBoxAuto = auto ? true : false;
objBox.appendChild(this._progressHolder);
}
cConnector.prototype.setVisible = function (visible)
{
this.visible = visible;
if (!visible)
{
this._progressHolder.style.visibility = 'hidden';
}
}
/****************************************************************************\
* Private Methods *
\****************************************************************************/
cConnector.prototype._setProgressState = function (state)
{
switch (state)
{
case 0:
case 4:
if (this._progressBox != null)
{
this._progressBox.style.visibility = 'hidden';
this._progressBox.style.zIndex = '-1';
}
this._progressHolder.style.visibility = 'hidden';
this._progressHolder.style.zIndex = '-1';
break;
default:
if (this.visible)
{
if (this._progressBox != null)
{
if (this._progressBoxAuto)
{
if (is_ie)
{
this._progressBox.style.top = parseInt(document.body.offsetHeight)/2 + 'px';
this._progressBox.style.left = parseInt(document.body.offsetWidth)/2 + 'px';
}
else
{
this._progressBox.style.top = parseInt(window.innerHeight)/2 + parseInt(window.pageYOffset) - this._progressBox.style.height/2 + 'px';
this._progressBox.style.left = parseInt(window.innerWidth)/2 + parseInt(window.pageXOffset) - this._progressBox.style.width/2 + 'px';
}
}
this._progressBox.style.visibility = 'inherit';
this._progressBox.style.zIndex = 1000000;
}
this._progressHolder.style.visibility = 'inherit';
this._progressHolder.style.zIndex = '100';
this._progressHolder.innerHTML = this.progressContents[state] ? this.progressContents[state] : '';
}
}
}
var Connector;
dynapi.onLoad(function(){
Connector = new cConnector();
Connector.setVisible(true);
});

View File

@ -1,26 +0,0 @@
.dJSWin_main
{
background-color: #e3e3e3;
}
.dJSWin_title_text
{
background-color: #3978d6;
color: white;
font-weight: bold;
}
.dJSWin_title
{
background-color: #3978d6;
}
.dJSWin_high
{
background-color: #e3e3e3;
}
.dJSWin_low
{
background-color: #c9c9c9;
}

View File

@ -1,318 +0,0 @@
/****************************************************************************\
* Dynamic JS Win - Javascript Object *
* *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\****************************************************************************/
if (!window.dd)
{
throw("wz_dragdrop lib must be loaded!");
}
function dJSWin(params)
{
this.init(params);
}
dJSWin.prototype.init = function(params)
{
if (!params || typeof(params) != 'object' || !params.id || !params.width || !params.height || !params.content_id)
{
throw("Can't create empty window or window without width, height or ID");
}
/* Internal Variables */
this.clientArea = document.createElement('div');
this.title = document.createElement('div');
this.title_text = document.createElement('span');
this.buttons = new Array();
this.shadows = new Array();
this.border = new Array();
this.content = Element(params.content_id);
this.includedContents = params['include_contents'];
var _this = this;
var style;
style = document.createElement('link');
style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dJSWin/dJSWin.css";
style.rel = "stylesheet";
style.type = "text/css";
document.body.appendChild(style);
if (is_moz1_6)
{
var content_ = this.content;
this.content = this.content.cloneNode(true);
content_.id = content_.id+'CLONE';
content_.style.display = 'none';
}
this.border['t'] = document.createElement('div');
this.border['b'] = document.createElement('div');
this.border['l'] = document.createElement('div');
this.border['r'] = document.createElement('div');
this.shadows['r'] = document.createElement('div');
this.shadows['b'] = document.createElement('div');
this.buttons['xDIV'] = document.createElement('div');
if (params['button_x_img'])
{
this.buttons['xIMG'] = document.createElement('IMG');
this.buttons['xIMG'].src = params['button_x_img'];
this.buttons['xIMG'].style.cursor = 'hand';
this.buttons['xDIV'].appendChild(this.buttons['xIMG']);
}
else
{
this.buttons.xDIV.innerHTML = 'X';
}
/* Inicialization */
this.title.id = params['id'];
this.title.style.position = 'absolute';
this.title.style.visibility = 'hidden';
this.title.style.width = parseInt(params['width']) + 2 + 'px';
this.title.style.height = params['title_height'] ? params['title_height'] : '18px';
this.title.style.backgroundColor = '#3978d6';
// this.title.className = 'dJSWin_title';
this.title.style.top = '0px';
this.title.style.left = '0px';
this.title.style.zIndex = '1';
this.title_text.style.position = 'relative';
this.title_text.className = 'dJSWin_title_text';
// this.title_text.style.cursor = 'move';
this.title_text.innerHTML = params['title'];
this.title_text.style.zIndex = '1';
this.clientArea.id = params['id']+'_clientArea';
this.clientArea.style.position = 'absolute';
this.clientArea.style.visibility = 'hidden';
this.clientArea.style.width = parseInt(params['width']) + 2 + 'px';
this.clientArea.style.height = params['height'];
this.clientArea.style.top = parseInt(this.title.style.height) + 'px';
this.clientArea.style.left = '0px';
// this.clientArea.style.backgroundColor = params['bg_color'];
// this.clientArea.style.overflow = 'auto';
this.clientArea.className = 'dJSWin_main';
this.buttons.xDIV.id = params['id']+'_button';
this.buttons.xDIV.style.position = 'absolute';
this.buttons.xDIV.style.visibility = 'hidden';
this.buttons.xDIV.style.cursor = 'hand';
this.buttons.xDIV.style.top = '1px';
this.buttons.xDIV.style.left = parseInt(params['width']) - 13 + 'px';
this.buttons.xDIV.style.zIndex = '1';
this.buttons.xDIV.onclick = function() {_this.close();};
this.content.style.visibility = 'hidden';
//this.content.style.top = parseInt(this.title.style.height) + 'px';
this.content.style.top = '0px';
this.content.style.left = '0px';
this.shadows.b.id = params['id']+'_shadowb';
this.shadows.b.style.position = 'absolute';
this.shadows.b.style.visibility = 'hidden';
this.shadows.b.style.backgroundColor = '#666';
this.shadows.b.style.width = params['width'];
this.shadows.b.style.height = '4px';
this.shadows.b.style.top = parseInt(this.title.style.height) + parseInt(params['height']) + 'px';
this.shadows.b.style.left = '4px';
this.shadows.r.id = params['id']+'_shadowr';
this.shadows.r.style.position = 'absolute';
this.shadows.r.style.visibility = 'hidden';
this.shadows.r.style.backgroundColor = '#666';
this.shadows.r.style.width = '4px';
this.shadows.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px';
this.shadows.r.style.top = '4px';
this.shadows.r.style.left = params['width'];
this.border.t.id = params['id']+'_border_t';
this.border.b.id = params['id']+'_border_b';
this.border.l.id = params['id']+'_border_l';
this.border.r.id = params['id']+'_border_r';
this.border.t.style.position = 'absolute';
this.border.b.style.position = 'absolute';
this.border.l.style.position = 'absolute';
this.border.r.style.position = 'absolute';
this.border.t.style.visibility = 'hidden';
this.border.b.style.visibility = 'hidden';
this.border.l.style.visibility = 'hidden';
this.border.r.style.visibility = 'hidden';
this.border.t.className = 'dJSWin_title';
this.border.b.className = 'dJSWin_title';
this.border.l.className = 'dJSWin_title';
this.border.r.className = 'dJSWin_title';
this.border.t.style.border = '0px';
this.border.b.style.border = '0px';
this.border.l.style.border = '0px';
this.border.r.style.border = '0px';
if (params['border'])
{
this.border.t.style.width = parseInt(params['width']) + 2 + 'px';
this.border.b.style.width = parseInt(params['width']) + 2 + 'px';
this.border.l.style.width = '2px';
this.border.r.style.width = '2px';
this.border.t.style.height = '2px';
this.border.b.style.height = '2px';
this.border.l.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px';
this.border.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px';
this.border.t.style.top = '-2px';
this.border.b.style.top = parseInt(params['height']) + parseInt(this.title.style.height) + 'px';
this.border.l.style.top = '-2px';
this.border.r.style.top = '-2px';
this.border.t.style.left = '-2px';
this.border.b.style.left = '-2px';
this.border.l.style.left = '-2px';
this.border.r.style.left = params['width'];
this.shadows.b.style.top = parseInt(this.shadows.b.style.top) + 2 + 'px';
this.shadows.r.style.top = parseInt(this.shadows.r.style.top) + 2 + 'px';
this.shadows.b.style.left = parseInt(this.shadows.b.style.left) + 2 + 'px';
this.shadows.r.style.left = parseInt(this.shadows.r.style.left) + 2 + 'px';
}
else
{
this.border.t.style.width = '0px';
this.border.b.style.width = '0px';
this.border.l.style.width = '0px';
this.border.r.style.width = '0px';
}
if (!is_moz1_6)
{
this.content.parentNode.removeChild(this.content);
}
this.title.appendChild(this.title_text);
this.title.appendChild(this.clientArea);
this.title.appendChild(this.buttons.xDIV);
this.title.appendChild(this.border.t);
this.title.appendChild(this.border.b);
this.title.appendChild(this.border.l);
this.title.appendChild(this.border.r);
this.title.appendChild(this.shadows.r);
this.title.appendChild(this.shadows.b);
this.clientArea.appendChild(this.content);
document.body.appendChild(this.title);
this.draw();
}
dJSWin.prototype.close = function()
{
dd.elements[this.title.id].hide();
}
dJSWin.prototype.open = function()
{
this.moveTo(window.innerWidth/2 + window.pageXOffset - dd.elements[this.title.id].w/2,
window.innerHeight/2 + window.pageYOffset - dd.elements[this.clientArea.id].h/2);
dd.elements[this.title.id].maximizeZ();
dd.elements[this.title.id].show();
}
dJSWin.prototype.show = function()
{
this.open();
}
dJSWin.prototype.hide = function()
{
this.close();
}
dJSWin.prototype.moveTo = function(x,y)
{
dd.elements[this.title.id].moveTo(x,y);
}
dJSWin.prototype.x = function()
{
return dd.elements[this.title.id].x;
}
dJSWin.prototype.y = function()
{
return dd.elements[this.title.id].y;
}
dJSWin.prototype.draw = function()
{
if (dd.elements && dd.elements[this.title.id])
{
return;
}
if (this.drawn)
{
return;
}
this.drawn = true;
ADD_DHTML(this.title.id+CURSOR_MOVE);
ADD_DHTML(this.clientArea.id+NO_DRAG);
ADD_DHTML(this.buttons.xDIV.id+NO_DRAG);
ADD_DHTML(this.content.id+NO_DRAG);
ADD_DHTML(this.shadows.r.id+NO_DRAG);
ADD_DHTML(this.shadows.b.id+NO_DRAG);
ADD_DHTML(this.border.t.id+NO_DRAG);
ADD_DHTML(this.border.b.id+NO_DRAG);
ADD_DHTML(this.border.l.id+NO_DRAG);
ADD_DHTML(this.border.r.id+NO_DRAG);
dd.elements[this.title.id].addChild(dd.elements[this.border.t.id]);
dd.elements[this.title.id].addChild(dd.elements[this.clientArea.id]);
dd.elements[this.title.id].addChild(dd.elements[this.buttons.xDIV.id]);
dd.elements[this.title.id].addChild(dd.elements[this.content.id]);
dd.elements[this.title.id].addChild(dd.elements[this.shadows.r.id]);
dd.elements[this.title.id].addChild(dd.elements[this.shadows.b.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.b.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.l.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.r.id]);
if (typeof(this.includedContents) == 'object')
{
for (var i in this.includedContents)
{
ADD_DHTML(this.includedContents[i]+NO_DRAG);
dd.elements[this.title.id].addChild(dd.elements[this.includedContents[i]]);
}
}
dd.elements[this.title.id].hide();
dd.elements[this.title.id].moveTo(window.innerWidth/2 - dd.elements[this.clientArea.id].w/2,
window.innerHeight/2 - dd.elements[this.clientArea.id].h/2);
}
if (!dd.elements)
{
var div = document.createElement('div');
div.id = '__NONE__#';
div.style.position = 'absolute';
SET_DHTML(div.id);
}

View File

@ -1,321 +0,0 @@
/****************************************************************************\
* Dynamic JS Win - Javascript Object *
* *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\****************************************************************************/
dJSWin.prototype.init = function(params)
{
if (!params || typeof(params) != 'object' || !params.id || !params.width || !params.height || !params.content_id)
{
throw("Can't create empty window or window without width, height or ID");
}
/* Internal Variables */
this.winContainer = document.createElement('iframe');
this.clientArea = document.createElement('div');
this.title = document.createElement('div');
this.title_text = null; //document.createElement('');
this.buttons = new Array();
this.shadows = new Array();
this.border = new Array();
this.content_id = params.content_id;
this.includedContents = params['include_contents'];
var pixelTABLE, pixelTBODY, pixelTR, pixelTD;
var _this = this;
var style;
/* Create 1 pixel table to be able to create freely
* sizeble DIVs on IE
*/
pixelTABLE = document.createElement('table');
pixelTBODY = document.createElement('tbody');
pixelTR = document.createElement('tR');
pixelTD = document.createElement('td');
pixelTABLE.appendChild(pixelTBODY);
pixelTBODY.appendChild(pixelTR);
pixelTR.appendChild(pixelTD);
this.title_text_cont = pixelTABLE.cloneNode(true);
this.title_text = this.title_text_cont.firstChild.firstChild.firstChild;
pixelTABLE.style.width = '1px';
pixelTABLE.style.height = '1px';
pixelTD.style.width = '1px';
pixelTD.style.height = '1px';
this.border['t'] = document.createElement('div');
this.border['b'] = document.createElement('div');
this.border['l'] = document.createElement('div');
this.border['r'] = document.createElement('div');
this.shadows['r'] = document.createElement('div');
this.shadows['b'] = document.createElement('div');
this.buttons['xDIV'] = document.createElement('div');
if (params['button_x_img'])
{
this.buttons['xIMG'] = document.createElement('IMG');
this.buttons['xIMG'].src = params['button_x_img'];
this.buttons['xIMG'].style.cursor = 'hand';
this.buttons['xDIV'].appendChild(this.buttons['xIMG']);
}
else
{
this.buttons.xDIV.innerHTML = 'X';
}
/* Inicialization */
this.title.id = params['id'];
this.title.style.position = 'absolute';
this.title.style.visibility = 'hidden';
this.title.style.width = parseInt(params['width']) + 2 + 'px';
this.title.style.height = params['title_height'] ? params['title_height'] : '18px';
this.title.style.backgroundColor = '#3978d6';
// this.title.className = 'dJSWin_title';
this.title.style.top = '0px';
this.title.style.left = '0px';
this.title.style.zIndex = '1';
this.title_text_cont.id = params['id'] + '_text';
this.title_text_cont.style.position = 'relative';
// this.title_text_cont.border = '0';
this.title_text_cont.style.width = '100%';
this.title_text_cont.style.height = '100%';
this.title_text.style.cursor = 'move';
this.title_text_cont.className = 'dJSWin_title_text';
this.title_text.className = 'dJSWin_title_text';
// this.title_text.style.cursor = 'move';
this.title_text.innerHTML = params['title'];
this.title_text_cont.style.zIndex = '1';
this.winContainer.id = params['id']+'_winContainer';
this.winContainer.style.position = 'absolute';
this.winContainer.style.visibility = 'hidden';
this.winContainer.style.width = params['width'];
this.winContainer.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px';
// this.winContainer.style.top = '0px';
this.winContainer.style.top = '0px'; //this.title.style.height;
this.winContainer.style.left = '0px';
this.winContainer.style.zIndex = '-1';
// this.winContainer.style.backgroundColor = params['bg_color'];
// this.winContainer.className = params['win_class'];
this.winContainer.src = '';
this.clientArea.id = params['id']+'_clientArea';
this.clientArea.style.position = 'absolute';
this.clientArea.style.visibility = 'hidden';
this.clientArea.style.width = parseInt(params['width']) + 2 + 'px';
this.clientArea.style.height = params['height'];
this.clientArea.style.top = parseInt(this.title.style.height) + 'px';
this.clientArea.style.left = '0px';
// this.clientArea.style.backgroundColor = params['bg_color'];
// this.clientArea.style.overflow = 'auto';
this.clientArea.className = 'dJSWin_main';
this.buttons.xDIV.id = params['id']+'_button';
this.buttons.xDIV.style.position = 'absolute';
this.buttons.xDIV.style.visibility = 'hidden';
this.buttons.xDIV.style.cursor = 'hand';
this.buttons.xDIV.style.top = '1px';
this.buttons.xDIV.style.left = parseInt(params['width']) - 13 + 'px';
this.buttons.xDIV.style.zIndex = '1';
this.buttons.xDIV.onclick = function() {_this.close();};
this.shadows.b.id = params['id']+'_shadowb';
this.shadows.b.style.position = 'absolute';
this.shadows.b.style.visibility = 'hidden';
this.shadows.b.style.backgroundColor = '#666';
this.shadows.b.style.width = params['width'];
this.shadows.b.style.height = '4px';
this.shadows.b.style.top = parseInt(this.title.style.height) + parseInt(params['height']) + 2 + 'px';
this.shadows.b.style.left = '4px';
this.shadows.b.appendChild(pixelTABLE.cloneNode(true));
this.shadows.r.id = params['id']+'_shadowr';
this.shadows.r.style.position = 'absolute';
this.shadows.r.style.visibility = 'hidden';
this.shadows.r.style.backgroundColor = '#666';
this.shadows.r.style.width = '4px';
this.shadows.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px';
this.shadows.r.style.top = '4px';
this.shadows.r.style.left = params['width'];
this.border.t.id = params['id']+'_border_t';
this.border.b.id = params['id']+'_border_b';
this.border.l.id = params['id']+'_border_l';
this.border.r.id = params['id']+'_border_r';
this.border.t.style.position = 'absolute';
this.border.b.style.position = 'absolute';
this.border.l.style.position = 'absolute';
this.border.r.style.position = 'absolute';
this.border.t.style.visibility = 'hidden';
this.border.b.style.visibility = 'hidden';
this.border.l.style.visibility = 'hidden';
this.border.r.style.visibility = 'hidden';
this.border.t.className = 'dJSWin_title';
this.border.b.className = 'dJSWin_title';
this.border.l.className = 'dJSWin_title';
this.border.r.className = 'dJSWin_title';
this.border.t.style.border = '0px';
this.border.b.style.border = '0px';
this.border.l.style.border = '0px';
this.border.r.style.border = '0px';
this.border.t.appendChild(pixelTABLE.cloneNode(true));
this.border.b.appendChild(pixelTABLE.cloneNode(true));
if (params['border'])
{
this.border.t.style.width = parseInt(params['width']) + 2 + 'px';
this.border.b.style.width = parseInt(params['width']) + 4 + 'px';
this.border.l.style.width = '2px';
this.border.r.style.width = '2px';
this.border.t.style.height = '2px';
this.border.b.style.height = '2px';
this.border.l.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px';
this.border.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px';
this.border.t.style.top = '-2px';
this.border.b.style.top = parseInt(params['height']) + parseInt(this.title.style.height) + 'px';
this.border.l.style.top = '-2px';
this.border.r.style.top = '-2px';
this.border.t.style.left = '-2px';
this.border.b.style.left = '-2px';
this.border.l.style.left = '-2px';
this.border.r.style.left = params['width'];
this.shadows.b.style.top = parseInt(this.shadows.b.style.top) + 2 + 'px';
this.shadows.r.style.top = parseInt(this.shadows.r.style.top) + 2 + 'px';
this.shadows.b.style.left = parseInt(this.shadows.b.style.left) + 2 + 'px';
this.shadows.r.style.left = parseInt(this.shadows.r.style.left) + 2 + 'px';
this.winContainer.style.top = '-3px';
this.winContainer.style.left = '-2px';
this.winContainer.style.width = parseInt(this.winContainer.style.width) + 8 + 'px';
this.winContainer.style.height = parseInt(this.winContainer.style.height) + 10 + 'px';
}
else
{
this.border.t.style.width = '0px';
this.border.b.style.width = '0px';
this.border.l.style.width = '0px';
this.border.r.style.width = '0px';
}
//JsLib.postponeFunction(function(){_this._createWin();});
this._createWin();
}
dJSWin.prototype.open = function()
{
this.moveTo(document.body.offsetWidth/2 + document.body.scrollLeft - dd.elements[this.title.id].w/2,
document.body.offsetHeight/2 + document.body.scrollTop - dd.elements[this.winContainer.id].h/2);
dd.elements[this.title.id].maximizeZ();
dd.elements[this.title.id].show();
}
dJSWin.prototype.draw = function()
{
if (this.drawn)
{
return;
}
this.drawn = true;
if (dd.elements && dd.elements[this.title.id])
{
return;
}
ADD_DHTML(this.title.id+CURSOR_MOVE);
ADD_DHTML(this.title_text_cont.id+NO_DRAG);
ADD_DHTML(this.winContainer.id+NO_DRAG);
ADD_DHTML(this.clientArea.id+NO_DRAG);
ADD_DHTML(this.buttons.xDIV.id+NO_DRAG);
ADD_DHTML(this.content.id+NO_DRAG);
ADD_DHTML(this.shadows.r.id+NO_DRAG);
ADD_DHTML(this.shadows.b.id+NO_DRAG);
ADD_DHTML(this.border.t.id+NO_DRAG);
ADD_DHTML(this.border.b.id+NO_DRAG);
ADD_DHTML(this.border.l.id+NO_DRAG);
ADD_DHTML(this.border.r.id+NO_DRAG);
dd.elements[this.winContainer.id].setZ(-1);
dd.elements[this.title.id].setZ(0);
dd.elements[this.title.id].addChild(dd.elements[this.title_text_cont.id]);
dd.elements[this.title.id].addChild(dd.elements[this.winContainer.id]);
dd.elements[this.title.id].addChild(dd.elements[this.clientArea.id]);
dd.elements[this.title.id].addChild(dd.elements[this.buttons.xDIV.id]);
dd.elements[this.title.id].addChild(dd.elements[this.content.id]);
dd.elements[this.title.id].addChild(dd.elements[this.shadows.r.id]);
dd.elements[this.title.id].addChild(dd.elements[this.shadows.b.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.t.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.b.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.l.id]);
dd.elements[this.title.id].addChild(dd.elements[this.border.r.id]);
if (typeof(this.includedContents) == 'object')
{
for (var i in this.includedContents)
{
ADD_DHTML(this.includedContents[i]+NO_DRAG);
dd.elements[this.title.id].addChild(dd.elements[this.includedContents[i]]);
}
}
dd.elements[this.title.id].moveTo(document.body.offsetWidth/2 - dd.elements[this.winContainer.id].w/2,
document.body.offsetHeight/2 - dd.elements[this.winContainer.id].h/2)
dd.elements[this.title.id].hide();
}
dJSWin.prototype._createWin = function()
{
style = document.createElement('link');
style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dJSWin/dJSWin.css";
style.rel = "stylesheet";
style.type = "text/css";
document.body.appendChild(style);
this.content = Element(this.content_id);
this.content.style.visibility = 'hidden';
//this.content.style.top = parseInt(this.title.style.height) + 'px';
this.content.style.top = '0px';
this.content.style.left = '0px';
this.title.appendChild(this.title_text_cont);
this.title.appendChild(this.winContainer);
this.title.appendChild(this.clientArea);
this.title.appendChild(this.buttons.xDIV);
this.title.appendChild(this.border.t);
this.title.appendChild(this.border.b);
this.title.appendChild(this.border.l);
this.title.appendChild(this.border.r);
this.title.appendChild(this.shadows.r);
this.title.appendChild(this.shadows.b);
this.clientArea.appendChild(this.content);
document.body.appendChild(this.title);
this.draw();
}

View File

@ -1,54 +0,0 @@
.dTabs_noTabs
{
background-color: #a3a3a3;
width: '100%';
}
.dTabs_selected
{
background-color: #e3e3e3;
color: black;
font-weight: bold;
text-align: center;
width: 2px;
cursor: pointer;
}
.dTabs_unselected
{
background-color: #c9c9c9;
color: black;
font-weight: 0;
text-align: center;
width: 2px;
cursor: pointer;
cursor: hand;
}
.dTabs_unselected:hover
{
background-color: #c9c9c9;
color: red;
font-weight: 0;
text-align: center;
width: 2px;
cursor: pointer;
cursor: hand;
}
.dTabs_disabled
{
background-color: #c9c9c9;
color: #a3a3a3;
font-weight: 0;
text-align: center;
width: 2px;
cursor: hand;
cursor: pointer;
}
.dTabs_tr_index
{
border-spacing: 0px;
padding: 5px;
}

View File

@ -1,302 +0,0 @@
/****************************************************************************\
* Dynamic Tabs - Javascript Object *
* *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\****************************************************************************/
/*
* Dynamic Tabs - On-The-Fly Tabs in Javascript
*
* Usage:
* var tabs = new dTabsManager({'id': <DIV id to be used>, 'width': '498px'});
*
* tabs.addTab({'id': <ID of the Contents DIV (must be absolute)>,
* 'name': <text to be shown on tab selector>,
* 'selectedClass': <name of the class to be used when Tab is selected>,
* 'unselectedClass': <name of the class to be used when Tab is not selected>});
*/
/* Mozilla 1.6 has a bug which impossibilitates it to manage DOM contents that are defined in the
* original document. So we have to workaround it.
*/
navigator.userAgent.toLowerCase().match('mozilla.*rv[:]1\.6.*gecko') ? is_moz1_6 = true : is_moz1_6 = false;
function dTabsManager(params)
{
this._tabEvents = { show: {}, hide: {}};
this.init(params);
}
dTabsManager.prototype.init = function(params)
{
/* Attributes definition */
this._Tabs = new Array();
this._Tabs['root'] = null;
this._Tabs['tabIndexTR'] = null;
this._Tabs['tabIndexTDs'] = new Array();
this._Tabs['contents'] = null;
this._Tabs['contentsDIV'] = null;
this._selectedIndex = null;
this._nTabs = params['nTabs'] ? params['nTabs'] : 0;
this._maxTabs = params['maxTabs'] ? params['maxTabs'] : 0;
/* Create and insert the container */
var table, tbody, tr, td, style;
style = document.createElement('link');
style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dTabs/dTabs.css";
style.rel = "stylesheet";
style.type = "text/css";
document.body.appendChild(style);
this._Tabs['root'] = document.createElement('div');
this._Tabs['root'].id = params['id'];
this._Tabs['root'].style.position = 'absolute';
//this._Tabs['root'].style.visibility = 'hidden';
this._Tabs['root'].style.top = '150px';
this._Tabs['root'].style.left = '0px';
this._Tabs['root'].style.width = params['width'] ? params['width'] : 0;
table = document.createElement('table');
tbody = document.createElement('tbody');
table.style.border = '0px solid black';
table.style.width = '100%';
table.style.height = '100%';
table.cellpadding = '10px';
this._Tabs['tabIndexTR'] = document.createElement('tr');
this._Tabs['tabIndexTR'].style.height = '30px';
this._Tabs['tabIndexTR'].className = 'dTabs_tr_index';
//this._Tabs['tabIndexTR'].style.width = '100%';
this._Tabs['emptyTab'] = document.createElement('td');
this._Tabs['emptyTab'].className = 'dTabs_noTabs';
this._Tabs['emptyTab'].innerHTML = '&nbsp;';
this._Tabs['tabIndexTR'].appendChild(this._Tabs['emptyTab']);
tr = document.createElement('tr');
td = document.createElement('td');
tr.style.width = '100%';
tr.style.height = '100%';
//this._Tabs['contentsDIV'] = document.createElement('div');
//this._Tabs['contentsDIV'].style.position = 'relative';
this._Tabs['contentsDIV'] = td;
this._Tabs['root'].appendChild(table);
table.appendChild(tbody);
tbody.appendChild(this._Tabs['tabIndexTR']);
tbody.appendChild(tr);
tr.appendChild(td);
//td.appendChild(this._Tabs['contentsDIV']);
tr.appendChild(this._Tabs['contentsDIV']);
this._Tabs['contents'] = new Array();
document.body.appendChild(this._Tabs['root']);
}
/*
@method addTab
@abstract Inserts a tab
*/
dTabsManager.prototype.addTab = function (params)
{
if (typeof(params) != 'object')
{
return false;
}
if (!params['id'] || !Element(params['id']) ||
Element(params['id']).tagName.toLowerCase() != 'div' ||
Element(params['id']).style.position.toLowerCase() != 'absolute')
{
return false;
}
if (this._Tabs['contents'][params['id']])
{
this.replaceTab(params);
return;
}
//var contents, tdIndex;
var element = Element(params['id']);
if (is_moz1_6)
{/*
var element_ = element;
element = element.cloneNode(true);
//element_.parentNode.replaceChild(element, element_);
element_.id = element_.id+'CLONED';
element_.style.display = 'none';*/
element.style.position = 'absolute';
}
else
{
element.parentNode.removeChild(element);
}
element.style.top = parseInt(this._Tabs['tabIndexTR'].style.height) + 5 + 'px';
element.style.left = this._Tabs['root'].style.left;
element.style.zIndex = '-1';
this._Tabs['contents'][params['id']] = element;
this._Tabs.tabIndexTDs[params['id']] = document.createElement('td');
var _this = this;
this._Tabs.tabIndexTDs[params['id']].innerHTML = '&nbsp;&nbsp;'+(params['name'] ? params['name'] : 'undefined')+'&nbsp;&nbsp;';
this._Tabs.tabIndexTDs[params['id']].selectedClassName = 'dTabs_selected';
this._Tabs.tabIndexTDs[params['id']].unselectedClassName = 'dTabs_unselected';
this._Tabs.tabIndexTDs[params['id']].className = 'dTabs_unselected';
this._Tabs.tabIndexTDs[params['id']].onclick = function() {_this._showTab(params['id']);};
/* Old Version
this._Tabs.tabIndexTDs[params['id']].innerHTML = params['name'] ? params['name'] : 'undefined';
this._Tabs.tabIndexTDs[params['id']].selectedClassName = params['selectedClass'];
this._Tabs.tabIndexTDs[params['id']].unselectedClassName = params['unselectedClass'];
this._Tabs.tabIndexTDs[params['id']].className = params['unselectedClass'];
this._Tabs.tabIndexTDs[params['id']].onclick = function() {_this._showTab(params['id']);};
*/
this._Tabs.tabIndexTR.removeChild(this._Tabs['emptyTab']);
this._Tabs.tabIndexTR.appendChild(this._Tabs.tabIndexTDs[params['id']]);
this._Tabs.tabIndexTR.appendChild(this._Tabs['emptyTab']);
if (!is_moz1_6)
{
this._Tabs.contentsDIV.appendChild(this._Tabs['contents'][params['id']]);
}
this._nTabs++;
if (this._nTabs == 1)
{
this._showTab(params['id']);
}
return;
}
dTabsManager.prototype.removeTab = function (id)
{
if (!this._Tabs.contents[params['id']])
{
return false;
}
this._Tabs.tabIndexTR.removeChild(this._Tabs.tabIndexTDs[params['id']]);
this._Tabs.contentsDIV.removeChild(this._Tabs.contents[params['id']]);
this._Tabs.contents[params['id']] = null;
this._Tabs.tabIndexTDs[params['id']] = null;
return true;
}
dTabsManager.prototype.getTabObject = function()
{
return this._Tabs.root;
}
dTabsManager.prototype.enableTab = function(id)
{
if (this._Tabs.contents[id])
{
var _this = this;
this._Tabs.tabIndexTDs[id].className = 'dTabs_unselected';
this._Tabs.tabIndexTDs[id].onclick = function() {_this._showTab(id);};
}
}
dTabsManager.prototype.disableTab = function(id)
{
if (this._Tabs.contents[id])
{
this._Tabs.tabIndexTDs[id].className = 'dTabs_disabled';
this._Tabs.tabIndexTDs[id].onclick = false;
}
}
/****************************************************************************\
* Private Methods *
\****************************************************************************/
dTabsManager.prototype._showTab = function (id)
{
if (!this._Tabs.contents[id])
{
return false;
}
/* Ajust the tabIndexTR width to be the same as the contents width*/
if (this._Tabs.contents[id].style.width)
{
this._Tabs['root'].style.width = this._Tabs.contents[id].style.width;
this._Tabs['root'].style.height = this._Tabs.contents[id].style.height;
}
/*
else
{
this._Tabs['root'].style.width = '0px';
}*/
this._Tabs.tabIndexTDs[id].className = this._Tabs.tabIndexTDs[id].selectedClassName;
for (var i in this._Tabs.contents)
{
if (i == 'length')
{
continue;
}
//viniciuscb: mystery
if (this._Tabs.contents[i].style != null)
{
this._Tabs.contents[i].style.visibility = 'hidden';
this._Tabs.contents[i].style.display = 'none';
this._Tabs.contents[i].style.zIndex = '-1';
if (this._tabEvents['hide'][i]) this._tabEvents['hide'][i]();
}
}
this._Tabs.contents[id].style.visibility = 'visible';
this._Tabs.contents[id].style.display = '';
this._Tabs.contents[id].style.zIndex = '10';
if (this._tabEvents['show'][id]) this._tabEvents['show'][id]();
if (this._selectedIndex && this._selectedIndex != id)
{
this._Tabs.tabIndexTDs[this._selectedIndex].className = this._Tabs.tabIndexTDs[this._selectedIndex].unselectedClassName;
this._focus(this._Tabs.contents[id]);
}
this._selectedIndex = id;
}
dTabsManager.prototype._focus = function(obj)
{
for (var i in obj.childNodes)
{
if (obj.childNodes[i].focus)
{
obj.childNodes[i].focus();
return true;
}
else
{
if (this._focus(obj.childNodes[i]))
{
return true;
}
}
}
}

View File

@ -1,234 +0,0 @@
/****************************************************************************\
* Dynamic Tabs - Javascript Object *
* *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\****************************************************************************/
/*
* Dynamic Tabs - On-The-Fly Tabs in Javascript
*
* Usage:
* var tabs = new dTabsManager({'id': <DIV id to be used>, 'width': '498px'});
*
* tabs.addTab({'id': <ID of the Contents DIV (must be absolute)>,
* 'name': <text to be shown on tab selector>,
* 'selectedClass': <name of the class to be used when Tab is selected>,
* 'unselectedClass': <name of the class to be used when Tab is not selected>});
*/
dTabsManager.prototype.init = function(params)
{
/* Attributes definition */
this._Tabs = new Array();
this._Tabs['root'] = null;
this._Tabs['tabIndexTR'] = null;
this._Tabs['tabIndexTDs'] = new Array();
this._Tabs['contents'] = null;
this._Tabs['contentsDIV'] = null;
this._selectedIndex = null;
this._nTabs = params['nTabs'] ? params['nTabs'] : 0;
this._maxTabs = params['maxTabs'] ? params['maxTabs'] : 0;
/* Create and insert the container */
var table, tbody, tr, td, style;
var _this = this;
style = document.createElement('link');
style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dTabs/dTabs.css";
style.rel = "stylesheet";
style.type = "text/css";
this._Tabs['root'] = document.createElement('div');
this._Tabs['root'].id = params['id'];
this._Tabs['root'].style.position = 'absolute';
//this._Tabs['root'].style.visibility = 'hidden';
this._Tabs['root'].style.top = '150px';
this._Tabs['root'].style.left = '0px';
this._Tabs['root'].style.width = params['width'] ? params['width'] : 0;
table = document.createElement('table');
tbody = document.createElement('tbody');
table.style.border = '0px solid black';
table.style.width = '100%';
table.style.height = '100%';
table.cellpadding = '10px';
this._Tabs['tabIndexTR'] = document.createElement('tr');
this._Tabs['tabIndexTR'].style.height = '30px';
this._Tabs['tabIndexTR'].className = 'dTabs_tr_index';
//this._Tabs['tabIndexTR'].style.width = '100%';
this._Tabs['emptyTab'] = document.createElement('td');
this._Tabs['emptyTab'].className = 'dTabs_noTabs';
this._Tabs['emptyTab'].innerHTML = '&nbsp;';
this._Tabs['tabIndexTR'].appendChild(this._Tabs['emptyTab']);
tr = document.createElement('tr');
td = document.createElement('td');
tr.style.width = '100%';
tr.style.height = '100%';
//this._Tabs['contentsDIV'] = document.createElement('div');
//this._Tabs['contentsDIV'].style.position = 'relative';
this._Tabs['contentsDIV'] = td;
this._Tabs['root'].appendChild(table);
table.appendChild(tbody);
tbody.appendChild(this._Tabs['tabIndexTR']);
tbody.appendChild(tr);
tr.appendChild(td);
//td.appendChild(this._Tabs['contentsDIV']);
tr.appendChild(this._Tabs['contentsDIV']);
this._Tabs['contents'] = new Array();
var create = function ()
{
document.body.appendChild(style);
document.body.appendChild(_this._Tabs['root']);
_this.created = true;
}
this.created = false;
//JsLib.postponeFunction(create);
create();
}
/*
@method addTab
@abstract Inserts a tab
*/
dTabsManager.prototype.addTab = function (params)
{
var _this = this;
if (this.created)
{
return this.addTabIE(params);
}
//JsLib.postponeFunction(function(){ _this.addTabIE(params);});
}
dTabsManager.prototype.addTabIE = function (params)
{
if (typeof(params) != 'object')
{
return false;
}
if (!params['id'] || !Element(params['id']) ||
Element(params['id']).tagName.toLowerCase() != 'div' ||
Element(params['id']).style.position.toLowerCase() != 'absolute')
{
return false;
}
if (this._Tabs['contents'][params['id']])
{
this.replaceTab(params);
return;
}
//var contents, tdIndex;
var element = Element(params['id']);
// element.parentNode.removeChild(element);
element.style.top = parseInt(this._Tabs['tabIndexTR'].style.height) + 5 + 'px';
element.style.left = this._Tabs['root'].style.left;
element.style.zIndex = '-1';
this._Tabs['contents'][params['id']] = element;
this._Tabs.tabIndexTDs[params['id']] = document.createElement('td');
var _this = this;
this._Tabs.tabIndexTDs[params['id']].innerHTML = '&nbsp;&nbsp;'+(params['name'] ? params['name'] : 'undefined')+'&nbsp;&nbsp;';
this._Tabs.tabIndexTDs[params['id']].selectedClassName = 'dTabs_selected';
this._Tabs.tabIndexTDs[params['id']].unselectedClassName = 'dTabs_unselected';
this._Tabs.tabIndexTDs[params['id']].className = 'dTabs_unselected';
this._Tabs.tabIndexTDs[params['id']].onclick = function() {_this._showTab(params['id']);};
/* Old Version
this._Tabs.tabIndexTDs[params['id']].innerHTML = params['name'] ? params['name'] : 'undefined';
this._Tabs.tabIndexTDs[params['id']].selectedClassName = params['selectedClass'];
this._Tabs.tabIndexTDs[params['id']].unselectedClassName = params['unselectedClass'];
this._Tabs.tabIndexTDs[params['id']].className = params['unselectedClass'];
this._Tabs.tabIndexTDs[params['id']].onclick = function() {_this._showTab(params['id']);};
*/
this._Tabs.tabIndexTR.removeChild(this._Tabs['emptyTab']);
this._Tabs.tabIndexTR.appendChild(this._Tabs.tabIndexTDs[params['id']]);
this._Tabs.tabIndexTR.appendChild(this._Tabs['emptyTab']);
this._Tabs.contentsDIV.appendChild(this._Tabs['contents'][params['id']]);
this._nTabs++;
if (this._nTabs == 1)
{
this._showTab(params['id']);
}
return;
}
dTabsManager.prototype.enableTab = function(id)
{
var _this = this;
var enable = function()
{
if (_this._Tabs.contents[id])
{
_this._Tabs.tabIndexTDs[id].className = 'dTabs_unselected';
_this._Tabs.tabIndexTDs[id].onclick = function() {_this._showTab(id);};
}
}
if (!this.created)
{
JsLib.postponeFunction(enable);
}
else
{
enable();
}
}
dTabsManager.prototype.disableTab = function(id)
{
var _this = this;
var disable = function ()
{
if (_this._Tabs.contents[id])
{
_this._Tabs.tabIndexTDs[id].className = 'dTabs_disabled';
_this._Tabs.tabIndexTDs[id].onclick = null;
}
}
if (!this.created)
{
JsLib.postponeFunction(disable);
}
else
{
disable();
}
}
/****************************************************************************\
* Private Methods *
\****************************************************************************/

View File

@ -1,288 +0,0 @@
/*
DynAPI Distribution
DynDocument Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynElement
*/
function DynDocument(frame) {
this.DynElement = DynElement;
this.DynElement();
this.frame = frame;
this.doc = this.frame.document;
this._dyndoc = this;
this.x = 0;
this.y = 0;
this.w = 0;
this.h = 0;
this._topZIndex = 10000;
var o = this;
this.frame.onresize = function() {o._handleResize()};
this.onResizeNS4 = "reload"; // or "redraw"
this._created = false;
};
var p = dynapi.setPrototype('DynDocument','DynElement');
p._remove = function() {
this.elm=null;
this.doc=null;
this.frame=null;
};
p.getBgColor = function() {
return this.bgColor;
};
p.getX = p.getY = p.getPageX = p.getPageY = dynapi.functions.Zero;
p.getWidth = function() {
if (!this.w) this.findDimensions();
return this.w;
};
p.getHeight = function() {
if (!this.h) this.findDimensions();
return this.h;
};
p.getXScroll = function ()
{
return (dynapi.ua.ns)? this.frame.pageXOffset : this.elm.scrollLeft;
}
p.getYScroll = function ()
{
return (dynapi.ua.ns)? this.frame.pageYOffset : this.elm.scrollTop;
}
p.findDimensions = function() {
this.w=(dynapi.ua.ns||dynapi.ua.opera)? this.frame.innerWidth : (dynapi.ua.ie6) ?
this.doc.documentElement.clientWidth : this.elm.clientWidth;
this.h=(dynapi.ua.ns||dynapi.ua.opera)? this.frame.innerHeight : (dynapi.ua.ie6) ?
this.doc.documentElement.clientHeight : this.elm.clientHeight;
};
p.setBgColor = function(color) {
if (color == null) color='';
if (dynapi.ua.ns4 && color == '') color = '#ffffff';
this.bgColor = color;
this.doc.bgColor = color;
};
p.setFgColor = function(color) {
if (color == null) color='';
if (dynapi.ua.ns4 && color == '') color='#ffffff';
this.fgColor = color;
this.doc.fgColor = color;
};
p.insertChild = function(c,pos,usebp) { // Blueprint Enabled
if (c && !c.isInline && c.parent == this) {
if(pos) c.setPosition(pos);
DynElement._flagPreCreate(c);
if(usebp)
c.isInline=c._noInlineValues=true;
else {
this.doc.write(c.getOuterHTML());
c._inserted = true;
}
}
};
p.insertAllChildren = function(usebp,bpSrc) { // Blueprint Enabled
var i,c,str =[''];
var ch=this.children;
for(i=0;i<ch.length;i++) {
c = ch[i];
if(!c.isInline && !c._inserted){
DynElement._flagPreCreate(c);
if(usebp)
c.isInline=c._noInlineValues=true;
else {
str[i]=c.getOuterHTML();
c._inserted = true;
}
}
}
if(this._hBuffer.length) this.doc.write(this._hBuffer.join('')); // used by addHTML()
if(usebp){
if(bpSrc) dynapi.frame.document.write('<script type="text/javascript" language="JavaScript" src="'+bpSrc+'"><\/script>');
}
else {
this.doc.write(str.join('\n'));
this.doc.close();
}
};
p._create = function() {
var ua=dynapi.ua;
this._created = true;
if (ua.ns4) {
this.css = this.doc;
this.elm = this.doc;
}
else {
this.elm = this.frame.document.body;
this.css = this.frame.document.body.style;
if (ua.ie) {
this._overflow = this.css.overflow || '';
}
if (this._cursor) this.css.cursor = this._cursor;
}
this.elm._dynobj = this;
this.doc._dynobj = this; // DynKeyEvent needs this!
this.findDimensions();
this.fgColor = this.doc.fgColor||'';
this.bgColor = this.doc.bgColor||'';
var divs;
// create divs object - speeds up DOM browsers on Win32. Linux & Mac?
if (ua.ie||ua.dom) {
divs={};
var dv,all=(ua.ie||ua.opera)? document.all.tags('div') : document.getElementsByTagName('div');
var i=0,l=all.length; // very important!
while (i<l){
dv=all[i];
divs[dv.id]=dv;
i++;
}
}
var c,ch=this.children;
for(i=0;i<ch.length;i++){
c=ch[i];
if (c._inserted) c._createInserted(divs);
else if(c.isInline) c._createInline(divs);
else c._create();
};
this._updateAnchors();
if(ua.ie && this._textSelectable==false) this.doc.onselectstart = dynapi.functions.Deny;
if (this.captureMouseEvents) this.captureMouseEvents();
if (this.captureKeyEvents) this.captureKeyEvents();
this.invokeEvent('load');
};
p.destroyAllChildren = function() {
for (var i=0;i<this.children.length;i++) {
this.children[i]._destroy();
delete this.children[i];
}
this.children = [];
};
p._destroy = function() {
this.destroyAllChildren();
delete DynObject.all;
this.elm = null;
this.css = null;
this.frame = null;
};
p._handleResize = function() {
var w = this.w;
var h = this.h;
this.findDimensions();
if (this.w!=w || this.h!=h) {
if (dynapi.ua.ns4) {
if (this.onResizeNS4=="redraw") {
for (var i=0;i<this.children.length;i++) {
this.children[i].elm = null;
if (this.children[i]._created) {
this.children[i]._created = false;
this.children[i]._create();
}
}
this.invokeEvent('resize');
}
else if (this.onResizeNS4=="reload") {
this.doc.location.href = this.doc.location.href;
}
}
else {
this.invokeEvent('resize');
this._updateAnchors();
}
}
};
p.getCursor = function() {return (this._cursor=='pointer')? 'hand':this._cursor};
p.setCursor = function(c) {
if (!c) c = 'default';
else c=(c+'').toLowerCase();
if (!dynapi.ua.ie && c=='hand') c='pointer';
if (this._cursor!=c) {
this._cursor = c;
if (this.css) this.css.cursor = c;
}
};
p.setTextSelectable = function(b){
this._textSelectable = b;
if(!dynapi.ua.ie) this.captureMouseEvents();
else{
if (this.doc) this.doc.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny;
}
if (!b) this.setCursor('default');
};
p.showScrollBars = function(b){
if(b==this._showScroll) return;
else this._showScroll=b;
if(dynapi.ua.ie){
window.setTimeout('document.body.scroll="'+((b)? 'yes':'no')+'"',100);
}else if(dynapi.ua.ns||dynapi.ua.opera){
if(b){
this._docSize=[document.width,document.height];
document.width = this.frame.innerWidth;
document.height = this.frame.innerHeight;
}else if(this._docSize){
document.width = this._docSize[0];
document.height = this._docSize[1];
}
}
};
p.writeStyle = function(s){
// note: don't ever add \n to the end of the following strings or ns4 will choke!
if(!s) return;
var css ='<style><!-- ';
for(var i in s) css +='.'+i+' {'+s[i]+';} ';
css += ' --></style>';
document.write(css);
};
p._hBuffer = [];
p.addHTML = function(html){
var elm,ua = dynapi.ua;
var hbuf=this._hBuffer;
var cnt=(this._hblc)? this._hblc++:(this._hblc=1);
if (ua.ns4) {
html='<nobr>'+html+'<nobr>';
if(!this._created) hbuf[cnt]=html;
else {
elm=new Layer(0,this.frame);
elm.left=elm.top=0;
var doc=elm.document;
elm.clip.width=dynapi.document.w;
elm.clip.height=dynapi.document.h;
doc.open();doc.write(html);doc.close();
elm.visibility = 'inherit';
}
}
else {
var pelm=this.elm;
if(!this._created) hbuf[cnt]=html;
else {
if(ua.ie){
pelm.insertAdjacentHTML("beforeEnd",html);
elm = pelm.children[pelm.children.length-1];
}
else{
var r = pelm.ownerDocument.createRange();
r.setStartBefore(pelm);
var ptxt = r.createContextualFragment(html);
pelm.appendChild(ptxt);
elm = pelm.lastChild;
}
}
}
};
function main() {
if (dynapi.document==null) {
dynapi.document = new DynDocument(dynapi.frame);
if (dynapi.loaded) dynapi.document._create();
else dynapi.onLoad(function() {
dynapi.document._create();
});
}
};
if (!dynapi.loaded) main();

View File

@ -1,397 +0,0 @@
/*
DynAPI Distribution
DynLayer Base/Common Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynDocument
*/
var DynLayerBase = {}; // used by library
function DynLayer(html,x,y,w,h,color,image) {
this.DynElement = DynElement;
this.DynElement();
if (html && typeof(html)=='object'){ // typeof more stable than constructor when creating layers from another frame
var args=html; // dictionary input
html=args.html;
x = args.x;
y = args.y;
w = args.w;
h = args.h;
color = args.color;
image = args.image;
this.z = (args.zIndex||1);
this._saveAnchor = args.anchor;
this.visible = (args.visible==false)? false:true;
this._textSelectable = (args.textSelectable==false)?false:true;
if (args.id)
this.setID(args.id,true);
}
else {
this.visible = true;
this.z = 1;
this._saveAnchor = false;
this._textSelectable = true;
}
this.x = x||0;
this.y = y||0;
this.w = w;
this.h = h;
this.bgColor = color;
this.bgImage = image;
this.html = (html!=null)? html+'':null; // convert html to string
this.elm = null;
this.doc = null;
this.css = null;
};
var p = dynapi.setPrototype('DynLayer','DynElement');
p._cssBorder = '';
p._fixBw = 0;
p._fixBh = 0;
p._adjustSize=function(){
var aw=this._aSzW;
var ah=this._aSzH;
if(this._created && (aw||ah)) {
var i,c,w=0,h=0;
// get furthest child
for (i=0;i<this.children.length;i++){
c=this.children[i];
if(c && w<(c.x+c.w)) w=c.x+c.w;
if(c && h<(c.y+c.h)) h=c.y+c.h;
}
if(aw) {
i = this.getContentWidth();
if(w<i) w=i;
if(w!=this.w) this.setWidth(w); // set width first
}
if(ah) {
i = this.getContentHeight();
if(h<i) h=i;
if(h!=this.h) this.setHeight(h); // set height after width
}
}
};
p._destroy = function() {
this._destroyAllChildren();
this.removeAllEventListeners();
if (this.elm) this._remove();
this.setAnchor(null); // remove anchor
this.frame = null;
this.bgImage = null;
this.bgColor = null;
this.html = null;
this.x = null;
this.y = null;
this.w = null;
this.h = null;
this.z = null;
this.doc = null;
this.css = null;
this._dyndoc = null;
this.parent = null;
this._blkBoardElm = null;
DynObject.all[this.id] = null;
};
p._destroyAllChildren = function() {
var aSz = this._aSz;
this._aSz = false; // prevent children from adjusting parent's size when removed
for (var i=0;i<this.children.length;i++) {
this.children[i]._destroy();
delete this.children[i];
}
this.children.length=0;
this._aSz = aSz;
};
p._remove = function() { //! Overwritten by NS4
var p = this.parent;
if (p && this._alias) p[this._alias]=null;
if (p && this.elm) {
//this.elm.style.visibility = "hidden";
//this.elm.innerHTML = "";
//this.elm.outerHTML = "";
var pref=p.elm;
if(document.getElementById && document.childNodes){
if(this.elm.parentNode) pref = this.elm.parentNode; // used with relative layers
pref.removeChild(this.elm);
}
else if (pref && pref.children){
this.elm.outerHTML='';
}
this.elm = null;
if (this.releaseMouseEvents) this.releaseMouseEvents();
if (this.releaseKeyEvents) this.releaseKeyEvents();
}
/*
this.frame = null;
this.bgImage = null;
this.bgColor = null;
this.html = null;
this.z = null;
this.w = null;
this.h = null;
this.elm = this.css = this.doc = null;
*/
};
p._createInserted = function(divs){
DynLayer._assignElement(this,null,divs); //! NS4 will ignore divs
DynElement._flagCreate(this);
};
p.getOuterHTML=function() { //! Overwritten by NS4
// get box fix values
var fixBw = (this._fixBw)? this._fixBw:0;
var fixBh = (this._fixBh)? this._fixBh:0;
if (fixBw||fixBh) this._fixBoxModel = true;
if (this._noStyle) return '<div '+this._cssClass+' id="'+this.id+'">'+this.getInnerHTML()+'</div>';
else {
var s,clip='',bgimage=' background-image:none;';
if(this.bgImage!=null) bgimage=' background-image:url('+this.bgImage+');';
if (this.clip) clip=' clip:rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px);';
else if (this.w!=null && this.h!=null) clip=' clip:rect(0px '+(this.w+fixBw)+'px '+(this.h+fixBh)+'px 0px);';
// modify box fix values
if (!dynapi.ua.ie && !dynapi.ua.opera) fixBw = 0;
if (!dynapi.ua.ie) fixBh = 0;
return [
'\n<div '+this._cssClass+' id="'+this.id+'" style="',
' left:',(this.x!=null? this.x : 0),'px;',
' top:',(this.y!=null? this.y : 0),'px;',
((this.w!=null)? ' width:'+(this.w+fixBw)+'px;':''),
((this.h!=null)? ' height:'+(this.h+fixBh)+'px;':''),
((this.z)? ' z-index:'+this.z+';':''),
((this._cursor!=null)? ' cursor:'+this._cursor+';':'cursor:auto;'),
((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''),
((this.visible==false)? ' visibility:hidden;':' visibility:inherit;'),
bgimage,
clip,
this._cssBorder,
this._cssOverflow,
this._cssPosition,
';">',
this.getInnerHTML(),
'</div>'
].join('');
}
};
p.getInnerHTML=function() { //! Overwritten by NS4
var s = '';
var i,ch=this.children;
if (this.html!=null) s+=this.html;
if (this._blkBoardElm) s=('<div id="'+this.id+'_blkboard">'+s+'</div>');
if (ch.length<50) for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML();
else if(ch.length){
var ar=['']; // speed improvement for layers with nested children
for (i=0;i<ch.length;i++) ar[i]=ch[i].getOuterHTML();
s=s+ar.join('');
}
return s;
};
p.getPageX = function() {return (this.isChild)? this.parent.getPageX()+(this.x||0) : this.x||0}; //! Overwritten by NS4
p.getPageY = function() {return (this.isChild)? this.parent.getPageY()+(this.y||0) : this.y||0}; //! Overwritten by NS4
p.setAutoSize = function(w,h){
this._aSzW = w; // automatically adjust the size of layer to the size of its content
this._aSzH = h;
this._aSz = w||h;
if(this._aSz) this._adjustSize();
};
p._cssClass = '';
p.setClass = function(c,noInlineStyle){
this._class=c;
if(this.elm) this.elm.className=c;
else {
this._cssClass=(c)? 'class="'+c+'"':'';
this._noStyle=noInlineStyle;
}
};
p.setVisible = function(b) { //! Overwritten by NS4
//if (b!=this.visible) {
this.visible = b;
if (this.css) this.css.visibility = b? "inherit" : "hidden";
//}
};
p.setSize = function(w,h) { //! Overwritten by NS4
if (this._useMinSize||this._useMaxSize){
if (this._minW && w<this._minW) w=this._minW;
if (this._minH && h<this._minH) h=this._minH;
if (this._maxW && w>this._maxW) w=this._maxW;
if (this._maxH && h>this._maxH) h=this._maxH;
}
var cw = (w!=null && w!=this.w);
var ch = (h!=null && h!=this.h);
if (cw) this.w = w<0? 0 : w;
if (ch) this.h = h<0? 0 : h;
if (cw||ch) {
if (this._hasAnchor) this.updateAnchor(); // update this anchor
if (this._hasChildAnchors) this._updateAnchors(); // update child anchors
if (this.css) {
if (cw) this.css.width = this.w||0;
if (ch) this.css.height = this.h||0;
if (cw || ch) {
if(this._needBoxFix) BorderManager.FixBoxModel(this,true);
else this.css.clip = 'rect(0px '+(this.w||0)+'px '+(this.h||0)+'px 0px)';
// adjust parent size after being sized
if(this.parent._aSz) this.parent._adjustSize();
}
if (this.updateLayout) this.updateLayout(); // what's this?
}
}
if(this._hasResizeEvents) this.invokeEvent('resize');
return (cw||ch);
};
p.setMaximumSize = function(w,h){
this._maxW=w; this._maxH=h;
this._useMaxSize=(w!=h!=null);
w=(this.w>w)?w:this.w;
h=(this.h>h)? h:this.h;
this.setSize(this.w,this.h);
};
p.setMinimumSize = function(w,h){
this._minW=w; this._minH=h;
this._useMinSize=(w!=h!=null);
this.setSize(this.w,this.h);
};
p._position = 'absolute';
p._cssPosition = ' position:absolute';
p.setPosition = function(p){
if(p!='static' && p!='relative' && p!='fixed' && p!='absolute') p='absolute';
this._position=p;
if (this.css) this.css.position=p;
else this._cssPosition = ' position:'+p;
};
p._overflow='hidden';
p._cssOverflow =' overflow:hidden;';
p.getOverflow = function(){return this._overflow};
p.setOverflow = function(s){
// if(!s) s='default';
this._overflow=s;
if(this.css) this.css.overflow=s;
else this._cssOverflow=' overflow:'+s+';';
};
p.getAnchor = function(){
if(!this.parent) return this._saveAnchors;
else if (this.parent._childAnchors) {
return this.parent._childAnchors[this.id];
}
};
p.setAnchor = function(anchor) {
if (anchor == null) {
delete this._saveAnchor;
if (this.parent && this.parent._childAnchors && this.parent._childAnchors[this.id]) delete this.parent._childAnchors[this.id];
this._hasAnchor = false;
}
else if (this.parent) {
if (!this.parent._childAnchors) this.parent._childAnchors = {};
var a = this.parent._childAnchors;
a[this.id] = anchor;
this.parent._updateAnchor(this.id);
this._hasAnchor = this.parent._hasChildAnchors = true;
}
else this._saveAnchor = anchor;
};
p.setX=function(x) {this.setLocation(x,null)};
p.setY=function(y) {this.setLocation(null,y)};
p.getX=function() {return this.x||0};
p.getY=function() {return this.y||0};
p.setPageX = function(x) {this.setPageLocation(x,null)};
p.setPageY = function(y) {this.setPageLocation(null,y)};
p.getVisible=function() {return this.visible};
p.getZIndex=function() {return this.z};
p.setZIndex=function(z) {
if (typeof(z)=="object") {
if (z.above) this.z = z.above.z + 1;
else if (z.below) this.z = z.below.z - 1;
else if (z.topmost && !this.parent) this.z = (DynLayer._z)? (DynLayer._z++):(DynLayer._z=1000);
else if (z.topmost) {
var topZ=10000,ch=this.parent.children;
for(var i=0;i<ch.length;i++) if (ch[i].z>topZ) topZ=ch[i].z;
this.parent._topZ = topZ+2;
this.z = this.parent._topZ;
}
}
else this.z = z;
if (this.css) this.css.zIndex = this.z;
};
p.getHTML = function() {return this.html};
p.setWidth=function(w) {this.setSize(w,null)};
p.setHeight=function(h) {this.setSize(null,h)};
p.getWidth=function() {return this.w||0};
p.getHeight=function() {return this.h||0};
p.getBgImage=function() {return this.bgImage};
p.getBgColor=function() {return this.bgColor};
p.setBgColor=function(c) { //! Overwritten by NS4
if (c==null) c = 'transparent';
this.bgColor = c;
if (this.css) this.css.backgroundColor = c;
};
p.setBgImage=function(path) { //! Overwritten by NS4
this.bgImage=path;
if (this.css) this.css.backgroundImage='url('+path+')';
};
p.setClip=function(clip) { //! Overwritten by NS4
var cc=this.getClip();
for (var i=0;i<clip.length;i++) if (clip[i]==null) clip[i]=cc[i];
this.clip=clip;
if (this.css==null) return;
var c=this.css.clip;
this.css.clip="rect("+clip[0]+"px "+clip[1]+"px "+clip[2]+"px "+clip[3]+"px)";
};
p.getClip=function() { //! Overwritten by NS4
if (this.css==null || !this.css.clip) return [0,0,0,0];
var c = this.css.clip;
if (c) {
if (c.indexOf("rect(")>-1) {
c=c.split("rect(")[1].split(")")[0];
c=c.replace(/(\D+)/g,',').split(",");
for (var i=0;i<c.length;i++) c[i]=parseInt(c[i]);
return [c[0],c[1],c[2],c[3]];
}
else return [0,this.w,this.h,0];
}
};
p.slideTo = function(endx,endy,inc,speed) {
if (!this._slideActive) {
var x = this.x||0;
var y = this.y||0;
if (endx==null) endx = x;
if (endy==null) endy = y;
var distx = endx-x;
var disty = endy-y;
if (x==endx && y==endy) return;
var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/(inc||10)-1;
var dx = distx/num;
var dy = disty/num;
this._slideActive = true;
this._slide(dx,dy,endx,endy,num,this.x,this.y,1,(speed||20));
}
};
p.slideStop = function() {
this._slideActive = false;
//this.invokeEvent('pathcancel');
};
p._slide = function(dx,dy,endx,endy,num,x,y,i,speed) {
if (!this._slideActive) this.slideStop();
else if (i++ < num) {
this.invokeEvent('pathrun');
if (this._slideActive) {
x += dx;
y += dy;
this.setLocation(Math.round(x),Math.round(y));
setTimeout(this+'._slide('+dx+','+dy+','+endx+','+endy+','+num+','+x+','+y+','+i+','+speed+')',speed);
}
//else this.slideStop();
}
else {
this._slideActive = false;
this.invokeEvent('pathrun');
this.setLocation(endx,endy);
this.invokeEvent('pathfinish');
}
};

View File

@ -1,151 +0,0 @@
/*
DynAPI Distribution
DynLayer DOM Specific Functions
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynLayerBase
*/
p = DynLayer.prototype;
p._create = function() {
if (this.parent && !this.elm) {
DynElement._flagPreCreate(this);
var elm, parentElement;
parentElement = this.parent.elm;
// this method seems faster for most dom browsers
var r = parentElement.ownerDocument.createRange();
r.setStartBefore(parentElement);
var ptxt = r.createContextualFragment(this.getOuterHTML());
parentElement.appendChild(ptxt);
elm = parentElement.lastChild;
DynLayer._assignElement(this,elm);
DynElement._flagCreate(this);
}
};
DynLayer._assignElement = function(dlyr,elm,divs) {
if (!elm ) {
elm = (divs)? divs[dlyr.id] : dlyr.parent.doc.getElementById(dlyr.id);
if (!elm){
if(dlyr.isInline) dlyr._create(); // force create() for missing inline layer
return;
}
}
dlyr.elm = elm;
dlyr.css = elm.style;
dlyr.doc = dlyr.parent.doc;
dlyr.elm._dynobj = dlyr;
dlyr._dyndoc = dlyr.parent._dyndoc;
if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.doc.getElementById(dlyr.id+'_blkboard');
if (dlyr.z) dlyr.css.zIndex = dlyr.z;
// COMMENTED OUT TO PERMIT CSS PRIORITY
// by Raphael Pereira <raphaelpereira@users.sourceforge.net>
if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
//var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
//var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
dlyr.setSize(cw,ch);
}
var i,ch=dlyr.children;
for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs);
// Box Fix - for Border Manager
if (dlyr._needBoxFix) BorderManager.FixBoxModel(dlyr);
if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
};
p.enableBlackboard = function(){
if (!this._created) this._blkBoardElm=true;
else if(!this._blkBoardElm){
var r,ptxt;
var h='',elm = this.elm;
if(this.html!=null) h=this.html;
r = elm.ownerDocument.createRange();
r.setStartBefore(elm);
ptxt = r.createContextualFragment('<div id="'+this.id+'_blkboard">'+h+'</div>');
elm.appendChild(ptxt);
this._blkBoardElm = elm.lastChild;
}
};
p.setLocation=function(x,y) {
var cx = (x!=null && x!=this.x);
var cy = (y!=null && y!=this.y);
if (cx) this.x = x||0;
if (cy) this.y = y||0;
if (this.css!=null) {
if (cx) this.css.left = this.x+"px";
if (cy) this.css.top = this.y+"px";
// adjust parent size after being moved
if((cx||cy) && this.parent._aSz) this.parent._adjustSize();
}
if(this._hasLocationEvents) this.invokeEvent('locationchange');
return (cx||cy);
};
p.setPageLocation = function(x,y) {
if (this.isChild) {
if (x!=null) x = x - this.parent.getPageX();
if (y!=null) y = y - this.parent.getPageY();
}
return this.setLocation(x,y);
};
p.setHTML = function(html) {
if (html!=this.html) {
this.html = html;
if (this.css) {
var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm;
elm.innerHTML = html;
var sTmp=(this.w==null)?'<NOBR>'+this.html+'</NOBR>':this.html;
while (elm.hasChildNodes()) elm.removeChild(elm.firstChild);
var r=elm.ownerDocument.createRange();
r.selectNodeContents(elm);
r.collapse(true);
var df=r.createContextualFragment(sTmp);
elm.appendChild(df);
this._adjustSize();
}
}
if(this._hasContentEvents) this.invokeEvent('contentchange');
};
p.setTextSelectable=function(b) {
this._textSelectable = b;
if(!this._hasMouseEvents) this.captureMouseEvents();
if (!b) this.setCursor('default');
};
p.getCursor = function() {return (this._cursor=='pointer')? 'hand':this._cursor};
p.setCursor = function(c) {
if (!c) c = 'default';
else c=(c+'').toLowerCase();
if (c=='hand') c='pointer';
if (this._cursor!=c) {
this._cursor = c;
if (this.css) this.css.cursor = c;
}
};
p.getContentWidth=function() {
if (this.elm==null) return 0;
else {
var p = this.parent;
var tw = this.elm.style.width;
this.css.width = "auto";
var w = this.elm.offsetWidth;
this.css.width = tw;
return w;
};
};
p.getContentHeight=function() {
if (this.elm==null) return 0;
else {
var th = this.css.height;
this.elm.style.height = "auto";
var h = this.elm.offsetHeight;
this.css.height = th;
return h;
}
};

View File

@ -1,193 +0,0 @@
/*
DynAPI Distribution
DynLayer IE Specific Functions
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynLayerBase
*/
p = DynLayer.prototype;
p._create = function() {
if (this.parent && !this.elm) {
DynElement._flagPreCreate(this);
var elm, parentElement;
parentElement = this.parent.elm;
// if(dynapi.ua.v<5){
parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML());
elm = parentElement.children[parentElement.children.length-1];
/* }
else {
// this method is more efficient for ie5+. any comment?
//elm=document.createElement('DIV');
elm=this._getDOMObject();
elm.id=this.id;
if(this._className) elm.className=this._class;
if(!this._noStyle) {
var css = elm.style;
css.position=(this._position||'absolute');
if (this.x) css.pixelLeft = this.x;
if (this.y) css.pixelTop = this.y;
if (this.w) css.width = this.w;
if (this.h) css.height = this.h;
if (this.bgColor) css.backgroundColor = this.bgColor;
if (this.z) css.zIndex = this.z;
if (this._cursor) css.cursor = this._cursor;
if (this._overflow) css.overflow = this._overflow;
if (this.bgImage!=null) css.backgroundImage='url('+this.bgImage+')';
//if (this.bgImage==null && this.html==null) css.backgroundImage='';
if (this.clip) css.clip='rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px)';
else if (this.w!=null && this.h!=null) css.clip='rect(0px '+this.w+'px '+this.h+'px 0px)';
css.visibility=(this.visible==false)? 'hidden':'inherit';
// border - set by BorderManager
if(this._cssBorTop){
css.borderTop = this._cssBorTop||'';
css.borderRight = this._cssBorRight||'';
css.borderBottom = this._cssBorBottom||'';
css.borderLeft = this._cssBorLeft||'';
}
}
try {
elm.innerHTML = this.getInnerHTML();
}
catch (e)
{
}
//alert(elm.outerHTML);
parentElement.appendChild(elm);
}
*/ DynLayer._assignElement(this,elm);
DynElement._flagCreate(this);
}
};
p._getDOMObject = function()
{
return document.createElement('DIV');
}
DynLayer._assignElement = function(dlyr,elm,divs) {
if (!elm ) {
elm = (divs)? divs[dlyr.id] : dlyr.parent.elm.all[dlyr.id];
if (!elm){
if(dlyr.isInline) dlyr._create(); // force create() for missing inline layer
return;
}
}
dlyr.elm = elm;
dlyr.css = elm.style;
dlyr.doc = dlyr.parent.doc;
dlyr.elm._dynobj = dlyr;
dlyr._dyndoc = dlyr.parent._dyndoc;
if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.elm.all[dlyr.id+'_blkboard'];
// COMMENTED OUT TO PERMIT CSS PRIORITY
// by Raphael Pereira <raphael@think-e.com.br>
if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
dlyr.setSize(cw,ch);
}
var i,ch=dlyr.children;
for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs);
if (dlyr._textSelectable==false) elm.onselectstart = dynapi.functions.Deny;
// prevent dragging of images
//if (elm.all.tags("img").length) elm.ondragstart = dynapi.functions.False;
// Box Fix - for Border Manager
if (dlyr._needBoxFix) BorderManager.FixBoxModel(dlyr);
if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
};
p.enableBlackboard = function(){
if (!this._created) this._blkBoardElm=true;
else if(!this._blkBoardElm){
var h='',elm = this.elm;
if(this.html!=null) h=this.html;
elm.insertAdjacentHTML("beforeEnd",'<div id="'+this.id+'_blkboard">'+h+'</div>');
this._blkBoardElm = elm.children[elm.children.length-1];
}
};
p.setLocation=function(x,y) {
var cx = (x!=null && x!=this.x);
var cy = (y!=null && y!=this.y);
if (cx) this.x = x||0;
if (cy) this.y = y||0;
if (this.css!=null) {
if (cx) this.css.pixelLeft = this.x;
if (cy) this.css.pixelTop = this.y;
// adjust parent size after being moved
if((cx||cy) && this.parent._aSz) this.parent._adjustSize();
}
if(this._hasLocationEvents) this.invokeEvent('locationchange');
return (cx||cy);
};
p.setPageLocation = function(x,y) {
if (this.isChild) {
if (dynapi.ua.v>=5) {
if (cx) this.css.pixelLeft = this.x;
if (cy) this.css.pixelTop = this.y;
}
else {
if (cx) this.css.left = this.x+"px";
if (cy) this.css.top = this.y+"px";
}
}
return this.setLocation(x,y);
};
p.setHTML = function(html) {
if (html!=this.html) {
this.html = html;
if (this.css) {
var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm;
elm.innerHTML = html;
this._adjustSize();
}
}
if(this._hasContentEvents) this.invokeEvent('contentchange');
};
p.setTextSelectable=function(b) {
this._textSelectable = b;
if (this.elm) this.elm.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny;
if (!b) this.setCursor('default');
// && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents();
};
p.getCursor = function() {return this._cursor};
p.setCursor = function(c) {
if (!c) c = 'default';
else c=(c+'').toLowerCase();
if (this._cursor!=c) {
this._cursor = c;
if (this.css) this.css.cursor = c;
}
};
p.getContentWidth=function() {
if (this.elm==null) return 0;
else {
var w,tw = this.css.width;
this.css.width='auto'; // force ie to get width
if (dynapi.ua.platform=="mac") w = this.elm.offsetWidth;
else w = parseInt(this.elm.scrollWidth);
this.css.width=tw;
return w;
};
};
p.getContentHeight=function() {
if (this.elm==null) return 0;
else {
if (dynapi.ua.platform=="mac") return this.elm.offsetHeight;
return parseInt(this.elm.scrollHeight);
}
};
p.setOverflow = function(s)
{
if(!s) s='';
this._overflow=s;
if(this.css) this.css.overflow=s;
else this._cssOverflow=' overflow:'+s+';';
}

View File

@ -1,310 +0,0 @@
/*
DynAPI Distribution
DynLayer NS4 Specific Functions
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynLayerBase
*/
p = DynLayer.prototype;
p._ns4IPad = '<img src="'+dynapi.library.path+'gui/images/pixel.gif" width="0" height="0">'; // used with blackboard
p._remove = function() {
if (this.elm) {
var p = this.parent;
if (p && this._alias) p[this._alias]=null;
if (!p.doc.recycled) p.doc.recycled=[];
p.doc.recycled[p.doc.recycled.length]=this.elm;
this.elm.visibility="hide";
this.elm = null;
if (this.releaseMouseEvents) this.releaseMouseEvents();
if (this.releaseKeyEvents) this.releaseKeyEvents();
}
/*this.frame = null;
this.bgImage = null;
this.bgColor = null;
this.html = null;
this.z = null;
this.w = null;
this.h = null;
this.elm = null;
this.doc = null;
this.css = null;*/
};
p._create = function() {
if (this.parent && !this.elm) {
DynElement._flagPreCreate(this);
var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame;
var elm = new Layer(this.w||0, parentElement);
if(this._className) elm.className=this._className; // does this work in ns4?
if(!this._noStyle) {
if (this.w) elm.clip.width = this.w+this._fixBw;
if (this.h) elm.clip.height = this.h+this._fixBh;
if (this.x && this.y) elm.moveTo(this.x,this.y);
else if (this.x) elm.left = this.x;
else if (this.y) elm.top = this.y;
if (this.bgColor!=null) elm.document.bgColor = this.bgColor;
if (this.clip) {
var c = elm.clip, cl = this.clip;
c.top=cl[0], c.right=cl[1], c.bottom=cl[2], c.left=cl[3];
}
if (this.z) elm.zIndex = this.z;
if (this.visible) elm.visibility = 'inherit';
}
if (this.children.length || (this.html!=null && this.html!='')) {
elm.document.write(this.getInnerHTML());
elm.document.close();
}
DynLayer._assignElement(this,elm);
DynElement._flagCreate(this);
}
};
DynLayer._getLayerById = function(id,pElm){
var i,lyrs,elm;
pElm = (pElm)? pElm:document;
lyrs = pElm.layers;
for (i=0;i<lyrs.length;i++){
elm=lyrs[i];
if (elm.id==id) return elm;
else if (elm.layers.length){
elm = this._getLayerById(id,elm);
if (elm) return elm;
}
}
};
DynLayer._assignElement = function(dlyr,elm) {
if (!elm) {
elm = dlyr.parent.doc.layers[dlyr.id];
if (!elm) elm=DynLayer._getLayerById(dlyr.id,dlyr.parent.elm);
if (!elm){
if(dlyr.isInline) dlyr._create(); // force create() for missing inline layer
return;
}
}
dlyr.elm = elm;
dlyr.css = elm;
dlyr.doc = elm.document;
if(dlyr._blkBoardElm) {
dlyr._blkBoardElm = elm.document.layers[dlyr.id+'blkboard'];
dlyr.doc = dlyr._blkBoardElm.document; // useful for <forms>, images, links, etc
}
dlyr.elm._dynobj = dlyr.doc._dynobj = dlyr;
dlyr._dyndoc = dlyr.parent._dyndoc;
// COMMENTED OUT TO PERMIT CSS PRIORITY
// by Raphael Pereira <raphael@think-e.com.br>
if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
//var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
//var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
dlyr.setSize(cw,ch);
}
if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage);
var i,ch=dlyr.children;
for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null);
if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
else {
// assign ._dynobj to images and links
for (var i=0;i<dlyr.doc.images.length;i++) dlyr.doc.images[i]._dynobj=dlyr; // was _dynobji
for (var i=0;i<dlyr.doc.links.length;i++) dlyr.doc.links[i]._dynobj=dlyr;
}
};
p.getOuterHTML = function() {
// get box fix values
var fixBw = (this._fixBw)? this._fixBw:0;
var fixBh = (this._fixBh)? this._fixBh:0;
var tag='layer',clip='';
if (fixBw||fixBh) this._fixBoxModel = true;
if(this._position=='relative') tag='ilayer';
if(this._noStyle) return '\n<'+tag+' '+this._cssClass+' id="'+this.id+'">'+this.getInnerHTML()+'</'+tag+'>';
else {
if (this.clip) clip=' clip="'+this.clip[3]+','+this.clip[0]+','+this.clip[1]+','+this.clip[2]+'"';
else clip=' clip="0,0,'+((this.w>=0)? this.w+fixBw:0)+','+((this.h>=0)? this.h+fixBh:0)+'"';
return [
'\n<'+tag+' ',this._cssClass,' id="'+this.id+'"',
' left=',(this.x!=null? this.x : 0),
' top=',(this.y!=null? this.y : 0),
((this.visible)? ' visibility="inherit"':' visibility="hide"'),
((this.w!=null)? ' width='+(this.w+fixBw):''),
((this.h!=null)? ' height='+(this.h+fixBw):''),
((this.z)? ' zindex='+this.z:''),
((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':''),
((this.bgImage!=null)? ' background="'+this.bgImage+'"':''),
clip,'>',this.getInnerHTML(),'</'+tag+'>'
].join('');
}
};
p.getInnerHTML = function() {
var i,s = '',ch=this.children;
if (this.html!=null) {
if (this.w==null) s += '<nobr>'+this.html+'</nobr>';
else s+=this.html;
}
if (this._blkBoardElm) s='<layer id="'+this.id+'blkboard">'+this._ns4IPad+s+'</layer>';
if(ch.length<50) for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML();
else if(ch.length){
var ar=['']; // speed improvement for layers with nested children
for (i=0;i<ch.length;i++) ar[i]=ch[i].getOuterHTML();
s=s+ar.join('');
}
return s;
};
p.enableBlackboard = function(){
if (!this._created) this._blkBoardElm=true;
else if(!this._blkBoardElm){
var c,i,h='',elm = this.elm;
if(this.html!=null) h=this.html;
var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame;
var belm = this._blkBoardElm = new Layer(0, elm);
this.doc = belm.document;
this.doc.write(h); this.doc.close();
belm.visibility = 'inherit';
for (i=0;i<this.children.length;i++){
c=this.children[i];
c.css.zIndex=c.css.zIndex; // reset zindex
}
}
};
p.setLocation = function(x,y) {
var cx = (x!=null && x!=this.x);
var cy = (y!=null && y!=this.y);
if (cx) this.x = x||0;
if (cy) this.y = y||0;
if (this.css!=null) {
if (cx && cy) this.elm.moveTo(this.x, this.y);
else if (cx) this.css.left = this.x;
else if (cy) this.css.top = this.y;
// adjust parent size after being moved
if((cx||cy) && this.parent._aSz) this.parent._adjustSize();
}
if(this._hasLocationEvents) this.invokeEvent('locationchange');
return (cx||cy);
};
p.setPageLocation = function(x,y) {
if (this.css) {
if (x!=null) {
this.css.pageX = x;
this.x = this.css.left;
}
if (y!=null) {
this.css.pageY = y;
this.y = this.css.top;
}
return true;
}
else {
if (this.isChild) {
if (x!=null) x = x - this.parent.getPageX();
if (y!=null) y = y - this.parent.getPageY();
}
return this.setLocation(x,y);
}
};
p.getPageX = function() {return this.css? this.css.pageX : null};
p.getPageY = function() {return this.css? this.css.pageY : null};
p.setVisible = function(b) {
if (b!=this.visible) {
this.visible = b;
if (this.css) this.css.visibility = b? "inherit" : "hide";
}
};
p.setSize = function(w,h) {
if (this._useMinSize||this._useMaxSize){
if (this._minW && w<this._minW) w=this._minW;
if (this._minH && h<this._minH) h=this._minH;
if (this._maxW && w>this._maxW) w=this._maxW;
if (this._maxH && h>this._maxH) h=this._maxH;
}
var cw = (w!=null && w!=this.w);
var ch = (h!=null && h!=this.h);
if (cw) this.w = w<0? 0 : w;
if (ch) this.h = h<0? 0 : h;
if (cw||ch) {
if (this._hasAnchor) this.updateAnchor(); // update this anchor
if (this._hasChildAnchors) this._updateAnchors(); // update child anchors
if (this.css) {
if (cw) this.css.clip.width = (this.w || 0)+this._fixBw;
if (ch) this.css.clip.height = (this.h || 0)+this._fixBh;
// adjust parent size after being sized
if((cw||ch) && this.parent._aSz) this.parent._adjustSize();
if (this.updateLayout) this.updateLayout();
}
}
if(this._hasResizeEvents) this.invokeEvent('resize');
return (cw||ch);
};
p.setHTML=function(html) {
var ch = (html!=null && html!=this.html);
if (ch) {
this.html = html;
if (this.css) {
var i, doc = this.doc;
var html=(!this._blkBoardElm)? this.html:this._ns4IPad+this.html; // don't ask why! See HTMLContainer
doc.open(); doc.write(html); doc.close();
for (i=0;i<doc.images.length;i++) doc.images[i]._dynobj = this;
for (i=0;i<doc.links.length;i++) doc.links[i]._dynobj = this;
this._adjustSize();
}
}
if(this._hasContentEvents) this.invokeEvent('contentchange');
};
p.setTextSelectable=function(b) {
this._textSelectable = b;
this.addEventListener({
onmousemove : function(e) {
e.preventDefault();
}
});
// && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents();
};
p.getCursor = function() {return this._cursor};
p.setCursor = function(c) {
if (!c) c = 'default';
if (this._cursor!=c) this._cursor = c;
// Note: not supported in ns4
};
p.setBgColor=function(c) {
this.bgColor = c;
if (this.css) this.elm.document.bgColor = c;
};
p.setBgImage=function(path) {
this.bgImage=path||'none';
if (this.css) {
//if (!path) this.setBgColor(this.getBgColor());
setTimeout(this+'.elm.background.src="'+this.bgImage+'"',1);
}
};
p.getContentWidth=function() {
if (this.elm==null) return 0;
else {
return this.doc.width;
};
};
p.getContentHeight=function() {
if (this.elm==null) return 0;
else {
return this.doc.height;
}
};
p.setClip=function(clip) {
var cc=this.getClip();
for (var i=0;i<clip.length;i++) if (clip[i]==null) clip[i]=cc[i];
this.clip=clip;
if (this.css==null) return;
var c=this.css.clip;
c.top=clip[0], c.right=clip[1], c.bottom=clip[2], c.left=clip[3];
};
p.getClip=function() {
if (this.css==null || !this.css.clip) return [0,0,0,0];
var c = this.css.clip;
if (c) {
return [c.top,c.right,c.bottom,c.left];
}
};

View File

@ -1,147 +0,0 @@
/*
DynAPI Distribution
DynLayer Opera Specific Functions
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynLayerBase
*/
// Warning: Avoid using document.all collection as it has been reported
// that on some platforms when opera is set to an identity other than IE
// the all[] collection is not available
p = DynLayer.prototype;
p._create = function() {
if (this.parent && !this.elm) {
DynElement._flagPreCreate(this);
var elm, parentElement;
parentElement = this.parent.elm;
// this method is more efficient for opera7+
parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML());
elm = parentElement.children[parentElement.children.length-1];
DynLayer._assignElement(this,elm);
DynElement._flagCreate(this);
}
};
DynLayer._assignElement = function(dlyr,elm,divs) {
if (!elm ) {
elm = (divs)? divs[dlyr.id] : dlyr.parent.doc.getElementById(dlyr.id);
if (!elm){
if(dlyr.isInline) dlyr._create(); // force create() for missing inline layer
return;
}
}
dlyr.elm = elm;
dlyr.css = elm.style;
dlyr.doc = dlyr.parent.doc;
dlyr.elm._dynobj = dlyr;
dlyr._dyndoc = dlyr.parent._dyndoc;
if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.doc.getElementById(dlyr.id+'_blkboard');
// COMMENTED OUT TO PERMIT CSS PRIORITY
// by Raphael Pereira <raphael@think-e.com.br>
if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
//var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
//var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
dlyr.setSize(cw,ch);
}
var i,ch=dlyr.children;
for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs);
if (this._textSelectable==false) elm.onselectstart = dynapi.functions.Disallow;
// Box Fix - for Border Manager
if (dlyr._needBoxFix) BorderManager.FixBoxModel(dlyr);
if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
};
p.enableBlackboard = function(){
if (!this._created) this._blkBoardElm=true;
else if(!this._blkBoardElm){
var h='',elm = this.elm;
if(this.html!=null) h=this.html;
elm.insertAdjacentHTML("beforeEnd",'<div id="'+this.id+'_blkboard">'+h+'</div>');
this._blkBoardElm = elm.children[elm.children.length-1];
}
};
p.setLocation=function(x,y) {
var cx = (x!=null && x!=this.x);
var cy = (y!=null && y!=this.y);
if (cx) this.x = x||0;
if (cy) this.y = y||0;
if (this.css!=null) {
if (cx) this.css.pixelLeft = this.x;
if (cy) this.css.pixelTop = this.y;
// adjust parent size after being sized
if((cx||cy) && this.parent._aSz) this.parent._adjustSize();
}
if(this._hasLocationEvents) this.invokeEvent('locationchange');
return (cx||cy);
};
p.setPageLocation = function(x,y) {
if (this.isChild) {
if (dynapi.ua.v>=5) {
if (cx) this.css.pixelLeft = this.x;
if (cy) this.css.pixelTop = this.y;
}
else {
if (cx) this.css.left = this.x+"px";
if (cy) this.css.top = this.y+"px";
}
}
return this.setLocation(x,y);
};
p.setHTML = function(html) {
if (html!=this.html) {
this.html = html;
if (this.css) {
var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm;
elm.innerHTML = html;
this._adjustSize();
}
}
if(this._hasContentEvents) this.invokeEvent('contentchange');
};
p.setTextSelectable=function(b) {
this._textSelectable = b;
if (this.elm) this.elm.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny;
if (!b) this.setCursor('default');
// && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents();
};
p.getCursor = function() {return this._cursor};
p.setCursor = function(c) {
if (!c) c = 'default';
else c=(c+'').toLowerCase();
if (this._cursor!=c) {
this._cursor = c;
if (this.css) this.css.cursor = c;
}
};
p.getContentWidth=function() {
if (this.elm==null) return 0;
else {
var tw=this.css.width;
var w,to = this.css.overflow;
this.css.width='auto';
this.css.overflow='auto';
w = parseInt(this.elm.scrollWidth);
this.css.width=tw;
this.css.overflow=to;
return w;
};
};
p.getContentHeight=function() {
if (this.elm==null) return 0;
else {
if (dynapi.ua.platform=="mac") return this.elm.offsetHeight;
return parseInt(this.elm.scrollHeight);
}
};

View File

@ -1,369 +0,0 @@
/*
DynAPI Distribution
DynEvent, EventObject, DynElement Classes
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
function DynEvent(type,src) {
this.type = type;
this.src = src;
this.origin = src;
this.propagate = true;
this.bubble = false;
this.bubbleChild = null;
this.defaultValue = true;
};
var p = DynEvent.prototype;
p.getType = function() {return this.type};
p.getSource = function() {return this.src};
p.getOrigin=function() {return this.origin};
p.stopPropagation = function() {this.propagate = false};
p.preventBubble = function() {this.bubble = false};
p.preventDefault = function() {this.defaultValue = false};
p.getBubbleChild = function() {return this.bubbleChild};
function EventObject() {
this.DynObject = DynObject;
this.DynObject();
this._listeners = [];
};
EventObject._SubClass={};
p = dynapi.setPrototype('EventObject','DynObject');
p.addEventListener = function(el) {
if (el) {
for (var i=0;i<this._listeners.length;i++) if (this._listeners[i]==el) return;
this._listeners[this._listeners.length] = el;
// Use onCreate() and onPrecreate() function for create events
this._hasContentEvents=(el['oncontentchange'])? true:this._hasContentEvents;
this._hasLocationEvents=(el['onlocationchange'])? true:this._hasLocationEvents;
this._hasResizeEvents=(el['onresize'])? true:this._hasResizeEvents;
this._hasDragEvents=(el['ondragstart']||el['ondragmove']||
el['ondragend']||el['ondragdrop']||el['ondrop']||
el['ondragover']||el['ondragout'])? true:this._hasDragEvents;
if (this.captureMouseEvents) {
this._hasMouseEvents = this._hasMouseEvents||(el.onmousedown || el.onmouseup || el.onmouseover || el.onmouseout || el.onclick || el.ondblclick);
if (this._created && !this._hasMouseEvents) this.captureMouseEvents();
}
if (this.captureKeyEvents) {
this._hasKeyEvents = this._hasKeyEvents || (el.onkeyup || el.onkeydown || el.onkeypress);
if (this._created && !this._hasKeyEvents && (el.onkeydown || el.onkeyup || el.onkeypress)) this.captureKeyEvents();
}
}
};
p.removeEventListener = function(el) {
if (el) {
DynAPI.functions.removeFromArray(this._listeners, el, false);
if (!this._listeners.length && this.releaseMouseEvents && this.getClassName()!='DynDocument') this.releaseMouseEvents();
if (!this._listeners.length && this.releaseKeyEvents && this.getClassName()!='DynDocument') this.releaseKeyEvents();
}
};
p.removeAllEventListeners = function() {
delete this._listeners;
this._listeners = [];
};
p.invokeEvent = function(type,e,args) {
if (!e) e = new DynEvent(type,this);
e.src = this;
e.type = type;
// Check for subclassing
var clsFn=EventObject._SubClass[this+'_'+type];
if(clsFn) {
if (clsFn(e,args)==false) return;
};
if (this._listeners.length) for (var i=0;i<this._listeners.length;i++) {
if (this._listeners[i]["on"+type]) this._listeners[i]["on"+type](e,args);
if (!e.propagate) break;
}
if (this["on"+type]) this["on"+type](e,args);
if (e.bubble && this.parent) {
//if ((type=="mouseover" || type=="mouseout") && e._relative==this.parent) return;
e.x += this.x;
e.y += this.y;
e.bubbleChild = this;
this.parent.invokeEvent(type,e,args);
}
};
// Add subClassEvent() function to dynapi.functions
dynapi.functions.subClassEvent = function(type,eobj,fn){
var ek=eobj+'_'+type;
var cls=EventObject._SubClass;
if(typeof(fn)=='function') cls[ek]=fn;
else if(!fn && cls[ek]) delete cls[ek];
};
function DynElement() {
this.EventObject = EventObject;
this.EventObject();
this.isChild = false;
this._created = false;
this.parent = null;
this._dyndoc = null;
this.children = [];
this._childAnchors = {};
//raphaelpereira
this._cfn = {};
this._fn = 0;
};
DynElement._flagCreate = function(c){ // much faster than using DynElemnt._flagEvent
var ch=c.children;
c._created = true;
if (c._hasCreateFn) c._flagCreateEvent('create');
for (var i=0; i<ch.length; i++) this._flagCreate(ch[i]);
};
DynElement._flagPreCreate = function(c){
var ch=c.children;
if (c._hasPCreateFn) c._flagCreateEvent('precreate');
for (var i=0; i<ch.length; i++) this._flagPreCreate(ch[i]);
};
DynElement._flagEvent = function(c,type) {
var ch=c.children;
c.invokeEvent(type);
for (var i=0; i<ch.length; i++) this._flagEvent(ch[i],type);
};
p = dynapi.setPrototype('DynElement','EventObject');
p._adjustSize = dynapi.functions.Null;
p.addChild = function(c,alias,inlineID) {
if (!c) return dynapi.debug.print("Error: no object sent to [DynLayer].addChild()");
if (c.isChild) c.removeFromParent();
c.isChild = true;
c.parent = this;
if (c._saveAnchor) {
c.setAnchor(c._saveAnchor);
c._saveAnchor = null;
delete c._saveAnchor;
}
c._alias = alias;
if(alias) this[alias]=c;
if(inlineID)
c.setID(inlineID,true);
if (this._created) {
if (c.isInline) c._createInline();
else c._create();
}
this.children[this.children.length] = c;
if(this._aSz) this._adjustSize(); // adjust size if necessary
return c;
};
p.deleteAllChildren = function() { // removes & destroy all children
var i=0;
var ch =this.children;
var aSz = this._aSz;
this._aSz = false; // prevent children from adjusting parent's size when removed
while(ch.length) {
c=ch[0];
if(c) c.deleteFromParent();
else {
i++; // fail safe method
if(i>=ch.length) break;
}
};
ch.length = 0;
this._aSz = aSz;
if(this._aSz) this._adjustSize(); // adjust size if necessary
};
p.deleteChild = function(c) { // removes & destroy child
var l = this.children.length;
for (var i=0;i<l && this.children[i]!=c;i++);
if (i!=l) {
c._destroy();
this.dropChildIndex(i);
}
};
p.deleteFromParent = function () { // removes & destroy child
if (this.parent) this.parent.deleteChild(this);
};
p.dropChildIndex = function(i){
var ch = this.children;
var l = ch.length;
delete ch[i];
ch[i] = ch[l-1];
ch[l-1] = null;
ch.length--;
// adjust parent size if necessary
if(this._aSz) this._adjustSize();
};
p.removeChild = function(c) {
var l = this.children.length;
for (var i=0;i<l && this.children[i]!=c;i++);
if (i!=l) {
c._remove();
c._created = c.isChild = false;
c.parent = c.dyndoc = null;
c.elm = c._blkBoardElm = c.css = c.doc = null;
this.dropChildIndex(i);
}
};
p.removeFromParent = function () {
if (this.parent) this.parent.removeChild(this);
};
p._create = p._createInLine = p._createInserted = p._remove = p._delete = p._destroy = dynapi.functions.Null;
p.getChildren = function() {return this.children};
p.getAllChildren = function() {
var temp;
var ret = [];
var ch = this.children;
var l = ch.length;
for(var i=0;i<l;i++) {
ret[ch[i].id] = ch[i];
temp = ch[i].getAll();
for(var j in temp) ret[j] = temp[j];
}
return ret;
};
p.getParents = function(l) {
if (l==null) l = [];
if (this.parent) {
l[l.length] = this.parent;
l = this.parent.getParents(l);
}
return l;
};
p.isParentOf = function(c) {
if (c) {
var p = c.getParents();
for (var i=0;i<p.length;i++) {
if (p[i]==this) return true;
}
}
return false;
};
p.isChildOf = function(p) {
if (!p) return false;
return p.isParentOf(this);
};
// New onPreCreate() and onCreate() callback functions
p.onCreate = function(fn){
if(!fn) return;
if(!this._cfn){this._fn=0;this._cfn=[];}
var s='create'+this._fn++;
this._cfn[s]='create';
this._hasCreateFn=true;
this[s]=fn;
};
p.onPreCreate = function(fn){
if(!fn) return;
if(!this._cfn){this._fn=0;this._cfn=[];}
var s='precreate'+this._fn++;
this._cfn[s]='precreate';
this._hasPCreateFn=true;
this[s]=fn;
};
p._flagCreateEvent = function(t){
for(var i in this._cfn){
if(this._cfn[i]==t)
try{this[i]();}
catch(e){return}
};
};
p.updateAnchor = function() {
this.parent._updateAnchor(this.id);
};
p._updateAnchor = function(id) {
if (!id) return;
var dlyr = DynObject.all[id];
var a = this._childAnchors[id];
var tw = this.w;
var th = this.h;
if (a==null || (tw==null && th==null)) return;
// anchoring/docking
var fn=dynapi.functions;
var padX=0,padY=0;
if(a.topA) {
anc=fn.getAnchorLocation(a.topA,this);
if(anc){padY=anc.y; th=th-padY;}
}
if(a.leftA) {
anc=(a.leftA==a.topA && anc)? anc:fn.getAnchorLocation(a.leftA,this);
if(anc) {padX=anc.x; tw=tw-padX;}
}
if(a.bottomA) {
anc=fn.getAnchorLocation(a.bottomA,this);
th=th-(this.h-anc.y);
}
if(a.rightA) {
anc=(a.bottomA==a.rightA && anc)? anc:fn.getAnchorLocation(a.rightA,this);
if(anc) tw=tw-(this.w-anc.x);
}
var aleft=(tw>0 && a.left && typeof(a.left)=='string')? tw*(parseInt(a.left)/100):a.left;
var aright=(tw>0 && a.right && typeof(a.right)=='string')? tw*(parseInt(a.right)/100):a.right;
var atop=(th>0 && a.top && typeof(a.top)=='string')? th*(parseInt(a.top)/100):a.top;
var abottom=(th>0 && a.bottom && typeof(a.bottom)=='string')? th*(parseInt(a.bottom)/100):a.bottom;
var x = aleft;
var y = atop;
var w = null;
var h = null;
var dlyrWidth=dlyr.getWidth();
var dlyrHeight=dlyr.getHeight();
if (a.stretchH!=null) {
if(typeof(a.stretchH)!='string') w=a.stretchH;
else {
if(a.stretchH=='*') w = tw - ((aleft!=null)? aleft:0);
else w = tw*(parseInt(a.stretchH)/100);
}
dlyrWidth=w;
}
if (a.centerH!=null) {
x = Math.ceil(tw/2 - dlyrWidth/2 + a.centerH);
}else if (aright!=null) {
if (aleft!=null) w = (tw - aright) - aleft;
else x = (tw - dlyrWidth) - aright;
if(tw<=0 && x<0) x=null; // ns4 needs x>=0
}
if (a.stretchV!=null) {
if(typeof(a.stretchV)!='string') h=a.stretchV;
else {
if(a.stretchV=='*') h = th - ((atop!=null)? atop:0);
else h = th*(parseInt(a.stretchV)/100);
}
dlyrHeight=h;
}
if (a.centerV!=null) {
y = Math.ceil(th/2 - dlyrHeight/2 + a.centerV);
}else if (abottom!=null) {
if (atop!=null) h = (th - abottom) - atop;
else y = (th - dlyrHeight) - abottom;
if(th<=0 && y<0) y=null; // ns4 needs y>=0
}
if(padX) {x=(x)? x:0;x+=padX}
if(padY) {y=(y)? y:0;y+=padY}
// IE seems to be getting wrong position
if (dynapi.ua.ie)
{
/* aleft += 10;
aright += 10;
atop += 10;
abottom += 10;*/
x += 7;
y += 14;
}
var tmp=dlyr._hasAnchor;
dlyr._hasAnchor=false; // ignore anchor updates of this layer
if(x!=null||y!=null) dlyr.setLocation(x,y);
if(w!=null||h!=null) dlyr.setSize(w,h);
dlyr._hasAnchor = tmp; // useful for preventing stack overflow
};
p._updateAnchors = function() {
var tw = this.w;
var th = this.h;
if (tw==null && th==null) return;
for (id in this._childAnchors) this._updateAnchor(id);
};
// Bandwidth timer stop
var ua=dynapi.ua; ua._bwe=new Date;
ua.broadband=((ua._bwe-ua._bws)<=1500)? true:false;

View File

@ -1,306 +0,0 @@
/*
DynAPI Distribution
DragEvent Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
// DragEvent object
function DragEvent(type,src) {
this.MouseEvent = MouseEvent;
this.MouseEvent();
this.DynEvent();
this.isDragging = false;
};
var p = dynapi.setPrototype('DragEvent','MouseEvent');
p.getX=function() {return this.x};
p.getY=function() {return this.y};
p.getPageX=function() {return this.pageX};
p.getPageY=function() {return this.pageY};
p.cancelDrag=function() {this.isDragging=false};
//DragEvent.dragPlay=0;
DragEvent.dragevent = new DragEvent();
DragEvent.lyrListener = {
onmousedown : function(e) {
var ic,o = e.getSource();
//setup drag icon
if(o._useDragIcon && o._dragIcon) {
ic=o._dragIcon;
ic._dragOrg = o;
ic.setLocation(o.getPageX(),o.getPageY());
ic.setSize(o.w,o.h);
// if icon is fixed width then center at pointer
if(ic.w!=o.w||ic.h!=o.h) ic.setLocation(e.getPageX()-(ic.w/2),e.getPageY()-(ic.h/2));
}
DragEvent.startDrag(e,ic);
//e.preventDefault();
}
};
DragEvent.startDrag = function(e,dlyr) {
var origdlyr = dlyr;
if (!dlyr) dlyr = e.getSource();
if (dynapi.ua.dom) {
dlyr.elm.ondragstart = function() { return false; };
dlyr.elm.onselectstart = function() { return false; };
}
// Initialize dragEvent object
var de=DragEvent.dragevent;
//de.bubble = true;
de.src = dlyr;
de.origin = (origdlyr)? e.origin : dlyr;
de.x = e.getPageX()-dlyr.getPageX();
de.y = e.getPageY()-dlyr.getPageY();
de.pageX = e.getPageX();
de.pageY = e.getPageY();
de.parentPageX = dlyr.parent.getPageX();
de.parentPageY = dlyr.parent.getPageY();
de._mouseEvent = e._mouseEvent;
de._browserEvent = e._browserEvent; // ns4 only
de.isDragging = true;
e.preventDefault();
e.preventBubble();
//dlyr._dyndoc.addEventListener(DragEvent.docListener);
dlyr.invokeEvent("dragstart",de);
if(dlyr._dragOrg) {
dlyr.setVisible(true);
dlyr._dragOrg.invokeEvent("dragstart",e);
}
};
DragEvent.docListener = {
onmousemove : function(e) {
//var x = e.getPageX();
//var y = e.getPageY();
//dynapi.debug.status('drag move '+e.x+' '+e.y);
var de = DragEvent.dragevent;
if (de && de.isDragging) {
var lyr = de.src;
if (!lyr) return;
// DS: what is this?
// Detect if we should start the drag
/*if(DragEvent.dragPlay==0 || (Math.abs(de.pageX-e.getPageX())-DragEvent.dragPlay>0) || (Math.abs(de.pageY-e.getPageY())-DragEvent.dragPlay>0)) {
de.isDragging=true;
de.src.invokeEvent("dragstart",de);
e.setBubble(de.bubble);
}
*/
/*else if (!de.dragEnabled) {
// This allows 'cancelDrag' method to fire the mouseUp as if had been released by the user
lyr.invokeEvent("mouseup");
return;
}*/
// Properties
de.type="dragmove";
de.pageX=e.getPageX();
de.pageY=e.getPageY();
de._mouseEvent = e._mouseEvent;
de._browserEvent = e._browserEvent; // ns4 only
/*if (DragEvent.stopAtDocumentEdge) {
if (de.pageX<0) de.pageX = 0;
if (de.pageY<0) de.pageY = 0;
if (de.pageX>DynAPI.document.w) de.pageX = DynAPI.document.w;
if (de.pageY>DynAPI.document.h) de.pageY = DynAPI.document.h;
}*/
var x=de.pageX-de.parentPageX-de.x;
var y=de.pageY-de.parentPageY-de.y;
// Respect boundary, if any
if (lyr._dragBoundary) {
var dB = lyr._dragBoundary;
var t = dB.top;
var r = dB.right;
var b = dB.bottom;
var l = dB.left;
// prevent choppy dragging if child is greater than parent
var pw = (lyr.parent.w>lyr.w)? lyr.parent.w-lyr.w:lyr.x;
var ph = (lyr.parent.h>lyr.h)? lyr.parent.h-lyr.h:lyr.y;
if (x<l) x = l;
else if (x>pw-r) x = pw-r;
if (y<t) y = t;
else if (y>ph-b) y = ph-b;
}
else if (lyr._dragBoundaryA) {
var dB = lyr._dragBoundaryA;
var b=dB[2];
var r=dB[1];
var l=dB[3];
var t=dB[0];
var w=lyr.w;
var h=lyr.h;
if (x<l) x=l;
else if (x+w>r) x=r-w;
if (y<t) y=t;
else if (y+h>b) y=b-h;
}
// Move dragged layer
lyr.setLocation(x,y);
lyr.invokeEvent("dragmove",de);
// drag icon
if(lyr._dragOrg) {
lyr._dragOrg.invokeEvent("dragmove",e);
}
if (lyr._dragStealth==false && lyr.parent.DragOver) {
lyr.parent.DragOver(lyr,e.getPageX(),e.getPageY());
}
e.preventDefault();
e.preventBubble();
}
},
onmouseup : function(e) {
// Get, if any, the currently drag in process and the layer. If none, return
var de=DragEvent.dragevent;
//de.bubble = true;
if (!de) return;
var lyr=de.src;
if (!lyr) return;
if (!de.isDragging) {
de.type="dragend";
de.src=null;
//e.setBubble(true);
return;
}
if (dynapi.ua.ie) lyr.doc.body.onselectstart = null;
// Avoid click for the dragged layer ( with MouseEvent addition )
if (dynapi.ua.def) dynapi.wasDragging=true;
if (lyr.parent.DragDrop) lyr.parent.DragDrop(lyr,e.getPageX(),e.getPageY());
// Properties for the event
de.type="dragend";
de.isDragging=false;
lyr.invokeEvent("dragend",de);
// drag icon
if(lyr._dragOrg) {
lyr.setVisible(false);
lyr._dragOrg.invokeEvent("dragend",de);
}
// Clean drag stuff
de.src=null;
//e.preventDefault();
e.preventBubble();
//lyr._dyndoc.removeEventListener(DragEvent.docListener);
}
};
DragEvent.stopAtDocumentEdge = true;
DragEvent.setDragBoundary=function(lyr,t,r,b,l) {
if (!lyr) {dynapi.debug.print("Error: no object passed to DragEvent.setDragBoundary()"); return;}
var a=arguments;
if (a.length==0) return;
if (a.length==1) {
lyr._dragBoundary = {left:0,right:0,top:0,bottom:0};
}
if (a.length==2) {
lyr._dragBoundary = arguments[1];
}
else if (a.length==5) lyr._dragBoundaryA = [t,r,b,l];
};
DragEvent.enableDragEvents=function() {
for (var i=0;i<arguments.length;i++) {
var lyr=arguments[i];
if (!lyr) {dynapi.debug.print("Error: no object passed to DragEvent.enableDragEvents()"); return;}
if (lyr.isClass('DynLayer')) lyr.addEventListener(DragEvent.lyrListener);
}
dynapi.document.addEventListener(DragEvent.docListener);
dynapi.document.captureMouseEvents();
};
DragEvent.disableDragEvents=function() {
for (var i=0;i<arguments.length;i++) {
var lyr=arguments[i];
lyr.removeEventListener(DragEvent.lyrListener);
}
};
// used mainly inside ondrop and ondragover
DynLayer.prototype.getDragSource = function(){
return this._dragOrg||this;
};
DynLayer.prototype.setDragEnabled = function(b,boundry,useIcon){
if(!self.DragEvent) return false;
if(boundry)DragEvent.setDragBoundary(this,boundry);
if (b) DragEvent.enableDragEvents(this);
else DragEvent.disableDragEvents(this);
this._useDragIcon = useIcon;
return true;
};
DynLayer.prototype.setDragIcon = function(icon){
if(!icon) return;
this._dragIcon = icon;
icon.setZIndex({topmost:true});
icon.setVisible(false);
dynapi.document.addChild(icon);
};
DynLayer.prototype.setDragOverStealthMode = function(b){
this._dragStealth=(b)? true:false;
};
// Enable ondrop event
DynElement.prototype.DragDrop=function(s,mX,mY){
if (!this.children.length) return false;
var ch,chX,sX,sY;
for (var i in this.children) {
ch=this.children[i];
if(!ch._hasDragEvents) ch.DragDrop(s,mX,mY);
else {
chX=ch.getPageX();
chY=ch.getPageY();
//sX=s.getPageX();
//sY=s.getPageY();
//if (chX<sX && chX+ch.w>sX+s.w && chY<sY && chY+ch.h>sY+s.h) {
if ((mX>=chX && mX<=chX+ch.w) && (mY>=chY && mY<=chY+ch.h)) {
if (ch.DragDrop(s,mX,mY)) return true;
ch.invokeEvent("drop",null,s);
return true;
}
}
}
return false;
};
// Enable ondragover event
DynElement.prototype.DragOver=function(s,mX,mY){
if (!this.children.length) return false;
var ch,chX,sX,sY;
for (var i in this.children) {
ch=this.children[i];
if (!ch._hasDragEvents) ch.DragOver(s,mX,mY);
else {
chX=ch.getPageX();
chY=ch.getPageY();
if ((mX>=chX && mX<=chX+ch.w) && (mY>=chY && mY<=chY+ch.h)) {
if (ch.DragOver(s,mX,mY)) return true;
ch._isDragOver=true;
ch.invokeEvent("dragover",null,s);
return true;
}else if (ch._isDragOver) {
ch._isDragOver=false;
ch.invokeEvent("dragout",null,s);
}
}
}
return false;
};

View File

@ -1,248 +0,0 @@
/*
DynAPI Distribution
DynKeyEvent Extensions
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
Requirements:
dynapi.api
*/
function DynKeyEvent(type,src) {
this.DynEvent = DynEvent;
this.DynEvent(type,src);
this.charKey=null;
};
var p=dynapi.setPrototype('DynKeyEvent','DynEvent');
p.getKey=function() {
return this.charKey;
};
DynKeyEvent._keyEventListener=function(e) {
var dynobj=this._dynobj;
if(!dynobj)
return true;
var dyndoc=dynobj.doc._dynobj;
if(!dyndoc) return true;
if(!e) var e=dyndoc.frame.event;
var evt=new DynKeyEvent(e.type,dynobj);
evt.which=(e.keyCode)?e.keyCode:e.which;
var key=String.fromCharCode(evt.which).toLowerCase();
if((key>='a'&&key<='z')||(key>='0'&&key<='9')) evt.charKey=key;
evt.spaceKey=(evt.which==32);
evt.enterKey=(evt.which==13);
evt.tabKey=(evt.which==9||evt.which==65289);
evt.leftKey=(evt.which==37||evt.which==52||evt.which==100||evt.which==65460);
evt.rightKey=(evt.which==39||evt.which==54||evt.which==102||evt.which==65462);
evt.upKey=(evt.which==38||evt.which==56||evt.which==104||evt.which==65464);
evt.downKey=(evt.which==40||evt.which==50||evt.which==98||evt.which==65458);
evt.altKey=(e.modifiers)?false:(e.altKey||e.altLeft||evt.which==18||evt.which==57388);
evt.ctrlKey=(e.modifiers)?(e.modifiers&Event.CONTROL_MASK):(e.ctrlKey||e.ctrlLeft||evt.which==17||evt.which==57391);
evt.shiftKey=(e.modifiers)?(e.modifiers&Event.SHIFT_MASK):(e.shiftKey||e.shiftLeft||evt.which==16||evt.which==57390);
dynobj.invokeEvent(evt.type,evt);
if(evt.defaultValue==false) {
if(e.cancelBubble) e.cancelBubble=true;
if(e.stopPropagation) e.stopPropagation();
}
return evt.defaultValue;
};
TabManager={};
TabManager._c=0; // Current tab manager index.
TabManager._all=[];
TabManager._active=false;
TabManager._activeTimeout=function() { // Prevent duplcate keydown events in NS4.
TabManager._active=true;
setTimeout('TabManager._active=false;',25);
};
TabManager._getForm=null;
TabManager.getForm=function(p) { // Prevent default tab focus in Mozilla.
if(TabManager._getForm) return;
TabManager._getForm=p;
var html='<form name="__frm" onsubmit="return false;"><input name="__tab" size=1></form>';
return p.addChild(new DynLayer(html),'__lyr');
};
TabManager._grabFocus=function() {
var form=TabManager._getForm.__lyr;
setTimeout(form+'.doc.forms.__frm.__tab.focus();',0);
};
TabManager._el={};
TabManager._el.onkeydown=function(e) {
if(TabManager._getForm) { // User must have inserted TabManager form.
if(TabManager._active) return;
TabManager._activeTimeout();
}
var i1,o1,l1,i2,o2,l2;
var nextKey=(e.tabKey||e.rightKey);
var prevKey=((e.shiftKey&&e.tabKey)||e.leftKey);
var submitKey=(e.enterKey||e.spaceKey);
i1=TabManager._c; o1=TabManager._all[i1]; l1=TabManager._all.length;
i2=o1._tabGroup._c; o2=o1._tabGroup._all[i2]; l2=o1._tabGroup._all.length;
if(nextKey||prevKey) { // Cycle group.
if(o2._hasFocusEvents) o2.setFocus(false,o2._focusBubble);
else o2.invokeEvent('blur');
if(prevKey) i2=(i2==0)?l2-1:i2-1;
else i2=(i2==l2-1)?0:i2+1;
o2=o1._tabGroup._all[i2]; o1._tabGroup._c=i2;
if(o2._hasFocusEvents) o2.setFocus(true,o2._focusBubble);
else o2.invokeEvent('focus');
}
else if(e.upKey||e.downKey) { // Cycle manager.
if(o2._hasFocusEvents) o2.setFocus(false,o2._focusBubble);
else o2.invokeEvent('blur');
if(e.upKey) i1=(i1==0)?l1-1:i1-1;
else i1=(i1==l1-1)?0:i1+1;
o1=TabManager._all[i1]; TabManager._c=i1;
i2=o1._tabGroup._c;
o2=o1._tabGroup._all[i2];
if(o2._hasFocusEvents) o2.setFocus(true,o2._focusBubble);
else o2.invokeEvent('focus');
} else if(submitKey) {
o2.invokeEvent('submit');
}
e.preventDefault();
if(TabManager._getForm) TabManager._grabFocus();
};
DynElement.prototype.createTabManager=function() {
var p=this, c=p.children; if(!c) return;
var args=(arguments.length)?arguments:c;
var l=args.length, s; if(!l) return;
if(p._tabGroup) delete p._tabGroup;
p._tabGroup={ _c:0, _all:[] };
for(var i=0;i<l;i++) {
c=args[i];
p._tabGroup._all[i]=c;
c._hasTabManager=true;
if(!c._submitFn) {
s=c.id.replace(/-/g,'.')+'()'; // Element id callback.
c._submitFn=s;
}
}
l=TabManager._all.length; TabManager._all[l]=p;
if(l==0) dynapi.onLoad(function() {
dynapi.document.addEventListener(TabManager._el);
});
};
DynElement.prototype.updateTabManager=function() {
var tm=TabManager, all=tm._all[TabManager._c]; if(!all) return;
var old=all._tabGroup; if(!old||old._all[old._c]==this) return;
var p=this.parent, l;
var tg=(p&&p._tabGroup)?p._tabGroup:null; if(!tg) return;
l=tg._all.length;
for(var i=0;i<l;i++) if(tg._all[i]==this) { tg._c=i; break; }
l=tm._all.length;
for(var i=0;i<l;i++) if(tm._all[i]==p) { tm._c=i; break; }
};
DynElement.prototype.addTabListeners=function(el) {
if(el&&this._tabGroup) {
var a=this._tabGroup._all;
for(var i in a) a[i].addEventListener(el);
}
};
DynElement.prototype.addSubmitFn=function(fn) {
if(fn) this._submitFn=fn;
};
DynElement.prototype.callSubmitFn=function() {
var f=this._submitFn;
if(typeof(f)=='function') f();
else if(typeof(f)=='string') eval(f);
};
DynElement.prototype.captureKeyEvents=function() {
// This impossibilitates Inheritance... changing to the same aproach as captureMouseEvents
//var elm=(this.getClassName()=='DynLayer')?this.elm:this.doc;
var elm;
if (this.getKeyEventElement) elm = this.getKeyEventElement();
else elm=(this.getClassName()=='DynDocument')?this.doc:this.elm;
//if(!elm||this._hasKeyEvents) return true;
if (!elm) return true;
if(elm.addEventListener) {
elm.addEventListener("keydown",DynKeyEvent._keyEventListener,false);
elm.addEventListener("keypress",DynKeyEvent._keyEventListener,false);
elm.addEventListener("keyup",DynKeyEvent._keyEventListener,false);
elm.addEventListener("blur",DynKeyEvent._keyEventListener,false);
elm.addEventListener("focus",DynKeyEvent._keyEventListener,false);
}
else {
if(elm.captureEvents)
elm.captureEvents(Event.KEYPRESS|Event.KEYDOWN|Event.KEYUP);
elm.onblur=elm.onfocus=elm.onkeydown=elm.onkeypress=elm.onkeyup=DynKeyEvent._keyEventListener;
}
this._hasKeyEvents=true;
return false;
};
DynElement.prototype.releaseKeyEvents=function() {
var elm=(this.getClassName()=='DynLayer')?this.elm:this.doc;
if(!elm||!this._hasKeyEvents) return true;
if(elm.removeEventListener) {
elm.removeEventListener("keydown",DynKeyEvent._keyEventListener,false);
elm.removeEventListener("keypress",DynKeyEvent._keyEventListener,false);
elm.removeEventListener("keyup",DynKeyEvent._keyEventListener,false);
}
else {
if(elm.releaseEvents)
elm.releaseEvents(Event.KEYPRESS|Event.KEYDOWN|Event.KEYUP);
elm.onkeydown=elm.onkeypress=elm.onkeyup=null;
}
this._hasKeyEvents=false;
return false;
};
DynDocument.prototype.captureHotKey = function(key,fn){
var klst=((key+'').toLowerCase()).split('+');
klst.sort();
key=klst.join('+');
if(!this._hotKeys){
this._hotKeys={};
this._keyDn={};
this._keyLst='';
this.captureKeyEvents();
this.addEventListener({
onkeydown:function(e){
var k = e.which;
var o = e.getSource();
// to-do: add opera v7 key code (57xxx), e.g 57388
if (k==13) k="enter";
else if(k==27) k="esc";
else if(k==45) k="insert";
else if(k==46) k="delete";
else if(k==36) k="home";
else if(k==35) k="end";
else if(k==33) k="pgup";
else if(k==34) k="pgdn";
else if(k==38) k="up";
else if(k==40) k="down";
else if(k==37) k="left";
else if(k==39) k="right";
else if(e.altKey && !o._keyDn['alt']) k="alt";
else if(e.ctrlKey && !o._keyDn['ctrl']) k="ctrl";
else if(e.shiftKey && !o._keyDn['shift']) k="shift";
else k=(String.fromCharCode(k)).toLowerCase();
if(!o._keyDn[k]) {
// store new key in keyDn array
o._keyLst+=(((o._keyLst)? '+':'')+k); // build key list
var ar=o._keyLst.split('+');
ar.sort();
o._keyLst=ar.join('+');
o._keyDn[k]=true;
}
k=o._hotKeys[o._keyLst];
if(k){
o._keyLst='';o._keyDn={};
if(typeof(k)=='string') return eval(k); else return k();
}
},
onkeyup:function(e){
var o=e.getSource();
o._keyLst='';o._keyDn={};
}
});
}
this._hotKeys[key]=fn;
};
DynDocument.prototype.releaseHotKey = function(key){
if(this._hotKeys) delete this._hotKeys[key];
};

View File

@ -1,124 +0,0 @@
/*
DynAPI Distribution
DynLayer Inline Extension
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynLayer
*/
var DynLayerInline = {};
DynLayer.getInline = function (id, p) {
var elm;
var pobj;
if (!p) pobj = dynapi.document;
else if (p.isClass && p.isClass('DynElement')) pobj = p;
if (pobj) {
if (dynapi.ua.ns4) elm = pobj.doc.layers[id];
else if (dynapi.ua.ie) elm = pobj.doc.all[id];
else if (dynapi.ua.dom) elm = pobj.doc.getElementById(id);
}
if (!elm) return alert("DynLayerInline Error: did not find element "+id);
var dlyr = new DynLayer();
dlyr.setID(id);
dlyr.parent = pobj;
dlyr.elm = elm;
if (dynapi.ua.ns4) dlyr.doc = elm.document;
DynLayer._importInlineValues(dlyr);
DynLayer._assignElement(dlyr,elm);
DynElement._flagCreate(dlyr);
return dlyr;
};
DynLayer.prototype._createInline = function (divs) {
if (this.parent && !this.elm) {
var ch=this.children;
DynLayer._assignElement(this,null,divs);
DynLayer._importInlineValues(this);
for (var i=0;i<ch.length;i++) DynLayer._importInlineValues(ch[i]);
DynElement._flagCreate(this);
}
};
DynLayer._importInlineValues = function(dlyr) {
if(dlyr && dlyr._noInlineValues) return;
if (dynapi.ua.def) {
if (dynapi.ua.ie) {
var css = dlyr.elm.currentStyle;
dlyr.x = parseInt(css.left);
dlyr.y = parseInt(css.top);
dlyr.w = dynapi.ua.ie4? css.pixelWidth : dlyr.elm.offsetWidth;
dlyr.h = dynapi.ua.ie4? css.pixelHeight : dlyr.elm.offsetHeight;
dlyr.bgImage = css.backgroundImage;
dlyr.bgColor = css.backgroundColor;
dlyr.html = dlyr.elm.innerHTML;
}
else if (dynapi.ua.dom) {
var css = dlyr.elm.style;
dlyr.x = parseInt(dlyr.elm.offsetLeft);
dlyr.y = parseInt(dlyr.elm.offsetTop);
dlyr.w= dlyr.elm.offsetWidth;
dlyr.h= dlyr.elm.offsetHeight;
dlyr.bgImage = css.backgroundImage;
dlyr.bgColor = css.backgroundColor;
dlyr.html = dlyr.elm.innerHTML;
}
}
else if (dynapi.ua.ns4) {
var css = dlyr.elm;
dlyr.x = parseInt(css.left);
dlyr.y = parseInt(css.top);
dlyr.w = css.clip.width;
dlyr.h = css.clip.height;
dlyr.clip = [css.clip.top,css.clip.right,css.clip.bottom,css.clip.left];
dlyr.bgColor = dlyr.doc.bgColor!=''? dlyr.doc.bgColor : null;
dlyr.bgImage = css.background.src!=''? css.background.src : null;
dlyr.html = '';
}
dlyr.z = css.zIndex;
var b = css.visibility;
dlyr.visible = (b=="inherit" || b=="show" || b=="visible" || b=="");
};
// Generate Blueprint
DynElement.prototype.getBlueprint = function(type) {
var i,c,ht,str =[];
var f,ch=this.children;
for(i=0;i<ch.length;i++) {
c = ch[i];
DynElement._flagPreCreate(c);
ht=c.getOuterHTML();
if(!type || type=='css') str[i]=ht;
else {
ht=ht.replace(/\'/g,'\\\'');
ht=ht.replace(/\r/g,'\\r');
ht=ht.replace(/\n/g,'\\n');
str[str.length]='_bw(\''+ht+'\');';
}
}
if(!type || type=='css') str=str.join('');
else str=str.join('\n');
if(type=='css') { // generate style sheet from blueprints
var ar=str.split('<div');
for(i=0;i<ar.length;i++){
ar[i]=ar[i].replace(/(.+)id="(.+)" style="(.+)"(.+)/g,'#$2 {$3}');
}
str=ar.join('');
}
return str;
};
DynElement.prototype.generateBlueprint = function(type) {
var url=dynapi.library.path+'ext/blueprint.html';
var win=window.open(url,'blueprint','width=500,height=350,scrollbars=no,status=no,toolbar=no');
var f=win.document.forms['frm'];
f.txtout.value=this.getBlueprint(type);
};
// Blueprint Document write
_bw = function(str){
document.write(str);
};

View File

@ -1,148 +0,0 @@
/*
DynAPI Distribution
MouseEvent Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynDocument
*/
function MouseEvent(dyndoc) {
this.DynEvent = DynEvent;
this.DynEvent();
this.bubble = true;
this._mouseEvent = null;
this._relative = null;
this._dyndoc = dyndoc;
};
var p = dynapi.setPrototype('MouseEvent','DynEvent');
p.getX = function() {return this.x};
p.getY = function() {return this.y};
p.getPageX = function() {return this.pageX};
p.getPageY = function() {return this.pageY};
//p.trapMouseUp = dynapi.functions.Null;
p.getRelative = function() {return this._relative};
p.preventBubble = function() {
this.bubble = false;
};
p.getButton = function() {
if (!this._mouseEvent) return "left";
var b = this._mouseEvent.which;
if (b==2) return "middle";
if (b==3) return "right";
else return "left";
};
p._init = function(type,e,src) {
this.type = type;
this._mouseEvent = e;
this.origin = src;
this.bubbleChild = null;
this.defaultValue = true;
this.bubble = true;
};
p._invoke = function() {
var o = this.origin;
o.invokeEvent(this.type,this);
};
MouseEvent._getContainerLayerOf = function(element) {
try{
if (!element) return null;
while (!element._dynobj && element.parentNode && element.parentNode!=element) {
element = element.parentNode;
}
return element._dynobj;
}
catch(e)
{
//FIXME: For some wierd reason, a InputElement is parent of a DIV
// and then it falls here. For now, the error is ignored
}
};
MouseEvent._eventHandler = function(e) {
var dynobj = this._dynobj;
if (!dynobj) return true;
var dyndoc = dynobj._dyndoc;
var target = e.target;
var me = dyndoc._mouseEvent;
var src = MouseEvent._getContainerLayerOf(target);
me._init(e.type,e,src);
var rel = e.relatedTarget;
var r = me._relative = MouseEvent._getContainerLayerOf(rel);
if (e.type=="mouseout" || e.type=="mouseover") {
if(!r && dynapi.ua.opera) return; //fix for #15
if (r && (r==src||src.isParentOf(r))) return; // fix for #15
if (r && (r==src.parent||r.isChildOf(src.parent))) me.bubble=false;
}
me.pageX = e.clientX;
me.pageY = e.clientY;
if(!src) return;
me.x = (me.pageX+(window.pageXOffset||0)) - src.getPageX(); //offsetX;
me.y = (me.pageY+(window.pageYOffset||0)) - src.getPageY(); //offsetY;
// NOTE: This is done because in Mozilla, when adding event listeners
// to document element, 'title' properties doesn't work anymore...
// raphaelpereira@users.sourceforge.net
if (src.getClassName() != 'DynDocument') e.cancelBubble = true;
me._invoke();
var tn=(target.tagName+'').toLowerCase();
// fix for form elements inside drag-enabled layer #08
if(e.type=='mousedown' && tn=='input'||tn=='textarea'||tn=='button') {
var de=dynapi.frame.DragEvent;
de=(de && de.dragevent)? de.dragevent:null;
if(de && de.isDragging) de.cancelDrag();
}
// prevent image dragging
if(tn=='img' && typeof(target.onmousedown)!="function") {
target.onmousedown=dynapi.functions.False;
}
// disable text select
if (e.type=='mousedown' && src._textSelectable==false) {
e.preventDefault();
return false;
}
};
DynElement.prototype.disableContextMenu = function(){
this._noContextMenu = true;
if(this.elm) this.elm.addEventListener("contextmenu",MouseEvent._eventHandler,false);
};
DynElement.prototype.captureMouseEvents = function() {
this._hasMouseEvents = true;
var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm;
if(elm) {
elm.addEventListener("mousemove",MouseEvent._eventHandler,false);
elm.addEventListener("mousedown",MouseEvent._eventHandler,false);
elm.addEventListener("mouseup",MouseEvent._eventHandler,false);
elm.addEventListener("mouseover",MouseEvent._eventHandler,false);
elm.addEventListener("mouseout",MouseEvent._eventHandler,false);
elm.addEventListener("click",MouseEvent._eventHandler,false);
elm.addEventListener("dblclick",MouseEvent._eventHandler,false);
if(this._noContextMenu) elm.addEventListener("contextmenu",MouseEvent._eventHandler,false);
}
};
DynElement.prototype.releaseMouseEvents=function() {
this._hasMouseEvents = false;
var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm;
if (typeof(elm)=='object') {
/* elm.removeEventListener("mousemove",MouseEvent._eventHandler,false);
elm.removeEventListener("mousedown",MouseEvent._eventHandler,false);
elm.removeEventListener("mouseup",MouseEvent._eventHandler,false);
elm.removeEventListener("mouseover",MouseEvent._eventHandler,false);
elm.removeEventListener("mouseout",MouseEvent._eventHandler,false);
elm.removeEventListener("click",MouseEvent._eventHandler,false);
elm.removeEventListener("dblclick",MouseEvent._eventHandler,false);*/
}
};
function main_mouse_dom() {
dynapi.document._mouseEvent = new MouseEvent(dynapi.document);
};
if (!dynapi.loaded) main_mouse_dom();

View File

@ -1,124 +0,0 @@
/*
DynAPI Distribution
MouseEvent Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynDocument
*/
function MouseEvent(dyndoc) {
this.DynEvent = DynEvent;
this.DynEvent();
this.bubble = true;
this._mouseEvent = null;
this._relative = null;
this._dyndoc = dyndoc;
};
var p = dynapi.setPrototype('MouseEvent','DynEvent');
p.getX = function() {return this.x};
p.getY = function() {return this.y};
p.getPageX = function() {return this.pageX};
p.getPageY = function() {return this.pageY};
p.getRelative = function() {return this._relative};
p.preventBubble = function() {this.bubble = false;};
p.getButton = function() {
if (!this._mouseEvent) return "left";
var b = this._mouseEvent.button;
if (b==4) return "middle";
if (b==2) return "right";
else return "left";
};
p._init = function(type,e,src) {
this.type = type;
this._mouseEvent = e;
this.origin = src;
this.bubbleChild = null;
this.defaultValue = true;
this.bubble = true;
};
p._invoke = function() {
var o = this.origin;
o.invokeEvent(this.type,this);
};
MouseEvent._getContainerLayerOf = function(element) {
if (!element) return null;
while (!element._dynobj && element.parentElement && element.parentElement!=element) {
element = element.parentElement;
}
return element._dynobj;
};
//MouseEvent.trapMouseUp = dynapi.functions.False; // or MouseEvent.trapMouseUp=null
MouseEvent._eventHandler = function() {
var e = dynapi.frame.event;
var dynobj;
if (this._dynobj) dynobj = this._dynobj;
else if (e.srcElement._dynobj) dynobj = e.srcElement._dynobj;
else dynobj = dynapi.document;
var dyndoc = dynobj._dyndoc;
var target = e.srcElement;
var me = dyndoc._mouseEvent;
var src = MouseEvent._getContainerLayerOf(target);
me._init(e.type,e,src);
var rel = e.type=="mouseout"? e.toElement : e.fromElement;
var r = me._relative = MouseEvent._getContainerLayerOf(rel);
if (e.type=="mouseout" || e.type=="mouseover") {
if (r && src && (r==src||src.isParentOf(r))) return; //fix for #15 (ie only)
if (r && src && (r==src.parent||r.isChildOf(src.parent))) me.bubble=false;
}
me.pageX = e.clientX;
me.pageY = e.clientY;
if(!src) return;
me.x = (me.pageX + (document.body.scrollLeft||0)) - src.getPageX(); //offsetX;
me.y = (me.pageY + (document.body.scrollTop||0)) - src.getPageY(); //offsetY;
e.cancelBubble = true;
me._invoke();
var tt=target.type;
var tn=(target.tagName+'').toLowerCase();
// fix for form elements inside drag-enabled layer #08
if(tt=='textarea'||tt=='text' && target.onselectstart==null) target.onselectstart = dynapi.functions.Allow;
if(e.type=='mousedown' && tn=='input'||tn=='textarea'||tn=='button') {
var de=dynapi.frame.DragEvent;
de=(de && de.dragevent)? de.dragevent:null;
if(de && de.isDragging) de.cancelDrag();
}
// prevent image dragging
if(target.tagName=='IMG' && typeof(target.ondragstart)!="function") {
target.ondragstart=dynapi.functions.False;
}
};
DynElement.prototype.disableContextMenu = function(){
this._noContextMenu = true;
if(this.elm) this.elm.oncontextmenu = dynapi.functions.False;
};
DynElement.prototype.captureMouseEvents = function() {
this._hasMouseEvents = true;
if (this.elm) {
var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm;
elm.onmouseover = elm.onmouseout = elm.onmousedown = elm.onmouseup = elm.onclick = elm.ondblclick = elm.onmousemove = MouseEvent._eventHandler;
if(this._noContextMenu) elm.oncontextmenu = dynapi.functions.False;
}
};
DynElement.prototype.releaseMouseEvents = function() {
this._hasMouseEvents = false;
if (this.elm) {
var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm;
elm.onmousedown = elm.onmouseup = elm.onclick = elm.ondblclick = null;
elm.oncontextmenu = null;
}
};
function main_mouse_ie() {
dynapi.document._mouseEvent = new MouseEvent(dynapi.document);
};
if (!dynapi.loaded) main_mouse_ie();

View File

@ -1,214 +0,0 @@
/*
DynAPI Distribution
MouseEvent Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.api.DynDocument
*/
function MouseEvent(dyndoc) {
this.DynEvent = DynEvent;
this.DynEvent();
this.bubble = true;
this._browserEvent = null;
this._relative = null;
this._dyndoc = dyndoc;
};
var p = dynapi.setPrototype('MouseEvent','DynEvent');
p.getX = function() {return this.x};
p.getY = function() {return this.y};
p.getPageX = function() {return this.pageX};
p.getPageY = function() {return this.pageY};
//p.trapMouseUp = dynapi.functions.Null;
p.getRelative = function() {return this._relative};
p.getButton = function() {
if (!this._browserEvent) return "left";
var b = this._browserEvent.which;
if (b==2) return "middle";
if (b==3) return "right";
else return "left";
};
p._init = function(type,e,src) {
this.type = type;
this._browserEvent = e;
this.origin = src;
this.bubbleChild = null;
this.pageX = e.pageX-this._dyndoc.frame.pageXOffset;
this.pageY = e.pageY-this._dyndoc.frame.pageYOffset;
if (e.target._dynobj == src) {
this.x = e.layerX;
this.y = e.layerY;
}
else {
this.x = e.pageX - (src.pageX||0);
this.y = e.pageY - (src.pageY||0);
}
this.defaultValue = true;
this.bubble = true;
};
p._invoke = function() {
var o = this.origin;
o.invokeEvent(this.type,this);
// synthetic click event
if (this.type=='mouseup') {
this._init('click',this._browserEvent,o);
this._invoke();
// synthetic dblclick event
if (dynapi.ua.other);
}
};
function main() {
dynapi.document._mouseEvent = new MouseEvent(dynapi.document);
};
if (!dynapi.loaded) main();
MouseEvent._docMoveHandler = function(e) {
var dyndoc = this._dynobj;
var src = e.target;
var dynobj = src._dynobj || src._dynobji;
if (!dynobj || !dynobj._hasMouseEvents) {
var rel=dyndoc._moveOver;
if(rel && dynobj && !dynobj.isChildOf(rel)) {
var me = dyndoc._mouseEvent;
me._init('mouseout',e,rel);
me._invoke();
dyndoc._moveOver = null;
}
if(dynobj){
dynobj=dynobj.parent;
while (dynobj && !dynobj._hasMouseEvents){
dynobj=dynobj.parent;
}
}
if(!dynobj) return true;
}
var me = dyndoc._mouseEvent;
//dynapi.debug.status('move '+dynobj.name+' '+e.layerX+' '+e.layerY);
me._init('mousemove',e,dynobj);
me._invoke();
var defaultVal = me.defaultValue;
// synthetic mouseover/out events
if (dyndoc._moveOver!=dynobj) {
var rel = dyndoc._moveOver;
//var bubble = true;
// mouse out
if (rel && !dynobj.isChildOf(rel)) { // && !rel.isChildOf(dynobj)
// during mouseout e.getRelated() is which elm it is moving to
//bubble = !dynobj.isChildOf(rel);
me._init('mouseout',e,rel);
//prevent bubbling from child to parent for mouseout
if (rel.isChildOf(dynobj)) me.bubble=false;
me._relative = dynobj;
me._invoke();
//MouseEvent._generateEvent('mouseout',e,me,rel,dynobj,bubble); // out occurs before over
}
// mouse over
dyndoc._moveOver = dynobj;
//if (rel) var bubble = !rel.isChildOf(dynobj);
//var bubble = !dynobj.isChildOf(rel);
// during mouseover e.getRelated() is which elm it is moving to
if(!rel || !rel.isChildOf(dynobj)){
me._init('mouseover',e,dynobj);
//prevent bubbling from child to parent for mouseover
if(dynobj.isChildOf(rel)) me.bubble=false;
me._relative = rel;
me._invoke();
}
//MouseEvent._generateEvent('mouseover',e,me,dynobj,rel);
}
// prevent image dragging
if (e.type=="mousemove" && (e.target+'')=='[object Image]') {
me.defaultValue = defaultVal = false;
}
return defaultVal;
};
MouseEvent._eventHandler = function(e) {
var src = e.target;
var dynobj = this._dynobj;
if (!dynobj) return true;
var dyndoc = dynobj._dyndoc;
var me = dyndoc._mouseEvent;
me._wasHandled = false;
var r = routeEvent(e);
if (!me._wasHandled) {
//if (src._dynobji) { // src._dynobji == dynlayer.doc.images[x]._dynobji
// me._init(e.type,e,src._dynobji);
// if (e.type=='mousedown') me.defaultValue = false;
// me._invoke();
//}
// else
if (src._dynobj) { // src._dynobj == dynlayer.doc._dynobj,dynlayer.doc.images[x]._dynobj,dynlayer.doc.links[x]._dynobj
me._init(e.type,e,src._dynobj);
me._invoke();
}
else { // dynobj == dynlayer.elm._dynobj
me._init(e.type,e,dynobj);
me._invoke();
}
me._wasHandled = true;
}
dynobj = (src._dynobj)? src._dynobj:dynobj;
if (e.type=='mousedown'){
// disable text select
if(dynobj._textSelectable==false) {
// ns4 will disable hyperlinks. this is my workaround
me.defaultValue =(e.target.href)? null:false;
}
// allow images (<input type="image">) to be clicked
if ((e.target+'')=='[object Image]') {
me.defaultValue = true;
}
// allow form elements to be selected
var t = (e.target.type+'').toLowerCase();
if (t=='button'||t=='checkbox'||t=='radio') {
me.defaultValue=true;
}
}
return me.defaultValue;
};
DynElement.prototype.disableContextMenu = function(){
this._noContextMenu = true;
// can this be done in ns?
};
DynElement.prototype.captureMouseEvents = function() {
this._hasMouseEvents = true;
var elm = this.elm;
if (elm) {
elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.DBLCLICK);
elm.onmousedown = elm.onmouseup = elm.ondblclick = MouseEvent._eventHandler;
if (this.getClassName()=='DynDocument') { // move/over/out events are generated from the document
this.doc.captureEvents(Event.MOUSEMOVE);
elm.onmousemove = MouseEvent._docMoveHandler;
}
elm._dynobj = this;
this.doc._dynobj = this;
if(this._blkBoardElm) this.elm.document._dynobj = this;
for (var i=0;i<this.doc.images.length;i++) this.doc.images[i]._dynobj=this; // was _dynobji
for (var i=0;i<this.doc.links.length;i++) this.doc.links[i]._dynobj=this;
}
};
DynElement.prototype.releaseMouseEvents = function() {
this._hasMouseEvents = false;
var elm = this.elm;
if (elm) {
elm.releaseEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.DBLCLICK);
elm.onmousedown = elm.onmouseup = elm.ondblclick = null;
if (this.getClassName()=='DynDocument') {
elm.releaseEvents(Event.MOUSEMOVE);
elm.onmousemove = null;
}
elm._dynobj = null;
this.doc._dynobj = null;
for (var i=0;i<this.doc.images.length;i++) this.doc.images[i]._dynobji=null;
for (var i=0;i<this.doc.links.length;i++) this.doc.links[i]._dynobj=null;
}
};

View File

@ -1,440 +0,0 @@
/*
DynAPI Distribution
DynObject, DynAPI Object, UserAgent, Library, Functions
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
function DynObject() {
this.id = "DynObject"+DynObject._c++;
DynObject.all[this.id] = this;
};
var p = DynObject.prototype;
p.getClassName = function() {return this._className};
p.getClass = function() {return dynapi.frame[this._className]};
p.isClass = function(n) {return DynObject.isClass(this._className,n)};
p.addMethod = function(n,fn) {this[n] = fn};
p.removeMethod = function(n) {this[n] = null};
p.setID = function(id,isInline,noImports) {
if (this.id) delete DynObject.all[this.id];
this.id = id;
this.isInline=isInline;
this._noInlineValues=noImports;
DynObject.all[this.id] = this;
};
p.toString = function() {return "DynObject.all."+this.id};
DynObject.all = {};
DynObject._c = 0;
DynObject.isClass = function(cn,n) {
if (cn == n) return true;
else {
var c = dynapi.frame[cn];
var p = c.prototype._pClassName;
if (p) return DynObject.isClass(p,n);
else return false;
}
};
function _UserAgent() {
var b = navigator.appName;
var v = this.version = navigator.appVersion;
var ua = navigator.userAgent.toLowerCase();
this.v = parseInt(v);
this.safari = ua.indexOf("safari")>-1; // always check for safari & opera
this.opera = ua.indexOf("opera")>-1; // before ns or ie
this.ns = !this.opera && !this.safari && (b=="Netscape");
this.ie = !this.opera && (b=="Microsoft Internet Explorer");
this.gecko = ua.indexOf('gecko')>-1; // check for gecko engine
if (this.ns) {
this.ns4 = (this.v==4);
this.ns6 = (this.v>=5);
this.b = "Netscape";
}else if (this.ie) {
this.ie4 = this.ie5 = this.ie55 = this.ie6 = false;
if (v.indexOf('MSIE 4')>0) {this.ie4 = true; this.v = 4;}
else if (v.indexOf('MSIE 5')>0) {this.ie5 = true; this.v = 5;}
else if (v.indexOf('MSIE 5.5')>0) {this.ie55 = true; this.v = 5.5;}
else if (v.indexOf('MSIE 6')>0) {this.ie6 = true; this.v = 6;}
this.b = "MSIE";
}else if (this.opera) {
this.v=parseInt(ua.substr(ua.indexOf("opera")+6,1)); // set opera version
this.opera6=(this.v>=6);
this.opera7=(this.v>=7);
this.b = "Opera";
}else if (this.safari) {
this.ns6 = (this.v>=5); // ns6 compatible correct?
this.b = "Safari";
}
this.dom = (document.createElement && document.appendChild && document.getElementsByTagName)? true : false;
this.def = (this.ie||this.dom);
this.win32 = ua.indexOf("win")>-1;
this.mac = ua.indexOf("mac")>-1;
this.other = (!this.win32 && !this.mac);
this.supported = (this.def||this.ns4||this.ns6||this.opera)? true:false;
this.broadband=false;
this._bws=new Date; // bandwidth timer start
// Extended by Raphael Derosso Pereira
this.ua = this.safari ? 'safari' : this.opera ? 'opera' : this.ie ? 'ie' : this.gecko ? 'gecko' : this.ns ? 'ns' : 'unknown';
};
function DynAPIObject() {
this.DynObject = DynObject;
this.DynObject();
this.version = '3.0.0 Beta 1';
this.loaded = false;
this.ua = new _UserAgent();
this._loadfn = [];
this._unloadfn = [];
var f = this.frame = window;
var url = f.document.location.href;
url = url.substring(0,url.lastIndexOf('/')+1);
this.documentPath = url;
var o = this;
this.library = {};
this.library.setPath = function(p) {o.library.path = p};
f.onload = function() {
o.loaded = true;
if (!o.ua.supported) return alert('Unsupported Browser. Exiting.');
if (o.library._create) o.library._create(); // calls dynapi._onLoad() after loading necessary files
else setTimeout(o+'._onLoad()',1);
};
f.onunload = function() {
for (var i=0;i<o._unloadfn.length;i++) o._unloadfn[i]();
if (o.document) {
o.document._destroy();
o.document = null;
}
};
};
p = DynAPIObject.prototype = new DynObject;
p.onLoad = function(f) {
if (typeof(f)=="function") {
if (!this.loaded) this._loadfn[this._loadfn.length] = f;
else f();
}
};
p._onLoad = function(f) {
for (var i=0;i<this._loadfn.length;i++) this._loadfn[i]();
};
p.onUnload = function(f) {
if (typeof(f)=="function") this._unloadfn[this._unloadfn.length] = f;
};
p.setPrototype = function(sC,sP) {
var c = this.frame[sC];
var p = this.frame[sP];
if ((!c || !p) && this.ua.ns4 && this.library && this.library.elm) {
if (!c) c = this.library.elm[sC];
if (!p) p = this.library.elm[sP];
}
if (!c || !p) return alert('Prototype Error');
c.prototype = new p();
c.prototype._className = sC;
c.prototype._pClassName = sP;
c.toString = function() {return '['+sC+']'};
return c.prototype;
};
var dynapi = new DynAPIObject();
dynapi.ximages={'__xCnTer__':0}; // eXtensible Images
p._imageGetHTML=function(){
t= '<img src="'+this.src+'"'
+((this.width)? ' width="'+this.width+'"':'')
+((this.height)? ' height="'+this.height+'"':'')
+' border="0">';
return t;
};
dynapi.functions = {
removeFromArray : function(array, index, id) {
// This seems to be wrong!
// Commented out by Raphael Derosso Pereira
//var which=(typeof(index)=="object")?index:array[index];
var which = index;
if (id) delete array[which.id];
else for (var i=0; i<array.length; i++) {
if (array[i]==which) {
if(array.splice) array.splice(i,1);
else {
for(var x=i; x<array.length-1; x++) array[x]=array[x+1];
array.length -= 1;
}
break;
}
}
return array;
},
removeFromObject : function(object, id) {
if(!dynapi.ua.opera) delete object[id];
else {
var o={};
for (var i in object) if(id!=i) o[i]=object[i];
object=o;
}
return object;
},
True : function() {return true},
False : function() {return false},
Null : function() {},
Zero : function() {return 0;},
Allow : function() {
event.cancelBubble = true;
return true;
},
Deny : function() {
event.cancelBubble = false;
return false;
},
getImage : function(src,w,h) {
img=(w!=null&&h!=null)? new Image(w,h) : new Image();
img.src=src;
img.getHTML=dynapi._imageGetHTML;
return img;
},
getURLArguments : function(o) { // pass a string or frame/layer object
var url,l={};
if (typeof(o)=="string") url = o;
else if (dynapi.ua.ns4 && o.src) url = o.src;
else if (o.document) url = o.document.location.href;
else return l;
var s = url.substring(url.indexOf('?')+1);
var a = s.split('&');
for (var i=0;i<a.length;i++) {
var b = a[i].split('=');
l[b[0]] = unescape(b[1]);
}
return l;
},
getAnchorLocation : function(a,lyr){
var o,x=0,y=0;
if(lyr && !lyr.doc) lyr=null;
lyr=(lyr)? lyr:{doc:document,elm:document};
if(typeof(a)=='string') {
if(lyr.doc.all) a=lyr.doc.all[a];
else if(lyr.doc.getElementById) a=lyr.doc.getElementById(a);
else if(lyr.doc.layers) a=lyr.doc.anchors[a];
}
if(a) o=a;
else return;
if(lyr.doc.layers) { y+=o.y; x+=o.x;}
else if(lyr.doc.getElementById || lyr.doc.all){
while (o.offsetParent && lyr.elm!=o){
x+= o.offsetLeft;y+= o.offsetTop;
o = o.offsetParent;
}
}
return {x:x,y:y,anchor:a};
}
};
dynapi.documentArgs = dynapi.functions.getURLArguments(dynapi.frame);
dynapi.debug = {};
dynapi._debugBuffer = '';
dPrint=function(s){var d=dynapi.debug; d.print(s)};
dynapi.debug.print = function(s) {
//@IF:DEBUG[
if(s==null) s='';
dynapi._debugBuffer += s + '\n';
//]:DEBUG
};
// The DynAPI library system is optional, this can be removed if you want to include other scripts manually
function DynAPILibrary() {
this.DynObject = DynObject;
this.DynObject();
// list of js files: this.scripts['../src/api/dynlayer_ie.js'] = {dep, objects, pkg, fn};
this.scripts = {};
// list of package names: this.packages['dynapi.api'] = dynapi.api = {_objects,_path}
this.packages = {};
// list of object names: this.objects['DynLayer'] = this.scripts['../src/api/dynlayer_ie.js']
this.objects = {};
this._c = 0;
this.loadList = [];
this.loadIndex = -1;
this.path = null;
this.busy = true;
};
p = dynapi.setPrototype('DynAPILibrary','DynObject');
// can return a path specific to a package, eg. dynapi.library.getPath('dynapi.api') returns '/src/dynapi/api/'
p.getPath = function(pkg) {
if (!pkg) pkg = 'dynapi';
if (this.packages[pkg]) return this.packages[pkg]._path;
return null;
};
// set dynapi path
p.setPath = function(p,pkgFile) {
this.path = p;
// to-do: rearrange so add()'s can be done before setPath
// full paths will then be determined when queued
// need an extra argument on addPackage to specify whether the path is relative to this.path or not
// OR: add functionality so that these package definitions can be loaded/included on the fly
// load pkgFile or 'ext/packages.js' file
var s='<script type="text/javascript" language="JavaScript" src="'
+((pkgFile)? pkgFile:p+'ext/packages.js')+'"><\/script>';
document.write(s);
};
// adds package(s) to the library
p.addPackage = function(pkg, path) {
var ps;
if (pkg.indexOf('.')) ps = pkg.split('.');
else ps = [pkg];
var p = dynapi.frame;
for (var i=0;i<ps.length;i++) { // returns the package object (eg. dynapi.api), or creates it if non-existant
if (!p[ps[i]]) p[ps[i]] = {};
p = p[ps[i]];
}
this.packages[pkg] = p;
p._objects = [];
p._path = path;
return p;
};
// add object(s) to the library
p.add = function(name, src, dep, relSource) {
var objects = typeof(name)=="string"? [name] : name;
dep = (!dep)? [] : typeof(dep)=="string"? [dep] : dep;
var s,p,pkg;
if (objects[0].indexOf('.')) {
pkg = objects[0].substring(0,objects[0].lastIndexOf('.'));
if (pkg && this.packages[pkg]) {
p = this.packages[pkg];
if (relSource!=false) src = p._path + src;
}
}
if (!this.scripts[src]) s = this.scripts[src] = {};
else s = this.scripts[src];
s.objects = [];
s.dep = dep;
s.rdep = [];
s.src = src;
s.pkg = pkg;
s.loaded = false;
s.fn = null;
var n;
for (var i=0;i<objects.length;i++) {
n = objects[i];
if (pkg) n = n.substring(n.lastIndexOf('.')+1);
this.objects[n] = s;
s.objects[s.objects.length] = n;
if (p) p._objects[p._objects.length] = n;
}
return s;
};
// adds a dependency, whenever object "n" is loaded it will load object "d" beforehand
p.addBefore = function(n, d) {
var s = this.objects[n];
if (s && this.objects[d]) s.dep[s.dep.length] = d;
};
// adds a reverse dependency, whenever object "n" is loaded it will load object "r" afterword
p.addAfter = function(n, r) {
var s = this.objects[n];
if (s && this.objects[r]) s.rdep[s.rdep.length] = r;
};
// returns a list of js source filenames to load
p._queue = function(n, list, force) {
var na=[], names=[],o;
if (list==null) list = [];
if (typeof(n)=="string") na = [n];
else na = n;
for (var i=0;i<na.length;i++) {
o = na[i];
if (typeof(o)=="string") {
if (this.packages[o])
for (var j in this.packages[o]._objects)
names[names.length] = this.packages[o]._objects[j];
else names[names.length] = o;
}
else if (typeof(o)=="object" && o.length) {
list = this._queue(o, list, force);
}
}
var s;
for (var j=0;j<names.length;j++) {
s = this._queueObject(names[j], force);
if (s) {
if (s.dep)
for (var i=0;i<s.dep.length;i++)
list = this._queue(s.dep[i], list, force);
list[list.length] = s.src;
// also include reverse deps
if (s.rdep.length) list = this._queue(s.rdep, list, force);
}
}
return list;
};
// determines whether to queue the script this object is in
p._queueObject = function(n, f) {
if (n.indexOf('.')) {
var pkg = n.substring(0,n.lastIndexOf('.'));
if (this.packages[pkg]) n = n.substring(n.lastIndexOf('.')+1);
}
var s = this.objects[n];
if (s) {
if (!s.queued) {
if (f!=true && s.loaded) dynapi.debug.print('Library Warning: '+n+' is already loaded');
else {
s.queued = true;
s.loaded = false;
return s;
}
}
}
else dynapi.debug.print('Library Error: no library map for '+n);
return false;
};
// writes the <script> tag for the object
p.include = function() {
var a = arguments;
if (a[0]==true) a=a[1]; // arguments used ONLY by packages.js
// buffer includes until packages(.js) are loaded
if (!this._pakLoaded) {
if(!this._buffer) this._buffer=[];
this._buffer[this._buffer.length]=a;
return;
}
if (dynapi.loaded) this.load(a);
else {
var list = this._queue(a);
var src;
for (var i=0;i<list.length;i++) {
src = list[i];
this.scripts[src].loaded = true;
dynapi.frame.document.write('<script type="text/javascript" language="JavaScript" src="'+src+'"><\/script>');
}
}
};
p.load = p.reload = p.loadScript = p.reloadScript = function(n) {
dynapi.debug.print('Warning: dynapi.library load extensions not included');
};
dynapi.library = new DynAPILibrary();
// deprecated
var DynAPI = dynapi;

View File

@ -1,27 +0,0 @@
<html>
<head>
<title>Blueprint Output</title>
</head>
<body>
<!-- Used by the generateBluePrint() function -->
<form method="POST" action="--WEBBOT-SELF--" name="frm">
<div align="center">
<center>
<table border="0">
<tr>
<td align="center"><font color="#000080" size="5"><b>DynAPI
Blueprint</b></font></td>
</tr>
<tr>
<td align="center"><textarea rows="14" name="txtout" cols="54" wrap="off">Loading... Pleas wait</textarea></td>
</tr>
<tr>
<td align="center"><input type="button" value="Close window" name="cmdclose" onclick="window.close()"></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>

View File

@ -1,136 +0,0 @@
<html>
<title>DynAPI Debugger</title>
<head>
<script>
function handleError(msg, url, lno) {
if (!(dynapi && dynapi.debug)) alert(msg);
else dynapi.debug.error(msg, "Debugger", lno);
};
var dynapi
var dform
var win = this;
var lastCaller=window.opener;
var imgwatch,imgnormal,imghelp,imginspect,imgreload;
var imgclear,imgeval,imgnext,imgprev;
win.onload = function() {
// move the debug window to the right edge?
//dynapi.debug.win.clientWidth = 200;
//win.document.body.style.width = 200; //clientWidth=200
//alert(win.setSize)
//alert(win.document.body.clientWidth)
var w = dynapi.ua.mac? (dynapi.ua.ie?330:300) : 360;
if (dynapi.ua.ie) {
var f = dynapi.frame;
var b = f.document.body;
var x = Math.min(f.screenLeft+b.clientWidth+20,screen.width-w-10);
dynapi.debug.win.moveTo(x,f.screenTop-50);
}
else if (dynapi.ua.ns4) {
var f = dynapi.frame;
var x=f.screenX+f.outerWidth;
var y=f.screenY+50;
dynapi.debug.win.moveTo(x,y);
}else{
dynapi.debug.win.moveTo(100,100)
}
dform=document.forms['debugform'];
dynapi.debug.print();
dynapi.debug.setEvaluate();
window.setTimeout('window.onfocus = setFocus;',500);
}
function NullFn(){}; // null function
function setFocus(){
dynapi={'_imageHook':NullFn};
if(window.opener) dynapi = window.opener.dynapi;
if(dynapi && dynapi.debug) {
if(!dynapi.debug.win) dynapi.debug.win=win;
var url = dynapi.documentPath+dynapi.library.path+'ext/';
var f=dynapi.functions;
imgwatch=f.getImage(url+'images/debug_imgwatch.gif',25,22,{alias:"DebugIMGWatch",name:"DebugIMGWatch",downsrc:url+"images/debug_imgwatch_down.gif",oversrc:url+"images/debug_imgwatch_on.gif",onclick:"dynapi.functions.False(dynapi.debug.switchMode('watch'))",tooltip:"Show Watch Mode"}).getHTML();
imgnormal=f.getImage(url+'images/debug_imgnormal.gif',25,22,{alias:"DebugIMGNormal",name:"DebugIMGNormal",downsrc:url+"images/debug_imgnormal_down.gif",oversrc:url+"images/debug_imgnormal_on.gif",onclick:"dynapi.functions.False(dynapi.debug.switchMode('normal'))",tooltip:"Show Normal Mode"}).getHTML();
imginspect=f.getImage(url+'images/debug_imginspect.gif',80,22,{alias:"DebugIMGInspect",name:"DebugIMGInspect",oversrc:url+"images/debug_imginspect_on.gif",onclick:"dynapi.functions.False(dynapi.debug.inspect(dynapi.debug.win.document.debugform.inspect.value))",tooltip:"Inspect Variable/Object",hspace:1}).getHTML();
imgreload=f.getImage(url+'images/debug_imgreload.gif',25,22,{alias:"DebugIMGReload",name:"DebugIMGReload",oversrc:url+"images/debug_imgreload_on.gif",onclick:"dynapi.functions.False(dynapi.debug.reload(dynapi.debug.win.document.debugform.reload.value))",tooltip:"Load/Reload DynAPI Packages, HTML Pages and JavaScript (.js) files",hspace:1}).getHTML();
imgclear=f.getImage(url+'images/debug_imgclear.gif',46,22,{alias:"DebugIMGClear",name:"DebugIMGClear",oversrc:url+"images/debug_imgclear_on.gif",onclick:"dynapi.functions.False(dynapi.debug.reset());",tooltip:"Clear debug window",hspace:1}).getHTML();
imgeval=f.getImage(url+'images/debug_imgeval.gif',100,22,{alias:"DebugIMGEval",name:"DebugIMGEval",oversrc:url+"images/debug_imgeval_on.gif",onclick:"dynapi.functions.False(dynapi.debug.evaluate(dynapi.debug.win.document.debugform.eval.value));",tooltip:"Evalute JavaScript",hspace:2}).getHTML();
imgnext=f.getImage(url+'images/debug_imgnext.gif',25,22,{alias:"DebugIMGNext",name:"DebugIMGNext",oversrc:url+"images/debug_imgnext_on.gif",onclick:"dynapi.functions.False(dynapi.debug.getEvalHistory(1))",tooltip:"Forward",hspace:1}).getHTML();
imgprev=f.getImage(url+'images/debug_imgprev.gif',25,22,{alias:"DebugIMGPrev",name:"DebugIMGPrev",oversrc:url+"images/debug_imgprev_on.gif",onclick:"dynapi.functions.False(dynapi.debug.getEvalHistory(-1))",tooltip:"Backward",hspace:1}).getHTML();
imghelp=f.getImage(url+'images/debug_imghelp.gif',25,22,{alias:"DebugIMGHelp",name:"DebugIMGHelp",downsrc:url+"images/debug_imghelp_down.gif",oversrc:url+"images/debug_imghelp_on.gif",onclick:"dynapi.functions.False(dynapi.debug.showHelp())",tooltip:"Quick Help",hspace:1}).getHTML();
}
// if main window was closed then create a dynapi._imageHook() function
// this will disable image roller and clicks
if(!dynapi) dynapi={'_imageHook':NullFn};
}
// set focus to debug window
setFocus();
if (!dynapi.ua.ns6) self.onerror = handleError;
// write out debug style
if(!dynapi.ua.ns4){
document.write('<style type="text/css">\n'
+'BODY {\n'
+' border-width:1px;\n'
+' border-style:solid;\n'
+' border-color:#000000;\n'
+'}\n'
+'.debugtextbox {\n'
+' border-width:1;\n'
+' border-style:solid;\n'
+' border-color:#3399CC;\n'
+'}\n'
+'.textinspect{width:90px;}'
+'.textreload{width:130px;}'
+'.textprint{width:100%; height:100%;}'
+'.textstat{width:100%;}'
+'.texteval{width:100%;height:132px;}'
+'.cboprev{width:100%;}'
+'</style>');
}
</script>
</head>
<body bgcolor="#0033CC" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" scrolling=no style="overflow:hidden">
<!--D4D0C8-->
<script>
var ua=dynapi.ua;
var url = dynapi.documentPath+dynapi.library.path+'ext/';
var str = ua.ie?"Internet Explorer":(ua.ns?"Netscape":(ua.moz?"Mozilla":ua.b));
var status = 'DynAPI '+dynapi.version+' ['+str+' '+dynapi.ua.v+']';
var s=0;h=[];
h[s++]='<form name="debugform"><div align="center"><center><font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" size="1">\n';
h[s++]='<table border="0" bgcolor="#EFEBDE" cellpadding="0" cellspacing="0" width="100%" height="100%">\n';
h[s++]='<tr><td colspan="2" bgcolor="#0033CC"><table border="0" width="100%" cellspacing="0" cellpadding="0">\n';
h[s++]='<tr><td width="50%" nowrap><b><font size="2" color="#FFFFFF" face="Arial"><span style="cursor:default"><img border="0" src="'+url+'images/debug_icon.gif" align="absmiddle" width="32" height="32">&nbsp;DynAPI Debugger</span></font></b></td>\n';
h[s++]='<td width="50%" bgcolor="#0033CC"><table border="0" width="100%"><tr><td width="100%" align="right">\n';
h[s++]='<font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" size="1">'+imgwatch+' '+imgnormal+' '+imghelp+'</font></td></tr>\n';
h[s++]='</table></td></tr></table></td></tr>\n';
h[s++]='<tr><td colspan="2"><table border="0" cellspacing="0"><tr><td valign="middle">\n';
h[s++]='<input type="text" name="inspect" size="10" class="debugtextbox textinspect"></td><td>'+imginspect+'</td><td>\n';
h[s++]='<input type="text" name="reload" size="15" class="debugtextbox textreload"></td><td>'+imgreload+'</td></tr></table></td></tr><tr><td align="center" colspan="2">\n';
h[s++]='<textarea name="print" rows="11" cols="40" class="debugtextbox textprint" wrap="off"></textarea></td></tr>\n';
h[s++]='<tr><td nowrap><table border="0" cellspacing="0"><tr><td>\n';
h[s++]='<font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" size="1">'+imgclear+'</font></td><td>\n';
h[s++]='<font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" size="1">'+imgeval+'</font></td><td align="right">\n';
h[s++]='<font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" size="1">'+imgprev+'</font></td><td align="right">\n';
h[s++]='<font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" size="1">'+imgnext+'</font></td></tr></table>\n';
h[s++]='</td><td nowrap align="center"><font size="2" face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" color="#000000">JavaScript&nbsp;</font>\n';
h[s++]='</td></tr><tr><td align="center" colspan="2">\n';
h[s++]='<textarea name="eval" rows="7" cols="40" class="debugtextbox texteval" wrap="off"></textarea></td></tr>\n';
h[s++]='<tr><td align="center" colspan="2">\n';
h[s++]='<input type="text" name="stat" size="42" '+(dynapi.ua.mac? 'style="font-family:Monaco"':'')+' value="'+status+'" class="debugtextbox textstat"></td>\n';
h[s++]='</tr></table></font></center></div></form>\n';
document.open();
document.write(h.join(''));
document.close();
</script>
</body>
</html>

View File

@ -1,256 +0,0 @@
/*
DynAPI Distribution
Debugger
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
// Note: Debugger does not have to be a DynObject - very important for blueprinted layers
function Debugger() {
this._mode='normal';
this.win = null;
this._watch={};
this._evalBuffer='';
this._buffer = dynapi._debugBuffer;
dynapi._debugBuffer = '';
// close the debug window on unload
this.closeOnUnLoad = false;
dynapi.onUnload(function() {
if (dynapi.debug.closeOnUnLoad) dynapi.debug.close();
});
this.open();
}
var p = Debugger.prototype; //dynapi.setPrototype('Debugger','DynObject');
p.close = function() {
if (this.isLoaded()) {
this.win.close();
this.win = null;
}
};
// error - output a browser generated error to the debug window
p.error = function(msg, url, lno) {
if (url && url.indexOf(dynapi.documentPath)==0) {
url = url.substring(dynapi.documentPath.length);
}
this.print('Error:'+ (lno? ' Line '+lno : '') +' ['+url+']\n '+msg);
};
// evaluates an expression in the scope of the main dynapi window
p.evaluate = function(str) {
dynapi.frame.eval(str);
this.setEvalHistory(str);
};
// get evaluation history
p.getEvalHistory=function(n){
if(!this.isLoaded()) return;
var t,f=this.win.document.debugform;
if(n>=1) {
var lim=this.win.evalHistory.length-1;
this.win.evalIndex++;
if (this.win.evalIndex>lim) this.win.evalIndex=(lim<0)?0:lim;
t=this.win.evalHistory[this.win.evalIndex];
if(t)f.eval.value=t;
}else if(n<=0){
this.win.evalIndex--;
if(this.win.evalIndex<0) this.win.evalIndex=0;
t=this.win.evalHistory[this.win.evalIndex];
if(t)f.eval.value=t;
}
};
// lists all known properties of an object
p.inspect = function(obj,showFunctions) {
this.print('Inspecting:');
var v;
if (typeof(obj)=='string') obj=eval(obj);
if (typeof(obj)=='object') {
for (var i in obj) {
if (obj[i]==null) v = 'null'
else if (typeof(obj[i])=='undefined') v = 'null';
else if (typeof(obj[i])=='function') {
if (showFunctions==false) continue;
else v = '[Function]';
}
else if (typeof(obj[i])=='object' && typeof(obj[i].length)!='undefined') v = 'Array';// ['+obj[i]+']';
else if (typeof(obj[i])=='object') v = '[Object]';
else v = obj[i];
this.print(' '+i+' = '+v);
}
}
else this.print(' undefined');
};
p.isLoaded = function() {
return (this.win!=null && this.win.document && typeof(this.win.document.debugform)=="object");
};
// opens the debugger window
p.open = function() {
var p = dynapi.library.path;
if (!this.isLoaded() && p) {
// Modified by Raphael Pereira
//var url = dynapi.documentPath+p+'ext/debug.html#';
var url = p+'ext/debug.html#';
var w = (dynapi.ua.def||dynapi.ua.dom)? 350:355 //dynapi.ua.mac? (dynapi.ua.ie?330:300) : 350;
var h = (dynapi.ua.def||dynapi.ua.dom)? 432:485 //dynapi.ua.mac? (dynapi.ua.ie?405:365) : (dynapi.ua.def||dynapi.ua.dom)? 420:476;
this.win = window.open(url,'debugwin','width='+w+',height='+h+',scrollbars=no,status=no,toolbar=no'); //,resizable=no
this.win.opener=window;
this.win.evalHistory=[];
this.win.evalIndex=0;
this.print();
/* dynapi.frame.onerror = function(msg, url, lno) {
dynapi.debug.error(msg, url, lno);
};
*/
}
};
// output text to the debug window
p.print = function(s) {
if (s==null) s = '';
else s = s + '\n';
if (this.isLoaded()) {
this.switchMode('normal');
if (this._buffer != '') { // dump buffer
s = this._buffer + s;
this._buffer = '';
}
this.win.document.debugform.print.value += s;
this._normalModeData = this.win.document.debugform.print.value;
// Does mozilla has something like this?
if (dynapi.ua.ie) {
var po = this.win.document.debugform.print;
po.scrollTop = po.scrollHeight;
var range = po.createTextRange();
range.collapse(false);
range.select();
}
}
else this._buffer += s;
};
// reloads selected javascripts, packages or html pages
p.reload=function(t){
if (!this.isLoaded) return;
t=t+'';
if(t.substr(0,3).toLowerCase()=='go:') {
t=t.substr(3).replace(/\\/g,'/');
dynapi.frame.location.href=t;
return;
}
var i,f=t.split(';');
for(i=0;i<f.length;i++){
t=f[i];
if(t.indexOf('.js')<0) dynapi.library.load(t,null,true);
else {
var lib=dynapi.library;
if (!lib.scripts[t]) lib.loadScript(t);
else lib.reloadScript(t,null,true);
}
}
if(this.win.focus) this.win.focus();
else this.win.setZIndex({topmost:true});
};
p.reset=function(section){
if (!this.isLoaded) return;
this._oldWatchSrc='';
if(!section) {
this.win.document.debugform.reset();
this._normalModeData='';
this.switchMode('normal');
}else{
var t=this.win.document.debugform[section];
if(t) t.value='';
}
};
p.status = function(str) {
if (this.isLoaded()) {
for (var i=1;i<arguments.length;i++) {
str += ', '+arguments[i];
}
this.win.document.debugform.stat.value = str;
};
};
// Set Mode
p.switchMode=function(m){
if (!this.isLoaded) return;
if(m=='watch'||(this._mode=='normal' && m!='normal')) {
this._normalModeData = this.win.document.debugform.print.value;
this._mode='watch';
this._enableWatch();
}else if(m=='normal'||(this._mode=='watch' && m!='watch')){
this.win.document.debugform.print.value=(this._normalModeData)?this._normalModeData:'';
this._mode='normal';
this._disableWatch();
}
};
// enters text to the evaluate field in the debugger widnow
p.setEvaluate = function(str) {
if (!this.isLoaded()) this._evalBuffer=str;
else {
if (!str) str = '';
if(this._evalBuffer!='') {
str =this._evalBuffer+str;
this._evalBuffer='';
}
this.win.document.debugform.eval.value = str;
this.setEvalHistory(str);
}
};
// Set previous evaluation information
p.setEvalHistory=function(s){
if(!this.isLoaded()) return;
var i,found;
if(s){
for(i=0;i<this.win.evalHistory.length;i++){
if(this.win.evalHistory[i]==s) {found=i;break;}
}
if(found!=null) this.win.evalHistory=dynapi.functions.removeFromArray(this.win.evalHistory,found);
this.win.evalHistory[this.win.evalHistory.length]=s;
this.win.evalIndex=this.win.evalHistory.length-1;
}
};
p.showHelp=function(){
var t=''
+'-----------------------\n'
+'Quick Help\n'
+'-----------------------\n'
+'1) To inspect an Object enter the name\n'
+'of the object in the "Inspect Variable/Object"\n'
+'textbox and then click on the "Inspect" button\n\n'
+'2) To Load/Reload a DynAPI Package,\n'
+'javascript or html page enter the name\n'
+'of the package or javascript in the reload\n'
+'text. For HTML pages type the prefix Go:\n'
+'before the page name.\n'
+'------------------------------------------------';
this.print(t);
};
// watch object variables;
p.watch = function(name,value){
if(arguments.length>1) this._watch[name]=value;
else if(dynapi.frame.eval(name)) this._watch[name]='_watch object_';
else this._watch[name]='_watch object_';
};
p._disableWatch = function(){
this._oldWatchSrc='';
if(this._timerWatch) {
window.clearTimeout(this._timerWatch);
this._timerWatch=0;
}
};
p._enableWatch = function(){
if(this._mode!='watch') return;
var src,row,v;
src='Name\t \t \t Value\n---------------------------------------\n';
for(i in this._watch){
if(this._watch[i]=='_watch object_') v=dynapi.frame.eval(i);
else v=this._watch[i];
if(v==null) v='null';
if(typeof(v)=='string') v=v.replace(/\n/g,' ');
src+=(i+' ').substr(0,22)+'\t '+v+'\n';
}
if(src!=this._oldWatchSrc){
this.win.document.debugform.print.value=this._oldWatchSrc=src;
}
if(this._timerWatch) window.clearTimeout(this._timerWatch);
this._timerWatch=window.setTimeout(this+'._enableWatch()',200);
};
dynapi.debug = new Debugger();
var t='------------------------------\n'
+'Click "?" for help\n'
+'------------------------------\n';
dynapi.debug.print(t);

View File

@ -1,94 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.Color extension
*/
var f = dynapi.functions;
f.Color = Color = {}; // used by dynapi.library
// Color Functions ---------------------------
f.DecToHex = function(val){
lo=val%16;
val-=lo;
lo+=48;
if (lo>57) lo+=7;
hi=val/16;
hi+=48;
if (hi>57) hi+=7;
return String.fromCharCode(hi,lo);
};
f.getColor = function(r,g,b) {
return '#'+dynapi.functions.DecToHex(r)+dynapi.functions.DecToHex(g)+dynapi.functions.DecToHex(b);
};
f.getRandomColor = function() {
var s = '';
for (var i=0;i<3;i++) s += dynapi.functions.DecToHex(Math.floor(255*Math.random()));
return s;
};
f.createRedPal = function(pal) {
var r=g=b=0;
for (var i=0; i<256; i++){
pal[i]=dynapi.functions.getColor(r,g,b);
r+=8;
if (r>255) { r=255; g+=6; b+=2; }
if (g>255) { g=255; b+=2; }
if (b>255) { b=255; }
}
};
f.createGrayPal = function(pal) {
var r=0;
for (var i=0; i<256; i++){
pal[i]=dynapi.functions.getColor(r,r,r);
r+=4;
if (r>255) { r=255; }
}
};
f.createBluePal = function(pal){
var r=g=b=0;
for (var i=0; i<256; i++){
pal[i]=dynapi.functions.getColor(r,g,b);
b+=6;
if (b>255) { b=255; g+=2; }
if (g>255) { g=255; r+=2; }
}
};
f.createGreenPal = function(pal) {
var r=g=b=0;
for (var i=0; i<256; i++){
pal[i]=dynapi.functions.getColor(r,g,b);
g+=6;
if (g>255) { g=255; b+=2; }
if (b>255) { b=255; r+=2; }
}
};
f.fadeColor = function(from, to, percent){
if(!from || !to) return;
if(percent<0) return from;
else if(percent>100) to;
if(from.substring(0,1)!='#') from='#'+from;
if(to.substring(0,1)!='#') to='#'+to;
from = {
red:parseInt(from.substring(1,3),16),
green:parseInt(from.substring(3,5),16),
blue:parseInt(from.substring(5,7),16)
}
to = {
red:parseInt(to.substring(1,3),16),
green:parseInt(to.substring(3,5),16),
blue:parseInt(to.substring(5,7),16)
}
var r=from.red+Math.round((percent/100)*(to.red-from.red));
var g=from.green+Math.round((percent/100)*(to.green-from.green));
var b=from.blue+Math.round((percent/100)*(to.blue-from.blue));
r = (r < 16 ? '0' : '') + r.toString(16);
g = (g < 16 ? '0' : '') + g.toString(16);
b = (b < 16 ? '0' : '') + b.toString(16);
return '#' + r + g + b;
};

View File

@ -1,126 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.Date extension
*/
var f = dynapi.functions;
f.Date = {}; // used by dynapi.library
// Date Functions --------------------------------------
f.dateAdd = function(interval,n,dt){
if(!interval||!n||!dt) return;
var s=1,m=1,h=1,dd=1,i=interval;
if(i=='month'||i=='year'){
dt=new Date(dt);
if(i=='month') dt.setMonth(dt.getMonth()+n);
if(i=='year') dt.setFullYear(dt.getFullYear()+n);
}else if (i=='second'||i=='minute'||i=='hour'||i=='day'){
dt=Date.parse(dt);
if(isNaN(dt)) return;
if(i=='second') s=n;
if(i=='minute'){s=60;m=n}
if(i=='hour'){s=60;m=60;h=n};
if(i=='day'){s=60;m=60;h=24;dd=n};
dt+=((((1000*s)*m)*h)*dd);
dt=new Date(dt);
}
return dt;
};
f.dateDiff=function(interval,dt1,dt2){
if(!interval||!dt1||!dt2) return;
var v,s=1,m=1,h=1,dd=1,i=interval;
if(i=='month'||i=='year'){
dt1=new Date(dt1);
dt2=new Date(dt2);
years=dt2.getFullYear()-dt1.getFullYear();
if (i=='year') v=years;
else if(i=='month') {
v=(dt2.getMonth()+1)-(dt1.getMonth()+1);
if(years!=0) v+=(years*12);
}
}else if (i=='second'||i=='minute'||i=='hour'||i=='day'){
dt1=Date.parse(dt1);
dt2=Date.parse(dt2);
if(isNaN(dt1)||isNaN(dt2)) return;
v=dt2-dt1;
if(i=='second') s=1000;
if(i=='minute') s=60000;
if(i=='hour'){s=60000;m=60};
if(i=='day'){s=60000;m=60;h=24;};
v=((((v/s)/m)/h)/dd);
}
return v;
};
f.formatDate = function(date,format){
if(!date) return '';
var dt=new Date(date);
var mm=dt.getMonth();
var dd=dt.getDate();
var day=dt.getDay();
var yyyy=dt.getFullYear();
var hh=dt.getHours();
var nn=dt.getMinutes();
var ss=dt.getSeconds();
var ampm;
var days=['Sunday','Monday','Teusday','Wednesday','Thursday','Friday','Saturday'];
var months=['January','February','March','April','May','June','July','August','September','October','November','December'];
format=(format)? (format+'').toLowerCase():'dddd, mmmm dd, yyyy hh:nn:ss ampm';
format=format.replace('mmmm',months[mm]);
format=format.replace('mmm',months[mm].substr(0,3));
format=format.replace('mm',mm+1);
format=format.replace('dddd',days[day]);
format=format.replace('ddd',days[day].substr(0,3));
format=format.replace('dd',dd);
format=format.replace('yyyy',yyyy);
if(format.indexOf('ampm')>0){
if(hh>12) hh=hh-12;
if(hh<12) ampm='AM';
else ampm='PM';
format=format.replace('ampm',ampm);
}
format=format.replace('hh',hh);
format=format.replace('nn',nn);
format=format.replace('ss',ss);
return format;
};
f.getDayOfYear = function(dt){
dt = new Date(dt);
if(isNaN(dt)) dt = new Date();
var yr = new Date(dt.getFullYear(),0,1);
yr = yr.getTime() - (yr.getDay()-1)*(24*60*60*1000);
return(Math.ceil((dt.getTime() - yr)/(24*60*60*1000)));
};
f.isDate = function(dt,format){
if (!dt) return false;
var dd,mm,yyyy;
var isLeapYear,st=true,delim='/';
dt+='';format=(format)? format+'':'';
if(dt.indexOf('/')>=0) delim='/';
else if(dt.indexOf('-')>=0) delim='-';
else if(dt.indexOf(' ')>=0) delim=' ';
dt=dt.split(delim);
if(format) format=format.replace(/\W/g,'/');
else {
if (dt[0]>=1000) format='yyyy/mm/dd';
else if (dt[0]>=12 && dt[1]<=12) format='dd/mm/yyyy';
else if (dt[0]<=12 && dt[1]>=12) format='mm/dd/yyyy';
};
if(format=='yyyy/mm/dd'){yyyy=dt[0];mm=dt[1];dd=dt[2];}
else if(format=='mm/dd/yyyy'){mm=dt[0];dd=dt[1];yyyy=dt[2];}
else if(format=='dd/mm/yyyy'){dd=dt[0];mm=dt[1];yyyy=dt[2];}
if(isNaN(dd)||isNaN(mm)||isNaN(yyyy)) st=false;
else if(dd<1 || dd>31) st=false;
else if(yyyy>9999) st=false;
else if (mm < 1 || mm > 12) st=false;
else if((mm==4 || mm==6 || mm==9 || mm==11) && dd==31) st=false;
else if(mm==2) { // check for leap year and february 29th
isLeapYear = (yyyy % 4 == 0 && (yyyy % 100 != 0 || yyyy % 400 == 0));
if (dd > 29 || (dd==29 && !isLeapYear)) st=false;
}
return st;
};

View File

@ -1,124 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.Image extension
*/
var f = dynapi.functions;
f.Image = {}; // used by dynapi.library
// Image Functions ---------------------------
f._imgTTL = 30000; // Image Time To Load (ms)
f.getImage = function(src,w,h,params) {
var img,name,p=params;
if(!p) name=src;
else name=(!p.alias)? src:p.alias;
img = dynapi.ximages[name];
if(!img || (img && img.params!=params)){ // if user enters a new set of params then create a new image object
img=dynapi.ximages[name] = (w!=null&&h!=null)? new Image(w,h) : new Image();
img.w=w||null;
img.h=h||null;
img.src=src;img.params=p;
img.getHTML=dynapi._imageGetHTML;
img.reload=dynapi._imageReload;
img.dtStart=new Date();
if(p) {
var f=dynapi.functions;
if(p.oversrc) f.getImage(p.oversrc);
if(p.downsrc) f.getImage(p.downsrc);
}
if(!this._imgTmr && this._imgProgFn) this._imageProgress();
}
return img;
};
f.getFailedImages = function(){
var ar=[];
for(i in dynapi.ximages){
img=dynapi.ximages[i];
if(img && img.failed) ar[ar.length]=img;
}
return ar;
};
f.captureImageProgress=function(fn){ //fn = fn(completed,failed,total);
this._imgProgFn=fn;
this._imageProgress();
};
f._imageProgress = function(){
var i,c=0,f=0,t=0;
var img,dtEnd = new Date;
var fn=this._imgProgFn;
for(i in dynapi.ximages){
img=dynapi.ximages[i];
if(img && img.complete!=null){
t++;
img.failed=(!img.complete && (dtEnd-img.dtStart)>this._imgTTL)? true:false;
if (img.complete) c++;
else if(img.failed) f++;
}
}
if(fn) fn(c,f,t);
if(c+f<t) this._imgTmr=window.setTimeout('dynapi.functions._imageProgress()',100);
else this._imgTmr=0;
};
f.setImageTTL = function(ms){
this._imgTTL=ms;
};
dynapi._imageReload = function(){
var t=this.src;
this.src='';
this.src=t;
this.dtStart=new Date();
this.failed=false;
dynapi.functions._imageProgress();
};
dynapi._imageHookArray={};
dynapi._imageHook=function(anc,id,img,act,iSrc){
var rt,f,tf,p=dynapi._imageHookArray[id];
if(img && iSrc) img.src = iSrc;
if(p) {
f=p['on'+((act!='click')?'mouse':'')+act];tf=typeof(f);
if(f) rt=((tf=='string')? eval(f):f(act,anc,img,iSrc));
if(anc && !dynapi.ua.ns4) anc.blur();
}
return (!rt)? false:rt;
};
dynapi._imageGetHTML=function(params){
var c,i,t,text,dir,xtags='';
var p=(params)? params:{};
var lparams=(this.params)? this.params:{}; // opera can't do a for(i in object) on a null variable?
var forbid =',width,height,alias,src,tooltip,link,text,textdir,'
+'oversrc,downsrc,onclick,onmouseover,onmouseout,onmouseup,onmousedown,';
for(i in lparams) {if(p[i]==null) p[i]=lparams[i]};
if(!p.name) p.name='XImage'+dynapi.ximages['__xCnTer__']++;
if(p.border==null) p.border=0;
// setup width & height
if(this.width && this.w==null) this.w=this.width;
if(this.height && this.h==null) this.h=this.height;
text=p['text']; dir=p['textdir'];
t= '<img src="'+this.src+'"'
+((this.w)? ' width="'+this.w+'"':'')
+((this.h)? ' height="'+this.h+'"':'')
+((p['tooltip'])?' alt="'+p['tooltip']+'"':'');
c='return dynapi._imageHook(this,\''+p.name+'\','+((dynapi.ua.ns4)? '((this._dynobj)? this._dynobj.doc:document)':'document')+'.images[\'';
if(p.onclick) xtags=' onclick="'+c+p.name+'\'],\'click\');"';
if(p.onmouseover||p.oversrc) xtags+=' onmouseover="'+c+p.name+'\'],\'over\',\''+((p.oversrc)?p.oversrc:'')+'\');"';
if(p.onmouseout||p.oversrc) xtags+=' onmouseout="'+c+p.name+'\'],\'out\',\''+((p.oversrc)?this.src:'')+'\');"';
if(p.onmousedown||p.downsrc) xtags+=' onmousedown="'+c+p.name+'\'],\'down\',\''+((p.downsrc)?p.downsrc:'')+'\');"';
if(p.onmouseup||p.downsrc) xtags+=' onmouseup="'+c+p.name+'\'],\'up\',\''+((p.downsrc)?((p.oversrc)?p.oversrc:this.src):'')+'\');"';
if(!p.link && (p.onclick||p.oversrc||p.downsrc)) p.link='javascript:;';
if(!xtags && p.name.indexOf('XImage')==0) p.name=null; // remove name if not needed
for(i in p){if(forbid.indexOf(','+i+',')<0 && p[i]!=null) t+=' '+i+'="'+p[i]+'"';}
t+='>';
if (text){
dir=(dir)?(dir+'').toUpperCase():'E';
if (dir=='N') t=text+'<br>'+t;
else if (dir=='S') t=t+'<br>'+text;
else if (dir=='E') t=t+text;
else if (dir=='W') t=text+t;
}
if(p.link) t='<a title="'+((p.tooltip)? p.tooltip:'')+'" href="'+p['link']+'"'+xtags+'>'+t+'</a>';
if(xtags && p.name) dynapi._imageHookArray[p.name]=p;
return t;
};

View File

@ -1,85 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.Math extension
Math and Path functions
*/
var f = dynapi.functions;
f.Math = {}; // used by dynapi.library
// Math Functions --------------------------
f.radianToDegree = function(radian) {
return radian*180/Math.PI;
};
f.degreeToRadian = function(degree) {
return degree*Math.PI/180;
};
f.sintable = function(lsin) {
for (var i=0; i<361; i+=1) lsin[i]=Math.sin((i/180)*Math.PI);
};
f.costable = function(lcos) {
for (var i=0; i<361; i+=1) lcos[i]=Math.cos((i/180)*Math.PI);
};
f.getRandomNumber = function(n) {
var t=new Date();
n=(n)? n: parseInt(Math.random()*10000);
return Math.round((Math.abs(Math.sin(t.getTime()))*(Math.random()*1000)))%n+1;
};
f.getGUID = function() { // Globally Unique ID
var n1,n2,n3,n4;
var l,r,m,c=Math.random()+'';
c=c.substr(c.indexOf('.')+1);
m=(c.length-1)/2;
l=c.substr(0,m); r=c.substr(m);
n1=this.getRandomNumber(1000);
n2=this.getRandomNumber(255);n3=this.getRandomNumber(255);n4=this.getRandomNumber(255);
n2 = (n2 < 16 ? '0' : '') + n2.toString(16);
n3 = (n3 < 16 ? '0' : '') + n3.toString(16);
n4 = (n4 < 16 ? '0' : '') + n4.toString(16);
return (n1+n2+'-'+l+'-'+n3+n4+'-'+r).toUpperCase();
};
// Path Functions ------------------------
// Combines separate [x1,x2],[y1,y2] arrays into a path array [x1,y1,x2,y2]
f.interlacePaths = function (x,y) {
var l = Math.max(x.length,y.length);
var a = new Array(l*2);
for (var i=0; i<l; i++) {
a[i*2] = x[i];
a[i*2+1] = y[i];
}
return a;
};
// Returns correct angle in radians between 2 points
f.getNormalizedAngle = function (x1,y1,x2,y2) {
var distx = Math.abs(x1-x2);
var disty = Math.abs(y1-y2);
if (distx==0 && disty==0) angle = 0;
else if (distx==0) angle = Math.PI/2;
else angle = Math.atan(disty/distx);
if (x1<x2) {
if (y1<y2) angle = Math.PI*2-angle;
}
else {
if (y1<y2) angle = Math.PI+angle;
else angle = Math.PI-angle;
}
return angle;
};
// Generates a path between 2 points in N steps
f.generateLinePath = function(x1,y1,x2,y2,N) {
if (N==0) return [];
var dx = (x2 == x1)? 0 : (x2 - x1)/N;
var dy = (y2 == y1)? 0 : (y2 - y1)/N;
var path = new Array();
for (var i=0;i<=N;i++) {
path[i*2] = Math.round(x1 + i*dx);
path[i*2+1] = Math.round(y1 + i*dy);
}
return path;
};

View File

@ -1,83 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.Numeric extension
*/
var f = dynapi.functions;
f.Numeric = Numeric = {}; // used by dynapi.library
// Numeric Function ---------------------------------
f.formatNumber = function(n,format){
if(isNaN(n)) return;
var i,c,f,comma,symbol='',sign='',decimals='',integers='';
var fInt,fDec,nInt,nDec,len=0,cnt=0;
if(n<0) sign='-';
n+='';if(sign) n=n.replace('-','');
format=(format)? format+'':'#,##0.00';
if(format.indexOf(',')>=0) comma=',';
if(format.indexOf('$')>=0) symbol='$';
else if(format.indexOf('%')>=0) symbol='%';
s=format.split('.');
fInt=((s[0]==''||s[0]==null||s[0]=='undefinded')? '':s[0]);
fInt=fInt.split('').reverse().join('');
fDec=(s[1]==''||s[1]==null||s[1]=='undefinded')? '':s[1];
s=n.split('.');
nInt=((s[0]==''||s[0]==null||s[0]=='undefinded')? '':s[0]);
nInt=nInt.split('').reverse().join('');;
nDec=(s[1]==''||s[1]==null||s[1]=='undefinded')? '':s[1];
if (nInt) len=nInt.length;
if (fInt.length>len) len=fInt.length;
for(i=0;i<len;i++){
c=nInt.charAt(i);
f=fInt.charAt(i);
cnt++;
if (cnt==4 && comma && (c||f=='0')) integers+=comma;
if(f=='0' && !c) integers+='0';
else if(c) integers+=c;
if (cnt==4) cnt=1;
}
if(fDec) len=fDec.length;
for(i=0;i<len;i++){
c=nDec.charAt(i);
f=fDec.charAt(i);
if(f=='0' && !c) decimals+='0';
else if((f=='#' || f=='0') && c) decimals+=c;
}
f=((integers+'').split('').reverse().join(''))+((decimals)? '.'+decimals:'');
if(symbol=='%') f+=symbol;
else f=symbol+f;
return sign+f;
};
f.isFloat=function(n){
if(typeof(n)=='number' && (n+'').indexOf('.')>=0) return true;
else return false;
};
f.isInteger=function(n){
if(typeof(n)=='number' && (n+'').indexOf('.')<0) return true;
else return false;;
};
f.toInteger=function(dt){
var vl;
if(!dt) return 0;
if(isNaN(dt)) vl=parseInt((dt+'').replace(/\,/g,''));
else vl= parseInt(dt);
if (isNaN(vl)) vl = 0;
return vl;
};
f.toFloat=function(dt){
var vl;
if(!dt) return 0;
if(isNaN(dt)) vl=parseFloat((dt+'').replace(/\,/g,''));
else vl = parseFloat(dt);
if (isNaN(vl)) vl = 0;
return vl;
};
f.toBoolean = function(dt) {
return (dt=='true'||dt>=1)? true:false;
};
f.isNumeric = function (n)
{
var nReg = new RegExp('[-][[:digit:]]');
}

View File

@ -1,115 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.String extension
*/
var f = dynapi.functions;
f.String = {}; // used by dynapi.library
// String Functions --------------------------------
f.sprintf = function(t){
var ar = arguments;
var i=1,inx = t.indexOf("%s");
while(inx>=0){
t = t.substr(0, inx) + ar[i++] + t.substr(inx+2);
inx = t.indexOf("%s");
}
return t;
};
f.strRepeat = function(s,n) {
if(!s) return '';
var i,a=[];
for(i=1;i<=n;i++){
a[a.length]=s;
}
return a.join('');
};
f.strReverse = function(s) {
if(!s) return '';
var a=(s+'').split('');
a.reverse();
return a.join('');
};
f.strStuff = function(s,v,index) {
if(!s) return '';
if (index==null) s=s+v+'';
else {
var t1=t2=s+'';
s=t1.substr(0,index)+v+t2.substr(index,t2.length-index);
}
return s;
};
f.trim = function(s,dir){
if(!s) return;
else s+=''; // make sure s is a string
dir=(dir)? dir:'<>';
if(dir=='<'||dir=='<>') s=s.replace(/^(\s+)/g,'');
if(dir=='>'||dir=='<>') s=s.replace(/(\s+)$/g,'');
return s;
};
f.limitString = function (s,max)
{
if (!s) return s;
else s+='';
// Do not process HTML tags \\
var tag = new RegExp(/[<][^>]*[>]/g);
var special = new RegExp(/[&][^;]*;/g);
var m, count=0;
var tags = new Array();
var specials = new Array();
var r_s = s.replace(/[<][^>]*[>]/g,'\xFE').replace(/[&][^;]*;/g,'\xFF');
while (m = tag.exec(s))
{
tags[tags.length] = m[0];
max++;
}
while (m = special.exec(s))
{
specials[specials.length] = m[0];
max += 2;
}
var i;
var count = 0;
var r_final = '';
for (i=0; i<r_s.length;i++)
{
if (r_s[i] == '\xFF')
{
r_final += r_s.charAt(i);
}
else if (r_s[i] == '\xFE')
{
r_final += r_s.charAt(i);
count++;
}
else if (count <= max)
{
r_final += r_s.charAt(i);
count++;
}
}
if (count > max)
{
r_final += '...';
}
for (i=0; i<tags.length; i++)
{
r_final = r_final.replace(/\xFE/,tags[i]);
}
for (i=0; i<specials.length; i++)
{
r_final = r_final.replace(/\xFF/,specials[i]);
}
return r_final;
}

View File

@ -1,87 +0,0 @@
/*
DynAPI Distribution
dynapi.functions.System extension
*/
var f = dynapi.functions;
f.System = System = {}; // used by dynapi.library
// System Functions ---------------------------------
f.coalesce=function(){
var a,i;
for(i=0;arguments.length;i++){
a=arguments[i];
if(a!=null && a!='' && a!=undefined) return a;
}
}
f.choose = function(index){
if(isNaN(index)) return;
if (arguments.length>index) return arguments[index+1];
};
f.cloneObject = function(src) {
if(!src) return;
var i,tar;
if(typeof(src)!='object') return src;
else {
if((src.constructor+'')==(Array+'')) tar=[];
else if((src.constructor+'')==(Date+'')) return src;
else tar={};
};
for(i in src) {
if(typeof(src[i])!='object') tar[i]=src[i];
else tar[i]=this.cloneObject(src[i]);
}
return tar;
};
f.copyObject = function(from,to,noclone) {
var i;
if (to && !noclone) to=this.cloneObject(to);
else if(to && noclone) to=to;
else {
if(typeof(from)=='object') {
if((from.constructor+'')==(Array+'')) to=[];
else if((from.constructor+'')==(Date+'')) return from;
else to={};
};
}
for(i in from) {
if(typeof(from[i])!='object') to[i]=from[i];
else to[i]=this.copyObject(from[i],to[i],true);
}
return to;
};
f.getElementById = function(id,parentLyr){
if (document.all) return document.all[id];
else if(document.getElementById) return document.getElementById(id);
else if(document.layers){
var i,nLayers,layer;
parentLyr = (parentLyr)? parentLyr:document;
nLayers = parentLyr.layers;
for (i=0;i<nLayers;i++){
layer=nLayers[i];
if (layer.id == id) return layer;
else if (layer.layers.length){
layer = this.getElementById(id,layer);
if (layer) return layer;
}
}
}
};
f.isNull=function(value,_default){
if(value==null||value==''||value=='undefined') return _default;
else return value;
};
f.lookUp = function(value,array){
var i; if(!array) return;
for(i=0;i<array.length;i++){
if(value==array[i]) return i;
}
};
f.nullIf = function(){
var a,i;
for(i=0;arguments.length;i++){
a=arguments[i];
if(a!=null && a!='' && a!=undefined) return null;
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 962 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,3 +0,0 @@
<script>
dynapi.library._handleLoad(this);
</script>

View File

@ -1,232 +0,0 @@
/*
DynAPI Distribution
Dynamic Loading extension to dynapi.library
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
// begin loading the object
DynAPILibrary.prototype.load = function(n,fn) {
var list = this._queue(n,null,arguments[2]);
//return dynapi.debug.print('going to load: '+list);
if (list.length) {
var s,src;
for (var i=0;i<list.length;i++) {
src = list[i];
s = this.scripts[list[i]];
if (i==list.length-1 && fn!=null) s.fn = fn;
this.loadList[this.loadList.length] = src;
}
this._load();
}
else if (fn) fn();
};
// reload the object
DynAPILibrary.prototype.reload = function(n,fn,force) {
var s = this.objects[n];
if (s) {
s.loaded = false;
this.load(n,fn,force);
}
};
// load a script that is not added to the library
DynAPILibrary.prototype.loadScript = function(src,fn) {
if (!this.scripts[src]) {
var n = 'unnamed'+this._c++;
s = this.add(n,src); // generate a name for the script
s.unnamed = true;
s.fn = null;
s.dep = [];
this.load(n,fn);
}
};
// reload a script
DynAPILibrary.prototype.reloadScript = function(src,fn,force) {
var s=this.scripts[src];
if(s) this.load(s.objects[0],fn,force);
}
// inserts the script element into the page
DynAPILibrary.prototype._load = function() {
if (this.busy) return; // dynapi.debug.print('Library Warning: busy');
else {
if (this.loadIndex<this.loadList.length-1) {
this.busy = true;
this.loadIndex++;
var src = this.loadList[this.loadIndex];
//if (!confirm('load: '+src+' ?')) return;
var rsrc = src + '?'+Math.random(); // random ensures cached files are not loaded
var s = this.scripts[src];
if (dynapi.ua.ns4) {
// delete the constructors
for (var j=0;j<s.objects.length;j++) {
var n = s.objects[j];
if (dynapi.frame[n]) {
dynapi.frame[n] = null;
if (s.pkg) dynapi.frame[s.pkg+'.'+n] = null;
}
}
//NS4 does not like "/" inside the ?name=value
src=src.replace(/\//g,'+'); //substitute "/" for "+"
this.elm.src = dynapi._path+'ext/library.html?js='+src;
}
else if (dynapi.ua.ie && (dynapi.ua.v==4 || dynapi.ua.mac)) {
dynapi.frame.document.body.insertAdjacentHTML('beforeEnd','<script type="text/javascript" language="javascript" src="'+rsrc+'" defer><\/script>');
this._export(src);
}
else {
var elm = s.elm = dynapi.frame.document.createElement('script');
elm.src = rsrc;
elm.type = 'text/javascript';
elm.defer = true;
if (dynapi.ua.ie) {
elm.C = 0;
var o = this;
elm.onreadystatechange = function() {
elm.C++;
if (elm.C==2 || elm.readyState=="complete") { // use 2nd statechange for onload
o._export(src);
}
}
}
dynapi.frame.document.getElementsByTagName('head')[0].appendChild(elm);
// I could not find way to know when the script is complete in Moz v0.9.3
if (dynapi.ua.ns6) setTimeout(this+'._export("'+src+'")',100);
}
}
}
};
// executed after a script is finished loading, run main() functions
DynAPILibrary.prototype._export = function(src) {
var src = this.loadList[this.loadIndex];
var s = this.scripts[src];
if (s) {
this._register(s);
// run elm.main)() before global main()
if (dynapi.ua.ns4 && typeof(this.elm.main)=="function") {
this.elm.main();
this.elm.main = null;
}
// run global main() if available
if (typeof(main)=="function") {
main();
main = null;
}
// clear out all functions in the layer's scope
if (dynapi.ua.ns4) {
for (var i in this.elm) {
if (typeof(this.elm[i])=="function") delete this.elm[i];
}
}
this.busy = false;
// load next file
this._load();
}
//else return alert('Library Error: unknown script '+src);
};
// registers the script as loaded, exports the objects
DynAPILibrary.prototype._register = function(s) {
//dynapi.debug.print('loaded "'+s.src+'"');
s.loaded = true;
s.queued = false;
if (!s.unnamed) {
var n,found;
// loop through each object that the script contains
for (var i=0;i<s.objects.length;i++) {
found = false;
n = s.objects[i];
// scope local objects in the layer to the DynAPI frame
if (dynapi.ua.ns4 && this.elm && typeof(this.elm[n])!="undefined") {
dynapi.frame[n] = this.elm[n];
found = true;
}
else if (typeof(dynapi.frame[n])!="undefined") found = true;
else if (n.indexOf('.')>0) {
var ns = n.split('.'), o = dynapi.frame, b = false;
for (var j=0;j<ns.length;j++) {
o = o[ns[j]];
}
if (typeof(o)!="undefined") found = true;
}
else if (typeof(dynapi[n])!="undefined") found = true;
if (found) {
if (s.pkg) {
// make package link: dynapi.api.DynLayer = DynLayer
if (s.pkg!="dynapi") this.packages[s.pkg][n] = dynapi.frame[n];
n = s.pkg+'.'+n;
}
dynapi.debug.print('loaded ['+n+']');
}
else {
dynapi.debug.print('Library Error: could not find ['+n+']');
}
}
}
// run handler if available
if (s.fn) {
s.fn();
delete s.fn;
}
};
// called from /lib/dynapi/library.html to write the <script>, NS4 only
DynAPILibrary.prototype._handleLoad = function(elm) {
var args = dynapi.functions.getURLArguments(elm.src);
var js = args["js"];
if (js) {
js=js.replace(/\+/g,'/'); // convert + to /
if (js.indexOf('http')!=0) {
var l = dynapi.frame.document.location;
if (js.substr(0,1)=='/') js = l.port+'//'+host+src;
else js = dynapi.documentPath+js;
}
elm.document.write('<script type="text/javascript" language="JavaScript" src="'+js+'?r'+Math.random()+'"><\/script>');
elm.document.close();
elm.onload = function() {
dynapi.library._export(js);
}
}
};
// inserts the layer for NS4, register included scripts
DynAPILibrary.prototype._create = function() {
// ensure a previous main function is wiped out
if (typeof(main)=="function") main = null;
// register objects from scripts included by dynapi.library.include() or manually
var s,n;
for (var i in this.scripts) {
s = this.scripts[i];
n=s.objects[0];
if(s.pkg=='dynapi.functions') { // used to avoid conflicts with intrinsic objects such as String, Image, Date and Math objects
if(dynapi.functions[n]) this._register(s);
}
else if (s.loaded || (s.objects[0] && dynapi.frame[s.objects[0]])) this._register(s);
}
// create NS4 layer to load scripts into
if (dynapi.ua.ns4) this.elm = new Layer(0, dynapi.frame);
this.busy = false;
// load any scripts before proceeding
if (this.loadList.length) {
var s = this.scripts[this.loadList[this.loadList.length-1]];
s.fn = function() {
setTimeout('dynapi._onLoad()',1);
}
this._load();
}
else setTimeout('dynapi._onLoad()',1);
};

View File

@ -1,126 +0,0 @@
/*
DynAPI Distribution
Package File
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
var l = dynapi.library;
var p = dynapi.library.path;
l._pakLoaded=true;
l.addPackage('dynapi',p);
l.add('dynapi.library','ext/library.js');
l.add('dynapi.debug','ext/debug.js','dynapi.functions.Image');
// Functions
l.addPackage('dynapi.functions',p+'ext/');
l.add('dynapi.functions.Color','functions.color.js');
l.add('dynapi.functions.Math','functions.math.js');
l.add('dynapi.functions.Date','functions.date.js');
l.add('dynapi.functions.Numeric','functions.numeric.js');
l.add('dynapi.functions.String','functions.string.js');
l.add('dynapi.functions.System','functions.system.js');
if (dynapi.ua.ns4)
l.add('dynapi.functions.Image','functions.image.js','MouseEvent'); // ns4 required MouseEvent for Image functions
else
l.add('dynapi.functions.Image','functions.image.js'); // ns4 required MouseEvent for Image functions
// API - Core Events & DynDocument
l.addPackage('dynapi.api',p+'api/');
l.add(['dynapi.api.DynEvent','dynapi.api.EventObject','dynapi.api.DynElement'],'event.js');
l.add('dynapi.api.DynDocument','dyndocument.js','DynEvent');
// DynLayer
l.add('dynapi.api.DynLayerBase','dynlayer_base.js','DynDocument');
if (dynapi.ua.ns4)
l.add('dynapi.api.DynLayer','dynlayer_ns4.js','DynLayerBase');
else if (dynapi.ua.ie)
l.add('dynapi.api.DynLayer','dynlayer_ie.js','DynLayerBase');
else if (dynapi.ua.opera)
l.add('dynapi.api.DynLayer','dynlayer_opera.js','DynLayerBase');
else
l.add('dynapi.api.DynLayer','dynlayer_dom.js','DynLayerBase');
// MouseEvent
if (dynapi.ua.ns4)
l.add('dynapi.api.MouseEvent','mouse_ns4.js','DynLayer');
else if(dynapi.ua.ie|| (dynapi.ua.opera && dynapi.ua.v < 8))
l.add('dynapi.api.MouseEvent','mouse_ie.js','DynLayer');
else
l.add('dynapi.api.MouseEvent','mouse_dom.js','DynLayer');
// Extensions
l.addPackage('dynapi.api.ext',p+'api/ext/');
l.add('dynapi.api.ext.DragEvent','dragevent.js','DynDocument');
l.add(['dynapi.api.ext.DynKeyEvent','dynapi.api.ext.TabManager'],'dynkeyevent.js','DynLayer');
l.add('dynapi.api.ext.DynLayerInline','dynlayer.inline.js','DynLayer');
// FX
/*
l.addPackage('dynapi.fx',p+'fx/');
l.add('dynapi.fx.Thread','thread.js','DynLayer');
l.add('dynapi.fx.PathAnimation','pathanim.js','Thread');
l.add('dynapi.fx.SlideAnimation','slideanim.js','Thread');
l.add('dynapi.fx.GlideAnimation','glideanim.js',['Thread','dynapi.functions.Math']);
l.add('dynapi.fx.CircleAnimation','circleanim.js',['Thread','dynapi.functions.Math']);
l.add('dynapi.fx.HoverAnimation','hoveranim.js',['Thread','dynapi.functions.Math']);
l.add('dynapi.fx.Bezier','bezier.js','Thread');
l.add('dynapi.fx.TimerX','timerx.js','DynLayer');
l.add('dynapi.fx.MotionX','motionx.js','DynLayer');
l.add('dynapi.fx.SnapX','snapx.js','DynLayer');
l.add('dynapi.fx.FlashSound','fsound.js','DynLayer');
l.add('dynapi.fx.Fader','fader.js','DynLayer');
l.add('dynapi.fx.Swiper','swiper.js','DynLayer');
l.add('dynapi.fx.TextAnimation','textanim.js','DynLayer');
*/
// ThyAPI Packages
// ThyAPI Utils
l.addPackage('dynapi.thyutils', p+'thyutils/');
l.add('dynapi.thyutils.thyCollection','thycollection.js');
l.add('dynapi.thyutils.thyVisualCollection', 'thyvisualcollection.js', ['thyCollection']);
l.add('dynapi.thyutils.thyProtocol','thyprotocol.js');
l.add('dynapi.thyutils.thyXMLRPCProtocol','thyxmlrpcprotocol.js','thyProtocol');
l.add('dynapi.thyutils.thyConnector','thyconnector.js', 'thyXMLRPCProtocol');
l.add('dynapi.thyutils.thyDataSource','thydatasource.js', ['DynElement','thyConnector','thyCollection']);
//ThyAPI Widgets
l.addPackage('dynapi.thywidgets', p+'thywidgets/');
l.add('dynapi.thywidgets.thyPanelBase', 'thypanel.js', ['DynLayer', 'System', 'DynKeyEvent', 'thyCollection']);
if (dynapi.ua.ie) l.add('dynapi.thywidgets.thyPanel', 'thypanel_ie.js', 'thyPanelBase');
else if (dynapi.ua.ns4) l.add('dynapi.thywidgets.thyPanel', 'thypanel_ns4.js', 'thyPanelBase');
else if (dynapi.ua.opera) l.add('dynapi.thywidgets.thyPanel', 'thypanel_opera.js', 'thyPanelBase');
else l.add('dynapi.thywidgets.thyPanel', 'thypanel_dom.js', 'thyPanelBase');
l.add('dynapi.thywidgets.thyButton', 'thybutton.js', 'thyPanel');
l.add('dynapi.thywidgets.thyTabsManager', 'thytabsmanager.js', 'thyPanel');
l.add('dynapi.thywidgets.thyBorderPanel', 'thyborderpanel.js', 'thyPanel');
l.add('dynapi.thywidgets.thyLabelPanel', 'thylabelpanel.js', 'thyPanel');
l.add('dynapi.thywidgets.thyEditBox', 'thyeditbox.js', 'thyLabelPanel');
l.add('dynapi.thywidgets.thyCheckBox', 'thycheckbox.js', 'thyLabelPanel');
//l.add('dynapi.thywidgets.thyPopupCalendar', 'thypopupcalendar.js', ['thyEditBox','JSCalendarSetup','thyButton']);
l.add('dynapi.thywidgets.thyPopupCalendar', 'thypopupcalendar.js', ['thyEditBox','thyButton']);
l.add('dynapi.thywidgets.thyTextEdit', 'thytextedit.js', 'thyLabelPanel');
//l.add('dynapi.thywidgets.thyRichTextEdit', 'thyrichtextedit.js', ['thyLabelPanel', 'FCKeditor']);
l.add('dynapi.thywidgets.thyWindow', 'thywindow.js', ['thyBorderPanel','thyButton','DragEvent','dynapi.functions.String']);
l.add('dynapi.thywidgets.thyDialogWindow', 'thydialogwindow.js', ['thyWindow','thyButton']);
l.add('dynapi.thywidgets.thyGridCell', 'thygridcell.js', ['thyPanel','thyEditBox', 'thyCollection']);
l.add('dynapi.thywidgets.thyGridRow', 'thygridrow.js', ['thyGridCell', 'thyVisualCollection'])
l.add('dynapi.thywidgets.thyGridContents', 'thygridcontents.js', ['thyPanel']);
l.add('dynapi.thywidgets.thyGrid', 'thygrid.js', ['thyGridContents','thyLabelPanel','thyGridCell','thyGridRow','thyVisualCollection']);
l.add('dynapi.thywidgets.thyListBox', 'thylistbox.js', ['thyGrid']);
l.add('dynapi.thywidgets.thyDropDownBox', 'thydropdownbox.js', ['thyListBox','thyEditBox','thyButton']);
// ThyAPI External
//l.addPackage('dynapi.thywidgets.external', p+'thywidgets/external/');
//l.add('dynapi.thywidgets.external.FCKeditor', 'fckeditor/fckeditor.js');
//l.add('dynapi.thywidgets.external.JSCalendar', 'jscalendar/calendar.js');
//l.add('dynapi.thywidgets.external.JSCalendarLang', 'jscalendar/lang/calendar-en.js');
//l.add('dynapi.thywidgets.external.JSCalendarSetup', 'jscalendar/calendar-setup.js',['JSCalendar','JSCalendarLang']);
// Load buffered includes ---------
if(l._buffer){
var i,ar=l._buffer;
for(i=0;i<ar.length;i++) l.include(true,ar[i]); // pass arguments true and bufferedArguments
l._buffer=null;
}

View File

@ -1,75 +0,0 @@
/*
DynAPI Distribution
Bezier Class
Bezier Algorithm Reference: http://astronomy.swin.edu.au/~pbourke/curves/bezier/
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.fx.Thread
*/
function Bezier(cp, n) {
var l = cp.length;
var p = [];
for (var i=0; i<n; i++) p = p.concat(Bezier._plot(cp,i/n));
return p.concat([cp[l-2],cp[l-1]]);
}
Bezier._plot = function (cp, mu) {
var n = (cp.length/2)-1;
var k,kn,nn,nkn;
var blend;
var b = [0,0];
var muk = 1;
var munk = Math.pow(1-mu, n);
for (k=0;k<=n;k++) {
nn = n;
kn = k;
nkn = n - k;
blend = muk * munk;
muk *= mu;
munk /= (1-mu);
while (nn >= 1) {
blend *= nn;
nn--;
if (kn > 1) {
blend /= kn;
kn--;
}
if (nkn > 1) {
blend /= nkn;
nkn--;
}
}
b[0] += cp[k*2] * blend;
b[1] += cp[k*2+1] * blend;
}
b[0] = Math.round(b[0]);
b[1] = Math.round(b[1]);
return b;
}
/*function Bezier3(cp,mu) {
var x1=cp[0],y1=cp[1],x2=cp[2],y2=cp[3],x3=cp[4],y3=cp[5];
var mu2 = mu * mu;
var mum1 = 1 - mu;
var mum12 = mum1 * mum1;
var x = Math.round(x1 * mum12 + 2 * x2 * mum1 * mu + x3 * mu2);
var y = Math.round(y1 * mum12 + 2 * y2 * mum1 * mu + y3 * mu2);
return [x,y];
}
function Bezier4(cp,mu) {
var x1=cp[0],y1=cp[1],x2=cp[2],y2=cp[3],x3=cp[4],y3=cp[5],x4=cp[6],y4=cp[7];
var mum1 = 1 - mu;
var mum13 = mum1 * mum1 * mum1;
var mu3 = mu * mu * mu;
var x = Math.round(mum13*x1 + 3*mu*mum1*mum1*x2 + 3*mu*mu*mum1*x3 + mu3*x4);
var y = Math.round(mum13*y1 + 3*mu*mum1*mum1*y2 + 3*mu*mu*mum1*y3 + mu3*y4);
return [x,y];
}*/

View File

@ -1,91 +0,0 @@
/*
DynAPI Distribution
CircleAnimation Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.functions.Math,dynapi.fx.Thread
*/
function CircleAnimation(dlyr) {
this.Thread = Thread;
this.Thread(dlyr);
this.offsetX = 0;
this.offsetY = 0;
this.playing = false;
this.radius = 100;
this.angle = 0;
this.setAngleIncrement(10);
};
var p = dynapi.setPrototype('CircleAnimation','Thread');
p.setRadius = function (r) {
this.hradius = this.vradius = r;
};
p.setHRadius = function (r) {
this.hradius = r;
};
p.setVRadius = function (r) {
this.vradius = r;
};
p.setAngle = function (a) {
this.angle = dynapi.functions.degreeToRadian(a);
};
p.setAngleIncrement = function (inc) {
this.angleinc = dynapi.functions.degreeToRadian(inc);
};
p.playAnimation = function () {
this.playing = true;
if (this.dlyr!=null) {
this.offsetX = this.hradius*Math.cos(this.angle);
this.offsetY = -this.vradius*Math.sin(this.angle);
this.baseX = this.dlyr.x-this.offsetX;
this.baseY = this.dlyr.y+this.offsetY;
this.dlyr.invokeEvent("circlestart");
}
this.start();
};
p.stopAnimation = function () {
this.playing = false;
this.stop();
if (this.dlyr!=null) this.dlyr.invokeEvent("circlestop");
};
p.run = function () {
if (!this.playing || this.dlyr==null) return;
this.angle += this.angleinc;
this.offsetX = this.hradius*Math.cos(this.angle);
this.offsetY = -this.vradius*Math.sin(this.angle);
if (this.dlyr!=null) {
this.dlyr.invokeEvent("circlerun");
this.dlyr.setLocation(this.baseX+this.offsetX,this.baseY+this.offsetY);
}
};
p.reset = function () {
this.angle = this.offsetX = this.offsetY = 0;
};
p.generatePath = function(centerX,centerY) {
if (centerX==null) centerX = this.dlyr!=null? this.dlyr.x : 0;
if (centerY==null) centerY = this.dlyr!=null? this.dlyr.y : 0;
var path = [];
var i = 0;
/* for (var a=this.angle;a<=this.angle+Math.PI*2;a+=this.angleinc) {
path[i] = Math.round(centerX + this.hradius*Math.cos(a));
path[i+1] = Math.round(centerY - this.vradius*Math.sin(a));
i+=2;
}*/
if (this.angleinc>0)
for (var a=this.angle;a<=this.angle+Math.PI*2;a+=this.angleinc) {
path[i] = Math.round(centerX + this.hradius*Math.cos(a));
path[i+1] = Math.round(centerY - this.vradius*Math.sin(a));
i+=2;
}
else
for (var a=this.angle;a>=this.angle-Math.PI*2;a+=this.angleinc) {
path[i] = Math.round(centerX + this.hradius*Math.cos(a));
path[i+1] = Math.round(centerY - this.vradius*Math.sin(a));
i+=2;
}
return path;
};

View File

@ -1,69 +0,0 @@
/*
DynAPI Distribution
Fader Animation Extension
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: DynLayer
*/
Fader = {}; // used by dynapi.library
p = DynLayer.prototype;
p._fadeMode = '';
p.fadeIn = function(inc,ms){
this._opacity=0;
this._fadeMode='in';
this.fadeTo(100,(inc||4),ms);
};
p.fadeOut = function(inc,ms){
this._opacity=100;
this._fadeMode='out';
this.fadeTo(0,inc||4,ms);
};
// Fades an object to "opacity" by "inc" increments in every "ms" millisenconds
p.fadeTo = function(opacity,inc,ms){
if(this._opacity==null) this._opacity=100;
inc=(inc)? Math.abs(inc):5;
this._fadeMs=(ms)? ms:50;
if (this._opacity>opacity) inc*=-1;
this._fadeInc=inc;
this._fadeToOpacity = opacity;
this._fadeTimeout=window.setTimeout(this+'._fade()',this._fadeMs);
};
p._fade = function(){
var ua=dynapi.ua;
var fm=this._fadeMode;
var inc = this._fadeInc;
var opac = this._opacity;
var fopac = this._fadeToOpacity;
opac+=inc;
if ((inc<0 && opac<=fopac)|| (inc>0 && opac>=fopac)) opac=fopac;
this._opacity=opac;
if(!ua.def) this.setVisible((opac>0)? true:false);
else if(ua.dom && this.css){
if(opac>1 && this.visible==false) this.setVisible(true);
if(ua.ie) this.css.filter='alpha(opacity=' + opac + ')';
else this.css.MozOpacity = parseInt(opac)/100;
}
if(opac!=fopac) this._fadeTimeout=window.setTimeout(this+'._fade()',this._fadeMs);
else {
this._fadeMode='';
window.clearTimeout(this._fadeTimeout);
this.invokeEvent('fade'+fm);
}
};
p.getOpacity = function(){
if (this._opacity ||(this._opacity == 0)) return this._opacity;
else return this._opacity=100;
};
p.setOpacity = function(n){
var ua=dynapi.ua;
if(n>100) n=100;
else if(n<0)n=0;
this._opacity = n;
this.fadeTo(n);
};

View File

@ -1,300 +0,0 @@
/*
DynAPI Distribution
FlashSound Class - for sonifying web pages with the flash player
Based on the FlashSound API (1.8) Copyright 2001 Hayden Porter, hayden@aviarts.com
For more information please see the FlashSound Quick Reference
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
Requires: DynLayer
*/
function FlashSound(swfURL,loop,autostart){
this.DynLayer = DynLayer;
this.DynLayer(null,-10,-10,1,1);
// add layer to document
dynapi.document.addChild(this);
// instance properties
this.playerID = this.id + "SWF";
FlashSound.players[FlashSound.players.length] = this;
// instance embed properties
this.autostart = true;
this.base = null;
this.bgcolor = null;
this.loop = (loop)? loop:false;
this.src = null;
// setup flash plugin
this.setSWF(swfURL);
};
/* ============== FlashSound Instance methods =============== */
/*
javascript embed ---------------------------------
embeds swf if user has a supported browser and minimum player.
script sets swf bgcolor attribute to document.bgcolor if no custom color specified.
*/
var p = dynapi.setPrototype('FlashSound','DynLayer');
p._recognizeMethod = function (objstr){
// check for player readiness ----------------------
// check for javascript DOM object first then check to see if any frames are loaded in maintimeline
if(typeof(this.doc[this.playerID][objstr]) == "undefined") return false;
else return true;
};
p._checkForInstance = function() {
if(!FlashSound.supportedBrowser || !FlashSound.checkForMinPlayer()) return false;
if (this.doc[this.playerID] == null) return false;
return true;
};
// Public Methods -------------------
p.isPlayerReady = function(){
if(!FlashSound.engage) return false;
if(!this._checkForInstance()) return false;
// block browsers that do not recognize Flash javascript methods
if(!this._recognizeMethod("PercentLoaded")) return false;
if(this.percentLoaded() > 0) return true;
return false;
};
p.getFramesLoaded = function(target){
if(!this._checkForInstance()) {return 0;}
if(target == null) target = "/";
var framesloaded = this.doc[this.playerID].TGetProperty(target,12);
return parseInt(framesloaded);
};
p.getTotalFrames = function(target){
if(!this.isPlayerReady()) {return 0;}
if(target == null) target = "/";
var totalframes = this.doc[this.playerID].TGetProperty(target,5);
return parseInt(totalframes);
};
// check to see if all frames are loaded for a given timeline.
// check before moving playhead to a frame/label incase the frame/label is not yet loaded.
p.isLoaded = function(target){
if(!this.isPlayerReady()) return false;
if(target == null) target = "/";
if (this.getFramesLoaded(target) == this.getTotalFrames(target)) return true;
return false;
};
/* flash javascript api functions ------------------------ */
p.gotoAndPlay = function(target,frame){
if(!this.isPlayerReady()) return;
if(typeof(frame) == "number") {
this.doc[this.playerID].TGotoFrame(target,frame - 1);
this.doc[this.playerID].TPlay(target);
}
if(typeof(frame) == "string") {
this.doc[this.playerID].TGotoLabel(target,frame);
this.doc[this.playerID].TPlay(target);
}
};
p.gotoAndStop = function(target,frame){
if(!this.isPlayerReady()) return;
if(typeof(frame) == "number") {
this.doc[this.playerID].TGotoFrame(target,frame - 1);
}
if(typeof(frame) == "string") {
this.doc[this.playerID].TGotoLabel(target,frame);
}
};
// Is Playing (IsPlaying)
p.isPlaying = function(){
if(!this.isPlayerReady()) return false;
return this.doc[this.playerID].IsPlaying();
};
// Load Movie
p.loadMovie = function(layerNumber,url){
if(!this.isPlayerReady()) return;
this.doc[this.playerID].LoadMovie(layerNumber,url);
};
p.percentLoaded = function(){
if(!this._checkForInstance()) return 0;
var percentLoaded = this.doc[this.playerID].PercentLoaded();
return parseInt(percentLoaded);
};
p.play = function(target){
if(!this.isPlayerReady()) return;
if(target == null) target = "/";
this.doc[this.playerID].TPlay(target);
};
// Set SWF
p.setSWF = function(swfURL){
if (!FlashSound.supportedBrowser || !FlashSound.checkForMinPlayer()) return;
var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
var defaultBase = ".";
swfURL=(swfURL)? swfURL:'';
this.bgcolor = (this.bgcolor == null) ? defaultColor : this.bgcolor;
this.base = (this.base == null) ? defaultBase : this.base;
this.src = (swfURL.charAt(0) == "/") ? "http://" + location.host+swfURL : swfURL;
this.setHTML(
'<OBJECT ' +
'CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ' +
'WIDTH="1" ' +
'HEIGHT="1" ' +
'ID="' + this.playerID + '">\n' +
'<PARAM NAME="movie" VALUE="' + this.src + '">\n' +
'<PARAM NAME="play" VALUE="' + this.autostart + '">\n' +
'<PARAM NAME="loop" VALUE="' + this.loop + '">\n' +
'<PARAM NAME="quality" VALUE="low">\n' +
'<PARAM NAME="wmode" VALUE="transparent">\n' +
'<PARAM NAME="bgcolor" VALUE="' + this.bgcolor + '">\n' +
'<PARAM NAME="base" VALUE="' + this.base + '">\n' +
'<EMBED \n' +
'name="' + this.playerID + '"\n' +
'swLiveConnect="true"\n' +
'src="' + this.src + '\"' + '\n' +
'play="' + this.autostart + '\"' + '\n' +
'loop="' + this.loop + '\"' + '\n' +
'quality="low"\n' +
'wmode="transparent"\n' +
'base="' + this.base + '"\n' +
'bgcolor="' + this.bgcolor + '"\n' +
'WIDTH="1"\n' +
'HEIGHT="2"\n' +
'TYPE="application/x-shockwave-flash"\n' +
'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">\n' +
'</EMBED>\n' +
'</OBJECT>'
);
};
// Stop Play (TStopPlay)
p.stopPlay = function(target){
if(!this.isPlayerReady()) return;
if(target == null) target = "/";
this.doc[this.playerID].TStopPlay(target);
};
/* Static Functions & Properties --------------------------- */
var fs = FlashSound;
fs.engage = true; // engage
fs.playerCount = 0; // player count
fs.players = new Array(); // players[]
fs.playerVersion = 0; // set playerVersion to 0 for unsupported browsers
// check for LiveConnect - Opera version 6.x with Java Enabled and Netscape versions 4.x but not greater
fs.LiveConnect = ((navigator.javaEnabled() &&
(dynapi.ua.ns4 && dynapi.ua.v<5)) || dynapi.ua.opera6);
// browser compatibility check -----------------
fs.supportedBrowser = ((dynapi.ua.ie && dynapi.ua.win32) ||
dynapi.ua.ns6 || FlashSound.LiveConnect) ? true : false;
// player compatibility ------------------
// checkForMinPlayer sets playerVersion for supported browsers
fs.checkForMinPlayer = function(){
if(!this.supportedBrowser) return false;
if(dynapi.ua.ns6) {
// xpconnect works with version 6 r40 or greater
this.playerVersion = this.getPlugInVers(); // get version
releaseVers = this.getPlugInReleaseVers(); // get release version
//check release vers only for vers 6
if(this.playerVersion == 6 && releaseVers >=40) return true;
}
if(this.LiveConnect) this.playerVersion = this.getPlugInVers();
if(dynapi.ua.ie) this.playerVersion = (Flash_getActiveXVersion());
if(this.playerVersion >= this.minPlayer) return true;
else return false;
};
// check for flash plug-in in netscape
fs.checkForPlugIn = function(){
var flashmimeType = "application/x-shockwave-flash";
var hasplugin = (navigator.mimeTypes && navigator.mimeTypes[flashmimeType]) ? navigator.mimeTypes[flashmimeType].enabledPlugin : 0;
return hasplugin;
};
// Get Plugin Version
fs.getPlugInVers = function(){
if(this.checkForPlugIn()){
var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
return pluginversion;
}else{
return 0;
}
};
// Get Plugin Release Version
fs.getPlugInReleaseVers = function(){
if(this.checkForPlugIn()){
var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf("r")+1, plugin.description.length));
return pluginversion;
}else{
return 0;
}
};
// vers is integer
fs.setMinPlayer = function(vers){
if(!this.supportedBrowser) return;
this.minPlayer = (vers != null && vers >= 4) ? vers : 4;
if(dynapi.ua.ns6) {
this.minPlayer = 6; // set min player to 6 for XPConnect
}
this.checkForMinPlayer();
};
// vbscript get Flash ActiveX control version for windows IE
if(dynapi.ua.ie && dynapi.ua.win32){
var h='<scr' + 'ipt language="VBScript">' + '\n' +
'Function Flash_getActiveXVersion()' + '\n' +
'On Error Resume Next' + '\n' +
'Dim hasPlayer, playerversion' + '\n' +
'hasPlayer = false' + '\n' +
'playerversion = 15' + '\n' +
'Do While playerversion > 0' + '\n' +
'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion)))' + '\n' +
'If hasPlayer Then Exit Do' + '\n' +
'playerversion = playerversion - 1' + '\n' +
'Loop' + '\n' +
'Flash_getActiveXVersion = playerversion' + '\n' +
'End Function' + '\n' +
'<\/scr' + 'ipt>';
if(!dynapi.loaded) document.write(h);
else {
dynapi.document.addChild(new DynLayer({w:0,h:0,visible:false,html:'<iframe name="FSVBS"></iframe'}));
var elm=document.frames['FSVBS'];
var doc = elm.document;
doc.open();doc.write(h);doc.close();
dynapi.frame.Flash_getActiveXVersion = function() {
return elm.Flash_getActiveXVersion();
};
}
};
// set minimum player version - default is 4
fs.setMinPlayer();

View File

@ -1,82 +0,0 @@
/*
DynAPI Distribution
Glide Animation Extension
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.fx.Thread
*/
function GlideAnimation(x1,y1,x2,y2,angleinc,startSpeed,endSpeed) {
if (x2==null) x2 = x1;
if (y2==null) y2 = y1;
var normAngle = dynapi.functions.getNormalizedAngle(x1,y1,x2,y2);
var distx = x2-x1;
var disty = y2-y1;
var distance = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2));
angleinc = (angleinc==null)? 7 : Math.abs(angleinc);
// a terrible mess but it works
var r = 1;
if (startSpeed == "fast") {
var centerX = x1;
var centerY = y1;
var centerX2 = x2;
var centerY2 = y2;
startAngle = 0;
endAngle = 90;
if (endSpeed=="fast") distance = distance/2;
}
else {
startAngle = -90;
endAngle = 0;
if (endSpeed == "fast") {
var centerX = x1+distx;
var centerY = y1+disty;
}
else { // default slow,slow
var centerX2 = x2-distx/2;
var centerY2 = y2-disty/2;
distance = distance/2;
var centerX = x1+distx/2;
var centerY = y1+disty/2;
r = -1;
}
}
var i,d,x,y,dx,dy,path=[];
for (var a=startAngle; a<endAngle; a+=angleinc) {
i = path.length;
d = distance*Math.sin(a*Math.PI/180);
path[i] = Math.round(centerX + d*Math.cos(normAngle));
path[i+1] = Math.round(centerY - d*Math.sin(normAngle));
}
if (startSpeed==endSpeed) {
for (var a=endAngle; a<endAngle+90; a+=angleinc) {
i = path.length;
d = distance*Math.sin(a*Math.PI/180);
path[i] = Math.round(centerX2 - r*d*Math.cos(normAngle));
path[i+1] = Math.round(centerY2 + r*d*Math.sin(normAngle));
}
}
var l = path.length;
if (path[l-2] != x2 || path[l-1]!=y2) {
path[l] = x2;
path[l+1] = y2;
}
return path;
};
DynLayer.prototype.glideStop = function () {
if (this._thread) this._thread.stop();
};
DynLayer.prototype.glideTo = function(x2,y2,angleinc,ms,startSpeed,endSpeed) {
if (this.x!=x2 || this.y!=y2) {
if (!this._thread) this._thread = new Thread(this);
if (ms) this._thread.interval = ms;
this._thread.play(GlideAnimation(this.x,this.y,x2,y2,angleinc,startSpeed,endSpeed) );
}
};

View File

@ -1,63 +0,0 @@
/*
DynAPI Distribution
HoverAnimation Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.functions.Math, dynapi.fx.Thread
*/
function HoverAnimation(dlyr) {
this.Thread = Thread;
this.Thread(dlyr);
this.offsetX = 0;
this.offsetY = 0;
this.playing = false;
this.amplitude = 100;
this.angle = 0;
this.setAngleIncrement(10);
};
var p = dynapi.setPrototype('HoverAnimation','Thread');
p.setAmplitude = function (amp) {
this.amplitude = amp;
};
p.setAngle = function (a) {
this.angle = dynapi.functions.degreeToRadian(a);
};
p.setAngleIncrement = function (inc) {
this.angleinc = dynapi.functions.degreeToRadian(inc);
};
p.playAnimation = function () {
this.playing = true;
if (this.dlyr!=null) {
this.offsetX = 0;
this.offsetY = this.amplitude*Math.sin(this.angle);
this.baseX = this.dlyr.x;
this.baseY = this.dlyr.y+this.offsetY;
this.dlyr.invokeEvent("hoverstart");
}
this.start();
};
p.stopAnimation = function () {
this.playing = false;
this.stop();
if (this.dlyr!=null) this.dlyr.invokeEvent("hoverstop");
};
p.run = function () {
if (!this.playing || this.dlyr==null) return;
this.angle += this.angleinc;
this.offsetX = 0;
this.offsetY = this.amplitude*Math.sin(this.angle);
if (this.dlyr!=null) {
this.dlyr.invokeEvent("hoverrun");
this.dlyr.setLocation(this.baseX+this.offsetX,this.baseY+this.offsetY);
}
};
p.reset = function () {
this.angle = this.offsetX = this.offsetY = 0;
};
p.generatePath = function(centerX,centerY) {
// to do
};

View File

@ -1,102 +0,0 @@
/*
DynAPI Distribution
ImageAnimation Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: Thread
*/
function ImageAnimation(dynimage) {
this.Thread = Thread;
this.Thread(dynimage);
this.imgAnim = new Array();
this.imgAnim.playing = null;
}
var p = dynapi.setPrototype('ImageAnimation','Thread');
p.addAnimation = function (imgArray) {
var animNum = this.imgAnim.length;
this.imgAnim[animNum] = imgArray;
this.imgAnim[animNum].loops = false;
this.imgAnim[animNum].resets = false;
this.imgAnim[animNum].frame = 0;
this.imgAnim[animNum].playing = true;
this.imgAnim[animNum].direction = 0;
this.imgAnim[animNum].alternates = false;
return animNum;
};
p.getFrame = function (animNum,frameNum) {
return this.imgAnim[animNum][frameNum];
};
p.setLoops = function (animNum,loop) {
this.imgAnim[animNum].loops = loop;
};
p.setResets = function (animNum) {
this.imgAnim[animNum].resets = true;
};
p.setAlternates = function (animNum,alt) {
this.imgAnim[animNum].loops = true;
this.imgAnim[animNum].alternates = alt;
};
p.playAnimation = function (animNum) {
if (animNum!=null && this.imgAnim.playing!=animNum) {
this.playing = true;
this.imgAnim.playing = animNum;
if (this.dlyr!=null) this.dlyr.invokeEvent("imgstart");
this.start();
}
};
p.stopAnimation = function () {
this.imgAnim.playing = null;
this.playing = false;
this.stop();
if (this.dlyr!=null) this.dlyr.invokeEvent("imgrun");
};
p.run = function () {
if (!this.playing || this.imgAnim.playing==null || this.dlyr==null) return;
var anim = this.imgAnim[this.imgAnim.playing];
if (anim.frame==0 && this.img==anim[anim.frame]) {
anim.frame++; // skip 1st frame if same
}
if (this.dlyr!=null) this.dlyr.invokeEvent("imgrun");
this.dlyr.setImage(anim[anim.frame]);
if (anim.frame>=anim.length-1) {
if (anim.loops) {
if (anim.alternates && anim.direction==0 && anim.frame==anim.length-1) {
anim.direction = 1;
anim.frame = anim.length-2;
}
else anim.frame = 0;
}
else if (anim.resets) {
anim.frame = 0;
this.stop();
}
else {
this.stop();
}
}
else {
if (anim.alternates) {
if (anim.frame==0 && anim.direction==1) {
anim.direction = 0;
anim.frame = 1;
}
else if (anim.direction==0) {
anim.frame++;
}
else if (anim.direction==1) {
anim.frame--;
}
}
else {
anim.frame++;
}
}
};

View File

@ -1,113 +0,0 @@
/*
DynAPI Distribution
MotionX Class by Raymond Irving (http://dyntools.shorturl.com)
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: Dynlayer
*/
MotionX = {}; // used by dynapi.library
DynLayer.prototype.makeSolid=function(){
this.isHard=true;
this._collideX=this.x;
this._collideY=this.x;
this.collideEvent ={
onlocationchange:function(e) {
var me=e.getSource();
var dirX='',dirY='';
// get direction
if (me._collideX!=me.x) {
if (me._collideX<me.x){dirX="E"}else{dirX="W"};
}
if (me._collideY!=me.y){
if (me._collideY<me.y){dirY="S"}else{dirY="N"};
}
// get angle direction
me._setCollideAngleDirection(me._collideX,me._collideY,me.x,me.y);
me._collideX=me.x;
me._collideY=me.y;
me._collideDirection=dirY+dirX;
me._checkForCollision();
}
}
this.addEventListener(this.collideEvent);
};
DynLayer.prototype._setCollideAngleDirection = function(x1,y1,x2,y2) {
var distx = (x2-x1),disty = (y1-y2),angle;
//if (distx==0 && disty==0) return 0;
var rad=Math.abs(Math.atan2(disty,distx))
if (disty>=0) {
if (distx>=0) angle = 90-(rad*180/Math.PI);
else angle = 270+(180-(rad*180/Math.PI));
}else{
angle = 90+(rad*180/Math.PI);
}
this._collideAngle=Math.ceil(angle);
};
DynLayer.prototype._checkForCollision=function(){
if (!this.parent.children.length>0) return false;
var ch,chX,sX,sY,colX1,colX2,colY1,colY2,n1,n2;
this.collideObject==null;
for (var i in this.parent.children) {
ch=this.parent.children[i];
if (ch!=this && ch.isHard==true) {
chX=ch.x;
chY=ch.y;
sX=this.x;
sY=this.y;
colX1=(sX>=chX && sX<=chX+ch.w);
colX2=(chX>=sX && chX<=sX+this.w);
colY1=(sY>=chY && sY<=chY+ch.h);
colY2=(chY>=sY && chY<=sY+this.h);
if ((colX1 || colX2) && (colY1 || colY2)) {
if (this._collideDirection=='NE') {
n1=((chY+ch.h)-this.y);n2=((sX+this.w)-chX);
if (n1<n2) {face="S"}else{face="W"}
}else if (this._collideDirection=='NW') {
n1=((chY+ch.h)-this.y);n2=((chX+ch.w)-sX);
if (n1<n2) {face="S"}else{face="E"}
}else if (this._collideDirection=='SE') {
n1=((sY+this.h)-ch.y);n2=((sX+this.w)-chX);
if (n1<n2) {face="N"}else{face="W"}
}else if (this._collideDirection=='SW') {
n1=((sY+this.h)-ch.y);n2=((chX+ch.w)-sX);
if (n1<n2) {face="N"}else{face="E"}
}else if (this._collideDirection=='E') {
face="W";
}else if (this._collideDirection=='W') {
face="E";
}else if (this._collideDirection=='N') {
face="S";
}else if (this._collideDirection=='S') {
face="N";
}
ch._impactSide=face;
if (face=="W"){this._impactSide="E"}
if (face=="E"){this._impactSide="W"}
if (face=="N"){this._impactSide="S"}
if (face=="S"){this._impactSide="N"}
this._collideObject=ch;
this.invokeEvent("collide");
ch._collideObject=this;
ch.invokeEvent("collide");
}
}
}
return false;
};
DynLayer.prototype.getImpactSide=function(){
return this._impactSide;
}
DynLayer.prototype.getObstacle=function(){
return this._collideObject;
}
DynLayer.prototype.getDirection=function(){
return this._collideDirection;
}
DynLayer.prototype.getDirectionAngle=function(){
return this._collideAngle;
}

View File

@ -1,96 +0,0 @@
/*
DS: the extra features of this version will possibly be rebuilt as an advanced timeline object
DynAPI Distribution
PathAnimation Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.fx.Thread
*/
function PathAnimation(dlyr) {
this.Thread = Thread;
this.Thread(dlyr);
this.paths = [];
this.pathPlaying = null;
}
var p = dynapi.setPrototype('PathAnimation','Thread');
p.add = function (path, loops, resets) {
var n = this.paths.length;
this.paths[n] = path;
this.setLoops(n,loops);
this.setResets(n,resets);
this.setFrame(n,0);
return n;
};
p.setLoops = function (n, loops) {
this.paths[n].loops = (loops);
};
p.setResets = function (n, resets) {
this.paths[n].resets = (resets);
};
p.setFrame = function (n, frame) {
this.paths[n].frame = frame;
};
p.playAnimation = function (noevt) {
if (!this.playing) {
this.pathPlaying = null;
if (arguments[0]==null) arguments[0] = 0;
if (typeof(arguments[0]) == "number") {
this.pathPlaying = this.paths[arguments[0]];
}
else if (typeof(arguments[0]) == "object") {
this.pathPlaying = arguments[0];
this.pathPlaying.loops = arguments[1]||false;
this.pathPlaying.resets = arguments[2]||false;
this.pathPlaying.frame = 0;
}
this.playing = true;
if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstart");
this.start();
}
};
//p._Thread_stop = Thread.prototype.stop;
p.stopAnimation = function (noevt) {
if (this.pathPlaying && this.pathPlaying.resets && this.dlyr!=null) this.dlyr.setLocation(this.pathPlaying[0],this.pathPlaying[1]);
this.stop();
this.pathPlaying = null;
this.playing = false;
if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstop");
};
p.run = function () {
if (!this.playing || this.pathPlaying==null) return;
var anim = this.pathPlaying;
if (anim.frame>=anim.length/2) {
if (anim.loops) {
anim.frame = 0;
}
else if (anim.resets) {
anim.frame = 0;
if (this.dlyr!=null) this.dlyr.setLocation(anim[0],anim[1]);
this.stopAnimation();
this.dlyr.invokeEvent("pathfinish");
return;
}
else {
anim.frame = 0;
this.stopAnimation();
this.dlyr.invokeEvent("pathfinish");
return;
}
}
if (anim.frame==0 && (this.dlyr!=null && this.dlyr.x==anim[0] && this.dlyr.y==anim[1])) {
anim.frame += 1;
}
this.newX = anim[anim.frame*2];
this.newY = anim[anim.frame*2+1];
if (this.dlyr!=null) {
this.dlyr.invokeEvent("pathrun");
this.dlyr.setLocation(this.newX,this.newY);
}
anim.frame++;
};

View File

@ -1,42 +0,0 @@
/*
DynAPI Distribution
Slide Animation Extension
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: dynapi.fx.Thread
*/
// Generates a path between 2 points, stepping inc pixels at a time
function SlideAnimation(x1,y1,x2,y2,inc) {
var n,dx,dy,lx,ly,p=[];
if (x2==null) x2 = x1;
if (y2==null) y2 = y1;
lx = x2-x1;
ly = y2-y1;
n = Math.sqrt(Math.pow(lx,2) + Math.pow(ly,2))/(inc||10);
dx = lx/n;
dy = ly/n;
for (var i=0;i<n;i++) {
p[i*2] = x1 + Math.round(dx*i);
p[i*2+1] = y1 + Math.round(dy*i);
}
if (p[i*2-2] != x2 || p[i*2-1] != y2) {
p[i*2] = x2;
p[i*2+1] = y2;
}
return p;
};
DynLayer.prototype.slideTo = function(x2,y2,inc,ms) {
if (this.x!=x2 || this.y!=y2) {
if (!this._thread) this._thread = new Thread(this);
if (ms) this._thread.interval = ms;
this._thread.play(SlideAnimation(this.x,this.y,x2,y2,inc));
}
};
DynLayer.prototype.slideStop = function () {
if (this._thread) this._thread.stop();
};

View File

@ -1,780 +0,0 @@
/*
DynAPI Distribution
SnapX Class by Leif Westerlind <warp-9.9 (at) usa (dot) net>
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: DynLayer
*/
SnapX = {}; // used by dynapi.library
var p = DynLayer.prototype;
p._snapSetLocation = p.setLocation;
p.setLocation = function(x,y){
this._snapSetLocation(x,y);
if (this.isSnapEnabled){
var dirX = '', dirY = '';
// get direction
if (this._snapX != this.x){
if (this._snapX < this.x){
dirX="E";
}
else {
dirX="W";
}
}
if (this._snapY != this.y){
if (this._snapY < this.y){
dirY="S";
}
else {
dirY="N";
}
}
this._snapX = this.x;
this._snapY = this.y;
this._snapDirection = dirY + dirX;
this._checkForSnap();
}
};
p.getSnapDirection = function (){
return(this._snapDirection);
};
/*
INPUT:
0 args: use defaults
1 arg : snap type [normal|null|sticky|grid]
2 args: snap type [normal|null|sticky|grid],
boundary type [inner|outer|both]
3 args: snap type [normal|null|sticky|grid],
boundary type [inner|outer|both],
boundary
4 args: snap type [normal|null|sticky|grid],
boundary type [inner|outer|both],
boundary,
grid size (if applicable)
*/
p.enableSnap = function (){
var a = arguments;
var snapBoundaryDefault = DynLayer._snapBoundaryDefault;
this.isSnapEnabled = true;
this._snapX = this.x;
this._snapY = this.y;
if ( a.length >= 0 ){
this.setSnapBoundary();
this.setSnapBoundaryType();
}
if ( a.length >= 1 ){
if ( a[0] == 'sticky' || a[0] == 'grid' ){
this.setSnapType(a[0]);
}
else if ( a[0] == 'normal' || a[0] == null ){
this.setSnapType();
}
}
if ( a.length >= 2 ){
if ( a[1] == 'inner' || a[1] == 'outer' || a[1] == 'both' ){
this.setSnapBoundaryType(a[1]);
}
else {
this.setSnapBoundaryType();
}
}
if ( a.length >= 3 ){
if ( typeof(a[2]) == 'number' ){
this.setSnapBoundary(a[1],a[2]);
}
else {
this.setSnapBoundary(a[1],snapBoundaryDefault);
}
}
if ( a.length >= 4 ){
if ( typeof(a[3]) == 'number' ){
this.setGridSnapSize(a[3]);
}
else {
this.setGridSnapSize();
}
}
};
p.disableSnap = function(){
this.isSnapEnabled = false;
};
p.setSnapType = function(t){
var a = arguments;
if (a.length == 0){
this._snapType = 'normal';
}
else if (a.length == 1 ){
if ( a[0] == 'sticky' ){
this._snapType = a[0];
this.enableStickySnap();
} else if ( a[0] == 'grid' ){
this._snapType = a[0];
this.enableGridSnap();
}
else {
this._snapType = 'normal';
}
}
}
p.enableStickySnap = function(){
if (arguments.length == 0){
this.isStickySnapEnabled = true;
}
else if (arguments.length == 1 ){
if (arguments[0] === true){
this.isStickySnapEnabled = true;
}
else if (arguments[0] === false){
this.isStickySnapEnabled = false;
}
}
};
p.disableStickySnap = function(){
this.isStickySnapEnabled = false;
};
p.enableGridSnap = function(){
this.isGridSnapEnabled = true;
this.setGridSnapSize();
this._snapGridX = null;
this._snapGridY = null;
};
p.disableGridSnap = function(){
this.isGridSnapEnabled = false;
};
DynLayer._snapBoundaryTypeDefault = 'outer';
p.setSnapBoundaryTypeDefault = function(snapBoundaryType){
if (typeof(snapBoundaryType) == 'string') DynLayer._snapBoundaryTypeDefault = snapBoundaryType;
}
p.getSnapBoundaryTypeDefault = function(){
return(DynLayer._snapBoundaryTypeDefault);
}
p.setSnapBoundaryType = function(snapBoundaryType){
if (arguments.length == 0){
this._snapBoundaryType = DynLayer._snapBoundaryTypeDefault;
}
else if (typeof(snapBoundaryType) == 'string'){
this._snapBoundaryType = snapBoundaryType;
}
};
p.getSnapBoundaryType = function(){
return(this._snapBoundaryType);
};
DynLayer._snapBoundaryDefault = 25;
p.setSnapBoundaryDefault = function(snapBoundary){
if(typeof(snapBoundary) == 'number') DynLayer._snapBoundaryDefault = snapBoundary;
}
p.getSnapBoundaryDefault = function(){
return(DynLayer._snapBoundaryDefault);
}
DynLayer._snapGridSizeDefault = 10;
p.setGridSnapSizeDefault = function(s){
DynLayer._snapGridSizeDefault = s;
}
p.getGridSnapSizeDefault = function(){
return(DynLayer._snapGridSizeDefault);
}
p.setGridSnapSize = function(){
if (arguments.length == 0){
this._snapGridSize = DynLayer._snapGridSizeDefault;
}
else if (arguments.length == 1 ){
this._snapGridSize = arguments[0];
}
};
/*
INPUT:
0 args: set snapBoundaryType to snapBoundaryTypeDefault,
set boundary to snapBoundaryDefault
1 arg : if snapBoundaryType, set boundary to snapBoundaryDefault,
if boundary, set all sides to boundary
and snapBoundaryType to snapBoundaryTypeDefault
2 args: if snapBoundaryType,boundary, set type and boundary for all sides
if N1,N2 set inner to N1 and outer to N2 and
set snapBoundaryType to both
5 args: snapBoundaryType, t, r, b, l
8 args: ti, ri, bi, li, to, ro, bo, lo
*/
p.setSnapBoundary = function(){
var a = arguments;
var snapBoundaryDefault = DynLayer._snapBoundaryDefault;
if (a.length == 0){
this.setSnapBoundaryType();
this._snapBndTi = snapBoundaryDefault;
this._snapBndRi = snapBoundaryDefault;
this._snapBndBi = snapBoundaryDefault;
this._snapBndLi = snapBoundaryDefault;
this._snapBndTo = snapBoundaryDefault;
this._snapBndRo = snapBoundaryDefault;
this._snapBndBo = snapBoundaryDefault;
this._snapBndLo = snapBoundaryDefault;
}
if (a.length == 1){
if(a[0] == 'inner' || a[0] == 'outer' || a[0] == 'both'){
this.setSnapBoundaryType(a[0]);
this._snapBndTi = snapBoundaryDefault;
this._snapBndRi = snapBoundaryDefault;
this._snapBndBi = snapBoundaryDefault;
this._snapBndLi = snapBoundaryDefault;
this._snapBndTo = snapBoundaryDefault;
this._snapBndRo = snapBoundaryDefault;
this._snapBndBo = snapBoundaryDefault;
this._snapBndLo = snapBoundaryDefault;
}
else {
this.setSnapBoundaryType();
this._snapBndTi = a[0];
this._snapBndRi = a[0];
this._snapBndBi = a[0];
this._snapBndLi = a[0];
this._snapBndTo = a[0];
this._snapBndRo = a[0];
this._snapBndBo = a[0];
this._snapBndLo = a[0];
}
}
else if (a.length == 2){
if (a[0] == 'inner'){
this.setSnapBoundaryType(a[0]);
this._snapBndTi = a[1];
this._snapBndRi = a[1];
this._snapBndBi = a[1];
this._snapBndLi = a[1];
}
else if (a[0] == 'outer'){
this.setSnapBoundaryType(a[0]);
this._snapBndTo = a[1];
this._snapBndRo = a[1];
this._snapBndBo = a[1];
this._snapBndLo = a[1];
}
else if (a[0] == 'both' || a[0] == null){
this.setSnapBoundaryType('both');
this._snapBndTi = a[1];
this._snapBndRi = a[1];
this._snapBndBi = a[1];
this._snapBndLi = a[1];
this._snapBndTo = a[1];
this._snapBndRo = a[1];
this._snapBndBo = a[1];
this._snapBndLo = a[1];
}
else if (typeof(a[0]) == 'number' && typeof(a[1]) == 'number'){
this.setSnapBoundaryType('both');
this._snapBndTi = a[0];
this._snapBndRi = a[0];
this._snapBndBi = a[0];
this._snapBndLi = a[0];
this._snapBndTo = a[1];
this._snapBndRo = a[1];
this._snapBndBo = a[1];
this._snapBndLo = a[1];
}
}
else if (a.length == 5){
if(a[0] == 'inner' || a[0] == 'outer' || a[0] == 'both'){
this.setSnapBoundaryType(a[0]);
}
if (this._snapBoundaryType == 'inner'){
this._snapBndTi = a[1];
this._snapBndRi = a[2];
this._snapBndBi = a[3];
this._snapBndLi = a[4];
}
else if (this._snapBoundaryType == 'outer'){
this._snapBndTo = a[1];
this._snapBndRo = a[2];
this._snapBndBo = a[3];
this._snapBndLo = a[4];
}
else if (this._snapBoundaryType == 'both'){
this._snapBndTi = a[1];
this._snapBndRi = a[2];
this._snapBndBi = a[3];
this._snapBndLi = a[4];
this._snapBndTo = a[1];
this._snapBndRo = a[2];
this._snapBndBo = a[3];
this._snapBndLo = a[4];
}
}
else if (a.length == 8){
this.setSnapBoundaryType('both');
this._snapBndTi = a[0];
this._snapBndRi = a[1];
this._snapBndBi = a[2];
this._snapBndLi = a[3];
this._snapBndTo = a[4];
this._snapBndRo = a[5];
this._snapBndBo = a[6];
this._snapBndLo = a[7];
}
else {
this.setSnapBoundaryType();
this._snapBndTi = snapBoundaryDefault;
this._snapBndRi = snapBoundaryDefault;
this._snapBndBi = snapBoundaryDefault;
this._snapBndLi = snapBoundaryDefault;
this._snapBndTo = snapBoundaryDefault;
this._snapBndRo = snapBoundaryDefault;
this._snapBndBo = snapBoundaryDefault;
this._snapBndLo = snapBoundaryDefault;
}
};
p.getSnapBoundary = function(t){
var To,Ro,Bo,Lo,Ti,Ri,Bi,Li,bndAry,X,Y,W,H;
X = this.x;
Y = this.y;
W = this.w;
H = this.h;
Ti = Y + this._snapBndTi;
Ri = X + W - this._snapBndRi;
Bi = Y + H - this._snapBndBi;
Li = X + this._snapBndLi;
To = Y - this._snapBndTo;
Ro = X + W + this._snapBndRo;
Bo = Y + H + this._snapBndBo;
Lo = X - this._snapBndLo;
if (t==null) bndAry = [Ti,Ri,Bi,Li,To,Ro,Bo,Lo];
else {
if (t=='inner') bndAry = [Ti,Ri,Bi,Li];
else if (t=='outer') bndAry = [To,Ro,Bo,Lo];
else if (t=='both') bndAry = [Ti,Ri,Bi,Li,To,Ro,Bo,Lo];
}
return(bndAry);
};
p._checkForSnap = function(){
switch (this._snapBoundaryType) {
case 'outer' :
this._checkForSnapOuter();
break;
case 'inner' :
this._checkForSnapInner();
break;
case 'both' :
this._checkForSnapInner();
this._checkForSnapOuter();
break;
default:
return(false);
}
};
p._checkForSnapInner = function(){
if (!this.parent.children.length>0) return(false);
if (!this.isSnapEnabled==true) return(false);
var ch,chX1,chY1,chX2,chY2,
chBiX1,chBiY1,chBiX2,chBiY2,
sX1,sY1,sX2,sY2,
chBndAry,sDir,
B1,B2a,B2b,B3,B4a,B4b,B5,B6a,B6b,B7,B8a,B8b,
D1,D2a,D2b,D3,D4a,D4b,D5,D6a,D6b,D7,D8a,D8b,
C1,C2a,C2b,C3,C4a,C4b,C5,C6a,C6b,C7,C8a,C8b;
sX1 = this.x;
sY1 = this.y;
sW = this.w;
sH = this.h;
sX2 = sX1 + sW;
sY2 = sY1 + sH;
sDir = this.getSnapDirection();
for (var i in this.parent.children){
ch = this.parent.children[i];
if (ch != this && ch.isSnapEnabled == true){
chX1 = ch.x;
chY1 = ch.y;
chX2 = chX1 + ch.w;
chY2 = chY1 + ch.h;
chBndAry = ch.getSnapBoundary('inner');
chBiX1 = chBndAry[3];
chBiY1 = chBndAry[0];
chBiX2 = chBndAry[1];
chBiY2 = chBndAry[2];
// Cases B1 - B8 test TRUE if source corner is in snap border.
// Cases D1 - D8 test TRUE if the corresponding direction of
// movement of the corner is towards the boundary.
// Cases C1 - C8 test TRUE if the corresponding B and D cases
// are true for standard or sticky snap.
// inner top-left corner, source top-left, move N, NW, W
B1 = (sX1 <= chBiX1 && sX1 > chX1 && sY1 <= chBiY1 && sY1 > chY1);
D1 = (sDir == 'N' || sDir == 'NW' || sDir == 'W');
C1 = (B1 && (D1 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner top-middle side, source top-left, move NE, N, NW
B2a = (sX1 > chBiX1 && sX1 < chBiX2 && sY1 <= chBiY1 && sY1 > chY1);
D2a = (sDir == 'NE' || sDir == 'N' || sDir == 'NW');
C2a = (B2a && (D2a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner top-middle side, source top-right, move NE, N, NW
B2b = (sX2 > chBiX1 && sX2 < chBiX2 && sY1 <= chBiY1 && sY1 > chY1);
D2b = (sDir == 'NE' || sDir == 'N' || sDir == 'NW');
C2b = (B2b && (D2b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner top-right corner, source top-right, move E, NE, N
B3 = (sX2 >= chBiX2 && sX2 < chX2 && sY1 <= chBiY1 && sY1 > chY1);
D3 = (sDir == 'E' || sDir == 'NE' || sDir == 'N');
C3 = (B3 && (D3 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner right-middle side, source top-right, move SE, E, NE
B4a = (sX2 >= chBiX2 && sX2 < chX2 && sY1 > chBiY1 && sY1 < chBiY2);
D4a = (sDir == 'SE' || sDir == 'E' || sDir == 'NE');
C4a = (B4a && (D4a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner right-middle side, source bottom-right, move SE, E, NE
B4b = (sX2 >= chBiX2 && sX2 < chX2 && sY2 > chBiY1 && sY2 < chBiY2);
D4b = (sDir == 'SE' || sDir == 'E' || sDir == 'NE');
C4b = (B4b && (D4b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner bottom-right corner, source lower-right, move dir E, SE, S
B5 = (sX2 >= chBiX2 && sX2 < chX2 && sY2 >= chBiY2 && sY2 < chY2);
D5 = (sDir == 'E' || sDir == 'SE' || sDir == 'S');
C5 = (B5 && (D5 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner bottom-middle side, source lower-left, move SW, S, SE
B6a = (sX1 > chBiX1 && sX1 < chBiX2 && sY2 >= chBiY2 && sY2 < chY2);
D6a = (sDir == 'SW' || sDir == 'S' || sDir == 'SE');
C6a = (B6a && (D6a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner bottom-middle side, source lower-right, move SW, S, SE
B6b = (sX2 > chBiX1 && sX2 < chBiX2 && sY2 >= chBiY2 && sY2 < chY2);
D6b = (sDir == 'SW' || sDir == 'S' || sDir == 'SE');
C6b = (B6b && (D6b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner bottom-left corner, source lower-left, move W, SW, S
B7 = (sX1 <= chBiX1 && sX1 > chX1 && sY2 >= chBiY2 && sY2 < chY2);
D7 = (sDir == 'W' || sDir == 'SW' || sDir == 'S');
C7 = (B7 && (D7 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner left-middle side, source top-left, move NW, W, SW
B8a = (sX1 <= chBiX1 && sX1 > chX1 && sY1 > chBiY1 && sY1 < chBiY2);
D8a = (sDir == 'NW' || sDir == 'W' || sDir == 'SW');
C8a = (B8a && (D8a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// inner left-middle side, source bottom-left, move NW, W, SW
B8b = (sX1 <= chBiX1 && sX1 > chX1 && sY2 > chBiY1 && sY2 < chBiY2);
D8b = (sDir == 'NW' || sDir == 'W' || sDir == 'SW');
C8b = (B8b && (D8b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
if (C1){
if (this.isGridSnapEnabled){
var tmpX = chX1 + ( Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY1 + ( Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX1, chY1);
}
}
else if (C3){
if (this.isGridSnapEnabled){
var tmpX = chX2 - ( Math.floor( ( chX2 - sX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY1 + ( Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX2-sW, chY1);
}
}
else if (C5){
if (this.isGridSnapEnabled){
var tmpX = chX2 - ( Math.floor( ( chX2 - sX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY2 - sH - ( Math.floor( ( chY2 - sY2 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX2-sW, chY2-sH);
}
}
else if (C7){
if (this.isGridSnapEnabled){
var tmpX = chX1 + ( Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY2 - sH - ( Math.floor( ( chY2 - sY2 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX1, chY2-sH);
}
}
else if (C2a || C2b){
if (this.isGridSnapEnabled){
var tmpX = chX1 + ( Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, chY1);
}
else {
this._snapSetLocation(sX1, chY1);
}
}
else if (C4a || C4b){
if (this.isGridSnapEnabled){
var tmpY = chY1 + ( Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(chX2-sW, tmpY);
}
else {
this._snapSetLocation(chX2-sW, sY1);
}
}
else if (C6a || C6b){
if (this.isGridSnapEnabled){
var tmpX = chX1 + ( Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, chY2-sH);
}
else {
this._snapSetLocation(sX1, chY2-sH);
}
}
else if (C8a || C8b){
if (this.isGridSnapEnabled){
var tmpY = chY1 + ( Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(chX1 , tmpY);
}
else {
this._snapSetLocation(chX1 , sY1);
}
}
if (C1 || C2a || C2b || C3 || C4a || C4b || C5 || C6a || C6b || C7 || C8a || C8b){
this._snapObject=ch;
this.invokeEvent("snap");
ch._snapObject=this;
ch.invokeEvent("snap");
}
}
}
};
p._checkForSnapOuter = function(){
if (! this.parent.children.length > 0) return(false);
if (! this.isSnapEnabled == true) return(false);
var ch,chX1,chY1,chX2,chY2,
chBoX1,chBoY1,chBoX2,chBoY2,
sX1,sY1,sX2,sY2,
chBndAry,sDir,
B1,B2a,B2b,B3,B4a,B4b,B5,B6a,B6b,B7,B8a,B8b,
D1,D2a,D2b,D3,D4a,D4b,D5,D6a,D6b,D7,D8a,D8b,
C1,C2a,C2b,C3,C4a,C4b,C5,C6a,C6b,C7,C8a,C8b;
/*
if(this.isGridSnapEnabled){
if( Math.abs( this._snapX - this._snapGridX ) > this._snapGridSize ) this._snapGridX=null;
if( Math.abs( this._snapY - this._snapGridY ) > this._snapGridSize ) this._snapGridY=null;
this._snapSetLocation( this._snapGridX || this._snapX, this._snapGridY || this._snapY );
}
*/
sX1 = this.x;
sY1 = this.y;
sW = this.w;
sH = this.h;
sX2 = sX1 + sW;
sY2 = sY1 + sH;
sDir = this.getSnapDirection();
for (var i in this.parent.children){
ch = this.parent.children[i];
if (ch != this && ch.isSnapEnabled == true){
chX1 = ch.x;
chY1 = ch.y;
chX2 = chX1 + ch.w;
chY2 = chY1 + ch.h;
chBndAry = ch.getSnapBoundary('outer');
chBoX1 = chBndAry[3];
chBoY1 = chBndAry[0];
chBoX2 = chBndAry[1];
chBoY2 = chBndAry[2];
// Cases B1 - B8 test TRUE if source corner is in snap border.
// Cases D1 - D8 test TRUE if the corresponding direction of
// movement of the corner is towards the boundary.
// Cases C1 - C8 test TRUE if the corresponding B and D cases
// are true for standard, sticky or grid snap.
// outer top-left corner, source lower-right, move dir E, SE, S
B1 = (sX2 >= chBoX1 && sX2 < chX1 && sY2 >= chBoY1 && sY2 < chY1);
D1 = (sDir == 'E' || sDir == 'SE' || sDir == 'S');
C1 = (B1 && (D1 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer top-middle side, source lower-left, move SW, S, SE
B2a = (sX1 >= chX1 && sX1 <= chX2 && sY2 >= chBoY1 && sY2 < chY1);
D2a = (sDir == 'SW' || sDir == 'S' || sDir == 'SE');
C2a = (B2a && (D2a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer top-middle side, source lower-right, move SW, S, SE
B2b = (sX2 >= chX1 && sX2 <= chX2 && sY2 >= chBoY1 && sY2 < chY1);
D2b = (sDir == 'SW' || sDir == 'S' || sDir == 'SE');
C2b = (B2b && (D2b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer top-right corner, source lower-left, move W, SW, S
B3 = (sX1 <= chBoX2 && sX1 > chX2 && sY2 >= chBoY1 && sY2 < chY1);
D3 = (sDir == 'W' || sDir == 'SW' || sDir == 'S');
C3 = (B3 && (D3 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer right-middle side, source top-left, move NW, W, SW
B4a = (sX1 <= chBoX2 && sX1 > chX2 && sY1 >= chY1 && sY1 <= chY2);
D4a = (sDir == 'NW' || sDir == 'W' || sDir == 'SW');
C4a = (B4a && (D4a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer right-middle side, source bottom-left, move NW, W, SW
B4b = (sX1 <= chBoX2 && sX1 > chX2 && sY2 >= chY1 && sY2 <= chY2);
D4b = (sDir == 'NW' || sDir == 'W' || sDir == 'SW');
C4b = (B4b && (D4b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer bottom-right corner, source top-left, move N, NW, W
B5 = (sX1 <= chBoX2 && sX1 > chX2 && sY1 <= chBoY2 && sY1 > chY2);
D5 = (sDir == 'N' || sDir == 'NW' || sDir == 'W');
C5 = (B5 && (D5 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer bottom-middle side, source top-left, move NE, N, NW
B6a = (sX1 >= chX1 && sX1 <= chX2 && sY1 <= chBoY2 && sY1 > chY2);
D6a = (sDir == 'NE' || sDir == 'N' || sDir == 'NW');
C6a = (B6a && (D6a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer bottom-middle side, source top-right, move NE, N, NW
B6b = (sX2 >= chX1 && sX2 <= chX2 && sY1 <= chBoY2 && sY1 > chY2);
D6b = (sDir == 'NE' || sDir == 'N' || sDir == 'NW');
C6b = (B6b && (D6b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer bottom-left corner, source top-right, move E, NE, N
B7 = (sX2 >= chBoX1 && sX2 < chX1 && sY1 <= chBoY2 && sY1 > chY2);
D7 = (sDir == 'E' || sDir == 'NE' || sDir == 'N');
C7 = (B7 && (D7 || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer left-middle side, source top-right, move SE, E, NE
B8a = (sX2 >= chBoX1 && sX2 < chX1 && sY1 >= chY1 && sY1 <= chY2);
D8a = (sDir == 'SE' || sDir == 'E' || sDir == 'NE');
C8a = (B8a && (D8a || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
// outer left-middle side, source bottom-right, move SE, E, NE
B8b = (sX2 >= chBoX1 && sX2 < chX1 && sY2 >= chY1 && sY2 <= chY2);
D8b = (sDir == 'SE' || sDir == 'E' || sDir == 'NE');
C8b = (B8b && (D8b || ch.isStickySnapEnabled || ch.isGridSnapEnabled));
if (C1){
if (this.isGridSnapEnabled){
var tmpX = chX1 - ( Math.floor( ( chX1 - sX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY1 - ( Math.floor( ( chY1 - sY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX1-sW, chY1-sH);
}
}
else if (C3){
if (this.isGridSnapEnabled){
var tmpX = chX1 + ( Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY1 - ( Math.floor( ( chY1 - sY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX2, chY1-sH);
}
}
else if (C5){
if (this.isGridSnapEnabled){
var tmpX = chX1 + ( Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY1 + ( Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX2, chY2);
}
}
else if (C7){
if (this.isGridSnapEnabled){
var tmpX = chX1 - ( Math.floor( ( chX1 - sX1 ) / this._snapGridSize ) ) * this._snapGridSize;
var tmpY = chY1 + ( Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) ) * this._snapGridSize;
this._snapSetLocation(tmpX, tmpY);
}
else {
this._snapSetLocation(chX1-sW, chY2);
}
}
else if (C2a || C2b){
if (this.isGridSnapEnabled){
//if(!this._snapGridY) this._snapGridY=chY1-sH;
//this._snapSetLocation(sX1 , this._snapGridY);
var tmpX = chX1 + Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) * this._snapGridSize;
this._snapSetLocation(tmpX , chY1-sH);
}
else {
this._snapSetLocation(sX1, chY1-sH);
}
}
else if (C4a || C4b){
if (this.isGridSnapEnabled){
//if(!this._snapGridX) this._snapGridX=chX2;
//this._snapSetLocation(this._snapGridX, sY1);
var tmpY = chY1 + Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) * this._snapGridSize;
this._snapSetLocation(chX2, tmpY);
}
else {
this._snapSetLocation(chX2, sY1);
}
}
else if (C6a || C6b){
if (this.isGridSnapEnabled){
//if(!this._snapGridY) this._snapGridY=chY2;
//this._snapSetLocation(sX1 , this._snapGridY);
var tmpX = chX1 + Math.floor( ( sX1 - chX1 ) / this._snapGridSize ) * this._snapGridSize;
this._snapSetLocation(tmpX , chY2);
}
else {
this._snapSetLocation(sX1, chY2);
}
}
else if (C8a || C8b){
if (this.isGridSnapEnabled){
//if(!this._snapGridX) this._snapGridX=chX1-sW;
//this._snapSetLocation(chX1-sW , sY1);
var tmpY = chY1 + Math.floor( ( sY1 - chY1 ) / this._snapGridSize ) * this._snapGridSize;
this._snapSetLocation(chX1-sW, tmpY);
}
else {
this._snapSetLocation(chX1-sW, sY1);
}
}
if (C1 || C2a || C2b || C3 || C4a || C4b || C5 || C6a || C6b || C7 || C8a || C8b){
this._snapObject=ch;
this.invokeEvent("snap");
ch._snapObject=this;
ch.invokeEvent("snap");
}
}
}
};

View File

@ -1,182 +0,0 @@
/*
DynAPI Distribution
Swiper Animation Extension - originally designed by Erik Arvidsson (http://web.eae.net)
IncDec addon - Created by Daniel Tiru (http://www.tiru.se)
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: DynLayer
*/
Swiper = {}; // used by dynapi.library
DynLayer.prototype.swipeTo = function(dir, steps, ms, min) {
this._swipeSteps = (steps!=null)? steps: 4;
this._swipeMS = (ms!=null)? ms:25;
this._swipeDir=dir;
this._swiperMin=min;
if (this._swiperMinimized==null) {
this._swiperMinimized = 0
}
if (this.swipeTimer != null) window.clearTimeout(this.swipeTimer);
if (!this._swipeCnt) { // No animation yet!
this._swipeOrgX = this.getX();
this._swipeOrgY = this.getY();
this._swipeOrgWidth = this.getWidth();
this._swipeOrgHeight = this.getHeight();
}
this._swipeCnt = this._swipeSteps;
if (dir.substr(0,3)!='dec' && dir.substr(0,3)!='inc') {
this.setClip([0,0,0,0]);
}
window.setTimeout(this+"._swipe()", this._swipeMS);
};
DynLayer.prototype._swipe = function() {
var steps = this._swipeSteps;
var x = this._swipeOrgX;
var y = this._swipeOrgY;
var w = this._swipeOrgWidth;
var h = this._swipeOrgHeight;
var min = this._swiperMin;
if (this._swipeCnt == 0) {
if (this._swipeDir.substr(0,3)!='dec' && this._swipeDir.substr(0,3)!='inc') {
this.setClip([0, w, h,0]);
}
else if(this._swipeDir.substr(0,3)=='dec') {
this._swiperMinimized=1;
}
else if(this._swipeDir.substr(0,3)=='inc') {
this._swiperMinimized=0;
}
this.invokeEvent('swipefinish');
return;
}
else {
this._swipeCnt--;
this.setVisible(true);
switch (this._swipeDir) {
case "bottom": //down (see the numpad)
this.setClip([h * this._swipeCnt / steps, w, h, 0]);
this.setY(y - h * this._swipeCnt / steps);
break;
case "top":
this.setClip([0, w, h * (steps - this._swipeCnt) / steps, 0]);
this.setY(y + h * this._swipeCnt / steps);
break;
case "right":
this.setClip([0, w, h,w * this._swipeCnt / steps]);
this.setX(x - w * this._swipeCnt / steps);
break;
case "left":
this.setClip([0, w * (steps - this._swipeCnt) / steps, h, 0]);
this.setX(x + w * this._swipeCnt / steps);
break;
case "bottom-right":
this.setClip([h * this._swipeCnt / steps, w, h, w * this._swipeCnt / steps]);
this.setX(x - w * this._swipeCnt / steps);
this.setY(y - h * this._swipeCnt / steps);
break;
case "bottom-left":
this.setClip([h * this._swipeCnt / steps, w * (steps - this._swipeCnt) / steps, h, 0]);
this.setX(x + w * this._swipeCnt / steps);
this.setY(y - h * this._swipeCnt / steps);
break;
case "top-left":
this.setClip([0, w * (steps - this._swipeCnt) / steps, h * (steps - this._swipeCnt) / steps, 0]);
this.setX(x + w * this._swipeCnt / steps);
this.setY(y + h * this._swipeCnt / steps);
break;
case "top-right":
this.setClip([0, w, h * (steps - this._swipeCnt) / steps, w * this._swipeCnt / steps]);
this.setX(x - w * this._swipeCnt / steps);
this.setY(y + h * this._swipeCnt / steps);
break;
// inc-dec
case "dec-right":
if (this._swiperMinimized==0) {
if ((w/steps*this._swipeCnt) > min) {
this.setClip([0, (w/steps*this._swipeCnt), h, 0]);
}
else this.setClip([0, min, h, 0]);
}
break;
case "inc-right":
//var clippos = this.getClip().toString().split(',');
if (this.getClip()[1] < w-(w/steps*this._swipeCnt)) {
if (this._swiperMinimized==1) {
this.setClip([0, w-(w/steps*this._swipeCnt), h, 0]);
}
}
break;
case "dec-left":
if (this._swiperMinimized==0) {
if ((w/steps*this._swipeCnt) > min) {
this.setClip([0, Math.round(w/steps*this._swipeCnt), h, 0]);
this.setX(w+(x-(Math.round(w/steps*this._swipeCnt))));
}
else{
this.setClip([0, min, h, 0]);
this.setX(w+x-min);
}
}
break;
case "inc-left":
if (this._swiperMinimized==1) {
if (this.getClip()[1] < w-Math.round(w/steps*this._swipeCnt)) {
this.setClip([0, w-Math.round(w/steps*this._swipeCnt), h, 0]);
if (w-(w/steps*this._swipeCnt) < x) {
this.setX(x-(w-Math.round(w/steps*(this._swipeCnt)+min)));
}
else this.setX((steps*w/steps)-(x));
}
}
break;
case "dec-down":
if (this._swiperMinimized==0) {
if ((h/steps*this._swipeCnt) > min) {
this.setClip([0, w, (h/steps*this._swipeCnt), 0]);
}
else this.setClip([0, w, min, 0]);
}
break;
case "inc-down":
if (this._swiperMinimized==1) {
if (this.getClip()[2] < h-(h/steps*this._swipeCnt)) {
this.setClip([0,w, h-(h/steps*this._swipeCnt), 0]);
}
}
break;
case "dec-up":
if (this._swiperMinimized==0) {
if ((h/steps*this._swipeCnt) > min) {
this.setClip([0, w, Math.round(h/steps*this._swipeCnt), 0]);
this.setY((h+y-(Math.round(h/steps*this._swipeCnt))));
}
else{
this.setClip([0, w, min, 0]);
this.setY(h+y-min);
}
}
break;
case "inc-up":
if (this._swiperMinimized==1) {
if (this.getClip()[2] < h-Math.round(h/steps*this._swipeCnt)) {
this.setClip([0, w, h-Math.round(h/steps*this._swipeCnt), 0]);
if (h-(h/steps*this._swipeCnt) < y) {
this.setY(y-(h-Math.round(h/steps*(this._swipeCnt)+min)));
}
else this.setY((steps*h/steps)-(y-min));
}
}
break;
}
this.swipeTimer = window.setTimeout(this+"._swipe()", this._swipeMS);
}
};

View File

@ -1,293 +0,0 @@
/*
DynAPI Distribution
Fader Animation Extension
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: DynLayer, Fader
*/
function TextAnimation(x,y,text,animBy,dlyr){
this.EventObject = EventObject;
this.EventObject();
this._chars=[];
this._lyrPool=[];
this._text=text;
this._animBy=null;
this._inUse=0;
this._dlyr=(dlyr||dynapi.document);
this.setLocation(x,y);
this.animateBy(animBy);
this.visible=true;
var me=this; // use delegate "me"
var fn=function(){
me._created=true;
me._split();
}
if(this._dlyr!=dynapi.document) this._dlyr.onCreate(fn);
else {
var e={onload:fn};
this._dlyr.addEventListener(e);
}
};
var p = dynapi.setPrototype('TextAnimation','EventObject');
p._clear = function(){
var l;
var p=this._lyrPool;
var c=this._chars;
for(var i=0;i<c.length;i++){
l=c[i];
l.setVisible(false);
l.removeAllEventListeners();
p[p.length]=l;
}
this._chars.length=0;
};
p._createCharLayer=function(t){
var l;
var p=this._lyrPool;
if (!p.length) l = this._dlyr.addChild(new DynLayer());
else {
l = p[p.length-1];
p.length--;
};
l._ta=this;
l.setHTML(t);
if(l._created) {
// resize char layer
l.setSize(1,1); // why mozilla,gecko,ie??
l.setSize(l.getContentWidth(),l.getContentHeight());
}
l.setVisible(this.visible);
if(dynapi.ua.ie) l.css.filter='alpha(opacity=100)';
else l.css.MozOpacity = 1;
return l;
};
p._exec = function(cmd,i){
window.setTimeout(cmd,(this._ms*i)+5);
};
p._resize=function(align){
var x=this.x;
var y=this.y;
var i,l,c=this._chars;
for(i=0;i<c.length;i++){
l=c[i]; // resize char layer
if(l._created) {
l.setSize(1,1); // why mozilla,gecko,ie??
l.setSize(l.getContentWidth(),l.getContentHeight());
if(align) {
l.setLocation(x,y);
x+=l.w;
}
}
}
};
p._split = function(){
var i,ar,lyr;
var t=this._text;
var c=this._chars;
var x=this.x;
var y=this.y;
if(!t||!this._created) return;
this._clear();
if(this._animBy=='all') { // By all
t='<nobr>'+t+'</nobr>';
lyr=c[0]=this._createCharLayer(t);
lyr.setLocation(x,y);
}else { // By word or letter
if (this._animBy=='word') {
t=t.replace(/\s/g,' &nbsp; ');
ar=t.split(' ');
}
else {
ar=t.split('');
}
for(i=0;i<ar.length;i++){
if (ar[i]==' ') ar[i]='&nbsp;';
lyr=c[i]=this._createCharLayer(ar[i]);
lyr.setLocation(x,y);
x+=lyr.w;
}
}
if(lyr) lyr.addEventListener(TextAnimation._tiggerEvents);
};
p.animateBy=function(s,delay){ // all, letter, word
this._animBy=s||this._animBy||'letter';
this.setDelay(delay);
this._split();
};
p.getCharLayer = function(i){
if (i>=0 && i<this.chars.length) return this.chars[i];
};
p.setDelay = function(delay){
this._ms=delay||this._ms||50;
};
p.setFont=function(size,family){
};
p.setLocation=function(x,y){
x=x||0; y=y||0;
var byX=x-this.x;
var byY=y-this.y;
var c=this._chars;
this.x=x; this.y=y;
for (var i=0;i<c.length;i++){
l=c[i]; l.setLocation(l.x+byX,l.y+byY);
}
};
p.setText=function(t,animBy,delay){
this._text=t||'';
this.setDelay(delay);
this.animateBy(animBy);
};
p.setVisible = function(b){
var c=this._chars;
this.visible=b;
for (var i=0;i<c.length;i++) c[i].setVisible(b);
};
// Trigger Events
var fn = function(e){
var o=e.getSource();
o._ta._inUse--;
if(!o._ta._inUse) window.setTimeout(o._ta+'.invokeEvent("animfinish")',55);
};
TextAnimation._tiggerEvents = {
onpathfinish:fn,
onfadein:fn,
onfadeout:fn
};
// Effects
// ------------------------
// Apear
p.appear = function(){
var i,ext,c=this._chars;
this._exec(this+'.invokeEvent("animstart")',1);
for (i=0;i<c.length;i++) {
if(!this._inUse) c[i].setVisible(false);
if(i==(c.length-1)) ext=c[i]+'.invokeEvent("pathfinish")';
this._exec(c[i]+'.setVisible(true);;'+ext,i);
}
this._inUse++;
};
// Bounce
p.bounce = function(h,modifier){
var i,l,c;
c=this._chars;
h=(h||100);
modifier=(modifier<-1)? -1:(modifier||0);
this._exec(this+'.invokeEvent("animstart")',1);
// setup bounce chars
for (i=0;i<c.length; i++) {
l=c[i];
l._bonctmr=i<<modifier;
l._boncyv=0;
l._boncmaxv=8;
l._boncy=-l.h;
l.setLocation(null,this.y-h);
if(!this._inUse) l.setVisible(true);
this._exec(this+'._startBounce('+i+','+h+');',i);
}
this._inUse++;
};
p._startBounce = function(i,h){
var l,y,c,ext;
var c=this._chars;
l=c[i];
if (l._bonctmr>0) l._bonctmr--;
else {
yv=l._boncyv;
//y=l._boncy;
l._boncy+=yv;
if (yv<l._boncmaxv) l._boncyv++;
if (l._boncy>h-l.h) {
l._boncy=h-l.h;
l._boncyv=-l._boncyv;
if (l._boncmaxv>0) l._boncmaxv--;
}
l.setLocation(null,(this.y-h)+l._boncy+l.h);
}
if(l._boncmaxv!=0){
this._exec(this+'._startBounce('+i+','+h+');'+ext,1);
}
else if(i==(c.length-1)) {
this._exec(l+'.invokeEvent("pathfinish")',1);
}
};
// Fade In
p.fadeIn = function(inc,ms){
var i,c=this._chars;
this._exec(this+'.invokeEvent("animstart")',1);
for (i=0;i<c.length;i++) this._exec(c[i]+'.fadeIn('+inc+','+ms+');',i);
this._inUse++;
};
// Fade Out
p.fadeOut = function(inc,ms){
var i,c=this._chars;
this._exec(this+'.invokeEvent("animstart")',1);
for (i=0;i<c.length;i++) this._exec(c[i]+'.fadeOut('+inc+','+ms+');',i);
this._inUse++;
};
// Fly From
p.flyFrom = function(x,y,inc,ms){
var i,l,c=this._chars;
this._exec(this+'.invokeEvent("animstart")',1);
for (i=0;i<c.length;i++) {
l=c[i];
this._exec(
((!this._inUse)? l+'.setVisible(true);':'')
+l+'.slideTo('+l.x+','+l.y+','+inc+','+ms+');'
,i);
l.setLocation(x,y);
}
this._inUse++;
};
p.zoomText = function(from,to,inc,ms){
var i,l,c;
c=this._chars;
this._exec(this+'.invokeEvent("animstart")',1);
// setup chars
for (i=0;i<c.length; i++) {
l=c[i];
l._zTo = to||20;
l._zFrom = from||10;
l._zMs=(ms)? ms:50;
l._zInc=(inc)? Math.abs(inc):5;
l.css.fontSize=l._zFrom+'px';
if (l._zFrom>l._zTo) l._zInc*=-1;
if(!this._inUse) l.setVisible(true);
this._exec(this+'._startZoom('+i+');',i);
}
this._inUse++;
};
p._startZoom= function(i){
var l,y,c,ext;
var l=this._chars[i];
var inc = l._zInc;
var from = l._zFrom;
var to = l._zTo;
from+=inc;
if ((inc<0 && from<=to)|| (inc>0 && from>=to)) from=to;
l._zFrom=from;
l.css.fontSize=from+'px';
l.setSize(0,0); // ??
l.setSize(l.getContentWidth(),l.getContentHeight());
if(i==0) l.setLocation(null,this.y-(l.h/2));
else l.setLocation(this._chars[i-1].x+this._chars[i-1].w,this.y-(l.h/2));
if(from!=to) l._zTmr=window.setTimeout(this+'._startZoom('+i+')',l._zMs);
else if(i==(this._chars.length-1)) {
this._exec(l+'.invokeEvent("pathfinish")',1);
}
};
// to-do:
p.wave = function(){};
p.nudge = function(){};
p.quake = function(){};

View File

@ -1,64 +0,0 @@
/*
DynAPI Distribution
Glide Animation Extension
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: DynLayer, dynapi.functions.Math
*/
function Thread(dlyr) {
this.DynObject = DynObject;
this.DynObject();
if (dlyr) this.dlyr = dlyr;
else dlyr = this; // if no dynlayer passed it calls events onto itself
this._frame = 0;
this._path = null;
this.loop = false;
}
var p = dynapi.setPrototype('Thread','DynObject');
p.interval = 20;
p.sleep = function (ms) {
this.interval = Math.abs(parseInt(ms));
if (this._timer) this.start();
};
p._restart = function () { // starts, or restarts if necessary
this.stop(false);
setTimeout(this+'.start()',this.interval+1);
};
p.start = function () { // starts, or restarts if necessary
if (this._timer) this._restart();
else {
this.dlyr.invokeEvent("threadstart");
this._timer = setInterval(this+'.run()',this.interval);
}
};
p.run = function () {
var p=this._path, d=this.dlyr;
this.dlyr.invokeEvent("threadrun");
if (p && this.dlyr!=this && this._timer) {
if (this._frame>=p.length/2) {
if (this.loop) this._frame = 0;
else {
this.stop(false);
this.dlyr.invokeEvent("threadfinish");
return;
}
}
if (this._frame==0 && (d.x==p[0] && d.y==p[1])) this.frame += 1; // already at 1st coordinate
d.setLocation(p[this._frame*2],p[this._frame*2+1]);
this._frame++;
}
};
p.stop = function (noevt) {
clearInterval(this._timer);
this._timer = null;
this._frame = 0;
if (noevt!=false) this.dlyr.invokeEvent("threadstop");
};
p.play = function (path) {
this._path = path;
this.start();
};

View File

@ -1,44 +0,0 @@
/*
DynAPI Distribution
TimerX Class by Raymond Irving (http://dyntools.shorturl.com)
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
requires: Dynlayer
*/
TimerX = {}; // used by dynapi.library
p = DynLayer.prototype;
p.startTimer=function(interval) {
if (this.tickTimer>0) this.stopTimer();
this._timerInterval=interval||5;
this._timerTickCount=0;
this._timerStoped=false;
this._tickTimer=setTimeout(this+'.tickLoop()',this._timerInterval);
};
p.tickLoop=function() {
if (this._timerStoped==true||this._timerStoped==null) return;
this._timerTickCount++;
this.invokeEvent("timer");
this._tickTimer=window.setTimeout(this+'.tickLoop()',this._timerInterval);
};
p.stopTimer=function() {
this._timerStoped=true;
clearTimeout(this._tickTimer);
};
p.setTimerInterval=function(interval) {
this._timerInterval=interval||this._timerInterval;
};
p.getTimerInterval=function() {
return this._timerInterval;
};
p.getTickCount=function() {
return this._timerTickCount;
};
p.resetTickCount=function() {
this._timerTickCount=0;
};

View File

@ -1,5 +0,0 @@
<version>
<major>3</major>
<minor>0</minor>
<revision>0</revision>
</version>

View File

@ -1,28 +0,0 @@
Usage instructions for foldertree.js
foldertree was modified for egw by NDEE 2004
============================================
detailed instructions follow shortly
Definition of vars passed to function add Node()
Node(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open)
where
id = increasing number beginning from 0 (-1=Tree-Root)
pid = id of parent node
name = name of node
url = url of node's link
urlClick = js command for onClick
urlOut = js command(s) for onMouseOUt
title = Popup Title
target = target frame
icon = icon :)
iconOpen = special icon when opened
open = TRUE/FALSE id to make node open on start
vars to follow
urlOver = js command(s) for onMouseOver (dont use currently!)
urlUp = js command(s) for onMouseUp

View File

@ -1,368 +0,0 @@
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landrö |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/
// modified for egw 29-12-03 ndee
// 27-01-04 ndee: amended function dtree() with parameter for php based icondir
// Node object
function Node(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.urlClick = urlClick;
this.urlOut = urlOut;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName,icondir) {
iconPath = (icondir !='') ? icondir : '/egroupware/phpgwapi/templates/default/images';
this.icon = {
root : iconPath+'/foldertree_base.gif',
folder : iconPath+'/foldertree_folder.gif',
folderOpen : iconPath+'/foldertree_folderopen.gif',
node : iconPath+'/foldertree_folder.gif',
empty : iconPath+'/foldertree_empty.gif',
line : iconPath+'/foldertree_line.gif',
join : iconPath+'/foldertree_join.gif',
joinBottom : iconPath+'/foldertree_joinbottom.gif',
plus : iconPath+'/foldertree_plus.gif',
plusBottom : iconPath+'/foldertree_plusbottom.gif',
minus : iconPath+'/foldertree_minus.gif',
minusBottom : iconPath+'/foldertree_minusbottom.gif',
nlPlus : iconPath+'/foldertree_nolines_plus.gif',
nlMinus : iconPath+'/foldertree_nolines_minus.gif'
};
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false, //must be set to false for drag and drop! change-me!
closeSameLevel : false,
inOrder : false,
useJSCode : true
}
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};
// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
// commented, so we dont have all same root icons (NDEE)
//node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.title + '\';return true;" onmouseout="window.status=\'\';return true;" ';
// added 02-01-03 NDEE
// for easier JS code in links
//if (this.config.useJSCode) str += ' onClick="alert(\'' + node.urlClick + '\');return true;"';
if (this.config.useJSCode) str += ' onClick="' + node.urlClick + '"';
if (this.config.useJSCode) str += ' onMouseOut="' + node.urlOut + '"';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};
// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};
// Highlights the selected node
dTree.prototype.s = function(id) {
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
};
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};
// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};
// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Closes all children of a node
dTree.prototype.closeAllChildren = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom) {
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
};
// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};
// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};
// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
};
// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id) {
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
};
// If Push and pop is not implemented by the browser
if (!Array.prototype.push) {
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
};
if (!Array.prototype.pop) {
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
};

View File

@ -1,164 +0,0 @@
/***************************************************************************\
* eGroupWare - Javascript API *
* http://www.egroupware.org *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* - Vinicius Cubas Brand <viniciuscb@users.sourceforge.net> *
* sponsored by Think.e - http://www.think-e.com.br *
* ------------------------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\***************************************************************************/
/*
* eGroupWare Global API - Categories Handling Floating Window
*
*/
function egwCategoriesPlugin()
{
this.window = null;
this.selectedCategories = new Array();
this.categories = new Array();
this.postURL = GLOBALS['serverRoot']+'/xmlrpc.php';
//user-defined method to execute when window closes
this.onCloseHandler = null;
//user-defined method to execute when window changes
this.onChangeHandler = null;
this.DOM = new Object();
// Initialization
this.DOM.egw_categories = Element("egw_categories");
this.DOM.egw_categories_change = Element("egw_categories_change");
this.DOM.egw_categories_w_form = Element("egw_categories_w_form");
this.DOM.egw_categories_wcontent = Element("egw_categories_wcontent");
this.DOM.egw_categories_title = Element("egw_categories_title");
this.window = new dJSWin(
{ 'id': 'egwCategories',
'content_id': 'egw_categories_wcontent',
'win_class': 'row_off',
'width': '200px',
'height': '120px',
'title_color': '#3978d6',
'title': this.DOM.egw_categories_title.value,
'title_text_color': 'white',
'button_x_img': GLOBALS['egw_img_dir']+'/winclose.gif',
'border': true});
}
//receives an object with keys=keys of select, vals=vals to show
egwCategoriesPlugin.prototype.populate = function(population)
{
this.categories = population;
clearSelectBox(this.DOM.egw_categories,0);
fillSelectBox(this.DOM.egw_categories,this.categories);
this.selectedCategories = new Array();
}
//receives array or object with values=categories ids, fetch categories
//from egw via rpc call
egwCategoriesPlugin.prototype.setCategories = function(categories)
{
}
egwCategoriesPlugin.prototype.selectCategories = function(selected)
{
this.selectedCategories = selected;
selectOptions(this.DOM.egw_categories,this.selectedCategories);
}
//gets all selected categories values
egwCategoriesPlugin.prototype.getSelectedIDs = function()
{
return this.selectedCategories;
}
//gets all selected categories values
egwCategoriesPlugin.prototype.getSelectedNames = function()
{
var ret = new Array();
for (var i in this.selectedCategories)
{
ret.push(this.categories[this.selectedCategories[i]]);
}
return ret;
}
//gets all selected categories values
egwCategoriesPlugin.prototype.getSelectedCategories = function()
{
var ret = new Object();
for (var i in this.selectedCategories)
{
ret[this.selectedCategories[i]] = (this.categories[this.selectedCategories[i]]);
}
return ret;
}
egwCategoriesPlugin.prototype.close = function ()
{
this.window.close();
}
egwCategoriesPlugin.prototype.open = function ()
{
this.window.open();
}
egwCategoriesPlugin.prototype.setOnChangeHandler = function(func)
{
this.onChangeHandler = func;
}
/*********************************************************************\
* Private Methods *
\*********************************************************************/
//method to execute when window closes without saving
egwCategoriesPlugin.prototype._onClose = function()
{
if (typeof(this.onCloseHandler) == 'function')
{
this.onCloseHandler();
}
}
//method to execute when window changes its value
egwCategoriesPlugin.prototype._changeCategories = function(handler)
{
this.selectedCategories = getSelectedOptions(this.DOM.egw_categories);
if (typeof(this.onChangeHandler) == 'function')
{
this.onChangeHandler();
}
this.window.close();
}
egwCategoriesPlugin.prototype._clearAll = function ()
{
// Clear information container
this.selectedCategories = new Array();
// Clear Fields
this.DOM.egw_categories_w_form.reset();
}
egwCategoriesPlugin.prototype._disableAll = function ()
{
}
//just in the end of tpl
//egwCategories = new egwCategoriesPlugin();

View File

@ -1,17 +1,15 @@
/***************************************************************************\
* eGroupWare - JavaScript API *
* http://www.egroupware.org *
* Written by: *
* - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
* - Jonas Goes <jqhcb@users.sourceforge.net> *
* - Vinicus Cubas Brand <viniciuscb@users.sourceforge.net> *
* sponsored by Thyamad - http://www.thyamad.com *
* ------------------------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or (at *
* your option) any later version. *
\***************************************************************************/
/**
* eGroupWare - API
* http://www.egroupware.org
*
* This file was originally created Tyamad, but their content is now completly removed!
* It still contains some commonly used javascript functions, always included by EGroupware.
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage jsapi
* @version $Id$
*/
/***********************************************\
* INITIALIZATION *
@ -41,485 +39,6 @@ else if (document.layers)
is_ns4 = true;
}
// DO NOT CHANGE THIS!!! Enable DEBUG inside Application!
var DEBUG = false;
/***********************************************\
* DATA FUNCTIONS *
\***********************************************/
function serialize(data)
{
var f = function(data)
{
var str_data;
if (data == null ||
(typeof(data) == 'string' && data == ''))
{
str_data = 'N;';
}
else switch(typeof(data))
{
case 'object':
var arrayCount = 0;
str_data = '';
for (i in data)
{
if (i == 'length')
{
continue;
}
arrayCount++;
switch (typeof(i))
{
case 'number':
str_data += 'i:' + i + ';' + serialize(data[i]);
break;
case 'string':
str_data += 's:' + i.length + ':"' + i + '";' + serialize(data[i]);
break;
default:
showMessage(Element('cc_msg_err_serialize_data_unknown').value);
break;
}
}
if (!arrayCount)
{
str_data = 'N;';
}
else
{
str_data = 'a:' + arrayCount + ':{' + str_data + '}';
}
break;
case 'string':
str_data = 's:' + data.length + ':"' + data + '";';
break;
case 'number':
str_data = 'i:' + data + ';';
break;
case 'boolean':
str_data = 'b:' + (data ? '1' : '0') + ';';
break;
default:
showMessage(Element('cc_msg_err_serialize_data_unknown').value);
return null;
}
return str_data;
}
var sdata = f(data);
return sdata;
}
function unserialize(str)
{
var f = function (str)
{
switch (str.charAt(0))
{
case 'a':
var data = new Array();
var n = parseInt( str.substring( str.indexOf(':')+1, str.indexOf(':',2) ) );
var arrayContent = str.substring(str.indexOf('{')+1, str.lastIndexOf('}'));
for (var i = 0; i < n; i++)
{
var pos = 0;
/* Process Index */
var indexStr = arrayContent.substr(pos, arrayContent.indexOf(';')+1);
var index = unserialize(indexStr);
pos = arrayContent.indexOf(';', pos)+1;
/* Process Content */
var part = null;
switch (arrayContent.charAt(pos))
{
case 'a':
var pos_ = matchBracket(arrayContent, arrayContent.indexOf('{', pos))+1;
part = arrayContent.substring(pos, pos_);
pos = pos_;
data[index] = unserialize(part);
break;
case 's':
var pval = arrayContent.indexOf(':', pos+2);
var val = parseInt(arrayContent.substring(pos+2, pval));
pos = pval + val + 4;
data[index] = arrayContent.substr(pval+2, val);
break;
default:
part = arrayContent.substring(pos, arrayContent.indexOf(';', pos)+1);
pos = arrayContent.indexOf(';', pos)+1;
data[index] = unserialize(part);
break;
}
arrayContent = arrayContent.substr(pos);
}
break;
case 's':
var pos = str.indexOf(':', 2);
var val = parseInt(str.substring(2,pos));
var data = str.substr(pos+2, val);
str = str.substr(pos + 4 + val);
break;
case 'i':
case 'd':
var pos = str.indexOf(';');
var data = parseInt(str.substring(2,pos));
str = str.substr(pos + 1);
break;
case 'N':
var data = null;
str = str.substr(str.indexOf(';') + 1);
break;
case 'b':
var data = str.charAt(2) == '1' ? true : false;
break;
}
return data;
}
return f(str);
}
function matchBracket(strG, iniPosG)
{
var f = function (str, iniPos)
{
var nOpen, nClose = iniPos;
do
{
nOpen = str.indexOf('{', nClose+1);
nClose = str.indexOf('}', nClose+1);
if (nOpen == -1)
{
return nClose;
}
if (nOpen < nClose )
{
nClose = matchBracket(str, nOpen);
}
} while (nOpen < nClose);
return nClose;
}
return f(strG, iniPosG);
}
/***********************************************\
* DATE FUNCTIONS *
\***********************************************/
/**
* Converts a date string into an object second to a php date() date format.
*
* The result object have three indexes: day, month and year; (now currently
* only accepts d , m , and Y in any position and with any separator in the
* (input) date description string).
*
* @author Vinicius Cubas Brand <vinicius@users.sourceforge.net>
*
* @param string dateString The date string in a format described in
* phpDateFormat, like for instance '2005/02/09'
* @param string phpDateFormat The date descriptor in a php date() format,
* like for instance 'Y/m/d'
*
* @todo Other types handling
*/
function strtodate(dateString,phpDateFormat)
{
var _this = this;
var elements = new Object;
this.tmpelm = elements;
elements['d'] = { leng: 2, pos:-1};
elements['m'] = { leng: 2, pos:-1};
elements['Y'] = { leng: 4, pos:-1};
//array to populate - sort order
var indexes = new Array();
for (var i in elements)
{
elements[i]['pos'] = phpDateFormat.indexOf(i);
indexes.push(i);
}
function sortingFunction(a,b) {
return _this.tmpelm[a]['pos'] - _this.tmpelm[b]['pos'];
};
indexes.sort(sortingFunction);
var offset = 0;
for (var i in indexes)
{
var curr_index = indexes[i];
elements[curr_index]['start_pos'] = elements[curr_index]['pos'] + offset;
offset += elements[curr_index]['leng'] - 1;
}
for (var i in elements)
{
switch (i)
{
case 'd':
var day = parseInt(dateString.slice(elements[i]['start_pos'],elements[i]['start_pos']+elements[i]['leng']));
break;
case 'm':
var month = parseInt(dateString.slice(elements[i]['start_pos'],elements[i]['start_pos']+elements[i]['leng']));
break;
case 'Y':
var year = parseInt(dateString.slice(elements[i]['start_pos'],elements[i]['start_pos']+elements[i]['leng']));
break;
}
}
var ret = new Object();
ret['year'] = year;
ret['month'] = month - 1;
ret['day'] = day;
return ret;
}
/***********************************************\
* AUXILIAR FUNCTIONS *
\***********************************************/
/*
function js2xmlrpc
@param methodName the name of the method, for instance appointmentcenter.uixmlresponder.test
@param args all args in sequence, passed to the xml-rpc method
@return xml-rpc string corresponding to js objects passed in args
*/
function js2xmlrpc(methodName)
{
var msg = new XMLRPCMessage(methodName);
for (var i = 1; i< arguments.length; i++)
{
if (i==1 && GLOBALS['extra_get_vars'] && typeof(arguments[i]) == 'object'
&& typeof(GLOBALS['extra_get_vars']) == 'object')
{
arguments[i]['extra_get_vars'] = GLOBALS['extra_get_vars'];
}
msg.addParameter(arguments[i]);
}
return msg.xml();
}
/*
function xmlrpc2js
@param responseText The xml-rpc text of return of a xml-rpc function call
@return Javascript object corresponding to the given xmlrpc
*/
var xmlrpcHandler = null;
function xmlrpc2js(responseText)
{
if (!xmlrpcHandler || typeof(xmlrpcHandler) != 'object')
{
xmlrpcHandler = importModule("xmlrpc");
}
return xmlrpcHandler.unmarshall(responseText);
}
function resizeIcon(id, action)
{
var element = Element(id);
if (action == 0)
{
CC_old_icon_w = element.style.width;
CC_old_icon_h = element.style.height;
element.style.zIndex = parseInt(element.style.zIndex) + 1;
element.style.width = '36px';
element.style.height = '36px';
element.style.top = (parseInt(element.style.top) - parseInt(element.style.height)/2) + 'px';
element.style.left = (parseInt(element.style.left) - parseInt(element.style.width)/2) + 'px';
}
else if (action == 1)
{
element.style.zIndex = parseInt(element.style.zIndex) - 1;
element.style.top = (parseInt(element.style.top) + parseInt(element.style.height)/2) + 'px';
element.style.left = (parseInt(element.style.left) + parseInt(element.style.width)/2) + 'px';
element.style.width = CC_old_icon_w;
element.style.height = CC_old_icon_h;
}
}
function Element (element)
{
/* IE OBJECTS */
if (document.all)
{
return document.all[element];
}
/* MOZILLA OBJECTS */
else if (document.getElementById)
{
return document.getElementById(element);
}
/* NS4 OBJECTS */
else if (document.layers)
{
return document.layers[element];
}
}
function removeHTMLCode(id)
{
Element(id).parentNode.removeChild(Element(id));
}
function addHTMLCode(parent_id,child_id,child_code,surround_block_tag)
{
var obj = document.createElement(surround_block_tag);
Element(parent_id).appendChild(obj);
obj.id = child_id;
obj.innerHTML = child_code;
return obj;
}
function adjustString (str, max_chars)
{
if (str.length > max_chars)
{
return str.substr(0,max_chars) + '...';
}
else
{
return str;
}
}
function addSlashes(code)
{
for (var i = 0; i < code.length; i++)
{
switch(code.charAt(i))
{
case "'":
case '"':
case "\\":
code = code.substr(0, i) + "\\" + code.charAt(i) + code.substr(i+1);
i++;
break;
}
}
return code;
}
function htmlSpecialChars(str)
{
// TODO: Not implemented!!!
var pos = 0;
for (var i = 0; i < str.length; i++)
{
}
}
function replaceComAnd(str, replacer)
{
var oldPos = 0;
var pos = 0;
while ((pos = str.indexOf('&', pos)) != -1)
{
str = str.substring(oldPos, pos) + replacer + str.substring(pos+1);
}
return str;
}
function Timeout(control, code, maxCalls, actualCall, singleTimeout)
{
if (control())
{
if (typeof(code) == 'function')
{
code();
}
else
{
eval(code);
}
return true;
}
if (!actualCall)
{
actualCall = 1;
}
if (!maxCalls)
{
maxCalls = 100;
}
if (actualCall == maxCalls)
{
showMessage(Element('cc_msg_err_timeout').value);
return false;
}
if (!singleTimeout)
{
singleTimeout = 100;
}
setTimeout(function(){Timeout(control,code,maxCalls,actualCall+1,singleTimeout);}, singleTimeout);
}
function showMessage(msg, type)
{
// TODO: Replace alert with 'loading' style div with Ok button
switch(type)
{
case 'confirm':
return confirm(msg);
default:
alert(msg);
return;
}
}
// works only correctly in Mozilla/FF and Konqueror
function egw_openWindowCentered2(_url, _windowName, _width, _height, _status)
{
@ -529,12 +48,13 @@ function egw_openWindowCentered2(_url, _windowName, _width, _height, _status)
positionLeft = (windowWidth/2)-(_width/2)+egw_getWindowLeft();
positionTop = (windowHeight/2)-(_height/2)+egw_getWindowTop();
windowID = window.open(_url, _windowName, "width=" + _width + ",height=" + _height +
windowID = window.open(_url, _windowName, "width=" + _width + ",height=" + _height +
",screenX=" + positionLeft + ",left=" + positionLeft + ",screenY=" + positionTop + ",top=" + positionTop +
",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status="+_status);
return windowID;
}
function egw_openWindowCentered(_url, _windowName, _width, _height)
{
return egw_openWindowCentered2(_url, _windowName, _width, _height, 'no');
@ -624,388 +144,3 @@ function egw_getWindowOuterHeight()
return egw_getWindowInnerHeight();
}
}
/***********************************************\
* HTML ELEMENTS AUXILIAR FUNCTIONS *
\***********************************************/
//-------------------SELECT-------------------------
/* Copy the selected values from one select box to another */
function copyFromSelects(origSelectObj,destSelectObj)
{
var selectBox1 = origSelectObj;
var selectBox2 = destSelectObj;
var exists;
if (selectBox1 == null || selectBox2 == null)
{
return false;
}
var max1 = selectBox1.options.length;
var max2 = selectBox2.options.length;
for (var i=0 ; i < max1 ; i++)
{
if (selectBox1.options[i].selected)
{
exists = false;
for (var j=0 ; j < max2 ; j++)
{
if (selectBox1.options[i].value == selectBox2.options[j].value)
{
exists = true;
}
}
if (exists == false)
{
selectBox2.options[selectBox2.length] = new Option(selectBox1.options[i].text,selectBox1.options[i].value);
selectBox1.options[i].selected = false;
}
}
}
}
function removeSelectedOptions(selectId)
{
var selectBox1 = Element(selectId);
if (selectBox1 == null)
{
return false;
}
for (var i=0; i < selectBox1.options.length; )
{
if (selectBox1.options[i].selected)
{
selectBox1.removeChild(selectBox1.options[i]);
}
else
{
i++;
}
}
}
function clearSelectBox(obj, startIndex)
{
var nOptions = obj.options.length;
for (var i = nOptions - 1; i >= startIndex; i--)
{
obj.removeChild(obj.options[i]);
}
}
function fillSelectBox(obj,data)
{
if (typeof(data) != 'object')
{
return false;
}
var i;
//include new options
for (i in data)
{
if (typeof(data[i]) == 'function')
{
continue;
}
obj.options[obj.length] = new Option(data[i],i);
}
}
//use for select-multiple. The values of opts will be selected.
function selectOptions (obj,opts)
{
if (obj == false || obj.options == false)
{
throw('selectOptions: invalid object given as param');
return false;
}
if (opts == undefined || opts == null) //clean everything
{
var objtam = obj.options.length;
for (var i=0; i < objtam; i++)
{
obj.options[i].selected = false;
}
}
else
{
if (typeof(opts) != 'object')
{
//throw('selectOptions: opts must be an element of type Array or Object');
return false;
}
var objtam = obj.options.length;
var optstam = opts.length;
for (var i=0; i < objtam; i++)
{
obj.options[i].selected = false;
for (var j in opts)
{
if (obj.options[i].value == opts[j])
{
obj.options[i].selected = true;
}
}
}
}
}
//return selected options of a select in an array
function getSelectedOptions(obj)
{
if (obj == null)
{
throw('getSelectedOptions: invalid object');
return new Array();
}
var max = obj.options.length;
var response = new Array();
for (var i=0; i< max; i++)
{
if (obj.options[i].selected)
{
response.push(obj.options[i].value);
}
}
return response;
}
//return selected values of a select in an array
function getSelectedValues(obj)
{
if (obj == null || typeof(obj) != 'object')
{
return new Object();
}
var max = obj.options.length;
var response = new Object();
for (var i=0; i< max; i++)
{
if (obj.options[i].selected)
{
response[obj.options[i].value] = obj.options[i].text;
}
}
return response;
}
//return all options of a select in an array
function getAllOptions(id)
{
var obj = Element(id);
if (obj == null)
{
throw('getSelectedOptions: invalid object');
return new Array();
}
var max = obj.options.length;
var response = new Array();
for (var i=0; i< max; i++)
{
response.push(obj.options[i].value);
}
return response;
}
//-------------------RADIO-------------------------
function selectRadio (id, index)
{
var obj = Element(id);
var max = obj.options.length;
for (var i = 0; i < max; i++)
{
i == index ? obj.options[i].checked = true : obj.options[i].checked = false;
}
}
function getSelectedRadio(obj)
{
if (obj.type == 'radio')
{
if (obj.checked)
{
return obj.value;
}
}
else if (obj.length)
{
var max = obj.length;
for (var i = 0; i < max; i++)
{
if (obj[i].checked)
{
return obj[i].value;
}
}
}
return null;
}
/***********************************************\
* JSLIB OBJECT *
\***********************************************/
function cJsLib ()
{
this._functions = new Array();
this._arguments = new Array();
this._original_body_onload = null;
this.loaded = false;
}
//postpone function to be executed after body had loaded
cJsLib.prototype.postponeFunction = function(obj_function)
{
if (typeof(obj_function) != 'function')
{
throw ('JsLib.postponeFunction: parameter must be a function');
}
this._functions.push(obj_function);
// 'arguments' are all args passed to this function
var args = new Array();
for (var i = 1; i< arguments.length; i++)
{
args.push(arguments[i]);
}
if (args.length)
{
this._arguments.push(args);
}
this.init();
}
//exec postponed functions
cJsLib.prototype.execPostponed = function(e)
{
if (this._original_body_onload != null)
{
this._original_body_onload();
}
var code = '';
var _this = this;
for (var i in this._functions)
{
if (typeof(this._functions[i]) != 'function')
{
continue;
}
if (typeof(this._arguments[i]) == 'object')
{
code += 'this._functions['+i+'](';
for (var j in _this._arguments[i])
{
code += this._arguments[i][j]+',';
}
code = code.substr(code, code.length-1);
code += ');';
continue;
}
code += 'this._functions['+i+']();';
}
eval(code);
for (var i in this._functions)
{
if (typeof(this._arguments[i]) == 'object')
{
delete this._arguments[i];
this._arguments[i] = null;
}
delete this._functions[i];
this._functions[i] = null;
}
}
//put function on body onload
cJsLib.prototype.init = function()
{
/* if (this.initialized)
{
return;
}
*/
this.initialized = true;
var _this = this;
var init = function()
{
_this.execPostponed();
};
Timeout(function() { if (document.body) return true; else return false;}, init);
}
var JsLib = new cJsLib();
// Insert Debug Holder
function _createDebugDOM()
{
var dbg_holder = document.createElement('xmp');
dbg_holder.id = 'jsapiDebug';
dbg_holder.style.position = 'absolute';
dbg_holder.style.left = '1500px';
dbg_holder.style.top = '0px';
dbg_holder.style.fontFamily = 'monospace';
var func = function()
{
document.body.appendChild(dbg_holder);
}
JsLib.postponeFunction(func);
}
/***********************************************\
* CONSTANTS *
\***********************************************/
/***********************************************\
* GLOBALS VARIABLES *
\***********************************************/
/***********************************************\
* OTHER FUNCTIONS *
\***********************************************/
//JsLib.postponeFunction(function ()
//{
// dynapi.setPath(GLOBALS['serverRoot']+'/phpgwapi/js/dynapi');
//});

View File

@ -1,504 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,67 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | codecs</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.codecs" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
codecs</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module codecs</h1>
This module extends the String class with encoding and decoding functionalities.<br />
<br />
<div class="contentItem"><h2>public methods:<a class="bttop" href="#top"></a></h2><div>
<h3>listEncoders()</h3><div class="indent">
Returns an Array with all encoder names.<br />
</div>
<h3>listDecoders()</h3><div class="indent">
Returns an Arra with all decoder names.<br />
</div>
</div></div>
<div class="contentItem"><h2>globals:<a class="bttop" href="#top"></a></h2><div>
<h3>String::decode(codec)</h3><div class="indent">
Decodes an encoded string using the codec specified by the <code>codec</code>parameter .<br />
All parameters but the <code>codec</code> parameter are forwarded to the codec.<br />
</div>
<h3>String::encode(codec)</h3><div class="indent">
Encodes a string using the codec specified by the <code>codec</code> parameter.<br />
All Parameters but the <code>codec</code> parameter are forwarded to the codec.<br />
</div>
<h3>String::decode_base64()</h3><div class="indent">
Decodes a Base64 encoded string to a byte string.<br />
</div>
<h3>String::encode_base64()</h3><div class="indent">
Encodes a string using Base64.<br />
</div>
<h3>String::decode_uri()</h3><div class="indent">
Decodes a URI using decodeURI.<br />
</div>
<h3>String::encode_uri()</h3><div class="indent">
Encodes a URI using encodeURI.<br />
</div>
</div></div>
<div class="contentItem"><h2>codecs<a class="bttop" href="#top"></a></h2><div>
Currently there are only two codecs <b>base64</b> and <b>uri</b>.<br />
If you want to add your own codecs at runtime just extend the Stringl class by adding a
<code>String.prototype.encode_yourCodec</code> or
<code>String.prototype.decode_yourCodec</code> method.
</div></div>
</div>
</body>
</html>

View File

@ -1,72 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | crypto</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.crypto" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
crypto</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module crypto</h1>
This module adds cryptographic services to jsolait.
<br />
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>listEncrypters()</h3><div class="indent">
Returns an Array of all available encrypter names.<br />
</div>
<h3>listDecrypters()</h3><div class="indent">
Returns an Array of all available decrypter names.<br />
</div>
</div></div>
<div class="contentItem"><h2>globals:<a class="bttop" href="#top"></a></h2><div>
<h3>String::encrypt(crydec)</h3><div class="indent">
Encrypts a string using the encrypter specified by the <code>crydec</code>.<br />
All parameters but the <code>crypdec</code> parameter are forwardet to the encrypter.<br />
</div>
<h3>String::decrypt(crydec)</h3><div class="indent">
Decrypts a string using the decrypter specified by the <code>crydec</code>.<br />
All parameters but the <code>crypdec</code> parameter are forwardet to the decrypter.<br />
</div>
<h3>String::encrypt_xor(key)</h3><div class="indent">
Encrypts a string by XOR.<br />
The whole String will be XORed with the <code>key</code> parameter. <br />
If the key is shorter than the String then it will be multiplied to fit the length of the String.<br />
</div>
<h3>String::decrypt_xor</h3><div class="indent">
Decrypts a string using XOR.<br />
Since XORing is symetric it is the same as the encrypter.<br />
</div>
<h3>String::encrypt_rc4(key)</h3><div class="indent">
Encrypts a string using the ARC4 algorithm.<br />
The key is a String and can be of any length.
</div>
<h3>String::decrypt_rc4</h3><div class="indent">
Decrypts a string using the ARC4 algorithm.<br />
Since it is symetric it is the same as the encrypter.<br />
</div>
</div></div>
<div class="contentItem"><h2>encrypters/decrypters<a class="bttop" href="#top"></a></h2><div>
Currently there are only two encrypters/decrypters <b>xor</b> and <b>rc4</b>.<br />
If you want to add your own at runtime just extend the Stringl class by adding a
<code>String.prototype.encrypt_yourEncrypter</code> or
<code>String.prototype.decrypt_yourDecrypter</code> method.
</div></div>
</div>
</body>
</html>

View File

@ -1,88 +0,0 @@
.S0 {
color: #808080;
}
.S1 {
color: #007F00;
}
.S2 {
color: #007F00;
}
.S3 {
color: #3F70AA;
}
.S4 {
color: #007F7F;
}
.S5 {
font-weight: bold;
color: #00007F;
}
.S6 {
color: #7F007F;
}
.S10 {
font-weight: bold;
color: #000000;
}
.S15 {
color: #3F70AA;
}
.S18 {
color: #804020;
}
span {
font-family: Verdana;
font-size: 10pt;
}
S50 {
font-family: Times New Roman;
color: #000000;
font-size: 11pt;
}
.S51 {
color: #000080;
}
.S53 {
color: #008080;
}
.S56 {
color: #7F007F;
}
.S58 {
color: #800080;
}
.S510 {
font-family: Times New Roman;
color: #800080;
font-size: 11pt;
}
.S511 {
color: #000080;
}
.S521 {
color: #000080;
}
.S522 {
font-weight: bold;
color: #000080;
}
.S523 {
color: #006600;
}
.S524 {
color: #800000;
}
.code{
padding:0.5em;
border:solid;
border-width:1px;
margin-left:1em;
margin-top:2em;
margin-bottom:1em;
}
code{
font-size:115%;
}

View File

@ -1,293 +0,0 @@
html{
background-color:lightsteelblue;
font-size:14px;
font-family:Arial,sans-serif;
}
body{
padding:0em;
margin:0em;
height:100%;
}
div.navigationBar{
color:aliceblue;
z-index:98;
position:absolute;
position:fixed;
left:0em;
top:0em;
width:100%;
height:1.6em;
padding-left:0.5em;
padding-top:0.3em;
padding-bottom:0em;
background-color:slategray;
font-weight:bold;
border-bottom:1px solid black;
}
div.navigationBar a{
color:aliceblue;
text-decoration:none;
}
div.navigationBar a:link{
color:aliceblue;
text-decoration:none;
}
div.navigationBar a:visited{
color:aliceblue;
text-decoration:none;
}
div.navigationBar a:active{
color:white;
text-decoration:none;
}
div.navigationBar a:hover{
color:white;
text-decoration:underline;
}
/*-----------------------------------------------------------------------*/
div.menu{
color:aliceblue;
z-index:98;
position:absolute;
position:fixed;
margin-top:0.1em;
top:2em;
left:0em;
width:11em;
min-height:20em;
height:95%;
bottom:1em;
background-color:slategray;
font-weight:bold;
padding-left:1em;
padding-top:1em;
padding-right:1em;
padding-bottom:1em;
border-top:1px solid black;
border-right:1px solid black;
border-bottom:1px solid black;
}
div.menu ul{
padding-left:1em;
margin-left:0em;
}
div.menu ul li{
padding-bottom:0.5em;
}
div.menu a{
padding:0em;
color:aliceblue;
text-decoration:none;
font-size:13px;
}
div.menu a:link{
color:aliceblue;
text-decoration:none;
}
div.menu a:visited{
color:aliceblue;
text-decoration:none;
}
div.menu a:active{
color:white;
text-decoration:underline;
}
div.menu a:hover{
color:white;
text-decoration:underline;
}
div.menu div.copyright{
z-index:99;
border:none;
position:absolute;
bottom:2em;
width:19em;
height:2em;
left:0.5em;
margin-left:0em;
padding:0em;
font-size:10px;
font-weight:normal;
}
div.menu div.donate{
z-index:99;
border:none;
position:absolute;
bottom:5em;
width:3em;
height:3em;
margin-left:3.5em;
font-size:10px;
font-weight:normal;
}
a{
color:darkblue;
}
a:hover{
color:blue;
text-decoration:underline;
}
a:visited{
color:darkslategray;
text-decoration:underline;
}
/*-----------------------------------------------------------------*/
h1{
font-size:16px;
font-weight:bold;
font-family:sans-serif;
}
h2{
font-size:15px;
font-weight:bold;
font-family:sans-serif;
}
h3{
font-size:14px;
font-weight:bold;
font-family:sans-serif;
padding-bottom:0em;
margin-bottom:0.2em;
}
div.content{
z-index:0;
padding:0.5em;
position:absolute;
left:14em;
top:2.5em;
width:45em;
}
div.contentItem{
padding:0em;
margin-bottom:3em;
}
div.contentItem h2{
height:20px;
padding-left:0.5em;
margin-left:0;
margin-bottom:0.5em;
margin-top:1.5em;
left:0em;
top:0em;
width:43em;
color:aliceblue;
background-color:slategray;
}
div.contentItem div h2{
width:42em;
}
div.contentItem h2 a{
padding:0em;
margin-right:0;
margin-left:0;
color:aliceblue;
background-color:slategray;
}
div.contentItem h2 a:visited{
color:aliceblue;
background-color:slategray;
}
div.contentItem h2 a:active{
color:white;
background-color:slategray;
}
div.contentItem h2 a:hover{
color:white;
background-color:slategray;
}
div.contentItem h2 a:link{
color:aliceblue;
background-color:slategray;
}
div.contentItem a.bttop{
position:absolute;
left:43em;
color:aliceblue;
background-color:slategray;
}
div.contentItem a.bttop:link{
color:aliceblue;
text-decoration:none;
}
div.contentItem a.bttop:visited{
color:aliceblue;
text-decoration:none;
}
div.contentItem a.bttop:active{
color:white;
text-decoration:underline;
}
div.contentItem a.bttop:hover{
color:white;
text-decoration:underline;
}
div.contentItem div{
margin-left:1em;
margin-top:0;
}
button{
background-color:slategray;
border:1px;
border-style:solid;
border-color:black;
margin-right:1em;
}
div.indent{
margin-left:1em;
}
.code{
background-color:aliceblue;
}

View File

@ -1,93 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jsolait 1.0 documentation</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="JavaScript, OOP, object oriented programming, OOP in JavaScript, JS, OOP JS, tutorial, prototyping, inheritance, subclassing, data hiding" />
<link rel="stylesheet" type="text/css" href="./highlight.css" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar">documentation</div>
<div class="menu">
<ul>
<li>
<a href="./tutorial.xhtml">Tutorial</a>
</li>
</ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>JavaScript o Lait documentation</h1>
Version 1.0<br />
October 2004<br />
<br />
<div class="contentItem"><h2><a href="./tutorial.xhtml">Tutorial</a><a class="bttop" href="#top"></a></h2><div>
This is a good starting point if you have not worked with jsolait before.
</div></div>
<div class="contentItem"><h2>Modules<a class="bttop" href="#top"></a></h2><div>
<h3><a href="./jsolait.xhtml">jsolait</a></h3><div class="indent">
The main module containing the basic jsolait functionality.
</div>
<br />
<h3><a href="./codecs.xhtml">codecs</a></h3><div class="indent">
Provides String encoding and decoding functionalities.
</div>
<h3><a href="./crypto.xhtml">crypto</a></h3><div class="indent">
Provides cryptographic services.
</div>
<h3><a href="./jsonrpc.xhtml">jsonrpc</a></h3><div class="indent">
An implementation of the <a href="http://json-rpc.org" target="_blank">JSON-RPC</a> protocoll.
</div>
<h3><a href="./lang.xhtml">lang</a></h3><div class="indent">
Provides language services. E.g. a JavaScript tokenizer.
</div>
<h3><a href="./stringformat.xhtml">stringformat</a></h3><div class="indent">
This module is automatically loaded with the main module. It provides some powerful string formatting.
</div>
<h3><a href="./urllib.xhtml">urllib</a></h3><div class="indent">
Provides methods to make HTTP requests.
</div>
<h3><a href="./xml.xhtml">xml</a></h3><div class="indent">
Provides XML services.
</div>
<h3><a href="./xmlrpc.xhtml">xmlrpc</a></h3><div class="indent">
An implementation of the <a href="http://xml-rpc.com" target="_blank">XML-RPC</a> protocoll.
</div>
</div></div>
<div class="contentItem"><h2>Usage/Installation<a class="bttop" href="#top"></a></h2><div>
JavaScript o lait was designed to be used in web pages(HTML/SVG) but is not limited to it.
The simplest way to use it is to copy the jsolait folder to your project directory and include the main file into the web page by reference.<br />
In HTML use the script element:<br />
<span class="S51">&lt;script</span><span class="S58"> </span><span class="S53">type</span><span class="S58">=</span><span class="S56">"text/javascript"</span><span class="S58"> </span><span class="S53">src</span><span class="S58">=</span><span class="S56">"./jsolait/init.js"</span><span class="S51">&gt;&lt;/script&gt;</span><br />
In SVG it is similar:<br />
<span class="S51">&lt;script</span><span class="S58"> </span><span class="S53">type</span><span class="S58">=</span><span class="S56">"text/ecmascript"</span><span class="S58"> </span><span class="S53">xlink:href</span><span class="S58">=</span><span class="S56">"./jsolait/init.js"</span><span class="S511">/&gt;</span><br />
<br />
You can also use jsolait with WScript by running the init.js script and pass the script to be executed as a command line argument:<br />
<code>cscript.exe /nologo "c:\path_to_jsolait_folder\init.js" "file://path_to_script\your_script.js"</code><br />
<br />
See <a href="./jsolait.xhtml">jsolait</a> module documentation for customization and requirements.
</div></div>
</div>
</body>
</html>

View File

@ -1,139 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | jsolait</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.lang" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
jsolait</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module jsolait</h1>
This is the main module.<br />
It is used by all jsolait modules and provides the basic functionality.<br />
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>baseURL</h3><div class="indent">
The base URL to use when dynamically loading user modules.
</div>
<h3>libURL</h3><div class="indent">
The url of the jsolait installation, used for dynamically loading jsolait modules.
</div>
<br />
<h3>ModuleImportFailed()</h3><div class="indent">
Exception thrown when a module could not be imported.
</div>
<h3></h3><div class="indent">
</div>
<br />
<h3>importModule(moduleName)</h3><div class="indent">
Imports a module given its name(e.g. "someModule.someSubModule").<br />
For dynamic loading of modules:<br />
A module's file location is determined by treating each module name as a directory.<br />
Only the last one is assumed to point to a file.<br />
If the module's URL is not known to jsolait then it will be searched for in jsolait.baseURL which is "." by default.<br />
</div>
<h3>reportException(e)</h3><div class="indent">
Displays an Exception <code>e</code> and it's trace.<br />
This is better than <code>alert(e)</code>.
</div>
</div></div>
<div class="contentItem"><h2>globals:<a class="bttop" href="#top"></a></h2><div>
<h3>jsolait</h3><div class="indent">
The jsolait module.
</div>
<h3>Class(className, superClass, classScope)</h3><div class="indent">
A method for creating Classes.<br />
The <code>className</code> parameter is not needed if the Class is going to be a public member of a module.<br />
The <code>superClass</code> parameter must be specified if the new class is to be a subclass of the class specified by <code>superClass</code>.
The <code>classScope</code> is a <code>ClassScope</code> function and defines the scope of the class.<br />
<br />
Each class created by this method has the following properies and methods:<br />
<ul>
<li><b>className</b> The name of the class.</li>
<li><b>superClass</b> The super class of the class</li>
</ul>
<br />
</div>
<h3>Module(name, version, moduleScope)</h3><div class="indent">
A method for creating modules.<br />
The <code>name</code> parameter defines the name of the module.<br />
The <code>version</code> parameter contains the version of the module.<br />
The <code>moduleScope</code> is a <code>ModuleScope</code> function and defines the scope of the module.<br />
<br />
Modules created with this function have the following properties:<br />
<ul>
<li><b>name</b> The name of the module.</li>
<li><b>version</b> The module's version.</li>
<li><b>Exception</b> The base class for all exception classes in the module.</li>
</ul>
</div>
<br />
<h3>importModule(moduleName)</h3><div class="indent">
The globalized jsolait.importModule method.
</div>
<h3>reportException(e)</h3><div class="indent">
The globalized jsolait.reportException method.
</div>
</div></div>
<div class="contentItem"><h2>interfaces:<a class="bttop" href="#top"></a></h2><div>
<h3>ClassScope(publ, supr)</h3><div class="indent">
The ClassScope is a function which is called by the Class method when a new class is constructed.<br />
The <code>publ</code> parameter contains the new class' prototype object.<br />
All objects added to this object become public members of the new class.<br />
The <code>supr</code> parameter contains a wrapper function for easyly calling the super class' methods<br />
Everything declared with var inside the scope becomes "private" to the scope, i.e. is only visible within the scope.<br />
</div>
<h3>ModuleScope(mod)</h3><div class="indent">
The ModuleScope is a function which is called by the Module function when a new module is created.<br />
All objects added to the <code>mod</code> parameter will become public members of the module.<br />
It will already contain the modules porperties like name, version and the Exception class.<br />
</div>
</div></div>
<div class="contentItem"><h2>requirements:<a class="bttop" href="#top"></a></h2><div>
For dynamic loading of modules a synchronous HTTP connection must be available. Mozilla and IE both have it.
</div></div>
</div>
</body>
</html>

View File

@ -1,58 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | jsonrpc</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.jsonrpc" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
jsonrpc</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module jsonrpc</h1>
This module implements the <a href="http://json-rpc.org" target="_blank">JSON-RPC</a> protocoll.<br />
It supports both JSON-RPC over HTTP and JSON-RPC over TCP sockets(if sockets are available).<br />
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>ServiceProxy(url, methodNames, localService)</h3><div class="indent">
A class which creates proxy objects for remote JSON-RPC services.<br />
<ul>
<li><b>ServiceProxy::url</b> The URL of the remote services.</li>
<li><b>ServiceProxy::methodNames</b> An Array containing the methodNames of the remote service.</li>
<li><b>ServiceProxy::localService</b> An Object providing methods to the remote service.</li>
</ul>
</div>
</div></div>
<div class="contentItem"><h2>dependencies:<a class="bttop" href="#top"></a></h2><div>
<h3><a href="./lang.xhtml">lang</a></h3><div class="indent">
The <code>lang</code> module is required for JSON object serialization and deserialization.
</div>
<h3><a href="./urllib.xhtml">urllib</a></h3><div class="indent">
The <code>urllib</code> module is only required when using JSON-RPC over HTTP.
</div>
<h3>Sockets</h3><div class="indent">
You will need SVG1.2 sockets for JSON-RPC over TCP sockets to work.
This dependency will change once the <code>net</code> module is written.
It will provide networking services to jsolait.
</div>
</div></div>
</div>
</body>
</html>

View File

@ -1,98 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | lang</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.lang" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
lang</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module lang</h1>
This module provides language services like tokenizing JavaScript code
or converting JavaScript objects to and from <a href="http://json.org" target="_blank">JSON</a>.<br />
To customize JSON serialization of Objects just overwrite the toJSON method in your class.
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>JSONParser()</h3><div class="indent">
A class for parsing JSON.<br />
<ul>
<li><b>JSONParser::addLib(obj,name,exports)</b><br />
Adds a lib object for converting application specific JSON-Objects.<br />
This is an extension to the default JSON behavior to allow class hinitng.
</li>
<li><b>JSONParser::jsonToObj(data)</b><br />
Turns JSON code into JavaScript objects.<br />
<code>data</code> is a String containing the JSON code.
</li>
<li><b>JSONParser::objToJson(obj)</b><br />
Turns an object into JSON.<br />
This is the same as calling obj.toJSON();<br />
</li>
</ul>
</div>
<h3>parser</h3><div class="indent">
A JSONParser object used for jsonToObj and objToJson.
</div>
<h3>jsonToObj(src)</h3><div class="indent">
Turns JSON code into JavaScript objects.<br />
<code>src</code> is a String containing the JSON code.
</div>
<h3>objToJson(obj)</h3><div class="indent">
Turns an object into JSON.<br />
This is the same as calling obj.toJSON();<br />
</div>
<h3>tokens</h3><div class="indent">
Token type constants for the tokenizer.<br />
<ul>
<li><b>tokens.WSP</b> WhiteSpace </li>
<li><b>tokens.OP</b> Operator </li>
<li><b>tokens.STR</b> String</li>
<li><b>tokens.NAME</b> Name</li>
<li><b>tokens.NUM</b> Number</li>
<li><b>tokens.ERR</b> Error</li>
<li><b>tokens.NL</b> NewLine </li>
<li><b>tokens.COMMENT</b> Comment </li>
<li><b>tokens.DOCCOMMENT</b> Documentation comment </li>
<li><b>tokens.REGEXP</b> Regular Expression</li>
</ul>
</div>
<h3>Tokenizer(source)</h3><div class="indent">
Tokenizer Class which incrementally parses JavaScript code(<code>source</code>) and returns the language tokens.<br />
<ul>
<li><b>Tokenizer::next()</b><br />
Returns the next Token object.
</li>
<li><b>Tokenizer::nextNonWS(nlIsWS)</b><br />
Returns the next non whitespace token.<br />
If <code>nlIsWS</code> is <code>true</code> then a NewLine token is interpreted as whitespace.
</li>
<li><b>Tokenizer::finished()</b><br />
Returns <code>true</code> if the Tokenizer has finished the parsing.
</li>
</ul>
</div>
<h3>Token(type, value, pos, err)</h3><div class="indent">
Token class for token objects returned by the Tokenizer.<br />
<ul>
<li><b>Token::type</b>The type of the token(see the tokens constants).</li>
<li><b>Token::value</b>A String containing the token value.</li>
<li><b>Token::pos</b>The starting position of the token in the source .</li>
<li><b>Token::err</b>The error object for Error tokens.</li>
</ul>
</div>
</div></div>
</div>
</body>
</html>

View File

@ -1,95 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | stringformat</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.stringformat" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
stringformat</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module stringformat</h1>
This module is automatically loaded with the main module.<br />
It allows python like string formatting ("some text %s" % "something").
Also similar to sprintf from C.
<div class="contentItem"><h2>globals:<a class="bttop" href="#top"></a></h2><div>
<h3>String::format()</h3><div class="indent">
Formats a string replacing formatting specifiers with values provided as arguments<br />
which are formatted according to the specifier.<br />
This is an implementation of python's % operator for strings and is similar to sprintf from C.<br />
Usage:<br />
<code>resultString = formatString.format(value1, v2, ...);</code><br />
<br />
Each formatString can contain any number of formatting specifiers which are<br />
replaced with the formated values.<br />
<br />
The following describes a format-specifier ([...] are optional): <br />
<code>%[(key)][flag][sign][min][percision]typeOfValue</code>
<ul>
<li><b>(key)</b><br />
If specified the 1st argument is treated as an object/associative array and the formating values <br />
are retrieved from that object using the key.<br />
</li>
<li><b>flag:</b><br />
0 Use 0s for padding.<br />
- Left justify result, padding it with spaces.<br />
Use spaces for padding.<br />
</li>
<li><b>sign:</b><br />
+ Numeric values will contain a +|- infront of the number.<br />
</li>
<li><b>min:</b><br />
l The string will be padded with the padding character until it has a minimum length of l. <br />
</li>
<li><b>percision:</b><br />
.x Where x is the percision for floating point numbers and the lenght for 0 padding for integers.<br />
</li>
<li><b>typeOfValue:</b><br />
d Signed integer decimal. <br />
i Signed integer decimal. <br />
b Unsigned binary. <br />
o Unsigned octal. <br />
u Unsigned decimal. <br />
x Unsigned hexidecimal (lowercase). <br />
X Unsigned hexidecimal (uppercase). <br />
e Floating point exponential format (lowercase). <br />
E Floating point exponential format (uppercase). <br />
f Floating point decimal format. <br />
F Floating point decimal format. <br />
c Single character (accepts byte or single character string). <br />
s String (converts any object using object.toString()). <br />
</li>
</ul>
Examples:<br />
"%02d".format(8) == "08"<br />
"%05.2f".format(1.234) == "01.23"<br />
"123 in binary is: %08b".format(123) == "123 in binary is: 01111011"<br />
<br />
<b></b> * Each parameter is treated as a formating value. <br />
<br />
</div>
<h3>String::pad(flag,len)</h3><div class="indent">
Padds a String with a character to have a minimum length.<br />
<br />
<b>flag</b> "-": to padd with " " and left justify the string.<br />
Other: the character to use for padding. <br />
<b>len</b> The minimum length of the resulting string.<br />
</div>
<h3>String.prototype.mul(c)</h3><div class="indent">
Repeats a string.<br />
<b>c</b> The count how often the string should be repeated.<br />
</div>
</div></div>
</div>
</body>
</html>

View File

@ -1,295 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | tutorial</title>
<link rel="stylesheet" type="text/css" href="/html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="JavaScript, OOP, object oriented programming, OOP in JavaScript, JS, OOP JS, tutorial, prototyping, inheritance, subclassing, data hiding" />
<link rel="stylesheet" type="text/css" href="./highlight.css" />
<style type="text/css">
.S0 {
font-family: 'Times New Roman';
color: #000000;
font-size: 11pt;
}
.S1 {
color: #000080;
}
.S3 {
color: #008080;
}
.S6 {
color: #7F007F;
}
.S8 {
color: #800080;
}
span {
font-family: 'Verdana';
color: #000000;
font-size: 10pt;
}
</style>
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
tutorial</div>
<div class="menu">
<ul></ul>
<div class="donate">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="donate@kollhof.net" />
<input type="hidden" name="item_name" value="project development" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="http://jan.kollhof.net/projects/donation/success" />
<input type="hidden" name="cancel_return" value="http://jan.kollhof.net/projects/donation/cancel" />
<input type="hidden" name="cn" value="your comments" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="tax" value="0" />
<input type="image" src="/ppbtn.gif" border="0" name="submit" alt="support development" />
</form>
</div>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
Please note, this is only a current draft of the online jsolait tutorial and is not complete.<br />
<br />
<h1>Object Oriented Programming using JavaScript o Lait</h1>
It is very simple to use jsolait for object oriented programming.<br />
In this tutorial we will look at how we can integrate jsolait functionality in our projects.<br />
Then we will create our first jsolait module. As we go on we will add classes and methods and will explore the
OOP feautures of jsolai.<br />
All example code can be tried using your own webpage or <a href="../jsolaitonline.xhtml">jsolait online</a>.<br />
<div class="contentItem"><h2>integrating jsolait<a class="bttop" href="#top"></a></h2><div>
To use jsolait you will need to copy the library files to the location of your website.
Add a refference to jsolait's initialization script( ./jsolait/init.js) in your page.<br />
In HTML it will look like this:<br />
<br /><div class="code">
<span style="margin-left:0.5em"></span><span class="S0">...</span><br />
<span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span class="S1">&lt;script</span><span class="S8"> </span><span class="S3">type</span><span class="S8">=</span><span class="S6">"text/javascript"</span><span class="S8"> </span><span class="S3">src</span><span class="S8">=</span><span class="S6">"./jsolait/init.js"</span><span class="S1">&gt;&lt;/script&gt;</span><br />
<span style="margin-left:0.5em"></span><span class="S0">...</span><br />
</div>
<br />
After that you are ready to begin working with jsolait<br />
An easy way to do so is to create a JavaScript file and refference it in the page after the init script.<br />
The script can now use any jsolait functionality in addition to what is available in JavaScript alone.<br />
Your HTML file should now contain somethign similar to the following:<br />
<br /><div class="code">
<span style="margin-left:0.5em"></span><span class="S0">...</span><br />
<span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span class="S1">&lt;script</span><span class="S8"> </span><span class="S3">type</span><span class="S8">=</span><span class="S6">"text/javascript"</span><span class="S8"> </span><span class="S3">src</span><span class="S8">=</span><span class="S6">"./jsolait/init.js"</span><span class="S1">&gt;&lt;/script&gt;</span><br />
<span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span class="S1">&lt;script</span><span class="S8"> </span><span class="S3">type</span><span class="S8">=</span><span class="S6">"text/javascript"</span><span class="S8"> </span><span class="S3">src</span><span class="S8">=</span><span class="S6">"./tutorial.js"</span><span class="S1">&gt;&lt;/script&gt;</span><br />
<span style="margin-left:0.5em"></span><span class="S0">...</span><br />
</div>
</div></div>
<div class="contentItem"><h2>first script using jsolait<a class="bttop" href="#top"></a></h2><div>
As an example we will now use jsolait's powerful string-formating methods.<br />
<br /><div class="code">
<span>
<span class="S5">var</span><span class="S0"> </span>s1<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">"Hello %s!"</span><span class="S10">.</span>format<span class="S10">(</span><span class="S5">jsolait</span><span class="S10">.</span>name<span class="S10">);</span><br />
alert<span class="S10">(</span>s1<span class="S10">);</span><br />
<span class="S5">var</span><span class="S0"> </span>s2<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">"The number %d as a hexadecimal is %X."</span><span class="S10">.</span>format<span class="S10">(</span><span class="S4">123456789</span><span class="S10">,</span><span class="S4">123456789</span><span class="S10">);</span><br />
alert<span class="S10">(</span>s2<span class="S10">);</span>
</span>
</div>
<br />
In the example all <code>%s, %f, %X</code> are replaced by converting the values passed into the <code>format</code> method to a desired format.<br />
There are more formating specifiers than <code>%s, %f, %X</code>. Please see the documentation for the <a href="./stringformat.xhtml"><code>stringformat</code></a> module.
</div></div>
<div class="contentItem"><h2>using modules<a class="bttop" href="#top"></a></h2><div>
To use modules in your script jsolait provides a special method called <code>importModule</code>.
Let us see how this works. For an example we will import the <code>codecs</code> module which provides e.g. base64 encoding of strings.<br />
<br /><div class="code">
<span class="S5">var</span> <span>codecs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">importModule</span><span class="S10">(</span><span class="S6">"codecs"</span><span class="S10">);</span><br />
<br />
alert<span class="S10">(</span>codecs<span class="S10">.</span>listEncoders<span class="S10">());</span><br />
<br />
<span class="S5">var</span><span class="S0"> </span>s1<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">"Hello jsolait"</span><span class="S10">;</span><br />
<span class="S5">var</span><span class="S0"> </span>s2<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s1<span class="S10">.</span>encode<span class="S10">(</span><span class="S6">"base64"</span><span class="S10">);</span><br />
<br />
alert<span class="S10">(</span><span class="S6">"'%s' encoded using base64 is '%s'"</span><span class="S10">.</span>format<span class="S10">(</span>s1<span class="S10">,</span>s2<span class="S10">));</span><br />
</span>
</div>
<br />
The <code>codecs</code> module is loaded by jsolait and provided to the script calling the <code>importModule</code> function.<br />
Depending on your browser jsolait loads the module source files on demand, i.e. the file is retrieved during the first call to <code>importModule</code>.
A second call to <code>importModule</code> will only return the module object which has been loaded already by the first call, jsolait will not retrieve the file again.
In some browsers the feauture of loading moudule files on demand is not available.<br />
This does not mean you cannot uses jsolait. What you need to do is refference all module scripts in your web page.<br />
For oure example our web page would contain something like:<br />
<br /><div class="code">
<span style="margin-left:0.5em"></span><span class="S0">...</span><br />
<span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span class="S1">&lt;script</span><span class="S8"> </span><span class="S3">type</span><span class="S8">=</span><span class="S6">"text/javascript"</span><span class="S8"> </span><span class="S3">href</span><span class="S8">=</span><span class="S6">"./jsolait/init.js"</span><span class="S1">&gt;&lt;/script&gt;</span><br />
<span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span class="S1">&lt;script</span><span class="S8"> </span><span class="S3">type</span><span class="S8">=</span><span class="S6">"text/javascript"</span><span class="S8"> </span><span class="S3">href</span><span class="S8">=</span><span class="S6">"./jsolait/lib/codecs.js"</span><span class="S1">&gt;&lt;/script&gt;</span><br />
<span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span class="S1">&lt;script</span><span class="S8"> </span><span class="S3">type</span><span class="S8">=</span><span class="S6">"text/javascript"</span><span class="S8"> </span><span class="S3">href</span><span class="S8">=</span><span class="S6">"./tutorial.js"</span><span class="S1">&gt;&lt;/script&gt;</span><br />
<span style="margin-left:0.5em"></span><span class="S0">...</span><br />
</div>
All module scripts depend on the initialization script <code>init.js</code> to be loaded first.<br />
Depending on the module dependencies you must make sure the scripts are refferenced in the right order.<br />
But more on that later.<br />
</div></div>
<div class="contentItem"><h2>creating a jsolait module<a class="bttop" href="#top"></a></h2><div>
You can easily create your own modules by using the <code>Module</code> constructor.<br />
See the following code:<br />
<br /><div class="code">
<span><span class="S5">Module</span><span class="S10">(</span><span class="S6">"tutorial"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"0.0.1"</span><span class="S10">,</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span><span class="S5">mod</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">var</span><span class="S0"> </span>codecs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">importModule</span><span class="S10">(</span><span class="S6">"codecs"</span><span class="S10">);</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">mod</span><span class="S10">.</span>testCodecs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span>data<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span>alert<span class="S10">(</span>codecs<span class="S10">.</span>listEncoders<span class="S10">());</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">var</span><span class="S0"> </span>s1<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">"Hello jsolait"</span><span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">var</span><span class="S0"> </span>s2<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s1<span class="S10">.</span>encode<span class="S10">(</span><span class="S6">"base64"</span><span class="S10">);</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span>alert<span class="S10">(</span><span class="S6">"'%s' encoded using base64 is '%s'"</span><span class="S10">.</span>format<span class="S10">(</span>s1<span class="S10">,</span>s2<span class="S10">));</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S10">})</span><br />
<span class="S0"></span></span>
</div>
The module constructor is a function with 3 parameters. The first one is the module's name. This name is used when importing modules.<br />
The second one is the modules version. It is good practice to give a module a version string.<br />
The third parameter is a function object. <br />
This function is called to construct the module. Once constructed the module is registered with jsolait and can be imported.<br />
A special parameter <code>mod</code> is passed to that function wich represents the modul. It is very similar to the <code>this</code> object in JavaScript.
All properties set on the <code>mod</code> object will become public properties of the module. In our example this would be the <code>testCodecs</code> method.<br />
Variables declared with <code>var</code> are only visible inside the module constructor. One could say they are the private objects of the module.
In our example this would be the <code>codecs</code> object.<br />
If you declare a variable without the <code>var</code> keyword then this object will become global.<br />
Only declare global objects if you realy intend to create global objects. In most cases you should never need them.
The jsolait module for example defines two global objects: <code>importModule and reportException</code>.<br />
At first, using a function object might seem a little awkward, but it allowes us to practice good data hiding.<br />
</div></div>
<div class="contentItem"><h2>creating classes<a class="bttop" href="#top"></a></h2><div>
Creating classes in jsolait is as simple as creating modules. Especially when it comes to inheritance jsolait will take
care of all the work involved for creating subclasses in JavaScript.<br />
Have a look at the following code:<br />
<br /><div class="code">
<span><span class="S5">Module</span><span class="S10">(</span><span class="S6">"tutorial"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"0.0.1"</span><span class="S10">,</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span><span class="S5">mod</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">mod</span><span class="S10">.</span>SomeClass<span class="S10">=</span><span class="S5">Class</span><span class="S10">(</span><span class="S5">function</span><span class="S10">(</span><span class="S5">publ</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>foo<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span>p1<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">return</span><span class="S0"> </span><span class="S5">this</span><span class="S10">.</span>bar<span class="S0"> </span><span class="S10">*</span><span class="S0"> </span>p1<span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>bar<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">3</span><span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">})</span><br />
<span class="S10">})</span><br />
<span class="S0"></span></span>
</div>
You can see we declared a public object in our module. This object is a class object created with the <code>Class</code> function.<br />
The <code>Class</code> function accepts up to three parameters. For now we only need one, a function object.
Similar to the function object passed to the module constructor it is used for data hiding.<br />
The parameter passed to the function object is the <code>publ</code> object.
All properties added to this object will become the public members of the class.<br />
In our example we have two public members of the class: the method <code>foo</code> and the property <code>bar</code>.<br />
To create objects of the class we use the JavaScript <code>new</code> keyword.<br />
<br /><div class="code">
<span><span class="S5">var</span><span class="S0"> </span>tutorial<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">importModule</span><span class="S10">(</span><span class="S6">"tutorial"</span><span class="S10">);</span><br />
<br />
<span class="S5">var</span><span class="S0"> </span>obj<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>tutorial<span class="S10">.</span>SomeClass<span class="S10">();</span><br />
<br />
alert<span class="S10">(</span>obj<span class="S10">.</span>foo<span class="S10">(</span><span class="S4">3</span><span class="S10">));</span></span>
</div>
Becase our class <code>SomeClass</code> is part of the module <code>tutorial</code> we need to import that module before we use it.
Then we can create an object of our class and call methods of that objects.
</div></div>
<div class="contentItem"><h2>inheritence<a class="bttop" href="#top"></a></h2><div>
Let us create another class and have it be a subclass of <code>SomeClass</code>.<br />
<br /><div class="code">
<span><span class="S5">Module</span><span class="S10">(</span><span class="S6">"tutorial"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"0.0.1"</span><span class="S10">,</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span><span class="S5">mod</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">mod</span><span class="S10">.</span>SomeClass<span class="S10">=</span><span class="S5">Class</span><span class="S10">(</span><span class="S5">function</span><span class="S10">(</span><span class="S5">publ</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>foo<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span>p1<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">return</span><span class="S0"> </span><span class="S5">this</span><span class="S10">.</span>bar<span class="S0"> </span><span class="S10">*</span><span class="S0"> </span>p1<span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>bar<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">3</span><span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">})</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">mod</span><span class="S10">.</span>SubClass<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">Class</span><span class="S10">(</span><span class="S5">mod</span><span class="S10">.</span>SomeClass<span class="S10">,</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span><span class="S5">publ</span><span class="S10">,</span><span class="S0"> </span><span class="S5">supr</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>foo<span class="S10">=</span><span class="S5">function</span><span class="S10">(</span>p1<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">var</span><span class="S0"> </span>v1<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">supr</span><span class="S10">(</span><span class="S5">this</span><span class="S10">).</span>foo<span class="S10">(</span>p1<span class="S10">);</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">return</span><span class="S0"> </span>v1<span class="S0"> </span><span class="S10">*</span><span class="S0"> </span><span class="S4">3</span><span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">})</span><span class="S0"> <span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S10">})</span><br /></span>
</div>
In the above excample one can see that we added another class to our module. The difference to the first class is that we pass in another parameter to the <code>Class</code> method before the
last parameter, the function object.
This first parameter is the base class of our new class, i.e. our new class will inherit form that class.<br />
You can also notice that we have another parameter <code>supr</code> in our function object.
This parameter is a spechial function for calling overwritten methods of the base class. You can see how a base class method is invoked in the line <code>var v1 = supr(this).foo(p1)</code>.<br />
<code>SubClass</code> overwrites the <code>foo</code> method of <code>SomeClass</code>. When the <code>foo</code> method is called then it calls it's base class's <code>foo</code>
method first, then multiplying the return value by 3 and then returns the result.<br />
</div></div>
<div class="contentItem"><h2>object initialization<a class="bttop" href="#top"></a></h2><div>
Whenever an object is created form a class an initialization method is called with the parameters passed to the constructor. This method is named <code>init</code> and you may
consider it to be the constructor of the class, though technically speaking it is not.
You can overwrite the <code>init</code> method in your class. If you do so make sure you call the base class's <code>init</code> method.
For example:<br />
<br /><div class="code">
<span><span class="S5">Module</span><span class="S10">(</span><span class="S6">"tutorial"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"0.0.1"</span><span class="S10">,</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span><span class="S5">mod</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">mod</span><span class="S10">.</span>SomeClass<span class="S10">=</span><span class="S5">Class</span><span class="S10">(</span><span class="S5">function</span><span class="S10">(</span><span class="S5">publ</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>init<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span>barVal<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">this</span><span class="S10">.</span>bar<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>barVal<span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>foo<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span>p1<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">return</span><span class="S0"> </span><span class="S5">this</span><span class="S10">.</span>bar<span class="S0"> </span><span class="S10">*</span><span class="S0"> </span>p1<span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>bar<span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">})</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">mod</span><span class="S10">.</span>SubClass<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">Class</span><span class="S10">(</span><span class="S5">mod</span><span class="S10">.</span>SomeClass<span class="S10">,</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span><span class="S5">publ</span><span class="S10">,</span><span class="S0"> </span><span class="S5">supr</span><span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>init<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">function</span><span class="S10">(</span>a<span class="S10">,</span><span class="S0"> </span>b<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">supr</span><span class="S10">(</span><span class="S5">this</span><span class="S10">).</span>init<span class="S10">(</span>a<span class="S0"> </span><span class="S10">*</span><span class="S0"> </span>b<span class="S10">);</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">publ</span><span class="S10">.</span>foo<span class="S10">=</span><span class="S5">function</span><span class="S10">(</span>p1<span class="S10">){</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">var</span><span class="S0"> </span>v1<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">supr</span><span class="S10">(</span><span class="S5">this</span><span class="S10">).</span>foo<span class="S10">(</span>p1<span class="S10">);</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S5">return</span><span class="S0"> </span>v1<span class="S0"> </span><span class="S10">*</span><span class="S0"> </span><span class="S4">3</span><span class="S10">;</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">}</span><br />
<span class="S0"><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><span class="S10">})</span><span class="S0"> <span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span><span style="margin-left:0.5em"></span></span><br />
<span class="S10">})</span></span>
</div>
You can see that both of our classes have different initialization parameters and that <code>SubClass</code> calls the <code>SomeClass</code>'s initialization method.<br />
The code for the object creation would look like this:<br />
<br /><div class="code">
<span><span class="S5">var</span><span class="S0"> </span>tutorial<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">importModule</span><span class="S10">(</span><span class="S6">"tutorial"</span><span class="S10">);</span><br />
<br />
<span class="S5">var</span><span class="S0"> </span>obj<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>tutorial<span class="S10">.</span>SubClass<span class="S10">(</span><span class="S4">3</span><span class="S10">,</span><span class="S4">4</span><span class="S10">);</span><br />
<br />
alert<span class="S10">(</span>obj<span class="S10">.</span>foo<span class="S10">(</span><span class="S4">3</span><span class="S10">));</span></span>
</div>
</div></div>
<div class="contentItem"><h2>exception handling<a class="bttop" href="#top"></a></h2><div>
coming soon
</div></div>
<div class="contentItem"><h2>module dependencies<a class="bttop" href="#top"></a></h2><div>
coming soon
</div></div>
</div>
</body>
</html>

View File

@ -1,101 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | urllib</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.urllib" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
urllib</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module urllib</h1>
Provides methods for making HTTP requests.
<br />
The module is to be replaced by a richer <code>net</code> module, also containing sockets.<br />
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>NoHTTPRequestObject()</h3><div class="indent">
Exception thrown if no request object could be instanciated.<br />
</div>
<h3>RequestOpenFailed()</h3><div class="indent">
Exception thrown if an HTTP request could not be opened.<br />
</div>
<h3>SendFailed()</h3><div class="indent">
Exception thrown if a request could not be sent to the server.<br />
</div>
<br />
<h3>sendRequest(type,url,user,pass,data,headers,callback)</h3><div class="indent">
Sends a request to a server.<br />
To explain the way the optional arguments work I will give examples:<br />
simple:<br />
sendRequest("get", "url")<br />
sendRequest("post", "url", "data")<br />
<br />
with headers:<br />
sendRequest("get", "url", [["headername","value"]])<br />
sendRequest("post", "url", "data", [["headername","value"]])<br />
<br />
with user information:<br />
sendRequest("get", "url", "user", "pass")<br />
sendRequest("post", "url", "user", "pass", "data")<br />
<br />
with headers and user information:<br />
sendRequest("get", "url", "user", "pass", [["headername","value"]])<br />
sendRequest("post", "url", "user", "pass", "data", [["headername","value"]])<br />
<br />
To make the request asynchronous just add a callback function as the last argument to the calls above.<br />
<br />
<b>type</b> Type of connection (GET, POST, ...).<br />
<b>url</b> The URL to retrieve.<br />
<b>user</b> =null The username for auth.<br />
<b>pass</b> =null The password. (must be set if user is set!)<br />
<b>data</b> ="" The data to send with the request.<br />
<b>headers</b> =[] Array of headers. Each element in the array should be another array containing [headername,value].<br />
<b>callback</b> =null Callback for asynchronous connections. The callback is called after completion and is passed the request object as 1st Parameter.<br />
<b>returns</b> HTTP request object.<br />
</div>
<h3>getURL(url,user,pass,headers,callback)</h3><div class="indent">
Shorthand for a GET request.<br />
It calls sendRequest with "GET" as first argument.<br />
See the sendRequest method for more information.<br />
<br />
<b>url</b> The URL to retrieve.<br />
<b>user</b> =null The username for auth.<br />
<b>pass</b> =null The password. (must be set if user is set!)<br />
<b>headers</b> =[] Array of headers. Each element in the array should be another array containing [headername,value].<br />
<b>callback</b> =null Callback for asynchronous connections. The callback is called after completion and is passed the request object as 1st Parameter.<br />
<b>returns</b> HTTP request object.<br />
<br />
</div>
<h3>postURL(url,user,pass,data,headers, callback)</h3><div class="indent">
Shorthand for a POST request.<br />
It calls sendRequest with "POST" as first argument.<br />
See the sendRequest method for more information.<br />
<br />
<b>url</b> The URL to retrieve.<br />
<b>user</b> =null The username for auth.<br />
<b>pass</b> =null The password. (must be set if user is set!)<br />
<b>data</b> ="" The data to send with the request.<br />
<b>headers</b> =[] Array of headers. Each element in the array should be another array containing [headername,value].<br />
<b>callback</b> =null Callback for asynchronous connections. The callback is called after completion and is passed the request object as 1st Parameter.<br />
<b>returns</b> HTTP request object.<br />
<br />
</div>
</div></div>
<div class="contentItem"><h2>requirements<a class="bttop" href="#top"></a></h2><div>
The urllib requires the HTTPRequest object as fond in Mozilla and IE.<br />
In SVG it will use ASV's getURL/postURL methods, but is limited to asynchronous connections.<br />
</div></div>
</div>
</body>
</html>

View File

@ -1,60 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | xml</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.xml" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
xml</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module xml</h1>
Provides parseXML and an importNode implementation.
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>NoXMLParser()</h3><div class="indent">
Exception thrown if no parser could be instanciated.<br />
</div>
<h3>ParsingFailed()</h3><div class="indent">
Exception thrown if a document could not be parsed.<br />
<ul>
<li><b>ParsingFailed::xml</b> The xml source which could not be parsed.</li>
</ul>
</div>
<br />
<h3>parseXML(xml)</h3><div class="indent">
Parses an xml document.<br />
<b>xml</b> The xml text.<br />
<b>returns</b> A DOM of the xml document.<br />
</div>
<h3>importNode(importedNode,deep)</h3><div class="indent">
DOM2 implimentation of document.importNode().<br />
This will import into the current document. In SVG it will create SVG nodes in HTML it will create HTML nodes....<br />
This might become customizable in the future.<br />
<b>importedNode</b> The node to import.<br />
<b>deep</b> =true Import all childNodes recursively.<br />
<b>returns</b> The imported Node.<br />
<br />
</div>
<h3>node2XML(node)</h3><div class="indent">
Turns an XML document into a String.<br />
<b>node</b> The node to print.<br />
<b>returns</b> A string containing the text for the XML.<br />
<br />
</div>
</div></div>
<div class="contentItem"><h2>requirements<a class="bttop" href="#top"></a></h2><div>
Requires Mozilla's or IE's XML objects or parseXML in SVG(ASV).
</div></div>
</div>
</body>
</html>

View File

@ -1,175 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>.: jsolait :. | documentation | xmlrpc</title>
<link rel="stylesheet" type="text/css" href="./html.css" />
<meta name="author" content="Jan-Klaas Kollhof" />
<meta name="keywords" content="jsolait.xmlrpc" />
</head>
<body>
<a name="top" id="top"></a>
<div class="navigationBar"><a href="./index.xhtml">documentation</a> |
xmlrpc</div>
<div class="menu">
<ul></ul>
<div class="copyright">copyright © 2004, Jan-Klaas Kollhof</div>
</div>
<div class="content">
<h1>Module xmlrpc</h1>
Provides an XML-RPC imlementation.
It is similar to python's xmlrpclib module.
<div class="contentItem"><h2>public members:<a class="bttop" href="#top"></a></h2><div>
<h3>InvalidServerResponse()</h3><div class="indent">
Exception thrown if a server did not respond with response status 200 (OK).<br />
</div>
<h3>MalformedXmlRpc()</h3><div class="indent">
Exception thrown if an XML-RPC response is not well formed.<br />
</div>
<h3>Fault()</h3><div class="indent">
Exception thrown if the RPC response is a Fault. <br />
<ul>
<li><b>Fault::faultCode</b> The fault code returned by the rpc call.</li>
<li><b>Fault::faultString</b> The fault string returned by the rpc call.</li>
</ul>
</div>
<br />
<h3>marshall(obj)</h3><div class="indent">
Marshalls an object to XML-RPC.(Converts an object into XML-RPC conforming xml.)<br />
It just calls the toXmlRpc function of the objcect.<br />
So, to customize serialization of objects one just needs to specify/override the toXmlRpc method
which should return an xml string conforming with XML-RPC spec.<br />
<b>obj</b> The object to marshall<br />
<b>returns</b> An xml representation of the object.<br />
</div>
<h3>unmarshall(xml)</h3><div class="indent">
Unmarshalls an XML document to a JavaScript object. (Converts xml to JavaScript object.)<br />
It parses the xml source and creates a JavaScript object.<br />
<b>xml</b> The xml document source to unmarshall.<br />
<b>returns</b> The JavaScript object created from the XML.<br />
</div>
<h3>unmarshallDoc(doc,xml)</h3><div class="indent">
Unmarshalls an XML document to a JavaScript object like unmarshall but expects a DOM document as parameter.<br />
It parses the xml source and creates a JavaScript object.<br />
<b>doc</b> The xml document(DOM compatible) to unmarshall.<br />
<b>returns</b> The JavaScript object created from the XML.<br />
</div>
<br />
<h3>ServiceProxy(url,methodNames,user,pass)</h3><div class="indent">
Class for creating proxy objects which resemble the remote service.<br />
Method calls to this proxy will result in calls to the remote service.<br />
<br />
The arguments are interpreted as shown in the examples:<br />
<br />
ServerProxy("url")<br />
ServerProxy("url", ["methodName1",...])<br />
ServerProxy("url", ["methodName1",...], "user", "pass")<br />
ServerProxy("url", "user", "pass")<br />
<ul>
<li><b>url</b> The url of the service.</li>
<li><b>methodNames</b> =[] Array of names of methods that can be called on the server.<br />
If no methods are given then introspection is used to get the methodnames from the server.</li>
<li><b>user</b> =null The user name to use for HTTP authentication.</li>
<li><b>pass</b> =null The password to use for HTTP authentication.</li>
</ul>
The ServiceProxy objects expose all the methods of the remote service as XMLRPCMethod objects.
In addition the object also has the following methods and properties.<br />
<ul>
<li><b>ServiceProxy::_addMethodNames(methodNames)</b><br />
Adds new XMLRPCMethods to the proxy server which can then be invoked.<br />
<b>methodNames</b> Array of names of methods that can be called on the server.<br />
</li>
<li><b>ServiceProxy::_setAuthentication(user,pass)</b><br />
Sets username and password for HTTP Authentication for all methods of this service.<br />
<b>user</b> The user name.<br />
<b>pass</b> The password.<br />
</li>
<li><b>ServiceProxy::_introspect()</b><br />
Initiate XML-RPC introspection to retrieve methodnames from the server<br />
and add them to the server proxy.<br />
</li>
<li><b>ServiceProxy::_url</b><br />
The url of the service to resemble.<br />
</li>
<li><b>ServiceProxy::_user</b><br />
The user used for HTTP authentication.<br />
</li>
<li><b>ServiceProxy::_password</b><br />
The password used for HTTP authentication.<br />
</li>
<li><b>ServiceProxy::_methods</b><br />
All XMLRPCMethod objects the proxy can call.<br />
</li>
</ul>
</div>
<h3>XMLRPCMethod(url, name, user, pass)</h3><div class="indent">
Class for creating XML-RPC methods.<br />
Calling the created method will result in an XML-RPC call to the service.<br />
The return value of this call will be the return value of the RPC call.<br />
RPC-Faults will be raised as Exceptions.<br />
<br />
<ul>
<li><b>url</b> The URL of the service providing the method.</li>
<li><b>name</b> The name of the method to invoke.</li>
<li><b>user</b> =null The user name to use for HTTP authentication.</li>
<li><b>pass</b> =null The password to use for HTTP authentication.</li>
</ul>
Asynchronous operation:<br />
If the last parameter passed to the method is an XMLRPCAsyncCallback object, <br />
then the remote method will be called asynchronously. <br />
The results and errors are passed to the callback. <br />
<br />
<ul>
<li><b>XMLRPCMethod::toMulticall()</b><br />
Returns the method representation for system.multicall.<br />
All params will be passed to the remote method.<br />
<b>returns</b> An object containing a member methodName and a member params(As required by system.multicall).<br />
</li>
<li><b>XMLRPCMethod::setAuthentication(user,pass)</b><br />
Sets username and password for HTTP Authentication.<br />
<b>user</b> The user name.<br />
<b>pass</b> The password.<br />
</li>
<li><b>XMLRPCMethod::methodName</b><br />
The name of the remote method.<br />
</li>
<li><b>XMLRPCMethod::url</b><br />
The url of the remote service containing the method.<br />
</li>
<li><b>XMLRPCMethod::user</b><br />
The user name used for HTTP authorization.<br />
</li>
<li><b>XMLRPCMethod::password</b><br />
The password used for HTTP authorization.<br />
</li>
</ul>
</div>
<h3>XMLRPCAsyncCallback(result, err)</h3><div class="indent">
The interface of a callback for asynchronous XML-RPC.
<ul>
<li><b>result</b> The result of the call (null if error)</li>
<li><b>err</b> The Fault if there was one returned otherwise null</li>
</ul>
</div>
</div></div>
<div class="contentItem"><h2>requirements:<a class="bttop" href="#top"></a></h2><div>
<h3><a href="./urllib.xhtml">urllib</a></h3><div class="indent"> is required for making the HTTP request to the remote service.</div>
<h3><a href="./xml.xhtml">xml</a></h3><div class="indent"> is required for parsing the responses from the service.</div>
</div></div>
</div>
</body>
</html>

View File

@ -1,719 +0,0 @@
/*
Copyright (c) 2003 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Evaluates script in a global scope.
@param [0] The code to evaluate.
*/
globalEval=function(){
return eval(arguments[0]);
}
/**
Creates a new class object which inherits from superClass.
@param className="anonymous" The name of the new class.
If the created class is a public member of a module then
the className is automatically set.
@param superClass=Object The class to inherit from (super class).
@param classScope A function which is executed for class construction.
As 1st parameter it will get the new class' protptype for
overrideing or extending the super class. As 2nd parameter it will get
the super class' wrapper for calling inherited methods.
*/
Class = function(className, superClass, classScope){
if(arguments.length == 2){
classScope = superClass;
if(typeof className != "string"){
superClass = className;
className = "anonymous";
}else{
superClass = Object;
}
}else if(arguments.length == 1){
classScope = className;
superClass = Object;
className = "anonymous";
}
//this is the constructor for the new objects created from the new class.
//if and only if it is NOT used for prototyping/subclassing the init method of the newly created object will be called.
var NewClass = function(calledBy){
if(calledBy !== Class){
return this.init.apply(this, arguments);
}
}
//This will create a new prototype object of the new class.
NewClass.createPrototype = function(){
return new NewClass(Class);
}
//setting class properties for the new class.
NewClass.superClass = superClass;
NewClass.className=className;
NewClass.toString = function(){
return "[class %s]".format(NewClass.className);
};
if(superClass.createPrototype!=null){//see if the super class can create prototypes. (creating an object without calling init())
NewClass.prototype = superClass.createPrototype();
}else{//just create an object of the super class
NewClass.prototype = new superClass();
}
//reset the constructor for new objects to the actual constructor.
NewClass.prototype.constructor = NewClass;
if(superClass == Object){//all other objects already have a nice toString method.
NewClass.prototype.toString = function(){
return "[object %s]".format(this.constructor.className);
};
}
if(NewClass.prototype.init==null){
NewClass.prototype.init=function(){
}
}
//create a supr function to be used to call methods of the super class
var supr = function(self){
//set up super class functionality so a call to super(this) will return an object with all super class methods
//the methods can be called like super(this).foo and the this object will be bound to that method
var wrapper = {};
var superProto = superClass.prototype;
for(var n in superProto){
if(typeof superProto[n] == "function"){
wrapper[n] = function(){
var f = arguments.callee;
return superProto[f._name].apply(self, arguments);
}
wrapper[n]._name = n;
}
}
return wrapper;
}
//execute the scope of the class
classScope(NewClass.prototype, supr);
return NewClass;
}
Class.toString = function(){
return "[object Class]";
}
Class.createPrototype=function(){
throw "Can't use Class as a super class.";
}
/**
Creates a new module and registers it.
@param name The name of the module.
@param version The version of a module.
@param moduleScope A function which is executed for module creation.
As 1st parameter it will get the module variable.
*/
Module = function(name, version, moduleScope){
var mod = new Object();
mod.version = version;
mod.name = name;
mod.toString=function(){
return "[module '%s' version: %s]".format(mod.name, mod.version);
}
/**
Base class for all module-Exceptions.
*/
mod.Exception=Class("Exception", function(publ){
/**
Initializes a new Exception.
@param msg The error message for the user.
@param trace=null The error causing this Exception if available.
*/
publ.init=function(msg, trace){
this.name = this.constructor.className;
this.message = msg;
this.trace = trace;
}
publ.toString=function(){
var s = "%s %s\n\n".format(this.name, this.module);
s += this.message;
return s;
}
/**
Returns the complete trace of the exception.
@return The error trace.
*/
publ.toTraceString=function(){
var s = "%s %s:\n ".format(this.name, this.module );
s+="%s\n\n".format(this.message);
if(this.trace){
if(this.trace.toTraceString){
s+= this.trace.toTraceString();
}else{
s+= this.trace;
}
}
return s;
}
///The name of the Exception(className).
publ.name;
///The error message.
publ.message;
///The module the Exception belongs to.
publ.module = mod;
///The error which caused the Exception or null.
publ.trace;
})
//execute the scope of the module
moduleScope(mod);
//todo: set classNames for anonymous classes.
for(var n in mod){
if(mod[n].className == "anonymous"){
mod[n].className = n;
}
}
if(name != "jsolait"){
jsolait.registerModule(mod);
}
return mod;
}
Module.toString = function(){
return "[object Module]";
}
Module.createPrototype=function(){
throw "Can't use Module as a super class.";
}
//docstart
/**
The root module for jsolait.
It provides some global functionality for loading modules,
some String enhancements.
*/
Module("jsolait", "0.1.0", function(mod){
///The global jsolait object.
jsolait=mod;
///base url for user modules.
mod.baseURL=".";
///The URL where jsolait is installed.
/// viniciuscb 2004-11-18 - to work with eGroupWare
///mod.libURL ="./jsolait";
mod.libURL =GLOBALS['serverRoot']+"/phpgwapi/js/jsolait";
///Collection of all loaded modules.(module cache)
mod.modules = new Array();
///The URLs of there the modules, part of jsolait.
mod.moduleURLs = {urllib:"%(libURL)s/lib/urllib.js",
xml:"%(libURL)s/lib/xml.js",
crypto:"%(libURL)s/lib/crypto.js",
codecs:"%(libURL)s/lib/codecs.js",
jsonrpc:"%(libURL)s/lib/jsonrpc.js",
lang:"%(libURL)s/lib/lang.js",
xmlrpc:"%(libURL)s/lib/xmlrpc.js"};
mod.init=function(){
//make jsolait work with WScript
var ws = null;
try{//see if WScript is available
ws = WScript;
}catch(e){
}
if(ws != null){
initWS();
}
}
///initializes jsolait for using it with WScript
var initWS = function(){
print=function(msg){
WScript.echo(msg);
}
alert=function(msg){
print(msg);
}
var args = WScript.arguments;
try{
//get script to execute
var url = args(0);
url = url.replace(/\\/g, "/");
url = url.split("/");
url = url.slice(0, url.length-1);
//set base for user module loading
mod.baseURL = url.join("/");
}catch(e){
throw new mod.Exception("Missing script filename to be run.", e);
}
//location of jsolait/init.js
url = WScript.ScriptFullName;
if(args(0).replace("file://","").toLowerCase() == url.toLowerCase()){
WScript.stderr.write("Can't run myself! exiting ... \n");
return;
}
url = url.replace(/\\/g, "/");
url = url.split("/");
url = url.slice(0, url.length-1);
mod.libURL = "file://" + url.join("/");
try{
mod.loadScript(args(0));
}catch(e){
WScript.stdErr.write("%s(1,1) jsolait runtime error:\n%s\n".format(args(0).replace("file://",""), e.toTraceString()));
}
}
/**
Imports a module given its name(someModule.someSubModule).
A module's file location is determined by treating each module name as a directory.
Only the last one points to a file.
If the module's URL is not known to jsolait then it will be searched for in jsolait.baseURL which is "." by default.
@param name The name of the module to load.
@return The module object.
*/
mod.importModule = function(name){
if (mod.modules[name]){ //module already loaded
return mod.modules[name];
}else{
var src,modURL;
//check if jsolait already knows the url of the module(moduleURLs contains urls to modules)
if(mod.moduleURLs[name]){
modURL = mod.moduleURLs[name].format(mod);
}else{//assume it's a user module and located at baseURL
modURL = "%s/%s.js".format(mod.baseURL, name.split(".").join("/"));
}
try{//to load module from location calculated above
src = getFile(modURL);
}catch(e){//module could not be found at the location.
throw new mod.ModuleImportFailed(name, modURL, e);
}
try{//interpret the script
globalEval(src);
}catch(e){
throw new mod.ModuleImportFailed(name, modURL, e);
}
//the module should have registered itself
return mod.modules[name];
}
}
//make it global
importModule = mod.importModule;
/**
Loads and interprets a script file.
@param url The url of the script to load.
*/
mod.loadScript=function(url){
var src = getFile(url);
try{//to interpret the source
globalEval(src);
}catch(e){
throw new mod.EvalFailed(url, e);
}
}
/**
Registers a new module.
Registered modules can be imported with importModule(...).
@param module The module to register.
*/
mod.registerModule = function(module){
this.modules[module.name] = module;
}
/**
Creates an HTTP request object for retreiving files.
@return HTTP request object.
*/
var getHTTP=function() {
var obj;
try{ //to get the mozilla httprequest object
obj = new XMLHttpRequest();
}catch(e){
try{ //to get MS HTTP request object
obj=new ActiveXObject("Msxml2.XMLHTTP.4.0");
}catch(e){
try{ //to get MS HTTP request object
obj=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{// to get the old MS HTTP request object
obj = new ActiveXObject("microsoft.XMLHTTP");
}catch(e){
throw new mod.Exception("Unable to get an HTTP request object.");
}
}
}
}
return obj;
}
/**
Retrieves a file given its URL.
@param url The url to load.
@param headers=[] The headers to use.
@return The content of the file.
*/
var getFile=function(url, headers) {
//if callback is defined then the operation is done async
headers = (headers != null) ? headers : [];
//setup the request
try{
var xmlhttp= getHTTP();
xmlhttp.open("GET", url, false);
for(var i=0;i< headers.length;i++){
xmlhttp.setRequestHeader(headers[i][0], headers[i][1]);
}
xmlhttp.send("");
}catch(e){
throw new mod.Exception("Unable to load URL: '%s'.".format(url), e);
}
if(xmlhttp.status == 200 || xmlhttp.status == 0){
return xmlhttp.responseText;
}else{
throw new mod.Exception("File not loaded: '%s'.".format(url));
}
}
Error.prototype.toTraceString = function(){
if(this.message){
return "%s\n".format(this.message);
}
if (this.description){
return "%s\n".format(this.description);
}
return "unknown error\n";
}
/**
Thrown when a module could not be found.
*/
mod.ModuleImportFailed=Class(mod.Exception, function(publ, supr){
/**
Initializes a new ModuleImportFailed Exception.
@param name The name of the module.
@param url The url of the module.
@param trace The error cousing this Exception.
*/
publ.init=function(moduleName, url, trace){
supr(this).init("Failed to import module: '%s' from URL:'%s'".format(moduleName, url), trace);
this.moduleName = moduleName;
this.url = url;
}
///The name of the module that was not found.
publ.moduleName;
///The url the module was expected to be found at.
publ.url;
})
/**
Thrown when a source could not be loaded due to an interpretation error.
*/
mod.EvalFailed=Class(mod.Exception, function(publ, supr){
/**
Initializes a new EvalFailed exception.
@param url The url of the module.
@param trace The exception that was thrown while interpreting the module's source code.
*/
publ.init=function(url, trace){
supr(this).init("File '%s' Eval of script failed.".format(url), trace);
this.url = url;
}
///The url the module was expected to be found at.
publ.url;
})
/**
Displays an exception and it's trace.
This works better than alert(e) because traces are taken into account.
@param exception The exception to display.
*/
mod.reportException=function(exception){
if(exception.toTraceString){
var s= exception.toTraceString();
}else{
var s = exception.toString();
}
var ws = null;
try{//see if WScript is available
ws = WScript;
}catch(e){
}
if(ws != null){
WScript.stderr.write(s);
}else{
alert(s);
}
}
///The global exception report method;
reportException = mod.reportException;
})
//stringmod
/**
String formatting module.
It allows python like string formatting ("some text %s" % "something").
Also similar to sprintf from C.
*/
Module("stringformat", "0.1.0", function(mod){
/**
Creates a format specifier object.
*/
var FormatSpecifier=function(s){
var s = s.match(/%(\(\w+\)){0,1}([ 0-]){0,1}(\+){0,1}(\d+){0,1}(\.\d+){0,1}(.)/);
if(s[1]){
this.key=s[1].slice(1,-1);
}else{
this.key = null;
}
this.paddingFlag = s[2];
if(this.paddingFlag==""){
this.paddingFlag =" "
}
this.signed=(s[3] == "+");
this.minLength = parseInt(s[4]);
if(isNaN(this.minLength)){
this.minLength=0;
}
if(s[5]){
this.percision = parseInt(s[5].slice(1,s[5].length));
}else{
this.percision=-1;
}
this.type = s[6];
}
/**
Formats a string replacing formatting specifiers with values provided as arguments
which are formatted according to the specifier.
This is an implementation of python's % operator for strings and is similar to sprintf from C.
Usage:
resultString = formatString.format(value1, v2, ...);
Each formatString can contain any number of formatting specifiers which are
replaced with the formated values.
specifier([...]-items are optional):
"%(key)[flag][sign][min][percision]typeOfValue"
(key) If specified the 1st argument is treated as an object/associative array and the formating values
are retrieved from that object using the key.
flag:
0 Use 0s for padding.
- Left justify result, padding it with spaces.
Use spaces for padding.
sign:
+ Numeric values will contain a +|- infront of the number.
min:
l The string will be padded with the padding character until it has a minimum length of l.
percision:
.x Where x is the percision for floating point numbers and the lenght for 0 padding for integers.
typeOfValue:
d Signed integer decimal.
i Signed integer decimal.
b Unsigned binary. //This does not exist in python!
o Unsigned octal.
u Unsigned decimal.
x Unsigned hexidecimal (lowercase).
X Unsigned hexidecimal (uppercase).
e Floating point exponential format (lowercase).
E Floating point exponential format (uppercase).
f Floating point decimal format.
F Floating point decimal format.
c Single character (accepts byte or single character string).
s String (converts any object using object.toString()).
Examples:
"%02d".format(8) == "08"
"%05.2f".format(1.234) == "01.23"
"123 in binary is: %08b".format(123) == "123 in binary is: 01111011"
@param * Each parameter is treated as a formating value.
@return The formated String.
*/
String.prototype.format=function(){
var sf = this.match(/(%(\(\w+\)){0,1}[ 0-]{0,1}(\+){0,1}(\d+){0,1}(\.\d+){0,1}[dibouxXeEfFgGcrs%])|([^%]+)/g);
if(sf){
if(sf.join("") != this){
throw new mod.Exception("Unsupported formating string.");
}
}else{
throw new mod.Exception("Unsupported formating string.");
}
var rslt ="";
var s;
var obj;
var cnt=0;
var frmt;
var sign="";
for(var i=0;i<sf.length;i++){
s=sf[i];
if(s == "%%"){
s = "%";
}else if(s.slice(0,1) == "%"){
frmt = new FormatSpecifier(s);//get the formating object
if(frmt.key){//an object was given as formating value
if((typeof arguments[0]) == "object" && arguments.length == 1){
obj = arguments[0][frmt.key];
}else{
throw new mod.Exception("Object or associative array expected as formating value.");
}
}else{//get the current value
if(cnt>=arguments.length){
throw new mod.Exception("Not enough arguments for format string");
}else{
obj=arguments[cnt];
cnt++;
}
}
if(frmt.type == "s"){//String
if (obj == null){
obj = "null";
}
s=obj.toString().pad(frmt.paddingFlag, frmt.minLength);
}else if(frmt.type == "c"){//Character
if(frmt.paddingFlag == "0"){
frmt.paddingFlag=" ";//padding only spaces
}
if(typeof obj == "number"){//get the character code
s = String.fromCharCode(obj).pad(frmt.paddingFlag , frmt.minLength) ;
}else if(typeof obj == "string"){
if(obj.length == 1){//make sure it's a single character
s=obj.pad(frmt.paddingFlag, frmt.minLength);
}else{
throw new mod.Exception("Character of length 1 required.");
}
}else{
throw new mod.Exception("Character or Byte required.");
}
}else if(typeof obj == "number"){
//get sign of the number
if(obj < 0){
obj = -obj;
sign = "-"; //negative signs are always needed
}else if(frmt.signed){
sign = "+"; // if sign is always wanted add it
}else{
sign = "";
}
//do percision padding and number conversions
switch(frmt.type){
case "f": //floats
case "F":
if(frmt.percision > -1){
s = obj.toFixed(frmt.percision).toString();
}else{
s = obj.toString();
}
break;
case "E"://exponential
case "e":
if(frmt.percision > -1){
s = obj.toExponential(frmt.percision);
}else{
s = obj.toExponential();
}
s = s.replace("e", frmt.type);
break;
case "b"://binary
s = obj.toString(2);
s = s.pad("0", frmt.percision);
break;
case "o"://octal
s = obj.toString(8);
s = s.pad("0", frmt.percision);
break;
case "x"://hexadecimal
s = obj.toString(16).toLowerCase();
s = s.pad("0", frmt.percision);
break;
case "X"://hexadecimal
s = obj.toString(16).toUpperCase();
s = s.pad("0", frmt.percision);
break;
default://integers
s = parseInt(obj).toString();
s = s.pad("0", frmt.percision);
break;
}
if(frmt.paddingFlag == "0"){//do 0-padding
//make sure that the length of the possible sign is not ignored
s=s.pad("0", frmt.minLength - sign.length);
}
s=sign + s;//add sign
s=s.pad(frmt.paddingFlag, frmt.minLength);//do padding and justifiing
}else{
throw new mod.Exception("Number required.");
}
}
rslt += s;
}
return rslt;
}
/**
Padds a String with a character to have a minimum length.
@param flag "-": to padd with " " and left justify the string.
Other: the character to use for padding.
@param len The minimum length of the resulting string.
*/
String.prototype.pad = function(flag, len){
var s = "";
if(flag == "-"){
var c = " ";
}else{
var c = flag;
}
for(var i=0;i<len-this.length;i++){
s += c;
}
if(flag == "-"){
s = this + s;
}else{
s += this;
}
return s;
}
/**
Repeats a string.
@param c The count how often the string should be repeated.
*/
String.prototype.mul = function(c){
var a = new Array(this.length * c);
var s=""+ this;
for(var i=0;i<c;i++){
a[i] = s;
}
return a.join("");
}
})
//let jsolait do some startup initialization
jsolait.init();

View File

@ -1,168 +0,0 @@
/*
Copyright (c) 2004 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Codecs for encoding decoding Strings.
To add new encoders simply create new String.prototype.encode_yourCodec methods.
To add new decoders simply create new String.prototype.decode_yourCodec methods.
*/
Module("codecs", "0.1.2", function(mod){
/**
Returns all all available encoders.
@return An array of encoder names.
*/
mod.listEncoders=function(){
var c=[];
for(var attr in String.prototype){
if(attr.slice(0, 7) == "encode_"){
c.push(attr.slice(7));
}
}
return c;
}
/**
Returns all all available decoders.
@return An array of decoder names.
*/
mod.listDecoders=function(){
var c=[];
for(var attr in String.prototype){
if(attr.slice(0, 7) == "decode_"){
c.push(attr.slice(7));
}
}
return c;
}
/**
Decodes an encoded string.
Parameters but the codec parameter are forwardet to the codec.
@param codec The codec to use.
*/
String.prototype.decode = function(codec){
var n ="decode_" + codec;
if(String.prototype[n]){
var args=[];
for(var i=1;i<arguments.length;i++){
args[i-1] = arguments[i];
}
return String.prototype[n].apply(this, args);
}else{
throw new mod.Exception("Decoder '%s' not found.".format(codec));
}
}
/**
Encodes a string.
Parameters but the codec parameter are forwardet to the codec.
@param codec The codec to use.
*/
String.prototype.encode = function(codec){
var n ="encode_" + codec;
if(String.prototype[n]){
var args=[];
for(var i=1;i<arguments.length;i++){
args[i-1] = arguments[i];
}
return String.prototype[n].apply(this, args);
}else{
throw new mod.Exception("Ecnoder '%s' not found.".format(codec));
}
}
/**
Decodes a Base64 encoded string to a byte string.
*/
String.prototype.decode_base64=function(){
if((this.length % 4) == 0){
if(typeof(atob) != "undefined"){//try using mozillas builtin codec
return atob(this);
}else{
var nBits;
//create a result buffer, this is much faster than having strings concatinated.
var sDecoded = new Array(this.length /4);
var base64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
for(var i=0; i < this.length; i+=4){
nBits = (base64.indexOf(this.charAt(i)) & 0xff) << 18 |
(base64.indexOf(this.charAt(i+1)) & 0xff) << 12 |
(base64.indexOf(this.charAt(i+2)) & 0xff) << 6 |
base64.indexOf(this.charAt(i+3)) & 0xff;
sDecoded[i] = String.fromCharCode((nBits & 0xff0000) >> 16, (nBits & 0xff00) >> 8, nBits & 0xff);
}
//make sure padding chars are left out.
sDecoded[sDecoded.length-1] = sDecoded[sDecoded.length-1].substring(0, 3 - ((this.charCodeAt(i - 2) == 61) ? 2 : (this.charCodeAt(i - 1) == 61 ? 1 : 0)));
return sDecoded.join("");
}
}else{
throw new mod.Exception("String length must be divisible by 4.");
}
}
/**
Encodes a string using Base64.
*/
String.prototype.encode_base64=function(){
if(typeof(btoa) != "undefined"){//try using mozillas builtin codec
return btoa(this);
}else{
var base64 = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/'];
var sbin;
var pad=0;
var s="" + this;
if((s.length % 3) == 1){
s+=String.fromCharCode(0);
s+=String.fromCharCode(0);
pad=2;
}else if((s.length % 3) == 2){
s+=String.fromCharCode(0);
pad=1;
}
//create a result buffer, this is much faster than having strings concatinated.
var rslt=new Array(s.length / 3);
var ri=0;
for(var i=0;i<s.length; i+=3){
sbin=((s.charCodeAt(i) & 0xff) << 16) | ((s.charCodeAt(i+1) & 0xff ) << 8) | (s.charCodeAt(i+2) & 0xff);
rslt[ri] = (base64[(sbin >> 18) & 0x3f] + base64[(sbin >> 12) & 0x3f] + base64[(sbin >>6) & 0x3f] + base64[sbin & 0x3f]);
ri++;
}
if(pad>0){
rslt[rslt.length-1] = rslt[rslt.length-1].substr(0, 4-pad) + ((pad==2) ? "==" : (pad==1) ? "=" : "");
}
return rslt.join("");
}
}
/**
Decodes a URI using decodeURI.
*/
String.prototype.decode_uri=function(){
return decodeURI(this);
}
/**
Encodes a URI using encodeURI.
*/
String.prototype.encode_uri=function(){
return encodeURI(this);
}
})

View File

@ -1,149 +0,0 @@
/*
Copyright (c) 2003 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Cryptography module.
Provides String encryption/decryption and hashing.
*/
Module("crypto", "0.1.2", function(mod){
/**
Returns all all available encrypters.
@return An array of encrypters names.
*/
mod.listEncrypters=function(){
var c=[];
for(var attr in String.prototype){
if(attr.slice(0, 8) == "encrypt_"){
c.push(attr.slice(8));
}
}
return c;
}
/**
Returns all all available decrypters.
@return An array of decrypters names.
*/
mod.listDecrypters=function(){
var c=[];
for(var attr in String.prototype){
if(attr.slice(0, 8) == "decrypt_"){
c.push(attr.slice(8));
}
}
return c;
}
/**
Encrypts a string.
Parameters but the crypdec parameter are forwardet to the crypdec.
@param codec The codec to use.
*/
String.prototype.encrypt=function(crydec){
var n = "encrypt_" + crydec;
if(String.prototype[n]){
var args=[];
for(var i=1;i<arguments.length;i++){
args[i-1] = arguments[i];
}
return String.prototype[n].apply(this, args);
}else{
throw new mod.Exception("Decrypter '%s' not found.".format(crydec));
}
}
/**
Decrypts a string.
Parameters but the crypdec parameter are forwardet to the crypdec.
@param codec The codec to use.
*/
String.prototype.decrypt=function(crydec){
var n = "decrypt_" + crydec;
if(String.prototype[n]){
var args=[];
for(var i=1;i<arguments.length;i++){
args[i-1] = arguments[i];
}
return String.prototype[n].apply(this, args);
}else{
throw new mod.Exception("Encrypter '%s' not found.".format(crydec));
}
}
/**
Encrypts a string using XOR.
The whole String will be XORed with the key.
If the key is shorter than the String then it will be multiplied to fit the length of the String.
@param key The key to use for encryption.
*/
String.prototype.encrypt_xor=function(key){
var e=new Array(this.length);
var l=key.length;
for(var i=0;i<this.length;i++){
e[i] = String.fromCharCode(this.charCodeAt(i) ^ key.charCodeAt(i % l));
}
return e.join("");
}
/**
Decrypts a string using XOR.
Since XORing is symetric it is the same as the encrypter.
@param key The key to use for decryption.
*/
String.prototype.decrypt_xor=String.prototype.encrypt_xor;
/**
Encrypts a string using the ARC4 algorithm.
@param key The key to use for encryption.
*/
String.prototype.encrypt_rc4=function(key){
//generate substitution box
var sbox = new Array (256);
for (var i=0; i<256; i++){
sbox[i]=i;
}
//swap things around
var j=0;
for (var i=0; i < 256; i++) {
j = (j + sbox[i] + key.charCodeAt(i % key.length)) % 256;
var tmp = sbox[i];
sbox[i] = sbox[j];
sbox[j] = tmp;
}
//calculate the result
var i=256;
var j=256;
var rslt=new Array(this.length);
for (var k=0; k < this.length; k++) {
i = (i + 1) % 256;
j = (j + sbox[i]) % 256;
var tmp = sbox[i];
sbox[i] = sbox[j];
sbox[j] = tmp;
t = (sbox[i] + sbox[j]) % 256;
rslt[k] = String.fromCharCode(this.charCodeAt(k) ^ sbox[t]);
}
return rslt.join("");
}
/**
Decrypts a string using the ARC4 algorithm.
Since it is symetric it is the same as the encrypter.
@param key The key to use for decryption.
*/
String.prototype.decrypt_rc4=String.prototype.encrypt_rc4;
})

View File

@ -1,383 +0,0 @@
/*
Copyright (c) 2003-2004 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Provides an JSON-RPC imlementation.
*/
Module("jsonrpc", "0.3.2", function(mod){
var lang = importModule("lang");
var tokens = lang.tokens;
var ObjectBuffer=Class("ObjectBuffer", function(publ, supr){
publ.init=function(){
this.data="";
}
publ.getObjects=function(data){
this.data += data;
var t = new lang.Tokenizer(this.data);
var brCnt= 0;
var objects = [];
var readCnt = 0
while(! t.finished()){
var n = t.next();
if(n.type != tokens.ERR){
if(n.value == "{"){
brCnt+=1;
}else if(n.value == "}"){
brCnt-=1;
if(brCnt==0){
var s = this.data.slice(readCnt, n.pos+1);
readCnt += s.length;
objects.push(s);
}
}
}else{
break;
}
}
this.data = this.data.slice(readCnt);
return objects;
}
})
var nameAllowed=function(name){
return name.match(/^[a-zA-Z]\w*$/) != null;
}
var getMethodByName=function(obj, name){
try{//to get a method by asking the service
obj = obj._getMethodByName(name)
}catch(e){
var names = name.split(".");
for(var i=0;i<names.length;i++){
name = names[i];
if(nameAllowed(name)){
obj = obj[name];
}
}
}
return obj;
}
var Response=Class("Response", function(publ, supr){
publ.init=function(id, result, error){
this.id=id;
this.result = result;
this.error = error;
}
publ._toJSON=function(){
var p = [lang.objToJson(this.id), lang.objToJson(this.result),lang.objToJson(this.error)];
return '{"id":' + p[0] + ', "result":' + p[1] + ', "error":' + p[2] + "}";
}
})
var Request=Class("Request", function(publ, supr){
publ.init=function(id, method, params){
this.id=id;
this.method = method;
this.params = params;
}
publ._toJSON=function(){
var p = [lang.objToJson(this.id), lang.objToJson(this.method),lang.objToJson(this.params)];
return '{"id":' + p[0] + ', "method":' + p[1] + ', "params":' + p[2] + "}";
}
})
var Notification=Class("Notification", function(publ, supr){
publ.init=function(method, params){
this.method = method;
this.params = params;
}
publ._toJSON=function(){
var p = [lang.objToJson(this.method),lang.objToJson(this.params)];
return '{"method":' + p[0] + ', "params":' + p[1] + "}";
}
})
var ResponseHandler=Class("ResponseHandler", function(publ, supr){
publ.init=function(callback){
this.callback=callback;
}
publ.handleResponse=function(resp){
this.callback(resp.result, resp.error);
}
})
var RPCLib = Class("RPCLib", function(publ, supr){
})
var BaseConnectionHandler = Class("BaseConnectionHandler", function(publ, supr){
publ.init=function(service){
this.service = service;
this.jsonParser = new lang.JSONParser();
this.jsonParser.addLib(new RPCLib(), "rpc", []);
this.respHandlers = [];
this.objBuffer = new ObjectBuffer();
}
publ.addResponseHandler=function(cb){
var id=1;
while(this.respHandlers[""+id] ){
id+=1;
}
id="" + id;
this.respHandlers[id] = new ResponseHandler(cb);
return id;
}
publ.send = function(data){
}
publ.sendNotify = function(name, args){
var n = new Notification(name, args);
n = this.jsonParser.objToJson(n);
this.send(n)
}
publ.sendRequest = function(name, args, callback){
var id = this.addResponseHandler(callback);
var r = new Request(id, name, args);
r = this.jsonParser.objToJson(r);
this.send(r);
}
publ.sendResponse = function(id, result, error){
var r = new Response(id, result, error);
r = this.jsonParser.objToJson(r);
this.send(r);
}
publ.handleRequest = function(req){
var name = req.method;
var params = req.params;
var id=req.id;
if(this.service[name]){
try{
var rslt = this.service[name].apply(this.service,params);
this.sendResponse(id, rslt, null)
}catch(e){
this.sendResponse(id, null, new ApplicationError("" + e))
}
}else{
this.sendResponse(id, null, new MethodNotFound());
}
}
publ.handleNotification = function(notif){
if(this.service[notif.method]){
try{
this.service[notif.method].apply(this.service, notif.params);
}catch(e){
}
}
}
publ.handleResponse = function(resp){
var id=resp.id;
var h = this.respHandlers[id];
h.handleResponse(resp)
delete this.respHandlers[id]
}
publ.handleData = function(data){
var objs = this.objBuffer.getObjects(data);
for(var i=0;i<objs.length;i++){
try{
var obj = this.jsonParser.jsonToObj(objs[i]);
}catch(e){
throw "Not well formed";
}
if(obj.method != null){
if(obj.id != null){
this.handleRequest(new Request(obj.id, obj.method, obj.params));
}else{
this.handleNotification(new Notification(obj.method, obj.params));
}
}else if(obj.id != null){
this.handleResponse(new Response(obj.id, obj.result, obj.error));
}else{
throw "Unknown Data";
}
}
}
})
var SocketConnectionHandler = Class("SocketConnectionHandler", BaseConnectionHandler, function(publ, supr){
publ.init=function(socket, localService){
this.socket = socket;
socket.addEventListener("connectionData", this, false);
supr(this).init( localService);
}
publ.handleEvent=function(evt){
this.handleData(evt.data);
}
publ.send=function(data){
this.socket.send(data);
}
publ.close=function(data){
this.socket.close();
}
})
var HTTPConnectionHandler = Class("HTTPConnectionHandler", BaseConnectionHandler, function(publ, supr){
var urllib;
publ.init=function(url, localService){
urllib=importModule("urllib");
this.url = url;
supr(this).init( localService);
}
publ.handleData = function(data){
try{
var obj = this.jsonParser.jsonToObj(data);
}catch(e){
throw "Not well formed";
}
if(obj.id != null){
return obj;
}else{
throw "Unknown Data (No id property found)";
}
}
publ.sendRequest = function(name, args, callback){
var sync = false;
if(typeof callback != "function"){//see if it is sync
args.push(callback);
sync=true;
}
var data = new Request("httpReq", name, args);
data = this.jsonParser.objToJson(data);
if(sync){
var rsp = urllib.postURL(this.url, data, [["Content-Type", "text/plain"]]);
rsp = this.handleData(rsp.responseText);
if(rsp.error){
throw rsp.error;
}else{
return rsp.result;
}
}else{//async connection uses the respHandler to handle the repsonse
var self = this;
urllib.postURL(this.url, data, [["Content-Type", "text/plain"]], function(rsp){
try{
rsp = self.handleData(rsp.responseText);
}catch(e){
callback(null,e);
return;
}
callback(rsp.result, rsp.error);
});
}
}
publ.sendNotify = function(name, args){
var data = new Notification(name, args);
data = this.jsonParser.objToJson(data);
urllib.postURL(this.url, data, [["Content-Type", "text/plain"]], function(rsp){});
}
})
var PeerObject=Class("PeerObject", function(publ, supr){
publ.init=function(name, conn){
var fn=function(){
var args=[];
for(var i=0;i<arguments.length;i++){
args[i] = arguments[i];
}
var cb=args.pop();
return conn.sendRequest(name, args, cb);
}
return fn;
}
})
var PeerNotifyObject=Class("PeerNotifyObject", function(publ, supr){
publ.init=function(name, conn){
var fn=function(){
var args=[];
for(var i=0;i<arguments.length;i++){
args[i] = arguments[i];
}
conn.sendNotify(name, args);
}
return fn;
}
})
var BasePeer = Class("BasePeer", function(publ, supr){
publ.init=function(conn, methodNames){
this._conn = conn;
this.notify = new PeerObject("notify", conn);
this._add(methodNames);
}
var setupPeerMethod=function(root, methodName, conn, MethClass){
var names = methodName.split(".");
var obj = root;
for(var n=0;n<names.length-1;n++){
var name = names[n];
if(obj[name]){
obj = obj[name];
}else{
obj[name] = new Object();
obj = obj[name];
}
}
var name = names[names.length-1];
if(obj[name]){
}else{
var mth = new MethClass(methodName, conn);
obj[name] = mth;
}
}
publ._add = function(methodNames){
for(var i=0;i<methodNames.length;i++){
setupPeerMethod(this, methodNames[i], this._conn, PeerObject);
setupPeerMethod(this.notify, methodNames[i], this._conn, PeerNotifyObject);
}
}
})
mod.ServiceProxy = Class("ServiceProxy", BasePeer, function(publ, supr){
publ.init = function(url, methodNames, localService){
var n = url.match(/^jsonrpc:\/\/(.*:\d*)$/);
if(n!=null){//is it json-rpc over TCP protocoll
var hostaddr = n[1];
try{
var socket = createConnection();
}catch(e){
throw "Can't create a socket connection."
}
socket.connect(hostaddr);
supr(this).init( new SocketConnectionHandler(socket, localService), methodNames);
}else{//or is it json-rpc over http
supr(this).init( new HTTPConnectionHandler(url, localService), methodNames);
}
}
})
})

View File

@ -1,461 +0,0 @@
/*
Copyright (c) 2004 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Module providing language services like tokenizing JavaScript code
or converting JavaScript objects to and from JSON (see json.org).
To customize JSON serialization of Objects just overwrite the toJSON method in your class.
*/
Module("lang", "0.3.5", function(mod){
var ISODate = function(d){
if(/^(\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})/.test(d)){
return new Date(Date.UTC(RegExp.$1, RegExp.$2-1, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6));
}else{ //todo error message
throw "Not an ISO date: " + d;
}
}
mod.JSONParser=Class("JSONParser", function(publ, supr){
publ.init=function(){
this.libs = {};
var sys = {"ISODate" : ISODate};
this.addLib(sys, "sys", ["ISODate"]);
}
publ.addLib = function(obj, name, exports){
if(exports == null){
this.libs[name] = obj;
}else{
for(var i=0;i<exports.length;i++){
this.libs[name + "." + exports[i]] = obj[exports[i]];
}
}
}
var EmptyValue = {};
var SeqSep = {};
var parseValue = function(tkns, libs){
var tkn = tkns.nextNonWS();
switch(tkn.type){
case mod.tokens.STR:
case mod.tokens.NUM:
return eval(tkn.value);
case mod.tokens.NAME:
return parseName(tkn.value);
case mod.tokens.OP:
switch(tkn.value){
case "[":
return parseArray(tkns, libs);
break;
case "{":
return parseObj(tkns, libs);
break;
case "}": case "]":
return EmptyValue;
case ",":
return SeqSep;
default:
throw "expected '[' or '{' but found: '" + tkn.value + "'";
}
}
return EmptyValue;
}
var parseArray = function(tkns, libs){
var a = [];
while(! tkns.finished()){
var v = parseValue(tkns, libs);
if(v == EmptyValue){
return a;
}else{
a.push(v);
v = parseValue(tkns, libs);
if(v == EmptyValue){
return a;
}else if(v != SeqSep){
throw "',' expected but found: '" + v + "'";
}
}
}
throw "']' expected";
}
var parseObj = function(tkns, libs){
var obj = {};
var nme =""
while(! tkns.finished()){
var tkn = tkns.nextNonWS();
if(tkn.type == mod.tokens.STR){
var nme = eval(tkn.value);
tkn = tkns.nextNonWS();
if(tkn.value == ":"){
var v = parseValue(tkns, libs);
if(v == SeqSep || v == EmptyValue){
throw "value expected";
}else{
obj[nme] = v;
v = parseValue(tkns, libs);
if(v == EmptyValue){
return transformObj(obj, libs);
}else if(v != SeqSep){
throw "',' expected";
}
}
}else{
throw "':' expected but found: '" + tkn.value + "'";
}
}else if(tkn.value == "}"){
return transformObj(obj, libs);
}else{
throw "String expected";
}
}
throw "'}' expected."
}
var transformObj = function(obj, libs){
var o2;
if(obj.jsonclass != null){
var clsName = obj.jsonclass[0];
var params = obj.jsonclass[1]
if(libs[clsName]){
o2 = libs[clsName].apply(this, params);
for(var nme in obj){
if(nme != "jsonclass"){
if(typeof obj[nme] != "function"){
o2[nme] = obj[nme];
}
}
}
}else{
throw "jsonclass not found: " + clsName;
}
}else{
o2 = obj;
}
return o2;
}
var parseName = function(name){
switch(name){
case "null":
return null;
case "true":
return true;
case "false":
return false;
default:
throw "'null', 'true', 'false' expected but found: '" + name + "'";
}
}
publ.jsonToObj = function(data){
var t = new mod.Tokenizer(data);
return parseValue(t, this.libs);
}
publ.objToJson=function(obj){
if(obj == null){
return "null";
}else{
return obj.toJSON();
}
}
})
mod.parser = new mod.JSONParser();
/**
Turns JSON code into JavaScript objects.
@param src The source as a String.
*/
mod.jsonToObj=function(src){
return mod.parser.jsonToObj(src);
}
/**
Turns an object into JSON.
This is the same as calling obj.toJSON();
@param obj The object to marshall.
*/
mod.objToJson=function(obj){
return mod.parser.objToJson(obj);
}
///Token constants for the tokenizer.
mod.tokens = {};
mod.tokens.WSP = 0;
mod.tokens.OP =1;
mod.tokens.STR = 2;
mod.tokens.NAME = 3;
mod.tokens.NUM = 4;
mod.tokens.ERR = 5;
mod.tokens.NL = 6;
mod.tokens.COMMENT = 7;
mod.tokens.DOCCOMMENT = 8;
mod.tokens.REGEXP = 9;
//todo:doc
mod.Token=Class(function(publ, supr){
publ.init=function(type, value, pos, err){
this.type = type;
this.value = value;
this.pos = pos;
this.err= err;
}
})
/**
Tokenizer Class which incrementally parses JavaScript code and returns the language tokens.
*/
mod.Tokenizer=Class("Tokenizer", function(publ, supr){
publ.init=function(s){
this._working = s;
this._pos = 0;
}
/**
Returns weather or not the code was parsed.
@return True if the complete code was parsed, false otherwise.
*/
publ.finished=function(){
return this._working.length == 0;
}
publ.nextNonWS = function(nlIsWS){
var tkn = this.next();
while((tkn.type == mod.tokens.WSP) || (nlIsWS && (tkn.type == mod.tokens.NL))){
tkn = this.next();
}
return tkn;
}
/**
Returns the next token.
@return The next token.
*/
publ.next = function(){
if(this._working ==""){
throw "Empty";
}
var s1 = this._working.charAt(0);
var s2 = s1 + this._working.charAt(1);
var s3 = s2 + this._working.charAt(2);
var rslt=[];
switch(s1){
case '"': case "'":
try{
s1 = extractQString(this._working);
rslt= new mod.Token(mod.tokens.STR, s1, this._pos);
}catch(e){
rslt= new mod.Token(mod.tokens.ERR, s1, this._pos, e);
}
break;
case "\n": case "\r":
rslt =new mod.Token(mod.tokens.NL, s1, this._pos);
break;
case "{": case "}": case "[": case "]": case "(": case ")":
case ":": case ",": case ".": case ";":
case "*": case "-": case "+":
case "=": case "<": case ">": case "!":
switch(s2){
case "==": case "!=": case "<>": case "<=": case ">=":
rslt = new mod.Token(mod.tokens.OP, s2, this._pos);
break;
default:
rslt = new mod.Token(mod.tokens.OP, s1, this._pos);
}
break;
case "/":
if(s2 == "//" || s3 =="///"){
s1 = extractSLComment(this._working);
rslt = new mod.Token(s1.charAt(2) != "/" ? mod.tokens.COMMENT:mod.tokens.DOCCOMMENT, s1, this._pos);
}else if(s2 == "/*" || s3 =="/**"){
try{
s1 = extractMLComment(this._working);
rslt = new mod.Token(s3 !="/**" ? mod.tokens.COMMENT: mod.tokens.DOCCOMMENT, s1, this._pos);
}catch(e){
rslt= new mod.Token(mod.tokens.ERR, s3 != "/**" ? s2 : s3, this._pos, e);
}
}else{
try{
s1 = extractRegExp(this._working);
rslt = new mod.Token(mod.tokens.REGEXP, s1, this._pos);
}catch(e){
rslt = new mod.Token(mod.tokens.OP, s1, this._pos, e);
}
}
break;
default:
s1=this._working.match(/\d+\.\d+|\d+|\w+|\s+/)[0];
if(s1.replace(/\s+/g,"") == ""){ //whitespace
rslt = new mod.Token(mod.tokens.WSP, s1, this._pos);
}else if(/^\d|\d\.\d/.test(s1)){//number
rslt = new mod.Token(mod.tokens.NUM, s1, this._pos);
}else{//name
rslt =new mod.Token(mod.tokens.NAME, s1, this._pos);
}
}
this._working=this._working.slice(rslt.value.length);
this._pos += rslt.value.length;
return rslt;
}
var searchQoute = function(s, q){
if(q=="'"){
return s.search(/[\\']/);
}else{
return s.search(/[\\"]/);
}
}
var extractQString=function(s){
if(s.charAt(0) == "'"){
var q="'";
}else{
var q='"';
}
s=s.slice(1);
var rs="";
var p= searchQoute(s, q);
while(p >= 0){
if(p >=0){
if(s.charAt(p) == q){
rs += s.slice(0, p+1);
s = s.slice(p+1);
return q + rs;
}else{
rs+=s.slice(0, p+2);
s = s.slice(p+2);
}
}
p = searchQoute(s, q);
}
throw "End of String expected.";
}
var extractSLComment=function(s){
var p = s.search(/\n/);
if(p>=0){
return s.slice(0,p+1);
}else{
return s;
}
}
var extractMLComment=function(s){
var p = s.search(/\*\//);
if(p>=0){
return s.slice(0,p+2);
}else{
throw "End of comment expected.";
}
}
var extractRegExp=function(s){
var p=0;
for(var i=0;i<s.length;i++){
if(s.charAt(i) == "/"){
p=i;
}
if(s.charAt(i) == "\n"){
i = s.length;
}
}
return s.slice(0,p+1);
}
})
/**
Converts an object to JSON.
*/
Object.prototype.toJSON = function(){
var v=[];
for(attr in this){
if(typeof this[attr] != "function"){
v.push('"' + attr + '": ' + mod.objToJson(this[attr]));
}
}
return "{" + v.join(", ") + "}";
}
/**
Converts a String to JSON.
*/
String.prototype.toJSON = function(){
var s = '"' + this.replace(/(["\\])/g, '\\$1') + '"';
s = s.replace(/(\n)/g,"\\n");
return s;
}
/**
Converts a Number to JSON.
*/
Number.prototype.toJSON = function(){
return this.toString();
}
/**
Converts a Boolean to JSON.
*/
Boolean.prototype.toJSON = function(){
return this.toString();
}
/**
Converts a Date to JSON.
Date representation is not defined in JSON.
*/
Date.prototype.toJSON= function(){
var padd=function(s, p){
s=p+s
return s.substring(s.length - p.length)
}
var y = padd(this.getUTCFullYear(), "0000");
var m = padd(this.getUTCMonth() + 1, "00");
var d = padd(this.getUTCDate(), "00");
var h = padd(this.getUTCHours(), "00");
var min = padd(this.getUTCMinutes(), "00");
var s = padd(this.getUTCSeconds(), "00");
var isodate = y + m + d + "T" + h + ":" + min + ":" + s
return '{"jsonclass":["sys.ISODate", ["' + isodate + '"]]}';
}
/**
Converts an Array to JSON.
*/
Array.prototype.toJSON = function(){
var v = [];
for(var i=0;i<this.length;i++){
v.push(mod.objToJson(this[i])) ;
}
return "[" + v.join(", ") + "]";
}
})

View File

@ -1,306 +0,0 @@
/*
Copyright (c) 2003 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Provides methods for making HTTP requests.
*/
Module("urllib","1.1.2", function(mod){
/**
Thrown if no request object could be instanciated.
*/
mod.NoHTTPRequestObject=Class("NoHTTPRequestObject", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param trace The error causing this exception.
*/
publ.init=function(trace){
supr(this).init( "Could not create an HTTP request object", trace);
}
})
/**
Thrown if an HTTP request could not be opened.
*/
mod.RequestOpenFailed = Class("RequestOpenFailed", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param trace The error causing this exception.
*/
publ.init=function(trace){
supr(this).init( "Opening of HTTP request failed.", trace);
}
})
/**
Thrown is arequest could not be sent to the server.
*/
mod.SendFailed=Class("SendFailed", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param trace The error causing this exception.
*/
publ.init = function(trace){
supr(this).init( "Sending of HTTP request failed.", trace);
}
})
/**
Mimics the HTTPRequest object using Adobe's SVG Viewer's postURL and getURL.
It can only process asyncronous connection and the only header that's supported is 'Content-Type'.
*/
var ASVRequest=Class("ASVRequest", function(publ){
/**
Initializes the ASVRequest.
*/
publ.init = function(){
if((getURL==null) || (postURL==null)){
throw "getURL and postURL are not available!";
}else{
this.readyState=0;
this.responseText="";
this.__contType ="";
this.status=200;
}
}
/**
Mimics the open method without actually opening a connection.
@param type "GET" or "POST".
@param url The url to open.
@param async=true True for async. connection. Otherwhise an exception is thrown.
*/
publ.open=function(type,url,async){
if (async == false){
throw "Can only open asynchronous connections!";
}
this.__type = type;
this.__url = url;
this.readyState=0;
}
/**
Sets a header.
@param name The header name. All but "Content-Type" are ignored.
@param value The value of the header.
*/
publ.setRequestHeader=function(name, value){
if (name=="Content-Type"){
this.__contType =value;
}
}
/**
Sends the request.
@param data The data to send when doing a post.
*/
publ.send=function(data){
var self=this;
var cbh=new Object();
cbh.operationComplete = function(rsp){
self.readyState=4;
self.responseText=rsp.content;
if(this.ignoreComplete == false){
if(self.onreadystatechange){
self.onreadystatechange();
}
}
}
cbh.ignoreComplete = false;
try{
if(this.__type =="GET"){
getURL(this.__url,cbh);
}else if (this.__type == "POST"){
postURL(this.__url, data, cbh, this.__contType);
}
}catch(e){
cbh.ignoreComplete=true;
throw e;
}
}
})
/**
Creates an HTTP request object for retreiving files.
@return HTTP request object.
*/
var getHTTP=function() {
var obj;
try{ //to get the mozilla httprequest object
obj = new XMLHttpRequest();
}catch(e){
try{ //to get MS HTTP request object
obj=new ActiveXObject("Msxml2.XMLHTTP.4.0");
}catch(e){
try{ //to get MS HTTP request object
obj=new ActiveXObject("Msxml2.XMLHTTP")
}catch(e){
try{// to get the old MS HTTP request object
obj = new ActiveXObject("microsoft.XMLHTTP");
}catch(e){
try{//to create the ASV request object.
obj = new ASVRequest();
}catch(e){
throw new mod.NoHTTPRequestObject("Neither Mozilla, IE nor ASV found. Can't do HTTP request without them.");
}
}
}
}
}
return obj;
}
/**
Sends a request to a server.
To explain the way the optional arguments work I will give examples:
simple:
sendRequest("get", "url")
sendRequest("post", "url", "data")
with headers:
sendRequest("get", "url", [["headername","value"]])
sendRequest("post", "url", "data", [["headername","value"]])
with user information:
sendRequest("get", "url", "user", "pass")
sendRequest("post", "url", "user", "pass", "data")
with headers and user information:
sendRequest("get", "url", "user", "pass", [["headername","value"]])
sendRequest("post", "url", "user", "pass", "data", [["headername","value"]])
To make the request asynchronous just add a callback function as the last argument to the calls above.
@param type Type of connection (GET, POST, ...).
@param url The URL to retrieve.
@param user=null The username for auth.
@param pass=null The password. (must be set if user is set!)
@param data="" The data to send with the request.
@param headers=[] Array of headers. Each element in the array should be another array containing [headername,value].
@param callback=null Callback for asynchronous connections. The callback is called after completion and is passed the request object as 1st Parameter.
@return HTTP request object.
*/
mod.sendRequest=function(type, url, user, pass, data, headers, callback){
var async=false;
//check if the last argument is a function and treat it as callback;
if(arguments[arguments.length-1] instanceof Function){
var async=true;
callback = arguments[arguments.length-1];
}
//treat sencond last(if callback)/last(if no callback) argument as headers
var headindex=arguments.length-((async || arguments[arguments.length-1] == null) ?2:1);
//is it an array then it's headers
if(arguments[headindex] instanceof Array){
headers=arguments[headindex];
}else{
headers=[];
}
//are user AND password not specified then assume data as 3rd argument.
if(typeof user == "string" && typeof pass == "string"){
if(typeof data != "string"){
data="";
}
}else if (typeof user == "string"){
data = user;
user=null;
pass=null;
}else{
user=null;
pass=null;
}
var xmlhttp= getHTTP();
try{
if(user!=null){
xmlhttp.open(type, url, async, user, pass);
}else{
xmlhttp.open(type, url, async);
}
}catch(e){
throw new mod.RequestOpenFailed(e);
}
//set headers
for(var i=0;i< headers.length;i++){
xmlhttp.setRequestHeader(headers[i][0], headers[i][1]);
}
if(async){//set up a callback
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4) {
callback(xmlhttp);
xmlhttp = null; //help IE with arbage collection
}else if (xmlhttp.readyState==2){
//status property should be available (MS IXMLHTTPRequest documentation)
//in Mozilla it is not if the request failed(server not reachable)
//in IE it is not available at all ?!
try{//see if it is mozilla otherwise don't care.
var isNetscape = netscape;
try{//if status is not available the request failed.
var s=xmlhttp.status;
}catch(e){//call the callback because Mozilla will not get to readystate 4
callback(xmlhttp);
xmlhttp = null;
}
}catch(e){
}
}
}
}
try{
xmlhttp.send(data);
}catch(e){
throw new mod.SendFailed(e);
}
return xmlhttp;
}
/**
Shorthand for a GET request.
It calls sendRequest with "GET" as first argument.
See the sendRequest method for more information.
@param url The URL to retrieve.
@param user=null The username for auth.
@param pass=null The password. (must be set if user is set!)
@param headers=[] Array of headers. Each element in the array should be another array containing [headername,value].
@param callback=null Callback for asynchronous connections. The callback is called after completion and is passed the request object as 1st Parameter.
@return HTTP request object.
*/
mod.getURL=function(url, user, pass, headers, callback) {
var a= new Array("GET");
for(var i=0;i<arguments.length;i++){
a.push(arguments[i]);
}
return mod.sendRequest.apply(this,a)
}
/**
Shorthand for a POST request.
It calls sendRequest with "POST" as first argument.
See the sendRequest method for more information.
@param url The URL to retrieve.
@param user=null The username for auth.
@param pass=null The password. (must be set if user is set!)
@param data="" The data to send with the request.
@param headers=[] Array of headers. Each element in the array should be another array containing [headername,value].
@param callback=null Callback for asynchronous connections. The callback is called after completion and is passed the request object as 1st Parameter.
@return HTTP request object.
*/
mod.postURL=function(url, user, pass, data, headers, callback) {
var a= new Array("POST");
for(var i=0;i<arguments.length;i++){
a.push(arguments[i]);
}
return mod.sendRequest.apply(this,a)
}
})

View File

@ -1,247 +0,0 @@
/*
Copyright (c) 2003 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Provides parseXML and an importNode implementation.
*/
Module("xml","1.1.2", function(mod){
/**
Thrown if no parser could be instanciated.
*/
mod.NoXMLParser=Class("NoXMLParser", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param trace The error causing the Exception.
*/
publ.init=function(trace){
supr(this).init("Could not create an XML parser.", trace);
}
})
/**
Thrown if a document could not be parsed.
*/
mod.ParsingFailed=Class("ParsingFailed", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param xml The xml source which could not be parsed.
@param trace The error causing this Exception.
*/
publ.init=function(xml,trace){
supr(this).init("Failed parsing XML document.",trace);
this.xml = xml;
}
///The xml source which could not be parsed.
publ.xml;
})
/**
Parses an xml document.
@param xml The xml text.
@return A DOM of the xml document.
*/
mod.parseXML=function(xml){
var obj=null;
var isMoz=false;
var isIE=false;
var isASV=false;
try{//to get Adobe's SVG parseXML
var p=window.parseXML;
if(p==null){
throw "No ASV paseXML";
}
isASV=true;
}catch(e){
try{//to get the mozilla parser
obj = new DOMParser();
isMoz=true;
}catch(e){
try{//to get the MS XML parser
obj = new ActiveXObject("Msxml2.DomDocument.4.0");
isIE=true;
}catch(e){
try{//to get the MS XML parser
obj = new ActiveXObject("Msxml2.DomDocument");
isIE=true;
}catch(e){
try{//to get the old MS XML parser
obj = new ActiveXObject("microsoft.XMLDOM");
isIE=true;
}catch(e){
throw new mod.NoXMLParser(e);
}
}
}
}
}
try{
if(isMoz){
obj = obj.parseFromString(xml, "text/xml");
return obj;
}else if(isIE){
obj.loadXML(xml);
return obj;
}else if(isASV){
return window.parseXML(xml, null);
}
}catch(e){
throw new mod.ParsingFailed(xml,e);
}
}
/**
DOM2 implimentation of document.importNode().
This will import into the current document. In SVG it will create SVG nodes in HTML it will create HTML nodes....
This might become customizable in the future.
@param importedNode The node to import.
@param deep=true Import all childNodes recursively.
@return The imported Node.
*/
mod.importNode=function(importedNode, deep){
deep = (deep==null) ? true : deep;
//constants from doom2
var ELEMENT_NODE = 1;
var ATTRIBUTE_NODE = 2;
var TEXT_NODE = 3;
var CDATA_SECTION_NODE = 4;
var ENTITY_REFERENCE_NODE = 5;
var ENTITY_NODE = 6;
var PROCESSING_INSTRUCTION_NODE = 7;
var COMMENT_NODE = 8;
var DOCUMENT_NODE = 9;
var DOCUMENT_TYPE_NODE = 10;
var DOCUMENT_FRAGMENT_NODE = 11;
var NOTATION_NODE = 12;
var importChildren=function(srcNode, parent){
if(deep){
for(var i=0; i<srcNode.childNodes.length; i++){
var n=mod.importNode(srcNode.childNodes.item(i), true);
parent.appendChild(n);
}
}
}
var node=null;
switch(importedNode.nodeType){
case ATTRIBUTE_NODE:
node=document.createAttributeNS(importedNode.namespaceURI, importedNode.nodeName);
node.value=importedNode.value;
break;
case DOCUMENT_FRAGMENT_NODE:
node=document.createDocumentFragment();
importChildren(importedNode,node);
break;
case ELEMENT_NODE:
node=document.createElementNS(importedNode.namespaceURI, importedNode.tagName);
//import all attributes
for(var i=0; i<importedNode.attributes.length; i++){
var attr=this.importNode(importedNode.attributes.item(i), deep);
node.setAttributeNodeNS(attr);
}
importChildren(importedNode,node);
break;
case ENTITY_REFERENCE_NODE:
node=importedNode;
break;
case PROCESSING_INSTRUCTION_NODE:
node=document.createProcessingInstruction(importedNode.target, importedNode.data);
break;
case TEXT_NODE:
case CDATA_SECTION_NODE:
case COMMENT_NODE:
node=document.createTextNode(importedNode.nodeValue);
break;
case DOCUMENT_NODE:
//Document nodes cannot be imported.
case DOCUMENT_TYPE_NODE:
//DocumentType nodes cannot be imported.
case NOTATION_NODE:
//readonly in DOM2
case ENTITY_NODE:
//readonly in DOM2
throw "not supported in DOM2";
break;
}
return node;
}
/**
Turns an XML document into a String.
@param node The node to print.
@return A string containing the text for the XML.
*/
mod.node2XML = function(node){
var ELEMENT_NODE = 1;
var ATTRIBUTE_NODE = 2;
var TEXT_NODE = 3;
var CDATA_SECTION_NODE = 4;
var ENTITY_REFERENCE_NODE = 5;
var ENTITY_NODE = 6;
var PROCESSING_INSTRUCTION_NODE = 7;
var COMMENT_NODE = 8;
var DOCUMENT_NODE = 9;
var DOCUMENT_TYPE_NODE = 10;
var DOCUMENT_FRAGMENT_NODE = 11;
var NOTATION_NODE = 12;
var s="";
switch(node.nodeType){
case ATTRIBUTE_NODE:
s+=node.nodeName+'="' + node.value + '"';
break;
case DOCUMENT_NODE:
s+=this.node2XML(node.documentElement);
break;
case ELEMENT_NODE:
s+="<" + node.tagName;
//attributes
for(var i=0; i<node.attributes.length; i++){
s+=" " + this.node2XML(node.attributes.item(i));
}
//children
if(node.childNodes.length==0){
s+="/>\n";
}else{
s+=">";
for(var i=0; i<node.childNodes.length; i++){
s+=this.node2XML(node.childNodes.item(i));
}
s+="</" + node.tagName+ ">\n";
}
break;
case PROCESSING_INSTRUCTION_NODE:
s+="<?" + node.target + " " + node.data + " ?>";
break;
case TEXT_NODE:
s+=node.nodeValue;
break;
case CDATA_SECTION_NODE:
s+="<" +"![CDATA[" + node.nodeValue + "]" + "]>";
break;
case COMMENT_NODE:
s+="<!--" + node.nodeValue + "-->";
break;
case ENTITY_REFERENCE_NODE:
case DOCUMENT_FRAGMENT_NODE:
case DOCUMENT_TYPE_NODE:
case NOTATION_NODE:
case ENTITY_NODE:
throw new mod.Exception("Nodetype(%s) not supported.".format(node.nodeType));
break;
}
return s;
}
})

View File

@ -1,828 +0,0 @@
/*
Copyright (c) 2003-2004 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Provides an XML-RPC imlementation.
It is similar to python's xmlrpclib module.
*/
Module("xmlrpc","1.3.1", function(mod){
var xmlext = importModule("xml");
var urllib = importModule("urllib");
/**
Thrown if a server did not respond with response status 200 (OK).
*/
mod.InvalidServerResponse = Class("InvalidServerResponse", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param status The status returned by the server.
*/
publ.init= function(status){
supr(this).init("The server did not respond with a status 200 (OK) but with: " + status);
this.status = status;
}
///The status returned by the server.
publ.status;
})
/**
Thrown if an XML-RPC response is not well formed.
*/
mod.MalformedXmlRpc = Class("MalformedXmlRpc", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param msg The error message of the user.
@param xml The xml document's source.
@param trace=null The error causing this Exception
*/
publ.init= function(msg, xml, trace){
supr(this).init(msg,trace);
this.xml = xml;
}
///The xml source which was mal formed.
publ.xml;
})
/**
Thrown if the RPC response is a Fault.
*/
mod.Fault = Class("Fault", mod.Exception, function(publ, supr){
/**
Initializes the Exception.
@param faultCode The fault code returned by the rpc call.
@param faultString The fault string returned by the rpc call.
*/
publ.init= function(faultCode, faultString){
supr(this).init("XML-RPC Fault: " + faultCode + "\n\n" + faultString);
this.faultCode = faultCode;
this.faultString = faultString;
}
///The fault code returned from the rpc call.
publ.faultCode;
///The fault string returned from the rpc call.
publ.faultString;
})
/**
Marshalls an object to XML-RPC.(Converts an object into XML-RPC conforming xml.)
It just calls the toXmlRpc function of the objcect.
So, to customize serialization of objects one just needs to specify/override the toXmlRpc method
which should return an xml string conforming with XML-RPC spec.
@param obj The object to marshall
@return An xml representation of the object.
*/
mod.marshall = function(obj){
//vcb return obj.toXmlRpc()
}
/**
Unmarshalls an XML document to a JavaScript object. (Converts xml to JavaScript object.)
It parses the xml source and creates a JavaScript object.
@param xml The xml document source to unmarshall.
@return The JavaScript object created from the XML.
*/
mod.unmarshall = function(xml){
try {//try to parse xml ... this will throw an Exception if failed
var doc = xmlext.parseXML(xml);
}catch(e){
throw new mod.MalformedXmlRpc("The server's response could not be parsed.", xml, e);
}
var rslt = mod.unmarshallDoc(doc);
doc=null;
return rslt;
}
/**
Unmarshalls an XML document to a JavaScript object like unmarshall but expects a DOM document as parameter.
It parses the xml source and creates a JavaScript object.
@param doc The xml document(DOM compatible) to unmarshall.
@return The JavaScript object created from the XML.
*/
mod.unmarshallDoc = function(doc, xml){
try{
var node = doc.documentElement;
if(node==null){
/* just in case parse xml didn't throw an Exception but returned nothing usefull. */
throw new mod.MalformedXmlRpc("No documentElement found.", xml);
}
switch(node.tagName){
case "methodResponse":
return parseMethodResponse(node);
case "methodCall":
return parseMethodCall(node);
default://nothing usefull returned by parseXML.
throw new mod.MalformedXmlRpc("'methodCall' or 'methodResponse' element expected.\nFound: '" + node.tagName + "'", xml);
}
}catch(e){
if(e instanceof mod.Fault){//just rethrow the fault.
throw e;
}else {
throw new mod.MalformedXmlRpc("Unmarshalling of XML failed.", xml, e);
}
}
}
/**
Parses a methodeResponse element.
@param node The methodResponse element.
@return The return value of the XML-RPC.
*/
var parseMethodResponse=function(node){
try{
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "fault": //a fault is thrown as an Exception
throw parseFault(child);
case "params":
var params = parseParams(child);
if(params.length == 1){//params should only have one param
return params[0];
}else{
throw new mod.MalformedXmlRpc("'params' element inside 'methodResponse' must have exactly ONE 'param' child element.\nFound: " + params.length);
}
default:
throw new mod.MalformedXmlRpc("'fault' or 'params' element expected.\nFound: '" + child.tagName + "'");
}
}
}
//no child elements found
throw new mod.MalformedXmlRpc("No child elements found.");
}catch(e){
if(e instanceof mod.Fault){
throw e;
}else{
throw new mod.MalformedXmlRpc("'methodResponse' element could not be parsed.",null,e);
}
}
}
/**
Parses a methodCall element.
@param node The methodCall element.
@return Array [methodName,params].
*/
var parseMethodCall = function(node){
try{
var methodName = null;
var params = new Array();//default is no parameters
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "methodName":
methodName = new String(child.firstChild.nodeValue);
break;
case "params":
params = parseParams(child);
break;
default:
throw new mod.MalformedXmlRpc("'methodName' or 'params' element expected.\nFound: '" + child.tagName + "'");
}
}
}
if(methodName==null){
throw new mod.MalformedXmlRpc("'methodName' element expected.");
}else{
return new Array(methodName, params);
}
}catch(e){
throw new mod.MalformedXmlRpc("'methodCall' element could not be parsed.",null,e);
}
}
/**
Parses a params element.
@param node The params element.
@return Array of params values.
*/
var parseParams = function(node){
try{
var params=new Array();
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "param":
params.push(parseParam(child));
break;
default:
throw new mod.MalformedXmlRpc("'param' element expected.\nFound: '" + child.tagName + "'");
}
}
}
//the specs say a 'params' element can contain any number of 'param' elements. That includes 0 ?!
return params;
}catch(e){
throw new mod.MalformedXmlRpc("'params' element could not be parsed.",null,e);
}
}
/**
Parses a param element.
@param node The param node.
@return The value of the param.
*/
var parseParam = function(node){
try{
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "value":
return parseValue(child);
default:
throw new mod.MalformedXmlRpc("'value' element expected.\nFound: '" + child.tagName + "'");
}
}
}
//no child elements found, that's an error
throw new mod.MalformedXmlRpc("'value' element expected.But none found.");
}catch(e){
throw new mod.MalformedXmlRpc("'param' element could not be parsed.",null,e);
}
}
/**
Parses a value element.
@param node The value element.
@return The value.
*/
var parseValue = function(node){
try{
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "string":
var s=""
//Mozilla has many textnodes with a size of 4096 chars each instead of one large one.
//They all need to be concatenated.
for(var j=0;j<child.childNodes.length;j++){
s+=new String(child.childNodes.item(j).nodeValue);
}
return s;
case "int":
case "i4":
case "double":
//return (child.firstChild) ? new Number(child.firstChild.nodeValue) : 0;
var n = (child.firstChild) ? new Number(child.firstChild.nodeValue) : new Number(0);
var val = n.valueOf();
return val;
case "boolean":
return Boolean(isNaN(parseInt(child.firstChild.nodeValue)) ? (child.firstChild.nodeValue == "true") : parseInt(child.firstChild.nodeValue));
case "base64":
return parseBase64(child);
case "dateTime.iso8601":
return parseDateTime(child);
case "array":
return parseArray(child);
case "struct":
return parseStruct(child);
case "nil": //for python None todo: ??? is this valid XML-RPC
return null;
default:
throw new mod.MalformedXmlRpc("'string','int','i4','double','boolean','base64','dateTime.iso8601','array' or 'struct' element expected.\nFound: '" + child.tagName + "'");
}
}
}
if(node.firstChild){
var s=""
//Mozilla has many textnodes with a size of 4096 chars each instead of one large one.
//They all need to be concatenated.
for(var j=0;j<node.childNodes.length;j++){
s+=new String(node.childNodes.item(j).nodeValue);
}
return s;
}else{
return "";
}
}catch(e){
throw new mod.MalformedXmlRpc("'value' element could not be parsed.",null,e);
}
}
/**
Parses a base64 element.
@param node The base64 element.
@return A string with the decoded base64.
*/
var parseBase64=function(node){
try{
var s = node.firstChild.nodeValue;
return s.decode("base64");
}catch(e){
throw new mod.MalformedXmlRpc("'base64' element could not be parsed.",null,e);
}
}
/**
Parses a dateTime.iso8601 element.
@param node The dateTime.iso8601 element.
@return A JavaScript date.
*/
var parseDateTime=function(node){
try{
if(/^(\d{4})-?(\d{2})-?(\d{2})T(\d{2}):?(\d{2}):?(\d{2})/.test(node.firstChild.nodeValue)){
return new Date(Date.UTC(RegExp.$1, RegExp.$2-1, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6));
}else{ //todo error message
throw new mod.MalformedXmlRpc("Could not convert the given date.");
}
}catch(e){
throw new mod.MalformedXmlRpc("'dateTime.iso8601' element could not be parsed.",null,e);
}
}
/**
Parses an array element.
@param node The array element.
@return An Array.
*/
var parseArray=function(node){
try{
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "data":
return parseData(child);
default:
throw new mod.MalformedXmlRpc("'data' element expected.\nFound: '" + child.tagName + "'");
}
}
}
throw new mod.MalformedXmlRpc("'data' element expected. But not found.");
}catch(e){
throw new mod.MalformedXmlRpc("'array' element could not be parsed.",null,e);
}
}
/**
Parses a data element.
@param node The data element.
@return The value of a data element.
*/
var parseData=function(node){
try{
var rslt = new Array();
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "value":
rslt.push(parseValue(child));
break;
default:
throw new mod.MalformedXmlRpc("'value' element expected.\nFound: '" + child.tagName + "'");
}
}
}
return rslt;
}catch(e){
throw new mod.MalformedXmlRpc("'data' element could not be parsed.",null,e);
}
}
/**
Parses a struct element.
@param node The struct element.
@return A JavaScript object. Struct memembers are properties of the object.
*/
var parseStruct=function(node){
try{
var struct = new Object();
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "member":
var member = parseMember(child); //returns [name, value]
if(member[0] != ""){
struct[member[0]] = member[1];
}
break;
default:
throw new mod.MalformedXmlRpc("'data' element expected.\nFound: '" + child.tagName + "'");
}
}
}
return struct;
}catch(e){
throw new mod.MalformedXmlRpc("'struct' element could not be parsed.",null,e);
}
}
/**
Parses a member element.
@param node The member element.
@return Array containing [memberName, value].
*/
var parseMember=function(node){
try{
var name="";
var value=null;
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "value":
value = parseValue(child);
break;
case "name":
if(child.hasChildNodes()){
name = new String(child.firstChild.nodeValue);
}
break;
default:
throw new mod.MalformedXmlRpc("'value' or 'name' element expected.\nFound: '" + child.tagName + "'");
}
}
}
/*if(name == ""){
throw new mod.MalformedXmlRpc("Name for member not found/convertable.");
}else{
return new Array(name, value);
}*/
return [name, value];
}catch(e){
throw new mod.MalformedXmlRpc("'member' element could not be parsed.",null,e);
}
}
/**
Parses a fault element.
@param node The fault element.
@return A Fault Exception object.
*/
var parseFault = function(node){
try{
for(var i=0;i<node.childNodes.length;i++){
var child = node.childNodes.item(i);
if (child.nodeType == 1){
switch (child.tagName){
case "value":
var flt = parseValue(child);
return new mod.Fault(flt.faultCode, flt.faultString);
default:
throw new mod.MalformedXmlRpc("'value' element expected.\nFound: '" + child.tagName + "'");
}
}
}
throw new mod.MalformedXmlRpc("'value' element expected. But not found.");
}catch(e){
throw new mod.MalformedXmlRpc("'fault' element could not be parsed.",null,e);
}
}
/**
Class for creating XML-RPC methods.
Calling the created method will result in an XML-RPC call to the service.
The return value of this call will be the return value of the RPC call.
RPC-Faults will be raised as Exceptions.
Asynchronous operation:
If the last parameter passed to the method is an XMLRPCAsyncCallback object,
then the remote method will be called asynchronously.
The results and errors are passed to the callback.
*/
mod.XMLRPCMethod =Class("XMLRPCMethod", function(publ){
var postData = function(url, user, pass, data, callback){
if(callback == null){
var rslt = urllib.postURL(url, user, pass, data, [["Content-Type", "text/xml"]]);
return rslt;
}else{
urllib.postURL(url, user, pass, data, [["Content-Type", "text/xml"]], callback);
}
}
var handleResponse=function(resp){
var status=null;
try{//see if the server responded with a response code 200 OK.
status = resp.status;
}catch(e){
}
if(status == 200){
var respDoc=null;
try{
respDoc = resp.responseXML;
}catch(e){
}
var respTxt = "";
try{
respTxt=resp.responseText;
}catch(e){
}
if(respDoc == null){
if(respTxt == null || respTxt == ""){
throw new mod.MalformedXmlRpc("The server responded with an empty document.", "");
}else{
return mod.unmarshall(respTxt);
}
}else{ //use the respDoc directly so the xml does not have to be parsed.
return mod.unmarshallDoc(respDoc, respTxt);
}
}else{
throw new mod.InvalidServerResponse(status);
}
}
var getXML = function(methodName, args){
var data='<?xml version="1.0"?><methodCall><methodName>' + methodName + '</methodName>';
if (args.length>0){
data += "<params>";
for(var i=0;i<args.length;i++){
data += '<param><value>' + mod.marshall(args[i]) + '</value></param>';
}
data += '</params>';
}
data += '</methodCall>';
return data;
}
/**
Initializes the XML-RPC method.
@param url The URL of the service providing the method.
@param methodName The name of the method to invoke.
@param user=null The user name to use for HTTP authentication.
@param pass=null The password to use for HTTP authentication.
*/
publ.init = function(url, methodName, user, pass){
//this is pretty much a hack.
//we create a function which mimics this class and return it instead of really instanciating an object.
var fn=function(){
//sync or async call
if(typeof arguments[arguments.length-1] != "function"){
var data=getXML(fn.methodName,arguments);
var resp = postData(fn.url, fn.user, fn.password, data);
return handleResponse(resp);
}else{
var args=new Array();
for(var i=0;i<arguments.length;i++){
args.push(arguments[i]);
}
var cb = args.pop();
var data=getXML(fn.methodName, args);
postData(fn.url, fn.user, fn.password, data, function(resp){
var rslt = null;
var exc =null;
try{
rslt = handleResponse(resp);
}catch(e){
exc = e;
}
try{//call the callback for the async call.
cb(rslt,exc);
}catch(e){
}
args = null;
resp = null;
});
}
}
//make sure the function has the same property as an object created from this class.
fn.methodName = methodName;
fn.url = url;
fn.user = user;
fn.password=pass;
fn.toMulticall = this.toMulticall;
fn.toString = this.toString;
fn.setAuthentication=this.setAuthentication;
fn.constructor = this.constructor;
return fn;
}
/**
Returns the method representation for system.multicall.
@param All params will be passed to the remote method.
@return An object containing a member methodName and a member params(As required by system.multicall).
*/
publ.toMulticall = function(){
var multiCallable = new Object();
multiCallable.methodName = this.methodName;
var params = [];
for(var i=0;i<arguments.length;i++){
params[i] = arguments[i];
}
multiCallable.params = params;
return multiCallable;
}
/**
Sets username and password for HTTP Authentication.
@param user The user name.
@param pass The password.
*/
publ.setAuthentication = function(user, pass){
this.user = user;
this.password = pass;
}
///The name of the remote method.
publ.methodName;
///The url of the remote service containing the method.
publ.url;
///The user name used for HTTP authorization.
publ.user;
///The password used for HTTP authorization.
publ.password;
})
/**
Creates proxy objects which resemble the remote service.
Method calls of this proxy will result in calls to the service.
*/
mod.ServiceProxy=Class("ServiceProxy", function(publ){
/**
Initializes a new ServerProxy.
The arguments are interpreted as shown in the examples:
ServerProxy("url")
ServerProxy("url", ["methodName1",...])
ServerProxy("url", ["methodName1",...], "user", "pass")
ServerProxy("url", "user", "pass")
@param url The url of the service.
@param methodNames=[] Array of names of methods that can be called on the server.
If no methods are given then introspection is used to get the methodnames from the server.
@param user=null The user name to use for HTTP authentication.
@param pass=null The password to use for HTTP authentication.
*/
publ.init = function(url, methodNames, user, pass){
if(methodNames instanceof Array){
if(methodNames.length > 0){
var tryIntrospection=false;
}else{
var tryIntrospection=true;
}
}else{
pass=user;
user=methodNames;
methodNames=[];
var tryIntrospection=true;
}
this._url = url;
this._user = user;
this._password = pass;
this._addMethodNames(methodNames);
if(tryIntrospection){
try{//it's ok if it fails.
this._introspect();
}catch(e){
}
}
}
/**
Adds new XMLRPCMethods to the proxy server which can then be invoked.
@param methodNames Array of names of methods that can be called on the server.
*/
publ._addMethodNames = function(methodNames){
for(var i=0;i<methodNames.length;i++){
var obj = this;
//setup obj.childobj...method
var names = methodNames[i].split(".");
for(var n=0;n<names.length-1;n++){
var name = names[n];
if(obj[name]){
obj = obj[name];
}else{
obj[name] = new Object();
obj = obj[name];
}
}
var name = names[names.length-1];
if(obj[name]){
}else{
var mth = new mod.XMLRPCMethod(this._url, methodNames[i], this._user, this._password);
obj[name] = mth;
this._methods.push(mth);
}
}
}
/**
Sets username and password for HTTP Authentication for all methods of this service.
@param user The user name.
@param pass The password.
*/
publ._setAuthentication = function(user, pass){
this._user = user;
this._password = pass;
for(var i=0;i<this._methods.length;i++){
this._methods[i].setAuthentication(user, pass);
}
}
/**
Initiate XML-RPC introspection to retrieve methodnames from the server
and add them to the server proxy.
*/
publ._introspect = function(){
this._addMethodNames(["system.listMethods","system.methodHelp", "system.methodSignature"]);
var m = this.system.listMethods();
this._addMethodNames(m);
}
///The url of the service to resemble.
publ._url;
///The user used for HTTP authentication.
publ._user;
///The password used for HTTP authentication.
publ._password;
///All methods.
publ._methods=new Array();
})
///@deprecated Use ServiceProxy instead.
mod.ServerProxy= mod.ServiceProxy;
/**
Returns the XML-RPC representation of an object.
A struct is used. Each property of an object is a member of that struct.
@return A string containing the object's representation in XML.
*/
/* Object.prototype.toXmlRpc = function(){
var s = "<struct>";
for(var attr in this){
if(typeof this[attr] != "function"){
s += "<member><name>" + attr + "</name><value>" + this[attr].toXmlRpc() + "</value></member>";
}
}
s += "</struct>";
return s
}
*/
/**
XML-RPC representation of a string.
All '&' and '<' are replaced with the '&amp;' and '&lt'.
@return A string containing the String's representation in XML.
*/
/* String.prototype.toXmlRpc = function(){
return "<string>" + this.replace(/&/g, "&amp;").replace(/</g, "&lt;") + "</string>";
}*/
/**
XML-RPC representation of a number.
@return A string containing the Number's representation in XML.
*/
/* Number.prototype.toXmlRpc = function(){
if(this == parseInt(this)){
return "<int>" + this + "</int>";
}else if(this == parseFloat(this)){
return "<double>" + this + "</double>";
}else{
return false.toXmlRpc();
}
}
*/
/**
XML-RPC representation of a boolean.
@return A string containing the Boolean's representation in XML.
*/
/* Boolean.prototype.toXmlRpc = function(){
if(this == true) {
return "<boolean>1</boolean>";
}else{
return "<boolean>0</boolean>";
}
}
*/
/**
XML-RPC representation of a date(iso 8601).
@return A string containing the Date's representation in XML.
*/
/* Date.prototype.toXmlRpc = function(){
var padd=function(s, p){
s=p+s
return s.substring(s.length - p.length)
}
var y = padd(this.getUTCFullYear(), "0000");
var m = padd(this.getUTCMonth() + 1, "00");
var d = padd(this.getUTCDate(), "00");
var h = padd(this.getUTCHours(), "00");
var min = padd(this.getUTCMinutes(), "00");
var s = padd(this.getUTCSeconds(), "00");
var isodate = y + m + d + "T" + h + ":" + min + ":" + s
return "<dateTime.iso8601>" + isodate + "</dateTime.iso8601>";
}
*/
/**
XML-RPC representation of an array.
Each entry in the array is a value in the XML-RPC.
@return A string containing the Array's representation in XML.
*/
/* Array.prototype.toXmlRpc = function(){
var retstr = "<array><data>";
for(var i=0;i<this.length;i++){
retstr += "<value>" + this[i].toXmlRpc() + "</value>";
}
return retstr + "</data></array>";
}
*/
})

View File

@ -1,151 +0,0 @@
/*
Copyright (c) 2003 Jan-Klaas Kollhof
This file is part of the JavaScript o lait library(jsolait).
jsolait is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if(Function.prototype.apply == null){
Function.prototype.apply = function(thisObj, args){
var a =[];
for(var i=0;i<args.length;i++){
a[i] = "args[" + i + "]";
}
thisObj.__apply__ = this;
a="thisObj.__apply__(" + a.join(",") +")";
var r = eval(a);
delete thisObj.__apply__;
return r;
}
}
if(Function.prototype.call==null){
Function.prototype.call=function(thisObj){
var args=[]; //copy all arguments but the first
for(var i=1;i<arguments.length;i++){
args[i-1] = arguments[i];
}
return this.apply(thisObj, args);
}
}
///----------------------------------Array functions----------------------------------
if(Array.prototype.splice == null){
Array.prototype.splice = function(index, howMany){
var a = this.slice(0, index);
var e = this.slice(index + howMany, this.length);
var r = this.slice(index, index+howMany);
this.length=0;
for(var i=0;i<a.length;i++){
this[this.length] = a[i];
}
for(var i=2;i<arguments.length;i++){
this[this.length] = arguments[i];
}
for(var i=0;i<e.length;i++){
this[this.length] = e[i];
}
return r;
}
}
if(Array.prototype.pop == null){
Array.prototype.pop = function(){
var e=this[this.length-1];
this.length -= 1;
return e;
}
}
if(Array.prototype.push == null){
Array.prototype.push = function(){
for(var i=0;i<arguments.length;i++){
this[this.length] = arguments[i];
}
return this.length;
}
}
if(Array.prototype.shift == null){
Array.prototype.shift = function(){
var e = this[0];
for(var i=1;i<this.length;i++){
this[i-1] = this[i];
}
this.length -= 1;
return e;
}
}
if(Array.prototype.unshift == null){
Array.prototype.unshift = function(){
var a=[]
for(var i=0;i<arguments.length;i++){
a[i] = arguments[i];
}
for(var i=0;i<this.length;i++){
a[a.length] = this[i];
}
this.length=a.length;
for(var i=0;i<a.length;i++){
this[i] = a[i];
}
return this.length;
}
}
/**
Number functions.
Contributed by Wolfgang Dumhs.
*/
if(Number.prototype.toFixed == null){
Number.prototype.toFixed = function(d){
var n = this;
d = d || 0;
var f = Math.pow(10, d);
n = Math.round (f * n) / f;
n = (n >= 0) ? n+Math.pow(10, -(d+1)) : n-Math.pow(10, -(d+1));
n += '';
return d == 0 ? n.substring(0, n.indexOf('.')) : n.substring(0, n.indexOf('.') + d + 1);
}
}
if(Number.prototype.toExponential == null){
Number.prototype.toExponential = function(d){
var n = this;
var e = 0;
if (n != 0){
e = Math.floor(Math.log(Math.abs(n)) / Math.LN10);
}
n /= Math.pow(10, e);
if (isFinite(d)){
if (Math.abs(n) + 5*Math.pow(10, -(d+1)) >= 10.0){
n /= 10;
e += 1;
}
n = n.toFixed(d);
}
n += "e";
if (e >= 0){
n += "+";
}
n += e;
return n;
}
}

View File

@ -1,157 +0,0 @@
/******************************************************************************
* Sort tables by column *
* Copyright (C) 2002 by Mike Hall *
* Please see http://www.brainjar.com for terms of use. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*
******************************************************************************/
/* function sortTable
* @author Mike Hall
* @abstract Sorts an table by selection sort
* @param int col Number (0-n)of the column which will be used for the sorting
* @param string section name of the id of the sorted section
*/
function sortTable(col,section) {
// Get the table section to sort.
var tblEl = document.getElementById(section);
// Set up an array of reverse sort flags, if not done already.
if (tblEl.reverseSort == null)
tblEl.reverseSort = new Array();
// If this column was the last one sorted, reverse its sort direction.
if (col == tblEl.lastColumn)
tblEl.reverseSort[col] = !tblEl.reverseSort[col];
// Remember this column as the last one sorted.
tblEl.lastColumn = col;
// Set the table display style to "none" - necessary for Netscape 6
// browsers.
var oldDsply = tblEl.style.display;
tblEl.style.display = "none";
// Sort the rows based on the content of the specified column using a
// selection sort.
var tmpEl;
var i, j;
var minVal, minIdx;
var testVal;
var cmp;
for (i = 0; i < tblEl.rows.length - 1; i++) {
// Assume the current row has the minimum value.
minIdx = i;
minVal = TSgetTextValue(tblEl.rows[i].cells[col]);
// Search the rows that follow the current one for a smaller value.
for (j = i + 1; j < tblEl.rows.length; j++) {
testVal = TSgetTextValue(tblEl.rows[j].cells[col]);
cmp = TScompareValues(minVal, testVal);
// Reverse order?
if (tblEl.reverseSort[col])
cmp = -cmp;
// If this row has a smaller value than the current minimum, remember its
// position and update the current minimum value.
if (cmp > 0) {
minIdx = j;
minVal = testVal;
}
}
// By now, we have the row with the smallest value. Remove it from the
// table and insert it before the current row.
if (minIdx > i) {
tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
tblEl.insertBefore(tmpEl, tblEl.rows[i]);
}
}
// Restore the table's display style.
tblEl.style.display = oldDsply;
return false;
}
//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------
// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
if (document.ELEMENT_NODE == null) {
document.ELEMENT_NODE = 1;
document.TEXT_NODE = 3;
}
function TSgetTextValue(el) {
var i;
var s;
// Find and concatenate the values of all text nodes contained within the
// element.
s = "";
for (i = 0; i < el.childNodes.length; i++)
if (el.childNodes[i].nodeType == document.TEXT_NODE)
s += el.childNodes[i].nodeValue;
else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
el.childNodes[i].tagName == "BR")
s += " ";
else
// Use recursion to get text within sub-elements.
s += TSgetTextValue(el.childNodes[i]);
return TSnormalizeString(s);
}
function TScompareValues(v1, v2) {
var f1, f2;
// If the values are numeric, convert them to floats.
f1 = parseFloat(v1);
f2 = parseFloat(v2);
if (!isNaN(f1) && !isNaN(f2)) {
v1 = f1;
v2 = f2;
}
// Compare the two values.
if (v1 == v2)
return 0;
if (v1 > v2)
return 1
return -1;
}
// Regular expressions for normalizing white space.
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");
function TSnormalizeString(s) {
s = s.replace(whtSpMult, " "); // Collapse any multiple whites space.
s = s.replace(whtSpEnds, ""); // Remove leading or trailing white space.
return s;
}

Some files were not shown because too many files have changed in this diff Show More