EVME_HOSTING_PATH = "http://www.esprelive.com/sales/eagle/evme2.2.2/hosting/"; EVME_XSL_PATH = "http://www.esprelive.com/sales/eagle/evme2.2.2/mediaengine/"; EVME_HOST_DOMAIN = "www.esprelive.com"; EVME_CHAT_PATH = "http://www.esprelive.com/projects/parrot/evme2.2.2/chat/ChannelManager.php"; EVME_VXN_ADDR = "67.19.80.130"; EVME_VXN_PORT = "443"; //Actor.sdlPathType = "absolute"; function ComponentFactory(){ this.codebase = "http://www.esprelive.com/sales/eagle/evme2.2.2/mediaengine/components/"; var componentdata = eval({"components":{"encoder":{"code":"es.me.driver.encoder.AppletEncoder","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0","package_spec":""},"capture":{"code":"es.me.driver.capture.AppletCapture","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0","package_spec":""},"uploader":{"code":"es.me.driver.upload.AppletUpload","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"director":{"code":"es.theater.ClipContextApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"actor":{"code":"es.theater.ClipActorApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"sdlWriter":{"code":"es.theater.ClipContextApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"clipViewer":{"cache_archive":"cv.jar,evmResources.jar,eVChat.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0"},"clipViewerSigned":{"cache_archive":"cv_signed.jar,evmResources.jar,eVChat.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0"},"fileUtil":{"code":"es.me.espre.util.FileUtilityApplet","cache_archive":"me-fso_signed.jar,messaging_signed.jar,me-common_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0"},"evcInstaller":{"code":"es.installer.AppletUpgrade","cache_archive":"EvcInstaller.jar","\/\/cache_version":"1.0.0.0"},"evChat":{"code":"espre.eVChat.JChatApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"}}}); this.getAppletInformation = function (appletType) { if (componentdata['components'][appletType] != "" || componentdata['components'][appletType] != "undefined") { return componentdata['components'][appletType]; } else { return false; } } } function HostingAgent() { var that = this; if("undefined" == typeof HostingAgent.instance) { HostingAgent.instance = this; // define the singleton } if(this != HostingAgent.instance) return HostingAgent.instance; // return the singleton if it already exists var tm = null; var state = "blocked"; var queue = new Array(); var uploadRequest = null; // in process upload request holder var url = EVME_HOSTING_PATH; var namespace = "default"; var error = ""; var maxSize = 0; var progess = 0; var hostSize = 0; var nsCount = 0; var nsProCount = 0; var ProResCount = 0; this.http = HttpRequest; this.http(); var uploadApplet = null; // *** function getHostURL for testing this.getHostURL = function () { return url; } // *** function setHostURL this.setHostURL = function (_url) { if (this.isValidURL(_url)) { url = _url; return true; } else { return false; } } // *** function getNamespace for testing this.getNamespace = function () { return namespace; } // *** function setNamespace this.setNamespace = function (_namespace) { namespace = _namespace; return true; } // function createNamespace this.createNamespace = function (_namespace) { if (url != null) { var response = this.sendRequest("GET", url, Array("action=createNamespace","name=" + _namespace), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.createNamespace EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // function renameNamespace (currentName,newName) this.renameNamespace = function () { var curName; var newName; if (arguments.length == 1) { curName = namespace; newName = arguments[0]; } else if (arguments.length == 2) { curName = arguments[0]; newName = arguments[1]; } else { return false; } if (url != null) { var response = this.sendRequest("GET", url, Array("action=renameNamespace","name=" + curName,"newname=" + newName), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.renameNamespace EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // function deleteNamespace this.deleteNamespace = function () { var ns = ""; if (arguments.length == 1) { ns = arguments[0]; } else if (arguments.length == 0) { ns = this.getNamespace(); } if (url != null) { var response = this.sendRequest("GET", url,Array("action=deleteNamespace","name=" + ns), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.deleteNamespace EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // TODO: NOT YET IMPELMENTED this.getMaxPostSize = function (_size) { return maxSize; } // TODO: NOT YET IMPELMENTED this.setMaxPostSize = function (_size) { if (isNaN(_size) || (_size > 1024)) { return false; } else { maxSize = _size; } } this.deleteProject = function () { var _path = ''; var ns = ''; if (arguments.length == 1) { _path = arguments[0]; ns = this.getNamespace(); } else if (arguments.length == 2) { ns = arguments[0]; _path = arguments[1]; } else { return false; } if (url != null) { target = url + ns + "/" + _path + "/"; var response = this.sendRequest("GET", target, Array("action=deleteProject"), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.deleteProject EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // function renameProject this.renameProject = function () { var ns = ''; var newPath = ''; var oldPath = ''; if (arguments.length == 2) { oldPath = arguments[0]; newPath = arguments[1]; ns = this.getNamespace(); } else if (arguments.length == 3) { ns = arguments[0]; oldPath = arguments[1]; newPath = arguments[2]; } else { return false; } if (url != null) { target = url + ns + "/" + oldPath + "/"; var response = this.sendRequest("GET", target, Array("action=renameProject","newpath=" + newPath), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.renameProject EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } this.upload = function (_uploadRequest) { meLogger.write("Hosting Agent upload called."); if (!_uploadRequest) {return false;}; // empty upload request rejected!! if (url != null) { if (uploadApplet == null && tm == null) { var appSpec = new AppletSpec("uploader"); appSpec.setParameter("name","uploadApplet"); appSpec.setParameter("visible",false); AppletManager.theInstance().startApplet(appSpec,setAppletReadyState); } //meLogger.write("Url valid."); queue.push(_uploadRequest); //will get progress if (tm == null) { tm = setTimeout(processQueue, 50); } return true; // successfully posted request } else { return false; // unable to post request } } function setAppletReadyState(applet) { uploadApplet = applet; //alert(uploadApplet); setState('idle'); } function processQueue() { tm = null; meLogger.write("ProcessQueue: " + state); if (state == 'blocked') { tm = setTimeout(processQueue,50); return; } else if (state == 'busy') { tm = setTimeout(processQueue,50); return; } else if (queue.length == 0) { setState('idle'); return; } // must be idle and queue.length > 0; so process a request setState('busy'); uploadRequest = queue.shift(); var params = "action,upload,default," + uploadRequest.getMappedName(); var mfiles = uploadRequest.getManifestFiles(); meLogger.write("Number of files to be read :" + mfiles.length); for (var i = 0; i < mfiles.length; i++) { var buffer = mfiles[i].split('|'); if(i == 0) { tmp = buffer[0]; } else { tmp += "," + buffer[0]; } } files = tmp; target = url + escape(uploadRequest.getNameSpace()) + "/" + escape(uploadRequest.getName()) + "/"; meLogger.write("Target: " + target + " File: " + files + " Params: " + params); setState("uploading"); uploadApplet.ep_upload(target,files,params); meLogger.write('Upload started ....'); queryState(); //uploadApplet.ep_upload("http://sandbox2.espre.local:9002/hosting/test/jvo/","C:/Documents and Settings/jvo.ESPRE/eViewEngine/video.dat","action,upload"); } // add callback functions for status, progress, etc. function queryState() { uploadTimeout = null; var currentState = uploadApplet.ep_getUploadState(); meLogger.write("Query State: " + currentState + " " + that.getProgress() + "%"); if (currentState == "uploading") { uploadRequest.updateProgress(that.getProgress()); uploadTimeout = window.setTimeout(queryState,500); return; } if (currentState == "completed") { uploadRequest.updateProgress(that.getProgress()); setState(currentState); uploadRequest = null; } else if (currentState == "errored") { uploadRequest.setErrors(that.getErrors()); uploadRequest.updateProgress(that.getProgress()); setState(currentState); uploadRequest = null; } } this.getProgress = function(){ if(state == "uploading") { return (uploadApplet.ep_getProgress()); } if(state == "completed") return 100; return 0; } this.getErrors = function(){ if(state == "errored") return uploadApplet.ep_getErrors(); return ""; } this.isCompleted = function(){ if(uploadRequest == null && state == "completed") return true; return false; } this.isUploading = function(){ if(uploadRequest != null) return true; return false; } this.isError = function(){ if(uploadRequest == "errored") return true; return false; } //************************************************ /* this.getHostingInfo = function () { if (url === null) return false; param = new Array("action=query","ns.where.name==*","ns.columns=*","ns.created.show=true"); this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); //return this.responseText; // for testing } this.getHostingInfoDetail = function () { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==*","ns.columns=*","ns.create.show=true","ns.detail.show=true"); } else { param = new Array("action=query","","ns.columns=*","ns.create.show=true","ns.detail.show=true"); } this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); //return this.responseText; // for testing } */ this.getNamespaceList = function () { if (url === null) return false; var response = this.sendRequest("GET", url, Array("action=query","ns.columns=name"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getNamespaceList EXCEPTION: " + err.message); return null; } } else { return null; } } //getNamespaceInfo(String name) ?? should be namespace list? //the request to the server needs to look like this: //param = "action=query,ns.where.name=" + escape("=" + name) + ",ns.columns=*,ns.created.show=true"); //HTTPRequest.sendRequest("POST", url, param, "undefined", false); /* this.getNamespaceInfo = function (_namespace) { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==" + _namespace,"ns.columns=*","ns.create.show=true"); } else { param = new Array("action=query","ns.where.name==" + this.getNamespace(),"ns.columns=*","ns.create.show=true"); } this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); //return this.responseText; // for testing } this.getNamespaceCount = function (_namespace) { if (url === null) return false; if (!_namespace) return false; param = new Array("action=query","","ns.name.show=false","ns.created.show=false"); this.sendRequest("POST", url, param, "undefined", false); for (var i = 0; i < this.getNamespaceList().length; i++){ nsCount++; } return nsCount; //return this.responseText; } this.getNamespaceInfoDetail = function (_namespace) { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==" + _namespace,"ns.columns=*","ns.create.show=true","ns.detail.show=true"); } else { param = new Array("action=query","","ns.columns=*","ns.create.show=true","ns.detail.show=true"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); return this.responseText; // for testing } */ this.getDefaultFile = function () { var _namespace = "default"; var _groupname; if(arguments.length == 0) return ""; //BAD!! if(arguments.length == 1) { _groupname = arguments[0]; } else { _namespace = arguments[0]; _groupname = arguments[1]; } var requestUrl = url; if (url === null) return ""; requestUrl += _namespace + "/" + _groupname + "/"; var param = new Array(""); return this.sendRequest("GET", requestUrl, param, false); //return this.responseText; } /* // Don's initiative codes this.getNamespaceProjectsList = function () { if (url === null) return false; if (arguments.length == 1) { param = new Array("action=query","ns.where.name==" + arguments[0],"group.columns=*","ns.columns=*"); } else { param = new Array("action=query","ns.where.name==default","group.columns=*","ns.columns=*"); } this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); } */ this.getProjectList = function () { var ns = ''; if (arguments.length == 0) { ns = this.getNamespace(); } else if (arguments.length == 1) { ns = arguments[0]; } else { return false; } if (url === null) return false; target = url + ns + "/"; var response = this.sendRequest("GET", target, Array("action=query","ns.columns=*","ns.where.name=='" + ns + "'","group.columns=*"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getProjectList EXCEPTION: " + err.message); return null; } } else { return null; } } this.getMatchingProjectList = function () { var ns = ''; var path = ''; if (arguments.length == 1) { ns = this.getNamespace(); path = arguments[0] } else if (arguments.length == 2) { ns = arguments[0]; path = arguments[1] } else { return false; } if (url === null) return false; target = url + ns + "/" + path + "/"; var response = this.sendRequest("GET", target, Array("action=query","ns.where.name=='" + ns +"'","group.where.fqpath=LIKE '" + path + "'","group.columns=*"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getMatchingProjectList EXCEPTION: " + err.message); return null; } } else { return null; } } /* this.getNamespaceProjectsCount = function (_namespace) { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==" + _namespace,"group.*.show=false","ns.*.show=false"); } else { param = new Array("action=query","ns.where.name==default","group.*.show=false","ns.*.show=false"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); //parseJSON() gives error return this.responseText; } this.getProjectInfo = function (_project) { if (url === null) return false; if (_project != null) { param = new Array("action=query","proj.name.where==" + _proj,"ns.columns=*","proj.create.show=true"); } else { param = new Array("action=query","","proj.name.show=true","proj.create.show=true"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); return this.responseText; // for testing } this.getProjectInfoDetail = function (_project) { if (url === null) return false; if (_project != null) { param = new Array("action=query","proj.name.where==" + _proj,"ns.columns=*","proj.create.show=true"); } else { param = new Array("action=query","","proj.name.show=true","proj.create.show=true"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); return this.responseText; // for testing } */ this.getProjectResourceList = function () { var ns = ''; var path = ''; if (arguments.length == 1) { ns = this.getNamespace(); path = arguments[0]; } else if (arguments.length == 2) { ns = arguments[0]; path = arguments[1]; } else { return false; } if (url === null) return false; target = url + ns + "/" + path + "/"; var response = this.sendRequest("GET", url, Array("action=query","ns.where.name=='" + ns + "'","group.where.fqpath=='" + path + "'","resource.columns=name"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getProjectResourceList EXCEPTION: " + err.message); return null; } } else { return null; } } /* this.getProjectResourceCount = function (proPath) { if (this.isValidURL(url) == false) { return false; } else { for (var i = 0; i < proPath.length; i++) { proResCount++; } return proResCount; } } this.getResourceInfo = function (resList) { //var resList = new Array(); if (this.isValidURL(url) == false) { return false; } else { for (var i = 0; i < proj.length; i++) { resList[i] = new Array( new Array("resource", resource) ); } return resList; } } this.getResourceInfoDetail = function (resList) { //var resListDet = new Array(); if (this.isValidURL(url) == false) { return false; } else { for (var i = 0; i < resList.length; i++) { resListDetail[i] = new Array( new Array("project", resource), new Array("desc", "description"), new Array("detail", "detail") ); } return resListDetail; } } */ function setState(_state){ var oldState = state; if (_state != state){ state = _state; if(uploadRequest != null){ uploadRequest.updateState(state); } meLogger.write('HostingAgent: '+ oldState + ' -> ' + state); } } } // End of Hosting Agent HostingAgent.theInstance = function(){ if("undefined" == typeof HostingAgent.instance){ new HostingAgent(); } return HostingAgent.instance; } // ContextEventDescriptor.js function ContextEventDescriptor() { // example format 'mergeFinalized;1,et.main;success' // 'event;ctxId,htmlElementName;optionalArgs } ContextEventDescriptor.getEvent = function(eventDescriptor) { var event = null; if (ContextEventDescriptor.validate(eventDescriptor)) { event = eventDescriptor.split(';')[0]; } return event; } ContextEventDescriptor.getCtxId = function(eventDescriptor) { var ctxId = null; if (ContextEventDescriptor.validate(eventDescriptor)) { ctxId = eventDescriptor.split(';')[1].split(',')[0]; } return ctxId; } ContextEventDescriptor.getHtmlElement = function(eventDescriptor) { var element = null; if (ContextEventDescriptor.validate(eventDescriptor)) { element = eventDescriptor.split(';')[1].split(',')[1]; } return element; } ContextEventDescriptor.getOptionalArgs = function(eventDescriptor) { var args = null; if (ContextEventDescriptor.validate(eventDescriptor)) { args = eventDescriptor.split(';')[2]; } return args; } ContextEventDescriptor.validate = function(eventDescriptor) { var status = (eventDescriptor && isString(eventDescriptor) && (eventDescriptor.length > 0)); if (!status) { directorTrace('ContextEventDescriptor.validate INVALID DESCRIPTOR: ' + eventDescriptor); } return status; } ContextEventDescriptor.create = function(event,ctxId,actorName,optionalArgs) { var descriptor = null; if (typeof event != 'undefined') { if (typeof ctxId == 'undefined') { ctxId = 'null'; } if (typeof actorName == 'undefined') { actorName = 'null'; } if (typeof optionalArgs == 'undefined') { optionalArgs = 'null'; } descriptor = event + ';' + ctxId + ',' + actorName + ';' + optionalArgs; } return descriptor; } // $Id$ function EncodeRequest() { var that = this; //Let the private functions access the object instance. //acquire ParameterManager capabilities this.PMgr = ParameterManager; this.PMgr("general"); var encoder = Encoder.theInstance(); // get the singleton. var requestState = "idle"; // use this to track the request // states are: idle, encoding, completed, errored, cancelled this.integerStringValidator = function (group, name, _value) { //meLogger.write('Integer String Validator Called', 1); if(isNaN(parseInt(_value)))return false; return true; } // define the progress parameters this.defineParameter("general","xmlFile"); this.defineParameter("general","sdlFile"); this.defineParameter("general","videoProgress","defaultValue","0","validator",this.integerStringValidator); this.defineParameter("general","audioProgress","defaultValue","0","validator",this.integerStringValidator); //API functions this.startEncode = function(){ if(requestState == "encoding") return false; var _xmlFile = this.getParameter('xmlFile'); var _sdlFile = this.getParameter('sdlFile'); if((_xmlFile === null) || (_sdlFile === null)) return false; // must have an xml file. _xmlFile = _xmlFile.replace(/\\/g, "/"); _sdlFile = _sdlFile.replace(/\\/g, "/"); this.setParameter("general","xmlFile",_xmlFile); this.setParameter("general","sdlFile",_sdlFile); meLogger.write(_xmlFile, 2); var result = encoder.startEncode(this); if(result == true){ setRequestState("encoding"); } else{ setRequestState("errored"); this.setParameter("errors","Encoder busy with another request"); } return result; // true indicates that the request has been posted } this.start = this.startEncode; this.cancelEncode = function(){ if(requestState == "encoding") encoder.cancelEncode(this); setRequestState("cancelled") return; } this.cancel = this.cancelEncode; this.getProgress = function(){ if(requestState == "encoding") { return (this.getParameter("videoProgress") + this.getParameter("audioProgress"))/2; } if(requestState == "completed") return 100; return 0; } this.getVideoProgress = function(){ if(requestState == "encoding") return this.getParameter("videoProgress"); if(requestState == "completed") return 100; return 0; } this.getAudioProgress = function(){ if(requestState == "encoding") return this.getParameter("audioProgress"); if(requestState == "completed") return 100; return 0; } this.getErrors = function(){ if(requestState == "errored") return this.getParameter("errors"); return ""; } this.isCompleted = function(){ if(requestState == "completed" || requestState == "cancelled") return true; return false; } this.isEncoding = function(){ if(requestState == "encoding") return true; return false; } this.isError = function(){ if(requestState == "errored") return true; return false; } this.getState = function(){ return requestState; } // Private functions function setRequestState(_state){ var oldState = requestState; if (_state != requestState){ requestState = _state; meLogger.write('EncodeRequest: '+ oldState + ' -> ' + requestState); } } // add public callback functions for status, progress, etc. this.updateVideoProgress = function(_value) { this.setParameter("videoProgress",_value); } this.updateAudioProgress = function(_value) { this.setParameter("audioProgress",_value); } this.updateState = function(_state){ if(_state == "initializing" || _state == "ready") return; if(_state == "errored"){ this.setParameter("errors",encoder.getErrors()); meLogger.write(encoder.getErrors(), 3); } setRequestState(_state); } } function AVDevice(audio, video) { if(AVDevice.deviceAppletState === null || AVDevice.isInitializing()) return null; // must have supporting applet running var that = this; //*** DEVICE APPLET STATES ( AVDevice.deviceAppletState ) are: initializing, ready, active *** this.PMgr = ParameterManager; // From ParameterManager.js (JavaScript file) this.PMgr("device"); // this.eventManager = EventManager; //support events // this.eventManager(); //Device Object Array and Object ID to track the Device Objects that are Created this.objectID = AVDevice.AVDeviceObjectArray.length; AVDevice.AVDeviceObjectArray[this.objectID] = this; var captureTimeout = null; // define validators for parameter management this.integerStringValidator = function (group, name, _value) { if(isNaN(_value)) return false; return true; }; this.audioIndexValidator = function (group, name, _value) { if(isNaN(_value)) return false; // must be an integer var value = parseInt(_value); if(value < -1) return false; // range from -1 to return true; }; this.videoIndexValidator = function (group, name, _value) { if(isNaN(_value)) return false; // must be an integer var value = parseInt(_value); if(value < -1) return false; // range from -1 to return true; }; this.audioNameValidator = function (group, name, _value) { if(typeof _value != "string") return false; return true; }; this.videoNameValidator = function (group, name, _value) { if(typeof _value != "string") return false; return true; }; //Parameters Allowed for each device object this.defineParameter("device","audioIndex","defaultValue",-1,"validator",this.audioIndexValidator); //Index from the Audio Devices Array this.defineParameter("device","videoIndex","defaultValue",-1,"validator",this.videoIndexValidator); //Index from the Video Devices Array this.defineParameter("device","audioName","defaultValue","","validator",this.audioNameValidator); //Name from the Audio Devices Array this.defineParameter("device","videoName","defaultValue","","validator",this.videoNameValidator); //Name from the Video Devices Array //User Defined Device Parameters this.defineParameter("device","framerate","defaultValue",30); //Frame Rate this.defineParameter("device","height","defaultValue",240); //Resolution Height this.defineParameter("device","width","defaultValue",320); //Resolution Width this.defineParameter("device","timelimit","defaultValue",120); //Timelimit for Capture Process this.defineParameter("device","outputfile","defaultValue","./default.avi"); // File name for the captured (AVI) file (Path is optional and the default path is User's Home Directory) //To Retrieve Capture Progress this.defineParameter("device","captureProgress","defaultValue","0","validator",this.integerStringValidator); //instance state model properties. this.setProperty("device","captureStateModel","captureState",false); this.setProperty("device","captureStateModel","completedState",false); this.setProperty("device","captureStateModel","erroredState",false); this.setProperty("device","previewStateModel","previewState",false); //Public Method to Start the Preview Process this.startPreview = function() { if (AVDevice.deviceAppletState === null || AVDevice.deviceAppletState == "initializing") return false; if(!this.isActive() && AVDevice.deviceAppletState == "busy"){ if(AVDevice.theActiveInstance().isCapturing()) return false; // don't disturb a capture if(AVDevice.theActiveInstance().isPreviewing()) AVDevice.theActiveInstance().stopPreview(); } if(!this.isCapturing()){ // Assert current parameters if(!declareActive()) return false; // couldn't find an AVDevice pair directorTrace('AVDevice.startPreview' + '\n outputfile: ' + this.getParameter("outputfile") + '\n height: ' + this.getParameter("height") + '\n width: ' + this.getParameter("width") + '\n timelimit: ' + this.getParameter("timelimit") + '\n framerate: ' + this.getParameter("framerate")); AVDevice.deviceApplet.ep_setCaptureParams(this.getParameter("outputfile"), this.getParameter("height"), this.getParameter("width"), this.getParameter("timelimit"), this.getParameter("framerate")); AVDevice.deviceApplet.ep_setActiveDevice(AVDevice.activeAudio,AVDevice.activeVideo); //must follow ep_setCaptureParams } AVDevice.deviceApplet.ep_setPreview(true); setAppletState("busy"); this.setProperty("device","previewStateModel","previewState",true); return true; }; //Public Method to Stop the Preview Process this.stopPreview = function() { if (!this.isActive() || !this.isPreviewing()) return true; //nothing to do AVDevice.deviceApplet.ep_setPreview(false); if(!this.isCapturing()) setAppletState("ready"); this.setProperty("device","previewStateModel","previewState",false); return true; }; //Public Method to determine whether the Preview Process is in Progress this.isPreviewing = function() { return this.getProperty("device","previewStateModel","previewState"); }; //Public Method to Start the Capture Process this.startCapture = function(_timelimit) { //timelimit optional if (AVDevice.deviceAppletState === null || AVDevice.deviceAppletState == "initializing") return false; if(this.isCapturing()) return true; // already capturing, do nothing if(!this.isActive() && AVDevice.deviceAppletState == "busy"){ if(AVDevice.theActiveInstance().isCapturing()) return false; // don't disturb a capture if(AVDevice.theActiveInstance().isPreviewing()) AVDevice.theActiveInstance().stopPreview(); } //alert("We are capturing using AVDevice!!!"); var timelimit = this.getParameter("timelimit"); if(!(typeof _timelimit == "undefined") && !isNaN(_timelimit)) timelimit = _timelimit; if(!declareActive()) return false; // couldn't find an AVDevice pair AVDevice.deviceApplet.ep_setActiveDevice(AVDevice.activeAudio,AVDevice.activeVideo); AVDevice.deviceApplet.ep_startCapture(this.getParameter("outputfile"), this.getParameter("height"), this.getParameter("width"), timelimit, this.getParameter("framerate")); setAppletState("busy"); this.setProperty("device","captureStateModel","captureState",true); this.setProperty("device","captureStateModel","completedState",false); this.setProperty("device","captureStateModel","erroredState",false); setTimeout(queryCaptureState,500); return true; }; //Public Method to Stop the Capture Process this.stopCapture = function() { if (this.isCapturing()) { AVDevice.deviceApplet.ep_stopCapture(); //State update will be driven by queryCaptureState return true; } return false; }; //Public Method to query for Capture Progress this.getCaptureProgress = function() { if (this.isCapturing() || this.isCompleted()) { return that.getParameter("captureProgress"); } return 0; }; //Public Method to query for errors this.getErrors = function() { if(that.isErrored()){ var errors = that.getParameter("errors"); if(errors !== null) return errors; } return ""; }; //Public Method to determine whether the Capture Process is in Progress this.isCapturing = function() { return this.getProperty("device","captureStateModel","captureState"); }; //Public Method to determine whether the Capture Process is Completed this.isCompleted = function() { return this.getProperty("device","captureStateModel","completedState"); }; //Public Method to determine whether an Error occurred during the Capture Process this.isError = function() { return this.getProperty("device","captureStateModel","erroredState"); }; //Public Method to determine which Device Object is Active (Previewing or Capturing) this.isActive = function() { if (AVDevice.activeDeviceObjectID == this.objectID) return true; return false; }; // Private method to initialize instance var init = function(audio, video){ // To populate the devices Array if ((AVDevice.audioDevicesArray === null) && (AVDevice.videoDevicesArray === null)) { AVDevice.getAudioDeviceList(); AVDevice.getVideoDeviceList(); } // To set the default device (per default selection algorithm) as Active Device if ((AVDevice.activeVideo == -1) && (AVDevice.videoDevicesArray[0] !== null)) { AVDevice.activeVideo = getDefaultDeviceIndex(AVDevice.videoDevicesArray); } if ((AVDevice.activeAudio == -1) && (AVDevice.audioDevicesArray[0] !== null)) { AVDevice.activeAudio = getDefaultDeviceIndex(AVDevice.videoDevicesArray); } // To set the Audio Index and Name Parameter if (audio) { that.setParameter("audioName",audio); that.setParameter("audioIndex",resolveNameToIndex(audio,AVDevice.audioDevicesArray)); } else { that.setParameter("audioName","defaultDevice"); that.setParameter("audioIndex","-1"); } // To set the Video Index and Name Parameter // Assume defaults, then correct with supplied if possible if (video) { that.setParameter("videoName",video); that.setParameter("videoIndex",resolveNameToIndex(video,AVDevice.videoDevicesArray)); } else { that.setParameter("videoName","defaultDevice"); that.setParameter("videoIndex","-1"); } }; //Private Method to Query the State while the Capturing Process is in Progress. var queryCaptureState = function() { captureTimeout = null; var currentState = "ready"; var progress = that.getParameter("captureProgress"); if(that.isActive()){ currentState = AVDevice.deviceApplet.ep_getCapturingState(); //Current State from the Device Applet progress = AVDevice.deviceApplet.ep_getCaptureProgress(); } var captureProgress = progress >= 0 ? progress : 0; // Current State from Device Applet are: Ready, Started, Errored if (currentState == "started"){ setAppletState("busy"); that.setParameter("captureProgress",captureProgress); captureTimeout = window.setTimeout(queryCaptureState,500); return; } if (currentState == "errored"){ that.setProperty("device","captureStateModel","erroredState",true); that.setParameter("captureProgress",captureProgress); that.setParameter("errors",AVDevice.deviceApplet.ep_getErrors()); if(!that.isPreviewing()) setAppletState("ready"); } if (currentState == "ready"){ that.setProperty("device","captureStateModel","captureState",false); that.setProperty("device","captureStateModel","completedState",true); that.setParameter("captureProgress",captureProgress); if(!that.isPreviewing()) setAppletState("ready"); } }; //Private Function to set the Applet State var setAppletState = function(_state){ var oldState = AVDevice.deviceAppletState; if (_state != AVDevice.deviceAppletState){ AVDevice.deviceAppletState = _state; that.setParameter("state",_state); } }; //Private Function to get the default device index var getDefaultDeviceIndex = function(deviceArray) { if(deviceArray === null || typeof deviceArray.length == "undefined" || deviceArray.length === 0) return -1; // no devices available //Prefer first Logitech device //or first Labtec device //or first device for (var deviceIndex = 0; deviceIndex < deviceArray.length; deviceIndex++) { var aDevice = deviceArray[deviceIndex].toLowerCase(); if (aDevice.indexOf("logitech") != -1) return deviceIndex; if (aDevice.indexOf("labtec") != -1) return deviceIndex; } return 0; // use first in list }; var resolveNameToIndex = function(_name,_deviceArray){ if(_deviceArray === null || typeof _deviceArray.length == "undefined" || _deviceArray.length === 0) return -1; // no devices available for (var index = 0; index < _deviceArray.length; index++) { if (_deviceArray[index] == _name) { return index; } } return -1; }; var resolveIndexToName = function(_index,_deviceArray){ if(_deviceArray === null || typeof _deviceArray.length == "undefined" || _deviceArray.length === 0 || _index < 0 || _index > (_deviceArray.length - 1)) return ""; // no device at that index available return _deviceArray[_index]; }; // declare me the active device... var declareActive = function(){ //take this opportunity to adjust name<->index relationships. //if name is set then it is king. index is adjusted to match. //if name is not set then index is used to update name and then name becomes king again // if the index does not match to a name, both are set to temporarily defaults var videoDevice = that.getParameter("videoIndex"); var audioDevice = that.getParameter("audioIndex"); var audioName = that.getParameter("audioName"); var videoName = that.getParameter("videoName"); if(videoName !== ""){ videoDevice = resolveNameToIndex(videoName,AVDevice.videoDevicesArray); that.setParameter("videoIndex",videoDevice); }else{ //no name present try index if(videoDevice != -1){ videoName = resolveIndexToName(videoDevice,AVDevice.videoDevicesArray); if(videoName !== ""){ //name found that.setParameter("videoName",videoName); }else{ //no name found, temporarily default both videoDevice = -1; } } } if(audioName !== ""){ audioDevice = resolveNameToIndex(audioName,AVDevice.audioDevicesArray); that.setParameter("audioIndex",audioDevice); }else{ //no name present try index if(audioDevice != -1){ audioName = resolveIndexToName(audioDevice,AVDevice.audioDevicesArray); if(audioName !== ""){ //name found that.setParameter("audioName",audioName); }else{ //no name found, temporarily default both audioDevice = -1; } } } // go active with devices as specified, or use defaults if(videoDevice == -1) videoDevice = getDefaultDeviceIndex(AVDevice.videoDevicesArray); if(videoDevice == -1) return false; // no video devices available if(audioDevice == -1) audioDevice = getDefaultDeviceIndex(AVDevice.audioDevicesArray); if(audioDevice == -1) return false; // no audio devices available AVDevice.activeVideo = videoDevice; AVDevice.activeAudio = audioDevice; AVDevice.activeDeviceObjectID = that.objectID; return true; }; // execute the init after all functions are defined init(audio, video); } // End of AVDevice class //Static Public Variables ( *** Not Part of the User API ***[Should not be accessed by the User] ) AVDevice.appspec = null; // Holds appspec information for AVDevice AVDevice.deviceApplet = null; // Device Applet ( *** SHOULD be CREATED even before creating Device Objects or Querying for Devices) AVDevice.deviceAppletState = null; // The STATUS of Device Applet (Updated and Maintained by the Device Class) //*** DEVICE APPLET STATES ( AVDevice.deviceAppletState ) ARE: INITIALIZING, READY, PREVIEWING, CAPTURING, COMPLETED, ERRORED *** AVDevice.activeVideo = -1; // To track the Active Video Device AVDevice.activeAudio = -1; // To track the Active Audio Device AVDevice.activeDeviceObjectID = null; // To track the Device Object that's Active AVDevice.audioDevicesArray = null; // List of Audio Devices AVDevice.videoDevicesArray = null; // List of Video Devices AVDevice.AVDeviceObjectArray = new Array(); // List (ID) of Device Object Created AVDevice.callbackAfterInstallation = null; // User CallBack Function After Installation //Static Public functions //Static Public method to Install and Start the Device Applet using AppSpec and AppletManager AVDevice.setDefaultAppspec = function() { if(AVDevice.appspec === null){ AVDevice.appspec = new AppletSpec("capture"); AVDevice.appspec.setParameter("name","captureApplet"); AVDevice.appspec.setParameter("visible","true"); AVDevice.appspec.addParameter("disableInstall","false"); AVDevice.appspec.setParameter("width","320"); AVDevice.appspec.setParameter("height","240"); } return AVDevice.appspec; } AVDevice.Install = function(callbackmethod) { if ((AVDevice.deviceApplet === null) && (AVDevice.deviceAppletState === null)) { AVDevice.callbackAfterInstallation = callbackmethod; AVDevice.deviceAppletState = "initializing"; if(AVDevice.appspec === null){ AVDevice.setDefaultAppspec(); } AppletManager.theInstance().startApplet(AVDevice.appspec, AVDevice.installCallbackmethod, 'captureAppletElement'); } } //Callback for the Device Applet (once its loaded and started) AVDevice.installCallbackmethod = function(applet) { AVDevice.deviceApplet = applet; AVDevice.deviceAppletState = "ready"; cameraCaptureDocument = applet; //TODO EAO live or die? - leave it to keep Actor happy for now if (AVDevice.callbackAfterInstallation !== null) { AVDevice.callbackAfterInstallation(applet); AVDevice.callbackAfterInstallation = null; } // Only when the callback method is provided by the User } //Static Public method to check for Installation // Installation will be invoked if necessary AVDevice.isInstalled = function(callbackmethod) { if (AVDevice.deviceAppletState === null || AVDevice.deviceAppletState == "initializing"){ if(callbackmethod !== null){ AVDevice.Install(callbackmethod); } return false; } return true; } //Static State queries AVDevice.isInitializing = function() { return (AVDevice.deviceAppletState == "initializing"); } AVDevice.isReady = function() { return (AVDevice.deviceAppletState == "ready"); } AVDevice.isPreviewing = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isPreviewing(); } AVDevice.isCapturing = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isCapturing(); } AVDevice.isCompleted = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isCompleted(); } AVDevice.isErrored = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isErrored(); } AVDevice.getErrors = function() { if(AVDevice.isErrored()){ return AVDevice.theActiveInstance().getErrors(); } return ""; } //Static Public method to query for the list of Video Devices in Users System AVDevice.getVideoDeviceList = function() { if(AVDevice.isInstalled()){ var videoDevicesList = String(AVDevice.deviceApplet.ep_getVideoDevices()); AVDevice.videoDevicesArray = videoDevicesList.split(";"); return AVDevice.videoDevicesArray; } return new Array(); } //Static Public method to query for the list of Audio Devices in Users System AVDevice.getAudioDeviceList = function() { if(AVDevice.isInstalled()){ var audioDevicesList = String(AVDevice.deviceApplet.ep_getAudioDevices()); AVDevice.audioDevicesArray = audioDevicesList.split(";"); return AVDevice.audioDevicesArray; } return new Array(); } //Static Public method to query for the Active Audio Device AVDevice.getActiveAudio = function() { if(AVDevice.isInstalled() && AVDevice.activeAudio != -1){ return AVDevice.audioDevicesArray[AVDevice.activeAudio]; }else{ return ""; } } //Static Public method to query for the Active Video Device AVDevice.getActiveVideo = function() { if(AVDevice.isInstalled() && AVDevice.activeVideo != -1){ return AVDevice.videoDevicesArray[AVDevice.activeVideo]; }else{ return ""; } } //Static Public method to retrieve the currently active avDevice instance AVDevice.theActiveInstance = function(){ if(AVDevice.activeDeviceObjectID === null) return null; return AVDevice.AVDeviceObjectArray[AVDevice.activeDeviceObjectID]; } CameraCapture.useAVDevice = true; function CameraCapture(captureApplet) { if(CameraCapture.instance != null) return CameraCapture.instance; // Singleton only if(CameraCapture.useAVDevice) { //alert('meCameraCapture.CameraCapture captureApplet: ' + captureApplet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); // if ((!captureApplet || (captureApplet == null)) && cameraCaptureDocument) // { // captureApplet = cameraCaptureDocument; // } this.captureApplet = captureApplet; //we don't use this, but its in the interface this.setCaptureApplet = function(applet) { // alert('meCameraCapture.setCaptureApplet' + '\n applet: ' + applet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); this.captureApplet = applet; } var avDevice = new AVDevice(); //uses default video and audio devices var pendingAVDevice = null; // used to hold new device while current device is capturing or previewing. // avDevice can be changed if not capturing and not previewing var updateAVDevice = function(){ if(pendingAVDevice !== null){ avDevice = pendingAVDevice; pendingAVDevice = null; } } this.startCapture = function() // USER API { avDevice.startCapture(); } this.stopCapture = function() // USER API { avDevice.stopCapture(); updateAVDevice(); } this.startPreview = function() // USER API { avDevice.startPreview(); } this.stopPreview = function() // USER API { avDevice.stopPreview(); updateAVDevice(); } this.getCapturePath = function() // USER API { var path = null; try {path = avDevice.getParameter("outputfile");} catch (e) { alert('CameraCapture.getCapturePath EXCEPTION: ' + e.message); path = null; } if ((path != null) && isString(path) && (path.length > 0)) { path = path.replace(/\\/g,"/"); } else { path = null; } return path; } this.setCapturePath = function(aPath) // USER API { avDevice.setParameter("outputfile", aPath); } this.getCaptureApplet = function() { return this.captureApplet; } this.getAVDevice = function() { return avDevice; } this.setAVDevice = function(anAVDevice) { if(anAVDevice === null) return; if(! anAVDevice instanceof AVDevice) return; if(avDevice.isCapturing() || avDevice.isPreviewing()){ pendingDevice = anAVDevice; } else{ avDevice = anAVDevice; } } } else //old style direct access { //alert('meCameraCapture.CameraCapture captureApplet: ' + captureApplet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); if ((!captureApplet || (captureApplet == null)) && cameraCaptureDocument) { captureApplet = cameraCaptureDocument; } this.captureApplet = captureApplet; this.setCaptureApplet = function(applet) { // alert('meCameraCapture.setCaptureApplet' + '\n applet: ' + applet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); this.captureApplet = applet; } this.startCapture = function() // USER API { //camCapApp.getInstance().startCapture(); this.getCaptureApplet().ep_startCapture(120); // TODO GLM need to restore previously working method } this.stopCapture = function() // USER API { this.getCaptureApplet().ep_stopCapture(); } this.startPreview = function() // USER API { this.getCaptureApplet().ep_setPreview(true); } this.stopPreview = function() // USER API { this.getCaptureApplet().ep_setPreview(false); } this.getCapturePath = function() // USER API { var path = null; try {path = this.getCaptureApplet().ep_getCapturePath();} catch (e) { alert('CameraCapture.getCapturePath EXCEPTION: ' + e.message); path = null; } if ((path != null) && isString(path) && (path.length > 0)) { path = path.replace(/\\/g,"/"); } else { path = null; } return path; } this.setCapturePath = function(aPath) // USER API { this.getCaptureApplet().ep_setCapturePath(aPath); } this.getCaptureApplet = function() { //alert('meCameraCapture.getCaptureApplet applet: ' + camCapApp.getInstance()); return this.captureApplet; //return camCapApp.getInstance(); } } //alert('meCameraCapture. this: ' + this); CameraCapture.instance = this; } CameraCapture.instance = null; CameraCapture.startCapture = function() { if (CameraCapture.instance != null) { CameraCapture.instance.startCapture(); } else { directorTrace('CameraCapture.startCapture NO INSTANCE'); alert('CameraCapture.startCapture NO INSTANCE'); } } CameraCapture.stopCapture = function() { if (CameraCapture.instance != null) { CameraCapture.instance.stopCapture(); } else { directorTrace('CameraCapture.stopCapture NO INSTANCE'); alert('CameraCapture.stopCapture NO INSTANCE'); } } CameraCapture.startPreview = function() { if (CameraCapture.instance != null) { CameraCapture.instance.startPreview(); } else { directorTrace('CameraCapture.startPreview NO INSTANCE'); alert('CameraCapture.startPreview NO INSTANCE'); } } CameraCapture.stopPreview = function() { if (CameraCapture.instance != null) { CameraCapture.instance.stopPreview(); } else { directorTrace('CameraCapture.stopPreview NO INSTANCE'); alert('CameraCapture.stopPreview NO INSTANCE'); } } CameraCapture.getCapturePath = function() // USER API { if (CameraCapture.instance != null) { return CameraCapture.instance.getCapturePath(); } else { directorTrace('CameraCapture.getCapturePath NO INSTANCE'); alert('CameraCapture.getCapturePath NO INSTANCE'); } } CameraCapture.setCapturePath = function(aPath) // USER API { if (CameraCapture.instance != null) { CameraCapture.instance.setCapturePath(aPath); } else { directorTrace('CameraCapture.stopPreview NO INSTANCE'); alert('CameraCapture.stopPreview NO INSTANCE'); } } CameraCapture.setCaptureApplet = function(applet) { if (CameraCapture.instance != null) { CameraCapture.instance.setCaptureApplet(applet); } else { directorTrace('CameraCapture.setCaptureApplet NO INSTANCE'); alert('CameraCapture.setCaptureApplet NO INSTANCE'); } } function Scene() { var that = this; // acquire parametermanager capabilites this.PMgr = ParameterManager; this.PMgr("general"); var ctx = arguments[0]; this.container = ctx; if( this.container){ if(ControlData == this.container.constructor) { var pLen = arguments.length; var sName,cFromName,ctx,cToName,fromFrame,toFrame; this.nameValidator = function (group, name, _value) { meLogger.write('Scene name Validator Called', 1); if(_value == null || _value == ""){ //return false; var ex = new MeException('Scene => '+ _value + '<= is not a valid scene name'); throw ex; } if(ctx.getScene(_value)) { //meLogger.write('Scene =>' + _value + '<= already exists',3); //return false; var ex = new MeException('Scene =>' + _value + '<= already exists'); throw ex; } else { //meLogger.write('adding scene...' + _value); } meLogger.write('valid scene name is used=>' + _value, 2); return true; } this.fromToClipValidator = function (_group,_name,_value) { if((_name == 'fromClip') || (_name == 'toClip')){ var currentClip = ctx.getClip(_value); if(!(currentClip)) { var ex = new MeException('Clip =>' + _value + '<= does not exist'); throw ex; } try{ var tempToClip = that.getParameter(_group,'toClip'); var tempFromClip = that.getParameter(_group,'fromClip'); if(_name == 'fromClip'){ if ((tempToClip) && (_value != tempToClip)){ if ((currentClip.equals(ctx.getClip(tempToClip))) > 0) { throw new MeException('Clip =>' + _value + ' is after clip =>'+ tempToClip); } } } else if (_name == 'toClip'){ if ((tempFromClip) && (_value != tempFromClip)){ if ((currentClip.equals(ctx.getClip(tempFromClip))) < 0) { throw new MeException('Clip =>' + _value + ' is before clip =>'+ tempFromClip); } } } } catch(e) { //meLogger.write(e.name + ':= ' + e.message, 3); alert("Scene.fromToClipValidator EXCEPTION: " + e.message); throw(e); //return false; } meLogger.write('valid clip name is used=>' + _value, 2); return true; } return false; } //addScene(ctx,name, clipName) //addScene(ctx,name, startingClipName, endingClipName) //addScene(ctx,name, startingClipName, startingFrame, endingClipName,endingFrame) if (pLen == 6) { sName = arguments[1]; cFromName = arguments[2]; fromFrame =arguments[3]; cToName = arguments[4]; toFrame = arguments[5]; try{ this.setProperty('general', 'name', 'validator', this.nameValidator); this.setProperty('general', 'fromClip', 'validator', this.fromToClipValidator); this.setProperty('general', 'toClip', 'validator', this.fromToClipValidator); this.setParameter('general','name', sName); this.setParameter('general','fromClip',cFromName); this.setParameter('general','toClip',cToName); this.setParameter('general','fromFrame', fromFrame); this.setParameter('general','toFrame', toFrame); } catch(e) { meLogger.write(e.name + ':= ' + e.message, 3); throw(e); } } else { throw new MeException('Error initializing Scene object.'); } this.remove = function() { (this.container).removeScene(this); } this.rename = function(_name) { this.setParameter('general','name',_name); } } else { throw new MeException('Scene can not be initialized out side of ControlData context. Error initializing.'); } } else { throw new MeException('Attempting to initialize sceneError initializing Scene object.'); } this.encodeScene = function () { ; //TODO } this.createDocumentFragment = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var fragment = xmlDocument.createDocumentFragment(); var node = xmlDocument.createElement('scene'); node.appendChild(this._createDocumentFragment(xmlDocument)); fragment.appendChild(node); return fragment; }; this.toXML = null; this.toXML = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var xmlString = xutil.serializeToString(this.createDocumentFragment(xmlDocument)); return xmlString; } ; } // Supporting classes /** * **/ function SceneCollection(){ this.Col = MeCollection; this.Col(); //Other collection functions go here } /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } /* * Perform a simple self-test to see if the VM is working */ function md5_vm_test() { return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; } /* * Calculate the MD5 of an array of little-endian words, and a bit length */ function core_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } /* * Calculate the HMAC-MD5, of a key and some data */ function core_hmac_md5(key, data) { var bkey = str2binl(key); if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); return core_md5(opad.concat(hash), 512 + 128); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /* * Convert a string to an array of little-endian words * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. */ function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); return bin; } /* * Convert an array of little-endian words to a string */ function binl2str(bin) { var str = ""; var mask = (1 << chrsz) - 1; for(var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); return str; } /* * Convert an array of little-endian words to a hex string. */ function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; } /* * Convert an array of little-endian words to a base-64 string */ function binl2b64(binarray) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; for(var i = 0; i < binarray.length * 4; i += 3) { var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); for(var j = 0; j < 4; j++) { if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } return str; } /** * @fileoverview This class manages Applet lifecycle and display behaviours * * * * * */ function AppletManager() { var that = this; var queue = new Array(); var state = "blocked" ; var processqueuetimeout = null; var appletlist = new Array(); this.eventapplets = new Array(); /** * * This property determines the install location on the users system. * */ this.appfolder = '${user.home}/eviewEngine'; if("undefined" == typeof AppletManager.instance) { AppletManager.instance = this; // define the singleton } if(this != AppletManager.instance) return AppletManager.instance; // return the singleton if it already exists /** * * @private * @see ParameterManager */ this.PMgr = ParameterManager; // From ParameterManager.js (JavaScript file) this.PMgr("applets"); /** * Sets internal state for applet creation. * @private * */ this.setState = function (_state) { state = _state; } /** * * Set the file path for Applets with installable files. * @param {String} path The file path where to install dependent files. * */ this.setAppFolder = function (path) { this.appfolder = path; } /** * * * */ this.startApplet = function() { var appletSpecInstance; var callbackMethod; var target = null; if (arguments.length == 2) { appletSpecInstance = arguments[0]; callbackMethod = arguments[1]; } else if (arguments.length == 3) { appletSpecInstance = arguments[0]; callbackMethod = arguments[1]; target = arguments[2]; } else { return false; } appletSpecInstance.addParameter("APP_FOLDER",this.appfolder); var name = appletSpecInstance.getParameter("applet","name"); appletlist[appletlist.length] = name; this.defineParameter("applets", name, "value", ""); this.setProperty("applets",name,"callback",callbackMethod); this.setProperty("applets",name,"appletspec",appletSpecInstance); if (target != null) { this.setProperty("applets",name,"targetTag",target); } queue.push(name); if (processqueuetimeout == null) { setTimeout(function() { processQueue(); },100); // TODO: Research this problem that requires this timeout. Falied on R-Systems machines. } return true; } this.destroyApplet = function(_name) { try { if (typeof this.getProperty("applets",_name,"targetTag") != "undefined") { var parent = document.getElementById(this.getProperty("applets",_name,"targetTag")); var child = document.getElementById(this.getProperty("applets",_name,"positionElement")); parent.removeChild(child); } var container = document.getElementById(this.getProperty("applets",_name,"containerElement")); document.body.removeChild(container); if(typeof that.getProperty("applets",_name,"validator") != "undefined") { clearInterval(that.getProperty("applets",_name,"validator")); } this.removeParameter("applets",_name); } catch (err) { alert("AppletManager.destroyApplet EXCEPTION: " + err.message); return false; } return true; } this.setDisplay = function(applet_name, display) { this.setProperty("applets",applet_name,"display",display); } this.getDisplay = function(applet_name) { return this.getProperty("applets",applet_name,"display"); } this.setVisibility = function(applet_name, visible) { this.setProperty("applets",applet_name,"visible",visible); } this.getVisibility = function(applet_name) { return this.getProperty("applets",applet_name,"visible"); } this.resize = function(applet_name, width, height) { this.setProperty("applets",applet_name,"height",height); this.setProperty("applets",applet_name,"width",width); //this.getApplet(applet_name).height = height; //this.getApplet(applet_name).width = width; this.getApplet(applet_name).ep_setSize(width,height); } this.setHeight = function(applet_name, height) { this.setProperty("applets",applet_name,"height",height); this.getApplet(applet_name).height = height; } this.setWidth = function(applet_name, width) { this.setProperty("applets",applet_name,"width",width); this.getApplet(applet_name).width = width; } //Function to retrieve the height this.getHeight = function(applet_name) { return this.getProperty("applets",applet_name,"height"); } //Function to retrieve the Width this.getWidth = function(applet_name) { return this.getProperty("applets",applet_name,"width"); } function processQueue() { processqueuetimeout = null; if (state == 'blocked') { processqueuetimeout = setTimeout(function() { processQueue() },50); return; } else if (state == 'busy') { processqueuetimeout = setTimeout(function() { processQueue() },50); return; } else if (queue.length == 0) { state = 'idle'; return; } state = 'busy'; var name = queue.shift(); var appspec1 = that.getProperty("applets",name,"appletspec"); that.setProperty("applets",name,"positionElement",that.getUniqueElementID()); that.setProperty("applets",name,"containerElement",that.getUniqueElementID()); var show = that.getProperty("applets",name,"appletspec").getParameter("applet","visible"); if (show == "true") { that.setProperty("applets",name,"visible",true); } else { that.setProperty("applets",name,"visible",false); } that.setProperty("applets",name,"height",appspec1.getParameter("height")); that.setProperty("applets",name,"width",appspec1.getParameter("width")); var containerElement = document.createElement("metag"); containerElement.id = that.getProperty("applets",name,"containerElement"); document.body.appendChild(containerElement); containerElement.style.position = "absolute"; containerElement.style.top = -(that.getHeight(name) - 1); containerElement.style.left = -(that.getWidth(name) -1); if (typeof that.getProperty("applets",name,"targetTag") != "undefined") { if (document.getElementById(that.getProperty("applets",name,"targetTag")) == null) {alert('AppletManager.processQueue cannot find element name: ' + name);return;} var positionElement = document.createElement("div"); positionElement.id = that.getProperty("applets",name,"positionElement"); document.getElementById(that.getProperty("applets",name,"targetTag")).appendChild(positionElement); if (that.getDisplay(name)) { positionElement.style.height = that.getHeight(name) + "px"; positionElement.style.width = that.getWidth(name) + "px"; } else { positionElement.style.height = "0px"; positionElement.style.width = "0px"; } } that.getProperty("applets",name,"appletspec").startApplet(that.getProperty("applets",name,"containerElement")); } this.handleLifeCycle = function(appletID, name, elementType) { if (typeof this.getParameter(name) != "undefined") { this.setProperty("applets",name,"appletID",appletID); this.setProperty("applets",name,"elementType",elementType); setTimeout("AppletManager.theInstance().doCallback('" + name + "');",100); this.getApplet(name).height = this.getHeight(name); this.getApplet(name).width = this.getWidth(name); var containerElement = document.getElementById(that.getProperty("applets",name,"containerElement")); var appspec1 = that.getProperty("applets",name,"appletspec"); containerElement.style.top = -(appspec1.getParameter("height") + 10); containerElement.style.left = -(appspec1.getParameter("width") + 10); if (typeof that.getProperty("applets",name,"targetTag") != "undefined") { MeAddEvent(window, 'resize', function() { AppletManager.theInstance().validateLater(name);}); var positionElement = document.getElementById(that.getProperty("applets",name,"positionElement")); setEvents(positionElement,name); this.eventapplets[this.eventapplets.length] = name; this.setProperty("applets",name,"validatestatus",false); /* if (containerElement.style.setExpression) { var positionElement = document.getElementById(that.getProperty("applets",name,"positionElement")); positionElement.onmove = "AppletManager.theInstance().validate('" + name + "');"; positionElement.onpropertychange = "AppletManager.theInstance().validate('" + name + "');"; positionElement.onlayoutcomplete = "AppletManager.theInstance().validate('" + name + "');"; } else { var tm = setInterval("AppletManager.theInstance().validate('" + name + "')",1000); that.setProperty("applets",name,"validator",tm); } */ } state = "idle"; if (processqueuetimeout == null) { setTimeout(function() { processQueue()},100);} } else { //Error Condition } } this.doCallback = function(name) { if (this.getProperty("applets",name,"callback") !== null) { this.getProperty("applets",name,"callback")(this.getApplet(name)); } } this.getApplet = function (name) { var id = this.getProperty("applets",name,"appletID"); if (id != '') { if((instance = eval("document." + id))) { } else if (document.all) { instance = document.all(id); } else if (document.getElementById) { instance = document.getElementById(id); } return instance; } else { return false; } } this.getUniqueElementID = function () { var tmp = ""; do { tm = new Date(); //hex_md5() - From md5.js (JavaScript File) tmp = "div" + hex_md5(String((Math.random()) * tm.getTime())); } while(document.getElementById(tmp)); return tmp; } this.getAbsoluteLeft = function(objectId) { // Get an object left position from the upper left viewport corner // Tested with relative and nested objects o = document.getElementById(objectId) oLeft = o.offsetLeft // Get left position from the parent object if (o.offsetParent !== null) { while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element oParent = o.offsetParent // Get parent object reference if (o.clientLeft) { oLeft += oParent.offsetLeft + o.clientLeft; } else { oLeft += oParent.offsetLeft // Add parent left position } o = oParent } // Return left postion return oLeft; } else { return "error"; } } this.getAbsoluteTop = function(objectId) { // Get an object top position from the upper left viewport corner // Tested with relative and nested objects o = document.getElementById(objectId) oTop = o.offsetTop // Get top position from the parent object if (o.offsetParent !== null) { while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element oParent = o.offsetParent // Get parent object reference if (o.clientTop) { oTop += oParent.offsetTop + o.clientTop // Add parent top position } else { oTop += oParent.offsetTop // Add parent top position } o = oParent } // Return top position return oTop; } else { } return "error"; } this.validate = function() { var applet_name; if (arguments.length == 1) { applet_name = arguments[0]; if (typeof this.getParameter(applet_name) != "undefined") { var positionElementID = this.getProperty("applets",applet_name,"positionElement"); var containerElementID = this.getProperty("applets",applet_name,"containerElement"); var positionElement = document.getElementById(positionElementID); var containerElement = document.getElementById(containerElementID); var state = 'visible'; if (this.getDisplay(applet_name) == false) { state = 'hidden'; } else if (this.getVisibility(applet_name) == false) { state = 'none'; } else if (getElementDisplay(positionElement) == false) { state = 'none'; } else if (getStyle(positionElement,"visibility") != "visible") { state = 'hidden'; } //debugout("AppletManager.validate('" + applet_name + "')","","state: " + state); if (state == 'visible') { var positionElement = document.getElementById(positionElementID); var containerElement = document.getElementById(containerElementID); positionElement.style.height = this.getHeight(applet_name) + "px"; positionElement.style.width = this.getWidth(applet_name) + "px"; var atop = this.getAbsoluteTop(positionElementID); var aleft = this.getAbsoluteLeft(positionElementID); if (!isNaN(atop)) { containerElement.style.top = atop; } if (!isNaN(aleft)) { containerElement.style.left = aleft; } positionElement.style.height = this.getHeight(applet_name) + "px"; positionElement.style.width = this.getWidth(applet_name) + "px"; } else if (state == 'hidden') { containerElement.style.top = -(this.getHeight(applet_name) + 10); containerElement.style.left = -(this.getWidth(applet_name) + 10); positionElement.style.height = this.getHeight(applet_name) + "px"; positionElement.style.width = this.getWidth(applet_name) + "px"; } else if (state == 'none') { containerElement.style.top = -(this.getHeight(applet_name) + 10); containerElement.style.left = -(this.getWidth(applet_name) + 10); positionElement.style.height = "0px"; positionElement.style.width = "0px"; } setTimeout("AppletManager.theInstance().setValidateStatus('" + applet_name + "',false)",1); } } else { //alert(this.eventapplets.join('|')); /* try { for(var i = 0;i < this.eventapplets.length - 1;i++) { setTimeout("AppletManager.theInstance().validateLater('" + this.eventapplets[i] + "')",500); } return true; } catch(e) { return false; } */ } } function getStyle(el,styleProp) { var x = el; if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); //window.status = styleProp + ' = ' + y; if (y == "inherit") { y = getStyle(x.parentNode,styleProp); } return y; } function getElementDisplay(el) { var display = true; while(el.parentNode) { if (el.currentStyle) { if (el.currentStyle['display'] == 'none') { display = false; } } else if (window.getComputedStyle) { if (document.defaultView.getComputedStyle(el,null).getPropertyValue('display')){ display = false; } } if (!display) { break; } el = el.parentNode; } return display; } function setEvents(el,name) { while(el.parentNode) { // Parse the parent hierarchy up to the document element MeAddEvent(el, 'propertychange', function() { AppletManager.theInstance().validateLater(name); } ); if (el.onresizeend) { MeAddEvent(el, 'resizeend', function() { AppletManager.theInstance().validateLater(name); } ); } else { MeAddEvent(el, 'resize', function() { AppletManager.theInstance().validateLater(name); } ); } var sib = el.nextSibling; while(sib) { MeAddEvent(sib, 'propertychange', function() { AppletManager.theInstance().validateLater(name); } ); if (el.onresizeend) { MeAddEvent(el, 'resizeend', function() { AppletManager.theInstance().validateLater(name); } ); } else { MeAddEvent(el, 'resize', function() { AppletManager.theInstance().validateLater(name); } ); } sib = sib.nextSibling; } elParent = el.parentNode // Get parent object reference el = elParent } return true; } this.validateLater = function(name) { if (this.getDisplay(name) == true || this.getVisibility(name) == true) { if (this.getValidateStatus(name) === false) { this.setValidateStatus(name,true); setTimeout("AppletManager.theInstance().validate('" + name + "');",1); } } } this.getValidateStatus = function(name) { return this.getProperty("applets",name,"validatestatus"); } this.setValidateStatus = function(name,status) { this.setProperty("applets",name,"validatestatus",status); } } // End of AppletManager AppletManager.theInstance = function(){ if("undefined" == typeof AppletManager.instance){ return new AppletManager(); } return AppletManager.instance; } MeAddEvent(window, 'load', function() { AppletManager.theInstance().setState('idle');}); function ChannelManager(host) { var url = host; var docbase = document.location.href; if (docbase.lastIndexOf('/') !=-1) { docbase = docbase.substr(0,docbase.lastIndexOf('/') + 1); } var HTTPRequestObj = new HttpRequest(); this.registerChannels = function(name){ var response = HTTPRequestObj.sendRequest("GET", url, Array("name=" + name, "mode=sendAndRegister","docbase=" + docbase), false); if (response != "" && response != null) { return JSON.parse(response); } else { return null; } } this.lookupChannels = function(name){ var response = HTTPRequestObj.sendRequest("GET", url, Array("name=" + name, "mode=sendAndLookUp","docbase=" + docbase), false); if (response != "" && response != null) { return JSON.parse(response); } else { return null; } } this.deregisterChannels = function(name){ var response = HTTPRequestObj.sendRequest("GET", url, Array("name=" + name, "mode=sendAndDelete","docbase=" + docbase), false); if (response != "" && response != null) { return JSON.parse(response); } else { return null; } } } // SceneMerge.js function SceneMerge(sceneMergeActor) { var myActor = (sceneMergeActor) ? sceneMergeActor : null; var myName = myActor.getName(); var myElementId = myName + 'element'; var myAppletName = myName + 'applet'; var mergePhase = 0; var mergeAbort = false; var mergeSceneInProgress = false; var clipSdl = ''; var sceneSdl = ''; var originalClipStartSegment = 1; var originalClipStartRawRecNum = -1; var sceneStartSegment = 1; var sceneStartRawRecNum = 0; var sceneEndSegment = -1; var sceneEndRawRecNum = -1; var mergeClipLastSegment = 0; var mergeClipLastRawRecNum = 0; var mergeClipLastRecNum = 0; var videoMergeComplete = false; var audioMergeComplete = false; var callback = null; var sceneCodeBaseOverride = null; var clipCodeBaseOverride = null; var sceneMergeTmpDir = null; var sceneMergeDirector = null; var sceneMergeEventDescriptor = null; this.setSceneMergeDirector = function(director) // USER API { sceneMergeDirector = director; } this.setSceneMergeTmpDir = function(tmpDir) { sceneMergeTmpDir = tmpDir; } this.setSceneMergeClipSdl = function(sdl) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } clipSdl = sdl; if (clipSdl && isString(clipSdl) && (clipSdl.length > 0)) { var endOfCodeBaseOverride = clipSdl.lastIndexOf('/'); if (endOfCodeBaseOverride != -1) { clipCodeBaseOverride = clipSdl.substring(0,endOfCodeBaseOverride+1); } else { alert('SceneMerge.setSceneMergeClipSdl clipSdl INVALID:' + clipSdl); } } else { alert('SceneMerge.setSceneMergeClipSdl clipSdl INVALID:' + clipSdl); } } this.setSceneMergeSceneSdl = function(sdl) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } sceneSdl = sdl; if (sceneSdl && isString(sceneSdl) && (sceneSdl.length > 0)) { var endOfCodeBaseOverride = sceneSdl.lastIndexOf('/'); if (endOfCodeBaseOverride != -1) { sceneCodeBaseOverride = sceneSdl.substring(0,endOfCodeBaseOverride+1); } else { alert('SceneMerge.setSceneMergeSceneSdl sceneSdl INVALID:' + sceneSdl); } } else { alert('SceneMerge.setSceneMergeSceneSdl sceneSdl INVALID:' + sceneSdl); } //directorTrace('SceneMerge.setSceneMergeSceneSdl' + '\n sceneSdl: ' + sceneSdl + '\n sceneCodeBaseOverride: ' + sceneCodeBaseOverride); } this.setSceneMergeStartSegment = function(seg) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } originalClipStartSegment = parseInt(seg); } this.setSceneMergeStartRecNum = function(recNum) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } originalClipStartRawRecNum = parseInt(recNum); } this.setSceneMergeCallback = function(cb) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } callback = cb; } this.startSceneMerge = function() // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } //directorTrace('SceneMerge.startSceneMerge\n' + this.sceneMergeToString()); if ((mergePhase != 0) || isContextPlaying(getMyContextIndex())) { mergeAbort = true; mergePhase = 0; stopContext(getMyContextIndex()); this.disableMerge(); return; } // this is the first phase. if (sceneStartSegment > 0) { mergeSceneInProgress = true; enableHourGlass(); this.enableMerge(); if (originalClipStartRawRecNum > 0) { // fill in first part from the original clip setCodeBaseOverride(getMyContextIndex(),clipCodeBaseOverride); setSceneMergeTmpDir(getMyContextIndex(),sceneMergeTmpDir); playClipFromTo(getMyContextIndex(),originalClipStartSegment,0,originalClipStartSegment,originalClipStartRawRecNum-1,false,clipSdl); mergePhase = 2; // next merge phase } else { if (originalClipStartRawRecNum == 0) { this.mergePhase2(); } else { directorTrace('SceneMerge.startSceneMerge INVALID START FRAME: ' + originalClipStartRawRecNum); } } } else { directorTrace('SceneMerge.startSceneMerge INVALID START SEGMENT: ' + sceneStartSegment); } } this.mergePhase0 = function() { directorTrace('SceneMerge.nextMergePhase MERGE ABORTED'); this.mergeFinalized(0,''); } this.mergePhase2 = function() { // play scene to be merged in //directorTrace('SceneMerge.mergePhase2' + ' startSegment: ' + sceneStartSegment + ' startRawRecNum: ' + sceneStartRawRecNum); setCodeBaseOverride(getMyContextIndex(),sceneCodeBaseOverride); setSceneMergeTmpDir(getMyContextIndex(),sceneMergeTmpDir); playClipFromTo(getMyContextIndex(),sceneStartSegment,sceneStartRawRecNum,sceneEndSegment,sceneEndRawRecNum,false,sceneSdl); mergePhase = 3; // next merge phase } this.mergePhase3 = function() { mergeClipLastSegment = this.getMergeClipLastSegment(); mergeClipLastRawRecNum = this.getMergeClipLastRawRecNum(); mergeClipLastRecNum = this.getMergeClipLastRecNum(); //directorTrace('SceneMerge.mergePhase3' + ' lastSegment: ' + mergeClipLastSegment + ' lastRawRecNum: ' + mergeClipLastRawRecNum + ' lastRecNum: ' + mergeClipLastRecNum); if ((mergeClipLastSegment > 0) && (mergeClipLastRawRecNum > 0)) { this.updatePostMergeConfig(); var nextSegment = originalClipStartSegment+mergeClipLastSegment-1; setCodeBaseOverride(getMyContextIndex(),clipCodeBaseOverride); setSceneMergeTmpDir(getMyContextIndex(),sceneMergeTmpDir); playClipFromTo(getMyContextIndex(),nextSegment,mergeClipLastRawRecNum+1,nextSegment,-1,false,clipSdl); // play the rest mergePhase = 4; // next merge phase } else { this.mergePhase4(); } } this.mergePhase4 = function() { //directorTrace('SceneMerge.mergePhase4'); this.finalizeMerge(clipSdl,sceneSdl,'video'); } this.nextMergePhase = function() { var phase = 'this.mergePhase' + mergePhase + '()'; try { eval(phase); //directorTrace('SceneMerge.nextMergePhase phase: ' + phase); } catch(err) { directorTrace('SceneMerge.nextMergePhase INVALID PHASE: ' + mergePhase); } } this.setMergeClipEnabled = function(state) { getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_setMergeClipEnabled,' + state); } this.setClipWriterEnabled = function(state) { getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_setClipWriterEnabled,' + state); } this.enableMerge = function() { this.setMergeClipEnabled(true); this.setClipWriterEnabled(true); } this.disableMerge = function() { this.setMergeClipEnabled(false); this.setClipWriterEnabled(false); } this.mergeClipComplete = function(ctxId,eventDescriptor) { //directorTrace('SceneMerge.mergeClipComplete eventDescriptor:' + eventDescriptor); if (eventDescriptor.indexOf("video") != -1) videoMergeComplete = true; if (eventDescriptor.indexOf("audio") != -1) audioMergeComplete = true; //if (videoMergeComplete && audioMergeComplete) if (videoMergeComplete) { //directorTrace('SceneMerge.mergeClipComplete ctxId: ' + ctxId + ' eventDescriptor: ' + eventDescriptor); sceneMergeEventDescriptor = eventDescriptor; var _this = this; setTimeout(this.nextMergePhase._bind(_this,''),2000); } } this.getMergeClipLastSegment = function() { return parseInt(getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_getMergeClipLastSegment')); } this.getMergeClipLastRawRecNum = function() { return parseInt(getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_getMergeClipLastRawRecNum')); } this.getMergeClipLastRecNum = function() { return parseInt(getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_getMergeClipLastRecNum')); } this.finalizeMerge = function(sdlOfOriginalClip,sdlOfMergeClip,fileType) { setCodeBaseOverride(getMyContextIndex(),clipCodeBaseOverride); getSceneMergeDirector().ep_invoke(getMyContextIndex() + ',,ep_finalizeClipWriterMerge,' + sdlOfOriginalClip + ',' + sdlOfMergeClip + ',' + fileType); } this.mergeFinalized = function(eventDescriptor) { mergePhase = 0; mergeSceneInProgress = false; videoMergeComplete = false; audioMergeComplete = false; this.disableMerge(); if (callback != null) { try { eval(callback + "(\'" + eventDescriptor + "\')"); } catch(err) { directorTrace('SceneMerge.mergeFinalized callback EXCEPTION: ' + err.description); } } if (myActor != null) { myActor.invoke('sceneMergeComplete','sceneMergeComplete;SceneMerge.mergeFinalized'); } var event = ContextEventDescriptor.getEvent(eventDescriptor); var ctxId = ContextEventDescriptor.getCtxId(eventDescriptor); var element = ContextEventDescriptor.getHtmlElement(eventDescriptor); var args = ContextEventDescriptor.getOptionalArgs(eventDescriptor); disableHourGlass(); //directorTrace('SceneMerge.mergeFinalized' + '\n eventDescriptor:' + eventDescriptor + '\n event : ' + event + '\n ctxId : ' + ctxId + '\n element: ' + element + '\n args : ' + args); } this.updatePostMergeConfig = function() { getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_updatePostMergeConfig'); } this.isMergeSceneInProgress = function() // USER API { return mergeSceneInProgress; } this.sceneMergeToString = function() { return (' SceneMerge' + '\n myName: ' + myName + ' myContextIndex: ' + getMyContextIndex() + '\n myElementId: ' + myElementId + ' myAppletName: ' + myAppletName + '\n clipSdl : ' + clipSdl + '\n sceneSdl: ' + sceneSdl + '\n clipCodeBaseOverride : ' + clipCodeBaseOverride + '\n sceneCodeBaseOverride: ' + sceneCodeBaseOverride + '\n mergePhase: ' + mergePhase + ' mergeAbort: ' + mergeAbort + ' mergeSceneInProgress: ' + mergeSceneInProgress + '\n originalClipStartSegment: ' + originalClipStartSegment + ' originalClipStartRawRecNum: ' + originalClipStartRawRecNum + '\n sceneStartSegment: ' + sceneStartSegment + ' sceneStartRawRecNum: ' + sceneStartRawRecNum + '\n sceneEndSegment: ' + sceneEndSegment + ' sceneEndRawRecNum: ' + sceneEndRawRecNum + '\n mergeClipLastSegment: ' + mergeClipLastSegment + ' mergeClipLastRawRecNum: ' + mergeClipLastRawRecNum + ' mergeClipLastRecNum: ' + mergeClipLastRecNum + '\n videoMergeComplete: ' + videoMergeComplete + ' audioMergeComplete: ' + audioMergeComplete + '\n callback: ' + callback); } function getMyContextIndex() { return myActor.getContextIndex(); } function getSceneMergeDirector() { return ((sceneMergeDirector != null) ? sceneMergeDirector : clipDirector); } function sceneMergeAlreadyInProgress() { alert('SceneMerge already in-progress'); } SceneMerge.instance = this; } function AppletSpec(appletType) { var that = this; this.PMgr = ParameterManager; // From ParameterManager.js (JavaScript file) this.PMgr("applet"); var componentFactory = new ComponentFactory(); var type = appletType; this.setParameter("type",type); if (appletType != "undefined" || appletType !== "") { //AppletFactory for getting Parameter Information for Ecoder and Upload Applets //An Array of Applet Information (Encoder, Capture, and Upload Applets) var appletInfo = componentFactory.getAppletInformation(appletType); } if (!appletInfo) { appletInfo = new Array(); appletInfo['code'] = ''; appletInfo['archive'] = ''; } appletInfo['codebase'] = componentFactory.codebase; if (appletInfo['package_spec']) { this.setParameter("user","PACKAGE_SPEC",appletInfo['package_spec']); } if("undefined" == typeof appletInfo['cache_version']){ appletInfo['cache_version'] = ''; } this.setParameter("objectclassid","clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"); this.setParameter("objectcodebase", "http://java.sun.com/update/1.5.0/jinstall-1_5_0_11-windows-i586.cab"); this.setParameter("name", ""); this.setParameter("code", appletInfo['code'] !== '' ? appletInfo['code'] : ''); this.setParameter("codebase", appletInfo['codebase'] !== '' ? appletInfo['codebase'] : ''); this.setParameter("cache_archive", appletInfo['cache_archive'] !== '' ? appletInfo['cache_archive'] : ''); this.setParameter("cache_version", appletInfo['cache_version'] !== '' ? appletInfo['cache_version'] : ''); this.setParameter("width", "1"); this.setParameter("height", "1"); this.setParameter("hspace", ""); this.setParameter("vspace", ""); this.setParameter("align", ""); //this.setParameter("embedtype", "application/x-java-applet:;version=1.4"); // ** TO BE RESOLVED: NOT WORKING IN FOREFOX ** this.setParameter("embedtype", "application/x-java-applet;version=1.5"); this.setParameter("embedpluginspage", "http://www.java.com"); this.setParameter("scriptable", "true"); this.setParameter("mayscript", "true"); this.setParameter("visible", "true"); this.startApplet = function (target) { var tmpStr=""; tmpStr = this.appletToString(); if(tmpStr !== ""){ this.write(tmpStr, target); } else{ //alert("StartApplet tags empty"); }; }; this.startAppletWithAppletTag = function (target) { var tmpStr=""; tmpStr = this.appletTagOnlyToString(); if(tmpStr !== ""){ this.write(document,target,tmpStr); } else { //alert("StartAppletWithAppletTag tags empty"); }; }; this.addParameter = function (name, value) { switch (name.toUpperCase()) { case "NAME": return false; break; case "ID": return false; break; default: break; }; this.setParameter("user",name, value); return true; }; this.getUserParameters = function (type) { var tmpStr=""; var params = this.getActiveParameters("user"); var i; switch(type) { case "OBJECT": for(i = 0;i < params.length;i++) { tmpStr += '\n'; } break; case "EMBED": for(i = 0;i < params.length;i++) { tmpStr += params[i] + ' = \"' + this.getParameter("user",params[i]) + '\"\n'; } break; case "APPLET": for(i = 0;i < params.length;i++) { tmpStr += '\n'; } break; default: break; } return tmpStr; }; this.write = function (strhtml, tagid) { var htmlElement; //alert("AppletSpec.write : strhtml " + strhtml + " tagid " + tagid); if (document.layers && (document.layers[tagid].document !== null)) { htmlElement = document.layers[tagid].document; htmlElement.open(); htmlElement.write(strhtml); htmlElement.close(); } else if (document.all && (document.all(tagid) !== null)) { htmlElement = document.all(tagid); htmlElement.innerHTML = strhtml; } else if (document.documentElement && (document.getElementById(tagid) !== null)) { htmlElement = document.getElementById(tagid); htmlElement.innerHTML = strhtml; } }; this.appletToString = function () { var tmpStr = ""; //added Object ID var objid = this.getUniqueElementID(); var embedid = this.getUniqueElementID(); tmpStr = '\n'; if(this.getParameter("applet","cache_version") !== null && this.getParameter("applet","cache_version") !== ''){ tmpStr += '\n'; tmpStr += '\n'; } else{ tmpStr += '\n'; } tmpStr += '\n'; tmpStr += '\n'; if (this.getParameter("applet", "codebase") !== "") { tmpStr += '\n'; } tmpStr += '\n'; //added eval_start_exit for OBJECT tmpStr += '\n'; tmpStr += this.getUserParameters("OBJECT"); tmpStr += '\n'; tmpStr += '\n'; tmpStr += '\n'; //added eval_start_exit for APPLET tmpStr += '\n'; tmpStr += ' 0){ if(container.getClipByFile(_value)) { var ex = new MeException('File =>' + _value + '<= is already associated with another clip.'); throw ex; } else { meLogger.write('valid file name used.=> ' + _value, 1); return true; } } else { meLogger.write(_value + ' is not a valid file name. Name = '+_name + ' Group='+ _group, 2); throw new MeException('File =>' + _value + '<= is not a valid file name.'); } return false; }; this.nameValidator = function (group, _name, _value) { meLogger.write('Name Validator Called on ' + _value, 1); if(_value === null || _value === ""){ //return false; var ex = new MeException('Clip => '+ _value + '<= is not a valid clip name'); throw ex; } if(container){ if(ControlData == container.constructor) { if(container.getClip(_value)) { throw new MeException('Clip =>' + _value + '<= already exists'); } } else { return false; } meLogger.write('Valid clip name is used=>' + _value, 2); return true; } throw new MeException('name can not be validated. '); }; /** * X.equals(y) = 1 if x > y, -1 if X < Y and 0 if x = y **/ function equals(anotherClip) { if (anotherClip instanceof Clip) { if(order > anotherClip.getOrder()){ return 1; } if(order < anotherClip.getOrder()){ return -1; } if(order == anotherClip.getOrder()){ return 0; } } throw new MeException("Could not compare Clips."); } function setOrder(_order) { order = _order; } function getOrder() { return order; } function prepare4Encoding(_base){ meLogger.write('updating clip information.'); var success = true; //assume success // delete any existing artifacts deleteFile(toPath(_base,'video_s' + this.getOrder() + '.dat'),true); deleteFile(toPath(_base,'video_s' + this.getOrder() + '.idx'),true); deleteFile(toPath(_base,'audio_s' + this.getOrder() + '.dat'),true); deleteFile(toPath(_base,'audio_s' + this.getOrder() + '.idx'),true); if(!success) return false; //Unable to delete sdl file this.setParameter('video','dataOut', toPath(_base,'video_s'+ this.getOrder() + '.dat')); this.setParameter('video','indexOut', toPath(_base,'video_s'+ this.getOrder() + '.idx')); this.setParameter('audio','dataOut', toPath(_base,'audio_s'+ this.getOrder() + '.dat')); this.setParameter('audio','indexOut', toPath(_base,'audio_s'+ this.getOrder() + '.idx')); return success; } function revertFromEncoding(){ try{ this.removeParameter('video','dataOut'); this.removeParameter('video','indexOut'); this.removeParameter('audio','dataOut'); this.removeParameter('audio','indexOut'); } catch(e) { alert("Clip.revertFromEncoding EXCEPTION: " + e.message); meLogger.write(e.name + ':- ' + e.message); } } function init(){ if((container)&&(ControlData == container.constructor)) { if(container.getClipByFile(_file)) { var ex = new MeException('File =>' + _file + '<= already associated with another clip in this project.'); throw ex; } if(container.getClip(_name)) { throw new MeException('Clip =>' + _name + '<= already exists'); } else { that.setProperty('general', 'name', 'validator', that.nameValidator,container); that.setProperty('general', 'file', 'validator', that.fileValidator,container); that.setParameter('general','name', _name); that.setParameter('general','file', _file); //order = Clip.counter++; //return; } } else { throw new MeException('Error initializing Clip object.'); } } this.createDocumentFragment = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var fragment = xmlDocument.createDocumentFragment(); var node = xmlDocument.createElement('subclip'); node.appendChild(this._createDocumentFragment(xmlDocument)); fragment.appendChild(node); return fragment; }; this.toXML = null; this.toXML = function (xmlDocument) { xmlDocument =