From 8e8bd4dc9c495d62fdd889f842365feec95ca02c Mon Sep 17 00:00:00 2001 From: Ben Parr Date: Thu, 2 Aug 2007 21:59:12 +0000 Subject: [PATCH] Timeline Update: - HTML title now contains the name of the library / saved search / collection whose items are being displayed in the timeline - Clearer notes for the changes made to bundle.js, timeline-api.js and timelineControls.js --- chrome/skin/default/zotero/timeline/bundle.js | 32 ++++++++++++++++--- .../default/zotero/timeline/timeline-api.js | 4 +++ .../zotero/timeline/timelineControls.js | 12 +++---- components/zotero-protocol-handler.js | 12 +++++++ 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/chrome/skin/default/zotero/timeline/bundle.js b/chrome/skin/default/zotero/timeline/bundle.js index e7e7cf7f8..b665bed8c 100644 --- a/chrome/skin/default/zotero/timeline/bundle.js +++ b/chrome/skin/default/zotero/timeline/bundle.js @@ -133,12 +133,27 @@ Timeline.Graphics._arrowOffsets.left)+"px";div.style.top=top+"px";}})();doc.body return{containerDiv:containerDiv,contentDiv:contentDiv};};Timeline.Graphics.createAnimation=function(f,from,to,duration){return new Timeline.Graphics._Animation(f,from,to,duration);};Timeline.Graphics._Animation=function(f,from,to,duration){this.f=f;this.from=from;this.to=to;this.current=from;this.duration=duration;this.start=new Date().getTime();this.timePassed=0;};Timeline.Graphics._Animation.prototype.run=function(){var a=this;window.setTimeout(function(){a.step();},100);};Timeline.Graphics._Animation.prototype.step=function(){this.timePassed+=100;var timePassedFraction=this.timePassed/this.duration;var parameterFraction=-Math.cos(timePassedFraction*Math.PI)/2+0.5;var current=parameterFraction*(this.to-this.from)+this.from;try{this.f(current,current-this.current);}catch(e){} this.current=current;if(this.timePassed0){var zone=this._zones[z];var scale2=scale/zone.mag z--;}} return time;};Timeline.HotZoneEther.prototype._getScale=function(){return this._interval/this._pixelsPerInterval;}; -/* labellers.js +/* labellers.js */ +Timeline.GregorianDateLabeller=function(locale,timeZone){this._locale=locale;this._timeZone=timeZone;};Timeline.GregorianDateLabeller.dayNames=[];Timeline.GregorianDateLabeller.labelIntervalFunctions=[]; + + +/* Modified by Ben for Zotero */ +Timeline.GregorianDateLabeller.monthNames = [localeHash["shortName.january"], localeHash["shortName.february"], localeHash["shortName.march"], localeHash["shortName.april"], localeHash["shortName.may"], + localeHash["shortName.june"], localeHash["shortName.july"], localeHash["shortName.august"], localeHash["shortName.september"], localeHash["shortName.october"], localeHash["shortName.november"], localeHash["shortName.december"]]; +Timeline.GregorianDateLabeller.getMonthName=function(month,locale){return Timeline.GregorianDateLabeller.monthNames[month];}; -Timeline.GregorianDateLabeller=function(locale,timeZone){this._locale=locale;this._timeZone=timeZone;};Timeline.GregorianDateLabeller.monthNames = [localeHash["shortName.january"], localeHash["shortName.february"], localeHash["shortName.march"], localeHash["shortName.april"], localeHash["shortName.may"], localeHash["shortName.june"], localeHash["shortName.july"], localeHash["shortName.august"], localeHash["shortName.september"], localeHash["shortName.october"], localeHash["shortName.november"], localeHash["shortName.december"]];Timeline.GregorianDateLabeller.dayNames=[];Timeline.GregorianDateLabeller.labelIntervalFunctions=[];Timeline.GregorianDateLabeller.getMonthName=function(month,locale){return Timeline.GregorianDateLabeller.monthNames[month];};Timeline.GregorianDateLabeller.prototype.labelInterval=function(date,intervalUnit){var f=Timeline.GregorianDateLabeller.labelIntervalFunctions[this._locale];if(f==null){f=Timeline.GregorianDateLabeller.prototype.defaultLabelInterval;} + + +Timeline.GregorianDateLabeller.prototype.labelInterval=function(date,intervalUnit){var f=Timeline.GregorianDateLabeller.labelIntervalFunctions[this._locale];if(f==null){f=Timeline.GregorianDateLabeller.prototype.defaultLabelInterval;} return f.call(this,date,intervalUnit);};Timeline.GregorianDateLabeller.prototype.labelPrecise=function(date){return Timeline.DateTime.removeTimeZoneOffset(date,this._timeZone).toUTCString();};Timeline.GregorianDateLabeller.prototype.defaultLabelInterval=function(date,intervalUnit){var text;var emphasized=false;date=Timeline.DateTime.removeTimeZoneOffset(date,this._timeZone);switch(intervalUnit){case Timeline.DateTime.MILLISECOND:text=date.getUTCMilliseconds();break;case Timeline.DateTime.SECOND:text=date.getUTCSeconds();break;case Timeline.DateTime.MINUTE:var m=date.getUTCMinutes();if(m==0){text=date.getUTCHours()+":00";emphasized=true;}else{text=m;} break;case Timeline.DateTime.HOUR:text=date.getUTCHours()+"hr";break;case Timeline.DateTime.DAY:text=Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(),this._locale)+" "+date.getUTCDate();break;case Timeline.DateTime.WEEK:text=Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(),this._locale)+" "+date.getUTCDate();break;case Timeline.DateTime.MONTH:var m=date.getUTCMonth();if(m!=0){text=Timeline.GregorianDateLabeller.getMonthName(m,this._locale);break;} case Timeline.DateTime.YEAR:case Timeline.DateTime.DECADE:case Timeline.DateTime.CENTURY:case Timeline.DateTime.MILLENNIUM:var y=date.getUTCFullYear();if(y>0){text=date.getUTCFullYear();}else{text=(1-y)+"BC";} diff --git a/chrome/skin/default/zotero/timeline/timeline-api.js b/chrome/skin/default/zotero/timeline/timeline-api.js index c3939a817..91ccf71c4 100644 --- a/chrome/skin/default/zotero/timeline/timeline-api.js +++ b/chrome/skin/default/zotero/timeline/timeline-api.js @@ -81,6 +81,8 @@ Timeline.Platform = new Object(); Modified by Ben for Zotero */ + + // ISO-639 language codes, ISO-3166 country codes (2 characters) var supportedLocales = [ "cs", // Czech @@ -255,6 +257,8 @@ Timeline.Platform = new Object(); Modified by Ben for Zotero */ + + Timeline.Platform.serverLocale = defaultServerLocale; Timeline.Platform.clientLocale = defaultClientLocale; } catch (e) { diff --git a/chrome/skin/default/zotero/timeline/timelineControls.js b/chrome/skin/default/zotero/timeline/timelineControls.js index 938af139e..058bf4d4e 100644 --- a/chrome/skin/default/zotero/timeline/timelineControls.js +++ b/chrome/skin/default/zotero/timeline/timelineControls.js @@ -61,7 +61,7 @@ function wasChanged(current) { } } -function doTheKeyPress(e) +function doKeyPress(e) { clearTimeout(jumpToYearTimer); lastJumpToYearValue = document.getElementById('jumpYear').value; @@ -223,7 +223,7 @@ function setupOtherControls(div, timeline, url) { } } } - + var intervals = (theQueryValue['i']) ? theQueryValue['i'] : defaultQueryValue['i']; if (intervals.length < 3) { intervals += defaultQueryValue['i'].substr(intervals.length); @@ -256,7 +256,7 @@ function setupOtherControls(div, timeline, url) { input.type = "text"; input.size = "15"; input.id = "jumpYear"; - input.onkeypress=doTheKeyPress; + input.onkeypress=doKeyPress; td.appendChild(input); var options = new Array(localeHash["interval.day"], localeHash["interval.month"], localeHash["interval.year"], @@ -326,7 +326,7 @@ function setupOtherControls(div, timeline, url) { } /* - Everything below is from http://simile.mit.edu/timeline/examples/examples.js + Everything below is from http://simile.mit.edu/timeline/examples/examples.js unless noted otherwise */ function centerTimeline(date) { @@ -354,7 +354,7 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) { var input = document.createElement("input"); input.type = "text"; - input.size = "18"; + input.size = "18";//Added by Ben for Zotero Timeline.DOM.registerEvent(input, "keypress", handler); td.appendChild(input); @@ -365,7 +365,7 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) { input.type = "text"; Timeline.DOM.registerEvent(input, "keypress", handler); td.appendChild(input); - input.size = "15"; + input.size = "15";//Added by Ben for Zotero var divColor = document.createElement("div"); divColor.style.height = "0.5em"; divColor.style.background = theme.event.highlightColors[i]; diff --git a/components/zotero-protocol-handler.js b/components/zotero-protocol-handler.js index 0ece0ab6f..a9be82c32 100644 --- a/components/zotero-protocol-handler.js +++ b/components/zotero-protocol-handler.js @@ -325,6 +325,18 @@ function ChromeExtensionHandler() { var c = (theIntervals[intervals[2]]) ? theIntervals[intervals[2]] : 'Timeline.DateTime.DECADE'; content = content.replace(theTemp, theTemp + a + ',' + b + ',' + c + ',\'' + timelineDate + '\''); + theTemp = 'document.write("'; + if(type == 'collection') { + var theCollection = Zotero.Collections.get(id); + content = content.replace(theTemp, theTemp + theCollection.getName() + ' - '); + } + else if(type == 'search') { + var theSearch = Zotero.Searches.get(id); + content = content.replace(theTemp, theTemp + theSearch['name'] + ' - '); + } + else { + content = content.replace(theTemp, theTemp + Zotero.getString('pane.collections.library') + ' - '); + } theTemp = 'Timeline.loadXML("zotero://timeline/data/'; var d = '';