Timeline Update

-Users can now create a timeline from the Zotero items in a saved search or collection if that is what is in the current view.
-Fixed javascript warnings
-Noted changes from original code in bundle.js and timeline-api.js
This commit is contained in:
Ben Parr 2007-08-01 20:36:12 +00:00
parent f503693da9
commit f054f41519
7 changed files with 91 additions and 19 deletions

View File

@ -33,6 +33,7 @@
<script src="overlay.js"/>
<script src="fileInterface.js"/>
<script src="reportInterface.js"/>
<script src="timelineInterface.js"/>
<script src="browser.js"/>
<script src="chrome://global/content/nsDragAndDrop.js"/>
<script src="chrome://global/content/nsTransferable.js"/>
@ -119,7 +120,7 @@
<menuitem id="zotero-tb-actions-import" label="&zotero.toolbar.import.label;" oncommand="Zotero_File_Interface.importFile();"/>
<menuitem id="zotero-tb-actions-export" label="&zotero.toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile();"/>
<menuseparator id="zotero-tb-actions-utilities-separator"/>
<menuitem id="zotero-tb-actions-timeline" label="&zotero.toolbar.timeline.label;" oncommand="window.loadURI('zotero://timeline/')"/>
<menuitem id="zotero-tb-actions-timeline" label="&zotero.toolbar.timeline.label;" oncommand="Zotero_Timeline_Interface.loadTimeline()"/>
<menuseparator id="zotero-tb-actions-separator"/>
<menuitem id="zotero-tb-actions-prefs" label="&zotero.toolbar.preferences.label;"
oncommand="window.openDialog('chrome://zotero/content/preferences/preferences.xul', 'zotero-prefs', 'chrome,titlebar,toolbar,' + Zotero.Prefs.get('browser.preferences.instantApply', true) ? 'dialog=no' : 'modal')"/>

View File

@ -0,0 +1,51 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (c) 2006 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://chnm.gmu.edu
Licensed under the Educational Community License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***** END LICENSE BLOCK *****
*/
var Zotero_Timeline_Interface = new function() {
this.loadTimeline = loadTimeline;
/*
* Load a timeline for the currently selected collection
*/
function loadTimeline() {
var today=Date();
var dateParts=today.toString().split(' ');
today=dateParts[1]+'.'+dateParts[2]+'.'+dateParts[3];
var uri = 'zotero://timeline/mye/' + today + '/date';
var id = ZoteroPane.getSelectedCollection(true);
if (id) {
window.loadURI(uri + '/collection/' + id);
return;
}
var id = ZoteroPane.getSelectedSavedSearch(true);
if (id) {
window.loadURI(uri + '/search/' + id);
return;
}
window.loadURI(uri);
}
}

View File

@ -43,7 +43,7 @@ Zotero.Timeline = new function () {
content += 'title=" ' + (arr.title ? escapeXML(arr.title) : '') + '" ';
content += 'icon="' + item.getImageSrc() + '" ';
content += 'color="black">';
content += 'zotero://select/item/'+arr.itemID;
content += arr.itemID;
content += '</event>\n';
}
}

File diff suppressed because one or more lines are too long

View File

@ -77,6 +77,10 @@ Timeline.Platform = new Object();
"events.css"
];
/*
Modified by Ben for Zotero
*/
// ISO-639 language codes, ISO-3166 country codes (2 characters)
var supportedLocales = [
"cs", // Czech
@ -247,6 +251,10 @@ Timeline.Platform = new Object();
}
}
/*
Modified by Ben for Zotero
*/
Timeline.Platform.serverLocale = defaultServerLocale;
Timeline.Platform.clientLocale = defaultClientLocale;
} catch (e) {

View File

@ -77,7 +77,7 @@
}
Timeline.DurationEventPainter.prototype._showBubble = function(x, y, evt) {
window.location=evt.getDescription();
window.location='zotero://select/item/' + evt.getDescription();
}
document.write("<title>"+localeHash["general.title"]+"</title>");

View File

@ -4,7 +4,11 @@ function getLocaleHash() {
var localeHash = new Object();
var content = getContentsFromURL("chrome://zotero/locale/timeline.properties");
var m;
while(m = /^[\S]+(?=\s*=)/gm.exec(content)) {
while(true) {
m = /^[\S]+(?=\s*=)/gm.exec(content);
if(!m) {
break;
}
localeHash[m] = /=[^\n]+/g.exec(content).toString().replace(/=\s*/,'');;
}
return localeHash;
@ -89,7 +93,7 @@ function checkDate(date) {
}
if(/\D/.test(date)) {
return false;
return;
}
if (bc) {
@ -126,11 +130,11 @@ function changeDateType(url, intervals, values, date, seletedIndex) {
}
function createOption(t, selected) {
option = document.createElement("option");
var option = document.createElement("option");
if (selected) {
option.selected = "true";
}
text = document.createTextNode(t);
var text = document.createTextNode(t);
option.setAttribute("value", t);
option.appendChild(text);
return option;
@ -293,7 +297,7 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) {
td = tr.insertCell(1);
td.innerHTML = localeHash["general.highlight"];
var handler = function (elmt, evt, target) {
var handler = function(elmt, evt, target) {
onKeyPress(timeline, bandIndices, table);
};
@ -302,7 +306,7 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) {
td = tr.insertCell(0);
input = document.createElement("input");
var input = document.createElement("input");
input.type = "text";
input.size = "18";
Timeline.DOM.registerEvent(input, "keypress", handler);
@ -323,9 +327,9 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) {
}
td = tr.insertCell(tr.cells.length);
button = document.createElement("button");
var button = document.createElement("button");
button.innerHTML = localeHash["general.clearAll"];
Timeline.DOM.registerEvent(button, "click", function () {
Timeline.DOM.registerEvent(button, "click", function() {
clearAll(timeline, bandIndices, table);
});
td.appendChild(button);
@ -338,12 +342,12 @@ function onKeyPress(timeline, bandIndices, table) {
if (timerID != null) {
window.clearTimeout(timerID);
}
timerID = window.setTimeout(function () {
timerID = window.setTimeout(function() {
performFiltering(timeline, bandIndices, table);
}, 300);
}
function cleanString(s) {
return s.replace(/^\s + /, '').replace(/\s + $/, '');
return s.replace(/^\s+/, '').replace(/\s + $/, '');
}
function performFiltering(timeline, bandIndices, table) {
timerID = null;
@ -354,7 +358,7 @@ function performFiltering(timeline, bandIndices, table) {
var filterMatcher = null;
if (text.length > 0) {
var regex = new RegExp(text, "i");
filterMatcher = function (evt) {
filterMatcher = function(evt) {
return regex.test(evt.getText()) || regex.test(evt.getDescription());
};
}
@ -371,7 +375,7 @@ function performFiltering(timeline, bandIndices, table) {
regexes.push(null);
}
}
var highlightMatcher = hasHighlights ? function (evt) {
var highlightMatcher = hasHighlights ? function(evt) {
var text = evt.getText();
var description = evt.getDescription();
for (var x = 0; x < regexes.length; x++) {
@ -380,7 +384,7 @@ function performFiltering(timeline, bandIndices, table) {
return x;
}
}
return - 1;
return -1;
} : null;
for (var i = 0; i < bandIndices.length; i++) {