Initial commit: Kimai TMS

Kimai time management system (PHP 5.6 / MySQL) with custom extensions:
- Budget tracking (ki_budget)
- Change request form (ki_changerequest)
- Invoice generation (ki_invoice)
- Expense tracking (ki_expenses)
- Flexi time (ki_flexitime)
- Export, admin panel, timesheets, tasks, summary

Database: ~900K time entries, 2,000+ users, 439 projects.
Config: includes/autoconf.php — localhost/kimai/kimai
This commit is contained in:
TMS
2026-06-18 21:20:26 +00:00
commit eb299c9131
1099 changed files with 359817 additions and 0 deletions

View File

@@ -0,0 +1,226 @@
<?php
/*
File: TabManager.inc.php
Contains a class that can be used to invoke DOM calls on the browser which
will create or update an HTML table.
Title: clsTabManager class
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
if ( false == class_exists( 'xajaxPlugin' ) || false == class_exists( 'xajaxPluginManager' ) )
{
$sBaseFolder = dirname( dirname( dirname( __FILE__ ) ) );
$sXajaxCore = $sBaseFolder.'/xajax_core';
if ( false == class_exists( 'xajaxPlugin' ) )
require $sXajaxCore.'/xajaxPlugin.inc.php';
if ( false == class_exists( 'xajaxPluginManager' ) )
require $sXajaxCore.'/xajaxPluginManager.inc.php';
}
/*
Class: clsTabManager
*/
class clsTabManager
extends xajaxResponsePlugin
{
/*
String: sDefer
Used to store the state of the scriptDeferral configuration setting. When
script deferral is desired, this member contains 'defer' which will request
that the browser defer loading of the javascript until the rest of the page
has been loaded.
*/
var $sDefer;
/*
String: sJavascriptURI
Used to store the base URI for where the javascript files are located. This
enables the plugin to generate a script reference to it's javascript file
if the javascript code is NOT inlined.
*/
var $sJavascriptURI;
/*
Boolean: bInlineScript
Used to store the value of the inlineScript configuration option. When true,
the plugin will return it's javascript code as part of the javascript header
for the page, else, it will generate a script tag referencing the file by
using the <clsTabManager->sJavascriptURI>.
*/
var $bInlineScript;
/*
Function: clsTabManager
Constructs and initializes an instance of the table updater class.
*/
function clsTabManager()
{
$this->sDefer = '';
$this->sJavascriptURI = '';
$this->bInlineScript = false;
}
/*
Function: configure
Receives configuration settings set by <xajax> or user script calls to
<xajax->configure>.
sName - (string): The name of the configuration option being set.
mValue - (mixed): The value being associated with the configuration option.
*/
function configure( $sName, $mValue )
{
if ( 'scriptDeferral' == $sName )
{
if ( true === $mValue || false === $mValue )
{
if ( $mValue )
$this->sDefer = 'defer ';
else
$this->sDefer = '';
}
}
else if ( 'javascript URI' == $sName )
{
$this->sJavascriptURI = $mValue;
}else if ( 'inlineScript' == $sName )
{
if ( true === $mValue || false === $mValue )
$this->bInlineScript = $mValue;
}
}
/*
Function: generateClientScript
Called by the <xajaxPluginManager> during the script generation phase. This
will either inline the script or insert a script tag which references the
<TabManager.js> file based on the value of the <clsTabManager->bInlineScript>
configuration option.
*/
function generateClientScript()
{
if ( $this->bInlineScript )
{
echo "\n<script type='text/javascript' ".$this->sDefer."charset='UTF-8'>\n";
echo "/* <![CDATA[ */\n";
include( dirname( __FILE__ ).'/TabManager.js' );
echo "/* ]]> */\n";
echo "</script>\n";
}else
{
echo "\n<script type='text/javascript' src='".$this->sJavascriptURI."xajax_plugins/response/TabManager/TabManager.js' ".$this->sDefer."charset='UTF-8'></script>\n";
}
}
function getName()
{
return get_class( $this );
}
function create( $id, $config )
{
$command = array
(
'cmd' => 'tm_create',
'id' => $id
);
$this->addCommand( $command, $config );
}
function addPanel( $id, $config )
{
$command = array
(
'cmd' => 'tm_at',
'id' => $id
);
$this->addCommand( $command, $config );
}
function on( $eventName, $target, $panel, $event )
{
$command = array
(
'cmd' => 'tm_on',
'id' => $target
);
$this->addCommand( $command, array
(
"n" => $eventName,
"p" => $panel,
"e" => $event,
"key" => crc32($event)
));
}
function close( $id, $panel )
{
$command = array
(
'cmd' => 'tm_cl',
'id' => $id
);
$this->addCommand( $command, $panel );
}
function showPanel( $id, $panel )
{
$command = array
(
'cmd' => 'tm_sp',
'id' => $id
);
$this->addCommand( $command, $panel );
}
function setTitle( $id, $panel, $title )
{
$command = array
(
'cmd' => 'tm_st',
'id' => $id
);
$this->addCommand( $command, array
(
"panel" => $panel,
"title" => $title
));
}
function destroy( $id )
{
$command = array
(
'cmd' => 'tm_de',
'id' => $id
);
$this->addCommand( $command, array ());
}
}
$objPluginManager = &xajaxPluginManager::getInstance();
$objPluginManager->registerPlugin( new clsTabManager() );
?>

View File

@@ -0,0 +1,73 @@
installtabManager=function(){var xjxReady=false;try{if(xajax)
xjxReady=true;}
catch(e){}
if(false==xjxReady){setTimeout('installtabManager();',1000);return;}
try{if(undefined==xajax.ext.tabManager)
xajax.ext.tabManager={};xajax.ext.tabManager.instances={};}
catch(e){xajax.ext={};xajax.ext.tabManager={};xajax.ext.tabManager.instances={};}
xajax.ext.tabPanel=function(config){this.config=config;this._parent=config._parent;this.id=config.id;var element=this;this.events={};this.tabWidth=0;if('undefined'!=typeof config.closeable){this.closeable=config.closeable;}
else{this.closeable=true;}
var parPanel=this._parent.tabPanel;this.tab_item=document.createElement('div');this.tab_item.id="tabPanel_"+this.id;this.tab_item.className="tabPanelItem";this.tab_item.onclick=function(){element._parent.show(element.id);return false;};var tab_item_left=document.createElement('div');tab_item_left.className='tabLeft';tab_item_left.innerHTML='&nbsp;';this.tab_item.appendChild(tab_item_left);var tab_title=document.createElement('div');tab_title.id="tabPanelTitel_"+this.id;tab_title.innerHTML=config.title;tab_title.className='title';this.tab_title=tab_title;this.tab_item.appendChild(tab_title);if(this.closeable){var foo=this;var tab_close=document.createElement('div');tab_close.id="tabPanelClose_"+this.id;tab_close.innerHTML="&nbsp;";tab_close.className='close';tab_close.onclick=function(){foo.fire("close");element._parent.closePanel(element.id);return false;}
this.tab_item.appendChild(tab_close);}
var tab_item_right=document.createElement('div');tab_item_right.className='tabRight';tab_item_right.innerHTML='&nbsp;';this.tab_item.appendChild(tab_item_right);var tab_clear=document.createElement('div');tab_clear.style.clear='both';this.tab_item.appendChild(tab_clear);var tmp_width=$(parPanel).outerWidth();parPanel.appendChild(this.tab_item);var parContent=this._parent.tabContent;this.tab_content=document.createElement('div');this.tab_content.id="tabContent_"+this.id;this.tab_content.className="tabPanelContent";this.tab_content.innerHTML=config.content;this.tab_content.style.display='none';parContent.appendChild(this.tab_content);this.tabWidth=$(this.tab_item).outerWidth()+2;this.getWidth=function(){this.tabWidth=$(this.tab_item).outerWidth()+2;return this.tabWidth;};this.show=function(){this.tab_item.className='tabPanelItemActive';this.tab_content.style.display='block';this.fire("show");};this.hide=function(){this.tab_item.className='tabPanelItem';this.tab_content.style.display='none';this.fire("hide");};this.setTitle=function(title){this.tab_title.innerHTML=title;};this.setContent=function(content){this.tab_content.innerHTML=content;};this.destroy=function(){this.fire("destroy");parPanel.removeChild(this.tab_item);parContent.removeChild(this.tab_content);};this.fire=function(EventName){if('object'==typeof this.events[EventName]){for(a in this.events[EventName])
this.events[EventName][a]();}
}
this.on=function(EventName,EventFunction,EventFunctionId){if('object'!=typeof this.events[EventName])
this.events[EventName]=new Object();if('undefined'==typeof this.events[EventName][EventFunctionId])
this.events[EventName][EventFunctionId]=EventFunction;}
};xajax.ext.tabManager.tabBar=function(config){this.config=config;this.tabBar=xajax.$(config.tabPanel);this.tabContent=xajax.$(config.tabContent);this.tabs={};this.activeTab=null;this.lastActiveTab=null;this.interval=null;this.maxWidth=$(this.tabBar).innerWidth();this.tabWidth=0;this.tabHeight=$(this.tabBar).innerHeight();var leftHandle=document.createElement('div');leftHandle.className="leftHandle";var rightHandle=document.createElement('div');rightHandle.className="rightHandle";var foo=this;leftHandle.onmouseover=function(){foo.scroll(4);}
rightHandle.onmouseover=function(){foo.scroll(-4);}
leftHandle.onmouseout=function(){foo.scrollStop();}
rightHandle.onmouseout=function(){foo.scrollStop();}
leftHandle.style.display='none';rightHandle.style.display='none';this.leftHandle=leftHandle;this.rightHandle=rightHandle;var tabContainer=document.createElement('div');tabContainer.id="tabManager_Container_"+config.tabPanel;tabContainer.style.position="absolute";tabContainer.style.top="0px";tabContainer.style.left="0px";tabContainer.style.right="0px";tabContainer.style.height=this.tabHeight+"px";tabContainer.style.overflow="hidden";var tabPanel=document.createElement('div');tabPanel.style.position="absolute";tabPanel.style.height=this.tabHeight+"px";this.tabBar.appendChild(leftHandle);this.tabBar.appendChild(tabContainer);this.tabBar.appendChild(rightHandle);tabContainer.appendChild(tabPanel);this.tabPanel=tabPanel;this.tabContainer=tabContainer;if('undefined'!=typeof config.cssClass){this.tabPanel.className=this.tabBar.className+" "+config.cssClass;}
this.addPanel=function(config){if('undefined'!=typeof this.tabs[config.id]){if(config.hide)
return;this.tabs[config.id].fire("destroy");this.show(config.id);return;};config._parent=this;this.tabs[config.id]=new xajax.ext.tabPanel(config);if(true!=config.hide)
this.show(config.id);this.tabWidth+=this.tabs[config.id].getWidth();if(this.tabWidth > this.maxWidth){this.leftHandle.style.display='block';this.rightHandle.style.display='block';var lspace=$(this.leftHandle).outerWidth()+1;var rspace=$(this.rightHandle).outerWidth()+1;this.tabContainer.style.left=lspace+"px";this.tabContainer.style.right=rspace+"px";}
};this.show=function(id){if('undefined'==typeof this.tabs[id])
return;if(null!=this.activeTab)
this.activeTab.hide();this.tabs[id].show();this.lastActiveTab=this.activeTab;this.activeTab=this.tabs[id];var pos=$('#tabPanel_'+id).position();var elm_left=pos.left;var elm_max=pos.left+parseInt(this.tabs[id].tabWidth);var container_width=$(this.tabContainer).innerWidth();var panel_pos=$(this.tabPanel).position();var scroll_left=panel_pos.left;var visible_left=0-scroll_left;var visible_right=visible_left+container_width;if(elm_left < visible_left){$(this.tabPanel).animate({left:(0-elm_left)+"px"
});}
else if(elm_max > visible_right){$(this.tabPanel).animate({left:(container_width-elm_max-22)+"px"
});}
};this.setContent=function(id,content){if('undefined'!=typeof this.tabs[id])
return;this.tabs[id].setContent(content);};this.setTitle=function(id,title){if('undefined'==typeof this.tabs[id])
return;this.tabs[id].setTitle(title);};this.updateInnerWidth=function(){var tmpwidth=0;for(a in this.tabs){tmpwidth+=this.tabs[a].getWidth();}
this.tabWidth=tmpwidth+22;};this.closePanel=function(id){if('undefined'==typeof this.tabs[id])
return;if(null!=this.lastActiveTab){if(this.activeTab.id==id)
this.show(this.lastActiveTab.id);}
this.tabs[id].destroy();delete(this.tabs[id]);this.updateInnerWidth();if(this.tabWidth < this.maxWidth){this.leftHandle.style.display='none';this.rightHandle.style.display='none';this.tabContainer.style.left="0px";this.tabContainer.style.right="0px";this.tabPanel.style.left="0px";}
};this.on=function(EventName,id,EventFunction,EventFunctionId){this.tabs[id].on(EventName,EventFunction,EventFunctionId);}
this.scroll=function(value){if(null!=this.interval)
return;var tab=this;var i=value;this.interval=setInterval(function(){var lspace=$(tab.leftHandle).innerWidth()+1;var rspace=$(tab.rightHandle).innerWidth()+1;var sLeft=tab.tabPanel.style.left;var iLeft=sLeft.replace("px","");if(""==iLeft)
iLeft=0;iLeft=parseInt(iLeft);iLeft+=i;var iMin=tab.maxWidth-tab.tabWidth-rspace-lspace;if((iLeft > 0)||((iLeft < iMin)&&(i < 0))){tab.scrollStop();return;}
tab.tabPanel.style.left=iLeft+"px";},25);}
this.scrollStop=function(){if(null==this.interval)
return;clearInterval(this.interval);this.interval=null;}
this.destroy=function(){for(a in this.tabs){this.tabs[a].destroy();delete(this.tabs[a]);}
};};xajax.ext.tabManager.create=function(id,config){if("undefined"==typeof xajax.ext.tabManager.instances[id]){try{xajax.ext.tabManager.instances[id]=new xajax.ext.tabManager.tabBar(config);}
catch(ex){}
}
}
xajax.ext.tabManager.addPanel=function(id,config){try{xajax.ext.tabManager.instances[id].addPanel(config);}
catch(ex){}
}
xajax.ext.tabManager.showPanel=function(id,sPanel){try{xajax.ext.tabManager.instances[id].show(sPanel);}
catch(ex){}
}
xajax.ext.tabManager.setTitle=function(id,sPanel,title){try{xajax.ext.tabManager.instances[id].setTitle(sPanel,title);}
catch(ex){}
}
xajax.ext.tabManager.on=function(id,sEventName,sTarget,sEventFunc,sEventId){xajax.ext.tabManager.instances[id].on(sEventName,sTarget,sEventFunc,sEventId);}
xajax.ext.tabManager.closePanel=function(id,sPanel){xajax.ext.tabManager.instances[id].closePanel(sPanel);}
xajax.ext.tabManager.destroy=function(id){xajax.ext.tabManager.instances[id].destroy();delete(xajax.ext.tabManager.instances[id]);}
xajax.command.handler.register('tm_create',function(args){args.cmdFullName='ext.tabManager.create';xajax.ext.tabManager.create(args.id,args.data);return true;});xajax.command.handler.register('tm_at',function(args){args.cmdFullName='ext.tabManager.addPanel';xajax.ext.tabManager.addPanel(args.id,args.data);return true;});xajax.command.handler.register('tm_on',function(args){try{args.cmdFullName='ext.tabManager.on';eval("var sEvent = "+args.data.e+";");xajax.ext.tabManager.on(args.id,args.data.n,args.data.p,sEvent,args.data.key);}
catch(ex){}
return true;});xajax.command.handler.register('tm_cl',function(args){try{args.cmdFullName='ext.tabManager.closePanel';xajax.ext.tabManager.closePanel(args.id,args.data);}
catch(ex){debugObj(ex);}
return true;});xajax.command.handler.register('tm_sp',function(args){args.cmdFullName='ext.tabManager.showPanel';xajax.ext.tabManager.showPanel(args.id,args.data);return true;});xajax.command.handler.register('tm_st',function(args){try{args.cmdFullName='ext.tabManager.setTitle';xajax.ext.tabManager.setTitle(args.id,args.data.panel,args.data.title);}
catch(ex){}
return true;});xajax.command.handler.register('tm_de',function(args){try{args.cmdFullName='ext.tabManager.destroy';xajax.ext.tabManager.destroy(args.id);}
catch(ex){debugObj(ex);}
return true;});}
installtabManager();

View File

@@ -0,0 +1,614 @@
// if xajax has not yet been initialized, wait a second and try again
// once xajax has been initialized, install the table command handlers.
installtabManager = function()
{
var xjxReady = false;
try
{
if (xajax)
xjxReady = true;
}
catch (e)
{
}
if (false == xjxReady)
{
setTimeout('installtabManager();', 1000);
return;
}
try
{
if (undefined == xajax.ext.tabManager)
xajax.ext.tabManager = {
};
xajax.ext.tabManager.instances = {
};
}
catch (e)
{
xajax.ext = {
};
xajax.ext.tabManager = {
};
xajax.ext.tabManager.instances = {
};
}
xajax.ext.tabPanel = function(config)
{
this.config = config;
this._parent = config._parent;
this.id = config.id;
var element = this;
this.events = {
};
this.tabWidth = 0;
if ('undefined' != typeof config.closeable)
{
this.closeable = config.closeable;
}
else
{
this.closeable = true;
}
var parPanel = this._parent.tabPanel;
this.tab_item = document.createElement('div');
this.tab_item.id = "tabPanel_" + this.id;
this.tab_item.className = "tabPanelItem";
this.tab_item.onclick = function()
{
element._parent.show(element.id);
return false;
};
var tab_item_left = document.createElement('div');
tab_item_left.className = 'tabLeft';
tab_item_left.innerHTML = '&nbsp;';
this.tab_item.appendChild(tab_item_left);
var tab_title = document.createElement('div');
tab_title.id = "tabPanelTitel_" + this.id;
tab_title.innerHTML = config.title;
tab_title.className = 'title';
this.tab_title = tab_title;
this.tab_item.appendChild(tab_title);
if (this.closeable)
{
var foo = this;
var tab_close = document.createElement('div');
tab_close.id = "tabPanelClose_" + this.id;
tab_close.innerHTML = "&nbsp;";
tab_close.className = 'close';
tab_close.onclick = function()
{
foo.fire("close");
element._parent.closePanel(element.id);
return false;
}
this.tab_item.appendChild(tab_close);
}
var tab_item_right = document.createElement('div');
tab_item_right.className = 'tabRight';
tab_item_right.innerHTML = '&nbsp;';
this.tab_item.appendChild(tab_item_right);
var tab_clear = document.createElement('div');
tab_clear.style.clear = 'both';
this.tab_item.appendChild(tab_clear);
var tmp_width = $(parPanel).outerWidth();
//parPanel.style.width=(tmp_width+300)+"px";
parPanel.appendChild(this.tab_item);
var parContent = this._parent.tabContent;
this.tab_content = document.createElement('div');
this.tab_content.id = "tabContent_" + this.id;
this.tab_content.className = "tabPanelContent";
this.tab_content.innerHTML = config.content;
this.tab_content.style.display = 'none';
parContent.appendChild(this.tab_content);
//this.getWidth();
this.tabWidth = $(this.tab_item).outerWidth() + 2;
this.getWidth = function()
{
this.tabWidth = $(this.tab_item).outerWidth() + 2;
return this.tabWidth;
};
this.show = function()
{
this.tab_item.className = 'tabPanelItemActive';
this.tab_content.style.display = 'block';
this.fire("show");
};
this.hide = function()
{
this.tab_item.className = 'tabPanelItem';
this.tab_content.style.display = 'none';
this.fire("hide");
};
this.setTitle = function(title)
{
this.tab_title.innerHTML = title;
};
this.setContent = function(content)
{
this.tab_content.innerHTML = content;
};
this.destroy = function()
{
this.fire("destroy");
parPanel.removeChild(this.tab_item);
parContent.removeChild(this.tab_content);
};
this.fire = function(EventName)
{
if ('object' == typeof this.events[EventName])
{
for (a in this.events[EventName])
this.events[EventName][a]();
}
}
this.on = function(EventName, EventFunction, EventFunctionId)
{
if ('object' != typeof this.events[EventName])
this.events[EventName] = new Object();
if ('undefined' == typeof this.events[EventName][EventFunctionId])
this.events[EventName][EventFunctionId] = EventFunction;
}
};
/* ---------------------------------------------------------------------------------------------------------------------------- */
xajax.ext.tabManager.tabBar = function(config)
{
this.config = config;
this.tabBar = xajax.$(config.tabPanel);
this.tabContent = xajax.$(config.tabContent);
this.tabs = {
};
this.activeTab = null;
this.lastActiveTab = null;
this.interval = null;
this.maxWidth = $(this.tabBar).innerWidth();
this.tabWidth = 0;
this.tabHeight = $(this.tabBar).innerHeight();
var leftHandle = document.createElement('div');
leftHandle.className = "leftHandle";
var rightHandle = document.createElement('div');
rightHandle.className = "rightHandle";
var foo = this;
leftHandle.onmouseover = function()
{
foo.scroll(4);
}
rightHandle.onmouseover = function()
{
foo.scroll(-4);
}
leftHandle.onmouseout = function()
{
foo.scrollStop();
}
rightHandle.onmouseout = function()
{
foo.scrollStop();
}
leftHandle.style.display = 'none';
rightHandle.style.display = 'none';
this.leftHandle = leftHandle;
this.rightHandle = rightHandle;
var tabContainer = document.createElement('div');
tabContainer.id = "tabManager_Container_" + config.tabPanel;
tabContainer.style.position = "absolute";
tabContainer.style.top = "0px";
tabContainer.style.left = "0px";
tabContainer.style.right = "0px";
// possible IE abs pos fix
//tabContainer.style.width = this.maxWidth + "px";
tabContainer.style.height = this.tabHeight + "px";
tabContainer.style.overflow = "hidden";
var tabPanel = document.createElement('div');
tabPanel.style.position = "absolute";
tabPanel.style.height = this.tabHeight + "px";
this.tabBar.appendChild(leftHandle);
this.tabBar.appendChild(tabContainer);
this.tabBar.appendChild(rightHandle);
tabContainer.appendChild(tabPanel);
this.tabPanel = tabPanel;
this.tabContainer = tabContainer;
if ('undefined' != typeof config.cssClass)
{
this.tabPanel.className = this.tabBar.className + " " + config.cssClass;
}
this.addPanel = function(config)
{
if ('undefined' != typeof this.tabs[config.id])
{
if (config.hide)
return;
this.tabs[config.id].fire("destroy");
this.show(config.id);
return;
};
config._parent = this;
this.tabs[config.id] = new xajax.ext.tabPanel(config);
if (true != config.hide)
this.show(config.id);
this.tabWidth += this.tabs[config.id].getWidth();
// possible IE abs pos fix
//this.tabPanel.style.width=this.tabWidth+"px";
if (this.tabWidth > this.maxWidth)
{
this.leftHandle.style.display = 'block';
this.rightHandle.style.display = 'block';
var lspace = $(this.leftHandle).outerWidth() + 1;
var rspace = $(this.rightHandle).outerWidth() + 1;
this.tabContainer.style.left = lspace + "px";
this.tabContainer.style.right = rspace + "px";
}
};
this.show = function(id)
{
if ('undefined' == typeof this.tabs[id])
return;
if (null != this.activeTab)
this.activeTab.hide();
this.tabs[id].show();
this.lastActiveTab = this.activeTab;
this.activeTab = this.tabs[id];
var pos = $('#tabPanel_' + id).position();
var elm_left = pos.left;
var elm_max = pos.left + parseInt(this.tabs[id].tabWidth);
var container_width = $(this.tabContainer).innerWidth();
var panel_pos = $(this.tabPanel).position();
var scroll_left = panel_pos.left;
var visible_left = 0 - scroll_left;
var visible_right = visible_left + container_width;
if (elm_left < visible_left)
{
$(this.tabPanel).animate(
{
left: (0 - elm_left) + "px"
});
}
else if (elm_max > visible_right)
{
$(this.tabPanel).animate(
{
left: (container_width - elm_max - 22) + "px"
});
}
};
this.setContent = function(id, content)
{
if ('undefined' != typeof this.tabs[id])
return;
this.tabs[id].setContent(content);
};
this.setTitle = function(id, title)
{
if ('undefined' == typeof this.tabs[id])
return;
this.tabs[id].setTitle(title);
};
this.updateInnerWidth = function()
{
var tmpwidth = 0;
for (a in this.tabs)
{
tmpwidth += this.tabs[a].getWidth();
}
this.tabWidth = tmpwidth + 22;
};
this.closePanel = function(id)
{
if ('undefined' == typeof this.tabs[id])
return;
if (null != this.lastActiveTab)
{
if (this.activeTab.id == id)
this.show(this.lastActiveTab.id);
}
this.tabs[id].destroy();
delete (this.tabs[id]);
this.updateInnerWidth();
if (this.tabWidth < this.maxWidth)
{
this.leftHandle.style.display = 'none';
this.rightHandle.style.display = 'none';
this.tabContainer.style.left = "0px";
this.tabContainer.style.right = "0px";
// possible IE fix
//this.tabContainer.style.width = this.maxWidth + "px";
this.tabPanel.style.left = "0px";
}
};
this.on = function(EventName, id, EventFunction, EventFunctionId)
{
this.tabs[id].on(EventName, EventFunction, EventFunctionId);
}
this.scroll = function(value)
{
if (null != this.interval)
return;
var tab = this;
var i = value;
this.interval = setInterval(function()
{
var lspace = $(tab.leftHandle).innerWidth() + 1;
var rspace = $(tab.rightHandle).innerWidth() + 1;
var sLeft = tab.tabPanel.style.left;
var iLeft = sLeft.replace("px", "");
if ("" == iLeft)
iLeft = 0;
iLeft = parseInt(iLeft);
iLeft += i;
var iMin = tab.maxWidth - tab.tabWidth - rspace - lspace;
if ((iLeft > 0) || ((iLeft < iMin) && (i < 0)))
{
tab.scrollStop();
return;
}
tab.tabPanel.style.left = iLeft + "px";
}, 25);
}
this.scrollStop = function()
{
if (null == this.interval)
return;
clearInterval(this.interval);
this.interval = null;
}
this.destroy = function()
{
for (a in this.tabs)
{
this.tabs[a].destroy();
delete (this.tabs[a]);
}
};
};
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.create = function(id, config)
{
if ("undefined" == typeof xajax.ext.tabManager.instances[id])
{
try
{
xajax.ext.tabManager.instances[id] = new xajax.ext.tabManager.tabBar(config);
}
catch (ex)
{
}
}
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.addPanel = function(id, config)
{
try
{
xajax.ext.tabManager.instances[id].addPanel(config);
}
catch (ex)
{
}
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.showPanel = function(id, sPanel)
{
try
{
xajax.ext.tabManager.instances[id].show(sPanel);
}
catch (ex)
{
}
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.setTitle = function(id, sPanel, title)
{
try
{
xajax.ext.tabManager.instances[id].setTitle(sPanel, title);
}
catch (ex)
{
}
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.on = function(id, sEventName, sTarget, sEventFunc, sEventId)
{
xajax.ext.tabManager.instances[id].on(sEventName, sTarget, sEventFunc, sEventId);
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.closePanel = function(id, sPanel)
{
xajax.ext.tabManager.instances[id].closePanel(sPanel);
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.ext.tabManager.destroy = function(id)
{
xajax.ext.tabManager.instances[id].destroy();
delete (xajax.ext.tabManager.instances[id]);
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_create', function(args)
{
args.cmdFullName = 'ext.tabManager.create';
xajax.ext.tabManager.create(args.id, args.data);
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_at', function(args)
{
args.cmdFullName = 'ext.tabManager.addPanel';
xajax.ext.tabManager.addPanel(args.id, args.data);
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_on', function(args)
{
try
{
args.cmdFullName = 'ext.tabManager.on';
eval("var sEvent = " + args.data.e + ";");
xajax.ext.tabManager.on(args.id, args.data.n, args.data.p, sEvent, args.data.key);
}
catch (ex)
{
//console.log(ex);
}
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_cl', function(args)
{
try
{
args.cmdFullName = 'ext.tabManager.closePanel';
xajax.ext.tabManager.closePanel(args.id, args.data);
}
catch (ex)
{
debugObj(ex);
}
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_sp', function(args)
{
args.cmdFullName = 'ext.tabManager.showPanel';
xajax.ext.tabManager.showPanel(args.id, args.data);
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_st', function(args)
{
try
{
args.cmdFullName = 'ext.tabManager.setTitle';
xajax.ext.tabManager.setTitle(args.id, args.data.panel, args.data.title);
}
catch (ex)
{
//console.log(ex);
}
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
xajax.command.handler.register('tm_de', function(args)
{
try
{
args.cmdFullName = 'ext.tabManager.destroy';
xajax.ext.tabManager.destroy(args.id);
}
catch (ex)
{
debugObj(ex);
}
return true;
});
/* ------------------------------------------------------------------------------------------------------------------------------ */
}
installtabManager();

View File

@@ -0,0 +1,312 @@
<?php
define('FILE_APPEND', 1);
/*
File: tableUpdater.inc.php
Contains a class that can be used to invoke DOM calls on the browser which
will create or update an HTML table.
Title: clsTableUpdater class
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
{
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
$sXajaxCore = $sBaseFolder . '/xajax_core';
if (false == class_exists('xajaxPlugin'))
require $sXajaxCore . '/xajaxPlugin.inc.php';
if (false == class_exists('xajaxPluginManager'))
require $sXajaxCore . '/xajaxPluginManager.inc.php';
}
//require_once dirname(__FILE__) . '/xajaxCometPlugin.inc.php';
/*
Class: clsTableUpdater
*/
class clsCometStreaming extends xajaxResponsePlugin
{
/*
String: sDefer
Used to store the state of the scriptDeferral configuration setting. When
script deferral is desired, this member contains 'defer' which will request
that the browser defer loading of the javascript until the rest of the page
has been loaded.
*/
var $sDefer;
/*
String: sJavascriptURI
Used to store the base URI for where the javascript files are located. This
enables the plugin to generate a script reference to it's javascript file
if the javascript code is NOT inlined.
*/
var $sJavascriptURI;
/*
Boolean: bInlineScript
Used to store the value of the inlineScript configuration option. When true,
the plugin will return it's javascript code as part of the javascript header
for the page, else, it will generate a script tag referencing the file by
using the <clsTableUpdater->sJavascriptURI>.
*/
var $bInlineScript;
/*
Function: clsTableUpdater
Constructs and initializes an instance of the table updater class.
*/
function clsCometStreaming()
{
$this->sDefer = '';
$this->sJavascriptURI = '';
$this->bInlineScript = false;
}
/*
Function: configure
Receives configuration settings set by <xajax> or user script calls to
<xajax->configure>.
sName - (string): The name of the configuration option being set.
mValue - (mixed): The value being associated with the configuration option.
*/
function configure($sName, $mValue)
{
if ('scriptDeferral' == $sName) {
if (true === $mValue || false === $mValue) {
if ($mValue) $this->sDefer = 'defer ';
else $this->sDefer = '';
}
} else if ('javascript URI' == $sName) {
$this->sJavascriptURI = $mValue;
} else if ('inlineScript' == $sName) {
if (true === $mValue || false === $mValue)
$this->bInlineScript = $mValue;
}
}
/*
Function: generateClientScript
Called by the <xajaxPluginManager> during the script generation phase. This
will either inline the script or insert a script tag which references the
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
configuration option.
*/
function generateClientScript()
{
if ($this->bInlineScript)
{
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
echo "/* <![CDATA[ */\n";
include(dirname(__FILE__) . 'xajax_plugins/response/comet/comet.js');
echo "/* ]]> */\n";
echo "</script>\n";
} else {
echo "\n<script type='text/javascript' src='" . $this->sJavascriptURI . "xajax_plugins/response/comet/comet.js' " . $this->sDefer . "charset='UTF-8'></script>\n";
}
}
}
class xajaxCometResponse extends xajaxResponse
{
var $bHeaderSent = false;
/*
Function: xajaxCometResponse
calls parent function xajaxResponse();
*/
function xajaxCometResponse()
{
parent::xajaxResponse();
}
/*
Function: printOutput
override the original printOutput function. It's no longer needed since the output is already sent.
*/
function printOutput()
{
if ( "HTML5DRAFT" == $_GET['xjxstreaming']) {
$response = "";
$response .= "Event: xjxendstream\n";
$response .= "data: done\n";
$response .= "\n";
print $response;
}
}
/*
Function: flush_XHR
Flushes the command queue for comet browsers.
*/
function flush_XHR()
{
if (!$this->bHeaderSent)
{
$this->_sendHeaders();
$this->bHeaderSent=true;
}
ob_start();
$this->_printResponse_XML();
$c = ob_get_contents();
ob_get_clean();
$c = str_replace(chr(1)," ",$c);
$c = str_replace(chr(2)," ",$c);
$c = str_replace(chr(31)," ",$c);
$c = str_replace(""," ",$c);
if ($c == "<xjx></xjx>") return false;
print $c;
ob_flush();
flush();
$this->sleep(1.1);
}
/*
Function: flush_activeX
Flushes the command queue for ActiveX browsers.
*/
function flush_activeX()
{
ob_start();
$this->_printResponse_XML();
$c = ob_get_contents();
ob_get_clean();
$c = '<?xml version="1.0" ?>'.$c;
$c = str_replace('"','\"',$c);
$c = str_replace("\n",'\n',$c);
$c = str_replace("\r",'\r',$c);
$response = "";
$response .= "<script>top.document.callback(\"";
$response .= $c;
$response .= "\");</script>";
print $response;
ob_flush();
flush();
$this->sleep(0.99);
}
/*
Function: flush_HTML5DRAFT
Flushes the command queue for HTML5DRAFT browsers.
*/
function flush_HTML5DRAFT()
{
if (!$this->bHeaderSent)
{
header("Content-Type: application/x-dom-event-stream");
$this->bHeaderSent=1;
}
ob_start();
$this->_printResponse_XML();
$c = ob_get_contents();
ob_get_clean();
$c = str_replace("\n",'\n',$c);
$c = str_replace("\r",'\r',$c);
$response = "";
$response .= "Event: xjxstream\n";
$response .= "data: $c\n";
$response .= "\n";
print $response;
ob_flush();
flush();
$this->sleep(1);
}
/*
Function: flush
Determines which browser is wating for a response and calls the according flush function.
*/
function flush()
{
if (0 == count($this->aCommands)) return false;
if ("xhr" == $_SERVER['HTTP_STREAMING'])
{
$this->flush_XHR();
}
elseif ( "HTML5DRAFT" == $_GET['xjxstreaming'])
{
$this->flush_HTML5DRAFT();
}
else
{
$this->flush_activeX();
}
$this->aCommands=array();
}
/*
Function: sleep
Very accurate sleep function.
*/
function sleep($seconds)
{
usleep(floor($seconds*1000000));
}
function file_put_contents($n, $d, $flag = false)
{
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
$f = @fopen($n, $mode);
if ($f === false)
{
return 0;
} else
{
if (is_array($d)) $d = implode($d);
$bytes_written = fwrite($f, $d);
fclose($f);
return $bytes_written;
}
}
}
$objPluginManager =& xajaxPluginManager::getInstance();
$objPluginManager->registerPlugin(new clsCometStreaming());

View File

@@ -0,0 +1,516 @@
/*
File: comet.js
Title: Comet plugin for xajax
*/
/*
@package comet plugin
@version $Id:
@copyright Copyright (c) 2007 by Steffen Konerow (IE)
@license http://www.xajaxproject.org/bsd_license.txt BSD License
*/
/*
Class: xajax.ext.comet
This class contains all functions for using comet streaming with xajax.
*/
try {
if (undefined == xajax.ext)
xajax.ext = {};
} catch (e) {
}
try {
if (undefined == xajax.ext.comet)
xajax.ext.comet = {};
} catch (e) {
alert("Could not create xajax.ext.comet namespace");
}
// create Shorthand for xajax.ext.comet
xjxEc = xajax.ext.comet;
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: detectSupport
Detects browser for using fallback methods instead of multipart XHR responses.
*/
xjxEc.detectSupport = function()
{
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1)
{
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla')
{
return navigator.userAgent.substr(0,agt.indexOf('\/'));
}
else return 'Netscape';
}
else if (agt.indexOf(' ') != -1) return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
// if (navigator.appVersion.indexOf("MSIE")!=-1)
// {
// var version,temp;
// temp=navigator.appVersion.split("MSIE")
// version=parseFloat(temp[1])
// if (version>=5.5) return "MSIE";
// }
// if ( "undefined" != typeof window.opera )
// {
// return "OPERA";
// }
// if ( "undefined" != typeof window.Iterator )
// {
// return "FF2";
// }
return false;
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: prepareRequestXHR
Prepares the XMLHttpRequest object for this xajax request in FF/Safari browsers.
*/
xjxEc.prepareRequestXHR = function (oRequest)
{
if (true == oRequest.comet)
{
var xx = xajax;
var xt = xx.tools;
oRequest.request = xt.getRequestObject();
oRequest.setRequestHeaders = function(headers) {
if ('object' == typeof headers) {
for (var optionName in headers)
this.request.setRequestHeader(optionName, headers[optionName]);
}
}
oRequest.setCommonRequestHeaders = function() {
this.setRequestHeaders(this.commonHeaders);
}
oRequest.setPostRequestHeaders = function() {
this.setRequestHeaders(this.postHeaders);
}
oRequest.setGetRequestHeaders = function() {
this.setRequestHeaders(this.getHeaders);
}
oRequest.applyRequestHeaders = function() {
}
oRequest.setCommonRequestHeaders = function() {
this.request.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
this.request.setRequestHeader('streaming', 'xhr');
if (typeof(oRequest.header) == "object")
{
for (a in oRequest.header)
this.request.setRequestHeader(a, oRequest.header[a]);
}
}
oRequest.comet = {};
oRequest.comet.LastPosition = 0;
var pollLatestResponse = function() {
xjxEc.responseProcessor.XHR(oRequest);
}
oRequest.pollTimer = setInterval(pollLatestResponse, 80);
oRequest.request.onreadystatechange = function()
{
if (oRequest.request.readyState < 3)
return;
if (oRequest.request.readyState == 4)
{
clearInterval(oRequest.pollTimer);
xjxEc.responseProcessor.XHR(oRequest);
//xajax.responseReceived(oRequest);
xajax.completeResponse(oRequest);
return;
}
}
oRequest.finishRequest = function()
{
return this.returnValue;
}
if ('undefined' != typeof oRequest.userName && 'undefined' != typeof oRequest.password)
{
oRequest.open = function()
{
this.request.open(
this.method,
this.requestURI,
true,
oRequest.userName,
oRequest.password);
}
} else
{
oRequest.open = function()
{
this.request.open(
this.method,
this.requestURI,
true);
}
}
if ('POST' == oRequest.method) { // W3C: Method is case sensitive
oRequest.applyRequestHeaders = function() {
this.setCommonRequestHeaders();
try {
this.setPostRequestHeaders();
} catch (e) {
this.method = 'GET';
this.requestURI += this.requestURI.indexOf('?')== -1 ? '?' : '&';
this.requestURI += this.requestData;
this.requestData = '';
if (0 == this.requestRetry) this.requestRetry = 1;
throw e;
}
}
} else {
oRequest.applyRequestHeaders = function() {
this.setCommonRequestHeaders();
this.setGetRequestHeaders();
}
}
return;
}
return xjxEc.prepareRequest(oRequest);
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: connect_htmlfile
Create a hidden iframe for IE
*/
xjxEc.connect_htmlfile = function (url, callback,oRequest)
{
try {
xjxEc.transferDoc = new ActiveXObject("htmlfile");
xjxEc.transferDoc.open();
xjxEc.transferDoc.write("<html>");
xjxEc.transferDoc.write("<script>document.domain='http://192.168.1.21/';</script>");
xjxEc.transferDoc.write("</html>");
xjxEc.transferDoc.close();
xjxEc.ifrDiv = xjxEc.transferDoc.createElement("div");
xjxEc.transferDoc.body.appendChild(xjxEc.ifrDiv);
xjxEc.ifrDiv.innerHTML = "<iframe src='" + url + "'></iframe>";
xjxEc.transferDoc.callback = function (response) {
callback(response,oRequest);
};
} catch (ex) {
}
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: prepareRequestActiveX
Prepares the Iframe for streaming with active X
*/
xjxEc.prepareRequestActiveX = function(oRequest) {
if (true == oRequest.comet) {
var xx = xajax;
var xt = xx.tools;
oRequest.requestURI += oRequest.requestURI.indexOf('?')== -1 ? '?' : '&';
oRequest.requestURI += oRequest.requestData;
oRequest.requestData = '';
try {
xjxEc.connect_htmlfile(oRequest.requestURI,xjxEc.responseProcessor.ActiveX,oRequest);
if (0 < oRequest.requestRetry) oRequest.requestRetry = 0;
} catch (ex) {
}
return;
}
return xjxEc.prepareRequest(oRequest);
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: prepareRequestHTMLDRAFT
Prepares streaming with HTML 5 Draft
*/
xjxEc.prepareRequestHTMLDRAFT = function(oRequest) {
if (true == oRequest.comet) {
var xx = xajax;
var xt = xx.tools;
oRequest.requestURI += oRequest.requestURI.indexOf('?')== -1 ? '?' : '&';
oRequest.requestURI += oRequest.requestData;
oRequest.requestURI += "&xjxstreaming=HTML5DRAFT";
try {
var uri = oRequest.requestURI;
var es = document.createElement("event-source");
es.setAttribute("src", uri);
es.setAttribute("width", 200);
es.setAttribute("height", 200);
es.style.display="block";
callback = function(event)
{
xjxEc.responseProcessor.HTMLDRAFT(event.data,oRequest);
};
remove = function() {
es.removeEventListener("xjxstream",callback,false);
es.removeEventListener("xjxendstream",remove,false);
//document.body.removeChild(es);
}
es.addEventListener("xjxstream",callback,false);
es.addEventListener("xjxendstream",remove,false);
document.body.appendChild(es);
if (0 < oRequest.requestRetry) oRequest.requestRetry = 0;
}
catch (ex)
{
}
return;
}
return xjxEc.prepareRequest(oRequest);
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: responseProcessor.XHR
Processes the streaming response for FF/Safari
*/
xajax.debug={};
xajax.debug.prepareDebugText = function(text) {
try {
text = text.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\n/g, '<br />');
return text;
} catch (e) {
xajax.debug.stringReplace = function(haystack, needle, newNeedle) {
var segments = haystack.split(needle);
haystack = '';
for (var i = 0; i < segments.length; ++i) {
if (0 != i)
haystack += newNeedle;
haystack += segments[i];
}
return haystack;
}
xajax.debug.prepareDebugText = function(text) {
text = xajax.debug.stringReplace(text, '&', '&amp;');
text = xajax.debug.stringReplace(text, '<', '&lt;');
text = xajax.debug.stringReplace(text, '>', '&gt;');
text = xajax.debug.stringReplace(text, '\n', '<br />');
return text;
}
xajax.debug.prepareDebugText(text);
}
}
xjxEc.responseProcessor={}
xjxEc.responseProcessor.XHR = function(oRequest) {
var xx = xajax;
var xt = xx.tools;
var xcb = xx.callback;
var gcb = xcb.global;
var lcb = oRequest.callback;
var oRet = oRequest.returnValue;
if ("" == oRequest.request.responseText) return;
var allMessages = oRequest.request.responseText;
do {
var unprocessed = allMessages.substring(oRequest.comet.LastPosition);
var messageXMLEndIndex = unprocessed.indexOf("</xjx>");
if (messageXMLEndIndex!=-1) {
var endOfFirstMessageIndex = messageXMLEndIndex + "</xjx>".length;
var anUpdate = unprocessed.substring(0, endOfFirstMessageIndex);
var cmd = (new DOMParser()).parseFromString(anUpdate, "text/xml");
try {
var seq = 0;
var child = cmd.documentElement.firstChild;
xt.xml.processFragment(child, seq, oRequest);
} catch (ex) {
}
xt.queue.process(xx.response);
oRequest.comet.LastPosition += endOfFirstMessageIndex;
}
} while (messageXMLEndIndex != -1);
return oRet;
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: responseProcessor.ActiveX
Processes the streaming response for IE
*/
xjxEc.responseProcessor.ActiveX = function(response,oRequest) {
response.replace('\"','"');
var xx = xajax;
var xt = xx.tools;
var xcb = xx.callback;
var gcb = xcb.global;
var lcb = oRequest.callback;
var oRet = oRequest.returnValue;
if (response) {
var cmd = (new DOMParser()).parseFromString(response, "text/xml");
var seq=0;
var child = cmd.documentElement.firstChild;
xt.xml.processFragment(child, seq, oRequest);
if (null == xx.response.timeout)
xt.queue.process(xx.response);
}
return oRet;
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: responseProcessor.HTMLDRAFT
Processes the streaming response for HTML 5 Draft Browsers (Opera 9+)
*/
xjxEc.responseProcessor.HTMLDRAFT = function(response,oRequest) {
var xx = xajax;
var xt = xx.tools;
var xcb = xx.callback;
var gcb = xcb.global;
var lcb = oRequest.callback;
var oRet = oRequest.returnValue;
if (response) {
var cmd = (new DOMParser()).parseFromString(response, "text/xml");
var seq=0;
var child = cmd.documentElement.firstChild;
xt.xml.processFragment(child, seq, oRequest);
if (null == xx.response.timeout)
xt.queue.process(xx.response);
}
return oRet;
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: submitRequestActiveX
Supresses the xajax.submitRequest() function call for IE in streaming calls.
*/
xjxEc.submitRequestActiveX = function(oRequest) {
if (true == oRequest.comet) return;
xjxEc.submitRequest(oRequest);
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
variable setup. Detects IE and replaces the according functions
*/
xjxEc.prepareRequest = xajax.prepareRequest;
xjxEc.stream_support = xjxEc.detectSupport();
switch (xjxEc.stream_support)
{
case "Internet Explorer" :
xajax.prepareRequest = xjxEc.prepareRequestActiveX;
xjxEc.submitRequest=xajax.submitRequest;
xajax.submitRequest=xjxEc.submitRequestActiveX;
break;
case "Firefox" :
case "Safari" :
xajax.prepareRequest = xjxEc.prepareRequestXHR;
break;
case "Opera" :
xajax.prepareRequest = xjxEc.prepareRequestHTMLDRAFT;
xjxEc.submitRequest=xajax.submitRequest;
xajax.submitRequest=xjxEc.submitRequestActiveX;
break;
default : alert("Xajax.Ext.Comet: Your browser does not support comet streaming or is not yet supported by this plugin!");
}
// -------------------------------------------------------------------------------------------------------------------------------------
/*
Function: DOMParser
Prototype DomParser for IE/Opera
*/
if (typeof DOMParser == "undefined") {
DOMParser = function () {}
DOMParser.prototype.parseFromString = function (str, contentType) {
if (typeof ActiveXObject != "undefined") {
var d = new ActiveXObject("Microsoft.XMLDOM");
d.loadXML(str);
return d;
} else if (typeof XMLHttpRequest != "undefined") {
var req = new XMLHttpRequest;
req.open("GET", "data:" + (contentType || "application/xml") +
";charset=utf-8," + encodeURIComponent(str), false);
if (req.overrideMimeType) {
req.overrideMimeType(contentType);
}
req.send(null);
return req.responseXML;
}
}
}
// -------------------------------------------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,232 @@
<?php
/*
File: xajaxCometFunction.inc.php
Contains the xajaxCometFunction class
Title: xajaxCometFunction class
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
/*
@package xajax
@version $Id: xajaxCometFunction.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
@license http://www.xajaxproject.org/bsd_license.txt BSD License
*/
/*
Class: xajaxCometFunction
Construct instances of this class to define functions that will be registered
with the <xajax> request processor. This class defines the parameters that
are needed for the definition of a xajax enabled function. While you can
still specify functions by name during registration, it is advised that you
convert to using this class when you wish to register external functions or
to specify call options as well.
*/
class xajaxCometFunction
{
/*
String: sAlias
An alias to use for this function. This is useful when you want
to call the same xajax enabled function with a different set of
call options from what was already registered.
*/
var $sAlias;
/*
Object: uf
A string or array which defines the function to be registered.
*/
var $uf;
/*
String: sInclude
The path and file name of the include file that contains the function.
*/
var $sInclude;
/*
Array: aConfiguration
An associative array containing call options that will be sent to the
browser curing client script generation.
*/
var $aConfiguration;
/*
Function: xajaxCometFunction
Constructs and initializes the <xajaxCometFunction> object.
$uf - (mixed): A function specification in one of the following formats:
- a three element array:
(string) Alternate function name: when a method of a class has the same
name as another function in the system, you can provide an alias to
help avoid collisions.
(object or class name) Class: the name of the class or an instance of
the object which contains the function to be called.
(string) Method: the name of the method that will be called.
- a two element array:
(object or class name) Class: the name of the class or an instance of
the object which contains the function to be called.
(string) Method: the name of the method that will be called.
- a string:
the name of the function that is available at global scope (not in a
class.
$sInclude - (string, optional): The path and file name of the include file
that contains the class or function to be called.
$aConfiguration - (array, optional): An associative array of call options
that will be used when sending the request from the client.
Examples:
$myFunction = array('alias', 'myClass', 'myMethod');
$myFunction = array('alias', &$myObject, 'myMethod');
$myFunction = array('myClass', 'myMethod');
$myFunction = array(&$myObject, 'myMethod');
$myFunction = 'myFunction';
$myUserFunction = new xajaxCometFunction($myFunction, 'myFile.inc.php', array(
'method' => 'get',
'mode' => 'synchronous'
));
$xajax->register(XAJAX_FUNCTION, $myUserFunction);
*/
function xajaxCometFunction($uf, $sInclude=NULL, $aConfiguration=array())
{
$this->sAlias = '';
$this->uf =& $uf;
$this->sInclude = $sInclude;
$this->aConfiguration = array();
foreach ($aConfiguration as $sKey => $sValue)
$this->configure($sKey, $sValue);
if (is_array($this->uf) && 2 < count($this->uf))
{
$this->sAlias = $this->uf[0];
$this->uf = array_slice($this->uf, 1);
}
//SkipDebug
if (is_array($this->uf) && 2 != count($this->uf))
trigger_error(
'Invalid function declaration for xajaxCometFunction.',
E_USER_ERROR
);
//EndSkipDebug
}
/*
Function: getName
Get the name of the function being referenced.
Returns:
string - the name of the function contained within this object.
*/
function getName()
{
// Do not use sAlias here!
if (is_array($this->uf))
return $this->uf[1];
return $this->uf;
}
/*
Function: configure
Call this to set call options for this instance.
*/
function configure($sName, $sValue)
{
if ('alias' == $sName)
$this->sAlias = $sValue;
else
$this->aConfiguration[$sName] = $sValue;
}
/*
Function: generateRequest
Constructs and returns a <xajaxRequest> object which is capable
of generating the javascript call to invoke this xajax enabled
function.
*/
function generateRequest($sXajaxPrefix)
{
$sAlias = $this->getName();
if (0 < strlen($this->sAlias))
$sAlias = $this->sAlias;
return new xajaxRequest("{$sXajaxPrefix}{$sAlias}");
}
/*
Function: generateClientScript
Called by the <xajaxPlugin> that is referencing this function
reference during the client script generation phase. This function
will generate the javascript function stub that is sent to the
browser on initial page load.
*/
function generateClientScript($sXajaxPrefix)
{
$sFunction = $this->getName();
$sAlias = $sFunction;
if (0 < strlen($this->sAlias))
$sAlias = $this->sAlias;
echo "{$sXajaxPrefix}{$sAlias} = function() { ";
echo "return xajax.request( ";
echo "{ xjxcomet: '{$sFunction}' }, ";
echo "{ parameters: arguments, mode:'comet'";
$sSeparator = ", ";
foreach ($this->aConfiguration as $sKey => $sValue)
echo "{$sSeparator}{$sKey}: {$sValue}";
echo " } ); ";
echo "};\n";
}
/*
Function: call
Called by the <xajaxPlugin> that references this function during the
request processing phase. This function will call the specified
function, including an external file if needed and passing along
the specified arguments.
*/
function call($aArgs=array())
{
$objResponseManager =& xajaxResponseManager::getInstance();
if (NULL != $this->sInclude)
{
ob_start();
require_once $this->sInclude;
$sOutput = ob_get_clean();
//SkipDebug
if (0 < strlen($sOutput))
{
$sOutput = 'From include file: ' . $this->sInclude . ' => ' . $sOutput;
$objResponseManager->debug($sOutput);
}
//EndSkipDebug
}
$mFunction = $this->uf;
$objResponseManager->append(call_user_func_array($mFunction, $aArgs));
}
}
?>

View File

@@ -0,0 +1,165 @@
<?php
/*
File: googleMap.inc.php
Contains a class that can be used to invoke DOM calls on the browser which
will create or update a google map.
Title: clsGoogleMap class
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
//$sBaseFolder = dirname(dirname(dirname(__FILE__)));
//$sXajaxCore = $sBaseFolder . '/xajax_core';
//require $sXajaxCore . '/xajaxPlugin.inc.php';
//require $sXajaxCore . '/xajaxPluginManager.inc.php';
/*
Class: clsGoogleMap
*/
class clsGoogleMap extends xajaxResponsePlugin
{
/*
String: sJavascriptURI
Used to store the base URI for where the javascript files are located. This
enables the plugin to generate a script reference to it's javascript file
if the javascript code is NOT inlined.
*/
var $sJavascriptURI;
/*
Boolean: bInlineScript
Used to store the value of the inlineScript configuration option. When true,
the plugin will return it's javascript code as part of the javascript header
for the page, else, it will generate a script tag referencing the file by
using the <clsTableUpdater->sJavascriptURI>.
*/
var $bInlineScript;
/*
String: sGoogleSiteKey
The key that google has assigned to your site. Set this with <clsGoogleMap->setKey>
*/
/*
Function: clsTableUpdater
Constructs and initializes an instance of the table updater class.
*/
function clsGoogleMap()
{
$this->sJavascriptURI = '';
$this->bInlineScript = true;
}
/*
Function: configure
Receives configuration settings set by <xajax> or user script calls to
<xajax->configure>.
sName - (string): The name of the configuration option being set.
mValue - (mixed): The value being associated with the configuration option.
*/
function configure($sName, $mValue)
{
if ('javascript URI' == $sName) {
$this->sJavascriptURI = $mValue;
} else if ('inlineScript' == $sName) {
if (true === $mValue || false === $mValue)
$this->bInlineScript = $mValue;
}
}
/*
Function: generateClientScript
Called by the <xajaxPluginManager> during the script generation phase. This
will either inline the script or insert a script tag which references the
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
configuration option.
*/
function generateClientScript()
{
echo "\n<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=";
echo $this->sGoogleSiteKey;
echo "' type='text/javascript'>\n</script>\n";
echo "\n<script type='text/javascript' charset='UTF-8'>\n";
echo "/* <![CDATA[ */\n";
echo "maps = {};\n";
echo "xajax.commands['gm:cr'] = function(args) {\n";
echo "\tmaps[args.data] = new GMap2(args.objElement);\n";
echo "\tvar ptCenter = new GLatLng(0, 10);\n";
echo "\tmaps[args.data].setCenter(ptCenter, 10);\n";
echo "\tmaps[args.data].addControl(new GSmallMapControl());\n";
echo "\tmaps[args.data].addControl(new GMapTypeControl());\n";
echo "\tmaps[args.data].setMapType(maps[args.data].getMapTypes()[2]);\n";
echo "}\n";
echo "xajax.commands['gm:zm'] = function(args) {\n";
echo "\tmaps[args.id].setZoom(parseInt(args.data));\n";
echo "}\n";
echo "xajax.commands['gm:sm'] = function(args) {\n";
echo "\tvar ptCenter = new GLatLng(args.data[0], args.data[1]);\n";
echo "\tvar markerNew = new GMarker(ptCenter);\n";
echo "\tmarkerNew.text = args.data[2];\n";
echo "\tmaps[args.id].addOverlay(markerNew);\n";
echo "\tGEvent.addListener(maps[args.id], 'click', function(marker, point) {\n";
echo "\t\tif (marker && undefined != marker.openInfoWindowHtml) {\n";
echo "\t\t\tmarker.openInfoWindowHtml(marker.text);\n";
echo "\t\t}\n";
echo "\t} );\n";
echo "}\n";
echo "/* ]]> */\n";
echo "</script>\n";
}
function getName()
{
return get_class($this);
}
function setGoogleSiteKey($sKey)
{
$this->sGoogleSiteKey = $sKey;
}
function create($sMap, $sParentId)
{
$command = array('n'=>'gm:cr', 't'=>$sParentId);
$this->addCommand($command, $sMap);
}
function zoom($sMap, $nZoom) {
$command = array('n'=>'gm:zm', 't'=>$sMap);
$this->addCommand($command, $nZoom);
}
function setMarker($sMap, $nLat, $nLon, $sText) {
$this->addCommand(
array('n'=>'gm:sm', 't'=>$sMap),
array($nLat, $nLon, $sText)
);
}
function moveTo($sMap, $nLat, $nLon) {
// 39.928005,
// -82.70784,
// 15);
$command = array('n'=>'et_ar', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, $row);
}
}
$objPluginManager =& xajaxPluginManager::getInstance();
$objPluginManager->registerPlugin(new clsGoogleMap());

View File

@@ -0,0 +1,151 @@
<?php
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
{
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
$sXajaxCore = $sBaseFolder . '/xajax_core';
if (false == class_exists('xajaxPlugin'))
require $sXajaxCore . '/xajaxPlugin.inc.php';
if (false == class_exists('xajaxPluginManager'))
require $sXajaxCore . '/xajaxPluginManager.inc.php';
}
//require_once dirname(__FILE__) . '/xajaxCometPlugin.inc.php';
/*
Class: clsTableUpdater
*/
class clsPreloader extends xajaxResponsePlugin
{
/*
String: sDefer
Used to store the state of the scriptDeferral configuration setting. When
script deferral is desired, this member contains 'defer' which will request
that the browser defer loading of the javascript until the rest of the page
has been loaded.
*/
var $sDefer;
/*
String: sJavascriptURI
Used to store the base URI for where the javascript files are located. This
enables the plugin to generate a script reference to it's javascript file
if the javascript code is NOT inlined.
*/
var $sJavascriptURI;
/*
Boolean: bInlineScript
Used to store the value of the inlineScript configuration option. When true,
the plugin will return it's javascript code as part of the javascript header
for the page, else, it will generate a script tag referencing the file by
using the <clsTableUpdater->sJavascriptURI>.
*/
var $bInlineScript;
var $aScripts = array();
var $aImages = array();
var $aStyles = array();
/*
Function: clsTableUpdater
Constructs and initializes an instance of the table updater class.
*/
function clsPreloader()
{
$this->sDefer = '';
$this->sJavascriptURI = '';
$this->bInlineScript = false;
}
/*
Function: configure
Receives configuration settings set by <xajax> or user script calls to
<xajax->configure>.
sName - (string): The name of the configuration option being set.
mValue - (mixed): The value being associated with the configuration option.
*/
function configure($sName, $mValue)
{
if ('scriptDeferral' == $sName) {
if (true === $mValue || false === $mValue) {
if ($mValue) $this->sDefer = 'defer ';
else $this->sDefer = '';
}
} else if ('javascript URI' == $sName) {
$this->sJavascriptURI = $mValue;
} else if ('inlineScript' == $sName) {
if (true === $mValue || false === $mValue)
$this->bInlineScript = $mValue;
}
}
/*
Function: generateClientScript
Called by the <xajaxPluginManager> during the script generation phase. This
will either inline the script or insert a script tag which references the
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
configuration option.
*/
function generateClientScript()
{
if ($this->bInlineScript)
{
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
echo "/* <![CDATA[ */\n";
include(dirname(__FILE__) . 'xajax_plugins/response/preloader/preload.js');
echo "/* ]]> */\n";
echo "</script>\n";
} else {
echo "\n<script type='text/javascript' src='" . $this->sJavascriptURI . "xajax_plugins/response/preloader/preload.js' " . $this->sDefer . "charset='UTF-8'></script>\n";
echo "\n<script type='text/javascript'>";
print "try {";
echo "
try {
if (undefined == xajax.ext)
xajax.ext = {};
} catch (e) {
}
try {
if (undefined == xajax.ext.preloader)
xajax.ext.preloader = {};
} catch (e) {
alert('Could not create xajax.ext.preloader namespace');
}
";
echo "xajax.ext.preloader.aScripts = ".json_encode($this->aScripts).";\n";
echo "xajax.ext.preloader.aStyles = ".json_encode($this->aStyles).";\n";
echo "xajax.ext.preloader.aImages = ".json_encode($this->aImages).";\n";
echo "xajax.ext.preloader.ready=true;";
echo "} catch(ex) { alert(ex);}";
echo "</script>";
}
}
function addScript($uri) {
$this->aScripts[] = $uri;
}
function addImages($uri) {
$this->aImages[] = $uri;
}
function addStyleSheet($uri) {
$this->aStyles[] = $uri;
}
}
$objPluginManager =& xajaxPluginManager::getInstance();
$objPluginManager->registerPlugin(new clsPreloader());

View File

@@ -0,0 +1,46 @@
try {
if (undefined == xajax.ext)
xajax.ext = {};
} catch (e) {
}
try {
if (undefined == xajax.ext.preloader)
xajax.ext.preloader = {};
} catch (e) {
alert("Could not create xajax.ext.preloader namespace");
}
xajax.ext.preloader.aScripts = [];
xajax.ext.preloader.aImages = [];
xajax.ext.preloader.aStyles = [];
xajax.ext.preloader.ready = false;
xajax.ext.preloader.run = function() {
if (!xajax.ext.preloader.ready)
{
window.setTimout(xajax.ext.preloader.run,200);
return;
}
var splash = document.createElement("div");
splash.id = "inhalt";
document.body.appendChild(splash);
var l = xajax.ext.preloader.aScripts.length;
for (i=0;i<l;++i)
{
var command =
{
data : xajax.ext.preloader.aScripts[i],
onload : function() {alert(aScripts[i]+ " loaded");}
}
xajax.js.includeScript(command);
splash.innerHTML += xajax.ext.preloader.aScripts[i]+"\n<br />\n";
}
}
window.onload=xajax.ext.preloader.run;

View File

@@ -0,0 +1,227 @@
<?php
/*
File: tableUpdater.inc.php
Contains a class that can be used to invoke DOM calls on the browser which
will create or update an HTML table.
Title: clsTableUpdater class
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
{
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
$sXajaxCore = $sBaseFolder . '/xajax_core';
if (false == class_exists('xajaxPlugin'))
require $sXajaxCore . '/xajaxPlugin.inc.php';
if (false == class_exists('xajaxPluginManager'))
require $sXajaxCore . '/xajaxPluginManager.inc.php';
}
/*
Class: clsTableUpdater
*/
class clsTableUpdater extends xajaxResponsePlugin
{
/*
String: sDefer
Used to store the state of the scriptDeferral configuration setting. When
script deferral is desired, this member contains 'defer' which will request
that the browser defer loading of the javascript until the rest of the page
has been loaded.
*/
var $sDefer;
/*
String: sJavascriptURI
Used to store the base URI for where the javascript files are located. This
enables the plugin to generate a script reference to it's javascript file
if the javascript code is NOT inlined.
*/
var $sJavascriptURI;
/*
Boolean: bInlineScript
Used to store the value of the inlineScript configuration option. When true,
the plugin will return it's javascript code as part of the javascript header
for the page, else, it will generate a script tag referencing the file by
using the <clsTableUpdater->sJavascriptURI>.
*/
var $bInlineScript;
/*
Function: clsTableUpdater
Constructs and initializes an instance of the table updater class.
*/
function clsTableUpdater()
{
$this->sDefer = '';
$this->sJavascriptURI = '';
$this->bInlineScript = true;
}
/*
Function: configure
Receives configuration settings set by <xajax> or user script calls to
<xajax->configure>.
sName - (string): The name of the configuration option being set.
mValue - (mixed): The value being associated with the configuration option.
*/
function configure($sName, $mValue)
{
if ('scriptDeferral' == $sName) {
if (true === $mValue || false === $mValue) {
if ($mValue) $this->sDefer = 'defer ';
else $this->sDefer = '';
}
} else if ('javascript URI' == $sName) {
$this->sJavascriptURI = $mValue;
} else if ('inlineScript' == $sName) {
if (true === $mValue || false === $mValue)
$this->bInlineScript = $mValue;
}
}
/*
Function: generateClientScript
Called by the <xajaxPluginManager> during the script generation phase. This
will either inline the script or insert a script tag which references the
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
configuration option.
*/
function generateClientScript()
{
if ($this->bInlineScript)
{
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
echo "/* <![CDATA[ */\n";
include(dirname(__FILE__) . '/tableUpdater.js');
echo "/* ]]> */\n";
echo "</script>\n";
} else {
echo "\n<script type='text/javascript' src='" . $this->sJavascriptURI . "tableUpdater.js' " . $this->sDefer . "charset='UTF-8'>\n";
}
}
function getName()
{
return get_class($this);
}
// tables
function appendTable($table, $parent) {
$command = array('n'=>'et_at', 't'=>$parent);
$this->addCommand($command, $table);
}
function insertTable($table, $parent, $position) {
$command = array('n'=>'et_it', 't'=>$parent, 'p'=>$position);
$this->addCommand($command, $table);
}
function deleteTable($table) {
$this->addCommand(array('n'=>'et_dt'), $table);
}
// rows
function appendRow($row, $parent, $position = null) {
$command = array('n'=>'et_ar', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, $row);
}
function insertRow($row, $parent, $position = null, $before = null) {
$command = array('n'=>'et_ir', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
if (null != $before)
$command['c'] = $before;
$this->addCommand($command, $row);
}
function replaceRow($row, $parent, $position = null, $before = null) {
$command = array('n'=>'et_rr', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
if (null != $before)
$command['c'] = $before;
$this->addCommand($command, $row);
}
function deleteRow($parent, $position = null) {
$command = array('n'=>'et_dr', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, null);
}
function assignRow($values, $parent, $position = null, $start_column = null) {
$command = array('n'=>'et_asr', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
if (null != $start_column)
$command['c'] = $start_column;
$this->addCommand($command, $values);
}
function assignRowProperty($property, $value, $parent, $position = null) {
$command = array('n'=>'et_asr', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, array('p'=>$property, 'v'=>$value));
}
// columns
function appendColumn($column, $parent, $position = null) {
$command = array('n'=>'et_acol', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, $column);
}
function insertColumn($column, $parent, $position = null) {
$command = array('n'=>'et_icol', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, $column);
}
function replaceColumn($column, $parent, $position = null) {
$command = array('n'=>'et_rcol', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, $column);
}
function deleteColumn($parent, $position = null) {
$command = array('n'=>'et_dcol', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, null);
}
function assignColumn($values, $parent, $position = null, $start_row = null) {
$command = array('n'=>'et_ascol', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
if (null != $start_row)
$command['c'] = $start_row;
$this->addCommand($command, $values);
}
function assignColumnProperty($property, $value, $parent, $position = null) {
$command = array('n'=>'et_ascol', 't'=>$parent);
if (null != $position)
$command['p'] = $position;
$this->addCommand($command, array('p'=>$property, 'v'=>$value));
}
function assignCell($row, $column, $value) {
$this->addCommand(array('n'=>'et_asc', 't'=>$row, 'p'=>$column), $value);
}
function assignCellProperty($row, $column, $property, $value) {
$this->addCommand(array('n'=>'et_asc', 't'=>$row, 'p'=>$column), array('p'=>$property, 'v'=>$value));
}
}
$objPluginManager =& xajaxPluginManager::getInstance();
$objPluginManager->registerPlugin(new clsTableUpdater());

View File

@@ -0,0 +1,499 @@
// if xajax has not yet been initialized, wait a second and try again
// once xajax has been initialized, then install the table command
// handlers.
installTableUpdater = function() {
var xjxReady = false;
try {
if (xajax) xjxReady = true;
} catch (e) {
}
if (false == xjxReady) {
setTimeout('installTableUpdater();', 1000);
return;
}
try {
if (undefined == xajax.ext.tables)
xajax.ext.tables = {};
} catch (e) {
xajax.ext = {};
xajax.ext.tables = {};
}
// internal helper functions
xajax.ext.tables.internal = {};
xajax.ext.tables.internal.createTable = function(table) {
if ('string' != typeof (table))
throw { name: 'TableError', message: 'Invalid table name specified.' }
var newTable = document.createElement('table');
newTable.id = table;
// save the column configuration
xajax.ext.tables.appendHeader(table + '_header', newTable);
xajax.ext.tables.appendBody(table + '_body', newTable);
xajax.ext.tables.appendFooter(table + '_footer', newTable);
return newTable;
}
xajax.ext.tables.internal.createRow = function(objects, id) {
var row = document.createElement('tr');
if (null != id)
row.id = id;
return row;
}
xajax.ext.tables.internal.createCell = function(objects, id) {
var cell = document.createElement('td');
if (null != id)
cell.id = id;
cell.innerHTML = '...';
return cell;
}
xajax.ext.tables.internal.getColumnNumber = function(objects, cell) {
var position;
var columns = objects.header.getElementsByTagName('td');
for (var column = 0; column < columns.length; ++column)
if (columns[column].id == cell)
return column;
throw { name: 'TableError', message: 'Column not found. (getColumnNumber)' }
return undefined;
}
xajax.ext.tables.internal.objectify = function(params, required) {
if (undefined == params.source)
return false;
var source = params.source;
if ('string' == typeof (source))
source = xajax.$(source);
if ('TBODY' == source.nodeName) {
params.table = source.parentNode;
} else if ('TABLE' == source.nodeName) {
params.table = source;
} else if ('TR' == source.nodeName) {
params.row = source;
params.body = source.parentNode;
params.table = source.parentNode.parentNode;
} else if ('TD' == source.nodeName) {
params.cell = source;
params.row = source.parentNode;
params.columns = params.row.getElementsByTagName('TD');
for (var column = 0; undefined == params.column && column < params.columns.length; ++column)
if (params.cell.id == params.columns[column].id)
params.column = column;
params.table = source.parentNode.parentNode.parentNode;
} else if ('THEAD' == source.nodeName) {
params.table = source.parentNode;
} else if ('TFOOT' == source.nodeName) {
params.table = source.parentNode;
} else
params.source = source;
var bodies = params.table.getElementsByTagName('TBODY');
if (0 < bodies.length)
params.body = bodies[0];
var headers = params.table.getElementsByTagName('THEAD');
if (0 < headers.length)
params.header = headers[0];
var feet = params.table.getElementsByTagName('TFOOT');
if (0 < feet.length)
params.footer = feet[0];
if (undefined != params.body)
params.rows = params.body.getElementsByTagName('TR');
if (undefined != params.row)
params.cells = params.row.getElementsByTagName('TD');
if (undefined != params.header)
params.columns = params.header.getElementsByTagName('TD');
if (undefined == required)
return true;
for (var index = 0; index < required.length; ++index) {
var require = required[index];
var is_defined = false;
eval('is_defined = (undefined != params.' + require + ');');
if (false == is_defined)
throw { name: 'TableError', message: 'Unable to locate required object [' + require + '].' };
}
return true;
}
// table
xajax.ext.tables.append = function(table, parent) {
if ('string' == typeof (parent))
parent = xajax.$(parent);
parent.appendChild(xajax.ext.tables.internal.createTable(table));
}
xajax.ext.tables.insert = function(table, parent, before) {
if ('string' == typeof (parent))
parent = xajax.$(parent);
if ('string' == typeof (before))
before = xajax.$(before);
parent.insertBefore(xajax.ext.tables.internal.createTable(table), before);
}
xajax.ext.tables.remove = function(table) {
var objects = { source: table };
xajax.ext.tables.internal.objectify(objects, ['table']);
objects.table.parentNode.removeChild(objects.table);
}
xajax.ext.tables.appendHeader = function(id, table) {
var objects = { source: table };
xajax.ext.tables.internal.objectify(objects, ['table']);
if (undefined == objects.header) {
var thead = document.createElement('thead');
if (null != id)
thead.id = id;
objects.header = thead;
thead.appendChild(xajax.ext.tables.internal.createRow(objects, null));
if (undefined == objects.table.firstChild)
table.appendChild(thead);
else
table.insertBefore(thead, table.firstChild);
}
}
xajax.ext.tables.appendBody = function(id, table) {
var objects = { source: table };
xajax.ext.tables.internal.objectify(objects, ['table']);
if (undefined == objects.body) {
var tbody = document.createElement('tbody');
if (null != id)
tbody.id = id;
objects.body = tbody;
}
if (undefined != objects.rows) {
for (var rn = 0; rn < objects.rows.length; ++rn) {
var row = objects.rows[rn];
objects.table.removeChild(row);
objects.body.appendChild(row);
}
}
if (undefined != objects.footer)
objects.table.insertBefore(objects.body, objects.footer);
else
objects.table.appendChild(objects.body);
}
xajax.ext.tables.appendFooter = function(id, table) {
var objects = { source: table }
xajax.ext.tables.internal.objectify(objects, ['table']);
if (undefined == objects.footer) {
var tfoot = document.createElement('tfoot');
if (null != id)
tfoot.id = id;
objects.footer = tfoot;
tfoot.appendChild(xajax.ext.tables.internal.createRow(objects, null));
objects.table.appendChild(tfoot);
}
}
// rows
xajax.ext.tables.rows = {}
xajax.ext.tables.rows.internal = {}
xajax.ext.tables.rows.internal.calculateRow = function(objects, position) {
if (undefined == position)
throw { name: 'TableError', message: 'Missing row number / id.' }
if (undefined == objects.row)
if (undefined != objects.rows)
if (undefined != objects.rows[position])
objects.row = objects.rows[position];
if (undefined == objects.row)
objects.row = xajax.$(position);
if (undefined == objects.row)
throw { name: 'TableError', message: 'Invalid row number / row id specified.' }
}
xajax.ext.tables.rows.append = function(id, table) {
var objects = { source: table }
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
var row = xajax.ext.tables.internal.createRow(objects, id);
if (undefined != objects.columns) {
for (var column = 0; column < objects.columns.length; ++column) {
var cell = xajax.ext.tables.internal.createCell(objects, null);
cell.innerHTML = '...';
row.appendChild(cell);
}
}
objects.body.appendChild(row);
}
xajax.ext.tables.rows.insert = function(id, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
if (undefined == objects.row)
xajax.ext.tables.rows.internal.calculateRow(objects, position);
var row = xajax.ext.tables.internal.createRow(objects, id);
if (undefined != objects.columns) {
for (var column = 0; column < objects.columns.length; ++column) {
var cell = xajax.ext.tables.internal.createCell(objects, null);
cell.innerHTML = '...';
row.appendChild(cell);
}
}
objects.body.insertBefore(row, objects.row);
}
xajax.ext.tables.rows.replace = function(id, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
if (undefined == objects.row)
xajax.ext.tables.rows.internal.calculateRow(objects, position);
var row = xajax.ext.tables.internal.createRow(objects, id);
if (undefined != objects.columns) {
for (var column = 0; column < objects.columns.length; ++column) {
var cell = xajax.ext.tables.internal.createCell(objects, null);
cell.innerHTML = '...';
row.appendChild(cell);
}
}
objects.body.insertBefore(row, objects.row);
objects.body.removeChild(objects.row);
}
xajax.ext.tables.rows.remove = function(source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
if (undefined == objects.row)
xajax.ext.tables.rows.internal.calculateRow(objects, position);
objects.body.removeChild(objects.row);
}
xajax.ext.tables.rows.assign = function(values, source, position, start_column) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'body', 'header']);
if (undefined == objects.row)
xajax.ext.tables.rows.internal.calculateRow(objects, position);
if (undefined == start_column)
start_column = 0;
if ('object' == typeof (values) && undefined != values['p'] && undefined != values['v'])
eval('objects.row.' + values['p'] + ' = values["v"];');
else for (var column = 0; column < values.length; ++column)
xajax.ext.tables.cells.assign(values[column], objects.row, start_column + column);
}
// columns
xajax.ext.tables.columns = {}
xajax.ext.tables.columns.internal = {}
xajax.ext.tables.columns.internal.calculateColumn = function(objects, position) {
if (undefined == position)
throw { name: 'TableError', message: 'Missing column number / id.' }
if (undefined == objects.column)
if (undefined != objects.columns)
if (undefined != objects.columns[position])
objects.column = position;
if (undefined == objects.column)
for (var column = 0; undefined == objects.column && column < objects.columns.length; ++column)
if (objects.columns[column].id == position)
objects.column = column;
if (undefined == objects.column)
throw { name: 'TableError', message: 'Invalid column number / row id specified.' }
}
xajax.ext.tables.columns.append = function(column_definition, table) {
var objects = { source: table }
xajax.ext.tables.internal.objectify(objects, ['table', 'header', 'body']);
var cell = xajax.ext.tables.internal.createCell(objects, column_definition.id);
if (undefined != column_definition.name)
cell.innerHTML = column_definition.name;
objects.header.firstChild.appendChild(cell);
if (undefined != objects.rows)
for (var i = 0; i < objects.rows.length; ++i)
xajax.ext.tables.cells.append({id: null}, objects.rows[i]);
}
xajax.ext.tables.columns.insert = function(column_definition, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'header']);
if (undefined == objects.column)
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
var column = xajax.ext.tables.internal.createCell(objects, column_definition.id);
if (undefined != column_definition.name)
column.innerHTML = column_definition.name;
objects.header.firstChild.insertBefore(column, objects.columns[objects.column]);
if (undefined != objects.rows)
for (var i = 0; i < objects.rows.length; ++i)
xajax.ext.tables.cells.insert({id: null}, objects.rows[i], objects.column);
}
xajax.ext.tables.columns.replace = function(column_definition, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'header', 'columns']);
if (undefined == objects.column)
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
var before = objects.columns[objects.column];
var column = xajax.ext.tables.internal.createCell(objects, column_definition.id);
if (undefined != column_definition.name)
column.innerHTML = column_definition.name;
objects.header.firstChild.insertBefore(column, before);
objects.header.firstChild.removeChild(before);
if (undefined != objects.rows)
for (var i = 0; i < objects.rows.length; ++i)
xajax.ext.tables.cells.replace({id: null}, objects.rows[i], objects.column);
}
xajax.ext.tables.columns.remove = function(source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'header']);
if (undefined == objects.column)
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
objects.header.firstChild.removeChild(objects.columns[objects.column]);
if (undefined != objects.rows)
for (var i = 0; i < objects.rows.length; ++i)
xajax.ext.tables.cells.remove(objects.rows[i], objects.column);
}
xajax.ext.tables.columns.assign = function(values, source, position, start_row) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'cell']);
if (undefined == objects.column)
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
if ('object' == typeof(values) && undefined != values['p'] && undefined != values['v'])
for (var row = 0; row < objects.rows.length; ++row)
xajax.ext.tables.cells.assign(values, objects.rows[row], objects.column);
else for (var row = 0; row < values.length; ++row)
xajax.ext.tables.cells.assign(values[row], objects.rows[start_row + row], objects.column);
}
// cells
xajax.ext.tables.cells = {}
xajax.ext.tables.cells.internal = {}
xajax.ext.tables.cells.internal.calculateCell = function(objects, position) {
if (undefined == position)
throw { name: 'TableError', message: 'Missing cell number / id.' }
if (undefined == objects.cell)
if (undefined != objects.cells)
if (undefined != objects.cells[position])
objects.cell = objects.cells[position];
if (undefined == objects.cell)
if (undefined != objects.columns)
for (var column = 0; undefined == objects.cell && column < objects.columns.length; ++column)
if (objects.columns[column].id == position)
objects.cell = objects.cells[column];
if (undefined == objects.cell)
throw { name: 'TableError', message: 'Invalid cell number / id specified.' }
}
xajax.ext.tables.cells.append = function(cell_definition, source) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
if (undefined != cell_definition.name)
cell.innerHTML = cell_definition.name;
objects.row.appendChild(cell);
}
xajax.ext.tables.cells.insert = function(cell_definition, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
if (undefined == objects.cell)
xajax.ext.tables.cells.internal.calculateCell(objects, position);
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
if (undefined != cell_definition.name)
cell.innerHTML = cell_definition.name;
objects.row.insertBefore(cell, objects.cell);
}
xajax.ext.tables.cells.replace = function(cell_definition, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
if (undefined == objects.cell)
xajax.ext.tables.cells.internal.calculateCell(objects, position);
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
if (undefined != cell_definition.name)
cell.innerHTML = cell_definition.name;
objects.row.insertBefore(cell, objects.cell);
objects.row.removeChild(objects.cell);
}
xajax.ext.tables.cells.remove = function(source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
if (undefined == objects.cell)
xajax.ext.tables.cells.internal.calculateCell(objects, position);
objects.row.removeChild(objects.cell);
}
xajax.ext.tables.cells.assign = function(value, source, position) {
var objects = { source: source }
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
if (undefined == objects.cell)
xajax.ext.tables.cells.internal.calculateCell(objects, position);
if ('object' == typeof (value) && undefined != value['p'] && undefined != value['v']) {
eval('objects.cell.' + value['p'] + ' = value["v"];');
} else
objects.cell.innerHTML = value;
}
// command handlers
// tables
xajax.commands['et_at'] = function(args) {
args.cmdFullName = 'ext.tables.append';
xajax.ext.tables.append(args.data, args.id);
return true;
}
xajax.commands['et_it'] = function(args) {
args.cmdFullName = 'ext.tables.insert';
xajax.ext.tables.insert(args.data, args.id, args.property);
return true;
}
xajax.commands['et_dt'] = function(args) {
args.cmdFullName = 'ext.tables.remove';
xajax.ext.tables.remove(args.data);
return true;
}
// rows
xajax.commands['et_ar'] = function(args) {
args.cmdFullName = 'ext.tables.rows.append';
xajax.ext.tables.rows.append(args.data, args.id);
return true;
}
xajax.commands['et_ir'] = function(args) {
args.cmdFullName = 'ext.tables.rows.insert';
xajax.ext.tables.rows.insert(args.data, args.id, args.property);
return true;
}
xajax.commands['et_rr'] = function(args) {
args.cmdFullName = 'ext.tables.rows.replace';
xajax.ext.tables.rows.replace(args.data, args.id, args.property);
return true;
}
xajax.commands['et_dr'] = function(args) {
args.cmdFullName = 'ext.tables.rows.remove';
xajax.ext.tables.rows.remove(args.id, args.property);
return true;
}
xajax.commands['et_asr'] = function(args) {
args.cmdFullName = 'ext.tables.rows.assign';
xajax.ext.tables.rows.assign(args.data, args.id, args.property);
return true;
}
// columns
xajax.commands['et_acol'] = function(args) {
args.cmdFullName = 'ext.tables.columns.append';
xajax.ext.tables.columns.append(args.data, args.id);
return true;
}
xajax.commands['et_icol'] = function(args) {
args.cmdFullName = 'ext.tables.columns.insert';
xajax.ext.tables.columns.insert(args.data, args.id, args.property);
return true;
}
xajax.commands['et_rcol'] = function(args) {
args.cmdFullName = 'ext.tables.columns.replace';
xajax.ext.tables.columns.replace(args.data, args.id, args.property);
return true;
}
xajax.commands['et_dcol'] = function(args) {
args.cmdFullName = 'ext.tables.columns.remove';
xajax.ext.tables.columns.remove(args.id, args.property);
return true;
}
xajax.commands['et_ascol'] = function(args) {
args.cmdFullName = 'ext.tables.columns.assign';
xajax.ext.tables.columns.assign(args.data, args.id, args.property, args.type);
return true;
}
// cells
xajax.commands['et_ac'] = function(args) {
args.cmdFullName = 'ext.tables.cells.append';
xajax.ext.tables.cells.append(args.data, args.id);
return true;
}
xajax.commands['et_ic'] = function(args) {
args.cmdFullName = 'ext.tables.cells.insert';
xajax.ext.tables.cells.insert(args.data, args.id, args.property);
return true;
}
xajax.commands['et_rc'] = function(args) {
args.cmdFullName = 'ext.tables.cells.replace';
xajax.ext.tables.cells.replace(args.data, args.id, args.property);
}
xajax.commands['et_dc'] = function(args) {
args.cmdFullName = 'ext.tables.cells.remove';
xajax.ext.tables.cells.remove(args.id, args.property);
return true;
}
xajax.commands['et_asc'] = function(args) {
args.cmdFullName = 'ext.tables.cells.assign';
xajax.ext.tables.cells.assign(args.data, args.id, args.property);
return true;
}
}
installTableUpdater();