Remove unused eval() calls in Timeline code to avoid AMO flagging, though we should probably integrate a newer version of Timeline anyway

This commit is contained in:
Dan Stillman 2009-11-13 06:13:08 +00:00
parent 034c2a1792
commit 3fd5fe06a3

View file

@ -38,9 +38,9 @@ var eventPainter=new Timeline.DurationEventPainter(eventPainterParams);return{wi
if("trackGap"in params){eventPainterParams.trackGap=params.trackGap;}
var eventPainter=new Timeline.DurationEventPainter(eventPainterParams);return{width:params.width,eventSource:eventSource,timeZone:("timeZone"in params)?params.timeZone:0,ether:ether,etherPainter:etherPainter,eventPainter:eventPainter};};Timeline.getDefaultTheme=function(){if(Timeline._defaultTheme==null){Timeline._defaultTheme=Timeline.ClassicTheme.create(Timeline.Platform.getDefaultLocale());}
return Timeline._defaultTheme;};Timeline.setDefaultTheme=function(theme){Timeline._defaultTheme=theme;};Timeline.loadXML=function(url,f){var fError=function(statusText,status,xmlhttp){alert("Failed to load data xml from "+url+"\n"+statusText);};var fDone=function(xmlhttp){var xml=xmlhttp.responseXML;if(!xml.documentElement&&xmlhttp.responseStream){xml.load(xmlhttp.responseStream);}
f(xml,url);};Timeline.XmlHttp.get(url,fError,fDone);};Timeline.loadJSON=function(url,f){var fError=function(statusText,status,xmlhttp){alert("Failed to load json data from "+url+"\n"+statusText);};var fDone=function(xmlhttp){f(eval('('+xmlhttp.responseText+')'),url);};Timeline.XmlHttp.get(url,fError,fDone);};Timeline._Impl=function(elmt,bandInfos,orientation,unit){this._containerDiv=elmt;this._bandInfos=bandInfos;this._orientation=orientation==null?Timeline.HORIZONTAL:orientation;this._unit=(unit!=null)?unit:Timeline.NativeDateUnit;this._initialize();};Timeline._Impl.prototype.dispose=function(){for(var i=0;i<this._bands.length;i++){this._bands[i].dispose();}
f(xml,url);};Timeline.XmlHttp.get(url,fError,fDone);};Timeline.loadJSON=function(url,f){var fError=function(statusText,status,xmlhttp){alert("Failed to load json data from "+url+"\n"+statusText);};var fDone=function(xmlhttp){throw('break');};Timeline.XmlHttp.get(url,fError,fDone);};Timeline._Impl=function(elmt,bandInfos,orientation,unit){this._containerDiv=elmt;this._bandInfos=bandInfos;this._orientation=orientation==null?Timeline.HORIZONTAL:orientation;this._unit=(unit!=null)?unit:Timeline.NativeDateUnit;this._initialize();};Timeline._Impl.prototype.dispose=function(){for(var i=0;i<this._bands.length;i++){this._bands[i].dispose();}
this._bands=null;this._bandInfos=null;this._containerDiv.innerHTML="";};Timeline._Impl.prototype.getBandCount=function(){return this._bands.length;};Timeline._Impl.prototype.getBand=function(index){return this._bands[index];};Timeline._Impl.prototype.layout=function(){this._distributeWidths();};Timeline._Impl.prototype.paint=function(){for(var i=0;i<this._bands.length;i++){this._bands[i].paint();}};Timeline._Impl.prototype.getDocument=function(){return this._containerDiv.ownerDocument;};Timeline._Impl.prototype.addDiv=function(div){this._containerDiv.appendChild(div);};Timeline._Impl.prototype.removeDiv=function(div){this._containerDiv.removeChild(div);};Timeline._Impl.prototype.isHorizontal=function(){return this._orientation==Timeline.HORIZONTAL;};Timeline._Impl.prototype.isVertical=function(){return this._orientation==Timeline.VERTICAL;};Timeline._Impl.prototype.getPixelLength=function(){return this._orientation==Timeline.HORIZONTAL?this._containerDiv.offsetWidth:this._containerDiv.offsetHeight;};Timeline._Impl.prototype.getPixelWidth=function(){return this._orientation==Timeline.VERTICAL?this._containerDiv.offsetWidth:this._containerDiv.offsetHeight;};Timeline._Impl.prototype.getUnit=function(){return this._unit;};Timeline._Impl.prototype.loadXML=function(url,f){var tl=this;var fError=function(statusText,status,xmlhttp){alert("Failed to load data xml from "+url+"\n"+statusText);tl.hideLoadingMessage();};var fDone=function(xmlhttp){try{var xml=xmlhttp.responseXML;if(!xml.documentElement&&xmlhttp.responseStream){xml.load(xmlhttp.responseStream);}
f(xml,url);}finally{tl.hideLoadingMessage();}};this.showLoadingMessage();window.setTimeout(function(){Timeline.XmlHttp.get(url,fError,fDone);},0);};Timeline._Impl.prototype.loadJSON=function(url,f){var tl=this;var fError=function(statusText,status,xmlhttp){alert("Failed to load json data from "+url+"\n"+statusText);tl.hideLoadingMessage();};var fDone=function(xmlhttp){try{f(eval('('+xmlhttp.responseText+')'),url);}finally{tl.hideLoadingMessage();}};this.showLoadingMessage();window.setTimeout(function(){Timeline.XmlHttp.get(url,fError,fDone);},0);};Timeline._Impl.prototype._initialize=function(){var containerDiv=this._containerDiv;var doc=containerDiv.ownerDocument;containerDiv.className=containerDiv.className.split(" ").concat("timeline-container").join(" ");while(containerDiv.firstChild){containerDiv.removeChild(containerDiv.firstChild);}
f(xml,url);}finally{tl.hideLoadingMessage();}};this.showLoadingMessage();window.setTimeout(function(){Timeline.XmlHttp.get(url,fError,fDone);},0);};Timeline._Impl.prototype.loadJSON=function(url,f){var tl=this;var fError=function(statusText,status,xmlhttp){alert("Failed to load json data from "+url+"\n"+statusText);tl.hideLoadingMessage();};var fDone=function(xmlhttp){try{throw('break2');}finally{tl.hideLoadingMessage();}};this.showLoadingMessage();window.setTimeout(function(){Timeline.XmlHttp.get(url,fError,fDone);},0);};Timeline._Impl.prototype._initialize=function(){var containerDiv=this._containerDiv;var doc=containerDiv.ownerDocument;containerDiv.className=containerDiv.className.split(" ").concat("timeline-container").join(" ");while(containerDiv.firstChild){containerDiv.removeChild(containerDiv.firstChild);}
var elmtCopyright=Timeline.Graphics.createTranslucentImage(doc,Timeline.urlPrefix+(this.isHorizontal()?"images/copyright-vertical.png":"images/copyright.png"));elmtCopyright.className="timeline-copyright";elmtCopyright.title="Timeline (c) SIMILE - http://simile.mit.edu/timeline/";Timeline.DOM.registerEvent(elmtCopyright,"click",function(){window.location="http://simile.mit.edu/timeline/";});containerDiv.appendChild(elmtCopyright);this._bands=[];for(var i=0;i<this._bandInfos.length;i++){var band=new Timeline._Band(this,this._bandInfos[i],i);this._bands.push(band);}
this._distributeWidths();for(var i=0;i<this._bandInfos.length;i++){var bandInfo=this._bandInfos[i];if("syncWith"in bandInfo){this._bands[i].setSyncWithBand(this._bands[bandInfo.syncWith],("highlight"in bandInfo)?bandInfo.highlight:false);}}
var message=Timeline.Graphics.createMessageBubble(doc);message.containerDiv.className="timeline-message-container";containerDiv.appendChild(message.containerDiv);message.contentDiv.className="timeline-message";message.contentDiv.innerHTML="<img src='"+Timeline.urlPrefix+"images/progress-running.gif' /> Loading...";this.showLoadingMessage=function(){message.containerDiv.style.display="block";};this.hideLoadingMessage=function(){message.containerDiv.style.display="none";};};Timeline._Impl.prototype._distributeWidths=function(){var length=this.getPixelLength();var width=this.getPixelWidth();var cumulativeWidth=0;for(var i=0;i<this._bands.length;i++){var band=this._bands[i];var bandInfos=this._bandInfos[i];var widthString=bandInfos.width;var x=widthString.indexOf("%");if(x>0){var percent=parseInt(widthString.substr(0,x));var bandWidth=percent*width/100;}else{var bandWidth=parseInt(widthString);}