first commit
This commit is contained in:
296
resources/xajax/xajax_plugins/response/comet/comet.inc.php
Normal file
296
resources/xajax/xajax_plugins/response/comet/comet.inc.php
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
define('FILE_APPEND', 1);
|
||||
|
||||
/*
|
||||
File: comet.inc.php
|
||||
|
||||
|
||||
Title: clsCometStreaming class
|
||||
|
||||
*/
|
||||
|
||||
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: clsCometStreaming
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
var $fTimeOut;
|
||||
/*
|
||||
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;
|
||||
} else if ('cometsleeptimout' == strtolower($sName) ) {
|
||||
if ( is_numeric($mValue) )
|
||||
$this->fTimeOut = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the script generation phase.
|
||||
|
||||
*/
|
||||
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;
|
||||
var $fTimeOut=1;
|
||||
|
||||
|
||||
/*
|
||||
Function: xajaxCometResponse
|
||||
|
||||
calls parent function xajaxResponse();
|
||||
*/
|
||||
|
||||
function xajaxCometResponse($fTimeOut=false)
|
||||
{
|
||||
|
||||
if ( false != $fTimeOut ) $this->fTimeOut=$fTimeOut;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printOutput
|
||||
|
||||
override the original printOutput function. It's no longer needed since the output is already sent.
|
||||
*/
|
||||
|
||||
function printOutput()
|
||||
{
|
||||
$this->flush();
|
||||
if ( "HTML5DRAFT" == $_REQUEST['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( $this->fTimeOut );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Function: flush_activeX
|
||||
|
||||
Flushes the command queue for ActiveX browsers.
|
||||
*/
|
||||
|
||||
function flush_activeX()
|
||||
{
|
||||
ob_start();
|
||||
$this->_printResponse_XML();
|
||||
$c = ob_get_contents();
|
||||
ob_end_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( $this->fTimeOut-0.1 );
|
||||
}
|
||||
|
||||
/*
|
||||
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_end_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( $this->fTimeOut );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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" == $_REQUEST['xjxstreaming'])
|
||||
{
|
||||
$this->flush_HTML5DRAFT();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->flush_activeX();
|
||||
}
|
||||
$this->aCommands=array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: sleep
|
||||
|
||||
Very accurate sleep function.
|
||||
*/
|
||||
function sleep($seconds)
|
||||
{
|
||||
usleep(floor($seconds*1000000));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new clsCometStreaming());
|
||||
102
resources/xajax/xajax_plugins/response/comet/comet.js
Normal file
102
resources/xajax/xajax_plugins/response/comet/comet.js
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
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");}
|
||||
xjxEc=xajax.ext.comet;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;return false;}
|
||||
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;oRequest.comet.inProgress=false;var pollLatestResponse=function(){console.log('pollLatestResponse');xjxEc.responseProcessor.XHR(oRequest);}
|
||||
oRequest.pollTimer=setInterval(pollLatestResponse,300);oRequest.request.onreadystatechange=function(){if(oRequest.request.readyState < 3){console.log('readyState < 3');return;}
|
||||
if(oRequest.request.readyState==4){console.log('readyState == 4');clearInterval(oRequest.pollTimer);xjxEc.responseProcessor.XHR(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){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);}
|
||||
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){}
|
||||
}
|
||||
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);}
|
||||
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";oRequest.inProgress=false;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);}
|
||||
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);}
|
||||
xajax.debug={};xajax.debug.prepareDebugText=function(text){try{text=text.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').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,'&','&');text=xajax.debug.stringReplace(text,'<','<');text=xajax.debug.stringReplace(text,'>','>');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;if(true===oRequest.comet.inProgress)return;oRequest.comet.inProgress=true;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,oRet,oRequest);}
|
||||
catch(ex){}
|
||||
xt.queue.process(xx.response);oRequest.comet.LastPosition+=endOfFirstMessageIndex;}
|
||||
}while(messageXMLEndIndex!=-1);oRequest.comet.inProgress=false;return oRet;}
|
||||
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;}
|
||||
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(oRequest.inProgress)return;if(response&&oRequest.lastResponse!==response){oRequest.inProgress=true;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);oRequest.inProgress=false;oRequest.lastResponse=response
|
||||
}
|
||||
return oRet;}
|
||||
xjxEc.submitRequestActiveX=function(oRequest){if(true==oRequest.comet)
|
||||
return;xjxEc.submitRequest(oRequest);}
|
||||
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!");}
|
||||
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;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,624 @@
|
||||
/*
|
||||
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;
|
||||
oRequest.comet.inProgress = false;
|
||||
var pollLatestResponse = function()
|
||||
{
|
||||
|
||||
console.log('pollLatestResponse');
|
||||
xjxEc.responseProcessor.XHR(oRequest);
|
||||
}
|
||||
oRequest.pollTimer = setInterval(pollLatestResponse, 300);
|
||||
oRequest.request.onreadystatechange = function()
|
||||
{
|
||||
if (oRequest.request.readyState < 3)
|
||||
{
|
||||
console.log('readyState < 3');
|
||||
return;
|
||||
}
|
||||
if (oRequest.request.readyState == 4)
|
||||
{
|
||||
console.log('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";
|
||||
oRequest.inProgress = false;
|
||||
|
||||
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, '&').replace(/</g, '<').replace(/>/g, '>').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, '&', '&');
|
||||
text = xajax.debug.stringReplace(text, '<', '<');
|
||||
text = xajax.debug.stringReplace(text, '>', '>');
|
||||
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;
|
||||
if (true === oRequest.comet.inProgress) return;
|
||||
oRequest.comet.inProgress = true;
|
||||
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, oRet, oRequest);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
xt.queue.process(xx.response);
|
||||
oRequest.comet.LastPosition += endOfFirstMessageIndex;
|
||||
}
|
||||
} while (messageXMLEndIndex != -1);
|
||||
|
||||
oRequest.comet.inProgress = false;
|
||||
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 (oRequest.inProgress) return;
|
||||
if (response && oRequest.lastResponse !== response)
|
||||
{
|
||||
oRequest.inProgress = true;
|
||||
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);
|
||||
oRequest.inProgress=false;
|
||||
oRequest.lastResponse = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,622 @@
|
||||
/*
|
||||
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;
|
||||
oRequest.comet.inProgress = false;
|
||||
var pollLatestResponse = function()
|
||||
{
|
||||
xjxEc.responseProcessor.XHR(oRequest);
|
||||
}
|
||||
oRequest.pollTimer = setInterval(pollLatestResponse, 300);
|
||||
oRequest.request.onreadystatechange = function()
|
||||
{
|
||||
if (oRequest.request.readyState < 3)
|
||||
{
|
||||
console.log('readyState < 3');
|
||||
return;
|
||||
}
|
||||
if (oRequest.request.readyState == 4)
|
||||
{
|
||||
console.log('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";
|
||||
oRequest.inProgress = false;
|
||||
|
||||
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, '&').replace(/</g, '<').replace(/>/g, '>').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, '&', '&');
|
||||
text = xajax.debug.stringReplace(text, '<', '<');
|
||||
text = xajax.debug.stringReplace(text, '>', '>');
|
||||
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;
|
||||
if (true === oRequest.comet.inProgress) return;
|
||||
oRequest.comet.inProgress = true;
|
||||
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, oRet, oRequest);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
xt.queue.process(xx.response);
|
||||
oRequest.comet.LastPosition += endOfFirstMessageIndex;
|
||||
}
|
||||
} while (messageXMLEndIndex != -1);
|
||||
|
||||
oRequest.comet.inProgress = false;
|
||||
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 (oRequest.inProgress) return;
|
||||
if (response && oRequest.lastResponse !== response)
|
||||
{
|
||||
oRequest.inProgress = true;
|
||||
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);
|
||||
oRequest.inProgress=false;
|
||||
oRequest.lastResponse = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
?>
|
||||
18
resources/xajax/xajax_plugins/response/googleMap.inc.php
Normal file
18
resources/xajax/xajax_plugins/response/googleMap.inc.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class clsGoogleMap extends xajaxResponsePlugin{var $sJavascriptURI;var $bInlineScript;function clsGoogleMap(){$this->sJavascriptURI='';$this->bInlineScript=true;}
|
||||
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(){echo "\n<script src='http://maps.google.com/maps?file=api&v=2&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.command.handler.register('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.command.handler.register('gm:zm', function(args) {\n";echo "\tmaps[args.id].setZoom(parseInt(args.data));\n";echo "});\n";echo "xajax.command.handler.register('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){$command=array('n'=>'et_ar','t'=>$parent);if(null!=$position)
|
||||
$command['p']=$position;$this->addCommand($command,$row);}
|
||||
}
|
||||
$objPluginManager=&xajaxPluginManager::getInstance();$objPluginManager->registerPlugin(new clsGoogleMap());
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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';}
|
||||
class clsSwfUpload
|
||||
extends xajaxResponsePlugin{private $sCallName="SWFUpload";private $sDefer;private $sJavascriptURI;private $bInlineScript;private $SWFupload_FadeTimeOut=1500;private $sRequestedFunction=NULL;private $sXajaxPrefix="xajax_";public function clsSwfUpload(){$this->sDefer='';$this->sJavascriptURI='';$this->bInlineScript=false;}
|
||||
function getName(){return get_class($this);}
|
||||
public function configure($sName,$mValue){switch($sName){case 'scriptDeferral':
|
||||
if(true===$mValue||false===$mValue){if($mValue)
|
||||
$this->sDefer='defer ';else
|
||||
$this->sDefer='';}
|
||||
break;case 'javascript URI':
|
||||
$this->sJavascriptURI=$mValue;break;case 'inlineScript':
|
||||
if(true===$mValue||false===$mValue)
|
||||
$this->bInlineScript=$mValue;break;case 'SWFupload_FadeTimeOut':
|
||||
if(is_numeric($mValue))
|
||||
$this->SWFupload_FadeTimeOut=$mValue;break;}
|
||||
}
|
||||
public function generateClientScript(){echo "\n<script type='text/javascript' ".$this->sDefer."charset='UTF-8'>\n";echo "/* <![CDATA[ */\n";echo "if (undefined == xajax.ext) xajax.ext = {};\n";echo "xajax.ext.SWFupload = {};";echo "xajax.ext.SWFupload.config = {};\n";echo "xajax.ext.SWFupload.config.javascript_URI='".$this->sJavascriptURI."xajax_plugins/response/swfupload/';\n";echo "xajax.ext.SWFupload.config.FadeTimeOut = '".$this->SWFupload_FadeTimeOut."';\n";echo "/* ]]> */\n";echo "</script>\n";if($this->bInlineScript){echo "\n<script type='text/javascript' ".$this->sDefer."charset='UTF-8'>\n";echo "/* <![CDATA[ */\n";include(dirname(__FILE__).'xajax_plugins/response/swfupload/swfupload.js');include(dirname(__FILE__).'xajax_plugins/response/swfupload/swfupload.xajax.js');echo "/* ]]> */\n";echo "</script>\n";}else{echo "\n<script type='text/javascript' src='".$this->sJavascriptURI."xajax_plugins/response/swfupload/swfupload.js' ".$this->sDefer."charset='UTF-8'></script>\n";echo "\n<script type='text/javascript' src='".$this->sJavascriptURI."xajax_plugins/response/swfupload/swfupload.xajax.js' ".$this->sDefer."charset='UTF-8'></script>\n";}
|
||||
}
|
||||
function transForm($id,$config,$multi=false){$command=array
|
||||
(
|
||||
'cmd'=> 'SWFup_tfo',
|
||||
'id'=> $id
|
||||
);$this->addCommand($command,array
|
||||
(
|
||||
"config"=> $config,
|
||||
"multi"=> $multi
|
||||
));}
|
||||
function transField($id,$config,$multi=false){$command=array
|
||||
(
|
||||
'cmd'=> 'SWFup_tfi',
|
||||
'id'=> $id
|
||||
);$this->addCommand($command,array
|
||||
(
|
||||
"config"=> $config,
|
||||
"multi"=> $multi
|
||||
));}
|
||||
function destroyField($id){$command=array
|
||||
(
|
||||
'cmd'=> 'SWFup_dfi',
|
||||
'id'=> $id
|
||||
);$this->addCommand($command,array());}
|
||||
function destroyForm($id){$command=array
|
||||
(
|
||||
'cmd'=> 'SWFup_dfo',
|
||||
'id'=> $id
|
||||
);$this->addCommand($command,array());}
|
||||
}
|
||||
$objPluginManager=&xajaxPluginManager::getInstance();$objPluginManager->registerPlugin(new clsSwfUpload(),100);?>
|
||||
151
resources/xajax/xajax_plugins/response/swfupload/swfupload.js
Normal file
151
resources/xajax/xajax_plugins/response/swfupload/swfupload.js
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(settings){this.initSWFUpload(settings);};}
|
||||
SWFUpload.prototype.initSWFUpload=function(settings){try{this.customSettings={};this.settings=settings;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo();}catch(ex){delete SWFUpload.instances[this.movieName];throw ex;}
|
||||
};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.2.0 Beta 3";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,
|
||||
FILE_EXCEEDS_SIZE_LIMIT:-110,
|
||||
ZERO_BYTE_FILE:-120,
|
||||
INVALID_FILETYPE:-130
|
||||
};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,
|
||||
MISSING_UPLOAD_URL:-210,
|
||||
IO_ERROR:-220,
|
||||
SECURITY_ERROR:-230,
|
||||
UPLOAD_LIMIT_EXCEEDED:-240,
|
||||
UPLOAD_FAILED:-250,
|
||||
SPECIFIED_FILE_ID_NOT_FOUND:-260,
|
||||
FILE_VALIDATION_FAILED:-270,
|
||||
FILE_CANCELLED:-280,
|
||||
UPLOAD_STOPPED:-290
|
||||
};SWFUpload.FILE_STATUS={QUEUED:-1,
|
||||
IN_PROGRESS:-2,
|
||||
ERROR:-3,
|
||||
COMPLETE:-4,
|
||||
CANCELLED:-5
|
||||
};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,
|
||||
SELECT_FILES:-110,
|
||||
START_UPLOAD:-120
|
||||
};SWFUpload.CURSOR={ARROW:-1,
|
||||
HAND:-2
|
||||
};SWFUpload.WINDOW_MODE={WINDOW:"window",
|
||||
TRANSPARENT:"transparent",
|
||||
OPAQUE:"opaque"
|
||||
};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(settingName,defaultValue){this.settings[settingName]=(this.settings[settingName]==undefined)? defaultValue:this.settings[settingName];};this.ensureDefault("upload_url","");this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+"?swfuploadrnd="+Math.floor(Math.random()*999999999);}
|
||||
delete this.ensureDefault;};SWFUpload.prototype.loadFlash=function(){if(this.settings.button_placeholder_id!==""){this.replaceWithFlash();}else{this.appendFlash();}
|
||||
};SWFUpload.prototype.appendFlash=function(){var targetElement,container;if(document.getElementById(this.movieName)!==null){throw "ID "+this.movieName+" is already in use. The Flash Object could not be added";}
|
||||
targetElement=document.getElementsByTagName("body")[0];if(targetElement==undefined){throw "Could not find the 'body' element.";}
|
||||
container=document.createElement("div");container.style.width="1px";container.style.height="1px";container.style.overflow="hidden";targetElement.appendChild(container);container.innerHTML=this.getFlashHTML();if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement();}
|
||||
};SWFUpload.prototype.replaceWithFlash=function(){var targetElement,tempParent;if(document.getElementById(this.movieName)!==null){throw "ID "+this.movieName+" is already in use. The Flash Object could not be added";}
|
||||
targetElement=document.getElementById(this.settings.button_placeholder_id);if(targetElement==undefined){throw "Could not find the placeholder element.";}
|
||||
tempParent=document.createElement("div");tempParent.innerHTML=this.getFlashHTML();targetElement.parentNode.replaceChild(tempParent.firstChild,targetElement);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement();}
|
||||
};SWFUpload.prototype.getFlashHTML=function(){return ['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">',
|
||||
'<param name="wmode" value="',this.settings.button_window_mode,'" />',
|
||||
'<param name="movie" value="',this.settings.flash_url,'" />',
|
||||
'<param name="quality" value="high" />',
|
||||
'<param name="menu" value="false" />',
|
||||
'<param name="allowScriptAccess" value="always" />',
|
||||
'<param name="flashvars" value="'+this.getFlashVars()+'" />',
|
||||
'</object>'].join("");};SWFUpload.prototype.getFlashVars=function(){var paramString=this.buildParamString();var httpSuccessString=this.settings.http_success.join(",");return ["movieName=",encodeURIComponent(this.movieName),
|
||||
"&uploadURL=",encodeURIComponent(this.settings.upload_url),
|
||||
"&useQueryString=",encodeURIComponent(this.settings.use_query_string),
|
||||
"&requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),
|
||||
"&httpSuccess=",encodeURIComponent(httpSuccessString),
|
||||
"&params=",encodeURIComponent(paramString),
|
||||
"&filePostName=",encodeURIComponent(this.settings.file_post_name),
|
||||
"&fileTypes=",encodeURIComponent(this.settings.file_types),
|
||||
"&fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),
|
||||
"&fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),
|
||||
"&fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),
|
||||
"&fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),
|
||||
"&debugEnabled=",encodeURIComponent(this.settings.debug_enabled),
|
||||
"&buttonImageURL=",encodeURIComponent(this.settings.button_image_url),
|
||||
"&buttonWidth=",encodeURIComponent(this.settings.button_width),
|
||||
"&buttonHeight=",encodeURIComponent(this.settings.button_height),
|
||||
"&buttonText=",encodeURIComponent(this.settings.button_text),
|
||||
"&buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),
|
||||
"&buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),
|
||||
"&buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),
|
||||
"&buttonAction=",encodeURIComponent(this.settings.button_action),
|
||||
"&buttonDisabled=",encodeURIComponent(this.settings.button_disabled),
|
||||
"&buttonCursor=",encodeURIComponent(this.settings.button_cursor)
|
||||
].join("");};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName);}
|
||||
if(this.movieElement===null){throw "Could not find Flash element";}
|
||||
return this.movieElement;};SWFUpload.prototype.buildParamString=function(){var postParams=this.settings.post_params;var paramStringPairs=[];if(typeof(postParams)==="object"){for(var name in postParams){if(postParams.hasOwnProperty(name)){paramStringPairs.push(encodeURIComponent(name.toString())+"="+encodeURIComponent(postParams[name].toString()));}
|
||||
}
|
||||
}
|
||||
return paramStringPairs.join("&");};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);;var movieElement=null;movieElement=this.getMovieElement();if(movieElement){for(var i in movieElement){try{if(typeof(movieElement[i])==="function"){movieElement[i]=null;}
|
||||
}catch(ex1){}
|
||||
}
|
||||
try{movieElement.parentNode.removeChild(movieElement);}catch(ex){}
|
||||
}
|
||||
window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true;}catch(ex1){alert(ex);return false;}
|
||||
};SWFUpload.prototype.displayDebugInfo=function(){this.debug(
|
||||
[
|
||||
"---SWFUpload Instance Info---\n",
|
||||
"Version: ",SWFUpload.version,"\n",
|
||||
"Movie Name: ",this.movieName,"\n",
|
||||
"Settings:\n",
|
||||
"\t","upload_url: ",this.settings.upload_url,"\n",
|
||||
"\t","flash_url: ",this.settings.flash_url,"\n",
|
||||
"\t","use_query_string: ",this.settings.use_query_string.toString(),"\n",
|
||||
"\t","requeue_on_error: ",this.settings.requeue_on_error.toString(),"\n",
|
||||
"\t","http_success: ",this.settings.http_success.join(", "),"\n",
|
||||
"\t","file_post_name: ",this.settings.file_post_name,"\n",
|
||||
"\t","post_params: ",this.settings.post_params.toString(),"\n",
|
||||
"\t","file_types: ",this.settings.file_types,"\n",
|
||||
"\t","file_types_description: ",this.settings.file_types_description,"\n",
|
||||
"\t","file_size_limit: ",this.settings.file_size_limit,"\n",
|
||||
"\t","file_upload_limit: ",this.settings.file_upload_limit,"\n",
|
||||
"\t","file_queue_limit: ",this.settings.file_queue_limit,"\n",
|
||||
"\t","debug: ",this.settings.debug.toString(),"\n",
|
||||
"\t","prevent_swf_caching: ",this.settings.prevent_swf_caching.toString(),"\n",
|
||||
"\t","button_placeholder_id: ",this.settings.button_placeholder_id.toString(),"\n",
|
||||
"\t","button_image_url: ",this.settings.button_image_url.toString(),"\n",
|
||||
"\t","button_width: ",this.settings.button_width.toString(),"\n",
|
||||
"\t","button_height: ",this.settings.button_height.toString(),"\n",
|
||||
"\t","button_text: ",this.settings.button_text.toString(),"\n",
|
||||
"\t","button_text_style: ",this.settings.button_text_style.toString(),"\n",
|
||||
"\t","button_text_top_padding: ",this.settings.button_text_top_padding.toString(),"\n",
|
||||
"\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n",
|
||||
"\t","button_action: ",this.settings.button_action.toString(),"\n",
|
||||
"\t","button_disabled: ",this.settings.button_disabled.toString(),"\n",
|
||||
"\t","custom_settings: ",this.settings.custom_settings.toString(),"\n",
|
||||
"Event Handlers:\n",
|
||||
"\t","swfupload_loaded_handler assigned: ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n",
|
||||
"\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n",
|
||||
"\t","file_queued_handler assigned: ",(typeof this.settings.file_queued_handler==="function").toString(),"\n",
|
||||
"\t","file_queue_error_handler assigned: ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n",
|
||||
"\t","upload_start_handler assigned: ",(typeof this.settings.upload_start_handler==="function").toString(),"\n",
|
||||
"\t","upload_progress_handler assigned: ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n",
|
||||
"\t","upload_error_handler assigned: ",(typeof this.settings.upload_error_handler==="function").toString(),"\n",
|
||||
"\t","upload_success_handler assigned: ",(typeof this.settings.upload_success_handler==="function").toString(),"\n",
|
||||
"\t","upload_complete_handler assigned: ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n",
|
||||
"\t","debug_handler assigned: ",(typeof this.settings.debug_handler==="function").toString(),"\n"
|
||||
].join("")
|
||||
);};SWFUpload.prototype.addSetting=function(name,value,default_value){if(value==undefined){return(this.settings[name]=default_value);}else{return(this.settings[name]=value);}
|
||||
};SWFUpload.prototype.getSetting=function(name){if(this.settings[name]!=undefined){return this.settings[name];}
|
||||
return "";};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement();var returnValue,returnString;try{returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+'</invoke>');returnValue=eval(returnString);}catch(ex){throw "Call to "+functionName+" failed";}
|
||||
if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue);}
|
||||
return returnValue;};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile");};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles");};SWFUpload.prototype.startUpload=function(fileID){this.callFlash("StartUpload",[fileID]);};SWFUpload.prototype.cancelUpload=function(fileID,triggerErrorEvent){if(triggerErrorEvent!==false){triggerErrorEvent=true;}
|
||||
this.callFlash("CancelUpload",[fileID,triggerErrorEvent]);};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload");};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats");};SWFUpload.prototype.setStats=function(statsObject){this.callFlash("SetStats",[statsObject]);};SWFUpload.prototype.getFile=function(fileID){if(typeof(fileID)==="number"){return this.callFlash("GetFileByIndex",[fileID]);}else{return this.callFlash("GetFile",[fileID]);}
|
||||
};SWFUpload.prototype.addFileParam=function(fileID,name,value){return this.callFlash("AddFileParam",[fileID,name,value]);};SWFUpload.prototype.removeFileParam=function(fileID,name){this.callFlash("RemoveFileParam",[fileID,name]);};SWFUpload.prototype.setUploadURL=function(url){this.settings.upload_url=url.toString();this.callFlash("SetUploadURL",[url]);};SWFUpload.prototype.setPostParams=function(paramsObject){this.settings.post_params=paramsObject;this.callFlash("SetPostParams",[paramsObject]);};SWFUpload.prototype.addPostParam=function(name,value){this.settings.post_params[name]=value;this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.removePostParam=function(name){delete this.settings.post_params[name];this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.setFileTypes=function(types,description){this.settings.file_types=types;this.settings.file_types_description=description;this.callFlash("SetFileTypes",[types,description]);};SWFUpload.prototype.setFileSizeLimit=function(fileSizeLimit){this.settings.file_size_limit=fileSizeLimit;this.callFlash("SetFileSizeLimit",[fileSizeLimit]);};SWFUpload.prototype.setFileUploadLimit=function(fileUploadLimit){this.settings.file_upload_limit=fileUploadLimit;this.callFlash("SetFileUploadLimit",[fileUploadLimit]);};SWFUpload.prototype.setFileQueueLimit=function(fileQueueLimit){this.settings.file_queue_limit=fileQueueLimit;this.callFlash("SetFileQueueLimit",[fileQueueLimit]);};SWFUpload.prototype.setFilePostName=function(filePostName){this.settings.file_post_name=filePostName;this.callFlash("SetFilePostName",[filePostName]);};SWFUpload.prototype.setUseQueryString=function(useQueryString){this.settings.use_query_string=useQueryString;this.callFlash("SetUseQueryString",[useQueryString]);};SWFUpload.prototype.setRequeueOnError=function(requeueOnError){this.settings.requeue_on_error=requeueOnError;this.callFlash("SetRequeueOnError",[requeueOnError]);};SWFUpload.prototype.setHTTPSuccess=function(http_status_codes){if(typeof http_status_codes==="string"){http_status_codes=http_status_codes.replace(" ","").split(",");}
|
||||
this.settings.http_success=http_status_codes;this.callFlash("SetHTTPSuccess",[http_status_codes]);};SWFUpload.prototype.setDebugEnabled=function(debugEnabled){this.settings.debug_enabled=debugEnabled;this.callFlash("SetDebugEnabled",[debugEnabled]);};SWFUpload.prototype.setButtonImageURL=function(buttonImageURL){if(buttonImageURL==undefined){buttonImageURL="";}
|
||||
this.settings.button_image_url=buttonImageURL;this.callFlash("SetButtonImageURL",[buttonImageURL]);};SWFUpload.prototype.setButtonDimensions=function(width,height){this.settings.button_width=width;this.settings.button_height=height;var movie=this.getMovieElement();if(movie!=undefined){movie.style.width=width+"px";movie.style.height=height+"px";}
|
||||
this.callFlash("SetButtonDimensions",[width,height]);};SWFUpload.prototype.setButtonText=function(html){this.settings.button_text=html;this.callFlash("SetButtonText",[html]);};SWFUpload.prototype.setButtonTextPadding=function(left,top){this.settings.button_text_top_padding=top;this.settings.button_text_left_padding=left;this.callFlash("SetButtonTextPadding",[left,top]);};SWFUpload.prototype.setButtonTextStyle=function(css){this.settings.button_text_style=css;this.callFlash("SetButtonTextStyle",[css]);};SWFUpload.prototype.setButtonDisabled=function(isDisabled){this.settings.button_disabled=isDisabled;this.callFlash("SetButtonDisabled",[isDisabled]);};SWFUpload.prototype.setButtonAction=function(buttonAction){this.settings.button_action=buttonAction;this.callFlash("SetButtonAction",[buttonAction]);};SWFUpload.prototype.setButtonCursor=function(cursor){this.settings.button_cursor=cursor;this.callFlash("SetButtonCursor",[cursor]);};SWFUpload.prototype.queueEvent=function(handlerName,argumentArray){if(argumentArray==undefined){argumentArray=[];}else if(!(argumentArray instanceof Array)){argumentArray=[argumentArray];}
|
||||
var self=this;if(typeof this.settings[handlerName]==="function"){this.eventQueue.push(function(){this.settings[handlerName].apply(this,argumentArray);});setTimeout(function(){self.executeNextEvent();},0);}else if(this.settings[handlerName]!==null){throw "Event handler "+handlerName+" is unknown or is not a function";}
|
||||
};SWFUpload.prototype.executeNextEvent=function(){var f=this.eventQueue ? this.eventQueue.shift():null;if(typeof(f)==="function"){f.apply(this);}
|
||||
};SWFUpload.prototype.unescapeFilePostParams=function(file){var reg=/[$]([0-9a-f]{4})/i;var unescapedPost={};var uk;if(file!=undefined){for(var k in file.post){if(file.post.hasOwnProperty(k)){uk=k;var match;while((match=reg.exec(uk))!==null){uk=uk.replace(match[0],String.fromCharCode(parseInt("0x"+match[1],16)));}
|
||||
unescapedPost[uk]=file.post[k];}
|
||||
}
|
||||
file.post=unescapedPost;}
|
||||
return file;};SWFUpload.prototype.flashReady=function(){var movieElement=this.getMovieElement();if(typeof(movieElement.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var key in movieElement){try{if(typeof(movieElement[key])==="function"){movieElement[key]=null;}
|
||||
}catch(ex){}
|
||||
}
|
||||
}
|
||||
this.queueEvent("swfupload_loaded_handler");};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler");};SWFUpload.prototype.fileQueued=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("file_queued_handler",file);};SWFUpload.prototype.fileQueueError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("file_queue_error_handler",[file,errorCode,message]);};SWFUpload.prototype.fileDialogComplete=function(numFilesSelected,numFilesQueued){this.queueEvent("file_dialog_complete_handler",[numFilesSelected,numFilesQueued]);};SWFUpload.prototype.uploadStart=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("return_upload_start_handler",file);};SWFUpload.prototype.returnUploadStart=function(file){var returnValue;if(typeof this.settings.upload_start_handler==="function"){file=this.unescapeFilePostParams(file);returnValue=this.settings.upload_start_handler.call(this,file);}else if(this.settings.upload_start_handler!=undefined){throw "upload_start_handler must be a function";}
|
||||
if(returnValue===undefined){returnValue=true;}
|
||||
returnValue=!!returnValue;this.callFlash("ReturnUploadStart",[returnValue]);};SWFUpload.prototype.uploadProgress=function(file,bytesComplete,bytesTotal){file=this.unescapeFilePostParams(file);this.queueEvent("upload_progress_handler",[file,bytesComplete,bytesTotal]);};SWFUpload.prototype.uploadError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("upload_error_handler",[file,errorCode,message]);};SWFUpload.prototype.uploadSuccess=function(file,serverData){file=this.unescapeFilePostParams(file);this.queueEvent("upload_success_handler",[file,serverData]);};SWFUpload.prototype.uploadComplete=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("upload_complete_handler",file);};SWFUpload.prototype.debug=function(message){this.queueEvent("debug_handler",message);};SWFUpload.prototype.debugMessage=function(message){if(this.settings.debug){var exceptionMessage,exceptionValues=[];if(typeof message==="object"&&typeof message.name==="string"&&typeof message.message==="string"){for(var key in message){if(message.hasOwnProperty(key)){exceptionValues.push(key+": "+message[key]);}
|
||||
}
|
||||
exceptionMessage=exceptionValues.join("\n")||"";exceptionValues=exceptionMessage.split("\n");exceptionMessage="EXCEPTION: "+exceptionValues.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(exceptionMessage);}else{SWFUpload.Console.writeLine(message);}
|
||||
}
|
||||
};SWFUpload.Console={};SWFUpload.Console.writeLine=function(message){var console,documentForm;try{console=document.getElementById("SWFUpload_Console");if(!console){documentForm=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(documentForm);console=document.createElement("textarea");console.id="SWFUpload_Console";console.style.fontFamily="monospace";console.setAttribute("wrap","off");console.wrap="off";console.style.overflow="auto";console.style.width="700px";console.style.height="350px";console.style.margin="5px";documentForm.appendChild(console);}
|
||||
console.value+=message+"\n";console.scrollTop=console.scrollHeight-console.clientHeight;}catch(ex){alert("Exception: "+ex.name+" Message: "+ex.message);}
|
||||
};
|
||||
BIN
resources/xajax/xajax_plugins/response/swfupload/swfupload.swf
Normal file
BIN
resources/xajax/xajax_plugins/response/swfupload/swfupload.swf
Normal file
Binary file not shown.
@@ -0,0 +1,112 @@
|
||||
|
||||
xajax.ext.SWFupload.swf=null;xajax.ext.SWFupload.forms={};xajax.ext.SWFupload.fields={};xajax.ext.SWFupload.queues={};xajax.ext.SWFupload.tools={};xajax.ext.SWFupload.settings={flash_url:xajax.ext.SWFupload.config.javascript_URI+"swfupload.swf",
|
||||
file_size_limit:"0",
|
||||
file_types:"*.*",
|
||||
file_types_description:"All Files",
|
||||
file_upload_limit:0,
|
||||
file_queue_limit:0,
|
||||
file_queue_error_handler:xajax.ext.SWFupload.tools.fileQueueError,
|
||||
debug:false,
|
||||
button_image_url:"img/button_500x22.gif",
|
||||
button_width:270,
|
||||
button_height:22,
|
||||
button_action:SWFUpload.BUTTON_ACTION.SELECT_FILES,
|
||||
button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,
|
||||
button_placeholder_id:'',
|
||||
button_text:'<span class="btnText">Select Files...</span>',
|
||||
button_text_style:".btnText { font-size: 10; font-weight: bold; font-family: MS Shell Dlg; }",
|
||||
button_text_top_padding:3,
|
||||
button_text_left_padding:100,
|
||||
post_params:{}
|
||||
}
|
||||
if('undefined'==typeof xajax.ext.SWFupload.lang){xajax.ext.SWFupload.lang={};xajax.ext.SWFupload.lang.browseFiles='Browse Files';xajax.ext.SWFupload.lang.browseFile='Browse File';}
|
||||
xajax.ext.SWFupload.configure=function(config){if("object"==typeof config)return xajax.ext.SWFupload.tools.mergeObj(this.settings,config);return this.settings;}
|
||||
xajax.ext.SWFupload.addQueue=function(child,parent,config,multiple){var id=xajax.ext.SWFupload.tools.getId();this.queues[id]=new xajax.ext.SWFupload.tools.fileQueue(id,child,parent,config,multiple);return id;}
|
||||
xajax.ext.SWFupload.applyConfig=function(oQueue){var conf=oQueue.getConfig();var swf=xajax.ext.SWFupload.getInstance();if('undefined'!=typeof conf.file_types)
|
||||
swf.setFileTypes(conf.file_types,conf.file_types_description);if('undefined'!=typeof conf.file_size_limit)
|
||||
swf.setFileSizeLimit(conf.file_size_limit);if('object'==typeof conf.post_params){for(a in conf.post_params)
|
||||
swf.addPostParam(a,conf.post_params[a]);}
|
||||
swf.settings.file_queued_handler=function(oFile){oQueue.addFile(oFile)};;swf.settings.file_queue_error_handler=oQueue.fileQueueError;}
|
||||
xajax.ext.SWFupload.selectFile=function(oQueue){this.applyConfig(oQueue);if(oQueue.getConfig().file_queue_limit > 0&&oQueue.getConfig().file_queue_limit <=oQueue.queued)return;xajax.ext.SWFupload.getInstance().selectFile();}
|
||||
xajax.ext.SWFupload.selectFiles=function(oQueue){this.applyConfig(oQueue);if(oQueue.getConfig().file_queue_limit > 0&&oQueue.getConfig().file_queue_limit <=oQueue.queued)return;xajax.ext.SWFupload.getInstance().selectFiles();}
|
||||
xajax.ext.SWFupload.getInstance=function(){if(null==this.swf)this.swf=new SWFUpload(this.settings);return this.swf;}
|
||||
xajax.ext.SWFupload.removeFile=function(QueueId,FileId,finished){this.queues[QueueId].removeFile(FileId,finished);}
|
||||
xajax.ext.SWFupload.request={};xajax.ext.SWFupload.request.getFileFromQueue=function(oRequest){var instances={};var queued=0;if("string"==typeof oRequest.SWFform){if('object'!=typeof xajax.ext.SWFupload.forms[oRequest.SWFform]){return false;}
|
||||
for(a in xajax.ext.SWFupload.forms[oRequest.SWFform]){var field=xajax.ext.SWFupload.forms[oRequest.SWFform][a];if(0 < xajax.ext.SWFupload.queues[field].queued){oRequest.currentFile=xajax.ext.SWFupload.queues[field].getFile();oRequest.swf=xajax.ext.SWFupload.queues[field].getSWF();return true;};}
|
||||
}else if("string"==typeof oRequest.SWFfield){if('string'!=typeof xajax.ext.SWFupload.fields[oRequest.SWFfield]){return false;}
|
||||
var qId=xajax.ext.SWFupload.fields[oRequest.SWFfield];if(0 < xajax.ext.SWFupload.queues[qId].queued){oRequest.currentFile=xajax.ext.SWFupload.queues[qId].getFile();oRequest.swf=xajax.ext.SWFupload.queues[qId].getSWF();return true;};}else{for(var a in xajax.ext.SWFupload.queues){if(0 < xajax.ext.SWFupload.queues[a].queued){oRequest.currentFile=xajax.ext.SWFupload.queues[a].getFile();oRequest.swf=xajax.ext.SWFupload.queues[a].getSWF();return true;};}
|
||||
}
|
||||
return false;}
|
||||
xajax.ext.SWFupload.request.processParameters=function(oRequest){if("SWFupload"==oRequest.mode){oRequest.currentFile=false;xajax.ext.SWFupload.request.getFileFromQueue(oRequest);if(oRequest.currentFile)oRequest.method='GET';}
|
||||
return xajax.ext.SWFupload.bak.processParameters(oRequest);}
|
||||
xajax.ext.SWFupload.request.prepareRequest=function(oRequest){if("SWFupload"==oRequest.mode&&false!=oRequest.currentFile)return;return xajax.ext.SWFupload.bak.prepareRequest(oRequest);}
|
||||
xajax.ext.SWFupload.request.submitRequest=function(oRequest){if("SWFupload"==oRequest.mode&&false!=oRequest.currentFile){if(oRequest.requestURI){oRequest.bak_requestURI=oRequest.requestURI;}else if(oRequest.bak_requestURI){oRequest.requestURI=oRequest.bak_requestURI;}
|
||||
var swf=oRequest.swf;var fileQueue=xajax.ext.SWFupload.queues[oRequest.currentFile.QueueId];swf.customSettings.currentFile=oRequest.currentFile;swf.setFilePostName(swf.customSettings.currentFile.name);swf.customSettings.oRequest=oRequest;swf.setUploadURL(oRequest.requestURI);swf.settings.upload_success_handler=function(oFile,response){var xx=xajax;var xt=xx.tools;var xcb=xx.callback;var gcb=xcb.global;var lcb=oRequest.callback;var oRet=oRequest.returnValue;var FileId=swf.customSettings.currentFile;if('function'==typeof this.old_upload_success_handler)this.old_upload_success_handler(oFile);xcb.execute([gcb,lcb],'onSuccess',oRequest);var seq=0;if(response){var responseXML=(new DOMParser()).parseFromString(response,"text/xml");if(responseXML.documentElement){oRequest.status.onProcessing();var child=responseXML.documentElement.firstChild;oRet=xt.xml.processFragment(child,seq,oRet,oRequest);}
|
||||
}
|
||||
var obj={};obj.fullName='Response Complete';obj.sequence=seq;obj.request=oRequest;obj.context=oRequest.context;obj.cmd='rcmplt';xt.queue.push(xx.response,obj);if(null==xx.response.timeout)
|
||||
xt.queue.process(xx.response);}
|
||||
swf.settings.upload_complete_handler=function(oFile){var qFile=this.customSettings.currentFile;xajax.ext.SWFupload.removeFile(qFile.QueueId,qFile.id,true);if(!xajax.ext.SWFupload.request.getFileFromQueue(oRequest)){if('function'==typeof oRequest.onUploadComplete)oRequest.onUploadComplete();return;}
|
||||
xajax.ext.SWFupload.request.submitRequest(oRequest);}
|
||||
swf.settings.upload_start_handler=function(oFile){if('function'==typeof this.old_upload_start_handler)this.old_upload_start_handler(oFile);oRequest.startTime=new Date();}
|
||||
swf.settings.upload_progress_handler=function(oFile,bytesLoaded,bytesTotal){upload={};upload.received=bytesLoaded;upload.total=bytesTotal;upload.state="uploading";var reqTime=new Date();upload.lastbytes=oRequest.lastbytes;upload.now=reqTime.getTime()/1000;upload.start=oRequest.startTime.getTime()/1000;var step=upload.received/(upload.total/100);var progressbar=xajax.$('SWFup_progress_'+oFile.id);var w=Math.round(220*step/100);progressbar.style.width=w+'px';var progress=xajax.$("swf_queued_filesize_"+oFile.id);var elapsed=upload.now-upload.start;var rate=xajax.ext.SWFupload.tools.formatBytes(upload.received/elapsed).toString()+'/s';progress.innerHTML="<i>"+rate+"</i> "+xajax.ext.SWFupload.tools.formatBytes(upload.received)+"/"+xajax.ext.SWFupload.tools.formatBytes(upload.total);oRequest.lastbytes=upload.received;}
|
||||
swf.settings.upload_error_handler=function(file,errorCode,message){if(-280==errorCode)return;if(file==null){fileName='';}else{fileName=file.name;}
|
||||
alert("Error Code: "+errorCode+", File name: "+fileName+", Message: "+message);};swf.startUpload(swf.customSettings.currentFile.id);return;}
|
||||
return xajax.ext.SWFupload.bak.submitRequest(oRequest);}
|
||||
xajax.ext.SWFupload.tools.queueFile=function(oFile,name,QueueId,QueueContainer){this.id=oFile.id;this.name=name;this.QueueId=QueueId;var container=document.createElement('div');container.id="SWFup_"+this.id;container.className="swf_queued_file";this.elm=container;var remove=document.createElement('div');remove.className="swf_queued_file_remove";remove.innerHTML=" ";var id=this.id;var QueueId=this.QueueId;remove.onclick=function(){xajax.ext.SWFupload.removeFile(QueueId,id);}
|
||||
container.appendChild(remove);var label=document.createElement('div');label.className="swf_queued_filename";label.innerHTML=oFile.name;container.appendChild(label);var progress_container=document.createElement('div');progress_container.className="swf_queued_file_progress_container";container.appendChild(progress_container);var progress=document.createElement('div');progress.className="swf_queued_file_progress_bar";progress.style.width='1px';progress.id='SWFup_progress_'+oFile.id;progress_container.appendChild(progress);var fSize=document.createElement('div');fSize.className="swf_queued_filesize";fSize.id="swf_queued_filesize_"+this.id;fSize.innerHTML=xajax.ext.SWFupload.tools.formatBytes(oFile.size);container.appendChild(fSize);var fClear=document.createElement('div');fClear.style.clear='both';container.appendChild(fClear);QueueContainer.appendChild(container);this.container=container;this.oFile=oFile;this.destroy=function(){QueueContainer.removeChild(container);}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.fileQueue=function(id,child,parent,config,multiple){this.id=id;var config='object'==typeof config ? xajax.ext.SWFupload.tools.mergeObj(xajax.ext.SWFupload.settings,config):xajax.ext.SWFupload.settings;this.queued=0;this.files={};this.queue=null;this.getConfig=function(){return config;}
|
||||
var tmpName=child.name;var container=document.createElement('div');container.id='SWFbuttonContainer_'+tmpName;container.className='swf_browse_button';parent.appendChild(container);var container2=document.createElement('div');container2.id='SWFbutton_'+tmpName;container.appendChild(container2);parent.removeChild(child);var oQueue=this;if(true===multiple){config.button_action=SWFUpload.BUTTON_ACTION.SELECT_FILES;}else{config.button_action=SWFUpload.BUTTON_ACTION.SELECT_FILE;}
|
||||
var QueueContainer=document.createElement('div');QueueContainer.id='SWFqueue_'+this.id;QueueContainer.className='swf_queue_container';parent.appendChild(QueueContainer);config.button_placeholder_id=container2.id;var foo=this;var fieldname=child.name;this.addFile=function(oFile){foo.files[oFile.id]=new xajax.ext.SWFupload.tools.queueFile(oFile,fieldname,foo.id,QueueContainer);foo.queued++;if(foo.queued==config.file_queue_limit)foo.swf.setButtonDisabled(true);}
|
||||
this.getFile=function(FileId){if("undefined"!=typeof FileId)return foo.files[FileId];for(a in foo.files)return foo.files[a];return false;}
|
||||
this.purge=function(d){var a=d.attributes,i,l,n;if(a){l=a.length;for(i=0;i < l;i+=1){n=a[i].name;if(typeof d[n]==='function'){d[n]=null;}
|
||||
}
|
||||
}
|
||||
a=d.childNodes;if(a){l=a.length;for(i=0;i < l;i+=1){this.purge(d.childNodes[i]);}
|
||||
}
|
||||
}
|
||||
this.removeFile=function(FileId,finished){foo.swf.cancelUpload(FileId);foo.queued--;if(foo.queued <=config.file_queue_limit)foo.swf.setButtonDisabled(false);var filediv=xajax.$("SWFup_"+foo.files[FileId].id);filediv.className=true===finished ? 'swf_queued_file_finished':'swf_queued_file_removed';setTimeout(function(){xajax.ext.SWFupload.tools.FadeOut(filediv,100);},xajax.ext.SWFupload.config.FadeTimeOut);foo.files[FileId]=null;delete foo.files[FileId];}
|
||||
this.destroy=function(){this.swf.destroy();delete(this.swf);for(a in foo.files){foo.files[a].destroy();delete(foo.files[a]);}
|
||||
foo.queued=0;delete(foo);}
|
||||
this.fileQueueError=function(swf,code,msg){if(-110==code){msg="Die gewählte Datei ist zu groß!";alert(msg);}
|
||||
}
|
||||
this.getSWF=function(){return this.swf;}
|
||||
config.file_queued_handler=this.addFile;config.file_queue_error_handler=this.fileQueueError;this.swf=new SWFUpload(config);}
|
||||
xajax.ext.SWFupload.tools._parseFields=function(children,parent,config,multiple){var result={};var iLen=children.length;for(var i=0;i < iLen;++i){var child=children[i];if('undefined'!=typeof child.childNodes)
|
||||
var res2=xajax.ext.SWFupload.tools._parseFields(child.childNodes,child,config,multiple);result=xajax.ext.SWFupload.tools.mergeObj(result,res2);if(child.name){if('file'==child.type){result[child.name]=xajax.ext.SWFupload.addQueue(child,parent,config,multiple);}
|
||||
}
|
||||
}
|
||||
return result;}
|
||||
xajax.ext.SWFupload.tools.transForm=function(form_id,config,multiple){var oForm=xajax.$(form_id);if(oForm)
|
||||
if(oForm.childNodes){var fields=xajax.ext.SWFupload.tools._parseFields(oForm.childNodes,oForm,config,multiple);xajax.ext.SWFupload.forms[form_id]=fields;}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.transField=function(field_id,config,multiple){try{var oField=xajax.$(field_id);if('undefined'!=typeof oField)return xajax.ext.SWFupload.fields[field_id]=xajax.ext.SWFupload.addQueue(oField,oField.parentNode,config,multiple);}catch(ex){}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.destroyForm=function(form_id){if("undefined"==typeof xajax.ext.SWFupload.forms[form_id])return;for(a in xajax.ext.SWFupload.forms[form_id]){var key=xajax.ext.SWFupload.forms[form_id][a];xajax.ext.SWFupload.queues[key].destroy();delete xajax.ext.SWFupload.queues[key];}
|
||||
delete xajax.ext.SWFupload.forms[form_id];return;}
|
||||
xajax.ext.SWFupload.tools.destroyField=function(field_id){if("undefined"==typeof xajax.ext.SWFupload.fields[field_id])return;var key=xajax.ext.SWFupload.fields[field_id];xajax.ext.SWFupload.queues[key].destroy();delete(xajax.ext.SWFupload.queues[key]);delete xajax.ext.SWFupload.fields[field_id];return true;}
|
||||
xajax.ext.SWFupload.tools.FadeOut=function(elm,opacity){var reduceOpacityBy=15;var rate=40;if(opacity > 0){opacity-=reduceOpacityBy;if(opacity < 0){opacity=0;}
|
||||
if(elm.filters){try{elm.filters.item("DXImageTransform.Microsoft.Alpha").opacity=opacity;}catch(e){elm.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity+")";}
|
||||
}else{elm.style.opacity=opacity/100;}
|
||||
}
|
||||
if(opacity > 0){var oSelf=this;setTimeout(function(){xajax.ext.SWFupload.tools.FadeOut(elm,opacity);},rate);}else{var parent=elm.parentNode;parent.removeChild(elm);}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.formatBytes=function(bytes){var ret={};if(bytes/1204 < 1024){return(Math.round(bytes/1024*100)/100).toString()+" kB";}else{return(Math.round(bytes/1024/1024*100)/100).toString()+" MB";}
|
||||
return ret;}
|
||||
xajax.ext.SWFupload.tools.mergeObj=function(){if('object'!=typeof arguments)return;var res={};var len=arguments.length;for(var i=0;i<len;i++){var obj=arguments[i];for(a in obj){res[a]=obj[a];}
|
||||
}
|
||||
return res;}
|
||||
xajax.ext.SWFupload.tools.getId=function(){var pid_str="";for(i=0;i<=3;i++){var pid=0;pid=Math.random();while(Math.ceil(pid).toString().length<8){pid*=10;}
|
||||
pid=Math.ceil(pid).toString();pid_str=pid_str+pid.toString();}
|
||||
return pid_str;}
|
||||
xajax.command.handler.register('SWFup_dfi',function(args){args.cmdFullName='ext.SWFupload.tools.destroyField';xajax.ext.SWFupload.tools.destroyField(args.id);return true;});xajax.command.handler.register('SWFup_dfo',function(args){args.cmdFullName='ext.SWFupload.tools.destroyForm';xajax.ext.SWFupload.tools.destroyForm(args.id);return true;});xajax.command.handler.register('SWFup_tfi',function(args){args.cmdFullName='ext.SWFupload.tools.transField';if("string"==typeof args.data.config.upload_success_handler){try{eval("var foo = "+args.data.config.upload_success_handler);args.data.config.upload_success_handler=foo;}catch(ex){delete(args.data.config.upload_success_handler);}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.transField(args.id,args.data.config,args.data.multi);return true;});xajax.command.handler.register('SWFup_tfo',function(args){try{args.cmdFullName='ext.SWFupload.tools.transForm';if("string"==typeof args.data.config.upload_success_handler){try{eval("var foo = "+args.data.config.upload_success_handler);args.data.config.upload_success_handler=foo;}catch(ex){delete(args.data.config.upload_success_handler);}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.transForm(args.id,args.data.config,args.data.multi);}catch(ex){}
|
||||
return true;});xajax.ext.SWFupload.bak={};xajax.ext.SWFupload.bak.prepareRequest=xajax.prepareRequest;xajax.ext.SWFupload.bak.submitRequest=xajax.submitRequest;xajax.ext.SWFupload.bak.responseProcessor=xajax.responseProcessor;xajax.ext.SWFupload.bak.processParameters=xajax.processParameters;xajax.prepareRequest=xajax.ext.SWFupload.request.prepareRequest;xajax.submitRequest=xajax.ext.SWFupload.request.submitRequest;xajax.processParameters=xajax.ext.SWFupload.request.processParameters;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;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,972 @@
|
||||
|
||||
//xjxSWFup = xajax.ext.SWFupload;
|
||||
|
||||
xajax.ext.SWFupload.swf = null;
|
||||
|
||||
xajax.ext.SWFupload.forms = {};
|
||||
xajax.ext.SWFupload.fields = {};
|
||||
xajax.ext.SWFupload.queues = {};
|
||||
xajax.ext.SWFupload.tools = {};
|
||||
|
||||
/* default upload settings */
|
||||
xajax.ext.SWFupload.settings = {
|
||||
flash_url : xajax.ext.SWFupload.config.javascript_URI+"swfupload.swf",
|
||||
file_size_limit : "0",
|
||||
file_types : "*.*",
|
||||
file_types_description : "All Files",
|
||||
file_upload_limit : 0,
|
||||
file_queue_limit : 0,
|
||||
file_queue_error_handler : xajax.ext.SWFupload.tools.fileQueueError,
|
||||
debug: false,
|
||||
button_image_url : "img/button_500x22.gif",
|
||||
button_width : 270,
|
||||
button_height : 22,
|
||||
button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
|
||||
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
|
||||
button_placeholder_id :'' ,
|
||||
button_text : '<span class="btnText">Select Files...</span>',
|
||||
button_text_style : ".btnText { font-size: 10; font-weight: bold; font-family: MS Shell Dlg; }",
|
||||
button_text_top_padding : 3,
|
||||
button_text_left_padding : 100,
|
||||
post_params : {}
|
||||
}
|
||||
|
||||
if ('undefined' == typeof xajax.ext.SWFupload.lang)
|
||||
{
|
||||
xajax.ext.SWFupload.lang = {};
|
||||
xajax.ext.SWFupload.lang.browseFiles = 'Browse Files';
|
||||
xajax.ext.SWFupload.lang.browseFile = 'Browse File';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.init
|
||||
arguments: config [object]
|
||||
|
||||
Creates the SWFupload instance
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.configure = function (config)
|
||||
{
|
||||
if ("object" == typeof config) return xajax.ext.SWFupload.tools.mergeObj(this.settings,config);
|
||||
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.addQueue
|
||||
arguments: child [object], parent [object], config [objeect ,multiple [bool]
|
||||
|
||||
Creates a new a new file queue and stores the reference in this.queues
|
||||
*/
|
||||
xajax.ext.SWFupload.addQueue = function (child,parent,config,multiple)
|
||||
{
|
||||
var id = xajax.ext.SWFupload.tools.getId();
|
||||
this.queues[id] = new xajax.ext.SWFupload.tools.fileQueue(id,child,parent,config,multiple);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.applyConfig
|
||||
arguments: oQueue [object]
|
||||
|
||||
Applies the queue's config on the SWFupload instance
|
||||
*/
|
||||
xajax.ext.SWFupload.applyConfig = function(oQueue)
|
||||
{
|
||||
|
||||
var conf = oQueue.getConfig();
|
||||
var swf = xajax.ext.SWFupload.getInstance();
|
||||
|
||||
if ( 'undefined' != typeof conf.file_types )
|
||||
swf.setFileTypes(conf.file_types, conf.file_types_description);
|
||||
|
||||
if ( 'undefined' != typeof conf.file_size_limit )
|
||||
swf.setFileSizeLimit(conf.file_size_limit);
|
||||
|
||||
if ( 'object' == typeof conf.post_params)
|
||||
{
|
||||
for (a in conf.post_params)
|
||||
swf.addPostParam(a,conf.post_params[a]);
|
||||
}
|
||||
|
||||
swf.settings.file_queued_handler = function(oFile) {oQueue.addFile(oFile)};;
|
||||
swf.settings.file_queue_error_handler = oQueue.fileQueueError;
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.selectFile
|
||||
arguments: oQueue [object]
|
||||
|
||||
Onclick handler for selecting file
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.selectFile = function(oQueue)
|
||||
{
|
||||
this.applyConfig(oQueue);
|
||||
|
||||
if (oQueue.getConfig().file_queue_limit > 0 && oQueue.getConfig().file_queue_limit <= oQueue.queued) return;
|
||||
|
||||
xajax.ext.SWFupload.getInstance().selectFile();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.selectFiles
|
||||
arguments: oQueue [object]
|
||||
|
||||
Onclick handler for selecting files
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.selectFiles = function(oQueue)
|
||||
{
|
||||
this.applyConfig(oQueue);
|
||||
if (oQueue.getConfig().file_queue_limit > 0 && oQueue.getConfig().file_queue_limit <= oQueue.queued) return;
|
||||
xajax.ext.SWFupload.getInstance().selectFiles();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.getInstance
|
||||
arguments:
|
||||
|
||||
Return the SWFupload instance. If there's no instance available it creates a new one with default settings.
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.getInstance = function()
|
||||
{
|
||||
if (null == this.swf) this.swf = new SWFUpload(this.settings);
|
||||
|
||||
return this.swf;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.removeFile
|
||||
arguments: QueueId [integer] , FileId [integer]
|
||||
|
||||
Removes the file (FileID) from queue (QueueId)
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.removeFile = function(QueueId,FileId,finished)
|
||||
{
|
||||
this.queues[QueueId].removeFile(FileId,finished);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.SWFupload.request = {};
|
||||
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request.getFileFromQueue
|
||||
arguments: oRequest [object]
|
||||
|
||||
Returns the first file from first available queue.
|
||||
Returns false if no files were selected
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.getFileFromQueue = function(oRequest)
|
||||
{
|
||||
|
||||
|
||||
var instances = {};
|
||||
var queued = 0;
|
||||
if ("string" == typeof oRequest.SWFform)
|
||||
{
|
||||
|
||||
|
||||
if ('object' != typeof xajax.ext.SWFupload.forms[oRequest.SWFform])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (a in xajax.ext.SWFupload.forms[oRequest.SWFform])
|
||||
{
|
||||
var field = xajax.ext.SWFupload.forms[oRequest.SWFform][a];
|
||||
if (0 < xajax.ext.SWFupload.queues[field].queued) {
|
||||
oRequest.currentFile = xajax.ext.SWFupload.queues[field].getFile();
|
||||
oRequest.swf = xajax.ext.SWFupload.queues[field].getSWF();
|
||||
return true ;
|
||||
};
|
||||
}
|
||||
} else if ("string" == typeof oRequest.SWFfield)
|
||||
{
|
||||
if ('string' != typeof xajax.ext.SWFupload.fields[oRequest.SWFfield])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var qId = xajax.ext.SWFupload.fields[oRequest.SWFfield];
|
||||
if (0 < xajax.ext.SWFupload.queues[qId].queued) {
|
||||
oRequest.currentFile = xajax.ext.SWFupload.queues[qId].getFile();
|
||||
oRequest.swf = xajax.ext.SWFupload.queues[qId].getSWF();
|
||||
return true ;
|
||||
};
|
||||
} else
|
||||
{
|
||||
|
||||
for (var a in xajax.ext.SWFupload.queues)
|
||||
{
|
||||
if (0 < xajax.ext.SWFupload.queues[a].queued) {
|
||||
oRequest.currentFile = xajax.ext.SWFupload.queues[a].getFile();
|
||||
oRequest.swf = xajax.ext.SWFupload.queues[a].getSWF();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request. xajax.ext.SWFupload.request.processParameters = function(oRequest)
|
||||
|
||||
arguments: oRequest [object]
|
||||
|
||||
Processes the parameters
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.processParameters = function(oRequest)
|
||||
{
|
||||
if ("SWFupload" == oRequest.mode)
|
||||
{
|
||||
oRequest.currentFile = false;
|
||||
xajax.ext.SWFupload.request.getFileFromQueue(oRequest);
|
||||
if (oRequest.currentFile) oRequest.method='GET';
|
||||
}
|
||||
return xajax.ext.SWFupload.bak.processParameters(oRequest);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request. xajax.ext.SWFupload.request.prepareRequest = function(oRequest)
|
||||
|
||||
arguments: oRequest [object]
|
||||
|
||||
doesn't to anything at all when there's a file selected for upload
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.prepareRequest = function (oRequest)
|
||||
{
|
||||
if ("SWFupload" == oRequest.mode && false != oRequest.currentFile) return;
|
||||
return xajax.ext.SWFupload.bak.prepareRequest(oRequest);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request. xajax.ext.SWFupload.request.submitRequest = function(oRequest)
|
||||
|
||||
arguments: oRequest [object]
|
||||
|
||||
Submits the request either via SWFupload or XHR
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.submitRequest = function(oRequest)
|
||||
{
|
||||
if ( "SWFupload" == oRequest.mode && false != oRequest.currentFile )
|
||||
{
|
||||
|
||||
if (oRequest.requestURI) {
|
||||
//backup requestURI, otherwise xajax.responseReceived() is going to delete our url
|
||||
oRequest.bak_requestURI = oRequest.requestURI;
|
||||
} else if (oRequest.bak_requestURI) {
|
||||
oRequest.requestURI = oRequest.bak_requestURI;
|
||||
}
|
||||
|
||||
var swf = oRequest.swf;
|
||||
|
||||
var fileQueue = xajax.ext.SWFupload.queues[oRequest.currentFile.QueueId];
|
||||
|
||||
swf.customSettings.currentFile = oRequest.currentFile;
|
||||
swf.setFilePostName(swf.customSettings.currentFile.name);
|
||||
|
||||
swf.customSettings.oRequest = oRequest;
|
||||
swf.setUploadURL(oRequest.requestURI);
|
||||
|
||||
swf.settings.upload_success_handler = function ( oFile, response )
|
||||
{
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xcb = xx.callback;
|
||||
var gcb = xcb.global;
|
||||
var lcb = oRequest.callback;
|
||||
|
||||
var oRet = oRequest.returnValue;
|
||||
|
||||
var FileId = swf.customSettings.currentFile;
|
||||
if ( 'function' == typeof this.old_upload_success_handler ) this.old_upload_success_handler( oFile );
|
||||
xcb.execute([gcb, lcb], 'onSuccess', oRequest);
|
||||
var seq = 0;
|
||||
if (response) {
|
||||
var responseXML = (new DOMParser()).parseFromString(response, "text/xml");
|
||||
if (responseXML.documentElement) {
|
||||
oRequest.status.onProcessing();
|
||||
|
||||
var child = responseXML.documentElement.firstChild;
|
||||
oRet = xt.xml.processFragment(child, seq, oRet, oRequest);
|
||||
}
|
||||
}
|
||||
var obj = {};
|
||||
obj.fullName = 'Response Complete';
|
||||
obj.sequence = seq;
|
||||
obj.request = oRequest;
|
||||
obj.context = oRequest.context;
|
||||
obj.cmd = 'rcmplt';
|
||||
xt.queue.push(xx.response, obj);
|
||||
|
||||
// do not re-start the queue if a timeout is set
|
||||
if (null == xx.response.timeout)
|
||||
xt.queue.process(xx.response);
|
||||
}
|
||||
|
||||
swf.settings.upload_complete_handler = function(oFile)
|
||||
{
|
||||
|
||||
var qFile = this.customSettings.currentFile;
|
||||
xajax.ext.SWFupload.removeFile(qFile.QueueId,qFile.id,true);
|
||||
|
||||
if ( !xajax.ext.SWFupload.request.getFileFromQueue(oRequest) )
|
||||
{
|
||||
if ('function' == typeof oRequest.onUploadComplete) oRequest.onUploadComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
xajax.ext.SWFupload.request.submitRequest(oRequest);
|
||||
}
|
||||
|
||||
|
||||
swf.settings.upload_start_handler = function(oFile)
|
||||
{
|
||||
if ('function' == typeof this.old_upload_start_handler) this.old_upload_start_handler(oFile);
|
||||
oRequest.startTime = new Date();
|
||||
|
||||
}
|
||||
swf.settings.upload_progress_handler = function (oFile, bytesLoaded, bytesTotal)
|
||||
{
|
||||
|
||||
upload = {};
|
||||
upload.received=bytesLoaded;
|
||||
upload.total=bytesTotal;
|
||||
upload.state="uploading";
|
||||
var reqTime = new Date();
|
||||
|
||||
upload.lastbytes = oRequest.lastbytes;
|
||||
upload.now = reqTime.getTime() / 1000;
|
||||
upload.start = oRequest.startTime.getTime()/ 1000;
|
||||
|
||||
var step = upload.received / (upload.total / 100);
|
||||
var progressbar = xajax.$('SWFup_progress_'+oFile.id);
|
||||
var w = Math.round(220 * step / 100);
|
||||
progressbar.style.width=w+'px';
|
||||
|
||||
var progress = xajax.$("swf_queued_filesize_"+oFile.id);
|
||||
var elapsed = upload.now-upload.start;
|
||||
var rate = xajax.ext.SWFupload.tools.formatBytes(upload.received/ elapsed).toString() + '/s';
|
||||
progress.innerHTML = "<i>"+rate + "</i> "+xajax.ext.SWFupload.tools.formatBytes(upload.received)+"/"+xajax.ext.SWFupload.tools.formatBytes(upload.total);
|
||||
oRequest.lastbytes = upload.received;
|
||||
|
||||
}
|
||||
|
||||
swf.settings.upload_error_handler = function(file, errorCode, message)
|
||||
{
|
||||
// Skipe error when a file is removed from queue (abort)
|
||||
if (-280 == errorCode) return;
|
||||
if (file == null) {fileName = '';} else {
|
||||
fileName = file.name;
|
||||
}
|
||||
|
||||
alert("Error Code: "+errorCode+", File name: " + fileName + ", Message: " + message);
|
||||
};
|
||||
swf.startUpload(swf.customSettings.currentFile.id);
|
||||
return;
|
||||
}
|
||||
return xajax.ext.SWFupload.bak.submitRequest(oRequest);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.queueFile
|
||||
arguments: oFile,QueueId,QueueContainer
|
||||
|
||||
*/
|
||||
xajax.ext.SWFupload.tools.queueFile = function(oFile,name,QueueId,QueueContainer) {
|
||||
|
||||
this.id = oFile.id;
|
||||
this.name = name;
|
||||
this.QueueId = QueueId;
|
||||
|
||||
var container = document.createElement('div');
|
||||
container.id = "SWFup_"+this.id;
|
||||
container.className="swf_queued_file";
|
||||
|
||||
this.elm = container;
|
||||
|
||||
var remove = document.createElement('div');
|
||||
remove.className="swf_queued_file_remove";
|
||||
remove.innerHTML=" ";
|
||||
|
||||
var id = this.id;
|
||||
var QueueId = this.QueueId;
|
||||
remove.onclick= function () {
|
||||
xajax.ext.SWFupload.removeFile(QueueId,id);
|
||||
}
|
||||
container.appendChild(remove);
|
||||
|
||||
var label = document.createElement('div');
|
||||
label.className="swf_queued_filename";
|
||||
label.innerHTML = oFile.name;
|
||||
container.appendChild(label);
|
||||
|
||||
var progress_container = document.createElement('div');
|
||||
progress_container.className="swf_queued_file_progress_container";
|
||||
container.appendChild(progress_container);
|
||||
|
||||
|
||||
var progress = document.createElement('div');
|
||||
progress.className="swf_queued_file_progress_bar";
|
||||
progress.style.width='1px';
|
||||
progress.id='SWFup_progress_'+oFile.id;
|
||||
progress_container.appendChild(progress);
|
||||
|
||||
|
||||
var fSize = document.createElement('div');
|
||||
fSize.className="swf_queued_filesize";
|
||||
fSize.id="swf_queued_filesize_"+this.id;
|
||||
fSize.innerHTML = xajax.ext.SWFupload.tools.formatBytes(oFile.size);
|
||||
container.appendChild(fSize);
|
||||
|
||||
var fClear= document.createElement('div');
|
||||
fClear.style.clear='both';
|
||||
container.appendChild(fClear);
|
||||
QueueContainer.appendChild(container);
|
||||
|
||||
this.container = container;
|
||||
this.oFile = oFile;
|
||||
|
||||
this.destroy = function()
|
||||
{
|
||||
QueueContainer.removeChild(container);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.fileQueue
|
||||
arguments: id [integer],child [object], parent [object], multiple [bool]
|
||||
|
||||
parses the form for fields
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.fileQueue = function (id,child,parent,config,multiple)
|
||||
{
|
||||
|
||||
|
||||
this.id = id;
|
||||
var config = 'object' == typeof config ? xajax.ext.SWFupload.tools.mergeObj(xajax.ext.SWFupload.settings,config) : xajax.ext.SWFupload.settings;
|
||||
this.queued = 0;
|
||||
this.files = {};
|
||||
this.queue = null;
|
||||
|
||||
this.getConfig = function() {return config;}
|
||||
|
||||
var tmpName = child.name;
|
||||
var container = document.createElement('div');
|
||||
container.id = 'SWFbuttonContainer_'+tmpName;
|
||||
container.className='swf_browse_button';
|
||||
parent.appendChild(container);
|
||||
|
||||
|
||||
var container2 = document.createElement('div');
|
||||
container2.id = 'SWFbutton_'+tmpName;
|
||||
container.appendChild(container2);
|
||||
|
||||
parent.removeChild(child);
|
||||
|
||||
var oQueue = this;
|
||||
if (true === multiple)
|
||||
{
|
||||
config.button_action = SWFUpload.BUTTON_ACTION.SELECT_FILES;
|
||||
} else {
|
||||
config.button_action = SWFUpload.BUTTON_ACTION.SELECT_FILE;
|
||||
|
||||
}
|
||||
|
||||
var QueueContainer = document.createElement('div');
|
||||
QueueContainer.id = 'SWFqueue_'+ this.id;
|
||||
QueueContainer.className = 'swf_queue_container';
|
||||
parent.appendChild(QueueContainer);
|
||||
|
||||
config.button_placeholder_id=container2.id;
|
||||
|
||||
var foo = this;
|
||||
|
||||
var fieldname = child.name;
|
||||
this.addFile = function (oFile)
|
||||
{
|
||||
foo.files[oFile.id] = new xajax.ext.SWFupload.tools.queueFile(oFile,fieldname,foo.id,QueueContainer);
|
||||
foo.queued++;
|
||||
if (foo.queued == config.file_queue_limit) foo.swf.setButtonDisabled(true);
|
||||
}
|
||||
|
||||
this.getFile = function (FileId)
|
||||
{
|
||||
if ("undefined" != typeof FileId) return foo.files[FileId];
|
||||
for (a in foo.files) return foo.files[a];
|
||||
return false;
|
||||
}
|
||||
|
||||
this.purge = function (d) {
|
||||
var a = d.attributes, i, l, n;
|
||||
if (a) {
|
||||
l = a.length;
|
||||
for (i = 0; i < l; i += 1) {
|
||||
n = a[i].name;
|
||||
if (typeof d[n] === 'function') {
|
||||
d[n] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
a = d.childNodes;
|
||||
if (a) {
|
||||
l = a.length;
|
||||
for (i = 0; i < l; i += 1) {
|
||||
this.purge(d.childNodes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.removeFile = function(FileId,finished)
|
||||
{
|
||||
|
||||
foo.swf.cancelUpload(FileId);
|
||||
|
||||
foo.queued--;
|
||||
if (foo.queued <= config.file_queue_limit) foo.swf.setButtonDisabled(false);
|
||||
var filediv = xajax.$("SWFup_"+foo.files[FileId].id);
|
||||
filediv.className = true === finished ? 'swf_queued_file_finished' : 'swf_queued_file_removed';
|
||||
setTimeout(function ()
|
||||
{
|
||||
xajax.ext.SWFupload.tools.FadeOut(filediv,100);
|
||||
}, xajax.ext.SWFupload.config.FadeTimeOut);
|
||||
|
||||
foo.files[FileId] = null;
|
||||
delete foo.files[FileId];
|
||||
}
|
||||
this.destroy = function() {
|
||||
|
||||
this.swf.destroy();
|
||||
delete(this.swf);
|
||||
for (a in foo.files) {
|
||||
foo.files[a].destroy();
|
||||
delete (foo.files[a]);
|
||||
}
|
||||
foo.queued=0;
|
||||
delete(foo);
|
||||
}
|
||||
this.fileQueueError = function(swf,code,msg) {
|
||||
if (-110 == code) {
|
||||
msg = "Die gewählte Datei ist zu groß!";
|
||||
alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
this.getSWF = function() {
|
||||
return this.swf;
|
||||
|
||||
}
|
||||
|
||||
config.file_queued_handler=this.addFile;
|
||||
config.file_queue_error_handler=this.fileQueueError;
|
||||
|
||||
this.swf = new SWFUpload(config);
|
||||
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools._parseFields
|
||||
arguments: children [array],parent [object], config [object], multiple [bool]
|
||||
|
||||
parses the form for fields
|
||||
*/
|
||||
|
||||
|
||||
xajax.ext.SWFupload.tools._parseFields = function(children,parent,config,multiple)
|
||||
{
|
||||
var result={};
|
||||
var iLen = children.length;
|
||||
for (var i = 0; i < iLen; ++i)
|
||||
{
|
||||
var child = children[i];
|
||||
if ('undefined' != typeof child.childNodes)
|
||||
var res2 = xajax.ext.SWFupload.tools._parseFields(child.childNodes,child,config,multiple);
|
||||
result = xajax.ext.SWFupload.tools.mergeObj(result,res2);
|
||||
if (child.name)
|
||||
{
|
||||
if ('file' == child.type)
|
||||
{
|
||||
result[child.name] = xajax.ext.SWFupload.addQueue(child,parent,config,multiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.transForm
|
||||
arguments: form_id [integer] ,config [object] ,multiple [bool]
|
||||
|
||||
transforms the all fields of the given form into fileQueue instances
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.transForm = function(form_id,config,multiple)
|
||||
{
|
||||
var oForm = xajax.$(form_id);
|
||||
if (oForm)
|
||||
if (oForm.childNodes) {
|
||||
var fields = xajax.ext.SWFupload.tools._parseFields(oForm.childNodes,oForm,config,multiple);
|
||||
xajax.ext.SWFupload.forms[form_id] = fields;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.transField
|
||||
arguments: field_id [integer] ,config [object] ,multiple [bool]
|
||||
|
||||
transforms the given field into a fileQueue instance
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.transField = function(field_id,config,multiple)
|
||||
{
|
||||
try {
|
||||
var oField = xajax.$(field_id);
|
||||
if ('undefined' != typeof oField) return xajax.ext.SWFupload.fields[field_id] = xajax.ext.SWFupload.addQueue(oField,oField.parentNode,config,multiple);
|
||||
|
||||
}catch(ex) {}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.destroyForm
|
||||
arguments: form_id [integer]
|
||||
|
||||
destroys the given form
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.destroyForm = function(form_id)
|
||||
{
|
||||
if ("undefined" == typeof xajax.ext.SWFupload.forms[form_id]) return;
|
||||
for (a in xajax.ext.SWFupload.forms[form_id])
|
||||
{
|
||||
var key = xajax.ext.SWFupload.forms[form_id][a];
|
||||
xajax.ext.SWFupload.queues[key].destroy();
|
||||
delete xajax.ext.SWFupload.queues[key];
|
||||
}
|
||||
delete xajax.ext.SWFupload.forms[form_id];
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.destroyField
|
||||
arguments: field_id [integer]
|
||||
|
||||
destroys the given field
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.destroyField = function(field_id)
|
||||
{
|
||||
if ("undefined" == typeof xajax.ext.SWFupload.fields[field_id]) return;
|
||||
var key = xajax.ext.SWFupload.fields[field_id];
|
||||
xajax.ext.SWFupload.queues[key].destroy();
|
||||
delete(xajax.ext.SWFupload.queues[key]);
|
||||
delete xajax.ext.SWFupload.fields[field_id];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.FadeOut
|
||||
arguments: elm [object], opacity [integer]
|
||||
|
||||
fades a div
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.FadeOut = function(elm,opacity)
|
||||
{
|
||||
var reduceOpacityBy = 15;
|
||||
var rate = 40;
|
||||
if (opacity > 0)
|
||||
{
|
||||
opacity -= reduceOpacityBy;
|
||||
if (opacity < 0)
|
||||
{
|
||||
opacity = 0;
|
||||
}
|
||||
|
||||
if (elm.filters)
|
||||
{
|
||||
try
|
||||
{
|
||||
elm.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
|
||||
} catch (e) {
|
||||
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
||||
elm.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")";
|
||||
}
|
||||
} else {
|
||||
elm.style.opacity = opacity / 100;
|
||||
}
|
||||
}
|
||||
|
||||
if ( opacity > 0)
|
||||
{
|
||||
var oSelf = this;
|
||||
setTimeout(function ()
|
||||
{
|
||||
xajax.ext.SWFupload.tools.FadeOut(elm,opacity);
|
||||
}, rate);
|
||||
} else {
|
||||
var parent = elm.parentNode;
|
||||
parent.removeChild(elm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.formatBytes
|
||||
arguments: bytes [integer]
|
||||
|
||||
returns string with formatted size (kB / MB)
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.formatBytes = function(bytes)
|
||||
{
|
||||
|
||||
var ret = {};
|
||||
if (bytes / 1204 < 1024)
|
||||
{
|
||||
return (Math.round(bytes / 1024 * 100)/100).toString()+ " kB";
|
||||
} else {
|
||||
return (Math.round(bytes / 1024 / 1024 * 100)/100).toString()+ " MB";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.mergeObj
|
||||
arguments: n objects
|
||||
|
||||
Merges all objects and returns a single object.
|
||||
Newrt keys override existing keys.
|
||||
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.mergeObj = function()
|
||||
{
|
||||
if ('object' != typeof arguments) return;
|
||||
|
||||
var res = {};
|
||||
var len = arguments.length;
|
||||
for (var i=0;i<len;i++)
|
||||
{
|
||||
var obj = arguments[i];
|
||||
for (a in obj)
|
||||
{
|
||||
res[a] = obj[a];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.getId
|
||||
arguments:
|
||||
|
||||
returns a 'unique' (rand) id
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.getId = function()
|
||||
{
|
||||
var pid_str = "";
|
||||
for (i=0;i<=3;i++) {
|
||||
var pid = 0;
|
||||
pid = Math.random();
|
||||
while( Math.ceil(pid).toString().length<8)
|
||||
{
|
||||
pid *= 10;
|
||||
}
|
||||
pid = Math.ceil(pid).toString();
|
||||
pid_str = pid_str+pid.toString();
|
||||
}
|
||||
return pid_str;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_dfi')
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.destroyField
|
||||
*/
|
||||
xajax.command.handler.register('SWFup_dfi', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.SWFupload.tools.destroyField';
|
||||
xajax.ext.SWFupload.tools.destroyField(args.id);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_dfo')
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.destroyForm
|
||||
*/
|
||||
|
||||
xajax.command.handler.register('SWFup_dfo', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.SWFupload.tools.destroyForm';
|
||||
xajax.ext.SWFupload.tools.destroyForm(args.id);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_tfi'I
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.transField
|
||||
*/
|
||||
|
||||
xajax.command.handler.register('SWFup_tfi', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.SWFupload.tools.transField';
|
||||
|
||||
// if ("string" == typeof args.data.config.upload_complete_handler) {
|
||||
// try {
|
||||
// eval("var foo = "+args.data.config.upload_complete_handler);
|
||||
// args.data.config.upload_complete_handler = foo;
|
||||
// } catch(ex) {delete(args.data.config.upload_complete_handler);}
|
||||
// }
|
||||
|
||||
if ("string" == typeof args.data.config.upload_success_handler) {
|
||||
try {
|
||||
eval("var foo = "+args.data.config.upload_success_handler);
|
||||
args.data.config.upload_success_handler = foo;
|
||||
} catch(ex) {delete(args.data.config.upload_success_handler);}
|
||||
}
|
||||
|
||||
xajax.ext.SWFupload.tools.transField(args.id, args.data.config,args.data.multi);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_tfo']
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.transForm
|
||||
*/
|
||||
xajax.command.handler.register('SWFup_tfo',function(args)
|
||||
{
|
||||
try {
|
||||
args.cmdFullName = 'ext.SWFupload.tools.transForm';
|
||||
// if ("string" == typeof args.data.config.upload_complete_handler)
|
||||
// {
|
||||
// try {
|
||||
// eval("var foo = "+args.data.config.upload_complete_handler);
|
||||
// args.data.config.upload_complete_handler = foo;
|
||||
// } catch(ex) {delete(args.data.config.upload_complete_handler);}
|
||||
// }
|
||||
|
||||
if ("string" == typeof args.data.config.upload_success_handler)
|
||||
{
|
||||
try
|
||||
{
|
||||
eval("var foo = "+args.data.config.upload_success_handler);
|
||||
args.data.config.upload_success_handler = foo;
|
||||
} catch(ex)
|
||||
{
|
||||
delete(args.data.config.upload_success_handler);
|
||||
}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.transForm(args.id, args.data.config,args.data.multi);
|
||||
|
||||
} catch(ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
});
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
xajax.ext.SWFupload.bak = {};
|
||||
xajax.ext.SWFupload.bak.prepareRequest = xajax.prepareRequest;
|
||||
xajax.ext.SWFupload.bak.submitRequest = xajax.submitRequest;
|
||||
xajax.ext.SWFupload.bak.responseProcessor = xajax.responseProcessor;
|
||||
xajax.ext.SWFupload.bak.processParameters = xajax.processParameters;
|
||||
|
||||
xajax.prepareRequest = xajax.ext.SWFupload.request.prepareRequest;
|
||||
xajax.submitRequest = xajax.ext.SWFupload.request.submitRequest;
|
||||
xajax.processParameters = xajax.ext.SWFupload.request.processParameters;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,946 @@
|
||||
/**
|
||||
* SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
|
||||
*
|
||||
* mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
|
||||
*
|
||||
* SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* ******************* */
|
||||
/* Constructor & Init */
|
||||
/* ******************* */
|
||||
var SWFUpload;
|
||||
|
||||
if (SWFUpload == undefined) {
|
||||
SWFUpload = function (settings) {
|
||||
this.initSWFUpload(settings);
|
||||
};
|
||||
}
|
||||
|
||||
SWFUpload.prototype.initSWFUpload = function (settings) {
|
||||
try {
|
||||
this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
|
||||
this.settings = settings;
|
||||
this.eventQueue = [];
|
||||
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
|
||||
this.movieElement = null;
|
||||
|
||||
|
||||
// Setup global control tracking
|
||||
SWFUpload.instances[this.movieName] = this;
|
||||
|
||||
// Load the settings. Load the Flash movie.
|
||||
this.initSettings();
|
||||
this.loadFlash();
|
||||
this.displayDebugInfo();
|
||||
} catch (ex) {
|
||||
delete SWFUpload.instances[this.movieName];
|
||||
throw ex;
|
||||
}
|
||||
};
|
||||
|
||||
/* *************** */
|
||||
/* Static Members */
|
||||
/* *************** */
|
||||
SWFUpload.instances = {};
|
||||
SWFUpload.movieCount = 0;
|
||||
SWFUpload.version = "2.2.0 Beta 3";
|
||||
SWFUpload.QUEUE_ERROR = {
|
||||
QUEUE_LIMIT_EXCEEDED : -100,
|
||||
FILE_EXCEEDS_SIZE_LIMIT : -110,
|
||||
ZERO_BYTE_FILE : -120,
|
||||
INVALID_FILETYPE : -130
|
||||
};
|
||||
SWFUpload.UPLOAD_ERROR = {
|
||||
HTTP_ERROR : -200,
|
||||
MISSING_UPLOAD_URL : -210,
|
||||
IO_ERROR : -220,
|
||||
SECURITY_ERROR : -230,
|
||||
UPLOAD_LIMIT_EXCEEDED : -240,
|
||||
UPLOAD_FAILED : -250,
|
||||
SPECIFIED_FILE_ID_NOT_FOUND : -260,
|
||||
FILE_VALIDATION_FAILED : -270,
|
||||
FILE_CANCELLED : -280,
|
||||
UPLOAD_STOPPED : -290
|
||||
};
|
||||
SWFUpload.FILE_STATUS = {
|
||||
QUEUED : -1,
|
||||
IN_PROGRESS : -2,
|
||||
ERROR : -3,
|
||||
COMPLETE : -4,
|
||||
CANCELLED : -5
|
||||
};
|
||||
SWFUpload.BUTTON_ACTION = {
|
||||
SELECT_FILE : -100,
|
||||
SELECT_FILES : -110,
|
||||
START_UPLOAD : -120
|
||||
};
|
||||
SWFUpload.CURSOR = {
|
||||
ARROW : -1,
|
||||
HAND : -2
|
||||
};
|
||||
SWFUpload.WINDOW_MODE = {
|
||||
WINDOW : "window",
|
||||
TRANSPARENT : "transparent",
|
||||
OPAQUE : "opaque"
|
||||
};
|
||||
|
||||
/* ******************** */
|
||||
/* Instance Members */
|
||||
/* ******************** */
|
||||
|
||||
// Private: initSettings ensures that all the
|
||||
// settings are set, getting a default value if one was not assigned.
|
||||
SWFUpload.prototype.initSettings = function () {
|
||||
this.ensureDefault = function (settingName, defaultValue) {
|
||||
this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
|
||||
};
|
||||
|
||||
// Upload backend settings
|
||||
this.ensureDefault("upload_url", "");
|
||||
this.ensureDefault("file_post_name", "Filedata");
|
||||
this.ensureDefault("post_params", {});
|
||||
this.ensureDefault("use_query_string", false);
|
||||
this.ensureDefault("requeue_on_error", false);
|
||||
this.ensureDefault("http_success", []);
|
||||
|
||||
// File Settings
|
||||
this.ensureDefault("file_types", "*.*");
|
||||
this.ensureDefault("file_types_description", "All Files");
|
||||
this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
|
||||
this.ensureDefault("file_upload_limit", 0);
|
||||
this.ensureDefault("file_queue_limit", 0);
|
||||
|
||||
// Flash Settings
|
||||
this.ensureDefault("flash_url", "swfupload.swf");
|
||||
this.ensureDefault("prevent_swf_caching", true);
|
||||
|
||||
// Button Settings
|
||||
this.ensureDefault("button_image_url", "");
|
||||
this.ensureDefault("button_width", 1);
|
||||
this.ensureDefault("button_height", 1);
|
||||
this.ensureDefault("button_text", "");
|
||||
this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
|
||||
this.ensureDefault("button_text_top_padding", 0);
|
||||
this.ensureDefault("button_text_left_padding", 0);
|
||||
this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
|
||||
this.ensureDefault("button_disabled", false);
|
||||
this.ensureDefault("button_placeholder_id", null);
|
||||
this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
|
||||
this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
|
||||
|
||||
// Debug Settings
|
||||
this.ensureDefault("debug", false);
|
||||
this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
|
||||
|
||||
// Event Handlers
|
||||
this.settings.return_upload_start_handler = this.returnUploadStart;
|
||||
this.ensureDefault("swfupload_loaded_handler", null);
|
||||
this.ensureDefault("file_dialog_start_handler", null);
|
||||
this.ensureDefault("file_queued_handler", null);
|
||||
this.ensureDefault("file_queue_error_handler", null);
|
||||
this.ensureDefault("file_dialog_complete_handler", null);
|
||||
|
||||
this.ensureDefault("upload_start_handler", null);
|
||||
this.ensureDefault("upload_progress_handler", null);
|
||||
this.ensureDefault("upload_error_handler", null);
|
||||
this.ensureDefault("upload_success_handler", null);
|
||||
this.ensureDefault("upload_complete_handler", null);
|
||||
|
||||
this.ensureDefault("debug_handler", this.debugMessage);
|
||||
|
||||
this.ensureDefault("custom_settings", {});
|
||||
|
||||
// Other settings
|
||||
this.customSettings = this.settings.custom_settings;
|
||||
|
||||
// Update the flash url if needed
|
||||
if (this.settings.prevent_swf_caching) {
|
||||
this.settings.flash_url = this.settings.flash_url + "?swfuploadrnd=" + Math.floor(Math.random() * 999999999);
|
||||
}
|
||||
|
||||
delete this.ensureDefault;
|
||||
};
|
||||
|
||||
SWFUpload.prototype.loadFlash = function () {
|
||||
if (this.settings.button_placeholder_id !== "") {
|
||||
this.replaceWithFlash();
|
||||
} else {
|
||||
this.appendFlash();
|
||||
}
|
||||
};
|
||||
|
||||
// Private: appendFlash gets the HTML tag for the Flash
|
||||
// It then appends the flash to the body
|
||||
SWFUpload.prototype.appendFlash = function () {
|
||||
var targetElement, container;
|
||||
|
||||
// Make sure an element with the ID we are going to use doesn't already exist
|
||||
if (document.getElementById(this.movieName) !== null) {
|
||||
throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
|
||||
}
|
||||
|
||||
// Get the body tag where we will be adding the flash movie
|
||||
targetElement = document.getElementsByTagName("body")[0];
|
||||
|
||||
if (targetElement == undefined) {
|
||||
throw "Could not find the 'body' element.";
|
||||
}
|
||||
|
||||
// Append the container and load the flash
|
||||
container = document.createElement("div");
|
||||
container.style.width = "1px";
|
||||
container.style.height = "1px";
|
||||
container.style.overflow = "hidden";
|
||||
|
||||
targetElement.appendChild(container);
|
||||
container.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
|
||||
|
||||
// Fix IE Flash/Form bug
|
||||
if (window[this.movieName] == undefined) {
|
||||
window[this.movieName] = this.getMovieElement();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Private: replaceWithFlash replaces the button_placeholder element with the flash movie.
|
||||
SWFUpload.prototype.replaceWithFlash = function () {
|
||||
var targetElement, tempParent;
|
||||
|
||||
// Make sure an element with the ID we are going to use doesn't already exist
|
||||
if (document.getElementById(this.movieName) !== null) {
|
||||
throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
|
||||
}
|
||||
|
||||
// Get the element where we will be placing the flash movie
|
||||
targetElement = document.getElementById(this.settings.button_placeholder_id);
|
||||
|
||||
if (targetElement == undefined) {
|
||||
throw "Could not find the placeholder element.";
|
||||
}
|
||||
|
||||
// Append the container and load the flash
|
||||
tempParent = document.createElement("div");
|
||||
tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
|
||||
targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
|
||||
|
||||
// Fix IE Flash/Form bug
|
||||
if (window[this.movieName] == undefined) {
|
||||
window[this.movieName] = this.getMovieElement();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
|
||||
SWFUpload.prototype.getFlashHTML = function () {
|
||||
// Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
|
||||
return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
|
||||
'<param name="wmode" value="', this.settings.button_window_mode , '" />',
|
||||
'<param name="movie" value="', this.settings.flash_url, '" />',
|
||||
'<param name="quality" value="high" />',
|
||||
'<param name="menu" value="false" />',
|
||||
'<param name="allowScriptAccess" value="always" />',
|
||||
'<param name="flashvars" value="' + this.getFlashVars() + '" />',
|
||||
'</object>'].join("");
|
||||
};
|
||||
|
||||
// Private: getFlashVars builds the parameter string that will be passed
|
||||
// to flash in the flashvars param.
|
||||
SWFUpload.prototype.getFlashVars = function () {
|
||||
// Build a string from the post param object
|
||||
var paramString = this.buildParamString();
|
||||
var httpSuccessString = this.settings.http_success.join(",");
|
||||
|
||||
// Build the parameter string
|
||||
return ["movieName=", encodeURIComponent(this.movieName),
|
||||
"&uploadURL=", encodeURIComponent(this.settings.upload_url),
|
||||
"&useQueryString=", encodeURIComponent(this.settings.use_query_string),
|
||||
"&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
|
||||
"&httpSuccess=", encodeURIComponent(httpSuccessString),
|
||||
"&params=", encodeURIComponent(paramString),
|
||||
"&filePostName=", encodeURIComponent(this.settings.file_post_name),
|
||||
"&fileTypes=", encodeURIComponent(this.settings.file_types),
|
||||
"&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
|
||||
"&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
|
||||
"&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
|
||||
"&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
|
||||
"&debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
|
||||
"&buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
|
||||
"&buttonWidth=", encodeURIComponent(this.settings.button_width),
|
||||
"&buttonHeight=", encodeURIComponent(this.settings.button_height),
|
||||
"&buttonText=", encodeURIComponent(this.settings.button_text),
|
||||
"&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
|
||||
"&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
|
||||
"&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
|
||||
"&buttonAction=", encodeURIComponent(this.settings.button_action),
|
||||
"&buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
|
||||
"&buttonCursor=", encodeURIComponent(this.settings.button_cursor)
|
||||
].join("");
|
||||
};
|
||||
|
||||
// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
|
||||
// The element is cached after the first lookup
|
||||
SWFUpload.prototype.getMovieElement = function () {
|
||||
if (this.movieElement == undefined) {
|
||||
this.movieElement = document.getElementById(this.movieName);
|
||||
}
|
||||
|
||||
if (this.movieElement === null) {
|
||||
throw "Could not find Flash element";
|
||||
}
|
||||
|
||||
return this.movieElement;
|
||||
};
|
||||
|
||||
// Private: buildParamString takes the name/value pairs in the post_params setting object
|
||||
// and joins them up in to a string formatted "name=value&name=value"
|
||||
SWFUpload.prototype.buildParamString = function () {
|
||||
var postParams = this.settings.post_params;
|
||||
var paramStringPairs = [];
|
||||
|
||||
if (typeof(postParams) === "object") {
|
||||
for (var name in postParams) {
|
||||
if (postParams.hasOwnProperty(name)) {
|
||||
paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paramStringPairs.join("&");
|
||||
};
|
||||
|
||||
// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
|
||||
// all references to the SWF, and other objects so memory is properly freed.
|
||||
// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
|
||||
// Credits: Major improvements provided by steffen
|
||||
SWFUpload.prototype.destroy = function () {
|
||||
try {
|
||||
// Make sure Flash is done before we try to remove it
|
||||
this.cancelUpload(null, false);
|
||||
;
|
||||
// Remove the SWFUpload DOM nodes
|
||||
var movieElement = null;
|
||||
movieElement = this.getMovieElement();
|
||||
|
||||
if (movieElement) {
|
||||
// Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
|
||||
for (var i in movieElement) {
|
||||
try {
|
||||
if (typeof(movieElement[i]) === "function") {
|
||||
movieElement[i] = null;
|
||||
}
|
||||
} catch (ex1) {}
|
||||
}
|
||||
|
||||
// Remove the Movie Element from the page
|
||||
try {
|
||||
movieElement.parentNode.removeChild(movieElement);
|
||||
} catch (ex) {}
|
||||
}
|
||||
|
||||
|
||||
// Remove IE form fix reference
|
||||
window[this.movieName] = null;
|
||||
|
||||
// Destroy other references
|
||||
SWFUpload.instances[this.movieName] = null;
|
||||
delete SWFUpload.instances[this.movieName];
|
||||
|
||||
this.movieElement = null;
|
||||
this.settings = null;
|
||||
this.customSettings = null;
|
||||
this.eventQueue = null;
|
||||
this.movieName = null;
|
||||
|
||||
|
||||
return true;
|
||||
} catch (ex1) {
|
||||
alert(ex);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Public: displayDebugInfo prints out settings and configuration
|
||||
// information about this SWFUpload instance.
|
||||
// This function (and any references to it) can be deleted when placing
|
||||
// SWFUpload in production.
|
||||
SWFUpload.prototype.displayDebugInfo = function () {
|
||||
this.debug(
|
||||
[
|
||||
"---SWFUpload Instance Info---\n",
|
||||
"Version: ", SWFUpload.version, "\n",
|
||||
"Movie Name: ", this.movieName, "\n",
|
||||
"Settings:\n",
|
||||
"\t", "upload_url: ", this.settings.upload_url, "\n",
|
||||
"\t", "flash_url: ", this.settings.flash_url, "\n",
|
||||
"\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
|
||||
"\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
|
||||
"\t", "http_success: ", this.settings.http_success.join(", "), "\n",
|
||||
"\t", "file_post_name: ", this.settings.file_post_name, "\n",
|
||||
"\t", "post_params: ", this.settings.post_params.toString(), "\n",
|
||||
"\t", "file_types: ", this.settings.file_types, "\n",
|
||||
"\t", "file_types_description: ", this.settings.file_types_description, "\n",
|
||||
"\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
|
||||
"\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
|
||||
"\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
|
||||
"\t", "debug: ", this.settings.debug.toString(), "\n",
|
||||
|
||||
"\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
|
||||
|
||||
"\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
|
||||
"\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
|
||||
"\t", "button_width: ", this.settings.button_width.toString(), "\n",
|
||||
"\t", "button_height: ", this.settings.button_height.toString(), "\n",
|
||||
"\t", "button_text: ", this.settings.button_text.toString(), "\n",
|
||||
"\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
|
||||
"\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
|
||||
"\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
|
||||
"\t", "button_action: ", this.settings.button_action.toString(), "\n",
|
||||
"\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
|
||||
|
||||
"\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
|
||||
"Event Handlers:\n",
|
||||
"\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
|
||||
"\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
|
||||
"\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
|
||||
"\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
|
||||
"\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
|
||||
"\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
|
||||
"\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
|
||||
"\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
|
||||
"\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
|
||||
"\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
|
||||
].join("")
|
||||
);
|
||||
};
|
||||
|
||||
/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
|
||||
the maintain v2 API compatibility
|
||||
*/
|
||||
// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
|
||||
SWFUpload.prototype.addSetting = function (name, value, default_value) {
|
||||
if (value == undefined) {
|
||||
return (this.settings[name] = default_value);
|
||||
} else {
|
||||
return (this.settings[name] = value);
|
||||
}
|
||||
};
|
||||
|
||||
// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
|
||||
SWFUpload.prototype.getSetting = function (name) {
|
||||
if (this.settings[name] != undefined) {
|
||||
return this.settings[name];
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Private: callFlash handles function calls made to the Flash element.
|
||||
// Calls are made with a setTimeout for some functions to work around
|
||||
// bugs in the ExternalInterface library.
|
||||
SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
|
||||
argumentArray = argumentArray || [];
|
||||
|
||||
var movieElement = this.getMovieElement();
|
||||
var returnValue, returnString;
|
||||
|
||||
// Flash's method if calling ExternalInterface methods (code adapted from MooTools).
|
||||
try {
|
||||
returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
|
||||
returnValue = eval(returnString);
|
||||
} catch (ex) {
|
||||
throw "Call to " + functionName + " failed";
|
||||
}
|
||||
|
||||
// Unescape file post param values
|
||||
if (returnValue != undefined && typeof returnValue.post === "object") {
|
||||
returnValue = this.unescapeFilePostParams(returnValue);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
|
||||
/* *****************************
|
||||
-- Flash control methods --
|
||||
Your UI should use these
|
||||
to operate SWFUpload
|
||||
***************************** */
|
||||
|
||||
// WARNING: this function does not work in Flash Player 10
|
||||
// Public: selectFile causes a File Selection Dialog window to appear. This
|
||||
// dialog only allows 1 file to be selected.
|
||||
SWFUpload.prototype.selectFile = function () {
|
||||
this.callFlash("SelectFile");
|
||||
};
|
||||
|
||||
// WARNING: this function does not work in Flash Player 10
|
||||
// Public: selectFiles causes a File Selection Dialog window to appear/ This
|
||||
// dialog allows the user to select any number of files
|
||||
// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
|
||||
// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
|
||||
// for this bug.
|
||||
SWFUpload.prototype.selectFiles = function () {
|
||||
this.callFlash("SelectFiles");
|
||||
};
|
||||
|
||||
|
||||
// Public: startUpload starts uploading the first file in the queue unless
|
||||
// the optional parameter 'fileID' specifies the ID
|
||||
SWFUpload.prototype.startUpload = function (fileID) {
|
||||
this.callFlash("StartUpload", [fileID]);
|
||||
};
|
||||
|
||||
// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
|
||||
// If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
|
||||
// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
|
||||
SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
|
||||
if (triggerErrorEvent !== false) {
|
||||
triggerErrorEvent = true;
|
||||
}
|
||||
this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
|
||||
};
|
||||
|
||||
// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
|
||||
// If nothing is currently uploading then nothing happens.
|
||||
SWFUpload.prototype.stopUpload = function () {
|
||||
this.callFlash("StopUpload");
|
||||
};
|
||||
|
||||
/* ************************
|
||||
* Settings methods
|
||||
* These methods change the SWFUpload settings.
|
||||
* SWFUpload settings should not be changed directly on the settings object
|
||||
* since many of the settings need to be passed to Flash in order to take
|
||||
* effect.
|
||||
* *********************** */
|
||||
|
||||
// Public: getStats gets the file statistics object.
|
||||
SWFUpload.prototype.getStats = function () {
|
||||
return this.callFlash("GetStats");
|
||||
};
|
||||
|
||||
// Public: setStats changes the SWFUpload statistics. You shouldn't need to
|
||||
// change the statistics but you can. Changing the statistics does not
|
||||
// affect SWFUpload accept for the successful_uploads count which is used
|
||||
// by the upload_limit setting to determine how many files the user may upload.
|
||||
SWFUpload.prototype.setStats = function (statsObject) {
|
||||
this.callFlash("SetStats", [statsObject]);
|
||||
};
|
||||
|
||||
// Public: getFile retrieves a File object by ID or Index. If the file is
|
||||
// not found then 'null' is returned.
|
||||
SWFUpload.prototype.getFile = function (fileID) {
|
||||
if (typeof(fileID) === "number") {
|
||||
return this.callFlash("GetFileByIndex", [fileID]);
|
||||
} else {
|
||||
return this.callFlash("GetFile", [fileID]);
|
||||
}
|
||||
};
|
||||
|
||||
// Public: addFileParam sets a name/value pair that will be posted with the
|
||||
// file specified by the Files ID. If the name already exists then the
|
||||
// exiting value will be overwritten.
|
||||
SWFUpload.prototype.addFileParam = function (fileID, name, value) {
|
||||
return this.callFlash("AddFileParam", [fileID, name, value]);
|
||||
};
|
||||
|
||||
// Public: removeFileParam removes a previously set (by addFileParam) name/value
|
||||
// pair from the specified file.
|
||||
SWFUpload.prototype.removeFileParam = function (fileID, name) {
|
||||
this.callFlash("RemoveFileParam", [fileID, name]);
|
||||
};
|
||||
|
||||
// Public: setUploadUrl changes the upload_url setting.
|
||||
SWFUpload.prototype.setUploadURL = function (url) {
|
||||
this.settings.upload_url = url.toString();
|
||||
this.callFlash("SetUploadURL", [url]);
|
||||
};
|
||||
|
||||
// Public: setPostParams changes the post_params setting
|
||||
SWFUpload.prototype.setPostParams = function (paramsObject) {
|
||||
this.settings.post_params = paramsObject;
|
||||
this.callFlash("SetPostParams", [paramsObject]);
|
||||
};
|
||||
|
||||
// Public: addPostParam adds post name/value pair. Each name can have only one value.
|
||||
SWFUpload.prototype.addPostParam = function (name, value) {
|
||||
this.settings.post_params[name] = value;
|
||||
this.callFlash("SetPostParams", [this.settings.post_params]);
|
||||
};
|
||||
|
||||
// Public: removePostParam deletes post name/value pair.
|
||||
SWFUpload.prototype.removePostParam = function (name) {
|
||||
delete this.settings.post_params[name];
|
||||
this.callFlash("SetPostParams", [this.settings.post_params]);
|
||||
};
|
||||
|
||||
// Public: setFileTypes changes the file_types setting and the file_types_description setting
|
||||
SWFUpload.prototype.setFileTypes = function (types, description) {
|
||||
this.settings.file_types = types;
|
||||
this.settings.file_types_description = description;
|
||||
this.callFlash("SetFileTypes", [types, description]);
|
||||
};
|
||||
|
||||
// Public: setFileSizeLimit changes the file_size_limit setting
|
||||
SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
|
||||
this.settings.file_size_limit = fileSizeLimit;
|
||||
this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
|
||||
};
|
||||
|
||||
// Public: setFileUploadLimit changes the file_upload_limit setting
|
||||
SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
|
||||
this.settings.file_upload_limit = fileUploadLimit;
|
||||
this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
|
||||
};
|
||||
|
||||
// Public: setFileQueueLimit changes the file_queue_limit setting
|
||||
SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
|
||||
this.settings.file_queue_limit = fileQueueLimit;
|
||||
this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
|
||||
};
|
||||
|
||||
// Public: setFilePostName changes the file_post_name setting
|
||||
SWFUpload.prototype.setFilePostName = function (filePostName) {
|
||||
this.settings.file_post_name = filePostName;
|
||||
this.callFlash("SetFilePostName", [filePostName]);
|
||||
};
|
||||
|
||||
// Public: setUseQueryString changes the use_query_string setting
|
||||
SWFUpload.prototype.setUseQueryString = function (useQueryString) {
|
||||
this.settings.use_query_string = useQueryString;
|
||||
this.callFlash("SetUseQueryString", [useQueryString]);
|
||||
};
|
||||
|
||||
// Public: setRequeueOnError changes the requeue_on_error setting
|
||||
SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
|
||||
this.settings.requeue_on_error = requeueOnError;
|
||||
this.callFlash("SetRequeueOnError", [requeueOnError]);
|
||||
};
|
||||
|
||||
// Public: setHTTPSuccess changes the http_success setting
|
||||
SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
|
||||
if (typeof http_status_codes === "string") {
|
||||
http_status_codes = http_status_codes.replace(" ", "").split(",");
|
||||
}
|
||||
|
||||
this.settings.http_success = http_status_codes;
|
||||
this.callFlash("SetHTTPSuccess", [http_status_codes]);
|
||||
};
|
||||
|
||||
|
||||
// Public: setDebugEnabled changes the debug_enabled setting
|
||||
SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
|
||||
this.settings.debug_enabled = debugEnabled;
|
||||
this.callFlash("SetDebugEnabled", [debugEnabled]);
|
||||
};
|
||||
|
||||
// Public: setButtonImageURL loads a button image sprite
|
||||
SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
|
||||
if (buttonImageURL == undefined) {
|
||||
buttonImageURL = "";
|
||||
}
|
||||
|
||||
this.settings.button_image_url = buttonImageURL;
|
||||
this.callFlash("SetButtonImageURL", [buttonImageURL]);
|
||||
};
|
||||
|
||||
// Public: setButtonDimensions resizes the Flash Movie and button
|
||||
SWFUpload.prototype.setButtonDimensions = function (width, height) {
|
||||
this.settings.button_width = width;
|
||||
this.settings.button_height = height;
|
||||
|
||||
var movie = this.getMovieElement();
|
||||
if (movie != undefined) {
|
||||
movie.style.width = width + "px";
|
||||
movie.style.height = height + "px";
|
||||
}
|
||||
|
||||
this.callFlash("SetButtonDimensions", [width, height]);
|
||||
};
|
||||
// Public: setButtonText Changes the text overlaid on the button
|
||||
SWFUpload.prototype.setButtonText = function (html) {
|
||||
this.settings.button_text = html;
|
||||
this.callFlash("SetButtonText", [html]);
|
||||
};
|
||||
// Public: setButtonTextPadding changes the top and left padding of the text overlay
|
||||
SWFUpload.prototype.setButtonTextPadding = function (left, top) {
|
||||
this.settings.button_text_top_padding = top;
|
||||
this.settings.button_text_left_padding = left;
|
||||
this.callFlash("SetButtonTextPadding", [left, top]);
|
||||
};
|
||||
|
||||
// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
|
||||
SWFUpload.prototype.setButtonTextStyle = function (css) {
|
||||
this.settings.button_text_style = css;
|
||||
this.callFlash("SetButtonTextStyle", [css]);
|
||||
};
|
||||
// Public: setButtonDisabled disables/enables the button
|
||||
SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
|
||||
this.settings.button_disabled = isDisabled;
|
||||
this.callFlash("SetButtonDisabled", [isDisabled]);
|
||||
};
|
||||
// Public: setButtonAction sets the action that occurs when the button is clicked
|
||||
SWFUpload.prototype.setButtonAction = function (buttonAction) {
|
||||
this.settings.button_action = buttonAction;
|
||||
this.callFlash("SetButtonAction", [buttonAction]);
|
||||
};
|
||||
|
||||
// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
|
||||
SWFUpload.prototype.setButtonCursor = function (cursor) {
|
||||
this.settings.button_cursor = cursor;
|
||||
this.callFlash("SetButtonCursor", [cursor]);
|
||||
};
|
||||
|
||||
/* *******************************
|
||||
Flash Event Interfaces
|
||||
These functions are used by Flash to trigger the various
|
||||
events.
|
||||
|
||||
All these functions a Private.
|
||||
|
||||
Because the ExternalInterface library is buggy the event calls
|
||||
are added to a queue and the queue then executed by a setTimeout.
|
||||
This ensures that events are executed in a determinate order and that
|
||||
the ExternalInterface bugs are avoided.
|
||||
******************************* */
|
||||
|
||||
SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
|
||||
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
||||
|
||||
if (argumentArray == undefined) {
|
||||
argumentArray = [];
|
||||
} else if (!(argumentArray instanceof Array)) {
|
||||
argumentArray = [argumentArray];
|
||||
}
|
||||
|
||||
var self = this;
|
||||
if (typeof this.settings[handlerName] === "function") {
|
||||
// Queue the event
|
||||
this.eventQueue.push(function () {
|
||||
this.settings[handlerName].apply(this, argumentArray);
|
||||
});
|
||||
|
||||
// Execute the next queued event
|
||||
setTimeout(function () {
|
||||
self.executeNextEvent();
|
||||
}, 0);
|
||||
|
||||
} else if (this.settings[handlerName] !== null) {
|
||||
throw "Event handler " + handlerName + " is unknown or is not a function";
|
||||
}
|
||||
};
|
||||
|
||||
// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
|
||||
// we must queue them in order to garentee that they are executed in order.
|
||||
SWFUpload.prototype.executeNextEvent = function () {
|
||||
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
||||
|
||||
var f = this.eventQueue ? this.eventQueue.shift() : null;
|
||||
if (typeof(f) === "function") {
|
||||
f.apply(this);
|
||||
}
|
||||
};
|
||||
|
||||
// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
|
||||
// properties that contain characters that are not valid for JavaScript identifiers. To work around this
|
||||
// the Flash Component escapes the parameter names and we must unescape again before passing them along.
|
||||
SWFUpload.prototype.unescapeFilePostParams = function (file) {
|
||||
var reg = /[$]([0-9a-f]{4})/i;
|
||||
var unescapedPost = {};
|
||||
var uk;
|
||||
|
||||
if (file != undefined) {
|
||||
for (var k in file.post) {
|
||||
if (file.post.hasOwnProperty(k)) {
|
||||
uk = k;
|
||||
var match;
|
||||
while ((match = reg.exec(uk)) !== null) {
|
||||
uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
|
||||
}
|
||||
unescapedPost[uk] = file.post[k];
|
||||
}
|
||||
}
|
||||
|
||||
file.post = unescapedPost;
|
||||
}
|
||||
|
||||
return file;
|
||||
};
|
||||
|
||||
SWFUpload.prototype.flashReady = function () {
|
||||
// Check that the movie element is loaded correctly with its ExternalInterface methods defined
|
||||
var movieElement = this.getMovieElement();
|
||||
|
||||
// Pro-actively unhook all the Flash functions
|
||||
if (typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
|
||||
this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
|
||||
for (var key in movieElement) {
|
||||
try {
|
||||
if (typeof(movieElement[key]) === "function") {
|
||||
movieElement[key] = null;
|
||||
}
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.queueEvent("swfupload_loaded_handler");
|
||||
};
|
||||
|
||||
|
||||
/* This is a chance to do something before the browse window opens */
|
||||
SWFUpload.prototype.fileDialogStart = function () {
|
||||
this.queueEvent("file_dialog_start_handler");
|
||||
};
|
||||
|
||||
|
||||
/* Called when a file is successfully added to the queue. */
|
||||
SWFUpload.prototype.fileQueued = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("file_queued_handler", file);
|
||||
};
|
||||
|
||||
|
||||
/* Handle errors that occur when an attempt to queue a file fails. */
|
||||
SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
|
||||
};
|
||||
|
||||
/* Called after the file dialog has closed and the selected files have been queued.
|
||||
You could call startUpload here if you want the queued files to begin uploading immediately. */
|
||||
SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued) {
|
||||
this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadStart = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("return_upload_start_handler", file);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.returnUploadStart = function (file) {
|
||||
var returnValue;
|
||||
if (typeof this.settings.upload_start_handler === "function") {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
returnValue = this.settings.upload_start_handler.call(this, file);
|
||||
} else if (this.settings.upload_start_handler != undefined) {
|
||||
throw "upload_start_handler must be a function";
|
||||
}
|
||||
|
||||
// Convert undefined to true so if nothing is returned from the upload_start_handler it is
|
||||
// interpretted as 'true'.
|
||||
if (returnValue === undefined) {
|
||||
returnValue = true;
|
||||
}
|
||||
|
||||
returnValue = !!returnValue;
|
||||
|
||||
this.callFlash("ReturnUploadStart", [returnValue]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadError = function (file, errorCode, message) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_error_handler", [file, errorCode, message]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadSuccess = function (file, serverData) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_success_handler", [file, serverData]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadComplete = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_complete_handler", file);
|
||||
};
|
||||
|
||||
/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
|
||||
internal debug console. You can override this event and have messages written where you want. */
|
||||
SWFUpload.prototype.debug = function (message) {
|
||||
this.queueEvent("debug_handler", message);
|
||||
};
|
||||
|
||||
|
||||
/* **********************************
|
||||
Debug Console
|
||||
The debug console is a self contained, in page location
|
||||
for debug message to be sent. The Debug Console adds
|
||||
itself to the body if necessary.
|
||||
|
||||
The console is automatically scrolled as messages appear.
|
||||
|
||||
If you are using your own debug handler or when you deploy to production and
|
||||
have debug disabled you can remove these functions to reduce the file size
|
||||
and complexity.
|
||||
********************************** */
|
||||
|
||||
// Private: debugMessage is the default debug_handler. If you want to print debug messages
|
||||
// call the debug() function. When overriding the function your own function should
|
||||
// check to see if the debug setting is true before outputting debug information.
|
||||
SWFUpload.prototype.debugMessage = function (message) {
|
||||
if (this.settings.debug) {
|
||||
var exceptionMessage, exceptionValues = [];
|
||||
|
||||
// Check for an exception object and print it nicely
|
||||
if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
|
||||
for (var key in message) {
|
||||
if (message.hasOwnProperty(key)) {
|
||||
exceptionValues.push(key + ": " + message[key]);
|
||||
}
|
||||
}
|
||||
exceptionMessage = exceptionValues.join("\n") || "";
|
||||
exceptionValues = exceptionMessage.split("\n");
|
||||
exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
|
||||
SWFUpload.Console.writeLine(exceptionMessage);
|
||||
} else {
|
||||
SWFUpload.Console.writeLine(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SWFUpload.Console = {};
|
||||
SWFUpload.Console.writeLine = function (message) {
|
||||
var console, documentForm;
|
||||
|
||||
try {
|
||||
console = document.getElementById("SWFUpload_Console");
|
||||
|
||||
if (!console) {
|
||||
documentForm = document.createElement("form");
|
||||
document.getElementsByTagName("body")[0].appendChild(documentForm);
|
||||
|
||||
console = document.createElement("textarea");
|
||||
console.id = "SWFUpload_Console";
|
||||
console.style.fontFamily = "monospace";
|
||||
console.setAttribute("wrap", "off");
|
||||
console.wrap = "off";
|
||||
console.style.overflow = "auto";
|
||||
console.style.width = "700px";
|
||||
console.style.height = "350px";
|
||||
console.style.margin = "5px";
|
||||
documentForm.appendChild(console);
|
||||
}
|
||||
|
||||
console.value += message + "\n";
|
||||
|
||||
console.scrollTop = console.scrollHeight - console.clientHeight;
|
||||
} catch (ex) {
|
||||
alert("Exception: " + ex.name + " Message: " + ex.message);
|
||||
}
|
||||
};
|
||||
112
resources/xajax/xajax_plugins/response/tableUpdater.inc.php
Normal file
112
resources/xajax/xajax_plugins/response/tableUpdater.inc.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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';}
|
||||
class clsTableUpdater extends xajaxResponsePlugin{var $sDefer;var $sJavascriptURI;var $bInlineScript;function clsTableUpdater(){$this->sDefer='';$this->sJavascriptURI='';$this->bInlineScript=true;}
|
||||
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(){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);}
|
||||
function appendTable($table,$parent){$command=array(
|
||||
'cmd'=>'et_at',
|
||||
'id'=>$parent
|
||||
);$this->addCommand($command,$table);}
|
||||
function insertTable($table,$parent,$position){$command=array(
|
||||
'cmd'=>'et_it',
|
||||
'id'=>$parent,
|
||||
'pos'=>$position
|
||||
);$this->addCommand($command,$table);}
|
||||
function deleteTable($table){$this->addCommand(
|
||||
array(
|
||||
'cmd'=>'et_dt'
|
||||
),
|
||||
$table
|
||||
);}
|
||||
function appendRow($row,$parent,$position=null){$command=array(
|
||||
'cmd'=>'et_ar',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,$row);}
|
||||
function insertRow($row,$parent,$position=null,$before=null){$command=array(
|
||||
'cmd'=>'et_ir',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;if(null!=$before)
|
||||
$command['type']=$before;$this->addCommand($command,$row);}
|
||||
function replaceRow($row,$parent,$position=null,$before=null){$command=array(
|
||||
'cmd'=>'et_rr',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;if(null!=$before)
|
||||
$command['type']=$before;$this->addCommand($command,$row);}
|
||||
function deleteRow($parent,$position=null){$command=array(
|
||||
'cmd'=>'et_dr',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,null);}
|
||||
function assignRow($values,$parent,$position=null,$start_column=null){$command=array(
|
||||
'cmd'=>'et_asr',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;if(null!=$start_column)
|
||||
$command['type']=$start_column;$this->addCommand($command,$values);}
|
||||
function assignRowProperty($property,$value,$parent,$position=null){$command=array(
|
||||
'cmd'=>'et_asrp',
|
||||
'id'=>$parent,
|
||||
'prop'=>$property
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,$value);}
|
||||
function appendColumn($column,$parent,$position=null){$command=array(
|
||||
'cmd'=>'et_acol',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,$column);}
|
||||
function insertColumn($column,$parent,$position=null){$command=array(
|
||||
'cmd'=>'et_icol',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,$column);}
|
||||
function replaceColumn($column,$parent,$position=null){$command=array(
|
||||
'cmd'=>'et_rcol',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,$column);}
|
||||
function deleteColumn($parent,$position=null){$command=array(
|
||||
'cmd'=>'et_dcol',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,null);}
|
||||
function assignColumn($values,$parent,$position=null,$start_row=null){$command=array(
|
||||
'cmd'=>'et_ascol',
|
||||
'id'=>$parent
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;if(null!=$start_row)
|
||||
$command['type']=$start_row;$this->addCommand($command,$values);}
|
||||
function assignColumnProperty($property,$value,$parent,$position=null){$command=array(
|
||||
'cmd'=>'et_ascolp',
|
||||
'id'=>$parent,
|
||||
'prop'=>$property
|
||||
);if(null!=$position)
|
||||
$command['pos']=$position;$this->addCommand($command,$value);}
|
||||
function assignCell($row,$column,$value){$this->addCommand(
|
||||
array(
|
||||
'cmd'=>'et_asc',
|
||||
'id'=>$row,
|
||||
'pos'=>$column
|
||||
),
|
||||
$value
|
||||
);}
|
||||
function assignCellProperty($row,$column,$property,$value){$this->addCommand(
|
||||
array(
|
||||
'cmd'=>'et_ascp',
|
||||
'id'=>$row,
|
||||
'pos'=>$column,
|
||||
'prop'=>$property
|
||||
),
|
||||
$value
|
||||
);}
|
||||
}
|
||||
$objPluginManager=&xajaxPluginManager::getInstance();$objPluginManager->registerPlugin(new clsTableUpdater());
|
||||
528
resources/xajax/xajax_plugins/response/tableUpdater.js
Normal file
528
resources/xajax/xajax_plugins/response/tableUpdater.js
Normal file
@@ -0,0 +1,528 @@
|
||||
// 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' == typeof 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' == typeof 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' == typeof 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' != typeof params.body)
|
||||
params.rows = params.body.getElementsByTagName('TR');
|
||||
if ('undefined' != typeof params.row)
|
||||
params.cells = params.row.getElementsByTagName('TD');
|
||||
if ('undefined' != typeof params.header)
|
||||
params.columns = params.header.getElementsByTagName('TD');
|
||||
|
||||
if ('undefined' == typeof 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' == typeof 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' == typeof 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' == typeof objects.body) {
|
||||
var tbody = document.createElement('tbody');
|
||||
if (null != id)
|
||||
tbody.id = id;
|
||||
objects.body = tbody;
|
||||
}
|
||||
if ('undefined' != typeof 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' != typeof 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' == typeof 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' == typeof position)
|
||||
throw { name: 'TableError', message: 'Missing row number / id.' }
|
||||
if ('undefined' == typeof objects.row)
|
||||
if ('undefined' != typeof objects.rows)
|
||||
if ('undefined' != typeof objects.rows[position])
|
||||
objects.row = objects.rows[position];
|
||||
if ('undefined' == typeof objects.row)
|
||||
objects.row = xajax.$(position);
|
||||
if ('undefined' == typeof 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' != typeof 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' == typeof objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
var row = xajax.ext.tables.internal.createRow(objects, id);
|
||||
if ('undefined' != typeof 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' == typeof objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
var row = xajax.ext.tables.internal.createRow(objects, id);
|
||||
if ('undefined' != typeof 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' == typeof objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
objects.body.removeChild(objects.row);
|
||||
}
|
||||
xajax.ext.tables.rows.assignProperty = function(value, source, position, property) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'body', 'header']);
|
||||
if ('undefined' == typeof objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
if ('undefined' != typeof property)
|
||||
eval('objects.row.' + property + ' = value;');
|
||||
}
|
||||
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' == typeof objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
if ('undefined' == typeof start_column)
|
||||
start_column = 0;
|
||||
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' == typeof position)
|
||||
throw { name: 'TableError', message: 'Missing column number / id.' }
|
||||
if ('undefined' == typeof objects.column)
|
||||
if ('undefined' != typeof objects.columns)
|
||||
if ('undefined' != typeof objects.columns[position])
|
||||
objects.column = position;
|
||||
if ('undefined' == typeof objects.column)
|
||||
for (var column = 0; 'undefined' == typeof objects.column && column < objects.columns.length; ++column)
|
||||
if (objects.columns[column].id == position)
|
||||
objects.column = column;
|
||||
if ('undefined' == typeof 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' != typeof column_definition.name)
|
||||
cell.innerHTML = column_definition.name;
|
||||
objects.header.firstChild.appendChild(cell);
|
||||
if ('undefined' != typeof 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' == typeof objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
var column = xajax.ext.tables.internal.createCell(objects, column_definition.id);
|
||||
if ('undefined' != typeof column_definition.name)
|
||||
column.innerHTML = column_definition.name;
|
||||
objects.header.firstChild.insertBefore(column, objects.columns[objects.column]);
|
||||
if ('undefined' != typeof 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' == typeof 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' != typeof column_definition.name)
|
||||
column.innerHTML = column_definition.name;
|
||||
objects.header.firstChild.insertBefore(column, before);
|
||||
objects.header.firstChild.removeChild(before);
|
||||
if ('undefined' != typeof 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' == typeof objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
objects.header.firstChild.removeChild(objects.columns[objects.column]);
|
||||
if ('undefined' != typeof 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' == typeof objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
for (var row = 0; row < values.length; ++row)
|
||||
xajax.ext.tables.cells.assign(values[row], objects.rows[start_row + row], objects.column);
|
||||
}
|
||||
xajax.ext.tables.columns.assignProperty = function(value, source, position, property) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'cell']);
|
||||
if ('undefined' == typeof objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
for (var row = 0; row < objects.rows.length; ++row)
|
||||
xajax.ext.tables.cells.assignProperty(value, objects.rows[row], objects.column, property);
|
||||
}
|
||||
// cells
|
||||
xajax.ext.tables.cells = {}
|
||||
xajax.ext.tables.cells.internal = {}
|
||||
xajax.ext.tables.cells.internal.calculateCell = function(objects, position) {
|
||||
if ('undefined' == typeof position)
|
||||
throw { name: 'TableError', message: 'Missing cell number / id.' }
|
||||
if ('undefined' == typeof objects.cell)
|
||||
if ('undefined' != typeof objects.cells)
|
||||
if ('undefined' != typeof objects.cells[position])
|
||||
objects.cell = objects.cells[position];
|
||||
if ('undefined' == typeof objects.cell)
|
||||
if ('undefined' != typeof objects.columns)
|
||||
for (var column = 0; 'undefined' == typeof objects.cell && column < objects.columns.length; ++column)
|
||||
if (objects.columns[column].id == position)
|
||||
objects.cell = objects.cells[column];
|
||||
if ('undefined' == typeof 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' != typeof 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' == typeof objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
|
||||
if ('undefined' != typeof 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' == typeof objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
|
||||
if ('undefined' != typeof 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' == typeof 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' == typeof objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
objects.cell.innerHTML = value;
|
||||
}
|
||||
xajax.ext.tables.cells.assignProperty = function(value, source, position, property) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
|
||||
if ('undefined' == typeof objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
eval('objects.cell.' + property + ' = value;');
|
||||
}
|
||||
|
||||
// command handlers
|
||||
|
||||
// tables
|
||||
xajax.command.handler.register('et_at', function(args) {
|
||||
args.fullName = 'ext.tables.append';
|
||||
xajax.ext.tables.append(args.data, args.id);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_it', function(args) {
|
||||
args.fullName = 'ext.tables.insert';
|
||||
xajax.ext.tables.insert(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_dt', function(args) {
|
||||
args.fullName = 'ext.tables.remove';
|
||||
xajax.ext.tables.remove(args.data);
|
||||
return true;
|
||||
});
|
||||
// rows
|
||||
xajax.command.handler.register('et_ar', function(args) {
|
||||
args.fullName = 'ext.tables.rows.append';
|
||||
xajax.ext.tables.rows.append(args.data, args.id);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_ir', function(args) {
|
||||
args.fullName = 'ext.tables.rows.insert';
|
||||
xajax.ext.tables.rows.insert(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_rr', function(args) {
|
||||
args.fullName = 'ext.tables.rows.replace';
|
||||
xajax.ext.tables.rows.replace(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_dr', function(args) {
|
||||
args.fullName = 'ext.tables.rows.remove';
|
||||
xajax.ext.tables.rows.remove(args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_asr', function(args) {
|
||||
args.fullName = 'ext.tables.rows.assign';
|
||||
xajax.ext.tables.rows.assign(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_asrp', function(args) {
|
||||
args.fullName = 'ext.tables.rows.assignProperty';
|
||||
xajax.ext.tables.rows.assignProperty(args.data, args.id, args.pos, args.prop);
|
||||
});
|
||||
// columns
|
||||
xajax.command.handler.register('et_acol', function(args) {
|
||||
args.fullName = 'ext.tables.columns.append';
|
||||
xajax.ext.tables.columns.append(args.data, args.id);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_icol', function(args) {
|
||||
args.fullName = 'ext.tables.columns.insert';
|
||||
xajax.ext.tables.columns.insert(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_rcol', function(args) {
|
||||
args.fullName = 'ext.tables.columns.replace';
|
||||
xajax.ext.tables.columns.replace(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_dcol', function(args) {
|
||||
args.fullName = 'ext.tables.columns.remove';
|
||||
xajax.ext.tables.columns.remove(args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_ascol', function(args) {
|
||||
args.fullName = 'ext.tables.columns.assign';
|
||||
xajax.ext.tables.columns.assign(args.data, args.id, args.pos, args.type);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_ascolp', function(args) {
|
||||
args.fullName = 'ext.tables.columns.assignProperty';
|
||||
xajax.ext.tables.columns.assignProperty(args.data, args.id, args.pos, args.prop);
|
||||
return true;
|
||||
});
|
||||
// cells
|
||||
xajax.command.handler.register('et_ac', function(args) {
|
||||
args.fullName = 'ext.tables.cells.append';
|
||||
xajax.ext.tables.cells.append(args.data, args.id);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_ic', function(args) {
|
||||
args.fullName = 'ext.tables.cells.insert';
|
||||
xajax.ext.tables.cells.insert(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_rc', function(args) {
|
||||
args.fullName = 'ext.tables.cells.replace';
|
||||
xajax.ext.tables.cells.replace(args.data, args.id, args.pos);
|
||||
});
|
||||
xajax.command.handler.register('et_dc', function(args) {
|
||||
args.fullName = 'ext.tables.cells.remove';
|
||||
xajax.ext.tables.cells.remove(args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_asc', function(args) {
|
||||
args.fullName = 'ext.tables.cells.assign';
|
||||
xajax.ext.tables.cells.assign(args.data, args.id, args.pos);
|
||||
return true;
|
||||
});
|
||||
xajax.command.handler.register('et_ascp', function(args) {
|
||||
args.fullName = 'ext.tables.cells.assignProperty';
|
||||
xajax.ext.tables.cells.assignProperty(args.data, args.id, args.pos, args.prop);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
installTableUpdater();
|
||||
Reference in New Issue
Block a user