This repository has been archived by the owner on Jul 29, 2021. It is now read-only.
forked from timesheets/timesheets.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timesheets.min.js
1 lines (1 loc) · 31.1 KB
/
timesheets.min.js
1
(function(){var a={bind:function(c,b,d){},unbind:function(c,b,d){},trigger:function(c,b){}};if(window.addEventListener){a.bind=function(c,b,d){if(!c){return}c.addEventListener(b,d,false)};a.unbind=function(c,b,d){if(!c){return}c.removeEventListener(b,d,false)};a.trigger=function(d,b){if(!d){return}if(!a.eventList){a.eventList=[]}var c=a.eventList[b];if(!c){c=document.createEvent("Event");c.initEvent(b,false,false);a.eventList[b]=c}d.dispatchEvent(c)};a.preventDefault=function(b){b.preventDefault()}}else{if(window.attachEvent){a.bind=function(d,b,e){if(!d){return}var c=b+e;b="on"+b;if(b in d){if(!d["e"+c]){d["e"+c]=e;d[c]=function(){d["e"+c](window.event)};d.attachEvent(b,d[c])}}else{if(!d.eventList){d.eventList=[]}if(!d.eventList[b]){d.eventList[b]=[]}d.eventList[b].push(e)}};a.unbind=function(h,d,k){if(!h){return}var g=d+k;d="on"+d;if(d in h){if(h["e"+g]){h.detachEvent(d,h[g]);try{delete (h[g]);delete (h["e"+g])}catch(j){h[g]=null;h["e"+g]=null}}}else{if(!h||!h.eventList||!h.eventList[d]){return}var f=h.eventList[d];var b=f.length;for(var c=0;c<b;c++){if(f[c]==k){f.slice(c,1);return}}}};a.trigger=function(h,d){if(!h){return}d="on"+d;if(d in h){try{h.fireEvent(d);return}catch(j){}}var g={};g.target=h;g.srcElement=h;if(!h||!h.eventList||!h.eventList[d]){return}var f=h.eventList[d];var b=f.length;for(var c=0;c<b;c++){f[c].call(h,g)}};a.preventDefault=function(b){b.returnValue=false}}}a.onHashChange=function(c){if("onhashchange" in window){a.bind(window,"hashchange",c)}else{var b="";window.setInterval(function(){if(b!=window.location.hash){b=window.location.hash;c()}},250)}};a.onDOMReady=function(b){if(window.addEventListener){window.addEventListener("DOMContentLoaded",b,false)}else{a.bind(window,"load",b)}};a.onMediaReady=function(b){a.bind(window,"MediaContentLoaded",b)};a.onSMILReady=function(b){a.bind(window,"SMILContentLoaded",b)};window.EVENTS=a})();(function(){var f=true;var e=false;function c(g,h){}function d(g,h){}if(window.qwery){d=qwery}else{if(window.Sizzle){d=Sizzle}else{if(window.jQuery){d=function(g,h){return $(g,h)}}else{if(window.YAHOO&&window.YAHOO.util&&window.YAHOO.util.Selector){d=YAHOO.util.Selector.query}else{if(document.querySelectorAll){e=true;d=function(g,h){h=h||document;return h.querySelectorAll(g)}}else{f=false;d=function(g,j){j=j||document;var h=[];if(/^#[^\s]+$/.test(g)){var k=document.getElementById(g.substring(1));if(k){h.push(k)}}else{if(/^[a-z]+$/i.test(g)){h=j.getElementsByTagName(g)}}return h}}}}}}if(document.querySelector){c=function(g,h){h=h||document;return h.querySelector(g)}}else{c=function(g,j){var h=d(g,j);if(h&&h.length){return h[0]}else{return null}}}function b(){if(f){return d("*[data-timecontainer], *[smil-timecontainer], *[timeContainer]")}var j=[];var h=document.getElementsByTagName("*");var k=/^(par|seq|excl)$/i;for(var g=0;g<h.length;g++){if(k.test(h[g].nodeName)||h[g].getAttribute("data-timecontainer")||h[g].getAttribute("smil-timecontainer")||h[g].getAttribute("timeContainer")){j.push(h[g])}}return j}function a(){if(f){return d("link[rel=timesheet]")}var j=[];var g=document.getElementsByTagName("link");for(var h=0;h<g.length;h++){if(g[h].rel.toLowerCase()=="timesheet"){j.push(g[h])}}return j}window.QWERY={select:c,selectAll:d,selectTimeContainers:b,selectExtTimesheets:a,supported:f,nativeSelector:e}})();if(!Array.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}}if(!Date.now){Date.now=function(){var a=new Date();return a.getTime()}}(function(){function consoleWarn(message){if(typeof(console)=="object"){console.warn(message)}}var TIMERATE=40;if(window.mejs){mejs.MediaElementDefaults.timerRate=TIMERATE}var TIMECONTAINERS=[];var OLDIE=(window.addEventListener)?false:true;function checkHash(){var targetElement=null;var targetTiming=null;var container=null;var i,tmp;var hash=document.location.hash;if(hash.length){var targetID=hash.substr(1).replace(/\&.*$/,"");targetElement=document.getElementById(targetID)||document.getElementById(targetID.substr(1))}if(!targetElement){return}tmp=document.getTimeNodesByTarget(targetElement);if(tmp.length){targetTiming=tmp[0];container=tmp[0].parentNode}var time=NaN;if(targetTiming&&targetTiming.timeContainer){tmp=hash.split("&");for(i=0;i<tmp.length;i++){if(/^t=.*/i.test(tmp[i])){time=targetTiming.parseTime(tmp[i].substr(2).replace(/,.*$/,""));break}}}var containers=[];var indexes=[];var timeNodes=[];var element=targetElement;while(container){for(var index=0;index<container.timeNodes.length;index++){if(container.timeNodes[index].target==element){if(!container.timeNodes[index].isActive()){containers.push(container);indexes.push(index);timeNodes.push(container.timeNodes[index])}break}}element=container.getNode();container=container.parentNode}for(i=containers.length-1;i>=0;i--){containers[i].selectIndex(indexes[i])}if(targetTiming&&!isNaN(time)){targetTiming.setCurrentTime(time)}if(targetElement.scrollIntoViewIfNeeded!=undefined){targetElement.scrollIntoViewIfNeeded()}else{try{var tabIndex=targetElement.tabIndex;targetElement.tabIndex=0;targetElement.focus();targetElement.blur();if(tabIndex>=0){targetElement.tabIndex=tabIndex}else{targetElement.removeAttribute("tabIndex")}}catch(e){}}}EVENTS.onSMILReady(function(){checkHash();EVENTS.onHashChange(checkHash)});function parseMediaElement(node){if(window.MediaElement){var m=new MediaElement(node,{success:function(mediaAPI,element){if((/^(flash|silverlight)$/i).test(mediaAPI.pluginType)){var pluginElement=element.previousSibling;if(element.firstChild&&(/^(object|embed)$/i).test(element.firstChild.nodeName)){pluginElement=element.firstChild}else{if(pluginElement&&((/^me_flash/).test(pluginElement.id)||(/^me_silverlight/).test(pluginElement.id)||(pluginElement.className=="me-plugin"))){pluginElement.setAttribute("timeAction","none")}}element.pluginElement=pluginElement;element.mediaAPI=mediaAPI}EVENTS.trigger(document,"MediaElementLoaded")},error:function(){alert("MediaElement error")}})}else{node.setCurrentTime=function(time){node.currentTime=time};EVENTS.trigger(document,"MediaElementLoaded")}}function parseAllMediaElements(){var allAudioElements=document.getElementsByTagName("audio");var allVideoElements=document.getElementsByTagName("video");var meLength=allAudioElements.length+allVideoElements.length;if(meLength===0){EVENTS.trigger(window,"MediaContentLoaded");return}else{if(OLDIE&&!window.MediaElement){if(0){throw"MediaElement.js is required on IE<9"}}}var meParsed=0;function CountMediaElements(){meParsed++;if(meParsed>=meLength){EVENTS.unbind(document,"MediaElementLoaded",CountMediaElements);EVENTS.trigger(window,"MediaContentLoaded")}}EVENTS.bind(document,"MediaElementLoaded",CountMediaElements);for(var i=0;i<allAudioElements.length;i++){parseMediaElement(allAudioElements[i])}for(i=0;i<allVideoElements.length;i++){parseMediaElement(allVideoElements[i])}}function parseTimeContainerNode(node){if(!node){return}if(!node.timing){var smilPlayer=new smilTimeElement(node);smilPlayer.show()}else{}}function parseTimesheetNode(timesheetNode){var containers=timesheetNode.childNodes;for(var i=0;i<containers.length;i++){if(containers[i].nodeType==1){parseTimeContainerNode(containers[i])}}}function parseAllTimeContainers(){TIMECONTAINERS=[];var allTimeContainers=QWERY.selectTimeContainers();for(var i=0;i<allTimeContainers.length;i++){parseTimeContainerNode(allTimeContainers[i])}var timesheets=QWERY.selectExtTimesheets();var tsLength=timesheets.length;var tsParsed=0;function CountTimesheets(){tsParsed++;if(tsParsed>tsLength){EVENTS.unbind(document,"SMILTimesheetLoaded",CountTimesheets);EVENTS.trigger(window,"SMILContentLoaded")}}EVENTS.bind(document,"SMILTimesheetLoaded",CountTimesheets);var xhr;for(i=0;i<tsLength;i++){if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");xhr.open("GET",timesheets[i].href,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.loadXML(xhr.responseText);var tsNodes=xmlDoc.getElementsByTagName("timesheet");if(tsNodes&&tsNodes.length){parseTimesheetNode(tsNodes[0])}EVENTS.trigger(document,"SMILTimesheetLoaded")}};xhr.send(null)}else{if(window.XMLHttpRequest){xhr=new XMLHttpRequest();xhr.overrideMimeType("text/xml");xhr.open("GET",timesheets[i].href,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){var tsNodes=xhr.responseXML.getElementsByTagName("timesheet");if(tsNodes&&tsNodes.length){parseTimesheetNode(tsNodes[0])}EVENTS.trigger(document,"SMILTimesheetLoaded")}};xhr.send(null)}else{EVENTS.trigger(document,"SMILTimesheetLoaded")}}}if(!OLDIE){var docElt=document.documentElement;var ns={xhtml:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg",smil:docElt.getAttribute("xmlns:smil")||"http://www.w3.org/ns/SMIL"};function nsResolver(prefix){return ns[prefix]||null}var TimesheetNS=nsResolver("smil");timesheets=document.getElementsByTagNameNS(TimesheetNS,"timesheet");if(!timesheets.length){timesheets=document.getElementsByTagName("timesheet")}for(i=0;i<timesheets.length;i++){parseTimesheetNode(timesheets[i])}if(docElt.getAttribute("xmlns")){var containers=document.evaluate("//*[@smil:timeContainer]",document,nsResolver,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var thisContainer=containers.iterateNext();try{while(thisContainer){parseTimeContainerNode(thisContainer);thisContainer=containers.iterateNext()}}catch(e){}}}EVENTS.trigger(document,"SMILTimesheetLoaded")}EVENTS.onDOMReady(function(){EVENTS.onMediaReady(parseAllTimeContainers);parseAllMediaElements()});function smilInternalTimer(timerate){if(!timerate){timerate=TIMERATE}var self=this;this.onTimeUpdate=null;var timerID=null;var timeStart=0;var timePause=0;var paused=true;this.isPaused=function(){return paused};this.getTime=function(){var ms=timePause;if(!paused){ms+=Date.now()-timeStart}return(ms/1000)};this.setTime=function(time){timeStart-=(time-self.getTime())*1000};this.Play=function(){if(!paused){return}timeStart=Date.now();timerID=setInterval(function(){self.onTimeUpdate()},timerate);paused=false};this.Pause=function(){if(paused){return}clearInterval(timerID);timerID=null;timePause=1000*self.getTime();paused=true;self.onTimeUpdate()};this.Stop=function(){if(!timerID){return}clearInterval(timerID);timerID=null;timePause=0;paused=true;self.onTimeUpdate()}}function smilExternalTimer(mediaPlayerNode){var self=this;var currentTime=NaN;this.onTimeUpdate=null;var mediaPlayerAPI=mediaPlayerNode;if(mediaPlayerNode.mediaAPI){mediaPlayerAPI=mediaPlayerNode.mediaAPI}this.isPaused=function(){return mediaPlayerAPI.paused};this.getTime=function(){return isNaN(currentTime)?mediaPlayerAPI.currentTime:currentTime};this.setTime=function(time){if(mediaPlayerAPI.seeking){consoleWarn("seeking");function setThisTime(){mediaPlayerAPI.setCurrentTime(time);mediaPlayerAPI.removeEventListener("seeked",setThisTime,false)}mediaPlayerAPI.removeEventListener("seeked",setThisTime,false);mediaPlayerAPI.addEventListener("seeked",setThisTime,false)}else{try{mediaPlayerAPI.setCurrentTime(time)}catch(e){consoleWarn(e);function setThisTimeErr(){mediaPlayerAPI.setCurrentTime(time);mediaPlayerAPI.removeEventListener("canplay",setThisTimeErr,false)}mediaPlayerAPI.addEventListener("canplay",setThisTimeErr,false)}}};this.Play=function(){if(mediaPlayerAPI.addEventListener){mediaPlayerAPI.addEventListener("timeupdate",self.onTimeUpdate,false)}};this.Pause=function(){if(mediaPlayerAPI.pause){mediaPlayerAPI.pause()}};this.Stop=function(){if(mediaPlayerAPI.removeEventListener){mediaPlayerAPI.removeEventListener("timeupdate",self.onTimeUpdate,false)}}}smilTimeItem.prototype.getNode=function(){};smilTimeItem.prototype.parseTime=function(timeStr){if(!timeStr||!timeStr.length){return undefined}else{if(timeStr=="indefinite"){return Infinity}else{if(/ms[\s]*$/.test(timeStr)){return parseFloat(timeStr)/1000}else{if(/s[\s]*$/.test(timeStr)){return parseFloat(timeStr)}else{if(/min[\s]*$/.test(timeStr)){return parseFloat(timeStr)*60}else{if(/h[\s]*$/.test(timeStr)){return parseFloat(timeStr)*3600}else{if(/^[0-9:\.]*$/.test(timeStr)){var seconds=0;var tmp=timeStr.split(":");for(var i=0;i<tmp.length;i++){seconds=(seconds*60)+parseFloat(tmp[i])}return seconds}else{return timeStr}}}}}}}};smilTimeItem.prototype.parseEvents=function(eventStr,callback){var events=[];if(!eventStr||!eventStr.length||!isNaN(eventStr)){return events}var eventStrArray=eventStr.split(/;\s*/);for(var i=0;i<eventStrArray.length;i++){var tmp=eventStrArray[i].split(".");var target,evt;if(tmp.length>=2){target=document.getElementById(tmp[0]);evt=tmp[1]}else{target=this.parentTarget;evt=eventStr}events.push({target:target,event:evt});if(callback){EVENTS.bind(target,evt,callback)}}return events};smilTimeItem.prototype.parseAttribute=function(attrName,dValue){var node=this.getNode();var nodeName=node.nodeName.replace(/^smil:/,"");var value="";if((attrName=="timeContainer")&&(/^(seq|par|excl)$/i).test(nodeName)){value=nodeName}else{value=node.getAttribute(attrName)||node.getAttribute("data-"+attrName.toLowerCase())||node.getAttribute("smil-"+attrName.toLowerCase())||node.getAttribute("smil:"+attrName)}if(!value||!value.length){return dValue}switch(attrName){case"timeContainer":case"timeAction":return value.toLowerCase();case"repeatCount":return(value=="indefinite")?Infinity:parseFloat(value);case"onbegin":case"onend":return function(){eval(value)};case"beginInc":case"begin":case"dur":case"end":case"repeatDur":return this.parseTime(value);default:return value}};smilTimeItem.prototype.newTargetHandler=function(timeAction,target){if(!target){return function(state){}}var setTargetState_intrinsic=function(state){target.setAttribute("smil",state)};var setTargetState_display=function(state){target.setAttribute("smil",state);target.style.display=(state=="active")?"block":"none"};var setTargetState_visibility=function(state){target.setAttribute("smil",state);target.style.visibility=(state=="active")?"visible":"hidden"};var setTargetState_style=function(state){target.setAttribute("smil",state);var active=(state=="active");if(!target._smilstyle){target._smilstyle=target.style.cssText}target.style.cssText=active?target._smilstyle:""};var setTargetState_class=function(state){target.setAttribute("smil",state);var active=(state=="active");if(!target._smilclass_active){var activeCN=target.className+(target.className.length?" ":"")+timeAction.replace(/class:[\s]*/,"");target._smilclass_active=activeCN;target._smilclass_idle=target.className}target.className=active?target._smilclass_active:target._smilclass_idle};switch(timeAction){case"display":return setTargetState_display;break;case"visibility":return setTargetState_visibility;break;case"style":return setTargetState_style;break;case"intrinsic":if(OLDIE){return setTargetState_display}else{return setTargetState_intrinsic}default:if(/^class:/.test(timeAction)){return setTargetState_class}else{return setTargetState_display}break}return null};smilTimeItem.prototype.addEventListener=function(events,callback){for(var i=0;i<events.length;i++){var evt=events[i];if(evt.target){EVENTS.bind(evt.target,evt.event,callback)}}};smilTimeItem.prototype.removeEventListener=function(events,callback){for(var i=0;i<events.length;i++){var evt=events[i];if(evt.target){EVENTS.unbind(evt.target,evt.event,callback)}}};smilTimeItem.prototype.dispatchEvent=function(eventType){var func=this["on"+eventType];EVENTS.trigger(this.parentTarget,eventType);if(func){func.call(this.parentTarget)}};function smilTimeItem(domNode,parentNode,targetNode){var self=this;this.parseTime=smilTimeItem.prototype.parseTime;this.parseEvents=smilTimeItem.prototype.parseEvents;this.parseAttribute=smilTimeItem.prototype.parseAttribute;this.parentNode=parentNode;this.previousSibling=null;this.nextSibling=null;this.timeNodes=null;this.getNode=function(){return domNode};this.target=targetNode||domNode;if(/^(smil:){0,1}(par|seq|excl)$/i.test(this.target.nodeName)){this.target=null}this.parentTarget=this.target;var node=this.parentNode;while(!this.parentTarget&&node){this.parentTarget=node.target;node=node.parentNode}var timeAction=parentNode?parentNode.timeAction:"intrinsic";this.timeAction=this.parseAttribute("timeAction",timeAction);this.timeContainer=this.parseAttribute("timeContainer",null);this.begin=this.parseAttribute("begin");this.dur=this.parseAttribute("dur");this.end=this.parseAttribute("end");var fillDefault=parentNode?parentNode.fillDefault:"remove";this.fill=this.parseAttribute("fill",fillDefault);this.fillDefault=this.parseAttribute("fillDefault",null);this.setTargetState=smilTimeItem.prototype.newTargetHandler.call(this,this.timeAction,this.target);this.addEventListener=smilTimeItem.prototype.addEventListener;this.removeEventListener=smilTimeItem.prototype.removeEventListener;this.dispatchEvent=smilTimeItem.prototype.dispatchEvent;this.onbegin=this.parseAttribute("onbegin");this.onend=this.parseAttribute("onend");var beginEvents=this.parseEvents(this.begin);var endEvents=this.parseEvents(this.end);function onbeginListener(){self.time_in=self.parentNode.getCurrentTime();self.time_out=isNaN(self.end)?Infinity:self.end;self.parentNode.selectItem(self)}function onendListener(){self.time_in=isNaN(self.begin)?Infinity:self.begin;self.time_out=self.parentNode.getCurrentTime();if(self.parentNode.timeContainer=="seq"){self.parentNode.selectIndex(self.parentNode.currentIndex+1)}else{self.parentNode.currentIndex=-1}self.hide()}var state="";this.isActive=function(){return(state=="active")};this.show=function(){if(state=="active"){return}state="active";if(0){try{}catch(e){}}self.setTargetState(state);self.dispatchEvent("begin");self.addEventListener(endEvents,onendListener);self.removeEventListener(beginEvents,onbeginListener)};this.hide=function(){if(state=="done"){return}state="done";if(0){try{}catch(e){}}if(self.fill!="hold"){self.setTargetState(state)}self.dispatchEvent("end");self.addEventListener(beginEvents,onbeginListener);self.removeEventListener(endEvents,onendListener)};this.reset=function(){if(state=="idle"){return}state="idle";if(0){try{}catch(e){}}self.setTargetState(state);self.addEventListener(beginEvents,onbeginListener);self.removeEventListener(endEvents,onendListener)};if(targetNode&&(targetNode!=domNode)){if(!targetNode.extTiming){targetNode.extTiming=[]}targetNode.extTiming.push(this)}else{if(this.target){domNode.timing=this}}}smilTimeContainer_generic.prototype.getCurrentTime=function(){};smilTimeContainer_generic.prototype.setCurrentTime=function(){};smilTimeContainer_generic.prototype.onTimeUpdate=function(){};smilTimeContainer_generic.prototype.parseTimeNodes=function(){var timeNodes=[];var syncMasterNode=null;var segment;var children=this.getNode().childNodes;for(var i=0;i<children.length;i++){segment=children[i];var targets=[];if(segment.nodeType==1){if(segment.timing||segment.getAttribute("timing")){consoleWarn("!! "+segment.nodeName+" is already initialized !!")}else{if(/^(smil:){0,1}item$/i.test(segment.nodeName)){var select=segment.getAttribute("select")||segment.getAttribute("smil:select");targets=QWERY.selectAll(select,this.parentTarget);if(segment.childNodes.length){segment.setAttribute("timeContainer","par")}}else{targets.push(segment)}}for(var j=0;j<targets.length;j++){var target=targets[j];var node=null;if(segment!=target){node=new smilTimeElement(segment,this,target);var beginInc=node.parseAttribute("beginInc");if(isNaN(node.begin)&&!isNaN(beginInc)){node.begin=j*beginInc}}else{node=new smilTimeElement(segment,this)}if(node.parseAttribute("syncMaster")){syncMasterNode=target}if(node.timeAction!="none"){timeNodes.push(node)}else{delete (node)}}}}for(i=0;i<timeNodes.length;i++){segment=timeNodes[i];if(i>0){segment.previousSibling=timeNodes[i-1]}if(i<timeNodes.length-1){segment.nextSibling=timeNodes[i+1]}segment.parentNode=this}if(this.dur==undefined){if(!isNaN(this.end-this.begin)){this.dur=this.end-this.begin}else{this.dur=Infinity}}return{timeNodes:timeNodes,syncMasterNode:syncMasterNode}};smilTimeContainer_generic.prototype.computeTimeNodes=function(){};smilTimeContainer_generic.prototype.getMediaSync=function(syncMasterNode){var mediaSyncSelector=this.parseAttribute("mediaSync");return QWERY.select(mediaSyncSelector)||syncMasterNode};smilTimeContainer_generic.prototype.currentIndex=-1;smilTimeContainer_generic.prototype.selectIndex=function(index){if(this.repeatCount==Infinity){index=index%this.timeNodes.length}if((index>=0)&&(index<this.timeNodes.length)&&(index!=this.currentIndex)){var time=this.timeNodes[index].time_in;if(!isNaN(time)&&(time<Infinity)){if(this.mediaSyncNode){this.setCurrentTime(time+0.1);this.onTimeUpdate();return}else{this.setCurrentTime(time)}}this.currentIndex=index;this.timeNodes[index].show();for(var i=0;i<index;i++){this.timeNodes[i].hide()}for(i=index+1;i<this.timeNodes.length;i++){this.timeNodes[i].reset()}this.dispatchEvent("change")}};smilTimeContainer_generic.prototype.selectItem=function(item){var index=this.timeNodes.indexOf(item);this.selectIndex(index)};function smilTimeContainer_generic(timeContainerNode,parentNode,timerate){this.parseTimeNodes=smilTimeContainer_generic.prototype.parseTimeNodes;this.getMediaSync=smilTimeContainer_generic.prototype.getMediaSync;var self=this;this.repeatCount=this.parseAttribute("repeatCount",1);this.repeatDur=this.parseAttribute("repeatDur",NaN);var result=this.parseTimeNodes();this.timeNodes=result.timeNodes;this.computeTimeNodes();this.mediaSyncNode=this.getMediaSync(result.syncMasterNode);var timer=null;this.mediaSyncAPI=this.mediaSyncNode;if(this.mediaSyncNode){timer=new smilExternalTimer(this.mediaSyncNode);if(this.mediaSyncNode.mediaAPI){this.mediaSyncAPI=this.mediaSyncNode.mediaAPI}}else{timer=new smilInternalTimer(timerate)}this.isPaused=timer.isPaused;this.getCurrentTime=timer.getTime;this.setCurrentTime=timer.setTime;this.Play=timer.Play;this.Pause=timer.Pause;this.Stop=timer.Stop;timer.onTimeUpdate=function(){self.onTimeUpdate()};this.addEventListener=smilTimeItem.prototype.addEventListener;this.removeEventListener=smilTimeItem.prototype.removeEventListener;this.dispatchEvent=smilTimeItem.prototype.dispatchEvent;this.onbegin=this.parseAttribute("onbegin");this.onend=this.parseAttribute("onend");var beginEvents=this.parseEvents(this.begin);var endEvents=this.parseEvents(this.end);function onbeginListener(){self.time_in=self.parentNode.getCurrentTime();self.time_out=isNaN(self.end)?Infinity:self.end;self.parentNode.selectItem(self)}function onendListener(){self.time_in=isNaN(self.begin)?Infinity:self.begin;self.time_out=self.parentNode.getCurrentTime();self.parentNode.currentIndex=-1;if(self.parentNode){if(self.parentNode.timeContainer=="seq"){self.parentNode.selectIndex(self.parentNode.currentIndex+1)}else{self.parentNode.currentIndex=-1}self.hide()}}var state="";this.isActive=function(){return(state=="active")};this.show=function(){if(state=="active"){return}state="active";self.Play();self.setTargetState(state);self.dispatchEvent("begin");self.addEventListener(endEvents,onendListener);self.removeEventListener(beginEvents,onbeginListener);this.currentIndex=-1};this.hide=function(){if(state=="done"){return}state="done";self.Stop();self.setTargetState(state);for(var i=0;i<self.timeNodes.length;i++){self.timeNodes[i].hide();if(self.timeNodes[i].fill!="hold"){self.timeNodes[i].setTargetState("done")}}self.dispatchEvent("end");self.addEventListener(beginEvents,onbeginListener);self.removeEventListener(endEvents,onendListener)};this.reset=function(){if(state=="idle"){return}state="idle";self.Stop();self.setTargetState(state);for(var i=0;i<self.timeNodes.length;i++){self.timeNodes[i].reset()}self.addEventListener(beginEvents,onbeginListener);self.removeEventListener(endEvents,onendListener);this.currentIndex=-1};TIMECONTAINERS.push(this)}smilTimeContainer_par.prototype.computeTimeNodes=function(){for(var i=0;i<this.timeNodes.length;i++){var segment=this.timeNodes[i];segment.reset();if(segment.begin!=undefined){segment.time_in=isNaN(segment.begin)?Infinity:segment.begin}else{segment.time_in=0}if(segment.dur!=undefined){segment.time_out=segment.time_in+segment.dur}else{if(segment.end!=undefined){segment.time_out=isNaN(segment.end)?Infinity:segment.end}else{segment.time_out=this.dur}}}};smilTimeContainer_par.prototype.onTimeUpdate=function(){var time=this.getCurrentTime();if(this.repeatCount>=Infinity){time=time%this.dur}for(var i=0;i<this.timeNodes.length;i++){if(time<this.timeNodes[i].time_in){this.timeNodes[i].reset()}else{if(time>=this.timeNodes[i].time_out){this.timeNodes[i].hide()}else{this.timeNodes[i].show()}}}};function smilTimeContainer_par(domNode,parentNode,timerate){this.computeTimeNodes=smilTimeContainer_par.prototype.computeTimeNodes;this.onTimeUpdate=smilTimeContainer_par.prototype.onTimeUpdate;smilTimeContainer_generic.call(this,domNode,timerate);this.currentIndex=-1;this.selectIndex=function(index){};this.selectItem=function(item){if(!isNaN(item.time_in)){this.setCurrentTime(item.time_in)}item.show()}}smilTimeContainer_excl.prototype.computeTimeNodes=function(){var segment=null;for(i=0;i<this.timeNodes.length;i++){segment=this.timeNodes[i];segment.reset();if(segment.begin!=undefined){segment.time_in=isNaN(segment.begin)?Infinity:segment.begin}else{segment.time_in=Infinity}if(segment.end!=undefined){segment.time_out=isNaN(segment.end)?Infinity:segment.end}else{if((i<this.timeNodes.length-1)&&!isNaN(this.timeNodes[i+1].begin)){segment.time_out=this.timeNodes[i+1].begin}else{if(!isNaN(segment.dur)){segment.time_out=segment.time_in+segment.dur}else{segment.time_out=this.dur}}}}if(!segment){return}if(!this.timeNodes[0].time_in){this.timeNodes[0].show()}if(this.dur==undefined){this.dur=segment.time_out-this.timeNodes[0].time_in}};smilTimeContainer_excl.prototype.onTimeUpdate=function(){var time=this.getCurrentTime();if(this.repeatCount>=Infinity){time=time%this.dur}if(this.currentIndex>=0){var time_in=this.timeNodes[this.currentIndex].time_in;var time_out=this.timeNodes[this.currentIndex].time_out;var outOfBounds=(time<time_in)||(time>=time_out);if(!outOfBounds){return}}var index=-1;var active=false;for(var i=0;i<this.timeNodes.length;i++){var segment=this.timeNodes[i];var withinBounds=(time>=segment.time_in)&&(time<segment.time_out);if(time<segment.time_in){segment.reset()}else{if(time>=segment.time_out){segment.hide()}else{if(withinBounds){if(active){segment.reset()}else{active=true;segment.show();index=i}}}}}if(index>=0){this.currentIndex=index}else{if((this.currentIndex<this.timeNodes.length-1)&&isNaN(this.timeNodes[this.currentIndex+1].time_in)){this.selectIndex(this.currentIndex+1)}}};function smilTimeContainer_excl(domNode,parentNode,timerate){this.computeTimeNodes=smilTimeContainer_excl.prototype.computeTimeNodes;this.onTimeUpdate=smilTimeContainer_excl.prototype.onTimeUpdate;smilTimeContainer_generic.call(this,domNode,parentNode,timerate);var self=this;this.currentIndex=-1;if(this.timeNodes.length&&(this.timeNodes[0].time_in<=0)){this.currentIndex=0}this.selectIndex=smilTimeContainer_generic.prototype.selectIndex;this.selectItem=smilTimeContainer_generic.prototype.selectItem;this.parseEvents(this.parseAttribute("first"),function(){self.selectIndex(0)});this.parseEvents(this.parseAttribute("prev"),function(){self.selectIndex(self.currentIndex-1)});this.parseEvents(this.parseAttribute("next"),function(){self.selectIndex(self.currentIndex+1)});this.parseEvents(this.parseAttribute("last"),function(){self.selectIndex(self.timeNodes.length-1)})}smilTimeContainer_seq.prototype.computeTimeNodes=function(){var segment=null;for(var i=0;i<this.timeNodes.length;i++){segment=this.timeNodes[i];segment.reset();if(segment.begin!=undefined){segment.time_in=segment.begin}else{if((i>0)&&(this.timeNodes[i-1].time_out<Infinity)){segment.time_in=this.timeNodes[i-1].time_out}else{segment.time_in=0}}if(!isNaN(segment.dur)){segment.time_out=segment.time_in+segment.dur}else{if(i==this.timeNodes.length-1){segment.time_out=this.dur}else{segment.time_out=Infinity}}}if(!segment){return}if((this.dur==undefined)||(this.dur>=Infinity)){this.dur=segment.time_out}if(this.end==undefined){this.end=segment.time_out+this.begin}};smilTimeContainer_seq.prototype.onTimeUpdate=function(){var time=this.getCurrentTime();var withinBounds,outOfBounds,segment;if(this.repeatCount>=Infinity){time=time%this.dur}if(this.currentIndex>=0){segment=this.timeNodes[this.currentIndex];outOfBounds=(time<segment.time_in)||(time>=segment.time_out);withinBounds=(time>=segment.time_in)&&(time<segment.time_out);if(withinBounds){return}else{this.timeNodes[this.currentIndex].hide()}}if(this.currentIndex<this.timeNodes.length-1){var time_in=this.timeNodes[this.currentIndex+1].time_in;var time_out=this.timeNodes[this.currentIndex+1].time_out;outOfBounds=(time<time_in)||(time>=time_out);if((time_in>=Infinity)||!outOfBounds){this.currentIndex++;this.timeNodes[this.currentIndex].show();return}}var index=-1;var active=false;for(var i=0;i<this.timeNodes.length;i++){segment=this.timeNodes[i];withinBounds=(time>=segment.time_in)&&(time<segment.time_out);if(time<segment.time_in){segment.reset()}else{if(time>=segment.time_out){segment.hide()}else{if(withinBounds){if(active){segment.reset()}else{active=true;segment.show();index=i}}}}}if(index>=0){this.currentIndex=index}else{if((this.currentIndex<this.timeNodes.length-1)&&isNaN(this.timeNodes[this.currentIndex+1].time_in)){this.next()}}};function smilTimeContainer_seq(domNode,parentNode,timerate){this.computeTimeNodes=smilTimeContainer_seq.prototype.computeTimeNodes;this.onTimeUpdate=smilTimeContainer_seq.prototype.onTimeUpdate;smilTimeContainer_generic.call(this,domNode,parentNode,timerate);var self=this;this.currentIndex=-1;if(this.timeNodes.length&&(this.timeNodes[0].time_in<=0)){this.currentIndex=0}this.selectIndex=smilTimeContainer_generic.prototype.selectIndex;this.selectItem=smilTimeContainer_generic.prototype.selectItem;this.parseEvents(this.parseAttribute("first"),function(){self.selectIndex(0)});this.parseEvents(this.parseAttribute("prev"),function(){self.selectIndex(self.currentIndex-1)});this.parseEvents(this.parseAttribute("next"),function(){self.selectIndex(self.currentIndex+1)});this.parseEvents(this.parseAttribute("last"),function(){self.selectIndex(self.timeNodes.length-1)})}function smilTimeElement(domNode,parentNode,targetNode,timerate){smilTimeItem.call(this,domNode,parentNode,targetNode||domNode);switch(this.timeContainer){case"par":smilTimeContainer_par.call(this,domNode,parentNode,timerate);break;case"seq":smilTimeContainer_seq.call(this,domNode,parentNode,timerate);break;case"excl":smilTimeContainer_excl.call(this,domNode,parentNode,timerate);break;default:this.timeContainer=null;this.timeNodes=[];break}}document.createTimeContainer=function(domNode,parentNode,targetNode,timerate){return new smilTimeElement(domNode,parentNode,targetNode,timerate)};document.getTimeNodesByTarget=function(node){var timeNodes=[];if(!node){return timeNodes}if(node.timing){timeNodes.push(node.timing)}if(node.extTiming){for(var i=0;i<node.extTiming.length;i++){timeNodes.push(node.extTiming[i])}}timeNodes.item=function(index){return timeNodes[index]};return timeNodes};document.getTimeContainersByTarget=function(node){var contNodes=[];var timeNodes=document.getTimeNodesByTarget(node);for(var i=0;i<timeNodes.length;i++){if(timeNodes[i].timeContainer){contNodes.push(timeNodes[i])}}contNodes.item=function(index){return contNodes[index]};return contNodes};document.getTimeContainersByTagName=function(tagName){var contNodes=[];tagName=tagName.toLowerCase();if((/^(par|seq|excl)$/).test(tagName)){for(var i=0;i<TIMECONTAINERS.length;i++){if(TIMECONTAINERS[i].timeContainer.toLowerCase()==tagName){contNodes.push(TIMECONTAINERS[i])}}}else{if(tagName=="*"){contNodes=TIMECONTAINERS}}contNodes.item=function(index){return contNodes[index]};return contNodes}})();