Sorry, it was now or never, and now is better:

Changed "Scholar" to "Zotero", everywhere

Apologies to anyone with working copy changes, but there are probably the fewer at this moment than there will be again.

Hopefully this won't break anything, though existing prefs will be lost. I avoided scholar.google.com--if you know any other legitimate "scholar"s in the code, be sure to fix them once I'm done here.

This is a multi-commit change--there's at least one more coming. *Do not update to this version! It won't work!*
This commit is contained in:
Dan Stillman 2006-10-02 23:15:27 +00:00
parent ace0d17ccb
commit 1cd51be497
69 changed files with 2872 additions and 2872 deletions

View file

@ -1,8 +1,8 @@
content scholar chrome/chromeFiles/content/scholar/
locale scholar en-US chrome/chromeFiles/locale/en-US/scholar/
skin scholar default chrome/chromeFiles/skin/default/scholar/
content zotero chrome/chromeFiles/content/zotero/
locale zotero en-US chrome/chromeFiles/locale/en-US/zotero/
skin zotero default chrome/chromeFiles/skin/default/zotero/
overlay chrome://browser/content/browser.xul chrome://scholar/content/overlay.xul
overlay chrome://browser/content/browser.xul chrome://scholar/content/ingester/browser.xul
style chrome://browser/content/browser.xul chrome://scholar/skin/scholar.css
style chrome://global/content/customizeToolbar.xul chrome://scholar/skin/scholar.css
overlay chrome://browser/content/browser.xul chrome://zotero/content/overlay.xul
overlay chrome://browser/content/browser.xul chrome://zotero/content/ingester/browser.xul
style chrome://browser/content/browser.xul chrome://zotero/skin/zotero.css
style chrome://global/content/customizeToolbar.xul chrome://zotero/skin/zotero.css

View file

@ -5,12 +5,12 @@
http://chnm.gmu.edu/
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/about.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/about.dtd">
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/about.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/about.dtd">
<dialog
id="scholar-about"
id="zotero-about"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
orient="vertical"
buttons="accept"
@ -32,29 +32,29 @@
<script src="include.js"/>
<vbox id="aboutcontent">
<label id="name" value="&scholar.name;"/>
<label id="version" value="&scholar.version; "/>
<label id="name" value="&zotero.name;"/>
<label id="version" value="&zotero.version; "/>
<script>
document.getElementById('version').value += Scholar.version;
document.getElementById('version').value += Zotero.version;
</script>
<label class="subhead" value="&scholar.createdby;"/>
<label class="subhead" value="&zotero.createdby;"/>
<vbox class="subcontent">
<label class="text-link" href="http://chnm.gmu.edu" value="Center for History and New Media"/>
<label value="George Mason University"/>
<label value="Fairfax, VA"/>
</vbox>
<label class="subhead" value="&scholar.directors;"/>
<label class="subhead" value="&zotero.directors;"/>
<vbox class="subcontent">
<label value="Dan Cohen"/>
<label value="Josh Greenberg"/>
</vbox>
<label class="subhead" value="&scholar.developers;"/>
<label class="subhead" value="&zotero.developers;"/>
<vbox class="subcontent">
<label value="Dan Stillman"/>
<label value="David Norton"/>
<label value="Simon Kornblith"/>
</vbox>
<label class="subhead" value="&scholar.thanks;"/>
<label class="subhead" value="&zotero.thanks;"/>
<vbox class="subcontent">
<label class="text-link" href="http://www.imls.gov/" value="Institute of Museum and Library Services"/>
<label class="text-link" href="http://www.mozilla.org/" value="Mozilla Foundation"/>

View file

@ -4,7 +4,7 @@
http://chnm.gmu.edu/
*/
var Scholar_Citation_Dialog = new function () {
var Zotero_Citation_Dialog = new function () {
var _itemLocators = new Object();
var _itemLocatorTypes = new Object();
var _multipleSourcesOn = false;
@ -19,7 +19,7 @@ var Scholar_Citation_Dialog = new function () {
this.accept = accept;
function load() {
document.getElementById("multiple-sources-button").label = Scholar.getString("citation.multipleSources");
document.getElementById("multiple-sources-button").label = Zotero.getString("citation.multipleSources");
// load (from selectItemsDialog.js)
doLoad();
@ -29,13 +29,13 @@ var Scholar_Citation_Dialog = new function () {
if(_multipleSourcesOn) {
document.getElementById("multiple-sources").hidden = true;
document.getElementById("add-citation-dialog").width = "600";
document.getElementById("multiple-sources-button").label = Scholar.getString("citation.multipleSources");
document.getElementById("multiple-sources-button").label = Zotero.getString("citation.multipleSources");
window.sizeToContent();
window.moveTo((window.screenX+75), window.screenY);
} else {
document.getElementById("multiple-sources").hidden = undefined;
document.getElementById("add-citation-dialog").width = "750";
document.getElementById("multiple-sources-button").label = Scholar.getString("citation.singleSource");
document.getElementById("multiple-sources-button").label = Zotero.getString("citation.singleSource");
window.sizeToContent();
window.moveTo((window.screenX-75), window.screenY);
}
@ -87,7 +87,7 @@ var Scholar_Citation_Dialog = new function () {
itemNode.setAttribute("value", itemID);
itemNode.setAttribute("label", item.getField("title"));
itemNode.setAttribute("class", "listitem-iconic");
itemNode.setAttribute("image", "chrome://scholar/skin/treeitem-"+Scholar.ItemTypes.getName(item.getType())+".png");
itemNode.setAttribute("image", "chrome://zotero/skin/treeitem-"+Zotero.ItemTypes.getName(item.getType())+".png");
document.getElementById("citation-list").appendChild(itemNode);
// don't let someone select it again

View file

@ -5,19 +5,19 @@
http://chnm.gmu.edu/
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/addCitationDialog.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/addCitationDialog.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="add-citation-dialog"
orient="vertical"
title="Add Citation"
width="600" height="450"
onload="Scholar_Citation_Dialog.load();"
onload="Zotero_Citation_Dialog.load();"
onunload="doUnload();"
ondialogaccept="Scholar_Citation_Dialog.accept();"
ondialogaccept="Zotero_Citation_Dialog.accept();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="padding:2em">
@ -29,7 +29,7 @@
<vbox flex="1">
<hbox align="center" pack="end">
<label value="&toolbar.search.label;" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="250" oncommand="onSearch()" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_scholar_search'); return false; }">
<textbox id="tb-search" type="timed" timeout="250" oncommand="onSearch()" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_zotero_search'); return false; }">
<toolbarbutton id="tb-search-cancel" oncommand="this.parentNode.value='';" hidden="true"/>
</textbox>
</hbox>
@ -50,7 +50,7 @@
<tree id="items-tree"
flex="1" hidecolumnpicker="true" seltype="single"
onselect="Scholar_Citation_Dialog.treeItemSelected();">
onselect="Zotero_Citation_Dialog.treeItemSelected();">
<treecols>
<treecol
id="title" primary="true"
@ -90,12 +90,12 @@
<hbox hidden="true" id="multiple-sources">
<vbox pack="center">
<toolbarbutton id="citation-add" oncommand="Scholar_Citation_Dialog.addCitation()" disabled="true"/>
<toolbarbutton id="citation-delete" oncommand="Scholar_Citation_Dialog.deleteCitation()" disabled="true"/>
<toolbarbutton id="citation-add" oncommand="Zotero_Citation_Dialog.addCitation()" disabled="true"/>
<toolbarbutton id="citation-delete" oncommand="Zotero_Citation_Dialog.deleteCitation()" disabled="true"/>
</vbox>
<vbox>
<listbox id="citation-list" flex="1" seltype="single"
onselect="Scholar_Citation_Dialog.listItemSelected();"></listbox>
onselect="Zotero_Citation_Dialog.listItemSelected();"></listbox>
<hbox>
<menulist id="item-locator-type" disabled="true">
<menupopup id="item-locator-type-popup">
@ -112,7 +112,7 @@
<hbox>
<vbox>
<button id="multiple-sources-button" oncommand="Scholar_Citation_Dialog.toggleMultipleSources()"/>
<button id="multiple-sources-button" oncommand="Zotero_Citation_Dialog.toggleMultipleSources()"/>
</vbox>
<vbox flex="1" align="end">
<hbox>

View file

@ -1,4 +1,4 @@
var Scholar_ItemTypeManager = new function(){
var Zotero_ItemTypeManager = new function(){
this.init = init;
this.handleTypeSelect = handleTypeSelect;
this.buildTypeContextMenu = buildTypeContextMenu;
@ -22,7 +22,7 @@ var Scholar_ItemTypeManager = new function(){
function init(){
// Populate the listbox with item types
_typesList = document.getElementById('item-type-list');
_typeTemplates = document.getElementById('scholar-type-template-menu');
_typeTemplates = document.getElementById('zotero-type-template-menu');
_typeFieldsList = document.getElementById('item-type-fields-list');
_fieldsList = document.getElementById('fields-list');
@ -35,7 +35,7 @@ var Scholar_ItemTypeManager = new function(){
_typesList.selectedIndex = -1;
var types = Scholar.ItemTypes.getTypes();
var types = Zotero.ItemTypes.getTypes();
while (_typesList.getRowCount()){
_typesList.removeItemAt(0);
@ -57,7 +57,7 @@ var Scholar_ItemTypeManager = new function(){
item.setAttribute('label', types[i]['name']);
item.setAttribute('value', types[i]['id']);
item.setAttribute('type', 'checkbox');
item.setAttribute('oncommand', "Scholar_ItemTypeManager.setTemplate(document.popupNode.value, this.value)");
item.setAttribute('oncommand', "Zotero_ItemTypeManager.setTemplate(document.popupNode.value, this.value)");
_typeTemplates.appendChild(item);
}
@ -125,7 +125,7 @@ var Scholar_ItemTypeManager = new function(){
// If currently from a template, clear the template fields
if (currentTemplateItemTypeID){
var sql = "SELECT fieldID FROM itemTypeFields WHERE itemTypeID=?";
var fields = Scholar.DB.columnQuery(sql, currentTemplateItemTypeID);
var fields = Zotero.DB.columnQuery(sql, currentTemplateItemTypeID);
for (var i in fields){
_DBUnmapField(itemTypeID, fields[i]);
@ -136,10 +136,10 @@ var Scholar_ItemTypeManager = new function(){
// Add the new template fields
var sql = "SELECT fieldID FROM itemTypeFields WHERE itemTypeID=? "
+ "ORDER BY orderIndex";
var fields = Scholar.DB.columnQuery(sql, templateItemTypeID);
Scholar.debug('--------');
Scholar.debug(fields);
Scholar.debug('--------');
var fields = Zotero.DB.columnQuery(sql, templateItemTypeID);
Zotero.debug('--------');
Zotero.debug(fields);
Zotero.debug('--------');
for (var i in fields){
_DBMapField(itemTypeID, fields[i]);
}
@ -151,7 +151,7 @@ var Scholar_ItemTypeManager = new function(){
var sql = "UPDATE " + typesTable + " SET templateItemTypeID=? WHERE "
+ "itemTypeID=?";
return Scholar.DB.query(sql, [templateItemTypeID, itemTypeID]);
return Zotero.DB.query(sql, [templateItemTypeID, itemTypeID]);
}
@ -159,7 +159,7 @@ var Scholar_ItemTypeManager = new function(){
var table = itemTypeID>=1000 ? 'userItemTypes' : 'itemTypes';
var sql = "SELECT templateItemTypeID FROM " + table
sql += " WHERE itemTypeID=?";
return Scholar.DB.valueQuery(sql, itemTypeID);
return Zotero.DB.valueQuery(sql, itemTypeID);
}
@ -169,7 +169,7 @@ var Scholar_ItemTypeManager = new function(){
* _item_ is a listitem in the _fieldsList listbox
**/
function addFieldToType(item){
Scholar.debug('Adding field ' + item.value + ' to item type '
Zotero.debug('Adding field ' + item.value + ' to item type '
+ _getCurrentTypeID());
_DBMapField(_getCurrentTypeID(), item.value);
@ -186,7 +186,7 @@ var Scholar_ItemTypeManager = new function(){
* _item_ is a listitem in the _typeFieldsList listbox
**/
function removeFieldFromType(item){
Scholar.debug('Removing field ' + item.value + ' from item type '
Zotero.debug('Removing field ' + item.value + ' from item type '
+ _getCurrentTypeID());
_DBUnmapField(_getCurrentTypeID(), item.value);
@ -204,20 +204,20 @@ var Scholar_ItemTypeManager = new function(){
var typeID = _getCurrentTypeID();
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT fieldID FROM fields WHERE fieldName=?";
var fieldID = Scholar.DB.valueQuery(sql, [listbox.selectedItem.label]);
var fieldID = Zotero.DB.valueQuery(sql, [listbox.selectedItem.label]);
var sql = "SELECT hide FROM itemTypeFields WHERE itemTypeID=? AND "
+ "fieldID=?";
var hidden = Scholar.DB.valueQuery(sql, [typeID, fieldID]);
var hidden = Zotero.DB.valueQuery(sql, [typeID, fieldID]);
var sql = "UPDATE itemTypeFields SET hide=? WHERE itemTypeID=? AND "
+ "fieldID=?";
Scholar.DB.query(sql, [hidden ? null : 1, typeID, fieldID]);
Zotero.DB.query(sql, [hidden ? null : 1, typeID, fieldID]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
listbox.selectedItem.setAttribute('isHidden', !hidden);
@ -280,7 +280,7 @@ var Scholar_ItemTypeManager = new function(){
}
var sql = "INSERT INTO " + table + " (" + nameCol + ") VALUES (?)";
Scholar.DB.query(sql, name);
Zotero.DB.query(sql, name);
init();
@ -303,18 +303,18 @@ var Scholar_ItemTypeManager = new function(){
return true;
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT itemTypeID FROM itemTypes WHERE typeName=?";
var id = Scholar.DB.valueQuery(sql, [type]);
var id = Zotero.DB.valueQuery(sql, [type]);
var sql = "DELETE FROM itemTypeFields WHERE itemTypeID=?";
Scholar.DB.query(sql, [id]);
Zotero.DB.query(sql, [id]);
var sql = "DELETE FROM itemTypes WHERE itemTypeID=?";
Scholar.DB.query(sql, [id]);
Zotero.DB.query(sql, [id]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
this.init();
@ -332,26 +332,26 @@ var Scholar_ItemTypeManager = new function(){
var field = obj.label;
if (!_fieldExists(field)){
Scholar.debug("Field '" + field + "' does not exist", 1);
Zotero.debug("Field '" + field + "' does not exist", 1);
return true;
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT fieldID FROM fields WHERE fieldName=?";
var id = Scholar.DB.valueQuery(sql, [field]);
var id = Zotero.DB.valueQuery(sql, [field]);
var sql = "SELECT itemTypeID FROM itemTypeFields WHERE fieldID=?";
var types = Scholar.DB.columnQuery(sql, [id]);
var types = Zotero.DB.columnQuery(sql, [id]);
for (var i in types){
_DBUnmapField(types[i], id);
}
var sql = "DELETE FROM fields WHERE fieldID=?";
Scholar.DB.query(sql, [id]);
Zotero.DB.query(sql, [id]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
this.init();
@ -361,9 +361,9 @@ var Scholar_ItemTypeManager = new function(){
function createSQLDump(){
var types = Scholar.DB.query("SELECT * FROM itemTypes ORDER BY itemTypeID");
var fields = Scholar.DB.query("SELECT * FROM fields ORDER BY fieldID");
var itemTypeFields = Scholar.DB.query("SELECT * FROM itemTypeFields ORDER BY itemTypeID, orderIndex");
var types = Zotero.DB.query("SELECT * FROM itemTypes ORDER BY itemTypeID");
var fields = Zotero.DB.query("SELECT * FROM fields ORDER BY fieldID");
var itemTypeFields = Zotero.DB.query("SELECT * FROM itemTypeFields ORDER BY itemTypeID, orderIndex");
var prefix = " ";
var sql = '';
@ -411,7 +411,7 @@ var Scholar_ItemTypeManager = new function(){
* Return the field name for a given fieldID
**/
function _getFieldName(fieldID){
return Scholar.DB.valueQuery("SELECT fieldName FROM fields "
return Zotero.DB.valueQuery("SELECT fieldName FROM fields "
+ "WHERE fieldID=" + fieldID);
}
@ -427,7 +427,7 @@ var Scholar_ItemTypeManager = new function(){
+ "(SELECT templateItemTypeID FROM itemTypes WHERE itemTypeID=?1))) "
+ "AS isTemplateField FROM itemTypeFields ITF WHERE itemTypeID=?1 "
+ "ORDER BY orderIndex";
var fields = Scholar.DB.query(sql, itemTypeID);
var fields = Zotero.DB.query(sql, itemTypeID);
// Clear fields box
while (_typeFieldsList.getRowCount()){
@ -448,7 +448,7 @@ var Scholar_ItemTypeManager = new function(){
else {
item.addEventListener('dblclick', new function(){
return function(){
Scholar_ItemTypeManager.removeFieldFromType(this);
Zotero_ItemTypeManager.removeFieldFromType(this);
}
}, true);
}
@ -463,7 +463,7 @@ var Scholar_ItemTypeManager = new function(){
**/
function _populateFieldsList(itemTypeID){
var sql = "SELECT fieldID, fieldName FROM fields ORDER BY fieldName COLLATE NOCASE";
var fields = Scholar.DB.query(sql);
var fields = Zotero.DB.query(sql);
// Clear fields box
while (_fieldsList.getRowCount()){
@ -475,7 +475,7 @@ var Scholar_ItemTypeManager = new function(){
var item = _fieldsList.appendItem(fields[i]['fieldName'], fields[i]['fieldID']);
item.addEventListener('dblclick', new function(){
return function(){
Scholar_ItemTypeManager.addFieldToType(this);
Zotero_ItemTypeManager.addFieldToType(this);
}
}, true);
}
@ -483,13 +483,13 @@ var Scholar_ItemTypeManager = new function(){
var sql = "SELECT fieldID FROM fields WHERE fieldID NOT IN "
+ "(SELECT fieldID FROM itemTypeFields WHERE itemTypeID="
+ itemTypeID + ")";
var unusedFields = Scholar.DB.columnQuery(sql);
var unusedFields = Zotero.DB.columnQuery(sql);
// Remove fields that are already used
for (var i=0; i<_fieldsList.getRowCount(); i++){
// N.B. Some values at the end of list can only be accessed via getAttribute()
// in BonEcho, though .value works for all in Minefield
if (!Scholar.inArray(_fieldsList.getItemAtIndex(i).getAttribute('value'), unusedFields)){
if (!Zotero.inArray(_fieldsList.getItemAtIndex(i).getAttribute('value'), unusedFields)){
_fieldsList.removeItemAt(i);
i--;
}
@ -501,17 +501,17 @@ var Scholar_ItemTypeManager = new function(){
* Map a field to an item type in the DB
*/
function _DBMapField(itemTypeID, fieldID){
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
// Get the next available position
var sql = "SELECT IFNULL(MAX(orderIndex)+1,1) FROM itemTypeFields "
+ "WHERE itemTypeID=?";
var nextIndex = Scholar.DB.valueQuery(sql, itemTypeID);
var nextIndex = Zotero.DB.valueQuery(sql, itemTypeID);
var sql = "INSERT INTO itemTypeFields VALUES (?,?,?,?)";
Scholar.DB.query(sql, [itemTypeID, fieldID, null, nextIndex]);
Zotero.DB.query(sql, [itemTypeID, fieldID, null, nextIndex]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -519,22 +519,22 @@ var Scholar_ItemTypeManager = new function(){
* Unmap a field from an item type in the DB
*/
function _DBUnmapField(itemTypeID, fieldID){
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
// Get the old position
var sql = "SELECT orderIndex FROM itemTypeFields WHERE itemTypeID=? "
+ "AND fieldID=?";
var orderIndex = Scholar.DB.valueQuery(sql, [itemTypeID, fieldID]);
var orderIndex = Zotero.DB.valueQuery(sql, [itemTypeID, fieldID]);
var sql = "DELETE FROM itemTypeFields WHERE itemTypeID=? AND fieldID=?";
Scholar.DB.query(sql, [itemTypeID, fieldID]);
Zotero.DB.query(sql, [itemTypeID, fieldID]);
// Shift other fields down
var sql = "UPDATE itemTypeFields SET orderIndex=orderIndex-1 WHERE "
+ "itemTypeID=? AND orderIndex>?";
Scholar.DB.query(sql, [itemTypeID, orderIndex]);
Zotero.DB.query(sql, [itemTypeID, orderIndex]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -543,28 +543,28 @@ var Scholar_ItemTypeManager = new function(){
return false;
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT orderIndex FROM itemTypeFields WHERE itemTypeID=? "
+ "AND fieldID=?";
var orderIndex = Scholar.DB.valueQuery(sql, [_getCurrentTypeID(), item.value]);
var orderIndex = Zotero.DB.valueQuery(sql, [_getCurrentTypeID(), item.value]);
// Move down field above
var sql = "UPDATE itemTypeFields SET orderIndex=orderIndex+1 WHERE "
+ "itemTypeID=? AND orderIndex=?";
Scholar.DB.query(sql, [_getCurrentTypeID(), orderIndex-1]);
Zotero.DB.query(sql, [_getCurrentTypeID(), orderIndex-1]);
// Move field up
var sql = "UPDATE itemTypeFields SET orderIndex=orderIndex-1 WHERE "
+ "itemTypeID=? AND fieldID=?";
Scholar.DB.query(sql, [_getCurrentTypeID(), item.value]);
Zotero.DB.query(sql, [_getCurrentTypeID(), item.value]);
var index = _typeFieldsList.getIndexOfItem(item);
_typeFieldsList.removeItemAt(index);
var newItem = _typeFieldsList.insertItemAt(index-1, item.label, item.value);
_typeFieldsList.selectItem(newItem);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -573,21 +573,21 @@ var Scholar_ItemTypeManager = new function(){
return false;
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT orderIndex FROM itemTypeFields WHERE itemTypeID=? "
+ "AND fieldID=?";
var orderIndex = Scholar.DB.valueQuery(sql, [_getCurrentTypeID(), item.value]);
var orderIndex = Zotero.DB.valueQuery(sql, [_getCurrentTypeID(), item.value]);
// Move up field below
var sql = "UPDATE itemTypeFields SET orderIndex=orderIndex-1 WHERE "
+ "itemTypeID=? AND orderIndex=?";
Scholar.DB.query(sql, [_getCurrentTypeID(), orderIndex+1]);
Zotero.DB.query(sql, [_getCurrentTypeID(), orderIndex+1]);
// Move field down
var sql = "UPDATE itemTypeFields SET orderIndex=orderIndex+1 WHERE "
+ "itemTypeID=? AND fieldID=?";
Scholar.DB.query(sql, [_getCurrentTypeID(), item.value]);
Zotero.DB.query(sql, [_getCurrentTypeID(), item.value]);
var index = _typeFieldsList.getIndexOfItem(item);
@ -600,18 +600,18 @@ var Scholar_ItemTypeManager = new function(){
}
_typeFieldsList.selectItem(newItem);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
function _typeExists(type){
return !!Scholar.DB.valueQuery("SELECT COUNT(*) FROM itemTypes WHERE "
return !!Zotero.DB.valueQuery("SELECT COUNT(*) FROM itemTypes WHERE "
+ "typeName=?", [type])
}
function _fieldExists(field){
return !!Scholar.DB.valueQuery("SELECT COUNT(*) FROM fields WHERE "
return !!Zotero.DB.valueQuery("SELECT COUNT(*) FROM fields WHERE "
+ "fieldName=?", [field])
}
@ -622,4 +622,4 @@ var Scholar_ItemTypeManager = new function(){
}
}
window.addEventListener('load', Scholar_ItemTypeManager.init, true);
window.addEventListener('load', Zotero_ItemTypeManager.init, true);

View file

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/content/admin/itemTypeManager.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/content/admin/itemTypeManager.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<window
id="item-type-manager"
@ -15,46 +15,46 @@
<popupset>
<popup id="scholar-type-menu"
onpopupshowing="Scholar_ItemTypeManager.buildTypeContextMenu()"
onpopuphidden="Scholar_ItemTypeManager.init()">
<menuitem label="Remove item type" oncommand="Scholar_ItemTypeManager.removeType(document.popupNode)"/>
<popup id="zotero-type-menu"
onpopupshowing="Zotero_ItemTypeManager.buildTypeContextMenu()"
onpopuphidden="Zotero_ItemTypeManager.init()">
<menuitem label="Remove item type" oncommand="Zotero_ItemTypeManager.removeType(document.popupNode)"/>
<menuseparator/>
<menu label="Template">
<menupopup id="scholar-type-template-menu">
<menuitem type="checkbox" label="None" oncommand="Scholar_ItemTypeManager.setTemplate(document.popupNode.value, this.value)"/>
<menupopup id="zotero-type-template-menu">
<menuitem type="checkbox" label="None" oncommand="Zotero_ItemTypeManager.setTemplate(document.popupNode.value, this.value)"/>
<menuseparator/>
</menupopup>
</menu>
</popup>
<popup id="scholar-remove-field-menu">
<menuitem label="Remove field" oncommand="Scholar_ItemTypeManager.removeField(document.popupNode)"/>
<popup id="zotero-remove-field-menu">
<menuitem label="Remove field" oncommand="Zotero_ItemTypeManager.removeField(document.popupNode)"/>
</popup>
</popupset>
<vbox>
<hbox style="height:25em">
<listbox id="item-type-list" seltype="single" context="scholar-type-menu"
onselect="Scholar_ItemTypeManager.handleTypeSelect()">
<listbox id="item-type-list" seltype="single" context="zotero-type-menu"
onselect="Zotero_ItemTypeManager.handleTypeSelect()">
<listhead>
<listheader label="Item Types"/>
</listhead>
</listbox>
<listbox id="item-type-fields-list" onkeypress="Scholar_ItemTypeManager.handleShowHide(this, event)">
<listbox id="item-type-fields-list" onkeypress="Zotero_ItemTypeManager.handleShowHide(this, event)">
<listhead>
<listheader label="Used Fields"/>
</listhead>
</listbox>
<groupbox>
<button label="Move up" oncommand="Scholar_ItemTypeManager.moveSelectedFieldUp()" />
<button label="Move down" oncommand="Scholar_ItemTypeManager.moveSelectedFieldDown()" />
<button label="Move up" oncommand="Zotero_ItemTypeManager.moveSelectedFieldUp()" />
<button label="Move down" oncommand="Zotero_ItemTypeManager.moveSelectedFieldDown()" />
</groupbox>
<listbox id="fields-list" context="scholar-remove-field-menu">
<listbox id="fields-list" context="zotero-remove-field-menu">
<listhead>
<listheader label="Unused Fields"/>
</listhead>
@ -64,12 +64,12 @@
<hbox style="margin:1em 0 0 .2em">
<hbox style="-moz-box-align:baseline">
<label control="add-type" style="width:7em; text-align:right">Add item type:</label>
<textbox id="add-type" onkeypress="return Scholar_ItemTypeManager.handleAddType(this, event)"/>
<textbox id="add-type" onkeypress="return Zotero_ItemTypeManager.handleAddType(this, event)"/>
</hbox>
<hbox style="-moz-box-align:baseline">
<label control="add-field" style="width:7em; text-align:right">Add field:</label>
<textbox id="add-field" onkeypress="return Scholar_ItemTypeManager.handleAddField(this, event)"/>
<textbox id="add-field" onkeypress="return Zotero_ItemTypeManager.handleAddField(this, event)"/>
</hbox>
</hbox>
@ -82,7 +82,7 @@
Light blue fields are hidden. Brown fields are template fields and can only be removed by changing the template.
</description>
<button label="Generate SQL" oncommand="document.getElementById('sql-dump').value=Scholar_ItemTypeManager.createSQLDump()"/>
<button label="Generate SQL" oncommand="document.getElementById('sql-dump').value=Zotero_ItemTypeManager.createSQLDump()"/>
<textbox id="sql-dump" multiline="true" cols="100" rows="6"/>
</vbox>
</window>

View file

@ -1,12 +1,12 @@
//////////////////////////////////////////////////////////////////////////////
//
// Scholar_File_Interface_Bibliography
// Zotero_File_Interface_Bibliography
//
//////////////////////////////////////////////////////////////////////////////
// Class to provide options for bibliography
var Scholar_File_Interface_Bibliography = new function() {
var Zotero_File_Interface_Bibliography = new function() {
var _io;
this.init = init;
@ -21,7 +21,7 @@ var Scholar_File_Interface_Bibliography = new function() {
var listbox = document.getElementById("style-popup");
var styleMenu = document.getElementById("style-menu");
var styles = Scholar.Cite.getStyles();
var styles = Zotero.Cite.getStyles();
// add styles to list
for(i in styles) {
@ -40,7 +40,7 @@ var Scholar_File_Interface_Bibliography = new function() {
styleMenu.selectedIndex = 0;
}
if(Scholar.isMac && document.getElementById("copy-to-clipboard")) {
if(Zotero.isMac && document.getElementById("copy-to-clipboard")) {
document.getElementById("copy-to-clipboard").hidden = "true";
}

View file

@ -1,11 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&bibliography.title;" buttons="cancel,accept"
ondialogaccept="Scholar_File_Interface_Bibliography.acceptSelection()"
id="scholar-bibliography"
onload="Scholar_File_Interface_Bibliography.init()">
ondialogaccept="Zotero_File_Interface_Bibliography.acceptSelection()"
id="zotero-bibliography"
onload="Zotero_File_Interface_Bibliography.init()">
<script src="include.js"/>
<script src="bibliography.js"/>

View file

@ -35,7 +35,7 @@
this.noteRef = val;
if(this.note.getSource())
this.item = Scholar.Items.get(this.note.getSource());
this.item = Zotero.Items.get(this.note.getSource());
this.id('noteField').value = this.note.getNote();
this.id('links').item = this.note;
@ -58,15 +58,15 @@
else //Create new note
{
if(this.item)
var noteID = Scholar.Notes.add(noteField.value,this.item.getID()); //attached to an item
var noteID = Zotero.Notes.add(noteField.value,this.item.getID()); //attached to an item
else
{
//independent note
var noteID = Scholar.Notes.add(noteField.value);
var noteID = Zotero.Notes.add(noteField.value);
if(this.collection)
this.collection.addItem(noteID);
}
this.note = Scholar.Items.get(noteID);
this.note = Zotero.Items.get(noteID);
}
]]>
</body>

View file

@ -28,7 +28,7 @@
var seealso = this.item.getSeeAlso();
if(seealso)
{
seealso = Scholar.Items.get(seealso);
seealso = Zotero.Items.get(seealso);
for(var i = 0; i < seealso.length; i++)
{
r = r + seealso[i].getField('title') + ", ";
@ -54,11 +54,11 @@
if(seealso)
{
seealso = Scholar.Items.get(seealso);
seealso = Zotero.Items.get(seealso);
for(var i = 0; i < seealso.length; i++)
{
var icon= document.createElement("image");
icon.setAttribute('src','chrome://scholar/skin/treeitem-'+Scholar.ItemTypes.getName(seealso[i].getType())+'.png');
icon.setAttribute('src','chrome://zotero/skin/treeitem-'+Zotero.ItemTypes.getName(seealso[i].getType())+'.png');
var label = document.createElement("label");
label.setAttribute('value', seealso[i].getField('title'));
@ -97,7 +97,7 @@
<body>
<![CDATA[
var io = {dataIn: null, dataOut: null};
window.openDialog('chrome://scholar/content/selectItemsDialog.xul','','chrome,modal',io);
window.openDialog('chrome://zotero/content/selectItemsDialog.xul','','chrome,modal',io);
if(io.dataOut && this.item)
{
@ -130,15 +130,15 @@
if(id)
{
var p;
if(window.ScholarPane)
if(window.ZoteroPane)
{
p = window.ScholarPane;
p = window.ZoteroPane;
}
else
{
var win;
if(window.opener && window.opener.ScholarPane)
if(window.opener && window.opener.ZoteroPane)
{
win = window.opener;
}
@ -151,7 +151,7 @@
return;
}
p = win.ScholarPane;
p = win.ZoteroPane;
}
p.selectItem(id);

View file

@ -148,11 +148,11 @@
for(var i in operators)
{
operatorsList.appendItem(Scholar.getString('searchOperator.'+operators[i]),operators[i]);
operatorsList.appendItem(Zotero.getString('searchOperator.'+operators[i]),operators[i]);
}
var conditionsList = this.id('conditionsmenu');
var conditions = Scholar.SearchConditions.getStandardConditions();
var conditions = Zotero.SearchConditions.getStandardConditions();
for(var i=0, len=conditions.length; i<len; i++)
{
@ -174,7 +174,7 @@
this.selectedCondition = conditionsMenu.value;
this.selectedOperator = operatorsList.value;
var condition = Scholar.SearchConditions.get(conditionsMenu.value);
var condition = Zotero.SearchConditions.get(conditionsMenu.value);
var operators = condition['operators'];
// Display appropriate operators for condition
@ -196,13 +196,13 @@
case 'collectionID':
var merged = [];
var cols = Scholar.getCollections(false, true);
var cols = Zotero.getCollections(false, true);
for (var i in cols)
{
merged.push([cols[i].getName(), 'C' + cols[i].getID()]);
}
var searches = Scholar.Searches.getAll();
var searches = Zotero.Searches.getAll();
for (var i in searches)
{
if (searches[i]['id'] != this.parent.search.getID())
@ -215,10 +215,10 @@
return;
case 'itemTypeID':
var types = Scholar.ItemTypes.getTypes();
var types = Zotero.ItemTypes.getTypes();
for (var i in types)
{
types[i][0] = Scholar.getString('itemTypes.' + types[i]['name']);
types[i][0] = Zotero.getString('itemTypes.' + types[i]['name']);
types[i][1] = types[i]['id'];
delete types[i]['name'];
delete types[i]['id'];

View file

@ -5,7 +5,7 @@
http://chnm.gmu.edu/
-->
<!DOCTYPE bindings SYSTEM "chrome://scholar/locale/searchbox.dtd">
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/searchbox.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
@ -146,10 +146,10 @@
<xul:textbox xbl:inherits="flex">
<xul:popupset>
<xul:menupopup id="textbox-fulltext-menu">
<xul:menuitem type="radio" checked="true" label="&scholar.search.textModes.phrase;"/>
<xul:menuitem type="radio" label="&scholar.search.textModes.phraseBinary;"/>
<xul:menuitem type="radio" label="&scholar.search.textModes.regexp;"/>
<xul:menuitem type="radio" label="&scholar.search.textModes.regexpCS;"/>
<xul:menuitem type="radio" checked="true" label="&zotero.search.textModes.phrase;"/>
<xul:menuitem type="radio" label="&zotero.search.textModes.phraseBinary;"/>
<xul:menuitem type="radio" label="&zotero.search.textModes.regexp;"/>
<xul:menuitem type="radio" label="&zotero.search.textModes.regexpCS;"/>
</xul:menupopup>
</xul:popupset>

View file

@ -44,7 +44,7 @@
<method name="reload">
<body>
<![CDATA[
//Scholar.debug('Reloading tags');
//Zotero.debug('Reloading tags');
var rows = this.id('tagRows');
while(rows.hasChildNodes())
@ -75,7 +75,7 @@
<parameter name="tabindex"/>
<body>
<![CDATA[
var id = tag ? Scholar.Tags.getID(tag) : null;
var id = tag ? Zotero.Tags.getID(tag) : null;
tag = tag ? tag : '';
if (!tabindex)
@ -91,11 +91,11 @@
}
var icon= document.createElement("image");
icon.setAttribute('src','chrome://scholar/skin/tag.png');
icon.setAttribute('src','chrome://zotero/skin/tag.png');
// DEBUG: Why won't just this.nextSibling.blur() work?
icon.setAttribute('onclick','if (this.nextSibling.inputField){ this.nextSibling.inputField.blur() }');
var label = ScholarItemPane.createValueElement(tag, 'tag', tabindex);
var label = ZoteroItemPane.createValueElement(tag, 'tag', tabindex);
var remove = document.createElement("label");
remove.setAttribute('value','-');
@ -152,7 +152,7 @@
<![CDATA[
if(oldTagID && newTag)
{
var oldTag = Scholar.Tags.getName(oldTagID);
var oldTag = Zotero.Tags.getName(oldTagID);
if (oldTag!=newTag)
{
return this.item.replaceTag(oldTagID, newTag);
@ -205,7 +205,7 @@
//
// We reset the popup manually if it's showing
if (this.parentNode.getAttribute('showing')=='true'){
//Scholar.debug('Fixing popup');
//Zotero.debug('Fixing popup');
// The target element is 'tagsLabel', so change the
// path if the XUL DOM in the note editor XBL changes
this.parentNode.showPopup(

View file

@ -1,12 +1,12 @@
//////////////////////////////////////////////////////////////////////////////
//
// Scholar_File_Interface_Export
// Zotero_File_Interface_Export
//
//////////////////////////////////////////////////////////////////////////////
// Class to provide options for export
var Scholar_File_Interface_Export = new function() {
var Zotero_File_Interface_Export = new function() {
this.init = init;
this.updateOptions = updateOptions;
this.accept = accept;
@ -36,7 +36,7 @@ var Scholar_File_Interface_Export = new function() {
// presented to the user
// get readable name for option
try {
var optionLabel = Scholar.getString("exportOptions."+option);
var optionLabel = Zotero.getString("exportOptions."+option);
} catch(e) {
var optionLabel = option;
}

View file

@ -1,18 +1,18 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&exportOptions.title;" buttons="cancel,accept"
ondialogaccept="Scholar_File_Interface_Export.accept()"
ondialogcancel="Scholar_File_Interface_Export.cancel()"
id="scholar-export-options"
onload="Scholar_File_Interface_Export.init()">
ondialogaccept="Zotero_File_Interface_Export.accept()"
ondialogcancel="Zotero_File_Interface_Export.cancel()"
id="zotero-export-options"
onload="Zotero_File_Interface_Export.init()">
<script src="include.js"/>
<script src="exportOptions.js"/>
<hbox>
<label value="&exportOptions.format.label;" control="format-menu"/>
<menulist id="format-menu" oncommand="Scholar_File_Interface_Export.updateOptions()">
<menulist id="format-menu" oncommand="Zotero_File_Interface_Export.updateOptions()">
<menupopup id="format-popup">
</menupopup>
</menulist>

View file

@ -1,4 +1,4 @@
var Scholar_File_Interface = new function() {
var Zotero_File_Interface = new function() {
var _unresponsiveScriptPreference, _importCollection, _notifyItem, _notifyCollection;
this.exportFile = exportFile;
@ -9,15 +9,15 @@ var Scholar_File_Interface = new function() {
this.bibliographyFromItems = bibliographyFromItems;
/*
* Creates Scholar.Translate instance and shows file picker for file export
* Creates Zotero.Translate instance and shows file picker for file export
*/
function exportFile(name, items) {
var translation = new Scholar.Translate("export");
var translation = new Zotero.Translate("export");
var translators = translation.getTranslators();
// present options dialog
var io = {translators:translators}
window.openDialog("chrome://scholar/content/exportOptions.xul",
window.openDialog("chrome://zotero/content/exportOptions.xul",
"_blank", "chrome,modal,centerscreen", io);
if(!io.selectedTranslator) {
return false;
@ -27,10 +27,10 @@ var Scholar_File_Interface = new function() {
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Scholar.getString("fileInterface.export"), nsIFilePicker.modeSave);
fp.init(window, Zotero.getString("fileInterface.export"), nsIFilePicker.modeSave);
// set file name and extension
name = (name ? name : Scholar.getString("pane.collections.library"));
name = (name ? name : Zotero.getString("pane.collections.library"));
fp.defaultString = name+"."+io.selectedTranslator.target;
fp.appendFilter(io.selectedTranslator.label, "*."+io.selectedTranslator.target);
@ -43,8 +43,8 @@ var Scholar_File_Interface = new function() {
translation.setTranslator(io.selectedTranslator);
translation.setHandler("done", _exportDone);
_disableUnresponsive();
Scholar_File_Interface.Progress.show(
Scholar.getString("fileInterface.itemsExported"),
Zotero_File_Interface.Progress.show(
Zotero.getString("fileInterface.itemsExported"),
function() {
translation.translate();
});
@ -55,19 +55,19 @@ var Scholar_File_Interface = new function() {
* exports a collection or saved search
*/
function exportCollection() {
var collection = ScholarPane.getSelectedCollection();
var collection = ZoteroPane.getSelectedCollection();
if (collection)
{
exportFile(collection.getName(), Scholar.getItems(collection.getID()));
exportFile(collection.getName(), Zotero.getItems(collection.getID()));
return;
}
var searchRef = ScholarPane.getSelectedSavedSearch();
var searchRef = ZoteroPane.getSelectedSavedSearch();
if (searchRef)
{
var search = new Scholar.Search();
var search = new Zotero.Search();
search.load(searchRef['id']);
exportFile(search.getName(), Scholar.Items.get(search.search()));
exportFile(search.getName(), Zotero.Items.get(search.search()));
return;
}
@ -79,35 +79,35 @@ var Scholar_File_Interface = new function() {
* exports items
*/
function exportItems() {
var items = ScholarPane.getSelectedItems();
var items = ZoteroPane.getSelectedItems();
if(!items || !items.length) throw("no items currently selected");
exportFile(Scholar.getString("fileInterface.exportedItems"), items);
exportFile(Zotero.getString("fileInterface.exportedItems"), items);
}
/*
* closes items exported indicator
*/
function _exportDone(obj, worked) {
Scholar_File_Interface.Progress.close();
Zotero_File_Interface.Progress.close();
_restoreUnresponsive();
if(!worked) {
window.alert(Scholar.getString("fileInterface.exportError"));
window.alert(Zotero.getString("fileInterface.exportError"));
}
}
/*
* Creates Scholar.Translate instance and shows file picker for file import
* Creates Zotero.Translate instance and shows file picker for file import
*/
function importFile() {
var translation = new Scholar.Translate("import");
var translation = new Zotero.Translate("import");
var translators = translation.getTranslators();
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Scholar.getString("fileInterface.import"), nsIFilePicker.modeOpen);
fp.init(window, Zotero.getString("fileInterface.import"), nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll);
for(var i in translators) {
@ -122,7 +122,7 @@ var Scholar_File_Interface = new function() {
if(translators.length) {
// create a new collection to take in imported items
var date = new Date();
_importCollection = Scholar.Collections.add(Scholar.getString("fileInterface.imported")+" "+date.toLocaleString());
_importCollection = Zotero.Collections.add(Zotero.getString("fileInterface.imported")+" "+date.toLocaleString());
// import items
translation.setTranslator(translators[0]);
@ -131,30 +131,30 @@ var Scholar_File_Interface = new function() {
_disableUnresponsive();
// disable notifier
Scholar.Notifier.disable();
Zotero.Notifier.disable();
// show progress indicator
Scholar_File_Interface.Progress.show(
Scholar.getString("fileInterface.itemsImported"),
Zotero_File_Interface.Progress.show(
Zotero.getString("fileInterface.itemsImported"),
function() {
translation.translate();
});
} else {
window.alert(Scholar.getString("fileInterface.fileFormatUnsupported"));
window.alert(Zotero.getString("fileInterface.fileFormatUnsupported"));
}
}
}
/*
* Saves collections after they've been imported. Input item is of the type
* outputted by Scholar.Collection.toArray(); only receives top-level
* outputted by Zotero.Collection.toArray(); only receives top-level
* collections
*/
function _importCollectionDone(obj, collection) {
Scholar.Notifier.enable();
Scholar.Notifier.trigger("add", "collection", collection.getID());
Zotero.Notifier.enable();
Zotero.Notifier.trigger("add", "collection", collection.getID());
collection.changeParent(_importCollection.getID());
Scholar.Notifier.disable();
Zotero.Notifier.disable();
}
/*
@ -167,17 +167,17 @@ var Scholar_File_Interface = new function() {
}
// run notify
Scholar.Notifier.enable();
Zotero.Notifier.enable();
if(obj.newItems.length) {
Scholar.Notifier.trigger("add", "item", obj.newItems);
Scholar.Notifier.trigger("modify", "collection", _importCollection.getID());
Zotero.Notifier.trigger("add", "item", obj.newItems);
Zotero.Notifier.trigger("modify", "collection", _importCollection.getID());
}
Scholar_File_Interface.Progress.close();
Zotero_File_Interface.Progress.close();
_restoreUnresponsive();
if(!worked) {
window.alert(Scholar.getString("fileInterface.importError"));
window.alert(Zotero.getString("fileInterface.importError"));
}
}
@ -205,19 +205,19 @@ var Scholar_File_Interface = new function() {
* Creates a bibliography from a collection or saved search
*/
function bibliographyFromCollection() {
var collection = ScholarPane.getSelectedCollection();
var collection = ZoteroPane.getSelectedCollection();
if (collection)
{
_doBibliographyOptions(collection.getName(), Scholar.getItems(collection.getID()));
_doBibliographyOptions(collection.getName(), Zotero.getItems(collection.getID()));
return;
}
var searchRef = ScholarPane.getSelectedSavedSearch();
var searchRef = ZoteroPane.getSelectedSavedSearch();
if (searchRef)
{
var search = new Scholar.Search();
var search = new Zotero.Search();
search.load(searchRef['id']);
_doBibliographyOptions(search.getName(), Scholar.Items.get(search.search()));
_doBibliographyOptions(search.getName(), Zotero.Items.get(search.search()));
return;
}
@ -228,10 +228,10 @@ var Scholar_File_Interface = new function() {
* Creates a bibliography from a items
*/
function bibliographyFromItems() {
var items = ScholarPane.getSelectedItems();
var items = ZoteroPane.getSelectedItems();
if(!items || !items.length) throw("no items currently selected");
_doBibliographyOptions(Scholar.getString("fileInterface.untitledBibliography"), items);
_doBibliographyOptions(Zotero.getString("fileInterface.untitledBibliography"), items);
}
/*
@ -241,19 +241,19 @@ var Scholar_File_Interface = new function() {
// make sure at least one item is not a standalone note or attachment
var haveNonNote = false;
for(var i in items) {
var type = Scholar.ItemTypes.getName(items[i].getType());
var type = Zotero.ItemTypes.getName(items[i].getType());
if(type != "note" && type != "attachment") {
haveNonNote = true;
break;
}
}
if(!haveNonNote) {
window.alert(Scholar.getString("fileInterface.noReferencesError"));
window.alert(Zotero.getString("fileInterface.noReferencesError"));
return;
}
var io = new Object();
var newDialog = window.openDialog("chrome://scholar/content/bibliography.xul",
var newDialog = window.openDialog("chrome://zotero/content/bibliography.xul",
"_blank","chrome,modal,centerscreen", io);
// determine output format
@ -264,18 +264,18 @@ var Scholar_File_Interface = new function() {
// generate bibliography
try {
var csl = Scholar.Cite.getStyle(io.style);
var csl = Zotero.Cite.getStyle(io.style);
csl.preprocessItems(items);
var bibliography = csl.createBibliography(items, format);
} catch(e) {
window.alert(Scholar.getString("fileInterface.bibliographyGenerationError"));
window.alert(Zotero.getString("fileInterface.bibliographyGenerationError"));
throw(e);
return;
}
if(io.output == "print") {
// printable bibliography, using a hidden browser
var browser = Scholar.Browser.createHiddenBrowser(window);
var browser = Zotero.Browser.createHiddenBrowser(window);
browser.contentDocument.write(bibliography);
// this is kinda nasty, but we have to temporarily modify the user's
@ -301,7 +301,7 @@ var Scholar_File_Interface = new function() {
prefService.setCharPref(prefsToClear[i], oldPrefs[i]);
}
Scholar.Browser.deleteHiddenBrowser(browser);
Zotero.Browser.deleteHiddenBrowser(browser);
} else if(io.output == "save-as-html") {
var fStream = _saveBibliography(name, "HTML");
@ -311,7 +311,7 @@ var Scholar_File_Interface = new function() {
html +='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n';
html +='<head>\n';
html +='<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n';
html +='<title>'+Scholar.getString("fileInterface.bibliographyHTMLTitle")+'</title>\n';
html +='<title>'+Zotero.getString("fileInterface.bibliographyHTMLTitle")+'</title>\n';
html +='</head>\n';
html +='<body>\n';
html += bibliography;
@ -390,7 +390,7 @@ var Scholar_File_Interface = new function() {
}
// Handles the display of a progress indicator
Scholar_File_Interface.Progress = new function() {
Zotero_File_Interface.Progress = new function() {
var _windowLoaded = false;
var _windowLoading = false;
var _progressWindow;
@ -413,7 +413,7 @@ Scholar_File_Interface.Progress = new function() {
_outOf = 0;
_callback = callback;
_progressWindow = window.openDialog("chrome://scholar/chrome/fileProgress.xul", "", "chrome,resizable=no,close=no,dependent,dialog,centerscreen");
_progressWindow = window.openDialog("chrome://zotero/chrome/fileProgress.xul", "", "chrome,resizable=no,close=no,dependent,dialog,centerscreen");
_progressWindow.addEventListener("pageshow", _onWindowLoaded, false);
return true;

View file

@ -1,10 +1,10 @@
<?xml version="1.0" ?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&progress.title;" width="300" height="30"
id="scholar-progress">
id="zotero-progress">
<vbox style="padding:10px">
<hbox align="stretch">
<label id="progress-label" flex="1" />

View file

@ -1,4 +1,4 @@
var Scholar = Components.classes["@chnm.gmu.edu/Zotero;1"]
var Zotero = Components.classes["@chnm.gmu.edu/Zotero;1"]
// Currently uses only nsISupports
//.getService(Components.interfaces.chnmIZoteroService).
.getService(Components.interfaces.nsISupports)

View file

@ -1,20 +1,20 @@
// Scholar for Firefox Ingester Browser Functions
// Zotero for Firefox Ingester Browser Functions
// Based on code taken from Greasemonkey and PiggyBank
// This code is licensed according to the GPL
//////////////////////////////////////////////////////////////////////////////
//
// Scholar_Ingester_Interface
// Zotero_Ingester_Interface
//
//////////////////////////////////////////////////////////////////////////////
// Class to interface with the browser when ingesting data
var Scholar_Ingester_Interface = function() {}
var Zotero_Ingester_Interface = function() {}
//////////////////////////////////////////////////////////////////////////////
//
// Public Scholar_Ingester_Interface methods
// Public Zotero_Ingester_Interface methods
//
//////////////////////////////////////////////////////////////////////////////
@ -22,73 +22,73 @@ var Scholar_Ingester_Interface = function() {}
* Initialize some variables and prepare event listeners for when chrome is done
* loading
*/
Scholar_Ingester_Interface.init = function() {
Scholar_Ingester_Interface.browserData = new Object();
Scholar_Ingester_Interface._scrapePopupShowing = false;
Scholar.Ingester.ProxyMonitor.init();
Scholar.Ingester.MIMEHandler.init();
Scholar.Translate.init();
Zotero_Ingester_Interface.init = function() {
Zotero_Ingester_Interface.browserData = new Object();
Zotero_Ingester_Interface._scrapePopupShowing = false;
Zotero.Ingester.ProxyMonitor.init();
Zotero.Ingester.MIMEHandler.init();
Zotero.Translate.init();
window.addEventListener("load", Scholar_Ingester_Interface.chromeLoad, false);
window.addEventListener("unload", Scholar_Ingester_Interface.chromeUnload, false);
window.addEventListener("load", Zotero_Ingester_Interface.chromeLoad, false);
window.addEventListener("unload", Zotero_Ingester_Interface.chromeUnload, false);
}
/*
* When chrome loads, register our event handlers with the appropriate interfaces
*/
Scholar_Ingester_Interface.chromeLoad = function() {
Scholar_Ingester_Interface.tabBrowser = document.getElementById("content");
Scholar_Ingester_Interface.appContent = document.getElementById("appcontent");
Scholar_Ingester_Interface.statusImage = document.getElementById("scholar-status-image");
Zotero_Ingester_Interface.chromeLoad = function() {
Zotero_Ingester_Interface.tabBrowser = document.getElementById("content");
Zotero_Ingester_Interface.appContent = document.getElementById("appcontent");
Zotero_Ingester_Interface.statusImage = document.getElementById("zotero-status-image");
// this gives us onLocationChange, for updating when tabs are switched/created
Scholar_Ingester_Interface.tabBrowser.addEventListener("TabClose",
Scholar_Ingester_Interface.tabClose, false);
Scholar_Ingester_Interface.tabBrowser.addEventListener("TabSelect",
Scholar_Ingester_Interface.tabSelect, false);
Zotero_Ingester_Interface.tabBrowser.addEventListener("TabClose",
Zotero_Ingester_Interface.tabClose, false);
Zotero_Ingester_Interface.tabBrowser.addEventListener("TabSelect",
Zotero_Ingester_Interface.tabSelect, false);
// this is for pageshow, for updating the status of the book icon
Scholar_Ingester_Interface.appContent.addEventListener("pageshow",
Scholar_Ingester_Interface.contentLoad, true);
Zotero_Ingester_Interface.appContent.addEventListener("pageshow",
Zotero_Ingester_Interface.contentLoad, true);
}
/*
* When chrome unloads, delete our document objects and remove our listeners
*/
Scholar_Ingester_Interface.chromeUnload = function() {
delete Scholar_Ingester_Interface.browserData;
Zotero_Ingester_Interface.chromeUnload = function() {
delete Zotero_Ingester_Interface.browserData;
}
/*
* Scrapes a page (called when the capture icon is clicked); takes a collection
* ID as the argument
*/
Scholar_Ingester_Interface.scrapeThisPage = function(saveLocation) {
var browser = Scholar_Ingester_Interface.tabBrowser.selectedBrowser;
var data = Scholar_Ingester_Interface._getData(browser);
Zotero_Ingester_Interface.scrapeThisPage = function(saveLocation) {
var browser = Zotero_Ingester_Interface.tabBrowser.selectedBrowser;
var data = Zotero_Ingester_Interface._getData(browser);
if(data.translators && data.translators.length) {
Scholar_Ingester_Interface.Progress.show();
Zotero_Ingester_Interface.Progress.show();
if(saveLocation) {
saveLocation = Scholar.Collections.get(saveLocation);
saveLocation = Zotero.Collections.get(saveLocation);
} else { // save to currently selected collection, if a collection is selected
try {
saveLocation = ScholarPane.getSelectedCollection();
saveLocation = ZoteroPane.getSelectedCollection();
} catch(e) {}
}
var translate = new Scholar.Translate("web");
var translate = new Zotero.Translate("web");
translate.setDocument(data.document);
// use first translator available
translate.setTranslator(data.translators[0]);
translate.setHandler("select", Scholar_Ingester_Interface._selectItems);
translate.setHandler("itemDone", function(obj, item) { Scholar_Ingester_Interface._itemDone(obj, item, saveLocation) });
translate.setHandler("done", function(obj, item) { Scholar_Ingester_Interface._finishScraping(obj, item, saveLocation) });
translate.setHandler("select", Zotero_Ingester_Interface._selectItems);
translate.setHandler("itemDone", function(obj, item) { Zotero_Ingester_Interface._itemDone(obj, item, saveLocation) });
translate.setHandler("done", function(obj, item) { Zotero_Ingester_Interface._finishScraping(obj, item, saveLocation) });
translate.translate();
}
}
Scholar_Ingester_Interface.searchFrames = function(rootDoc, searchDoc) {
Zotero_Ingester_Interface.searchFrames = function(rootDoc, searchDoc) {
for each(var frame in rootDoc.frames) {
if(frame.document == searchDoc ||
(frame.document.frames && searchFrames(frame, searchDoc))) {
@ -103,7 +103,7 @@ Scholar_Ingester_Interface.searchFrames = function(rootDoc, searchDoc) {
* An event handler called when a new document is loaded. Creates a new document
* object, and updates the status of the capture icon
*/
Scholar_Ingester_Interface.contentLoad = function(event) {
Zotero_Ingester_Interface.contentLoad = function(event) {
if(event.originalTarget instanceof HTMLDocument) {
var doc = event.originalTarget;
var rootDoc = doc;
@ -115,9 +115,9 @@ Scholar_Ingester_Interface.contentLoad = function(event) {
// Figure out what browser this contentDocument is associated with
var browser;
for(var i=0; i<Scholar_Ingester_Interface.tabBrowser.browsers.length; i++) {
if(rootDoc == Scholar_Ingester_Interface.tabBrowser.browsers[i].contentDocument) {
browser = Scholar_Ingester_Interface.tabBrowser.browsers[i];
for(var i=0; i<Zotero_Ingester_Interface.tabBrowser.browsers.length; i++) {
if(rootDoc == Zotero_Ingester_Interface.tabBrowser.browsers[i].contentDocument) {
browser = Zotero_Ingester_Interface.tabBrowser.browsers[i];
break;
}
}
@ -126,12 +126,12 @@ Scholar_Ingester_Interface.contentLoad = function(event) {
}
// get data object
var data = Scholar_Ingester_Interface._getData(browser);
var data = Zotero_Ingester_Interface._getData(browser);
// if there's already a scrapable page in the browser window, and it's
// still there, ensure it is actually part of the page, then return
if(data.translators && data.translators.length && data.document.location) {
if(Scholar_Ingester_Interface.searchFrames(rootDoc, data.document)) {
if(Zotero_Ingester_Interface.searchFrames(rootDoc, data.document)) {
return;
} else {
data.document = null;
@ -139,12 +139,12 @@ Scholar_Ingester_Interface.contentLoad = function(event) {
}
// get translators
var translate = new Scholar.Translate("web");
var translate = new Zotero.Translate("web");
translate.setDocument(doc);
data.translators = translate.getTranslators();
// update status
if(Scholar_Ingester_Interface.tabBrowser.selectedBrowser == browser) {
Scholar_Ingester_Interface._updateStatus(data);
if(Zotero_Ingester_Interface.tabBrowser.selectedBrowser == browser) {
Zotero_Ingester_Interface._updateStatus(data);
}
// add document
if(data.translators && data.translators.length) {
@ -156,52 +156,52 @@ Scholar_Ingester_Interface.contentLoad = function(event) {
/*
* called when a tab is closed
*/
Scholar_Ingester_Interface.tabClose = function(event) {
Zotero_Ingester_Interface.tabClose = function(event) {
// To execute if document object does not exist
Scholar_Ingester_Interface._deleteData(event.target.linkedBrowser);
Zotero_Ingester_Interface._deleteData(event.target.linkedBrowser);
}
/*
* called when a tab is switched
*/
Scholar_Ingester_Interface.tabSelect = function(event) {
var data = Scholar_Ingester_Interface._getData(Scholar_Ingester_Interface.tabBrowser.selectedBrowser);
Scholar_Ingester_Interface._updateStatus(data);
Zotero_Ingester_Interface.tabSelect = function(event) {
var data = Zotero_Ingester_Interface._getData(Zotero_Ingester_Interface.tabBrowser.selectedBrowser);
Zotero_Ingester_Interface._updateStatus(data);
}
Scholar_Ingester_Interface.hidePopup = function(collectionID) {
Scholar_Ingester_Interface._scrapePopupShowing = false;
Zotero_Ingester_Interface.hidePopup = function(collectionID) {
Zotero_Ingester_Interface._scrapePopupShowing = false;
}
Scholar_Ingester_Interface.showPopup = function(collectionID, parentElement) {
if(Scholar_Ingester_Interface._scrapePopupShowing && parentElement.hasChildNodes()) {
Zotero_Ingester_Interface.showPopup = function(collectionID, parentElement) {
if(Zotero_Ingester_Interface._scrapePopupShowing && parentElement.hasChildNodes()) {
return false; // Don't dynamically reload popups that are already showing
}
Scholar_Ingester_Interface._scrapePopupShowing = true;
Zotero_Ingester_Interface._scrapePopupShowing = true;
parentElement.removeAllItems();
if(collectionID == null) { // show library
var newItem = document.createElement("menuitem");
newItem.setAttribute("label", Scholar.getString("pane.collections.library"));
newItem.setAttribute("class", "menuitem-iconic scholar-scrape-popup-library");
newItem.setAttribute("oncommand", 'Scholar_Ingester_Interface.scrapeThisPage()');
newItem.setAttribute("label", Zotero.getString("pane.collections.library"));
newItem.setAttribute("class", "menuitem-iconic zotero-scrape-popup-library");
newItem.setAttribute("oncommand", 'Zotero_Ingester_Interface.scrapeThisPage()');
parentElement.appendChild(newItem);
}
var childrenList = Scholar.getCollections(collectionID);
var childrenList = Zotero.getCollections(collectionID);
for(var i = 0; i < childrenList.length; i++) {
if(childrenList[i].hasChildCollections()) {
var newItem = document.createElement("menu");
var subMenu = document.createElement("menupopup");
subMenu.setAttribute("onpopupshowing", 'Scholar_Ingester_Interface.showPopup("'+childrenList[i].getID()+'", this)');
newItem.setAttribute("class", "menu-iconic scholar-scrape-popup-collection");
subMenu.setAttribute("onpopupshowing", 'Zotero_Ingester_Interface.showPopup("'+childrenList[i].getID()+'", this)');
newItem.setAttribute("class", "menu-iconic zotero-scrape-popup-collection");
newItem.appendChild(subMenu);
} else {
var newItem = document.createElement("menuitem");
newItem.setAttribute("class", "menuitem-iconic scholar-scrape-popup-collection");
newItem.setAttribute("class", "menuitem-iconic zotero-scrape-popup-collection");
}
newItem.setAttribute("label", childrenList[i].getName());
newItem.setAttribute("oncommand", 'Scholar_Ingester_Interface.scrapeThisPage("'+childrenList[i].getID()+'")');
newItem.setAttribute("oncommand", 'Zotero_Ingester_Interface.scrapeThisPage("'+childrenList[i].getID()+'")');
parentElement.appendChild(newItem);
}
@ -211,7 +211,7 @@ Scholar_Ingester_Interface.showPopup = function(collectionID, parentElement) {
//////////////////////////////////////////////////////////////////////////////
//
// Private Scholar_Ingester_Interface methods
// Private Zotero_Ingester_Interface methods
//
//////////////////////////////////////////////////////////////////////////////
@ -225,20 +225,20 @@ Scholar_Ingester_Interface.showPopup = function(collectionID, parentElement) {
*
* Currently, the data object contains only one property: "translators," which
* is an array of translators that should work with the given page as returned
* from Scholar.Translate.getTranslator()
* from Zotero.Translate.getTranslator()
*/
Scholar_Ingester_Interface._getData = function(browser) {
Zotero_Ingester_Interface._getData = function(browser) {
try {
var key = browser.getAttribute("scholar-key");
if(Scholar_Ingester_Interface.browserData[key]) {
return Scholar_Ingester_Interface.browserData[key];
var key = browser.getAttribute("zotero-key");
if(Zotero_Ingester_Interface.browserData[key]) {
return Zotero_Ingester_Interface.browserData[key];
}
} finally {
if(!key) {
var key = (new Date()).getTime();
browser.setAttribute("scholar-key", key);
Scholar_Ingester_Interface.browserData[key] = new Array();
return Scholar_Ingester_Interface.browserData[key];
browser.setAttribute("zotero-key", key);
Zotero_Ingester_Interface.browserData[key] = new Array();
return Zotero_Ingester_Interface.browserData[key];
}
}
return false;
@ -247,11 +247,11 @@ Scholar_Ingester_Interface._getData = function(browser) {
/*
* Deletes the document object associated with a given browser window object
*/
Scholar_Ingester_Interface._deleteData = function(browser) {
Zotero_Ingester_Interface._deleteData = function(browser) {
try {
var key = browser.getAttribute("scholar-key");
if(Scholar_Ingester_Interface.browserData[key]) {
delete Scholar_Ingester_Interface.browserData[key];
var key = browser.getAttribute("zotero-key");
if(Zotero_Ingester_Interface.browserData[key]) {
delete Zotero_Ingester_Interface.browserData[key];
return true;
}
} finally {}
@ -262,48 +262,48 @@ Scholar_Ingester_Interface._deleteData = function(browser) {
* Updates the status of the capture icon to reflect the scrapability or lack
* thereof of the current page
*/
Scholar_Ingester_Interface._updateStatus = function(data) {
Zotero_Ingester_Interface._updateStatus = function(data) {
if(data.translators && data.translators.length) {
var itemType = data.translators[0].itemType;
if(itemType == "multiple") {
// Use folder icon for multiple types, for now
Scholar_Ingester_Interface.statusImage.src = "chrome://scholar/skin/treesource-collection.png";
Zotero_Ingester_Interface.statusImage.src = "chrome://zotero/skin/treesource-collection.png";
} else {
Scholar_Ingester_Interface.statusImage.src = "chrome://scholar/skin/treeitem-"+itemType+".png";
Zotero_Ingester_Interface.statusImage.src = "chrome://zotero/skin/treeitem-"+itemType+".png";
}
Scholar_Ingester_Interface.statusImage.hidden = false;
Zotero_Ingester_Interface.statusImage.hidden = false;
} else {
Scholar_Ingester_Interface.statusImage.hidden = true;
Zotero_Ingester_Interface.statusImage.hidden = true;
}
}
/*
* Callback to be executed when an item has been finished
*/
Scholar_Ingester_Interface._itemDone = function(obj, item, collection) {
Zotero_Ingester_Interface._itemDone = function(obj, item, collection) {
var title = item.getField("title");
var icon = "chrome://scholar/skin/treeitem-"+Scholar.ItemTypes.getName(item.getField("itemTypeID"))+".png"
Scholar_Ingester_Interface.Progress.addLines([title], [icon]);
var icon = "chrome://zotero/skin/treeitem-"+Zotero.ItemTypes.getName(item.getField("itemTypeID"))+".png"
Zotero_Ingester_Interface.Progress.addLines([title], [icon]);
// add item to collection, if one was specified
if(collection) {
Scholar.Notifier.disable();
Zotero.Notifier.disable();
collection.addItem(item.getID());
Scholar.Notifier.enable();
Zotero.Notifier.enable();
}
}
/*
* called when a user is supposed to select items
*/
Scholar_Ingester_Interface._selectItems = function(obj, itemList) {
Zotero_Ingester_Interface._selectItems = function(obj, itemList) {
// this is kinda ugly, mozillazine made me do it! honest!
var io = { dataIn:itemList, dataOut:null }
var newDialog = window.openDialog("chrome://scholar/content/ingester/selectitems.xul",
var newDialog = window.openDialog("chrome://zotero/content/ingester/selectitems.xul",
"_blank","chrome,modal,centerscreen,resizable=yes", io);
if(!io.dataOut) { // user selected no items, so kill the progress indicatior
Scholar_Ingester_Interface.Progress.kill();
Zotero_Ingester_Interface.Progress.kill();
}
return io.dataOut;
@ -312,28 +312,28 @@ Scholar_Ingester_Interface._selectItems = function(obj, itemList) {
/*
* Callback to be executed when scraping is complete
*/
Scholar_Ingester_Interface._finishScraping = function(obj, returnValue, collection) {
Zotero_Ingester_Interface._finishScraping = function(obj, returnValue, collection) {
if(!returnValue) {
Scholar_Ingester_Interface.Progress.changeHeadline(Scholar.getString("ingester.scrapeError"));
Scholar_Ingester_Interface.Progress.addDescription(Scholar.getString("ingester.scrapeErrorDescription"));
Zotero_Ingester_Interface.Progress.changeHeadline(Zotero.getString("ingester.scrapeError"));
Zotero_Ingester_Interface.Progress.addDescription(Zotero.getString("ingester.scrapeErrorDescription"));
}
if(collection) {
// notify about modified items
Scholar.Notifier.trigger("modify", "collection", collection.getID());
Zotero.Notifier.trigger("modify", "collection", collection.getID());
}
Scholar_Ingester_Interface.Progress.fade();
Zotero_Ingester_Interface.Progress.fade();
}
//////////////////////////////////////////////////////////////////////////////
//
// Scholar.Ingester.Progress
// Zotero.Ingester.Progress
//
//////////////////////////////////////////////////////////////////////////////
// Handles the display of a div showing progress in scraping
Scholar_Ingester_Interface.Progress = new function() {
Zotero_Ingester_Interface.Progress = new function() {
var _windowLoaded = false;
var _windowLoading = false;
// keep track of all of these things in case they're called before we're
@ -341,7 +341,7 @@ Scholar_Ingester_Interface.Progress = new function() {
var _loadDescription = null;
var _loadLines = new Array();
var _loadIcons = new Array();
var _loadHeadline = Scholar.getString("ingester.scraping");
var _loadHeadline = Zotero.getString("ingester.scraping");
this.show = show;
this.changeHeadline = changeHeadline;
@ -354,7 +354,7 @@ Scholar_Ingester_Interface.Progress = new function() {
if(_windowLoading || _windowLoaded) { // already loading or loaded
return false;
}
_progressWindow = window.openDialog("chrome://scholar/chrome/ingester/progress.xul",
_progressWindow = window.openDialog("chrome://zotero/chrome/ingester/progress.xul",
"", "chrome,dialog=no,titlebar=no,popup=yes");
_progressWindow.addEventListener("load", _onWindowLoaded, false);
_windowLoading = true;
@ -364,7 +364,7 @@ Scholar_Ingester_Interface.Progress = new function() {
function changeHeadline(headline) {
if(_windowLoaded) {
_progressWindow.document.getElementById("scholar-progress-text-headline").value = headline;
_progressWindow.document.getElementById("zotero-progress-text-headline").value = headline;
} else {
_loadHeadline = headline;
}
@ -374,21 +374,21 @@ Scholar_Ingester_Interface.Progress = new function() {
if(_windowLoaded) {
for(i in label) {
var newLabel = _progressWindow.document.createElement("label");
newLabel.setAttribute("class", "scholar-progress-item-label");
newLabel.setAttribute("class", "zotero-progress-item-label");
newLabel.setAttribute("crop", "end");
newLabel.setAttribute("value", label[i]);
var newImage = _progressWindow.document.createElement("image");
newImage.setAttribute("class", "scholar-progress-item-icon");
newImage.setAttribute("class", "zotero-progress-item-icon");
newImage.setAttribute("src", icon[i]);
var newHB = _progressWindow.document.createElement("hbox");
newHB.setAttribute("class", "scholar-progress-item-hbox");
newHB.setAttribute("class", "zotero-progress-item-hbox");
newHB.setAttribute("valign", "center");
newHB.appendChild(newImage);
newHB.appendChild(newLabel);
_progressWindow.document.getElementById("scholar-progress-text-box").appendChild(newHB);
_progressWindow.document.getElementById("zotero-progress-text-box").appendChild(newHB);
}
_move();
@ -401,14 +401,14 @@ Scholar_Ingester_Interface.Progress = new function() {
function addDescription(text) {
if(_windowLoaded) {
var newHB = _progressWindow.document.createElement("hbox");
newHB.setAttribute("class", "scholar-progress-item-hbox");
newHB.setAttribute("class", "zotero-progress-item-hbox");
var newDescription = _progressWindow.document.createElement("description");
newDescription.setAttribute("class", "scholar-progress-description");
newDescription.setAttribute("class", "zotero-progress-description");
var newText = _progressWindow.document.createTextNode(text);
newDescription.appendChild(newText);
newHB.appendChild(newDescription);
_progressWindow.document.getElementById("scholar-progress-text-box").appendChild(newHB);
_progressWindow.document.getElementById("zotero-progress-text-box").appendChild(newHB);
_move();
} else {
@ -446,7 +446,7 @@ Scholar_Ingester_Interface.Progress = new function() {
_loadDescription = null;
_loadLines = new Array();
_loadIcons = new Array();
_loadHeadline = Scholar.getString("ingester.scraping")
_loadHeadline = Zotero.getString("ingester.scraping")
}
function _move() {

View file

@ -1,20 +1,20 @@
<?xml version="1.0"?>
<!-- Note: Contains Firefox-specific overlay -->
<overlay id="scholar-ingester-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<overlay id="zotero-ingester-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="../include.js"/>
<script src="browser.js"/>
<script type="application/x-javascript">
Scholar_Ingester_Interface.init();
Zotero_Ingester_Interface.init();
</script>
<hbox id="urlbar-icons">
<popupset>
<popup id="scholar-scrape-popup" onpopupshowing="Scholar_Ingester_Interface.showPopup(null, this)" onpopuphidden="Scholar_Ingester_Interface.hidePopup(null, this)">
<popup id="zotero-scrape-popup" onpopupshowing="Zotero_Ingester_Interface.showPopup(null, this)" onpopuphidden="Zotero_Ingester_Interface.hidePopup(null, this)">
</popup>
</popupset>
<image src="chrome://scholar/skin/treeitem-book.png" id="scholar-status-image" onclick="Scholar_Ingester_Interface.scrapeThisPage()" position="1" hidden="true" context="scholar-scrape-popup" />
<image src="chrome://zotero/skin/treeitem-book.png" id="zotero-status-image" onclick="Zotero_Ingester_Interface.scrapeThisPage()" position="1" hidden="true" context="zotero-scrape-popup" />
</hbox>
</overlay>

View file

@ -1,18 +1,18 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<window id="scholar-progress-window"
<window id="zotero-progress-window"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
windowtype="alert:alert"
align="start">
<hbox id="scholar-progress-box">
<vbox id="scholar-progress-text-box">
<label id="scholar-progress-text-headline" style="font-weight: bold;" />
<hbox id="zotero-progress-box">
<vbox id="zotero-progress-text-box">
<label id="zotero-progress-text-headline" style="font-weight: bold;" />
</vbox>
</hbox>

View file

@ -1,16 +1,16 @@
//////////////////////////////////////////////////////////////////////////////
//
// Scholar_Ingester_Interface_SelectItems
// Zotero_Ingester_Interface_SelectItems
//
//////////////////////////////////////////////////////////////////////////////
// Class to interface with the browser when ingesting data
var Scholar_Ingester_Interface_SelectItems = function() {}
var Zotero_Ingester_Interface_SelectItems = function() {}
//////////////////////////////////////////////////////////////////////////////
//
// Public Scholar_Ingester_Interface_SelectItems methods
// Public Zotero_Ingester_Interface_SelectItems methods
//
//////////////////////////////////////////////////////////////////////////////
@ -18,10 +18,10 @@ var Scholar_Ingester_Interface_SelectItems = function() {}
* Initialize some variables and prepare event listeners for when chrome is done
* loading
*/
Scholar_Ingester_Interface_SelectItems.init = function() {
Zotero_Ingester_Interface_SelectItems.init = function() {
this.io = window.arguments[0];
this.Scholar_Ingester_Interface = window.arguments[1];
var listbox = document.getElementById("scholar-selectitems-links");
this.Zotero_Ingester_Interface = window.arguments[1];
var listbox = document.getElementById("zotero-selectitems-links");
for(i in this.io.dataIn) { // we could use a tree for this if we wanted to
var itemNode = document.createElement("listitem");
@ -33,8 +33,8 @@ Scholar_Ingester_Interface_SelectItems.init = function() {
}
}
Scholar_Ingester_Interface_SelectItems.acceptSelection = function() {
var listbox = document.getElementById("scholar-selectitems-links");
Zotero_Ingester_Interface_SelectItems.acceptSelection = function() {
var listbox = document.getElementById("zotero-selectitems-links");
var returnObject = false;
this.io.dataOut = new Object();

View file

@ -3,20 +3,20 @@
Borrowed from Linky, originally MPL/GPL/LGPL (now GPL, and modified into oblivion)
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&selectitems.title;" width="400" height="330"
persist="width height screenX screenY"
buttons="cancel,accept"
ondialogaccept="Scholar_Ingester_Interface_SelectItems.acceptSelection()"
id="scholar-selectitems"
onload="Scholar_Ingester_Interface_SelectItems.init()">
ondialogaccept="Zotero_Ingester_Interface_SelectItems.acceptSelection()"
id="zotero-selectitems"
onload="Zotero_Ingester_Interface_SelectItems.init()">
<script src="../include.js"/>
<script src="selectitems.js"/>
<caption label="&selectitems.intro.label;" id="scholar-selectitems-intro"/>
<caption label="&selectitems.intro.label;" id="zotero-selectitems-intro"/>
<box flex="1">
<listbox id="scholar-selectitems-links" flex="1" context="scholarSelectContext"></listbox>
<listbox id="zotero-selectitems-links" flex="1" context="zoteroSelectContext"></listbox>
</box>
</dialog>

View file

@ -1,11 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&integration.docPrefs.title;" buttons="accept"
ondialogaccept="Scholar_File_Interface_Bibliography.acceptSelection()"
id="scholar-bibliography"
onload="Scholar_File_Interface_Bibliography.init()">
ondialogaccept="Zotero_File_Interface_Bibliography.acceptSelection()"
id="zotero-bibliography"
onload="Zotero_File_Interface_Bibliography.init()">
<script src="include.js"/>
<script src="bibliography.js"/>

View file

@ -4,7 +4,7 @@
http://chnm.gmu.edu/
*/
var ScholarItemPane = new function()
var ZoteroItemPane = new function()
{
var _dynamicFields;
var _creatorTypeMenu;
@ -29,11 +29,11 @@ var ScholarItemPane = new function()
var _tabIndexMaxTagsFields = 0;
const _defaultFirstName =
'(' + Scholar.getString('pane.item.defaultFirstName') + ')';
'(' + Zotero.getString('pane.item.defaultFirstName') + ')';
const _defaultLastName =
'(' + Scholar.getString('pane.item.defaultLastName') + ')';
'(' + Zotero.getString('pane.item.defaultLastName') + ')';
const _defaultFullName =
'(' + Scholar.getString('pane.item.defaultFullName') + ')';
'(' + Zotero.getString('pane.item.defaultFullName') + ')';
this.onLoad = onLoad;
this.viewItem = viewItem;
@ -60,7 +60,7 @@ var ScholarItemPane = new function()
function onLoad()
{
_tabs = document.getElementById('scholar-view-tabs');
_tabs = document.getElementById('zotero-view-tabs');
// Not in item pane, so skip the introductions
if (!_tabs)
@ -78,21 +78,21 @@ var ScholarItemPane = new function()
_tagsBox = document.getElementById('editpane-tags');
_relatedBox = document.getElementById('editpane-related');
var creatorTypes = Scholar.CreatorTypes.getTypes();
var creatorTypes = Zotero.CreatorTypes.getTypes();
for(var i = 0; i < creatorTypes.length; i++)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label",Scholar.getString('creatorTypes.'+creatorTypes[i]['name']));
menuitem.setAttribute("label",Zotero.getString('creatorTypes.'+creatorTypes[i]['name']));
menuitem.setAttribute("typeid",creatorTypes[i]['id']);
if(creatorTypes[i]['id'] == 0)
menuitem.setAttribute("selected",true);
_creatorTypeMenu.appendChild(menuitem);
}
var itemTypes = Scholar.ItemTypes.getTypes();
var itemTypes = Zotero.ItemTypes.getTypes();
for(var i = 0; i<itemTypes.length; i++)
if(itemTypes[i]['name'] != 'note' && itemTypes[i]['name'] != 'attachment')
_itemTypeMenu.appendItem(Scholar.getString("itemTypes."+itemTypes[i]['name']),itemTypes[i]['id']);
_itemTypeMenu.appendItem(Zotero.getString("itemTypes."+itemTypes[i]['name']),itemTypes[i]['id']);
return true;
}
@ -102,7 +102,7 @@ var ScholarItemPane = new function()
*/
function viewItem(thisItem)
{
//Scholar.debug('Viewing item');
//Zotero.debug('Viewing item');
// Force blur() when clicking off a textbox to another item in middle
// pane, since for some reason it's not being called automatically
@ -136,7 +136,7 @@ var ScholarItemPane = new function()
function loadPane(index)
{
//Scholar.debug('Loading item pane ' + index);
//Zotero.debug('Loading item pane ' + index);
// Clear the tab index when switching panes
if (_lastPane!=index)
@ -175,10 +175,10 @@ var ScholarItemPane = new function()
switch (_itemBeingEdited.getType())
{
// DEBUG: handle descendents of these types as well?
case Scholar.ItemTypes.getID('book'):
case Scholar.ItemTypes.getID('bookSection'):
case Scholar.ItemTypes.getID('journalArticle'):
case Scholar.ItemTypes.getID('thesis'):
case Zotero.ItemTypes.getID('book'):
case Zotero.ItemTypes.getID('bookSection'):
case Zotero.ItemTypes.getID('journalArticle'):
case Zotero.ItemTypes.getID('thesis'):
var openURL = true;
break;
@ -195,9 +195,9 @@ var ScholarItemPane = new function()
_itemTypeMenu.selectedIndex = i;
var fieldNames = new Array("title");
var fields = Scholar.ItemFields.getItemTypeFields(_itemBeingEdited.getField("itemTypeID"));
var fields = Zotero.ItemFields.getItemTypeFields(_itemBeingEdited.getField("itemTypeID"));
for(var i = 0; i<fields.length; i++)
fieldNames.push(Scholar.ItemFields.getName(fields[i]));
fieldNames.push(Zotero.ItemFields.getName(fields[i]));
fieldNames.push("dateAdded","dateModified");
for(var i = 0; i<fieldNames.length; i++)
@ -209,7 +209,7 @@ var ScholarItemPane = new function()
// Convert dates from UTC
if (fieldNames[i]=='dateAdded' || fieldNames[i]=='dateModified'
|| fieldNames[i]=='accessDate'){
var date = Scholar.Date.sqlToDate(val, true);
var date = Zotero.Date.sqlToDate(val, true);
val = date ? date.toLocaleString() : '';
}
@ -223,7 +223,7 @@ var ScholarItemPane = new function()
_tabIndexMaxInfoFields = Math.max(_tabIndexMaxInfoFields, tabindex);
var label = document.createElement("label");
label.setAttribute("value",Scholar.getString("itemFields."+fieldNames[i])+":");
label.setAttribute("value",Zotero.getString("itemFields."+fieldNames[i])+":");
label.setAttribute("onclick","this.nextSibling.blur();");
addDynamicRow(label,valueElement);
@ -256,13 +256,13 @@ var ScholarItemPane = new function()
while(_notesList.hasChildNodes())
_notesList.removeChild(_notesList.firstChild);
var notes = Scholar.Items.get(_itemBeingEdited.getNotes());
var notes = Zotero.Items.get(_itemBeingEdited.getNotes());
if(notes.length)
{
for(var i = 0; i < notes.length; i++)
{
var icon = document.createElement('image');
icon.setAttribute('src','chrome://scholar/skin/treeitem-note.png');
icon.setAttribute('src','chrome://zotero/skin/treeitem-note.png');
var label = document.createElement('label');
label.setAttribute('value',_noteToTitle(notes[i].getNote()));
@ -270,7 +270,7 @@ var ScholarItemPane = new function()
label.setAttribute('crop','end');
var box = document.createElement('box');
box.setAttribute('onclick',"ScholarPane.selectItem("+notes[i].getID()+");");
box.setAttribute('onclick',"ZoteroPane.selectItem("+notes[i].getID()+");");
box.setAttribute('class','clicky');
box.appendChild(icon);
box.appendChild(label);
@ -278,7 +278,7 @@ var ScholarItemPane = new function()
var removeButton = document.createElement('label');
removeButton.setAttribute("value","-");
removeButton.setAttribute("class","clicky");
removeButton.setAttribute("onclick","ScholarItemPane.removeNote("+notes[i].getID()+")");
removeButton.setAttribute("onclick","ZoteroItemPane.removeNote("+notes[i].getID()+")");
var row = document.createElement('row');
row.appendChild(box);
@ -297,30 +297,30 @@ var ScholarItemPane = new function()
while(_attachmentsList.hasChildNodes())
_attachmentsList.removeChild(_attachmentsList.firstChild);
var attachments = Scholar.Items.get(_itemBeingEdited.getAttachments());
var attachments = Zotero.Items.get(_itemBeingEdited.getAttachments());
if(attachments.length)
{
for(var i = 0; i < attachments.length; i++)
{
var icon = document.createElement('image');
var linkMode = attachments[i].getAttachmentLinkMode();
if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_FILE)
if(linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_FILE)
{
itemType = "-file";
}
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_FILE)
else if(linkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE)
{
itemType = "-link";
}
else if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
else if(linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
{
itemType = "-snapshot";
}
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_URL)
else if(linkMode == Zotero.Attachments.LINK_MODE_LINKED_URL)
{
itemType = "-web-link";
}
icon.setAttribute('src','chrome://scholar/skin/treeitem-file'+itemType+'.png');
icon.setAttribute('src','chrome://zotero/skin/treeitem-file'+itemType+'.png');
var label = document.createElement('label');
label.setAttribute('value',attachments[i].getField('title'));
@ -328,7 +328,7 @@ var ScholarItemPane = new function()
label.setAttribute('crop','end');
var box = document.createElement('box');
box.setAttribute('onclick',"ScholarPane.selectItem('"+attachments[i].getID()+"')");
box.setAttribute('onclick',"ZoteroPane.selectItem('"+attachments[i].getID()+"')");
box.setAttribute('class','clicky');
box.appendChild(icon);
box.appendChild(label);
@ -336,7 +336,7 @@ var ScholarItemPane = new function()
var removeButton = document.createElement('label');
removeButton.setAttribute("value","-");
removeButton.setAttribute("class","clicky");
removeButton.setAttribute("onclick","ScholarItemPane.removeAttachment("+attachments[i].getID()+")");
removeButton.setAttribute("onclick","ZoteroItemPane.removeAttachment("+attachments[i].getID()+")");
var row = document.createElement('row');
row.appendChild(box);
@ -374,7 +374,7 @@ var ScholarItemPane = new function()
function changeTypeTo(id)
{
if(id != _itemBeingEdited.getType() && confirm(Scholar.getString('pane.item.changeType')))
if(id != _itemBeingEdited.getType() && confirm(Zotero.getString('pane.item.changeType')))
{
_itemBeingEdited.setType(id);
_itemBeingEdited.save();
@ -389,10 +389,10 @@ var ScholarItemPane = new function()
function onOpenURLClick()
{
var url = Scholar.OpenURL.resolve(_itemBeingEdited);
var url = Zotero.OpenURL.resolve(_itemBeingEdited);
if (url)
{
window.loadURI(Scholar.OpenURL.resolve(_itemBeingEdited));
window.loadURI(Zotero.OpenURL.resolve(_itemBeingEdited));
}
}
@ -412,7 +412,7 @@ var ScholarItemPane = new function()
// Disable the "+" button on previous rows
var elems = _dynamicFields.getElementsByAttribute('value', '+');
if (elems.length){
ScholarItemPane.disableButton(elems[elems.length-1]);
ZoteroItemPane.disableButton(elems[elems.length-1]);
}
if (singleField)
@ -435,7 +435,7 @@ var ScholarItemPane = new function()
}
var label = document.createElement("label");
label.setAttribute("value",Scholar.getString('creatorTypes.'+Scholar.CreatorTypes.getName(typeID))+":");
label.setAttribute("value",Zotero.getString('creatorTypes.'+Zotero.CreatorTypes.getName(typeID))+":");
label.setAttribute("popup","creatorTypeMenu");
label.setAttribute("fieldname",'creator-'+_creatorCount+'-typeID');
label.className = 'clicky';
@ -493,7 +493,7 @@ var ScholarItemPane = new function()
}
else {
removeButton.setAttribute("class","clicky");
removeButton.setAttribute("onclick","ScholarItemPane.removeCreator("+_creatorCount+", this.parentNode.parentNode)");
removeButton.setAttribute("onclick","ZoteroItemPane.removeCreator("+_creatorCount+", this.parentNode.parentNode)");
}
hbox.appendChild(removeButton);
@ -539,10 +539,10 @@ var ScholarItemPane = new function()
// Switch to single-field mode
if (singleField)
{
button.setAttribute('image', 'chrome://scholar/skin/textfield-dual.png');
button.setAttribute('image', 'chrome://zotero/skin/textfield-dual.png');
button.setAttribute('tooltiptext', 'Switch to two fields');
lastName.setAttribute('singleField', 'true');
button.setAttribute('onclick', "ScholarItemPane.switchCreatorMode(this.parentNode.parentNode, false)");
button.setAttribute('onclick', "ZoteroItemPane.switchCreatorMode(this.parentNode.parentNode, false)");
// Remove firstname field from tabindex
var tab = parseInt(firstName.getAttribute('tabindex'));
@ -570,10 +570,10 @@ var ScholarItemPane = new function()
// Switch to two-field mode
else
{
button.setAttribute('image', 'chrome://scholar/skin/textfield-single.png');
button.setAttribute('image', 'chrome://zotero/skin/textfield-single.png');
button.setAttribute('tooltiptext', 'Switch to single field');
lastName.setAttribute('singleField', 'false');
button.setAttribute('onclick', "ScholarItemPane.switchCreatorMode(this.parentNode.parentNode, true)");
button.setAttribute('onclick', "ZoteroItemPane.switchCreatorMode(this.parentNode.parentNode, true)");
// Add firstname field to tabindex
var tab = parseInt(lastName.getAttribute('tabindex'));
@ -630,7 +630,7 @@ var ScholarItemPane = new function()
{
button.setAttribute('disabled', false);
button.setAttribute("class","clicky");
button.setAttribute("onclick","ScholarItemPane.disableButton(this); ScholarItemPane.addCreatorRow('','',1,false,true);");
button.setAttribute("onclick","ZoteroItemPane.disableButton(this); ZoteroItemPane.addCreatorRow('','',1,false,true);");
}
function createValueElement(valueText, fieldName, tabindex)
@ -648,7 +648,7 @@ var ScholarItemPane = new function()
{
valueElement.setAttribute('fieldname',fieldName);
valueElement.setAttribute('tabindex', tabindex);
valueElement.setAttribute('onclick', 'ScholarItemPane.showEditor(this)');
valueElement.setAttribute('onclick', 'ZoteroItemPane.showEditor(this)');
valueElement.className = 'clicky';
if (fieldName=='tag')
@ -706,7 +706,7 @@ var ScholarItemPane = new function()
function showEditor(elem)
{
//Scholar.debug('Showing editor');
//Zotero.debug('Showing editor');
var fieldName = elem.getAttribute('fieldname');
var tabindex = elem.getAttribute('tabindex');
@ -721,8 +721,8 @@ var ScholarItemPane = new function()
else if (fieldName=='tag')
{
var tagID = elem.parentNode.getAttribute('id').split('-')[1];
var value = tagID ? Scholar.Tags.getName(tagID) : '';
var itemID = Scholar.getAncestorByTagName(elem, 'tagsbox').item.getID();
var value = tagID ? Zotero.Tags.getName(tagID) : '';
var itemID = Zotero.getAncestorByTagName(elem, 'tagsbox').item.getID();
}
else
{
@ -779,8 +779,8 @@ var ScholarItemPane = new function()
t.select();
t.setAttribute('onblur',"ScholarItemPane.hideEditor(this, true)");
t.setAttribute('onkeypress',"return ScholarItemPane.handleKeyPress(event)");
t.setAttribute('onblur',"ZoteroItemPane.hideEditor(this, true)");
t.setAttribute('onkeypress',"return ZoteroItemPane.handleKeyPress(event)");
_tabDirection = false;
_lastTabIndex = tabindex;
@ -827,10 +827,10 @@ var ScholarItemPane = new function()
function hideEditor(t, saveChanges)
{
//Scholar.debug('Hiding editor');
var textbox = Scholar.getAncestorByTagName(t, 'textbox');
//Zotero.debug('Hiding editor');
var textbox = Zotero.getAncestorByTagName(t, 'textbox');
if (!textbox){
Scholar.debug('Textbox not found in hideEditor');
Zotero.debug('Textbox not found in hideEditor');
return;
}
var fieldName = textbox.getAttribute('fieldname');
@ -883,10 +883,10 @@ var ScholarItemPane = new function()
// Tags
else if (fieldName=='tag')
{
var tagsbox = Scholar.getAncestorByTagName(textbox, 'tagsbox');
var tagsbox = Zotero.getAncestorByTagName(textbox, 'tagsbox');
if (!tagsbox)
{
Scholar.debug('Tagsbox not found', 1);
Zotero.debug('Tagsbox not found', 1);
return;
}
@ -906,7 +906,7 @@ var ScholarItemPane = new function()
// (which causes a delete of the row),
// clear the tab direction so we don't advance
// when the notifier kicks in
var existing = Scholar.Tags.getID(value);
var existing = Zotero.Tags.getID(value);
if (existing && id != existing)
{
_tabDirection = false;
@ -1003,7 +1003,7 @@ var ScholarItemPane = new function()
: label1.value,
firstName: label2.firstChild ? label2.firstChild.nodeValue
: label2.value,
typeID: Scholar.CreatorTypes.getID(type.substr(0, type.length-1).toLowerCase()),
typeID: Zotero.CreatorTypes.getID(type.substr(0, type.length-1).toLowerCase()),
singleField: label1.getAttribute('singleField') == 'true'
}
}
@ -1059,15 +1059,15 @@ var ScholarItemPane = new function()
function removeNote(id)
{
var note = Scholar.Items.get(id);
var note = Zotero.Items.get(id);
if(note)
if(confirm(Scholar.getString('pane.item.notes.delete.confirm')))
if(confirm(Zotero.getString('pane.item.notes.delete.confirm')))
note.erase();
}
function addNote()
{
ScholarPane.openNoteWindow(_itemBeingEdited.getID());
ZoteroPane.openNoteWindow(_itemBeingEdited.getID());
}
function _noteToTitle(text)
@ -1083,7 +1083,7 @@ var ScholarItemPane = new function()
if(t == "")
{
return Scholar.getString('pane.item.notes.untitled');
return Zotero.getString('pane.item.notes.untitled');
}
else
{
@ -1095,32 +1095,32 @@ var ScholarItemPane = new function()
{
var c = _notesList.childNodes.length;
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
_notesLabel.value = Zotero.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
}
function _updateAttachmentCount()
{
var c = _attachmentsList.childNodes.length;
_attachmentsLabel.value = Scholar.getString('pane.item.attachments.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
_attachmentsLabel.value = Zotero.getString('pane.item.attachments.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
}
function removeAttachment(id)
{
var attachment = Scholar.Items.get(id);
var attachment = Zotero.Items.get(id);
if(attachment)
if(confirm(Scholar.getString('pane.item.attachments.delete.confirm')))
if(confirm(Zotero.getString('pane.item.attachments.delete.confirm')))
attachment.erase();
}
function addAttachmentFromDialog(link)
{
ScholarPane.addAttachmentFromDialog(link, _itemBeingEdited.getID());
ZoteroPane.addAttachmentFromDialog(link, _itemBeingEdited.getID());
}
function addAttachmentFromPage(link)
{
ScholarPane.addAttachmentFromPage(link, _itemBeingEdited.getID());
ZoteroPane.addAttachmentFromPage(link, _itemBeingEdited.getID());
}
@ -1143,7 +1143,7 @@ var ScholarItemPane = new function()
switch (tabindex)
{
case 1:
//Scholar.debug('At beginning');
//Zotero.debug('At beginning');
return false;
case _tabIndexMinCreators:
@ -1185,7 +1185,7 @@ var ScholarItemPane = new function()
break;
case _tabIndexMaxInfoFields:
//Scholar.debug('At end');
//Zotero.debug('At end');
return false;
default:
@ -1207,14 +1207,14 @@ var ScholarItemPane = new function()
}
}
Scholar.debug('Looking for tabindex ' + nextIndex, 4);
Zotero.debug('Looking for tabindex ' + nextIndex, 4);
switch (mode)
{
case 'info':
var next = box.getElementsByAttribute('tabindex', nextIndex);
if (!next[0])
{
//Scholar.debug("Next field not found");
//Zotero.debug("Next field not found");
return _focusNextField(mode, box, nextIndex, back);
}
break;
@ -1234,4 +1234,4 @@ var ScholarItemPane = new function()
}
}
addEventListener("load", function(e) { ScholarItemPane.onLoad(e); }, false);
addEventListener("load", function(e) { ZoteroItemPane.onLoad(e); }, false);

View file

@ -4,29 +4,29 @@
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
http://chnm.gmu.edu/
-->
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<overlay
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="itemPane.js"/>
<deck id="scholar-view-item" flex="1" onselect="if (this.selectedIndex!==''){ ScholarItemPane.loadPane(this.selectedIndex) }">
<vbox id="scholar-info" flex="1">
<deck id="zotero-view-item" flex="1" onselect="if (this.selectedIndex!==''){ ZoteroItemPane.loadPane(this.selectedIndex) }">
<vbox id="zotero-info" flex="1">
<popupset>
<popup id="creatorTypeMenu" position="after_start"
oncommand="var otherFields = ScholarItemPane.getCreatorFields(document.popupNode.parentNode);
oncommand="var otherFields = ZoteroItemPane.getCreatorFields(document.popupNode.parentNode);
var typeID = event.explicitOriginalTarget.getAttribute('typeid');
document.popupNode.setAttribute('value',
Scholar.getString('creatorTypes.' + Scholar.CreatorTypes.getName(typeID)) + ':');
ScholarItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1],
Zotero.getString('creatorTypes.' + Zotero.CreatorTypes.getName(typeID)) + ':');
ZoteroItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1],
'typeID', typeID, otherFields)"/>
</popupset>
<hbox align="center">
<button id="tb-go-to-url" label="&toolbar.goToURL.label;" tooltiptext="&toolbar.goToURL.tooltip;" flex="1" oncommand="ScholarItemPane.onGoToURLClick();" disabled="false"/>
<button id="tb-openurl" label="&toolbar.openURL.label;" tooltiptext="&toolbar.openURL.tooltip;" flex="1" oncommand="ScholarItemPane.onOpenURLClick();"/>
<button id="tb-go-to-url" label="&toolbar.goToURL.label;" tooltiptext="&toolbar.goToURL.tooltip;" flex="1" oncommand="ZoteroItemPane.onGoToURLClick();" disabled="false"/>
<button id="tb-openurl" label="&toolbar.openURL.label;" tooltiptext="&toolbar.openURL.tooltip;" flex="1" oncommand="ZoteroItemPane.onOpenURLClick();"/>
</hbox>
<hbox align="center">
<menulist id="editpane-type-menu" oncommand="ScholarItemPane.changeTypeTo(this.value)" flex="1">
<menulist id="editpane-type-menu" oncommand="ZoteroItemPane.changeTypeTo(this.value)" flex="1">
<menupopup/>
</menulist>
</hbox>
@ -41,7 +41,7 @@
<vbox flex="1">
<hbox align="center">
<label id="editpane-notes-label"/>
<button label="&item.add;" oncommand="ScholarItemPane.addNote();"/>
<button label="&item.add;" oncommand="ZoteroItemPane.addNote();"/>
</hbox>
<grid flex="1">
<columns>
@ -56,10 +56,10 @@
<label id="editpane-attachments-label"/>
<button id="tb-item-attachments-add" type="menu" label="&item.add;">
<menupopup>
<menuitem class="menuitem-iconic" id="tb-item-attachments-link" label="&toolbar.attachment.linked;" oncommand="ScholarItemPane.addAttachmentFromDialog(true);"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-file" label="&toolbar.attachment.add;" oncommand="ScholarItemPane.addAttachmentFromDialog();"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-web-link" label="&toolbar.attachment.weblink;" oncommand="ScholarItemPane.addAttachmentFromPage(true);"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-snapshot" label="&toolbar.attachment.snapshot;" oncommand="ScholarItemPane.addAttachmentFromPage();"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-link" label="&toolbar.attachment.linked;" oncommand="ZoteroItemPane.addAttachmentFromDialog(true);"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-file" label="&toolbar.attachment.add;" oncommand="ZoteroItemPane.addAttachmentFromDialog();"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-web-link" label="&toolbar.attachment.weblink;" oncommand="ZoteroItemPane.addAttachmentFromPage(true);"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-snapshot" label="&toolbar.attachment.snapshot;" oncommand="ZoteroItemPane.addAttachmentFromPage();"/>
</menupopup>
</button>
</hbox>

View file

@ -25,7 +25,7 @@ function onLoad()
if(id && id != '' && id != 'undefined')
{
var ref = Scholar.Items.get(id);
var ref = Zotero.Items.get(id);
if(ref.isNote())
{
noteEditor.note = ref;
@ -41,10 +41,10 @@ function onLoad()
{
window.title = "Add Note";
if(collectionID && collectionID != '' && collectionID != 'undefined')
noteEditor.collection = Scholar.Collections.get(collectionID);
noteEditor.collection = Zotero.Collections.get(collectionID);
}
notifierUnregisterID = Scholar.Notifier.registerItemTree(NotifyCallback);
notifierUnregisterID = Zotero.Notifier.registerItemTree(NotifyCallback);
}
function onUnload()
@ -52,7 +52,7 @@ function onUnload()
if(noteEditor && noteEditor.value)
noteEditor.save();
Scholar.Notifier.unregisterItemTree(notifierUnregisterID);
Zotero.Notifier.unregisterItemTree(notifierUnregisterID);
}
var NotifyCallback = {

View file

@ -5,10 +5,10 @@
http://chnm.gmu.edu/
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<window
id="scholar-note-window"
id="zotero-note-window"
orient="vertical"
width="400"
height="250"

View file

@ -7,7 +7,7 @@
/*
* This object contains the various functions for the interface
*/
var ScholarPane = new function()
var ZoteroPane = new function()
{
var collectionsView;
var itemsView;
@ -48,14 +48,14 @@ var ScholarPane = new function()
*/
function onLoad()
{
if(Scholar.Prefs.get("scholarPaneOnTop"))
if(Zotero.Prefs.get("zoteroPaneOnTop"))
{
var oldPane = document.getElementById('scholar-pane');
var oldSplitter = document.getElementById('scholar-splitter');
var oldPane = document.getElementById('zotero-pane');
var oldSplitter = document.getElementById('zotero-splitter');
var appContent = document.getElementById('appcontent');
var newPane = document.createElement('hbox');
newPane.setAttribute('id','scholar-pane');
newPane.setAttribute('id','zotero-pane');
newPane.setAttribute('collapsed',true);
newPane.setAttribute('flex','1');
newPane.height = oldPane.height;
@ -65,44 +65,44 @@ var ScholarPane = new function()
appContent.insertBefore(newPane, document.getElementById('content'));
var newSplitter = document.createElement('splitter');
newSplitter.setAttribute('id','scholar-splitter');
newSplitter.setAttribute('id','zotero-splitter');
newSplitter.setAttribute('collapsed',true);
newSplitter.setAttribute('resizebefore','closest');
newSplitter.setAttribute('resizeafter','closest');
appContent.removeChild(oldSplitter);
appContent.insertBefore(newSplitter, document.getElementById('content'));
document.getElementById('tb-fullscreen').setAttribute('scholartop','true');
document.getElementById('tb-fullscreen').setAttribute('zoterotop','true');
}
//Initialize collections view
collectionsView = new Scholar.CollectionTreeView();
collectionsView = new Zotero.CollectionTreeView();
var collectionsTree = document.getElementById('collections-tree');
collectionsTree.view = collectionsView;
collectionsTree.controllers.appendController(new Scholar.CollectionTreeCommandController(collectionsTree));
collectionsTree.controllers.appendController(new Zotero.CollectionTreeCommandController(collectionsTree));
var itemsTree = document.getElementById('items-tree');
itemsTree.controllers.appendController(new Scholar.ItemTreeCommandController(itemsTree));
itemsTree.controllers.appendController(new Zotero.ItemTreeCommandController(itemsTree));
// Create the New Item (+) menu with each item type
var addMenu = document.getElementById('tb-add').firstChild;
var separator = document.getElementById('tb-add').firstChild.firstChild;
var moreMenu = document.getElementById('tb-add-more');
var itemTypes = Scholar.ItemTypes.getPrimaryTypes();
var itemTypes = Zotero.ItemTypes.getPrimaryTypes();
for(var i = 0; i<itemTypes.length; i++)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
menuitem.setAttribute("label", Zotero.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ZoteroPane.newItem("+itemTypes[i]['id']+")");
addMenu.insertBefore(menuitem, separator);
}
// Create submenu for secondary item types
var itemTypes = Scholar.ItemTypes.getSecondaryTypes();
var itemTypes = Zotero.ItemTypes.getSecondaryTypes();
for(var i = 0; i<itemTypes.length; i++)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
menuitem.setAttribute("label", Zotero.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ZoteroPane.newItem("+itemTypes[i]['id']+")");
moreMenu.appendChild(menuitem);
}
}
@ -118,14 +118,14 @@ var ScholarPane = new function()
}
/*
* Hides/displays the Scholar interface
* Hides/displays the Zotero interface
*/
function toggleDisplay()
{
var visible = document.getElementById('scholar-pane').getAttribute('collapsed') == 'true';
var visible = document.getElementById('zotero-pane').getAttribute('collapsed') == 'true';
document.getElementById('scholar-pane').setAttribute('collapsed',!visible);
document.getElementById('scholar-splitter').setAttribute('collapsed',!visible);
document.getElementById('zotero-pane').setAttribute('collapsed',!visible);
document.getElementById('zotero-splitter').setAttribute('collapsed',!visible);
if(!visible)
{
@ -138,7 +138,7 @@ var ScholarPane = new function()
{
var visible = document.getElementById('content').getAttribute('collapsed') == 'true';
document.getElementById('content').setAttribute('collapsed', !visible);
document.getElementById('scholar-splitter').setAttribute('collapsed', !visible);
document.getElementById('zotero-splitter').setAttribute('collapsed', !visible);
document.getElementById('tb-fullscreen').setAttribute('fullscreenmode', !visible);
}
@ -149,7 +149,7 @@ var ScholarPane = new function()
*/
function newItem(typeID, data)
{
var item = new Scholar.Item(typeID);
var item = new Zotero.Item(typeID);
for (var i in data)
{
@ -161,7 +161,7 @@ var ScholarPane = new function()
itemsView._itemGroup.ref.addItem(item.getID());
//set to Info tab
document.getElementById('scholar-view-item').selectedIndex = 0;
document.getElementById('zotero-view-item').selectedIndex = 0;
return item;
}
@ -171,13 +171,13 @@ var ScholarPane = new function()
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var untitled = Scholar.getString('pane.collections.untitled');
untitled = Scholar.DB.getNextName('collections', 'collectionName',
Scholar.getString('pane.collections.untitled'));
var untitled = Zotero.getString('pane.collections.untitled');
untitled = Zotero.DB.getNextName('collections', 'collectionName',
Zotero.getString('pane.collections.untitled'));
var newName = { value: untitled };
var result = promptService.prompt(window, "",
Scholar.getString('pane.collections.name'), newName, "", {});
Zotero.getString('pane.collections.name'), newName, "", {});
if (!result)
{
@ -189,19 +189,19 @@ var ScholarPane = new function()
newName.value = untitled;
}
Scholar.Collections.add(newName.value);
Zotero.Collections.add(newName.value);
}
function newSearch()
{
var s = new Scholar.Search();
var s = new Zotero.Search();
s.addCondition('title','contains','');
var untitled = Scholar.getString('pane.collections.untitled');
untitled = Scholar.DB.getNextName('savedSearches', 'savedSearchName',
Scholar.getString('pane.collections.untitled'));
var untitled = Zotero.getString('pane.collections.untitled');
untitled = Zotero.DB.getNextName('savedSearches', 'savedSearchName',
Zotero.getString('pane.collections.untitled'));
var io = {dataIn: {search: s, name: untitled}, dataOut: null};
window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io);
window.openDialog('chrome://zotero/content/searchDialog.xul','','chrome,modal',io);
}
function onCollectionSelected()
@ -216,7 +216,7 @@ var ScholarPane = new function()
var itemgroup = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
itemgroup.setSearch('');
itemsView = new Scholar.ItemTreeView(itemgroup);
itemsView = new Zotero.ItemTreeView(itemgroup);
document.getElementById('items-tree').view = itemsView;
document.getElementById('tb-collection-rename').disabled = itemgroup.isLibrary();
itemsView.selection.clearSelection();
@ -236,20 +236,20 @@ var ScholarPane = new function()
if(item.isNote())
{
var noteEditor = document.getElementById('scholar-note-editor');
var noteEditor = document.getElementById('zotero-note-editor');
noteEditor.item = null;
noteEditor.note = item.ref;
document.getElementById('scholar-view-note-button').setAttribute('noteID',item.ref.getID());
document.getElementById('zotero-view-note-button').setAttribute('noteID',item.ref.getID());
if(item.ref.getSource() != null)
document.getElementById('scholar-view-note-button').setAttribute('sourceID',item.ref.getSource());
document.getElementById('zotero-view-note-button').setAttribute('sourceID',item.ref.getSource());
else
document.getElementById('scholar-view-note-button').removeAttribute('sourceID');
document.getElementById('zotero-view-note-button').removeAttribute('sourceID');
document.getElementById('item-pane').selectedIndex = 2;
}
else if(item.isAttachment())
{
// Wrap title to multiple lines if necessary
var label = document.getElementById('scholar-attachment-label');
var label = document.getElementById('zotero-attachment-label');
while (label.hasChildNodes())
{
label.removeChild(label.firstChild);
@ -269,43 +269,43 @@ var ScholarPane = new function()
}
// Metadata for URL's
if (item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_LINKED_URL
|| item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
if (item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_LINKED_URL
|| item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
{
// "View Page"/"View Snapshot" label
if (item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
if (item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
{
var str = Scholar.getString('pane.item.attachments.view.snapshot');
var str = Zotero.getString('pane.item.attachments.view.snapshot');
}
else
{
var str = Scholar.getString('pane.item.attachments.view.link');
var str = Zotero.getString('pane.item.attachments.view.link');
}
document.getElementById('scholar-attachment-show').setAttribute('hidden', true);
document.getElementById('zotero-attachment-show').setAttribute('hidden', true);
// URL
document.getElementById('scholar-attachment-url').setAttribute('value', item.getField('url'));
document.getElementById('scholar-attachment-url').setAttribute('hidden', false);
document.getElementById('zotero-attachment-url').setAttribute('value', item.getField('url'));
document.getElementById('zotero-attachment-url').setAttribute('hidden', false);
// Access date
document.getElementById('scholar-attachment-accessed').setAttribute('value',
Scholar.getString('itemFields.accessDate') + ': '
+ Scholar.Date.sqlToDate(item.getField('accessDate')).toLocaleString());
document.getElementById('scholar-attachment-accessed').setAttribute('hidden', false);
document.getElementById('zotero-attachment-accessed').setAttribute('value',
Zotero.getString('itemFields.accessDate') + ': '
+ Zotero.Date.sqlToDate(item.getField('accessDate')).toLocaleString());
document.getElementById('zotero-attachment-accessed').setAttribute('hidden', false);
}
// Metadata for files
else
{
var str = Scholar.getString('pane.item.attachments.view.file');
document.getElementById('scholar-attachment-show').setAttribute('hidden', false);
document.getElementById('scholar-attachment-url').setAttribute('hidden', true);
document.getElementById('scholar-attachment-accessed').setAttribute('hidden', true);
var str = Zotero.getString('pane.item.attachments.view.file');
document.getElementById('zotero-attachment-show').setAttribute('hidden', false);
document.getElementById('zotero-attachment-url').setAttribute('hidden', true);
document.getElementById('zotero-attachment-accessed').setAttribute('hidden', true);
}
document.getElementById('scholar-attachment-view').setAttribute('label', str);
document.getElementById('zotero-attachment-view').setAttribute('label', str);
var noteEditor = document.getElementById('scholar-attachment-note-editor');
var noteEditor = document.getElementById('zotero-attachment-note-editor');
noteEditor.item = null;
noteEditor.note = item.ref;
@ -313,7 +313,7 @@ var ScholarPane = new function()
}
else
{
ScholarItemPane.viewItem(item.ref);
ZoteroItemPane.viewItem(item.ref);
document.getElementById('item-pane').selectedIndex = 1;
}
}
@ -321,12 +321,12 @@ var ScholarPane = new function()
{
document.getElementById('item-pane').selectedIndex = 0;
var label = document.getElementById('scholar-view-selected-label');
var label = document.getElementById('zotero-view-selected-label');
if(itemsView && itemsView.selection.count)
label.value = Scholar.getString('pane.item.selected.multiple').replace('%1', itemsView.selection.count);
label.value = Zotero.getString('pane.item.selected.multiple').replace('%1', itemsView.selection.count);
else
label.value = Scholar.getString('pane.item.selected.zero');
label.value = Zotero.getString('pane.item.selected.zero');
}
}
@ -371,9 +371,9 @@ var ScholarPane = new function()
if (noPrompt || promptService.confirmCheck(
window,
Scholar.getString('pane.items.delete.title'),
Scholar.getString('pane.items.delete' + (itemsView.selection.count>1 ? '.multiple' : '')),
hasChildren ? Scholar.getString('pane.items.delete.attached') : '',
Zotero.getString('pane.items.delete.title'),
Zotero.getString('pane.items.delete' + (itemsView.selection.count>1 ? '.multiple' : '')),
hasChildren ? Zotero.getString('pane.items.delete.attached') : '',
eraseChildren))
{
itemsView.deleteSelection(eraseChildren.value, force);
@ -390,14 +390,14 @@ var ScholarPane = new function()
if (row.isCollection())
{
if (confirm(Scholar.getString('pane.collections.delete')))
if (confirm(Zotero.getString('pane.collections.delete')))
{
collectionsView.deleteSelection();
}
}
else if (row.isSearch())
{
if (confirm(Scholar.getString('pane.collections.deleteSearch')))
if (confirm(Zotero.getString('pane.collections.deleteSearch')))
{
collectionsView.deleteSelection();
}
@ -418,7 +418,7 @@ var ScholarPane = new function()
var newName = { value: collection.getName() };
var result = promptService.prompt(window, "",
Scholar.getString('pane.collections.rename'), newName, "", {});
Zotero.getString('pane.collections.rename'), newName, "", {});
if (result && newName.value)
{
@ -427,10 +427,10 @@ var ScholarPane = new function()
}
else
{
var s = new Scholar.Search();
var s = new Zotero.Search();
s.load(collection.ref['id']);
var io = {dataIn: {search: s, name: collection.getName()}, dataOut: null};
window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io);
window.openDialog('chrome://zotero/content/searchDialog.xul','','chrome,modal',io);
if(io.dataOut)
onCollectionSelected(); //reload itemsView
}
@ -467,11 +467,11 @@ var ScholarPane = new function()
{
//select the Library if the item is not in the current collection
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
var collectionID = itemsView._itemGroup.ref.getID();
if(!item.isRegularItem())
{
if(!Scholar.Items.get(item.getSource()).inCollection(collectionID))
if(!Zotero.Items.get(item.getSource()).inCollection(collectionID))
collectionsView.selection.select(0);
}
else if(!item.inCollection(collectionID))
@ -522,7 +522,7 @@ var ScholarPane = new function()
function buildCollectionContextMenu()
{
var menu = document.getElementById('scholar-collectionmenu');
var menu = document.getElementById('zotero-collectionmenu');
// Collection
if (collectionsView.selection.count == 1 &&
@ -585,7 +585,7 @@ var ScholarPane = new function()
function buildItemContextMenu()
{
var menu = document.getElementById('scholar-itemmenu');
var menu = document.getElementById('zotero-itemmenu');
if(itemsView && itemsView.selection.count > 0)
{
@ -606,7 +606,7 @@ var ScholarPane = new function()
if (itemsView._itemGroup.isCollection())
{
menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove' + multiple));
menu.childNodes[2].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple));
menu.childNodes[2].setAttribute('hidden', false);
}
else
@ -614,9 +614,9 @@ var ScholarPane = new function()
menu.childNodes[2].setAttribute('hidden', true);
}
menu.childNodes[3].setAttribute('label', Scholar.getString('pane.items.menu.erase' + multiple));
menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.export' + multiple));
menu.childNodes[6].setAttribute('label', Scholar.getString('pane.items.menu.createBib' + multiple));
menu.childNodes[3].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple));
menu.childNodes[5].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple));
menu.childNodes[6].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
}
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
@ -633,7 +633,7 @@ var ScholarPane = new function()
var item = getSelectedItems()[0];
if(item && item.isNote())
{
document.getElementById('scholar-view-note-button').doCommand();
document.getElementById('zotero-view-note-button').doCommand();
}
else if(item && item.isAttachment())
{
@ -647,8 +647,8 @@ var ScholarPane = new function()
{
if (!popup)
{
var item = this.newItem(Scholar.ItemTypes.getID('note'));
document.getElementById('scholar-note-editor').focus();
var item = this.newItem(Zotero.ItemTypes.getID('note'));
document.getElementById('zotero-note-editor').focus();
}
else
{
@ -666,7 +666,7 @@ var ScholarPane = new function()
function openNoteWindow(id, parent)
{
window.open('chrome://scholar/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
window.open('chrome://zotero/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
}
function addAttachmentFromDialog(link, id)
@ -674,15 +674,15 @@ var ScholarPane = new function()
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Scholar.getString('pane.item.attachments.select'), nsIFilePicker.modeOpen);
fp.init(window, Zotero.getString('pane.item.attachments.select'), nsIFilePicker.modeOpen);
if(fp.show() == nsIFilePicker.returnOK)
{
var attachmentID;
if(link)
attachmentID = Scholar.Attachments.linkFromFile(fp.file, id);
attachmentID = Zotero.Attachments.linkFromFile(fp.file, id);
else
attachmentID = Scholar.Attachments.importFromFile(fp.file, id);
attachmentID = Zotero.Attachments.importFromFile(fp.file, id);
if(attachmentID && !id)
{
@ -702,7 +702,7 @@ var ScholarPane = new function()
accessDate: "CURRENT_TIMESTAMP"
}
newItem(Scholar.ItemTypes.getID('webpage'), data);
newItem(Zotero.ItemTypes.getID('webpage'), data);
}
@ -711,12 +711,12 @@ var ScholarPane = new function()
if(link)
{
var attachmentID =
Scholar.Attachments.linkFromDocument(window.content.document, id);
Zotero.Attachments.linkFromDocument(window.content.document, id);
}
else
{
var attachmentID =
Scholar.Attachments.importFromDocument(window.content.document, id);
Zotero.Attachments.importFromDocument(window.content.document, id);
}
if (attachmentID && itemsView && itemsView._itemGroup.isCollection())
@ -732,10 +732,10 @@ var ScholarPane = new function()
{
var attachment = getSelectedItems()[0];
if(attachment.getAttachmentLinkMode() != Scholar.Attachments.LINK_MODE_LINKED_URL)
if(attachment.getAttachmentLinkMode() != Zotero.Attachments.LINK_MODE_LINKED_URL)
{
var file = attachment.getFile();
if (Scholar.MIME.fileHasInternalHandler(file))
if (Zotero.MIME.fileHasInternalHandler(file))
{
window.loadURI(attachment.getLocalFileURL());
}
@ -757,7 +757,7 @@ var ScholarPane = new function()
{
var attachment = getSelectedItems()[0];
if (attachment.getAttachmentLinkMode() != Scholar.Attachments.LINK_MODE_LINKED_URL)
if (attachment.getAttachmentLinkMode() != Zotero.Attachments.LINK_MODE_LINKED_URL)
{
var file = attachment.getFile();
file.reveal();
@ -766,5 +766,5 @@ var ScholarPane = new function()
}
}
window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false);
window.addEventListener("unload", function(e) { ScholarPane.onUnload(e); }, false);
window.addEventListener("load", function(e) { ZoteroPane.onLoad(e); }, false);
window.addEventListener("unload", function(e) { ZoteroPane.onUnload(e); }, false);

View file

@ -4,10 +4,10 @@
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
http://chnm.gmu.edu/
-->
<?xml-stylesheet href="chrome://scholar/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<overlay id="scholar"
<overlay id="zotero"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xul-overlay href="itemPane.xul" ?>
@ -18,65 +18,65 @@
<script src="fileInterface.js"/>
<commandset id="mainCommandSet">
<command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(2);"/>
<command id="cmd_scholar_newCollection" oncommand="ScholarPane.newCollection();"/>
<command id="cmd_scholar_search" oncommand="ScholarPane.search();"/>
<command id="cmd_zotero_newItem" oncommand="ZoteroPane.newItem(2);"/>
<command id="cmd_zotero_newCollection" oncommand="ZoteroPane.newCollection();"/>
<command id="cmd_zotero_search" oncommand="ZoteroPane.search();"/>
</commandset>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="zotero-toolbar-button" class="toolbarbutton-1"
label="&scholar.name;"
oncommand="ScholarPane.toggleDisplay();"/>
label="&zotero.name;"
oncommand="ZoteroPane.toggleDisplay();"/>
</toolbarpalette>
<vbox id="appcontent">
<!-- Changes to attributes of scholar-splitter and scholar-pane must be mirrored on overlay.js's onLoad() function -->
<splitter id="scholar-splitter" resizebefore="closest" resizeafter="closest" collapsed="true"/>
<hbox id="scholar-pane" persist="height" collapsed="true" flex="1">
<!-- Changes to attributes of zotero-splitter and zotero-pane must be mirrored on overlay.js's onLoad() function -->
<splitter id="zotero-splitter" resizebefore="closest" resizeafter="closest" collapsed="true"/>
<hbox id="zotero-pane" persist="height" collapsed="true" flex="1">
<popupset>
<popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();">
<menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
<menuitem label="&toolbar.newSavedSearch.label;" oncommand="ScholarPane.newSearch()"/>
<popup id="zotero-collectionmenu" onpopupshowing="ZoteroPane.buildCollectionContextMenu();">
<menuitem label="&toolbar.newCollection.label;" command="cmd_zotero_newCollection"/>
<menuitem label="&toolbar.newSavedSearch.label;" oncommand="ZoteroPane.newSearch()"/>
<menuseparator/>
<menuitem label="&toolbar.renameCollection.label;" oncommand="ScholarPane.editSelectedCollection();"/>
<menuitem label="&toolbar.renameSavedSearch.label;" oncommand="ScholarPane.editSelectedCollection()"/>
<menuitem label="&toolbar.removeCollection.label;" oncommand="ScholarPane.deleteSelectedCollection();"/>
<menuitem label="&toolbar.removeSavedSearch.label;" oncommand="ScholarPane.deleteSelectedCollection()"/>
<menuitem label="&toolbar.renameCollection.label;" oncommand="ZoteroPane.editSelectedCollection();"/>
<menuitem label="&toolbar.renameSavedSearch.label;" oncommand="ZoteroPane.editSelectedCollection()"/>
<menuitem label="&toolbar.removeCollection.label;" oncommand="ZoteroPane.deleteSelectedCollection();"/>
<menuitem label="&toolbar.removeSavedSearch.label;" oncommand="ZoteroPane.deleteSelectedCollection()"/>
<menuseparator/>
<menuitem label="&toolbar.exportCollection.label;" oncommand="Scholar_File_Interface.exportCollection();"/>
<menuitem label="&toolbar.exportSavedSearch.label;" oncommand="Scholar_File_Interface.exportCollection()"/>
<menuitem label="&toolbar.createBibCollection.label;" oncommand="Scholar_File_Interface.bibliographyFromCollection();"/>
<menuitem label="&toolbar.createBibSavedSearch.label;" oncommand="Scholar_File_Interface.bibliographyFromCollection()"/>
<menuitem label="&toolbar.export.label;" oncommand="Scholar_File_Interface.exportFile()"/>
<menuitem label="&toolbar.exportCollection.label;" oncommand="Zotero_File_Interface.exportCollection();"/>
<menuitem label="&toolbar.exportSavedSearch.label;" oncommand="Zotero_File_Interface.exportCollection()"/>
<menuitem label="&toolbar.createBibCollection.label;" oncommand="Zotero_File_Interface.bibliographyFromCollection();"/>
<menuitem label="&toolbar.createBibSavedSearch.label;" oncommand="Zotero_File_Interface.bibliographyFromCollection()"/>
<menuitem label="&toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile()"/>
</popup>
<popup id="scholar-itemmenu" onpopupshowing="ScholarPane.buildItemContextMenu();">
<menuitem label="&toolbar.newItem.label;" command="cmd_scholar_newItem"/>
<popup id="zotero-itemmenu" onpopupshowing="ZoteroPane.buildItemContextMenu();">
<menuitem label="&toolbar.newItem.label;" command="cmd_zotero_newItem"/>
<menuseparator/>
<menuitem oncommand="ScholarPane.deleteSelectedItem();"/>
<menuitem oncommand="ScholarPane.deleteSelectedItem(true);"/>
<menuitem oncommand="ZoteroPane.deleteSelectedItem();"/>
<menuitem oncommand="ZoteroPane.deleteSelectedItem(true);"/>
<menuseparator/>
<menuitem oncommand="Scholar_File_Interface.exportItems();"/>
<menuitem oncommand="Scholar_File_Interface.bibliographyFromItems();"/>
<menuitem oncommand="Zotero_File_Interface.exportItems();"/>
<menuitem oncommand="Zotero_File_Interface.bibliographyFromItems();"/>
</popup>
</popupset>
<vbox id="collections-pane" persist="width" flex="1">
<toolbar>
<toolbarbutton id="tb-collection-add" tooltiptext="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
<toolbarbutton id="tb-collection-addsearch" tooltiptext="&toolbar.newSavedSearch.label;" oncommand="ScholarPane.newSearch();"/>
<toolbarbutton id="tb-collection-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ScholarPane.editSelectedCollection();" disabled="true"/>
<toolbarbutton id="tb-collection-add" tooltiptext="&toolbar.newCollection.label;" command="cmd_zotero_newCollection"/>
<toolbarbutton id="tb-collection-addsearch" tooltiptext="&toolbar.newSavedSearch.label;" oncommand="ZoteroPane.newSearch();"/>
<toolbarbutton id="tb-collection-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ZoteroPane.editSelectedCollection();" disabled="true"/>
<spacer flex="1"/>
<toolbarbutton id="tb-collection-menu" type="menu">
<menupopup>
<menuitem label="&toolbar.import.label;" oncommand="Scholar_File_Interface.importFile();"/>
<menuitem label="&toolbar.export.label;" oncommand="Scholar_File_Interface.exportFile();"/>
<menuitem label="&toolbar.import.label;" oncommand="Zotero_File_Interface.importFile();"/>
<menuitem label="&toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile();"/>
<menuseparator/>
<menuitem label="&toolbar.preferences.label;" oncommand="window.openDialog('chrome://scholar/content/preferences.xul','prefs','chrome,modal')"/>
<menuitem label="&toolbar.preferences.label;" oncommand="window.openDialog('chrome://zotero/content/preferences.xul','prefs','chrome,modal')"/>
</menupopup>
</toolbarbutton>
</toolbar>
<tree id="collections-tree" hidecolumnpicker="true" context="scholar-collectionmenu"
onselect="ScholarPane.onCollectionSelected();" seltype="single"
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getCollectionsView())"
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarPane.getCollectionsView());"
onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteSelectedCollection(); return false; }"
<tree id="collections-tree" hidecolumnpicker="true" context="zotero-collectionmenu"
onselect="ZoteroPane.onCollectionSelected();" seltype="single"
ondragdrop="nsDragAndDrop.drop(event,ZoteroPane.getCollectionsView())"
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ZoteroPane.getCollectionsView());"
onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ZoteroPane.deleteSelectedCollection(); return false; }"
flex="1">
<treecols>
<treecol
@ -88,41 +88,41 @@
<treechildren/>
</tree>
</vbox>
<splitter id="scholar-tree-splitter" resizebefore="closest" resizeafter="closest"/>
<splitter id="zotero-tree-splitter" resizebefore="closest" resizeafter="closest"/>
<vbox id="items-pane" persist="width" flex="1">
<toolbar align="center">
<toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu">
<!-- New Item drop-down built in overlay.js::onLoad() -->
<menupopup>
<menuseparator/>
<menuitem label="&toolbar.attachment.linked;" oncommand="ScholarPane.addAttachmentFromDialog(true);"/>
<menuitem label="&toolbar.attachment.add;" oncommand="ScholarPane.addAttachmentFromDialog();"/>
<menuitem label="&toolbar.attachment.linked;" oncommand="ZoteroPane.addAttachmentFromDialog(true);"/>
<menuitem label="&toolbar.attachment.add;" oncommand="ZoteroPane.addAttachmentFromDialog();"/>
<menuseparator/>
<menu label="&toolbar.moreItemTypes.label;">
<menupopup id="tb-add-more"/>
</menu>
</menupopup>
</toolbarbutton>
<toolbarbutton id="tb-item-from-page" tooltiptext="&toolbar.newItemFromPage.label;" oncommand="ScholarPane.addItemFromPage()"/>
<toolbarbutton id="tb-item-from-page" tooltiptext="&toolbar.newItemFromPage.label;" oncommand="ZoteroPane.addItemFromPage()"/>
<toolbarseparator/>
<toolbarbutton id="tb-link-page" tooltiptext="&toolbar.attachment.weblink;" oncommand="ScholarPane.addAttachmentFromPage(true)"/>
<toolbarbutton id="tb-snapshot-page" tooltiptext="&toolbar.attachment.snapshot;" oncommand="ScholarPane.addAttachmentFromPage()"/>
<toolbarbutton id="tb-note-add" tooltiptext="&toolbar.note.standalone;" oncommand="ScholarPane.newNote(event.shiftKey);"/>
<toolbarbutton id="tb-link-page" tooltiptext="&toolbar.attachment.weblink;" oncommand="ZoteroPane.addAttachmentFromPage(true)"/>
<toolbarbutton id="tb-snapshot-page" tooltiptext="&toolbar.attachment.snapshot;" oncommand="ZoteroPane.addAttachmentFromPage()"/>
<toolbarbutton id="tb-note-add" tooltiptext="&toolbar.note.standalone;" oncommand="ZoteroPane.newNote(event.shiftKey);"/>
<spacer flex="1"/>
<label value="&toolbar.search.label;" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="250" command="cmd_scholar_search" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_scholar_search'); return false; }">
<textbox id="tb-search" type="timed" timeout="250" command="cmd_zotero_search" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_zotero_search'); return false; }">
<toolbarbutton id="tb-search-cancel" oncommand="this.parentNode.value='';" hidden="true"/>
</textbox>
</toolbar>
<tree
id="items-tree" context="scholar-itemmenu"
ondblclick="ScholarPane.onDoubleClick(event, this);"
id="items-tree" context="zotero-itemmenu"
ondblclick="ZoteroPane.onDoubleClick(event, this);"
enableColumnDrag="true"
onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteSelectedItem(); return false; }"
onselect="ScholarPane.itemSelected();"
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarPane.getItemsView());"
ondragover="nsDragAndDrop.dragOver(event,ScholarPane.getItemsView())"
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())"
onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ZoteroPane.deleteSelectedItem(); return false; }"
onselect="ZoteroPane.itemSelected();"
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ZoteroPane.getItemsView());"
ondragover="nsDragAndDrop.dragOver(event,ZoteroPane.getItemsView())"
ondragdrop="nsDragAndDrop.drop(event,ZoteroPane.getItemsView())"
flex="1">
<treecols>
<treecol
@ -168,15 +168,15 @@
<treechildren/>
</tree>
</vbox>
<splitter id="scholar-view-splitter" resizebefore="closest" resizeafter="closest"/>
<splitter id="zotero-view-splitter" resizebefore="closest" resizeafter="closest"/>
<vbox>
<toolbar align="right">
<toolbarbutton id="tb-fullscreen" tooltiptext="&toolbar.fullscreen.tooltip;" oncommand="ScholarPane.fullScreen();"/>
<toolbarbutton class="tabs-closebutton" oncommand="ScholarPane.toggleDisplay()"/>
<toolbarbutton id="tb-fullscreen" tooltiptext="&toolbar.fullscreen.tooltip;" oncommand="ZoteroPane.fullScreen();"/>
<toolbarbutton class="tabs-closebutton" oncommand="ZoteroPane.toggleDisplay()"/>
</toolbar>
<groupbox flex="1">
<caption>
<tabs id="scholar-view-tabs" onselect="document.getElementById('scholar-view-item').selectedIndex = this.selectedIndex;" hidden="true">
<tabs id="zotero-view-tabs" onselect="document.getElementById('zotero-view-item').selectedIndex = this.selectedIndex;" hidden="true">
<tab label="&tabs.info.label;"/>
<tab label="&tabs.notes.label;"/>
<tab label="&tabs.attachments.label;"/>
@ -184,28 +184,28 @@
<tab label="&tabs.related.label;"/>
</tabs>
</caption>
<deck id="item-pane" selectedIndex="0" flex="1" onselect="document.getElementById('scholar-view-tabs').setAttribute('hidden',(this.selectedIndex != 1));">
<deck id="item-pane" selectedIndex="0" flex="1" onselect="document.getElementById('zotero-view-tabs').setAttribute('hidden',(this.selectedIndex != 1));">
<box pack="center" align="center">
<label id="scholar-view-selected-label"/>
<label id="zotero-view-selected-label"/>
</box>
<deck id="scholar-view-item" flex="1"/>
<deck id="zotero-view-item" flex="1"/>
<!-- Note info pane -->
<vbox id="scholar-view-note" flex="1">
<noteeditor id="scholar-note-editor" flex="1"/>
<button id="scholar-view-note-button" label="&notes.separate;" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ScholarPane.selectItem(this.getAttribute('sourceID'));"/>
<vbox id="zotero-view-note" flex="1">
<noteeditor id="zotero-note-editor" flex="1"/>
<button id="zotero-view-note-button" label="&notes.separate;" oncommand="ZoteroPane.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ZoteroPane.selectItem(this.getAttribute('sourceID'));"/>
</vbox>
<!-- Attachment info pane -->
<vbox id="scholar-view-attachment" flex="1">
<label id="scholar-attachment-label"/>
<vbox id="zotero-view-attachment" flex="1">
<label id="zotero-attachment-label"/>
<hbox>
<button id="scholar-attachment-view" flex="1" oncommand="ScholarPane.viewSelectedAttachment();"/>
<button id="scholar-attachment-show" label="&item.attachment.file.show;" flex="1" oncommand="ScholarPane.showSelectedAttachmentInFilesystem()"/>
<button id="zotero-attachment-view" flex="1" oncommand="ZoteroPane.viewSelectedAttachment();"/>
<button id="zotero-attachment-show" label="&item.attachment.file.show;" flex="1" oncommand="ZoteroPane.showSelectedAttachmentInFilesystem()"/>
</hbox>
<vbox>
<label id="scholar-attachment-url" class="text-link" crop="end" onclick="window.loadURI(this.value)"/>
<label id="scholar-attachment-accessed"/>
<label id="zotero-attachment-url" class="text-link" crop="end" onclick="window.loadURI(this.value)"/>
<label id="zotero-attachment-accessed"/>
</vbox>
<noteeditor id="scholar-attachment-note-editor" notitle="1" flex="1"/>
<noteeditor id="zotero-attachment-note-editor" notitle="1" flex="1"/>
</vbox>
</deck>
</groupbox>
@ -214,31 +214,31 @@
</vbox>
<statusbar id="status-bar">
<statusbarpanel id="scholar-status-bar-icon"
src="chrome://scholar/skin/zotero_logo_18px.png"
class="statusbarpanel-iconic" onclick="ScholarPane.toggleDisplay();"
<statusbarpanel id="zotero-status-bar-icon"
src="chrome://zotero/skin/zotero_logo_18px.png"
class="statusbarpanel-iconic" onclick="ZoteroPane.toggleDisplay();"
hidden="true"/>
</statusbar>
<script>
window.addEventListener('load', function(e){
if (Scholar){
document.getElementById('scholar-status-bar-icon').setAttribute('hidden', 'false');
if (Zotero){
document.getElementById('zotero-status-bar-icon').setAttribute('hidden', 'false');
}
}, false);
</script>
<menupopup id="menu_ToolsPopup">
<menuseparator id="scholarSeparator" insertbefore="devToolsSeparator"/>
<menuitem id="tools-scholar" insertbefore="devToolsSeparator"
oncommand="ScholarPane.toggleDisplay();" label="&scholar.name;"
key="key_openScholar"/>
<menuseparator id="zoteroSeparator" insertbefore="devToolsSeparator"/>
<menuitem id="tools-zotero" insertbefore="devToolsSeparator"
oncommand="ZoteroPane.toggleDisplay();" label="&zotero.name;"
key="key_openZotero"/>
</menupopup>
<keyset id="mainKeyset">
<key id="key_openScholar"
<key id="key_openZotero"
key="Z"
oncommand="ScholarPane.toggleDisplay();"
oncommand="ZoteroPane.toggleDisplay();"
modifiers="shift accel" />
</keyset>
</overlay>

View file

@ -11,11 +11,11 @@ var openURLMenu;
var openURLResolvers;
var openURLServerField;
var openURLVersionMenu;
var scholarPaneOnTopInitial;
var zoteroPaneOnTopInitial;
/*
To add a new preference:
1) modify defaults/preferences/scholar.js
1) modify defaults/preferences/zotero.js
2) in this document:
a) add var above
b) add lines to init() function
@ -23,49 +23,49 @@ var scholarPaneOnTopInitial;
3) add a control to prefs.xul
4) (Optional) To add an observer for a preference change,
add an appropriate case in the switch statement
in Scholar.Prefs.observe()
in Zotero.Prefs.observe()
*/
function init()
{
autoUpdateBox = document.getElementById('autoUpdateBox');
autoUpdateBox.checked = scholarPaneOnTopInitial = Scholar.Prefs.get('automaticScraperUpdates');
autoUpdateBox.checked = zoteroPaneOnTopInitial = Zotero.Prefs.get('automaticScraperUpdates');
positionMenu = document.getElementById('positionMenu');
positionMenu.selectedIndex = Scholar.Prefs.get('scholarPaneOnTop') ? 0 : 1;
positionMenu.selectedIndex = Zotero.Prefs.get('zoteroPaneOnTop') ? 0 : 1;
parseEndnoteBox = document.getElementById('parseEndnoteBox');
parseEndnoteBox.checked = Scholar.Prefs.get('parseEndNoteMIMETypes');
parseEndnoteBox.checked = Zotero.Prefs.get('parseEndNoteMIMETypes');
openURLServerField = document.getElementById('openURLServerField');
openURLServerField.value = Scholar.Prefs.get('openURL.resolver');
openURLServerField.value = Zotero.Prefs.get('openURL.resolver');
openURLVersionMenu = document.getElementById('openURLVersionMenu');
openURLVersionMenu.value = Scholar.Prefs.get('openURL.version');
openURLVersionMenu.value = Zotero.Prefs.get('openURL.version');
openURLMenu = document.getElementById('openURLMenu');
openURLResolvers = Scholar.OpenURL.discoverResolvers();
openURLResolvers = Zotero.OpenURL.discoverResolvers();
for(var i in openURLResolvers)
{
openURLMenu.insertItemAt(i,openURLResolvers[i]['name']);
if(openURLResolvers[i]['url'] == Scholar.Prefs.get('openURL.resolver') && openURLResolvers[i]['version'] == Scholar.Prefs.get('openURL.version'))
if(openURLResolvers[i]['url'] == Zotero.Prefs.get('openURL.resolver') && openURLResolvers[i]['version'] == Zotero.Prefs.get('openURL.version'))
openURLMenu.selectedIndex = i;
}
}
function accept()
{
Scholar.Prefs.set('automaticScraperUpdates', autoUpdateBox.checked);
Scholar.Prefs.set('scholarPaneOnTop', positionMenu.selectedIndex == 0);
Zotero.Prefs.set('automaticScraperUpdates', autoUpdateBox.checked);
Zotero.Prefs.set('zoteroPaneOnTop', positionMenu.selectedIndex == 0);
if(Scholar.Prefs.get('parseEndNoteMIMETypes') != parseEndnoteBox.checked)
if(Zotero.Prefs.get('parseEndNoteMIMETypes') != parseEndnoteBox.checked)
{
Scholar.Prefs.set('parseEndNoteMIMETypes', parseEndnoteBox.checked);
Scholar.Ingester.MIMEHandler.init();
Zotero.Prefs.set('parseEndNoteMIMETypes', parseEndnoteBox.checked);
Zotero.Ingester.MIMEHandler.init();
}
Scholar.Prefs.set('openURL.resolver', openURLServerField.value);
Scholar.Prefs.set('openURL.version', openURLVersionMenu.value);
Zotero.Prefs.set('openURL.resolver', openURLServerField.value);
Zotero.Prefs.set('openURL.version', openURLVersionMenu.value);
}
function onOpenURLSelected()
@ -89,9 +89,9 @@ function onOpenURLCustomized()
function onPositionChange()
{
var statusLine = document.getElementById('statusLine');
if ((positionMenu.selectedIndex == 0) != scholarPaneOnTopInitial)
if ((positionMenu.selectedIndex == 0) != zoteroPaneOnTopInitial)
{
statusLine.value = Scholar.getString('scholar.preferences.status.positionChange');
statusLine.value = Zotero.getString('zotero.preferences.status.positionChange');
}
else
{

View file

@ -4,36 +4,36 @@
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
http://chnm.gmu.edu/
-->
<!DOCTYPE window SYSTEM "chrome://scholar/locale/preferences.dtd">
<!DOCTYPE window SYSTEM "chrome://zotero/locale/preferences.dtd">
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<dialog id="winMain" title="&scholar.preferences.title;" style="min-width:400px;"
<dialog id="winMain" title="&zotero.preferences.title;" style="min-width:400px;"
onload="init();" ondialogaccept="accept()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="preferences.js"/>
<script src="include.js"/>
<dialogheader id="header" title="&scholar.name;" description="&scholar.preferences.title;"/>
<dialogheader id="header" title="&zotero.name;" description="&zotero.preferences.title;"/>
<hbox align="center">
<label value="&scholar.preferences.position.label;" control="positionMenu"/>
<label value="&zotero.preferences.position.label;" control="positionMenu"/>
<menulist id="positionMenu" oncommand="onPositionChange()">
<menupopup>
<menuitem label="&scholar.preferences.position.above;"/>
<menuitem label="&scholar.preferences.position.below;"/>
<menuitem label="&zotero.preferences.position.above;"/>
<menuitem label="&zotero.preferences.position.below;"/>
</menupopup>
</menulist>
<label value="&scholar.preferences.position.browser;"/>
<label value="&zotero.preferences.position.browser;"/>
</hbox>
<checkbox id="autoUpdateBox" label="&scholar.preferences.autoUpdate.label;"/>
<checkbox id="autoUpdateBox" label="&zotero.preferences.autoUpdate.label;"/>
<checkbox id="parseEndnoteBox" label="&scholar.preferences.parseEndnote.label;"/>
<checkbox id="parseEndnoteBox" label="&zotero.preferences.parseEndnote.label;"/>
<groupbox>
<caption label="&scholar.preferences.openurl.caption;"/>
<caption label="&zotero.preferences.openurl.caption;"/>
<menulist id="openURLMenu" oncommand="onOpenURLSelected();">
<menupopup>
@ -43,12 +43,12 @@
</menulist>
<hbox align="center">
<label value="&scholar.preferences.openurl.server;"/>
<label value="&zotero.preferences.openurl.server;"/>
<textbox id="openURLServerField" flex="1" oninput="onOpenURLCustomized();"/>
</hbox>
<hbox align="center">
<label value="&scholar.preferences.openurl.version;"/>
<label value="&zotero.preferences.openurl.version;"/>
<menulist id="openURLVersionMenu" oncommand="onOpenURLCustomized();">
<menupopup>
<menuitem label="0.1" value="0.1"/>

View file

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<window id="zotero-progress-window"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"

View file

@ -5,12 +5,12 @@
http://chnm.gmu.edu/
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="scholar-search-dialog"
id="zotero-search-dialog"
title="Search"
orient="vertical"
buttons="cancel,accept"
@ -24,5 +24,5 @@
<script src="searchDialog.js"/>
<hbox align="center"><label value="Name:"/><textbox id="search-name" flex="1"/></hbox>
<scholarsearch id="search-box" flex="1"/>
<zoterosearch id="search-box" flex="1"/>
</dialog>

View file

@ -17,7 +17,7 @@ function doLoad()
{
io = window.arguments[0];
collectionsView = new Scholar.CollectionTreeView();
collectionsView = new Zotero.CollectionTreeView();
document.getElementById('collections-tree').view = collectionsView;
// move to center of screen
@ -45,7 +45,7 @@ function onCollectionSelected()
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
collection.setSearch('');
itemsView = new Scholar.ItemTreeView(collection, (window.arguments[1] ? true : false));
itemsView = new Zotero.ItemTreeView(collection, (window.arguments[1] ? true : false));
document.getElementById('items-tree').view = itemsView;
}

View file

@ -5,12 +5,12 @@
http://chnm.gmu.edu/
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="scholar-select-items-dialog"
id="zotero-select-items-dialog"
title="Select"
orient="vertical"
width="600" height="450"
@ -26,7 +26,7 @@
<hbox align="center" pack="end">
<label value="&toolbar.search.label;" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="250" oncommand="onSearch()" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_scholar_search'); return false; }">
<textbox id="tb-search" type="timed" timeout="250" oncommand="onSearch()" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_zotero_search'); return false; }">
<toolbarbutton id="tb-search-cancel" oncommand="this.parentNode.value='';" hidden="true"/>
</textbox>
</hbox>

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<window
@ -13,5 +13,5 @@
<script src="../include.js"/>
<script src="test.js"/>
<hbox><label>This is only a test...page.</label></hbox>
<hbox><label>This is a test page.</label></hbox>
</window>

View file

@ -1,4 +1,4 @@
Scholar.Attachments = new function(){
Zotero.Attachments = new function(){
this.LINK_MODE_IMPORTED_FILE = 0;
this.LINK_MODE_IMPORTED_URL = 1;
this.LINK_MODE_LINKED_FILE = 2;
@ -17,17 +17,17 @@ Scholar.Attachments = new function(){
function importFromFile(file, sourceItemID){
var title = file.leafName;
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
// Create a new attachment
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
var attachmentItem = Zotero.Items.getNewItemByType(Zotero.ItemTypes.getID('attachment'));
attachmentItem.setField('title', title);
attachmentItem.save();
var itemID = attachmentItem.getID();
// Create directory for attachment files within storage directory
var destDir = Scholar.getStorageDirectory();
var destDir = Zotero.getStorageDirectory();
destDir.append(itemID);
destDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0644);
@ -39,23 +39,23 @@ Scholar.Attachments = new function(){
newFile.initWithFile(destDir);
newFile.append(title);
var mimeType = Scholar.MIME.getMIMETypeFromFile(newFile);
var mimeType = Zotero.MIME.getMIMETypeFromFile(newFile);
_addToDB(newFile, null, null, this.LINK_MODE_IMPORTED_FILE,
mimeType, null, sourceItemID, itemID);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
// Determine charset and build fulltext index
_postProcessFile(itemID, newFile, mimeType);
}
catch (e){
// hmph
Scholar.DB.rollbackTransaction();
Zotero.DB.rollbackTransaction();
// Clean up
if (itemID){
var itemDir = Scholar.getStorageDirectory();
var itemDir = Zotero.getStorageDirectory();
itemDir.append(itemID);
if (itemDir.exists()){
itemDir.remove(true);
@ -69,7 +69,7 @@ Scholar.Attachments = new function(){
function linkFromFile(file, sourceItemID){
var title = file.leafName;
var mimeType = Scholar.MIME.getMIMETypeFromFile(file);
var mimeType = Zotero.MIME.getMIMETypeFromFile(file);
var itemID = _addToDB(file, null, title, this.LINK_MODE_LINKED_FILE, mimeType,
null, sourceItemID);
@ -82,20 +82,20 @@ Scholar.Attachments = new function(){
function importSnapshotFromFile(file, url, title, mimeType, charset, sourceItemID){
var charsetID = Scholar.CharacterSets.getID(charset);
var charsetID = Zotero.CharacterSets.getID(charset);
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
// Create a new attachment
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
var attachmentItem = Zotero.Items.getNewItemByType(Zotero.ItemTypes.getID('attachment'));
attachmentItem.setField('title', title);
attachmentItem.setField('url', url);
// TODO: access date
attachmentItem.save();
var itemID = attachmentItem.getID();
var storageDir = Scholar.getStorageDirectory();
var storageDir = Zotero.getStorageDirectory();
file.parent.copyTo(storageDir, itemID);
// Point to copied file
@ -107,17 +107,17 @@ Scholar.Attachments = new function(){
_addToDB(newFile, url, null, this.LINK_MODE_IMPORTED_URL, mimeType,
charsetID, sourceItemID, itemID);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
// Determine charset and build fulltext index
_postProcessFile(itemID, newFile, mimeType);
}
catch (e){
Scholar.DB.rollbackTransaction();
Zotero.DB.rollbackTransaction();
// Clean up
if (itemID){
var itemDir = Scholar.getStorageDirectory();
var itemDir = Zotero.getStorageDirectory();
itemDir.append(itemID);
if (itemDir.exists()){
itemDir.remove(true);
@ -130,7 +130,7 @@ Scholar.Attachments = new function(){
function importFromURL(url, sourceItemID){
Scholar.Utilities.HTTP.doHead(url, function(obj){
Zotero.Utilities.HTTP.doHead(url, function(obj){
var mimeType = obj.channel.contentType;
var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"]
@ -140,12 +140,12 @@ Scholar.Attachments = new function(){
// If we can load this internally, use a hidden browser (so we can
// get the charset and title)
if (Scholar.MIME.hasInternalHandler(mimeType, ext)){
var browser = Scholar.Browser.createHiddenBrowser();
if (Zotero.MIME.hasInternalHandler(mimeType, ext)){
var browser = Zotero.Browser.createHiddenBrowser();
browser.addEventListener("pageshow", function(){
Scholar.Attachments.importFromDocument(browser.contentDocument, sourceItemID);
Zotero.Attachments.importFromDocument(browser.contentDocument, sourceItemID);
browser.removeEventListener("pageshow", arguments.callee, true);
Scholar.Browser.deleteHiddenBrowser(browser);
Zotero.Browser.deleteHiddenBrowser(browser);
}, true);
browser.loadURI(url);
}
@ -162,11 +162,11 @@ Scholar.Attachments = new function(){
//wbp.persistFlags = nsIWBP.PERSIST_FLAGS...;
var encodingFlags = false;
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
// Create a new attachment
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
var attachmentItem = Zotero.Items.getNewItemByType(Zotero.ItemTypes.getID('attachment'));
attachmentItem.setField('title', title);
attachmentItem.setField('url', url);
attachmentItem.setField('accessDate', "CURRENT_TIMESTAMP");
@ -174,7 +174,7 @@ Scholar.Attachments = new function(){
var itemID = attachmentItem.getID();
// Create a new folder for this item in the storage directory
var destDir = Scholar.getStorageDirectory();
var destDir = Zotero.getStorageDirectory();
destDir.append(itemID);
destDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0644);
@ -185,13 +185,13 @@ Scholar.Attachments = new function(){
wbp.saveURI(nsIURL, null, null, null, null, file);
_addToDB(file, url, title, Scholar.Attachments.LINK_MODE_IMPORTED_URL,
_addToDB(file, url, title, Zotero.Attachments.LINK_MODE_IMPORTED_URL,
mimeType, null, sourceItemID, itemID);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
catch (e){
Scholar.DB.rollbackTransaction();
Zotero.DB.rollbackTransaction();
throw (e);
}
}
@ -213,8 +213,8 @@ Scholar.Attachments = new function(){
}
// Otherwise do a head request for the mime type
Scholar.Utilities.HTTP.doHead(url, function(obj){
_addToDB(null, url, title, Scholar.Attachments.LINK_MODE_LINKED_URL,
Zotero.Utilities.HTTP.doHead(url, function(obj){
_addToDB(null, url, title, Zotero.Attachments.LINK_MODE_LINKED_URL,
obj.channel.contentType, null, sourceItemID);
});
}
@ -225,7 +225,7 @@ Scholar.Attachments = new function(){
var url = document.location;
var title = document.title; // TODO: don't use Mozilla-generated title for images, etc.
var mimeType = document.contentType;
var charsetID = Scholar.CharacterSets.getID(document.characterSet);
var charsetID = Zotero.CharacterSets.getID(document.characterSet);
var itemID = _addToDB(null, url, title, this.LINK_MODE_LINKED_URL,
mimeType, charsetID, sourceItemID);
@ -233,7 +233,7 @@ Scholar.Attachments = new function(){
// Run the fulltext indexer asynchronously (actually, it hangs the UI
// thread, but at least it lets the menu close)
setTimeout(function(){
Scholar.Fulltext.indexDocument(document, itemID);
Zotero.Fulltext.indexDocument(document, itemID);
}, 50);
return itemID;
@ -244,7 +244,7 @@ Scholar.Attachments = new function(){
var url = document.location;
var title = document.title;
var mimeType = document.contentType;
var charsetID = Scholar.CharacterSets.getID(document.characterSet);
var charsetID = Zotero.CharacterSets.getID(document.characterSet);
const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
var wbp = Components
@ -253,10 +253,10 @@ Scholar.Attachments = new function(){
//wbp.persistFlags = nsIWBP.PERSIST_FLAGS...;
var encodingFlags = false;
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
// Create a new attachment
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
var attachmentItem = Zotero.Items.getNewItemByType(Zotero.ItemTypes.getID('attachment'));
attachmentItem.setField('title', title);
attachmentItem.setField('url', url);
attachmentItem.setField('accessDate', "CURRENT_TIMESTAMP");
@ -264,7 +264,7 @@ Scholar.Attachments = new function(){
var itemID = attachmentItem.getID();
// Create a new folder for this item in the storage directory
var destDir = Scholar.getStorageDirectory();
var destDir = Zotero.getStorageDirectory();
destDir.append(itemID);
destDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0644);
@ -276,7 +276,7 @@ Scholar.Attachments = new function(){
// This is a hack to make sure the file is opened in the browser when
// we use loadURI(), since Firefox's internal detection mechanisms seem
// to sometimes get confused
// (see #192, https://chnm.gmu.edu/trac/scholar/ticket/192)
// (see #192, https://chnm.gmu.edu/trac/zotero/ticket/192)
if (mimeType=='text/html' &&
(fileName.substr(fileName.length-5)!='.html'
&& fileName.substr(fileName.length-4)!='.htm')){
@ -290,12 +290,12 @@ Scholar.Attachments = new function(){
_addToDB(file, url, title, this.LINK_MODE_IMPORTED_URL, mimeType,
charsetID, sourceItemID, itemID);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
// Run the fulltext indexer asynchronously (actually, it hangs the UI
// thread, but at least it lets the menu close)
setTimeout(function(){
Scholar.Fulltext.indexDocument(document, itemID);
Zotero.Fulltext.indexDocument(document, itemID);
}, 50);
return itemID;
@ -333,37 +333,37 @@ Scholar.Attachments = new function(){
**/
function _addToDB(file, url, title, linkMode, mimeType, charsetID, sourceItemID, itemID){
if (file){
// Path relative to Scholar directory for external files and relative
// Path relative to Zotero directory for external files and relative
// to storage directory for imported files
var refDir = (linkMode==this.LINK_MODE_LINKED_FILE)
? Scholar.getScholarDirectory() : Scholar.getStorageDirectory();
? Zotero.getZoteroDirectory() : Zotero.getStorageDirectory();
var path = file.getRelativeDescriptor(refDir);
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
if (sourceItemID){
var sourceItem = Scholar.Items.get(sourceItemID);
var sourceItem = Zotero.Items.get(sourceItemID);
if (!sourceItem){
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
throw ("Cannot set attachment source to invalid item " + sourceItemID);
}
if (sourceItem.isAttachment()){
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
throw ("Cannot set attachment source to another file (" + sourceItemID + ")");
}
}
// If an itemID is provided, use that
if (itemID){
var attachmentItem = Scholar.Items.get(itemID);
var attachmentItem = Zotero.Items.get(itemID);
if (!attachmentItem.isAttachment()){
throw ("Item " + itemID + " is not a valid attachment in _addToDB()");
}
}
// Otherwise create a new attachment
else {
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
var attachmentItem = Zotero.Items.getNewItemByType(Zotero.ItemTypes.getID('attachment'));
attachmentItem.setField('title', title);
if (linkMode==self.LINK_MODE_IMPORTED_URL
|| linkMode==self.LINK_MODE_LINKED_URL){
@ -383,15 +383,15 @@ Scholar.Attachments = new function(){
(charsetID ? {int:charsetID} : null),
(path ? {string:path} : null)
];
Scholar.DB.query(sql, bindParams);
Scholar.DB.commitTransaction();
Zotero.DB.query(sql, bindParams);
Zotero.DB.commitTransaction();
if (sourceItemID){
sourceItem.incrementAttachmentCount();
Scholar.Notifier.trigger('modify', 'item', sourceItemID);
Zotero.Notifier.trigger('modify', 'item', sourceItemID);
}
Scholar.Notifier.trigger('add', 'item', attachmentItem.getID());
Zotero.Notifier.trigger('add', 'item', attachmentItem.getID());
return attachmentItem.getID();
}
@ -404,27 +404,27 @@ Scholar.Attachments = new function(){
* asynchronously after the fact
*/
function _postProcessFile(itemID, file, mimeType){
var ext = Scholar.File.getExtension(file);
var ext = Zotero.File.getExtension(file);
if (mimeType.substr(0, 5)!='text/' ||
!Scholar.MIME.hasInternalHandler(mimeType, ext)){
!Zotero.MIME.hasInternalHandler(mimeType, ext)){
return false;
}
var browser = Scholar.Browser.createHiddenBrowser();
var browser = Zotero.Browser.createHiddenBrowser();
Scholar.File.addCharsetListener(browser, new function(){
Zotero.File.addCharsetListener(browser, new function(){
return function(charset, id){
var charsetID = Scholar.CharacterSets.getID(charset);
var charsetID = Zotero.CharacterSets.getID(charset);
if (charsetID){
var sql = "UPDATE itemAttachments SET charsetID=" + charsetID
+ " WHERE itemID=" + itemID;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
}
// Chain fulltext indexer inside the charset callback,
// since it's asynchronous and a prerequisite
Scholar.Fulltext.indexDocument(browser.contentDocument, itemID);
Scholar.Browser.deleteHiddenBrowser(browser);
Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
Zotero.Browser.deleteHiddenBrowser(browser);
}
}, itemID);

View file

@ -1,11 +1,11 @@
/*
* Scholar.Cite: a class for creating bibliographies from within Scholar
* Zotero.Cite: a class for creating bibliographies from within Zotero
* this class handles pulling the CSL file and item data out of the database,
* while CSL, below, handles the actual generation of the bibliography
*/
default xml namespace = "http://purl.org/net/xbiblio/csl";
Scholar.Cite = new function() {
Zotero.Cite = new function() {
var _lastCSL = null;
var _lastStyle = null;
@ -18,7 +18,7 @@ Scholar.Cite = new function() {
function getStyles() {
// get styles
var sql = "SELECT cslID, title FROM csl ORDER BY title";
var styles = Scholar.DB.query(sql);
var styles = Zotero.DB.query(sql);
// convert to associative array
var stylesObject = new Object();
@ -33,13 +33,13 @@ Scholar.Cite = new function() {
* from the cache
*/
function getStyle(cslID) {
if(_lastStyle != cslID || Scholar.Prefs.get("cacheTranslatorData") == false) {
if(_lastStyle != cslID || Zotero.Prefs.get("cacheTranslatorData") == false) {
// get style
var sql = "SELECT csl FROM csl WHERE cslID = ?";
var style = Scholar.DB.valueQuery(sql, [cslID]);
var style = Zotero.DB.valueQuery(sql, [cslID]);
// create a CSL instance
_lastCSL = new Scholar.CSL(style);
_lastCSL = new Zotero.CSL(style);
_lastStyle = cslID;
}
return _lastCSL;
@ -49,25 +49,25 @@ Scholar.Cite = new function() {
/*
* CSL: a class for creating bibliographies from CSL files
* this is abstracted as a separate class for the benefit of anyone who doesn't
* want to use the Scholar data model, but does want to use CSL in JavaScript
* want to use the Zotero data model, but does want to use CSL in JavaScript
*/
Scholar.CSL = function(csl) {
this._csl = new XML(Scholar.CSL._cleanXML(csl));
Zotero.CSL = function(csl) {
this._csl = new XML(Zotero.CSL._cleanXML(csl));
// initialize CSL
Scholar.CSL.init();
Zotero.CSL.init();
// load localizations
this._terms = Scholar.CSL._parseLocales(this._csl.terms);
this._terms = Zotero.CSL._parseLocales(this._csl.terms);
// load class defaults
this.class = this._csl["@class"].toString();
Scholar.debug("CSL: style class is "+this.class);
Zotero.debug("CSL: style class is "+this.class);
this._defaults = new Object();
// load class defaults
if(Scholar.CSL._classDefaults[this.class]) {
var classDefaults = Scholar.CSL._classDefaults[this.class];
if(Zotero.CSL._classDefaults[this.class]) {
var classDefaults = Zotero.CSL._classDefaults[this.class];
for(var i in classDefaults) {
this._defaults[i] = classDefaults[i];
}
@ -79,7 +79,7 @@ Scholar.CSL = function(csl) {
this._parseCitationOptions();
// if no bibliography exists, parse citation element as bibliography
if(!this._bib) {
Scholar.debug("CSL: using citation element for bibliography");
Zotero.debug("CSL: using citation element for bibliography");
this._bib = this._cit;
}
}
@ -91,8 +91,8 @@ Scholar.CSL = function(csl) {
* must be called prior to generating citations or bibliography with a new set
* of items
*/
Scholar.CSL.prototype.preprocessItems = function(items) {
Scholar.debug("CSL: preprocessing items");
Zotero.CSL.prototype.preprocessItems = function(items) {
Zotero.debug("CSL: preprocessing items");
this._ignore = null;
@ -113,7 +113,7 @@ Scholar.CSL.prototype.preprocessItems = function(items) {
item._csl.translators = creators[2];
// parse date
item._csl.date = Scholar.CSL.prototype._processDate(item.getField("date"));
item._csl.date = Zotero.CSL.prototype._processDate(item.getField("date"));
}
// clear disambiguation and subsequent author substitute
if(item._csl.disambiguation) item._csl.date.disambiguation = undefined;
@ -122,7 +122,7 @@ Scholar.CSL.prototype.preprocessItems = function(items) {
// sort by sort order
if(this._bib.sortOrder) {
Scholar.debug("CSL: sorting items");
Zotero.debug("CSL: sorting items");
var me = this;
items.sort(function(a, b) {
return me._compareItem(a, b);
@ -187,7 +187,7 @@ Scholar.CSL.prototype.preprocessItems = function(items) {
/*
* create a citation (in-text or footnote)
*/
Scholar.CSL.prototype.createCitation = function(citation, format) {
Zotero.CSL.prototype.createCitation = function(citation, format) {
if(citation.citationType == 2) {
var string = this._getTerm("ibid");
string = string[0].toUpperCase()+string.substr(1);
@ -214,7 +214,7 @@ Scholar.CSL.prototype.createCitation = function(citation, format) {
locator = citation.locators[i];
}
string += this._getCitation(Scholar.Items.get(citation.itemIDs[i]),
string += this._getCitation(Zotero.Items.get(citation.itemIDs[i]),
(citation.citationType[i] == 1 ? "first" : "subsequent"),
locatorType, locator, format, this._cit);
}
@ -238,7 +238,7 @@ Scholar.CSL.prototype.createCitation = function(citation, format) {
* create a bibliography
* (items is expected to be an array of items)
*/
Scholar.CSL.prototype.createBibliography = function(items, format) {
Zotero.CSL.prototype.createBibliography = function(items, format) {
// process this._items
var output = "";
@ -278,7 +278,7 @@ Scholar.CSL.prototype.createBibliography = function(items, format) {
// add line feeds
if(format == "HTML") {
var coins = Scholar.OpenURL.createContextObject(item, "1.0");
var coins = Zotero.OpenURL.createContextObject(item, "1.0");
if(coins) {
string += '<span class="Z3988" title="'+coins.replace("&", "&amp;")+'"></span>';
}
@ -321,7 +321,7 @@ Scholar.CSL.prototype.createBibliography = function(items, format) {
}
// for elements that inherit defaults from each other
Scholar.CSL._inherit = {
Zotero.CSL._inherit = {
author:"contributor",
editor:"contributor",
translator:"contributor",
@ -333,8 +333,8 @@ Scholar.CSL._inherit = {
edition:"version"
}
// for class definitions
Scholar.CSL._classDefaults = new Object();
Scholar.CSL._classDefaults["author-date"] = {
Zotero.CSL._classDefaults = new Object();
Zotero.CSL._classDefaults["author-date"] = {
author:{
substitute:[
{name:"editor"},
@ -347,79 +347,79 @@ Scholar.CSL._classDefaults["author-date"] = {
}
};
Scholar.CSL.ns = "http://purl.org/net/xbiblio/csl";
Zotero.CSL.ns = "http://purl.org/net/xbiblio/csl";
/*
* initializes CSL interpreter
*/
Scholar.CSL.init = function() {
if(!Scholar.CSL._xmlLang) {
Zotero.CSL.init = function() {
if(!Zotero.CSL._xmlLang) {
// get XML lang
Scholar.CSL._xmlLang = Scholar.locale;
Zotero.CSL._xmlLang = Zotero.locale;
// read locales.xml from directory
var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance();
req.open("GET", "chrome://scholar/locale/locales.xml", false);
req.open("GET", "chrome://zotero/locale/locales.xml", false);
req.overrideMimeType("text/plain");
req.send(null);
// get default terms
var locales = new XML(Scholar.CSL._cleanXML(req.responseText));
Scholar.CSL._defaultTerms = Scholar.CSL._parseLocales(locales);
var locales = new XML(Zotero.CSL._cleanXML(req.responseText));
Zotero.CSL._defaultTerms = Zotero.CSL._parseLocales(locales);
}
}
/*
* returns an array of short or long month strings
*/
Scholar.CSL.getMonthStrings = function(form) {
Scholar.CSL.init();
return Scholar.CSL._defaultTerms[form]["_months"];
Zotero.CSL.getMonthStrings = function(form) {
Zotero.CSL.init();
return Zotero.CSL._defaultTerms[form]["_months"];
}
/*
* removes parse instructions from XML
*/
Scholar.CSL._cleanXML = function(xml) {
Zotero.CSL._cleanXML = function(xml) {
return xml.replace(/<\?[^>]*\?>/g, "");
}
/*
* parses locale strings into Scholar.CSL._defaultTerms
* parses locale strings into Zotero.CSL._defaultTerms
*/
Scholar.CSL._parseLocales = function(termXML) {
Zotero.CSL._parseLocales = function(termXML) {
// return defaults if there are no terms
if(!termXML.length()) {
return (Scholar.CSL._defaultTerms ? Scholar.CSL._defaultTerms : {});
return (Zotero.CSL._defaultTerms ? Zotero.CSL._defaultTerms : {});
}
var xml = new Namespace("http://www.w3.org/XML/1998/namespace");
// get proper locale
var locale = termXML.locale.(@xml::lang == Scholar.CSL._xmlLang);
var locale = termXML.locale.(@xml::lang == Zotero.CSL._xmlLang);
if(!locale.length()) {
var xmlLang = Scholar.CSL._xmlLang.substr(0, 2);
var xmlLang = Zotero.CSL._xmlLang.substr(0, 2);
locale = termXML.locale.(@xml::lang == xmlLang);
}
if(!locale.length()) {
// return defaults if there are no locales
return (Scholar.CSL._defaultTerms ? Scholar.CSL._defaultTerms : {});
return (Zotero.CSL._defaultTerms ? Zotero.CSL._defaultTerms : {});
}
var termArray = new Object();
termArray["default"] = new Object();
if(Scholar.CSL._defaultTerms) {
if(Zotero.CSL._defaultTerms) {
// ugh. copy default array. javascript dumb.
for(var i in Scholar.CSL._defaultTerms) {
for(var i in Zotero.CSL._defaultTerms) {
termArray[i] = new Object();
for(var j in Scholar.CSL._defaultTerms[i]) {
if(typeof(Scholar.CSL._defaultTerms[i]) == "object") {
termArray[i][j] = [Scholar.CSL._defaultTerms[i][j][0],
Scholar.CSL._defaultTerms[i][j][1]];
for(var j in Zotero.CSL._defaultTerms[i]) {
if(typeof(Zotero.CSL._defaultTerms[i]) == "object") {
termArray[i][j] = [Zotero.CSL._defaultTerms[i][j][0],
Zotero.CSL._defaultTerms[i][j][1]];
} else {
termArray[i][j] = Scholar.CSL._defaultTerms[i][j];
termArray[i][j] = Zotero.CSL._defaultTerms[i][j];
}
}
}
@ -480,7 +480,7 @@ Scholar.CSL._parseLocales = function(termXML) {
/*
* parses attributes and children for a CSL field
*/
Scholar.CSL.prototype._parseFieldAttrChildren = function(element, desc, ignoreChildren) {
Zotero.CSL.prototype._parseFieldAttrChildren = function(element, desc, ignoreChildren) {
if(!desc) {
var desc = new Object();
}
@ -504,7 +504,7 @@ Scholar.CSL.prototype._parseFieldAttrChildren = function(element, desc, ignoreCh
// add children to children array
for each(var child in children) {
if(child.namespace() == Scholar.CSL.ns) { // ignore elements in other
if(child.namespace() == Zotero.CSL.ns) { // ignore elements in other
// namespaces
// parse recursively
var name = child.localName();
@ -516,7 +516,7 @@ Scholar.CSL.prototype._parseFieldAttrChildren = function(element, desc, ignoreCh
var chooseChildren = child.choose.children();
for each(var choose in chooseChildren) {
if(choose.namespace() == Scholar.CSL.ns) {
if(choose.namespace() == Zotero.CSL.ns) {
var option = new Object();
option.name = choose.localName();
this._parseFieldAttrChildren(choose, option);
@ -542,11 +542,11 @@ Scholar.CSL.prototype._parseFieldAttrChildren = function(element, desc, ignoreCh
/*
* parses a list of fields into a defaults associative array
*/
Scholar.CSL.prototype._parseFieldDefaults = function(ref) {
Zotero.CSL.prototype._parseFieldDefaults = function(ref) {
for each(var element in ref.children()) {
if(element.namespace() == Scholar.CSL.ns) { // ignore elements in other namespaces
if(element.namespace() == Zotero.CSL.ns) { // ignore elements in other namespaces
var name = element.localName();
Scholar.debug("CSL: parsing field defaults for "+name);
Zotero.debug("CSL: parsing field defaults for "+name);
var fieldDesc = this._parseFieldAttrChildren(element);
if(this._defaults[name]) { // inherit from existing defaults
@ -562,10 +562,10 @@ Scholar.CSL.prototype._parseFieldDefaults = function(ref) {
/*
* parses a list of fields into an array of objects
*/
Scholar.CSL.prototype._parseFields = function(ref, position, type, bibCitElement, inheritFormat) {
Zotero.CSL.prototype._parseFields = function(ref, position, type, bibCitElement, inheritFormat) {
var typeDesc = new Array();
for each(var element in ref) {
if(element.namespace() == Scholar.CSL.ns) { // ignore elements in other namespaces
if(element.namespace() == Zotero.CSL.ns) { // ignore elements in other namespaces
var itemDesc = new Object();
itemDesc.name = element.localName();
@ -610,7 +610,7 @@ Scholar.CSL.prototype._parseFields = function(ref, position, type, bibCitElement
/*
* parses an et al field
*/
Scholar.CSL.prototype._parseEtAl = function(etAl, bibCitElement) {
Zotero.CSL.prototype._parseEtAl = function(etAl, bibCitElement) {
if(etAl.length()) {
bibCitElement.etAl = new Object();
@ -638,7 +638,7 @@ Scholar.CSL.prototype._parseEtAl = function(etAl, bibCitElement) {
* parses cs-format attributes into just a prefix and a suffix; accepts an
* optional array of cs-format
*/
Scholar.CSL.prototype._parseBibliographyOptions = function() {
Zotero.CSL.prototype._parseBibliographyOptions = function() {
if(!this._csl.bibliography.length()) {
return;
}
@ -702,7 +702,7 @@ Scholar.CSL.prototype._parseBibliographyOptions = function() {
* parses cs-format attributes into just a prefix and a suffix; accepts an
* optional array of cs-format
*/
Scholar.CSL.prototype._parseCitationOptions = function() {
Zotero.CSL.prototype._parseCitationOptions = function() {
var citation = this._csl.citation;
this._cit = new Object();
@ -723,8 +723,8 @@ Scholar.CSL.prototype._parseCitationOptions = function() {
* determine available reference types and add their XML objects to the tree
* (they will be parsed on the fly when necessary; see _parseReferenceType)
*/
Scholar.CSL.prototype._parseTypes = function(itemElements, bibCitElement) {
Scholar.debug("CSL: parsing item elements");
Zotero.CSL.prototype._parseTypes = function(itemElements, bibCitElement) {
Zotero.debug("CSL: parsing item elements");
bibCitElement._types = new Object();
bibCitElement._serializations = new Object();
@ -764,7 +764,7 @@ Scholar.CSL.prototype._parseTypes = function(itemElements, bibCitElement) {
/*
* convert reference types to native structures for speed
*/
Scholar.CSL.prototype._getTypeObject = function(position, reftype, bibCitElement) {
Zotero.CSL.prototype._getTypeObject = function(position, reftype, bibCitElement) {
if(!bibCitElement._types[position][reftype]) {
// no type available
return false;
@ -772,20 +772,20 @@ Scholar.CSL.prototype._getTypeObject = function(position, reftype, bibCitElement
// parse type if necessary
if(typeof(bibCitElement._types[position][reftype]) == "xml") {
Scholar.debug("CSL: parsing XML for "+reftype);
Zotero.debug("CSL: parsing XML for "+reftype);
bibCitElement._types[position][reftype] = this._parseFields(
bibCitElement._types[position][reftype].children(),
position, reftype, bibCitElement, true);
}
Scholar.debug("CSL: got object for "+reftype);
Zotero.debug("CSL: got object for "+reftype);
return bibCitElement._types[position][reftype];
}
/*
* merges two elements, letting the second override the first
*/
Scholar.CSL.prototype._merge = function(element1, element2) {
Zotero.CSL.prototype._merge = function(element1, element2) {
var mergedElement = new Object();
for(var i in element1) {
mergedElement[i] = element1[i];
@ -800,11 +800,11 @@ Scholar.CSL.prototype._merge = function(element1, element2) {
* gets defaults for a specific element; handles various inheritance rules
* (contributor, locator)
*/
Scholar.CSL.prototype._getFieldDefaults = function(elementName) {
Zotero.CSL.prototype._getFieldDefaults = function(elementName) {
// first, see if there are specific defaults
if(this._defaults[elementName]) {
if(Scholar.CSL._inherit[elementName]) {
var inheritedDefaults = this._getFieldDefaults(Scholar.CSL._inherit[elementName]);
if(Zotero.CSL._inherit[elementName]) {
var inheritedDefaults = this._getFieldDefaults(Zotero.CSL._inherit[elementName]);
for(var i in inheritedDefaults) { // will only be called if there
// is merging necessary
return this._merge(inheritedDefaults, this._defaults[elementName]);
@ -813,8 +813,8 @@ Scholar.CSL.prototype._getFieldDefaults = function(elementName) {
return this._defaults[elementName];
}
// next, try to get defaults from the item from which this item inherits
if(Scholar.CSL._inherit[elementName]) {
return this._getFieldDefaults(Scholar.CSL._inherit[elementName]);
if(Zotero.CSL._inherit[elementName]) {
return this._getFieldDefaults(Zotero.CSL._inherit[elementName]);
}
// finally, return an empty object
return {};
@ -823,7 +823,7 @@ Scholar.CSL.prototype._getFieldDefaults = function(elementName) {
/*
* gets a term, in singular or plural form
*/
Scholar.CSL.prototype._getTerm = function(term, plural, form) {
Zotero.CSL.prototype._getTerm = function(term, plural, form) {
if(!form) {
form = "long";
}
@ -846,7 +846,7 @@ Scholar.CSL.prototype._getTerm = function(term, plural, form) {
/*
* escapes a string for a given format
*/
Scholar.CSL.prototype._escapeString = function(string, format) {
Zotero.CSL.prototype._escapeString = function(string, format) {
if(format == "HTML") {
// replace HTML entities
string = string.replace(/&/g, "&amp;");
@ -880,7 +880,7 @@ Scholar.CSL.prototype._escapeString = function(string, format) {
/*
* formats a string according to the cs-format attributes on element
*/
Scholar.CSL.prototype._formatString = function(element, string, format, dontEscape) {
Zotero.CSL.prototype._formatString = function(element, string, format, dontEscape) {
if(!string) return "";
if(typeof(string) != "string") {
string = string.toString();
@ -958,7 +958,7 @@ Scholar.CSL.prototype._formatString = function(element, string, format, dontEsca
* formats a locator (pages, volume, issue) or an identifier (isbn, doi)
* note that label should be null for an identifier
*/
Scholar.CSL.prototype._formatLocator = function(identifier, element, number, format) {
Zotero.CSL.prototype._formatLocator = function(identifier, element, number, format) {
var data = "";
if(number) {
@ -990,7 +990,7 @@ Scholar.CSL.prototype._formatLocator = function(identifier, element, number, for
* format the date in format supplied by element from the date object
* returned by this._processDate
*/
Scholar.CSL.prototype._formatDate = function(element, date, format) {
Zotero.CSL.prototype._formatDate = function(element, date, format) {
if(format == "disambiguate") {
// for disambiguation, return only the year
return date.year;
@ -1047,7 +1047,7 @@ Scholar.CSL.prototype._formatDate = function(element, date, format) {
* serializes an element into a string suitable to prevent substitutes from
* recurring in the same style
*/
Scholar.CSL.prototype._serializeElement = function(name, element) {
Zotero.CSL.prototype._serializeElement = function(name, element) {
var string = name;
if(element.relation) {
string += " relation:"+element.relation;
@ -1061,7 +1061,7 @@ Scholar.CSL.prototype._serializeElement = function(name, element) {
/*
* pads a number or other string with a given string on the left
*/
Scholar.CSL.prototype._lpad = function(string, pad, length) {
Zotero.CSL.prototype._lpad = function(string, pad, length) {
while(string.length < length) {
string = pad + string;
}
@ -1071,7 +1071,7 @@ Scholar.CSL.prototype._lpad = function(string, pad, length) {
/*
* handles sorting of items
*/
Scholar.CSL.prototype._compareItem = function(a, b, opt) {
Zotero.CSL.prototype._compareItem = function(a, b, opt) {
for(var i in this._bib.sortOrder) {
var sortElement = this._bib.sortOrder[i];
@ -1094,7 +1094,7 @@ Scholar.CSL.prototype._compareItem = function(a, b, opt) {
* process creator objects; if someone had a creator model that handled
* non-Western names better than ours, this would be the function to change
*/
Scholar.CSL.prototype._processCreators = function(type, element, creators, format, bibCitElement) {
Zotero.CSL.prototype._processCreators = function(type, element, creators, format, bibCitElement) {
var maxCreators = creators.length;
if(!maxCreators) return;
@ -1201,8 +1201,8 @@ Scholar.CSL.prototype._processCreators = function(type, element, creators, forma
/*
* get a citation, given an item and bibCitElement
*/
Scholar.CSL.prototype._getCitation = function(item, position, locatorType, locator, format, bibCitElement) {
Scholar.debug("CSL: generating citation for item "+item.getID());
Zotero.CSL.prototype._getCitation = function(item, position, locatorType, locator, format, bibCitElement) {
Zotero.debug("CSL: generating citation for item "+item.getID());
if(!bibCitElement._types[position]) {
position = "first";
@ -1226,7 +1226,7 @@ Scholar.CSL.prototype._getCitation = function(item, position, locatorType, locat
if(!type) {
return false;
}
Scholar.debug("CSL: using CSL type "+typeName);
Zotero.debug("CSL: using CSL type "+typeName);
// remove previous ignore entries from list
this._ignore = new Array();
@ -1244,7 +1244,7 @@ Scholar.CSL.prototype._getCitation = function(item, position, locatorType, locat
/*
* processes an element from a (pre-processed) item into text
*/
Scholar.CSL.prototype._getFieldValue = function(name, element, item, format,
Zotero.CSL.prototype._getFieldValue = function(name, element, item, format,
bibCitElement, position,
locatorType, locator, typeName) {
var data = "";
@ -1404,8 +1404,8 @@ Scholar.CSL.prototype._getFieldValue = function(name, element, item, format,
substituteElement);
var inheritElement;
if(Scholar.CSL._inherit[substituteElement.name] && Scholar.CSL._inherit[name]
&& Scholar.CSL._inherit[substituteElement.name] == Scholar.CSL._inherit[name]) {
if(Zotero.CSL._inherit[substituteElement.name] && Zotero.CSL._inherit[name]
&& Zotero.CSL._inherit[substituteElement.name] == Zotero.CSL._inherit[name]) {
// if both substituteElement and the parent element inherit from
// the same base element, apply styles here
inheritElement = element;
@ -1453,10 +1453,10 @@ Scholar.CSL.prototype._getFieldValue = function(name, element, item, format,
}
/*
* THE FOLLOWING CODE IS SCHOLAR-SPECIFIC
* THE FOLLOWING CODE IS ZOTERO-SPECIFIC
* gets a list of possible CSL types, in order of preference, for an item
*/
Scholar.CSL._optionalTypeMappings = {
Zotero.CSL._optionalTypeMappings = {
journalArticle:"article-journal",
magazineArticle:"article-magazine",
newspaperArticle:"article-newspaper",
@ -1469,7 +1469,7 @@ Scholar.CSL.prototype._getFieldValue = function(name, element, item, format,
webpage:"webpage"
};
// TODO: check with Elena/APA/MLA on this
Scholar.CSL._fallbackTypeMappings = {
Zotero.CSL._fallbackTypeMappings = {
book:"book",
bookSection:"chapter",
journalArticle:"article",
@ -1484,25 +1484,25 @@ Scholar.CSL._fallbackTypeMappings = {
webpage:"article"
};
Scholar.CSL.prototype._getTypeFromItem = function(item) {
var scholarType = Scholar.ItemTypes.getName(item.getType());
Zotero.CSL.prototype._getTypeFromItem = function(item) {
var zoteroType = Zotero.ItemTypes.getName(item.getType());
// get type
Scholar.debug("CSL: parsing item of Scholar type "+scholarType);
return [Scholar.CSL._optionalTypeMappings[scholarType], Scholar.CSL._fallbackTypeMappings[scholarType]];
Zotero.debug("CSL: parsing item of Zotero type "+zoteroType);
return [Zotero.CSL._optionalTypeMappings[zoteroType], Zotero.CSL._fallbackTypeMappings[zoteroType]];
}
/*
* separate creators object into authors, editors, and translators
*/
Scholar.CSL.prototype._separateItemCreators = function(item) {
Zotero.CSL.prototype._separateItemCreators = function(item) {
var authors = new Array();
var editors = new Array();
var translators = new Array();
var authorID = Scholar.CreatorTypes.getID("author");
var editorID = Scholar.CreatorTypes.getID("editor");
var translatorID = Scholar.CreatorTypes.getID("translator");
var authorID = Zotero.CreatorTypes.getID("author");
var editorID = Zotero.CreatorTypes.getID("editor");
var translatorID = Zotero.CreatorTypes.getID("translator");
var creators = item.getCreators();
for(var j in creators) {
@ -1524,9 +1524,9 @@ Scholar.CSL.prototype._separateItemCreators = function(item) {
/*
* return an object containing year, month, and day
*/
Scholar.CSL.prototype._processDate = function(string) {
return Scholar.Date.strToDate(string);
Zotero.CSL.prototype._processDate = function(string) {
return Zotero.Date.strToDate(string);
}
/*
* END SCHOLAR-SPECIFIC CODE
* END ZOTERO-SPECIFIC CODE
*/

View file

@ -15,18 +15,18 @@
/*
* Constructor the the CollectionTreeView object
*/
Scholar.CollectionTreeView = function()
Zotero.CollectionTreeView = function()
{
this._treebox = null;
this.refresh();
this._unregisterID = Scholar.Notifier.registerColumnTree(this);
this._unregisterID = Zotero.Notifier.registerColumnTree(this);
}
/*
* Called by the tree itself
*/
Scholar.CollectionTreeView.prototype.setTree = function(treebox)
Zotero.CollectionTreeView.prototype.setTree = function(treebox)
{
if(this._treebox)
return;
@ -39,19 +39,19 @@ Scholar.CollectionTreeView.prototype.setTree = function(treebox)
* Reload the rows from the data access methods
* (doesn't call the tree.invalidate methods, etc.)
*/
Scholar.CollectionTreeView.prototype.refresh = function()
Zotero.CollectionTreeView.prototype.refresh = function()
{
this._dataItems = new Array();
this.rowCount = 0;
this._showItem(new Scholar.ItemGroup('library',null),0,1);
this._showItem(new Zotero.ItemGroup('library',null),0,1);
var newRows = Scholar.getCollections();
var newRows = Zotero.getCollections();
for(var i = 0; i < newRows.length; i++)
this._showItem(new Scholar.ItemGroup('collection',newRows[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow
this._showItem(new Zotero.ItemGroup('collection',newRows[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow
var savedSearches = Scholar.Searches.getAll();
var savedSearches = Zotero.Searches.getAll();
for(var i = 0; i < savedSearches.length; i++)
this._showItem(new Scholar.ItemGroup('search',savedSearches[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow
this._showItem(new Zotero.ItemGroup('search',savedSearches[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow
this._refreshHashMap();
}
@ -59,7 +59,7 @@ Scholar.CollectionTreeView.prototype.refresh = function()
/*
* Redisplay everything
*/
Scholar.CollectionTreeView.prototype.reload = function()
Zotero.CollectionTreeView.prototype.reload = function()
{
var openCollections = new Array();
@ -83,12 +83,12 @@ Scholar.CollectionTreeView.prototype.reload = function()
}
/*
* Called by Scholar.Notifier on any changes to collections in the data layer
* Called by Zotero.Notifier on any changes to collections in the data layer
*/
Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
{
var madeChanges = false;
var ids = Scholar.flattenArguments(ids);
var ids = Zotero.flattenArguments(ids);
if(action == 'remove')
{
@ -154,7 +154,7 @@ Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
// Search rows aren't mapped to native objects, so we
// have to pull the new data manually
this._getItemAtRow(this._searchRowMap[ids[i]]).ref =
Scholar.Searches.get(ids[i]);
Zotero.Searches.get(ids[i]);
this._treebox.invalidateRow(this._searchRowMap[ids[i]]);
}
break;
@ -169,13 +169,13 @@ Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
switch (type)
{
case 'collection':
var item = Scholar.Collections.get(ids);
this._showItem(new Scholar.ItemGroup('collection',item), 0, this.rowCount);
var item = Zotero.Collections.get(ids);
this._showItem(new Zotero.ItemGroup('collection',item), 0, this.rowCount);
break;
case 'search':
var search = Scholar.Searches.get(ids);
this._showItem(new Scholar.ItemGroup('search', search), 0, this.rowCount);
var search = Zotero.Searches.get(ids);
this._showItem(new Zotero.ItemGroup('search', search), 0, this.rowCount);
break;
}
@ -189,24 +189,24 @@ Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
}
/*
* Unregisters view from Scholar.Notifier (called on window close)
* Unregisters view from Zotero.Notifier (called on window close)
*/
Scholar.CollectionTreeView.prototype.unregister = function()
Zotero.CollectionTreeView.prototype.unregister = function()
{
Scholar.Notifier.unregisterColumnTree(this._unregisterID);
Zotero.Notifier.unregisterColumnTree(this._unregisterID);
}
Scholar.CollectionTreeView.prototype.isLibrary = function(row)
Zotero.CollectionTreeView.prototype.isLibrary = function(row)
{
return this._getItemAtRow(row).isLibrary();
}
Scholar.CollectionTreeView.prototype.isCollection = function(row)
Zotero.CollectionTreeView.prototype.isCollection = function(row)
{
return this._getItemAtRow(row).isCollection();
}
Scholar.CollectionTreeView.prototype.isSearch = function(row)
Zotero.CollectionTreeView.prototype.isSearch = function(row)
{
return this._getItemAtRow(row).isSearch();
}
@ -219,7 +219,7 @@ Scholar.CollectionTreeView.prototype.isSearch = function(row)
///
////////////////////////////////////////////////////////////////////////////////
Scholar.CollectionTreeView.prototype.getCellText = function(row, column)
Zotero.CollectionTreeView.prototype.getCellText = function(row, column)
{
var obj = this._getItemAtRow(row);
@ -229,23 +229,23 @@ Scholar.CollectionTreeView.prototype.getCellText = function(row, column)
return "";
}
Scholar.CollectionTreeView.prototype.getImageSrc = function(row, col)
Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col)
{
var collectionType = this._getItemAtRow(row).type;
return "chrome://scholar/skin/treesource-" + collectionType + ".png";
return "chrome://zotero/skin/treesource-" + collectionType + ".png";
}
Scholar.CollectionTreeView.prototype.isContainer = function(row)
Zotero.CollectionTreeView.prototype.isContainer = function(row)
{
return this._getItemAtRow(row).isCollection();
}
Scholar.CollectionTreeView.prototype.isContainerOpen = function(row)
Zotero.CollectionTreeView.prototype.isContainerOpen = function(row)
{
return this._dataItems[row][1];
}
Scholar.CollectionTreeView.prototype.isContainerEmpty = function(row)
Zotero.CollectionTreeView.prototype.isContainerEmpty = function(row)
{
//NOTE: this returns true if the collection has no child collections
@ -256,12 +256,12 @@ Scholar.CollectionTreeView.prototype.isContainerEmpty = function(row)
return true;
}
Scholar.CollectionTreeView.prototype.getLevel = function(row)
Zotero.CollectionTreeView.prototype.getLevel = function(row)
{
return this._dataItems[row][2];
}
Scholar.CollectionTreeView.prototype.getParentIndex = function(row)
Zotero.CollectionTreeView.prototype.getParentIndex = function(row)
{
var thisLevel = this.getLevel(row);
if(thisLevel == 0) return -1;
@ -271,7 +271,7 @@ Scholar.CollectionTreeView.prototype.getParentIndex = function(row)
return -1;
}
Scholar.CollectionTreeView.prototype.hasNextSibling = function(row, afterIndex)
Zotero.CollectionTreeView.prototype.hasNextSibling = function(row, afterIndex)
{
var thisLevel = this.getLevel(row);
for(var i = afterIndex + 1; i < this.rowCount; i++)
@ -285,7 +285,7 @@ Scholar.CollectionTreeView.prototype.hasNextSibling = function(row, afterIndex)
/*
* Opens/closes the specified row
*/
Scholar.CollectionTreeView.prototype.toggleOpenState = function(row)
Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
{
var count = 0; //used to tell the tree how many rows were added/removed
var thisLevel = this.getLevel(row);
@ -301,12 +301,12 @@ Scholar.CollectionTreeView.prototype.toggleOpenState = function(row)
}
else
{
var newRows = Scholar.getCollections(this._getItemAtRow(row).ref.getID()); //Get children
var newRows = Zotero.getCollections(this._getItemAtRow(row).ref.getID()); //Get children
for(var i = 0; i < newRows.length; i++)
{
count++;
this._showItem(new Scholar.ItemGroup('collection',newRows[i]), thisLevel+1, row+i+1); //insert new row
this._showItem(new Zotero.ItemGroup('collection',newRows[i]), thisLevel+1, row+i+1); //insert new row
}
}
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
@ -326,7 +326,7 @@ Scholar.CollectionTreeView.prototype.toggleOpenState = function(row)
/*
* Delete the selection
*/
Scholar.CollectionTreeView.prototype.deleteSelection = function()
Zotero.CollectionTreeView.prototype.deleteSelection = function()
{
if(this.selection.count == 0)
return;
@ -361,7 +361,7 @@ Scholar.CollectionTreeView.prototype.deleteSelection = function()
}
else if(group.isSearch())
{
Scholar.Searches.erase(group.ref['id']);
Zotero.Searches.erase(group.ref['id']);
}
}
this._treebox.endUpdateBatch();
@ -379,7 +379,7 @@ Scholar.CollectionTreeView.prototype.deleteSelection = function()
* level: the indent level of the row
* beforeRow: row index to insert new row before
*/
Scholar.CollectionTreeView.prototype._showItem = function(itemGroup, level, beforeRow)
Zotero.CollectionTreeView.prototype._showItem = function(itemGroup, level, beforeRow)
{
this._dataItems.splice(beforeRow, 0, [itemGroup, false, level]); this.rowCount++;
}
@ -387,15 +387,15 @@ Scholar.CollectionTreeView.prototype._showItem = function(itemGroup, level, befo
/*
* Called by view to hide specified row
*/
Scholar.CollectionTreeView.prototype._hideItem = function(row)
Zotero.CollectionTreeView.prototype._hideItem = function(row)
{
this._dataItems.splice(row,1); this.rowCount--;
}
/*
* Returns a reference to the collection at row (see Scholar.Collection in data_access.js)
* Returns a reference to the collection at row (see Zotero.Collection in data_access.js)
*/
Scholar.CollectionTreeView.prototype._getItemAtRow = function(row)
Zotero.CollectionTreeView.prototype._getItemAtRow = function(row)
{
return this._dataItems[row][0];
}
@ -404,7 +404,7 @@ Scholar.CollectionTreeView.prototype._getItemAtRow = function(row)
* Creates hash map of collection and search ids to row indexes
* e.g., var rowForID = this._collectionRowMap[]
*/
Scholar.CollectionTreeView.prototype._refreshHashMap = function()
Zotero.CollectionTreeView.prototype._refreshHashMap = function()
{
this._collectionRowMap = [];
this._searchRowMap = [];
@ -425,24 +425,24 @@ Scholar.CollectionTreeView.prototype._refreshHashMap = function()
///
////////////////////////////////////////////////////////////////////////////////
Scholar.CollectionTreeCommandController = function(tree)
Zotero.CollectionTreeCommandController = function(tree)
{
this.tree = tree;
}
Scholar.CollectionTreeCommandController.prototype.supportsCommand = function(cmd)
Zotero.CollectionTreeCommandController.prototype.supportsCommand = function(cmd)
{
}
Scholar.CollectionTreeCommandController.prototype.isCommandEnabled = function(cmd)
Zotero.CollectionTreeCommandController.prototype.isCommandEnabled = function(cmd)
{
}
Scholar.CollectionTreeCommandController.prototype.doCommand = function(cmd)
Zotero.CollectionTreeCommandController.prototype.doCommand = function(cmd)
{
}
Scholar.CollectionTreeCommandController.prototype.onEvent = function(evt)
Zotero.CollectionTreeCommandController.prototype.onEvent = function(evt)
{
}
@ -457,7 +457,7 @@ Scholar.CollectionTreeCommandController.prototype.onEvent = function(evt)
/*
* Called while a drag is over the tree.
*/
Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
Zotero.CollectionTreeView.prototype.canDrop = function(row, orient)
{
if(typeof row == 'object') //workaround... two different services call canDrop (nsDragAndDrop, and the tree)
return false;
@ -478,7 +478,7 @@ Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
var dataType = data.flavour.contentType;
//Highlight the rows correctly on drag:
if(orient == 1 && row == 0 && dataType == 'scholar/collection') //for dropping collections into root level
if(orient == 1 && row == 0 && dataType == 'zotero/collection') //for dropping collections into root level
{
return true;
}
@ -486,12 +486,12 @@ Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
{
var rowCollection = this._getItemAtRow(row).ref; //the collection we are dragging over
if(dataType == 'scholar/item' || dataType == "text/x-moz-url")
if(dataType == 'zotero/item' || dataType == "text/x-moz-url")
{
var ids = data.data.split(',');
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
// Can only drag top-level items into collections
if (item.isRegularItem() || !item.getSource())
{
@ -505,7 +505,7 @@ Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
}
return false;
}
else if(dataType='scholar/collection' && data.data != rowCollection.getID() && !Scholar.Collections.get(data.data).hasDescendent('collection',rowCollection.getID()) )
else if(dataType='zotero/collection' && data.data != rowCollection.getID() && !Zotero.Collections.get(data.data).hasDescendent('collection',rowCollection.getID()) )
return true; //collections cannot be dropped on themselves, nor in their children
}
return false;
@ -514,20 +514,20 @@ Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
/*
* Called when something's been dropped on or next to a row
*/
Scholar.CollectionTreeView.prototype.drop = function(row, orient)
Zotero.CollectionTreeView.prototype.drop = function(row, orient)
{
var dataSet = nsTransferable.get(this.getSupportedFlavours(),nsDragAndDrop.getDragData, true);
var data = dataSet.first.first;
var dataType = data.flavour.contentType;
if(dataType == 'scholar/collection')
if(dataType == 'zotero/collection')
{
var oldCount = this.rowCount;
var targetCollectionID;
if(this._getItemAtRow(row).isCollection())
targetCollectionID = this._getItemAtRow(row).ref.getID();
var droppedCollection = Scholar.Collections.get(data.data);
var droppedCollection = Zotero.Collections.get(data.data);
droppedCollection.changeParent(targetCollectionID);
var selectRow = this._collectionRowMap[data.data];
@ -540,13 +540,13 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
this.selection.selectEventsSuppressed = false;
}
else if(dataType == 'scholar/item' && this.canDrop(row, orient))
else if(dataType == 'zotero/item' && this.canDrop(row, orient))
{
var ids = data.data.split(',');
var targetCollection = this._getItemAtRow(row).ref;
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
// Only accept top-level items
if (item.isRegularItem() || !item.getSource())
{
@ -559,7 +559,7 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
var url = data.data.split("\n")[0];
/* WAITING FOR INGESTER SUPPORT
var newItem = Scholar.Ingester.scrapeURL(url);
var newItem = Zotero.Ingester.scrapeURL(url);
if(newItem)
this._getItemAtRow(row).ref.addItem(newItem.getID());
@ -570,30 +570,30 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
/*
* Begin a drag
*/
Scholar.CollectionTreeView.prototype.onDragStart = function(evt,transferData,action)
Zotero.CollectionTreeView.prototype.onDragStart = function(evt,transferData,action)
{
transferData.data=new TransferData();
//attach ID
transferData.data.addDataForFlavour("scholar/collection",this._getItemAtRow(this.selection.currentIndex).ref.getID());
transferData.data.addDataForFlavour("zotero/collection",this._getItemAtRow(this.selection.currentIndex).ref.getID());
}
/*
* Returns the supported drag flavors
*/
Scholar.CollectionTreeView.prototype.getSupportedFlavours = function ()
Zotero.CollectionTreeView.prototype.getSupportedFlavours = function ()
{
var flavors = new FlavourSet();
flavors.appendFlavour("text/x-moz-url");
flavors.appendFlavour("scholar/item");
flavors.appendFlavour("scholar/collection");
flavors.appendFlavour("zotero/item");
flavors.appendFlavour("zotero/collection");
return flavors;
}
/*
* Called by nsDragAndDrop.js for any sort of drop on the tree
*/
Scholar.CollectionTreeView.prototype.onDrop = function (evt,dropdata,session) { }
Zotero.CollectionTreeView.prototype.onDrop = function (evt,dropdata,session) { }
////////////////////////////////////////////////////////////////////////////////
///
@ -601,62 +601,62 @@ Scholar.CollectionTreeView.prototype.onDrop = function (evt,dropdata,session) {
///
////////////////////////////////////////////////////////////////////////////////
Scholar.CollectionTreeView.prototype.isSorted = function() { return false; }
Scholar.CollectionTreeView.prototype.isSeparator = function(row) { return false; }
Scholar.CollectionTreeView.prototype.isEditable = function(row, idx) { return false; }
Scholar.CollectionTreeView.prototype.getRowProperties = function(row, prop) { }
Scholar.CollectionTreeView.prototype.getColumnProperties = function(col, prop) { }
Scholar.CollectionTreeView.prototype.getCellProperties = function(row, col, prop) { }
Scholar.CollectionTreeView.prototype.performAction = function(action) { }
Scholar.CollectionTreeView.prototype.performActionOnCell = function(action, row, col) { }
Scholar.CollectionTreeView.prototype.getProgressMode = function(row, col) { }
Scholar.CollectionTreeView.prototype.cycleHeader = function(column) { }
Zotero.CollectionTreeView.prototype.isSorted = function() { return false; }
Zotero.CollectionTreeView.prototype.isSeparator = function(row) { return false; }
Zotero.CollectionTreeView.prototype.isEditable = function(row, idx) { return false; }
Zotero.CollectionTreeView.prototype.getRowProperties = function(row, prop) { }
Zotero.CollectionTreeView.prototype.getColumnProperties = function(col, prop) { }
Zotero.CollectionTreeView.prototype.getCellProperties = function(row, col, prop) { }
Zotero.CollectionTreeView.prototype.performAction = function(action) { }
Zotero.CollectionTreeView.prototype.performActionOnCell = function(action, row, col) { }
Zotero.CollectionTreeView.prototype.getProgressMode = function(row, col) { }
Zotero.CollectionTreeView.prototype.cycleHeader = function(column) { }
////////////////////////////////////////////////////////////////////////////////
///
/// Scholar ItemGroup -- a sort of "super class" for collection, library,
/// Zotero ItemGroup -- a sort of "super class" for collection, library,
/// and saved search
///
////////////////////////////////////////////////////////////////////////////////
Scholar.ItemGroup = function(type, ref)
Zotero.ItemGroup = function(type, ref)
{
this.type = type;
this.ref = ref;
}
Scholar.ItemGroup.prototype.isLibrary = function()
Zotero.ItemGroup.prototype.isLibrary = function()
{
return this.type == 'library';
}
Scholar.ItemGroup.prototype.isCollection = function()
Zotero.ItemGroup.prototype.isCollection = function()
{
return this.type == 'collection';
}
Scholar.ItemGroup.prototype.isSearch = function()
Zotero.ItemGroup.prototype.isSearch = function()
{
return this.type == 'search';
}
Scholar.ItemGroup.prototype.getName = function()
Zotero.ItemGroup.prototype.getName = function()
{
if(this.isCollection())
return this.ref.getName();
else if(this.isLibrary())
return Scholar.getString('pane.collections.library');
return Zotero.getString('pane.collections.library');
else if(this.isSearch())
return this.ref['name'];
else
return "";
}
Scholar.ItemGroup.prototype.getChildItems = function()
Zotero.ItemGroup.prototype.getChildItems = function()
{
if(this.searchText)
{
var s = new Scholar.Search();
var s = new Zotero.Search();
if (this.isCollection())
{
s.addCondition('collectionID', 'is', this.ref.getID(), true);
@ -666,26 +666,26 @@ Scholar.ItemGroup.prototype.getChildItems = function()
s.addCondition('savedSearchID', 'is', this.ref['id'], true);
}
s.addCondition('quicksearch', 'contains', this.searchText);
return Scholar.Items.get(s.search());
return Zotero.Items.get(s.search());
}
else
{
if(this.isCollection())
return Scholar.getItems(this.ref.getID());
return Zotero.getItems(this.ref.getID());
else if(this.isLibrary())
return Scholar.getItems();
return Zotero.getItems();
else if(this.isSearch())
{
var s = new Scholar.Search();
var s = new Zotero.Search();
s.load(this.ref['id']);
return Scholar.Items.get(s.search());
return Zotero.Items.get(s.search());
}
else
return null;
}
}
Scholar.ItemGroup.prototype.setSearch = function(searchText)
Zotero.ItemGroup.prototype.setSearch = function(searchText)
{
this.searchText = searchText;
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/*
* DB connection and schema management class
*/
Scholar.DB = new function(){
Zotero.DB = new function(){
// Private members
var _connection;
var _transactionRollback;
@ -78,7 +78,7 @@ Scholar.DB = new function(){
statement.execute();
}
else {
Scholar.debug(sql,5);
Zotero.debug(sql,5);
db.executeSimpleSQL(sql);
}
@ -160,7 +160,7 @@ Scholar.DB = new function(){
var db = _getDBConnection();
try {
Scholar.debug(sql,5);
Zotero.debug(sql,5);
var statement = db.createStatement(sql);
}
catch (e){
@ -207,7 +207,7 @@ Scholar.DB = new function(){
}
else {
throw('Invalid bound parameter ' + params[i] +
' in ' + Scholar.varDump(params));
' in ' + Zotero.varDump(params));
}
}
var value = params[i];
@ -216,19 +216,19 @@ Scholar.DB = new function(){
// Bind the parameter as the correct type
switch (type){
case 'int':
Scholar.debug('Binding parameter ' + (i+1)
Zotero.debug('Binding parameter ' + (i+1)
+ ' of type int: ' + value, 5);
statement.bindInt32Parameter(i, value);
break;
case 'string':
Scholar.debug('Binding parameter ' + (i+1)
Zotero.debug('Binding parameter ' + (i+1)
+ ' of type string: "' + value + '"', 5);
statement.bindUTF8StringParameter(i, value);
break;
case 'null':
Scholar.debug('Binding parameter ' + (i+1)
Zotero.debug('Binding parameter ' + (i+1)
+ ' of type NULL', 5);
statement.bindNullParameter(i);
break;
@ -262,11 +262,11 @@ Scholar.DB = new function(){
if (db.transactionInProgress){
_transactionNestingLevel++;
Scholar.debug('Transaction in progress -- increasing level to '
Zotero.debug('Transaction in progress -- increasing level to '
+ _transactionNestingLevel, 5);
}
else {
Scholar.debug('Beginning DB transaction', 5);
Zotero.debug('Beginning DB transaction', 5);
db.beginTransaction();
}
}
@ -277,14 +277,14 @@ Scholar.DB = new function(){
if (_transactionNestingLevel){
_transactionNestingLevel--;
Scholar.debug('Decreasing transaction level to ' + _transactionNestingLevel, 5);
Zotero.debug('Decreasing transaction level to ' + _transactionNestingLevel, 5);
}
else if (_transactionRollback){
Scholar.debug('Rolling back previously flagged transaction', 5);
Zotero.debug('Rolling back previously flagged transaction', 5);
db.rollbackTransaction();
}
else {
Scholar.debug('Committing transaction',5);
Zotero.debug('Committing transaction',5);
try {
db.commitTransaction();
}
@ -301,11 +301,11 @@ Scholar.DB = new function(){
var db = _getDBConnection();
if (_transactionNestingLevel){
Scholar.debug('Flagging nested transaction for rollback', 5);
Zotero.debug('Flagging nested transaction for rollback', 5);
_transactionRollback = true;
}
else {
Scholar.debug('Rolling back transaction', 5);
Zotero.debug('Rolling back transaction', 5);
_transactionRollback = false;
try {
db.rollbackTransaction();
@ -344,7 +344,7 @@ Scholar.DB = new function(){
return cols;
}
catch (e){
Scholar.debug(e,1);
Zotero.debug(e,1);
return false;
}
}
@ -370,7 +370,7 @@ Scholar.DB = new function(){
**/
function getNextID(table, column){
var sql = 'SELECT ' + column + ' FROM ' + table + ' ORDER BY ' + column;
var vals = Scholar.DB.columnQuery(sql);
var vals = Zotero.DB.columnQuery(sql);
if (!vals){
return 1;
@ -402,7 +402,7 @@ Scholar.DB = new function(){
{
var sql = "SELECT " + field + " FROM " + table + " WHERE " + field
+ " LIKE ? ORDER BY " + field;
var untitleds = Scholar.DB.columnQuery(sql, name + '%');
var untitleds = Zotero.DB.columnQuery(sql, name + '%');
if (!untitleds || untitleds[0]!=name){
return name;
@ -412,7 +412,7 @@ Scholar.DB = new function(){
var num = 2;
while (untitleds[i] && untitleds[i]==(name + ' ' + num)){
while (untitleds[i+1] && untitleds[i]==untitleds[i+1]){
Scholar.debug('Next ' + i + ' is ' + untitleds[i]);
Zotero.debug('Next ' + i + ' is ' + untitleds[i]);
i++;
}
@ -443,10 +443,10 @@ Scholar.DB = new function(){
var store = Components.classes["@mozilla.org/storage/service;1"].
getService(Components.interfaces.mozIStorageService);
var file = Scholar.getScholarDatabase();
var backupFile = Scholar.getScholarDatabase('bak');
var file = Zotero.getZoteroDatabase();
var backupFile = Zotero.getZoteroDatabase('bak');
if (SCHOLAR_CONFIG['DB_REBUILD']){
if (ZOTERO_CONFIG['DB_REBUILD']){
if (confirm('Erase all user data and recreate database from schema?')){
// Delete existing Zotero database
if (file.exists()){
@ -454,7 +454,7 @@ Scholar.DB = new function(){
}
// Delete existing storage folder
var dir = Scholar.getStorageDirectory();
var dir = Zotero.getStorageDirectory();
if (dir.exists()){
dir.remove(true);
}
@ -468,7 +468,7 @@ Scholar.DB = new function(){
_connection = store.openDatabase(backupFile);
}
catch (e){
Scholar.debug('Backup file was corrupt', 1);
Zotero.debug('Backup file was corrupt', 1);
}
_connection = undefined;
}
@ -478,29 +478,29 @@ Scholar.DB = new function(){
}
catch (e){
if (e.name=='NS_ERROR_FILE_CORRUPTED'){
Scholar.debug('Database file corrupted', 1);
Zotero.debug('Database file corrupted', 1);
// No backup file! Eek!
if (!backupFile.exists()){
Scholar.debug('No backup file exists', 1);
Zotero.debug('No backup file exists', 1);
// Save damaged filed
Scholar.debug('Saving damaged DB file with .damaged extension', 1);
var damagedFile = Scholar.getScholarDatabase('damaged');
Scholar.moveToUnique(file, damagedFile);
Zotero.debug('Saving damaged DB file with .damaged extension', 1);
var damagedFile = Zotero.getZoteroDatabase('damaged');
Zotero.moveToUnique(file, damagedFile);
// Create new main database
var file = Scholar.getScholarDatabase();
var file = Zotero.getZoteroDatabase();
_connection = store.openDatabase(file);
alert(Scholar.getString('db.dbCorruptedNoBackup'));
alert(Zotero.getString('db.dbCorruptedNoBackup'));
break catchBlock;
}
// Save damaged file
Scholar.debug('Saving damaged DB file with .damaged extension', 1);
var damagedFile = Scholar.getScholarDatabase('damaged');
Scholar.moveToUnique(file, damagedFile);
Zotero.debug('Saving damaged DB file with .damaged extension', 1);
var damagedFile = Zotero.getZoteroDatabase('damaged');
Zotero.moveToUnique(file, damagedFile);
// Test the backup file
try {
@ -509,19 +509,19 @@ Scholar.DB = new function(){
// Can't open backup either
catch (e){
// Create new main database
var file = Scholar.getScholarDatabase();
var file = Zotero.getZoteroDatabase();
_connection = store.openDatabase(file);
alert(Scholar.getString('db.dbRestoreFailed'));
alert(Zotero.getString('db.dbRestoreFailed'));
break catchBlock;
}
_connection = undefined;
// Copy backup file to main DB file
Scholar.debug('Restoring main database from backup file', 1);
Zotero.debug('Restoring main database from backup file', 1);
try {
backupFile.copyTo(backupFile.parent, SCHOLAR_CONFIG['DB_FILE']);
backupFile.copyTo(backupFile.parent, ZOTERO_CONFIG['DB_FILE']);
}
catch (e){
// TODO: deal with low disk space
@ -529,13 +529,13 @@ Scholar.DB = new function(){
}
// Open restored database
var file = Scholar.getScholarDirectory();
file.append(SCHOLAR_CONFIG['DB_FILE']);
var file = Zotero.getZoteroDirectory();
file.append(ZOTERO_CONFIG['DB_FILE']);
_connection = store.openDatabase(file);
Scholar.debug('Database restored', 1);
var msg = Scholar.getString('db.dbRestored');
msg = msg.replace('%1', Scholar.Date.getFileDateString(backupFile))
msg = msg.replace('%2', Scholar.Date.getFileTimeString(backupFile))
Zotero.debug('Database restored', 1);
var msg = Zotero.getString('db.dbRestored');
msg = msg.replace('%1', Zotero.Date.getFileDateString(backupFile))
msg = msg.replace('%2', Zotero.Date.getFileTimeString(backupFile))
alert(msg);
break catchBlock;

View file

@ -1,4 +1,4 @@
Scholar.File = new function(){
Zotero.File = new function(){
this.getExtension = getExtension;
this.getSample = getSample;
this.getContents = getContents;
@ -39,7 +39,7 @@ Scholar.File = new function(){
fis.init(file, false, false, false);
if (charset){
charset = Scholar.CharacterSets.getName(charset);
charset = Zotero.CharacterSets.getName(charset);
}
if (!charset){
@ -88,11 +88,11 @@ Scholar.File = new function(){
}
if (mimeType.substr(0, 5)!='text/' ||
!Scholar.MIME.hasInternalHandler(mimeType, this.getExtension(file))){
!Zotero.MIME.hasInternalHandler(mimeType, this.getExtension(file))){
return false;
}
var browser = Scholar.Browser.createHiddenBrowser();
var browser = Zotero.Browser.createHiddenBrowser();
var url = Components.classes["@mozilla.org/network/protocol;1?name=file"]
.getService(Components.interfaces.nsIFileProtocolHandler)
@ -118,23 +118,23 @@ Scholar.File = new function(){
.getService(Components.interfaces.nsIPrefBranch);
var oldPref = prefService.getCharPref('intl.charset.detector');
var newPref = 'universal_charset_detector';
//Scholar.debug("Default character detector is " + (oldPref ? oldPref : '(none)'));
//Zotero.debug("Default character detector is " + (oldPref ? oldPref : '(none)'));
if (oldPref != newPref){
//Scholar.debug('Setting character detector to universal_charset_detector');
//Zotero.debug('Setting character detector to universal_charset_detector');
prefService.setCharPref('intl.charset.detector', 'universal_charset_detector');
}
browser.addEventListener("pageshow", function(){
var charset = browser.contentDocument.characterSet;
Scholar.debug("Detected character set '" + charset + "'");
Zotero.debug("Detected character set '" + charset + "'");
//Scholar.debug('Resetting character detector to ' + (oldPref ? oldPref : '(none)'));
//Zotero.debug('Resetting character detector to ' + (oldPref ? oldPref : '(none)'));
prefService.setCharPref('intl.charset.detector', oldPref);
callback(charset, args);
Scholar.Browser.deleteHiddenBrowser(browser);
Zotero.Browser.deleteHiddenBrowser(browser);
}, false);
}
}

View file

@ -1,4 +1,4 @@
Scholar.Fulltext = new function(){
Zotero.Fulltext = new function(){
this.indexWord = indexWord;
this.indexWords = indexWords;
this.indexDocument = indexDocument;
@ -20,21 +20,21 @@ Scholar.Fulltext = new function(){
function cacheIsOutdated(){
var sql = "SELECT version FROM version WHERE schema='fulltext'";
return Scholar.DB.valueQuery(sql) < FULLTEXT_VERSION;
return Zotero.DB.valueQuery(sql) < FULLTEXT_VERSION;
}
function rebuildCache(){
Scholar.DB.beginTransaction();
Scholar.DB.query("DELETE FROM fulltextWords");
Scholar.DB.query("DELETE FROM fulltextItems");
//Scholar.DB.query("DELETE FROM fulltextContent");
Zotero.DB.beginTransaction();
Zotero.DB.query("DELETE FROM fulltextWords");
Zotero.DB.query("DELETE FROM fulltextItems");
//Zotero.DB.query("DELETE FROM fulltextContent");
var sql = "SELECT itemID FROM itemAttachments";
var items = Scholar.DB.columnQuery(sql);
var items = Zotero.DB.columnQuery(sql);
indexItems(items);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -42,20 +42,20 @@ Scholar.Fulltext = new function(){
* Index a single word
*/
function indexWord(itemID, word){
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT wordID FROM fulltextWords WHERE word=?";
var wordID = Scholar.DB.valueQuery(sql, {string:word});
var wordID = Zotero.DB.valueQuery(sql, {string:word});
if (!wordID){
var sql = "INSERT INTO fulltextWords (word) VALUES (?)";
var wordID = Scholar.DB.query(sql, {string:word});
var wordID = Zotero.DB.query(sql, {string:word});
}
var sql = "INSERT OR IGNORE INTO fulltextItems VALUES (?,?)";
Scholar.DB.query(sql, [wordID, itemID]);
Zotero.DB.query(sql, [wordID, itemID]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -75,11 +75,11 @@ Scholar.Fulltext = new function(){
sqlParams.push({string:word});
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "SELECT word, wordID from fulltextWords WHERE word IN ("
sql += sqlQues.join() + ")";
var wordIDs = Scholar.DB.query(sql, sqlParams);
var wordIDs = Zotero.DB.query(sql, sqlParams);
var existing = [];
for (var i in wordIDs){
@ -88,8 +88,8 @@ Scholar.Fulltext = new function(){
}
// Handle bound parameters manually for optimal speed
var statement1 = Scholar.DB.getStatement("INSERT INTO fulltextWords (word) VALUES (?)");
var statement2 = Scholar.DB.getStatement("INSERT OR IGNORE INTO fulltextItems VALUES (?,?)");
var statement1 = Zotero.DB.getStatement("INSERT INTO fulltextWords (word) VALUES (?)");
var statement2 = Zotero.DB.getStatement("INSERT OR IGNORE INTO fulltextItems VALUES (?,?)");
for each(var word in words){
if (existing['_' + word]){
@ -98,7 +98,7 @@ Scholar.Fulltext = new function(){
else {
statement1.bindUTF8StringParameter(0, word);
statement1.execute()
var wordID = Scholar.DB.getLastInsertID();
var wordID = Zotero.DB.getLastInsertID();
}
statement2.bindInt32Parameter(0, wordID);
@ -109,24 +109,24 @@ Scholar.Fulltext = new function(){
statement1.reset();
statement2.reset();
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
function indexString(text, charset, itemID){
var words = semanticSplitter(text, charset);
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
clearItemWords(itemID);
indexWords(itemID, words);
/*
var sql = "REPLACE INTO fulltextContent (itemID, textContent) VALUES (?,?)";
Scholar.DB.query(sql, [itemID, {string:text}]);
Zotero.DB.query(sql, [itemID, {string:text}]);
*/
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -135,7 +135,7 @@ Scholar.Fulltext = new function(){
throw ('Item ID not provided to indexDocument()');
}
Scholar.debug("Indexing document '" + document.title + "'");
Zotero.debug("Indexing document '" + document.title + "'");
var text = document.body.innerHTML.replace(/(>)/g, '$1 ');
text = HTMLToText(text);
@ -145,7 +145,7 @@ Scholar.Fulltext = new function(){
function indexFile(file, mimeType, charset, itemID){
if (!file.exists()){
Scholar.debug('File not found in indexFile()', 2);
Zotero.debug('File not found in indexFile()', 2);
return false;
}
@ -153,13 +153,13 @@ Scholar.Fulltext = new function(){
if (!mimeType){ throw ('MIME type not provided to indexFile()'); }
if (mimeType.substr(0, 5)!='text/'){
Scholar.debug('File is not text in indexFile()', 2);
Zotero.debug('File is not text in indexFile()', 2);
return false;
}
if (!charset){ throw ('Charset not provided to indexFile()'); }
var text = Scholar.File.getContents(file, charset);
var text = Zotero.File.getContents(file, charset);
// Split elements to avoid word concatentation
text = text.replace(/(>)/g, '$1 ');
text = HTMLToText(text);
@ -168,10 +168,10 @@ Scholar.Fulltext = new function(){
function indexItems(items){
var items = Scholar.Items.get(items);
var items = Zotero.Items.get(items);
var found = [];
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
for each(var i in items){
if (!i.isAttachment()){
@ -188,9 +188,9 @@ Scholar.Fulltext = new function(){
}
var sql = "REPLACE INTO version (schema,version) VALUES (?,?)";
Scholar.DB.query(sql, ['fulltext', FULLTEXT_VERSION]);
Zotero.DB.query(sql, ['fulltext', FULLTEXT_VERSION]);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -206,9 +206,9 @@ Scholar.Fulltext = new function(){
* - Slashes in regex are optional
*/
function findTextInFile(file, charset, searchText, mode){
Scholar.debug("Searching for text '" + searchText + "' in " + file.path);
Zotero.debug("Searching for text '" + searchText + "' in " + file.path);
var str = Scholar.File.getContents(file, charset);
var str = Zotero.File.getContents(file, charset);
// If not binary mode, convert HTML to text
if (!mode || mode.indexOf('Binary')==-1){
@ -240,7 +240,7 @@ Scholar.Fulltext = new function(){
var re = new RegExp(searchText, flags);
var matches = re(str);
if (matches){
Scholar.debug("Text found");
Zotero.debug("Text found");
return str.substr(matches.index, 50);
}
@ -253,7 +253,7 @@ Scholar.Fulltext = new function(){
var pos = str.indexOf(searchText);
if (pos!=-1){
Scholar.debug('Text found');
Zotero.debug('Text found');
return str.substr(pos, 50);
}
}
@ -280,7 +280,7 @@ Scholar.Fulltext = new function(){
return [];
}
var items = Scholar.Items.get(items);
var items = Zotero.Items.get(items);
var found = [];
for each(var i in items){
@ -314,13 +314,13 @@ Scholar.Fulltext = new function(){
function clearItemWords(itemID){
Scholar.DB.query("DELETE FROM fulltextItems WHERE itemID=" + itemID);
Zotero.DB.query("DELETE FROM fulltextItems WHERE itemID=" + itemID);
}
/*
function clearItemContent(itemID){
Scholar.DB.query("DELETE FROM fulltextContent WHERE itemID=" + itemID);
Zotero.DB.query("DELETE FROM fulltextContent WHERE itemID=" + itemID);
}
*/
@ -328,7 +328,7 @@ Scholar.Fulltext = new function(){
function purgeUnusedWords(){
var sql = "DELETE FROM fulltextWords WHERE wordID NOT IN "
+ "(SELECT wordID FROM fulltextItems)";
Scholar.DB.query(sql);
Zotero.DB.query(sql);
}
@ -347,7 +347,7 @@ Scholar.Fulltext = new function(){
return to.toString();
}
catch(e){
Scholar.debug(e, 1);
Zotero.debug(e, 1);
return text;
}
}
@ -355,7 +355,7 @@ Scholar.Fulltext = new function(){
function semanticSplitter(text, charset){
if (!text){
Scholar.debug('No text to index');
Zotero.debug('No text to index');
return;
}

View file

@ -1,4 +1,4 @@
Scholar.History = new function(){
Zotero.History = new function(){
this.begin = begin;
this.setAssociatedID = setAssociatedID;
this.add = add;
@ -27,7 +27,7 @@ Scholar.History = new function(){
* 'collection-modify', 'collection-delete'...
*
* id: An id or array of ids that will be passed to
* Scholar.Notifier.trigger() on an undo or redo
* Zotero.Notifier.trigger() on an undo or redo
**/
function begin(event, id){
if (_activeID){
@ -41,7 +41,7 @@ Scholar.History = new function(){
this.clearAfter();
}
Scholar.debug('Beginning history transaction set ' + event);
Zotero.debug('Beginning history transaction set ' + event);
var sql = "INSERT INTO transactionSets (event, id) VALUES "
+ "('" + event + "', ";
if (!id){
@ -56,8 +56,8 @@ Scholar.History = new function(){
}
sql += ")";
Scholar.DB.beginTransaction();
_activeID = Scholar.DB.query(sql);
Zotero.DB.beginTransaction();
_activeID = Zotero.DB.query(sql);
_activeEvent = event;
}
@ -67,7 +67,7 @@ Scholar.History = new function(){
* for use if the ids weren't available at when begin() was called
*
* id: An id or array of ids that will be passed to
* Scholar.Notifier.trigger() on an undo or redo
* Zotero.Notifier.trigger() on an undo or redo
**/
function setAssociatedID(id){
if (!_activeID){
@ -86,7 +86,7 @@ Scholar.History = new function(){
sql += id;
}
sql += " WHERE transactionSetID=" + _activeID;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
}
@ -144,8 +144,8 @@ Scholar.History = new function(){
* Commit the current transaction set
**/
function commit(){
Scholar.debug('Committing history transaction set ' + _activeEvent);
Scholar.DB.commitTransaction();
Zotero.debug('Committing history transaction set ' + _activeEvent);
Zotero.DB.commitTransaction();
_currentID = _activeID;
_maxID = _activeID;
_activeID = null;
@ -157,8 +157,8 @@ Scholar.History = new function(){
* Cancel the current transaction set
**/
function cancel(){
Scholar.debug('Cancelling history transaction set ' + _activeEvent);
Scholar.DB.rollbackTransaction();
Zotero.debug('Cancelling history transaction set ' + _activeEvent);
Zotero.DB.rollbackTransaction();
_activeID = null;
_activeEvent = null;
}
@ -174,7 +174,7 @@ Scholar.History = new function(){
var sql = "SELECT event FROM transactionSets WHERE transactionSetID="
+ _currentID;
return Scholar.DB.valueQuery(sql);
return Zotero.DB.valueQuery(sql);
}
@ -184,7 +184,7 @@ Scholar.History = new function(){
function getNextEvent(){
var sql = "SELECT event FROM transactionSets WHERE transactionSetID="
+ (_currentID + 1);
return Scholar.DB.valueQuery(sql);
return Zotero.DB.valueQuery(sql);
}
@ -198,11 +198,11 @@ Scholar.History = new function(){
}
var id = _currentID;
Scholar.debug('Undoing transaction set ' + id);
Scholar.DB.beginTransaction();
Zotero.debug('Undoing transaction set ' + id);
Zotero.DB.beginTransaction();
var undone = _do('undo');
_currentID--;
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
_reloadAndNotify(id);
return true;
}
@ -213,11 +213,11 @@ Scholar.History = new function(){
**/
function redo(){
var id = _currentID + 1;
Scholar.debug('Redoing transaction set ' + id);
Scholar.DB.beginTransaction();
Zotero.debug('Redoing transaction set ' + id);
Zotero.DB.beginTransaction();
var redone = _do('redo');
_currentID++;
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
_reloadAndNotify(id, true);
return redone;
}
@ -227,15 +227,15 @@ Scholar.History = new function(){
* Clear the entire history
**/
function clear(){
Scholar.DB.beginTransaction();
Scholar.DB.query("DELETE FROM transactionSets");
Scholar.DB.query("DELETE FROM transactions");
Scholar.DB.query("DELETE FROM transactionLog");
Zotero.DB.beginTransaction();
Zotero.DB.query("DELETE FROM transactionSets");
Zotero.DB.query("DELETE FROM transactions");
Zotero.DB.query("DELETE FROM transactionLog");
_currentID = null;
_activeID = null;
_activeEvent = null;
_maxID = null;
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
@ -243,25 +243,25 @@ Scholar.History = new function(){
* Clear all transactions in history after the current one
**/
function clearAfter(){
Scholar.DB.beginTransaction();
var min = Scholar.DB.valueQuery("SELECT MIN(transactionID) FROM "
Zotero.DB.beginTransaction();
var min = Zotero.DB.valueQuery("SELECT MIN(transactionID) FROM "
+ "transactions WHERE transactionSetID=" + (_currentID + 1));
if (!min){
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
return;
}
Scholar.DB.query("DELETE FROM transactionLog "
Zotero.DB.query("DELETE FROM transactionLog "
+ "WHERE transactionID>=" + min);
Scholar.DB.query("DELETE FROM transactions "
Zotero.DB.query("DELETE FROM transactions "
+ "WHERE transactionID>=" + min);
Scholar.DB.query("DELETE FROM transactionSets "
Zotero.DB.query("DELETE FROM transactionSets "
+ "WHERE transactionSetID>" + _currentID);
_maxID = _currentID;
_activeID = null;
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
return;
}
@ -287,7 +287,7 @@ Scholar.History = new function(){
+ "VALUES (" + _activeID + ", '" + contextString
+ "', '" + action + "')";
var transactionID = Scholar.DB.query(sql);
var transactionID = Zotero.DB.query(sql);
switch (action){
case 'add':
@ -299,24 +299,24 @@ Scholar.History = new function(){
if (field){
var sql = "INSERT INTO transactionLog SELECT " + transactionID
+ ", '" + field + "', " + field + fromClause;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
break;
}
// Fall through if no field specified and save all
case 'remove':
var cols = Scholar.DB.getColumns(table);
var cols = Zotero.DB.getColumns(table);
for (var i in cols){
// If column is not part of the key, log it
if (!Scholar.inArray(cols[i], context['keys'])){
if (!Zotero.inArray(cols[i], context['keys'])){
var sql = "INSERT INTO transactionLog "
+ "SELECT " + transactionID + ", '" + cols[i]
+ "', " + cols[i] + fromClause;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
}
}
break;
default:
Scholar.DB.rollbackTransaction();
Zotero.DB.rollbackTransaction();
throw("Invalid history action '" + action + "'");
}
}
@ -334,7 +334,7 @@ Scholar.History = new function(){
var sql = "SELECT transactionID, context, action FROM transactions "
+ "WHERE transactionSetID=" + id;
var transactions = Scholar.DB.query(sql);
var transactions = Zotero.DB.query(sql);
if (!transactions){
throw('Transaction set not found for '
@ -362,31 +362,31 @@ Scholar.History = new function(){
var fromClause = _contextToSQLFrom(context);
// First, store the row we're about to delete for later redo
var cols = Scholar.DB.getColumns(context['table']);
var cols = Zotero.DB.getColumns(context['table']);
for (var i in cols){
// If column is not part of the key, log it
if (!Scholar.inArray(cols[i], context['keys'])){
if (!Zotero.inArray(cols[i], context['keys'])){
var sql = "INSERT INTO transactionLog "
+ "SELECT " + transactionID + ", '" + cols[i]
+ "', " + cols[i] + fromClause;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
}
}
// And delete the row
var sql = "DELETE" + fromClause;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
break;
case 'modify':
// Retrieve old values
var sql = "SELECT field, value FROM transactionLog "
+ "WHERE transactionID=" + transactionID;
var oldFieldValues = Scholar.DB.query(sql);
var oldFieldValues = Zotero.DB.query(sql);
// Retrieve new values
var sql = "SELECT *" + _contextToSQLFrom(context);
var newValues = Scholar.DB.rowQuery(sql);
var newValues = Zotero.DB.rowQuery(sql);
// Update row with old values
var sql = "UPDATE " + context['table'] + " SET ";
@ -396,14 +396,14 @@ Scholar.History = new function(){
values.push(oldFieldValues[i]['value']);
}
sql = sql.substr(0, sql.length-2) + _contextToSQLWhere(context);
Scholar.DB.query(sql, values);
Zotero.DB.query(sql, values);
// Update log with new values for later redo
for (var i in newValues){
if (!Scholar.inArray(i, context['keys'])){
if (!Zotero.inArray(i, context['keys'])){
var sql = "UPDATE transactionLog SET "
+ "value=? WHERE transactionID=? AND field=?";
Scholar.DB.query(sql, [i, newValues[i], transactionID]);
Zotero.DB.query(sql, [i, newValues[i], transactionID]);
}
}
break;
@ -412,7 +412,7 @@ Scholar.History = new function(){
// Retrieve old values
var sql = "SELECT field, value FROM transactionLog "
+ "WHERE transactionID=" + transactionID;
var oldFieldValues = Scholar.DB.query(sql);
var oldFieldValues = Zotero.DB.query(sql);
// Add key to parameters
var fields = [], values = [], marks = [];
@ -432,12 +432,12 @@ Scholar.History = new function(){
// Insert old values into table
var sql = "INSERT INTO " + context['table'] + "("
+ fields.join() + ") VALUES (" + marks.join() + ")";
Scholar.DB.query(sql, values);
Zotero.DB.query(sql, values);
// Delete restored data from transactionLog
var sql = "DELETE FROM transactionLog WHERE transactionID="
+ transactionID;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
break;
}
}
@ -481,7 +481,7 @@ Scholar.History = new function(){
function _getSetData(transactionSetID){
var sql = "SELECT event, id FROM transactionSets WHERE transactionSetID="
+ transactionSetID;
return Scholar.DB.rowQuery(sql);
return Zotero.DB.rowQuery(sql);
}
@ -500,10 +500,10 @@ Scholar.History = new function(){
}
switch (eventParts[1]){
case 'item':
Scholar.Items.reload(data['id']);
Zotero.Items.reload(data['id']);
break;
}
Scholar.Notifier.trigger(eventParts[0], eventParts[1], data['id']);
Zotero.Notifier.trigger(eventParts[0], eventParts[1], data['id']);
}
}

View file

@ -1,12 +1,12 @@
// Scholar for Firefox Ingester
// Zotero for Firefox Ingester
// Utilities based on code taken from Piggy Bank 2.1.1 (BSD-licensed)
// This code is licensed according to the GPL
Scholar.Ingester = new Object();
Zotero.Ingester = new Object();
/////////////////////////////////////////////////////////////////
//
// Scholar.Ingester.ProxyMonitor
// Zotero.Ingester.ProxyMonitor
//
/////////////////////////////////////////////////////////////////
@ -18,7 +18,7 @@ Scholar.Ingester = new Object();
/*
* Precompile proxy regexps
*/
Scholar.Ingester.ProxyMonitor = new function() {
Zotero.Ingester.ProxyMonitor = new function() {
var _ezProxyRe = new RegExp();
_ezProxyRe.compile("\\?(?:.+&)?(url|qurl)=([^&]+)", "i");
/*var _hostRe = new RegExp();
@ -48,7 +48,7 @@ Scholar.Ingester.ProxyMonitor = new function() {
try {
// remove content-disposition headers for endnote, etc.
var contentType = channel.getResponseHeader("Content-Type").toLowerCase();
for each(var desiredContentType in Scholar.Ingester.MIMEHandler.URIContentListener.desiredContentTypes) {
for each(var desiredContentType in Zotero.Ingester.MIMEHandler.URIContentListener.desiredContentTypes) {
if(contentType.length < desiredContentType.length) {
break;
} else {
@ -100,7 +100,7 @@ Scholar.Ingester.ProxyMonitor = new function() {
newURI.hostPort.substr(newURI.hostPort.length-channel.URI.hostPort.length) == channel.URI.hostPort)) {
// Different ports but the same server means EZproxy active
Scholar.debug("EZProxy: host "+newURI.hostPort+" is really "+properURI.hostPort);
Zotero.debug("EZProxy: host "+newURI.hostPort+" is really "+properURI.hostPort);
// Initialize variables here so people who never use EZProxies
// don't get the (very very minor) speed hit
if(!_mapFromProxy) {
@ -124,7 +124,7 @@ Scholar.Ingester.ProxyMonitor = new function() {
var uri = _parseURL(url);
if(uri && _mapFromProxy[uri.hostPort]) {
url = url.replace(uri.hostPort, _mapFromProxy[uri.hostPort]);
Scholar.debug("EZProxy: proper url is "+url);
Zotero.debug("EZProxy: proper url is "+url);
}
}
@ -142,7 +142,7 @@ Scholar.Ingester.ProxyMonitor = new function() {
if(uri && _mapToProxy[uri.hostPort]) {
// Actually need to map
url = url.replace(uri.hostPort, _mapToProxy[uri.hostPort]);
Scholar.debug("EZProxy: proxied url is "+url);
Zotero.debug("EZProxy: proxied url is "+url);
}
}
@ -160,7 +160,7 @@ Scholar.Ingester.ProxyMonitor = new function() {
}
}
Scholar.OpenURL = new function() {
Zotero.OpenURL = new function() {
this.resolve = resolve;
this.discoverResolvers = discoverResolvers;
this.createContextObject = createContextObject;
@ -170,9 +170,9 @@ Scholar.OpenURL = new function() {
* Returns a URL to look up an item in the OpenURL resolver
*/
function resolve(itemObject) {
var co = createContextObject(itemObject, Scholar.Prefs.get("openURL.version"));
var co = createContextObject(itemObject, Zotero.Prefs.get("openURL.version"));
if(co) {
return Scholar.Prefs.get("openURL.resolver")+"?"+co;
return Zotero.Prefs.get("openURL.resolver")+"?"+co;
}
return false;
}
@ -342,7 +342,7 @@ Scholar.OpenURL = new function() {
item.itemType = "journalArticle";
break;
} else if(format == "info:ofi/fmt:kev:mtx:book") {
if(Scholar.inArray("rft.genre=bookitem", coParts)) {
if(Zotero.inArray("rft.genre=bookitem", coParts)) {
item.itemType = "bookSection";
} else {
item.itemType = "book";
@ -447,7 +447,7 @@ Scholar.OpenURL = new function() {
item.creators.push({firstName:value});
}
} else if(key == "rft.au") {
item.creators.push(Scholar.Utilities.prototype.cleanAuthor(value, "author", true));
item.creators.push(Zotero.Utilities.prototype.cleanAuthor(value, "author", true));
} else if(key == "rft.aucorp") {
item.creators.push({lastName:value, isInstitution:true});
} else if(key == "rft.isbn" && !item.ISBN) {
@ -488,7 +488,7 @@ Scholar.OpenURL = new function() {
}
}
Scholar.Ingester.MIMEHandler = new function() {
Zotero.Ingester.MIMEHandler = new function() {
var on = false;
this.init = init;
@ -497,26 +497,26 @@ Scholar.Ingester.MIMEHandler = new function() {
* registers URIContentListener to handle MIME types
*/
function init() {
var prefStatus = Scholar.Prefs.get("parseEndNoteMIMETypes");
var prefStatus = Zotero.Prefs.get("parseEndNoteMIMETypes");
if(!on && prefStatus) {
var uriLoader = Components.classes["@mozilla.org/uriloader;1"].
getService(Components.interfaces.nsIURILoader);
uriLoader.registerContentListener(Scholar.Ingester.MIMEHandler.URIContentListener);
uriLoader.registerContentListener(Zotero.Ingester.MIMEHandler.URIContentListener);
on = true;
} else if(on && !prefStatus) {
var uriLoader = Components.classes["@mozilla.org/uriloader;1"].
getService(Components.interfaces.nsIURILoader);
uriLoader.unRegisterContentListener(Scholar.Ingester.MIMEHandler.URIContentListener);
uriLoader.unRegisterContentListener(Zotero.Ingester.MIMEHandler.URIContentListener);
on = false;
}
}
}
/*
* Scholar.Ingester.MIMEHandler.URIContentListener: implements
* Zotero.Ingester.MIMEHandler.URIContentListener: implements
* nsIURIContentListener interface to grab MIME types
*/
Scholar.Ingester.MIMEHandler.URIContentListener = new function() {
Zotero.Ingester.MIMEHandler.URIContentListener = new function() {
// list of content types to capture
// NOTE: must be from shortest to longest length
this.desiredContentTypes = ["application/x-endnote-refer",
@ -538,20 +538,20 @@ Scholar.Ingester.MIMEHandler.URIContentListener = new function() {
}
function canHandleContent(contentType, isContentPreferred, desiredContentType) {
if(Scholar.inArray(contentType, this.desiredContentTypes)) {
if(Zotero.inArray(contentType, this.desiredContentTypes)) {
return true;
}
return false;
}
function doContent(contentType, isContentPreferred, request, contentHandler) {
Scholar.debug("doing content for "+request.name);
contentHandler.value = new Scholar.Ingester.MIMEHandler.StreamListener(request, contentType);
Zotero.debug("doing content for "+request.name);
contentHandler.value = new Zotero.Ingester.MIMEHandler.StreamListener(request, contentType);
return false;
}
function isPreferred(contentType, desiredContentType) {
if(Scholar.inArray(contentType, this.desiredContentTypes)) {
if(Zotero.inArray(contentType, this.desiredContentTypes)) {
return true;
}
return false;
@ -563,10 +563,10 @@ Scholar.Ingester.MIMEHandler.URIContentListener = new function() {
}
/*
* Scholar.Ingester.MIMEHandler.StreamListener: implements nsIStreamListener and
* Zotero.Ingester.MIMEHandler.StreamListener: implements nsIStreamListener and
* nsIRequestObserver interfaces to download MIME types we've grabbed
*/
Scholar.Ingester.MIMEHandler.StreamListener = function(request, contentType) {
Zotero.Ingester.MIMEHandler.StreamListener = function(request, contentType) {
this._request = request;
this._contentType = contentType
this._readString = "";
@ -577,12 +577,12 @@ Scholar.Ingester.MIMEHandler.StreamListener = function(request, contentType) {
var windowWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
getService(Components.interfaces.nsIWindowWatcher);
this._frontWindow = windowWatcher.activeWindow;
this._frontWindow.Scholar_Ingester_Interface.Progress.show();
this._frontWindow.Zotero_Ingester_Interface.Progress.show();
Scholar.debug("EndNote prepared to grab content type "+contentType);
Zotero.debug("EndNote prepared to grab content type "+contentType);
}
Scholar.Ingester.MIMEHandler.StreamListener.prototype.QueryInterface = function(iid) {
Zotero.Ingester.MIMEHandler.StreamListener.prototype.QueryInterface = function(iid) {
if(iid.equals(Components.interfaces.nsISupports)
|| iid.equals(Components.interfaces.nsIRequestObserver)
|| iid.equals(Components.interfaces.nsIStreamListener)) {
@ -591,13 +591,13 @@ Scholar.Ingester.MIMEHandler.StreamListener.prototype.QueryInterface = function(
throw Components.results.NS_ERROR_NO_INTERFACE;
}
Scholar.Ingester.MIMEHandler.StreamListener.prototype.onStartRequest = function(channel, context) {}
Zotero.Ingester.MIMEHandler.StreamListener.prototype.onStartRequest = function(channel, context) {}
/*
* called when there's data available; basicallly, we just want to collect this data
*/
Scholar.Ingester.MIMEHandler.StreamListener.prototype.onDataAvailable = function(request, context, inputStream, offset, count) {
Scholar.debug(count+" bytes available");
Zotero.Ingester.MIMEHandler.StreamListener.prototype.onDataAvailable = function(request, context, inputStream, offset, count) {
Zotero.debug(count+" bytes available");
if(inputStream != this._scriptableStreamInput) { // get storage stream
// if there's not one
@ -612,24 +612,24 @@ Scholar.Ingester.MIMEHandler.StreamListener.prototype.onDataAvailable = function
/*
* called when the request is done
*/
Scholar.Ingester.MIMEHandler.StreamListener.prototype.onStopRequest = function(channel, context, status) {
Scholar.debug("request finished");
Zotero.Ingester.MIMEHandler.StreamListener.prototype.onStopRequest = function(channel, context, status) {
Zotero.debug("request finished");
var externalHelperAppService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].
getService(Components.interfaces.nsIExternalHelperAppService);
// attempt to import through Scholar.Translate
var translation = new Scholar.Translate("import");
// attempt to import through Zotero.Translate
var translation = new Zotero.Translate("import");
translation.setLocation(this._request.name);
translation.setString(this._readString);
translation.setHandler("itemDone", this._frontWindow.Scholar_Ingester_Interface._itemDone);
translation.setHandler("done", this._frontWindow.Scholar_Ingester_Interface._finishScraping);
translation.setHandler("itemDone", this._frontWindow.Zotero_Ingester_Interface._itemDone);
translation.setHandler("done", this._frontWindow.Zotero_Ingester_Interface._finishScraping);
// attempt to retrieve translators
var translators = translation.getTranslators();
if(!translators.length) {
// we lied. we can't really translate this file. call
// nsIExternalHelperAppService with the data
this._frontWindow.Scholar_Ingester_Interface.Progress.kill();
this._frontWindow.Zotero_Ingester_Interface.Progress.kill();
var streamListener;
if(streamListener = externalHelperAppService.doContent(this._contentType, this._request, this._frontWindow)) {

View file

@ -1,4 +1,4 @@
Scholar.Integration = new function() {
Zotero.Integration = new function() {
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
var _XMLRe = /<\?[^>]+\?>/;
this.ns = "http://www.zotero.org/namespaces/SOAP";
@ -18,9 +18,9 @@ Scholar.Integration = new function() {
// bind to a random port on loopback only
serv.init(50001, true, -1);
serv.asyncListen(Scholar.Integration.SocketListener);
serv.asyncListen(Zotero.Integration.SocketListener);
Scholar.debug("Integration HTTP server listening on 127.0.0.1:"+serv.port);
Zotero.debug("Integration HTTP server listening on 127.0.0.1:"+serv.port);
}
/*
@ -51,17 +51,17 @@ Scholar.Integration = new function() {
* handles a SOAP envelope
*/
function handleEnvelope(envelope, encoding) {
Scholar.debug("Integration: SOAP Request\n"+envelope);
Zotero.debug("Integration: SOAP Request\n"+envelope);
envelope = envelope.replace(_XMLRe, "");
var env = new Namespace("http://schemas.xmlsoap.org/soap/envelope/");
var xml = new XML(envelope);
var request = xml.env::Body.children()[0];
if(request.namespace() != this.ns) {
Scholar.debug("Integration: SOAP method not supported: invalid namespace");
Zotero.debug("Integration: SOAP method not supported: invalid namespace");
} else {
var name = request.localName();
if(Scholar.Integration.SOAP[name]) {
if(Zotero.Integration.SOAP[name]) {
if(request.input.length()) {
// split apart passed parameters (same colon-escaped format
// as we pass)
@ -89,7 +89,7 @@ Scholar.Integration = new function() {
}
// execute request
var output = Scholar.Integration.SOAP[name](vars);
var output = Zotero.Integration.SOAP[name](vars);
// ugh: we can't use real SOAP, since AppleScript VBA can't pass
// objects, so implode arrays
@ -116,13 +116,13 @@ Scholar.Integration = new function() {
</SOAP-ENV:Envelope>;
var response = '<?xml version="1.0" encoding="'+encoding+'"?>\n'+responseEnvelope.toXMLString();
Scholar.debug("Integration: SOAP Response\n"+response);
Zotero.debug("Integration: SOAP Response\n"+response);
// return OK
return _generateResponse("200 OK", 'text/xml; charset="'+encoding+'"',
response);
} else {
Scholar.debug("Integration: SOAP method not supported");
Zotero.debug("Integration: SOAP method not supported");
}
}
}
@ -146,7 +146,7 @@ Scholar.Integration = new function() {
}
}
Scholar.Integration.SocketListener = new function() {
Zotero.Integration.SocketListener = new function() {
this.onSocketAccepted = onSocketAccepted;
/*
@ -157,7 +157,7 @@ Scholar.Integration.SocketListener = new function() {
var iStream = transport.openInputStream(0, 0, 0);
var oStream = transport.openOutputStream(0, 0, 0);
var dataListener = new Scholar.Integration.DataListener(iStream, oStream);
var dataListener = new Zotero.Integration.DataListener(iStream, oStream);
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
.createInstance(Components.interfaces.nsIInputStreamPump);
pump.init(iStream, -1, -1, 0, 0, false);
@ -168,7 +168,7 @@ Scholar.Integration.SocketListener = new function() {
/*
* handles the actual acquisition of data
*/
Scholar.Integration.DataListener = function(iStream, oStream) {
Zotero.Integration.DataListener = function(iStream, oStream) {
this.header = "";
this.headerFinished = false;
@ -188,12 +188,12 @@ Scholar.Integration.DataListener = function(iStream, oStream) {
* called when a request begins (although the request should have begun before
* the DataListener was generated)
*/
Scholar.Integration.DataListener.prototype.onStartRequest = function(request, context) {}
Zotero.Integration.DataListener.prototype.onStartRequest = function(request, context) {}
/*
* called when a request stops
*/
Scholar.Integration.DataListener.prototype.onStopRequest = function(request, context, status) {
Zotero.Integration.DataListener.prototype.onStopRequest = function(request, context, status) {
this.iStream.close();
this.oStream.close();
}
@ -201,7 +201,7 @@ Scholar.Integration.DataListener.prototype.onStopRequest = function(request, con
/*
* called when new data is available
*/
Scholar.Integration.DataListener.prototype.onDataAvailable = function(request, context,
Zotero.Integration.DataListener.prototype.onDataAvailable = function(request, context,
inputStream, offset, count) {
var readData = this.sStream.read(count);
@ -251,9 +251,9 @@ Scholar.Integration.DataListener.prototype.onDataAvailable = function(request, c
/*
* processes an HTTP header and decides what to do
*/
Scholar.Integration.DataListener.prototype._headerFinished = function() {
Zotero.Integration.DataListener.prototype._headerFinished = function() {
this.headerFinished = true;
var output = Scholar.Integration.handleHeader(this.header);
var output = Zotero.Integration.handleHeader(this.header);
if(typeof(output) == "number") {
this.bodyLength = output;
@ -268,7 +268,7 @@ Scholar.Integration.DataListener.prototype._headerFinished = function() {
* checks to see if Content-Length bytes of body have been read and, if they
* have, processes the body
*/
Scholar.Integration.DataListener.prototype._bodyData = function() {
Zotero.Integration.DataListener.prototype._bodyData = function() {
if(this.body.length >= this.bodyLength) {
if(this.body.length > this.bodyLength) {
// truncate
@ -277,7 +277,7 @@ Scholar.Integration.DataListener.prototype._bodyData = function() {
// UTF-8 crashes AppleScript
var encoding = (this.header.indexOf("\nUser-Agent: Mac OS X") !== -1 ? "macintosh" : "UTF-8");
var output = Scholar.Integration.handleEnvelope(this.body, encoding);
var output = Zotero.Integration.handleEnvelope(this.body, encoding);
this._requestFinished(output, encoding);
}
}
@ -285,7 +285,7 @@ Scholar.Integration.DataListener.prototype._bodyData = function() {
/*
* returns HTTP data from a request
*/
Scholar.Integration.DataListener.prototype._requestFinished = function(response, encoding) {
Zotero.Integration.DataListener.prototype._requestFinished = function(response, encoding) {
// close input stream
this.iStream.close();
@ -328,7 +328,7 @@ Scholar.Integration.DataListener.prototype._requestFinished = function(response,
this.oStream.close();
}
Scholar.Integration.SOAP = new function() {
Zotero.Integration.SOAP = new function() {
this.init = init;
this.update = update;
this.restoreSession = restoreSession;
@ -358,7 +358,7 @@ Scholar.Integration.SOAP = new function() {
var citationMode = vars[2];
var regenerateAll = (citationMode == "all");
var citationSet = new Scholar.Integration.CitationSet(session.style);
var citationSet = new Zotero.Integration.CitationSet(session.style);
var updatedCitations = new Object();
var citation, update;
@ -366,10 +366,10 @@ Scholar.Integration.SOAP = new function() {
if(vars[i+1] == "X") {
// get a new citation for a field with an X
var io = new Object();
window.openDialog('chrome://scholar/content/addCitationDialog.xul','',
window.openDialog('chrome://zotero/content/addCitationDialog.xul','',
'chrome,popup,modal', io, true);
citation = new Scholar.Integration.Citation(vars[i], "!");
citation = new Zotero.Integration.Citation(vars[i], "!");
updatedCitations[citation.index] = true;
if(io.items) { // cancel was not pressed
@ -382,7 +382,7 @@ Scholar.Integration.SOAP = new function() {
}
} else {
// load an existing citation
citation = new Scholar.Integration.Citation(vars[i], vars[i+1]);
citation = new Zotero.Integration.Citation(vars[i], vars[i+1]);
}
var isDuplicate = citationSet.addCitation(citation);
@ -428,7 +428,7 @@ Scholar.Integration.SOAP = new function() {
var itemsChanged = session.citationFactory.updateItems(citationSet, session, updatedCitations);
if(itemsChanged || bibliographyMode == "true") {
Scholar.debug("Integration: Regenerating bibliography");
Zotero.debug("Integration: Regenerating bibliography");
// EBNF: bibliography-data
if(bibliographyMode != "false") {
output.push(session.style.createBibliography(session.citationFactory.items, "Integration"));
@ -477,15 +477,15 @@ Scholar.Integration.SOAP = new function() {
* RETURNS: sessionID
*/
function restoreSession(vars) {
var sessionID = Scholar.randomString();
var session = _sessions[sessionID] = new Scholar.Integration.Session(vars[0]);
var sessionID = Zotero.randomString();
var session = _sessions[sessionID] = new Zotero.Integration.Session(vars[0]);
var encounteredItem = new Object();
var newField = new Object();
var regenerate = new Object();
for(var i=1; i<vars.length; i+=2) {
var citation = new Scholar.Integration.Citation(vars[i], vars[i+1]);
var citation = new Zotero.Integration.Citation(vars[i], vars[i+1]);
session.citationSet.addCitation(citation); // add to see when refresh is necessary
}
@ -509,8 +509,8 @@ Scholar.Integration.SOAP = new function() {
if(!vars || !vars[0] || vars[0] == "!") {
// no session ID; generate a new one
var sessionID = Scholar.randomString();
var session = _sessions[sessionID] = new Scholar.Integration.Session();
var sessionID = Zotero.randomString();
var session = _sessions[sessionID] = new Zotero.Integration.Session();
} else {
// session ID exists
var sessionID = vars[0];
@ -522,7 +522,7 @@ Scholar.Integration.SOAP = new function() {
io.style = originalStyle;
}
window.openDialog('chrome://scholar/content/integrationDocPrefs.xul','',
window.openDialog('chrome://zotero/content/integrationDocPrefs.xul','',
'chrome,popup,modal',io);
session.setStyle(io.style);
@ -530,26 +530,26 @@ Scholar.Integration.SOAP = new function() {
}
}
Scholar.Integration.Session = function(styleID) {
Zotero.Integration.Session = function(styleID) {
if(styleID) {
this.styleID = styleID;
this.style = Scholar.Cite.getStyle(this.styleID);
this.style = Zotero.Cite.getStyle(this.styleID);
}
this.citationSet = new Scholar.Integration.CitationSet(this.style);
this.citationFactory = new Scholar.Integration.CitationFactory(this.style);
this.citationSet = new Zotero.Integration.CitationSet(this.style);
this.citationFactory = new Zotero.Integration.CitationFactory(this.style);
}
Scholar.Integration.Session.prototype.setStyle = function(styleID) {
Zotero.Integration.Session.prototype.setStyle = function(styleID) {
this.styleID = styleID;
this.citationSet.style = this.citationFactory.style = this.style = Scholar.Cite.getStyle(styleID);
this.citationSet.style = this.citationFactory.style = this.style = Zotero.Cite.getStyle(styleID);
this.citationFactory.clearCache();
}
/*
* a class to keep track of citation objects in a document
*/
Scholar.Integration.Citation = function(index, field) {
Zotero.Integration.Citation = function(index, field) {
this.index = index;
this.field = field;
if(field != "!") {
@ -571,14 +571,14 @@ Scholar.Integration.Citation = function(index, field) {
/*
* generates a new field name based on available information
*/
Scholar.Integration.Citation.prototype.regenerateFieldName = function() {
this.field = this.itemIDString+"_"+this.locatorString+"_"+Scholar.randomString();
Zotero.Integration.Citation.prototype.regenerateFieldName = function() {
this.field = this.itemIDString+"_"+this.locatorString+"_"+Zotero.randomString();
}
/*
* updates itemIDString and locatorString based on data
*/
Scholar.Integration.Citation.prototype.setData = function(itemIDs, locators, locatorTypes) {
Zotero.Integration.Citation.prototype.setData = function(itemIDs, locators, locatorTypes) {
this.itemIDs = itemIDs;
this.itemIDString = itemIDs.join("|");
@ -596,7 +596,7 @@ Scholar.Integration.Citation.prototype.setData = function(itemIDs, locators, loc
/*
* loads locators from locatorString, if not already loaded
*/
Scholar.Integration.Citation.prototype.loadLocators = function() {
Zotero.Integration.Citation.prototype.loadLocators = function() {
if(this.locators) return;
this.locators = new Array();
@ -610,10 +610,10 @@ Scholar.Integration.Citation.prototype.loadLocators = function() {
}
/*
* a class to complement Scholar.Integration.Citation, to keep track of the
* a class to complement Zotero.Integration.Citation, to keep track of the
* order of citations
*/
Scholar.Integration.CitationSet = function(style) {
Zotero.Integration.CitationSet = function(style) {
this.citationsByID = new Object();
this.citationsByField = new Object();
this.citationsByIndex = new Object();
@ -626,7 +626,7 @@ Scholar.Integration.CitationSet = function(style) {
* adds a citation. returns true if this citation duplicates another that has
* already been added.
*/
Scholar.Integration.CitationSet.prototype.addCitation = function(citation) {
Zotero.Integration.CitationSet.prototype.addCitation = function(citation) {
var isDuplicate = false;
var itemID;
@ -671,14 +671,14 @@ Scholar.Integration.CitationSet.prototype.addCitation = function(citation) {
/*
* a class to generate and cache citations
*/
Scholar.Integration.CitationFactory = function(style) {
Zotero.Integration.CitationFactory = function(style) {
if(style) this.style = style;
this.cache = new Object();
this.dateModified = new Object();
this.items = new Array();
}
Scholar.Integration.CitationFactory.prototype.updateItems = function(citationSet, session, updateCitations) {
Zotero.Integration.CitationFactory.prototype.updateItems = function(citationSet, session, updateCitations) {
if(session) {
// check to see if an update is really necessary
var regenerateItemList = false;
@ -715,7 +715,7 @@ Scholar.Integration.CitationFactory.prototype.updateItems = function(citationSet
var disambiguation = new Array();
for(var i in citationSet.citationsByID) {
var item = Scholar.Items.get(i);
var item = Zotero.Items.get(i);
this.items.push(item);
if(this.dateModified[i] && this.dateModified[i] != item.getField("dateModified")) {
@ -729,7 +729,7 @@ Scholar.Integration.CitationFactory.prototype.updateItems = function(citationSet
}
}
Scholar.debug(disambiguation);
Zotero.debug(disambiguation);
this.style.preprocessItems(this.items);
var tempCache = new Object();
@ -764,7 +764,7 @@ Scholar.Integration.CitationFactory.prototype.updateItems = function(citationSet
return true;
}
Scholar.Integration.CitationFactory.prototype.getCitation = function(citation, usingCache) {
Zotero.Integration.CitationFactory.prototype.getCitation = function(citation, usingCache) {
if(!usingCache) usingCache = this.cache;
if(usingCache[citation.serializedType] && usingCache[citation.serializedType][citation.serialization]) {
@ -782,7 +782,7 @@ Scholar.Integration.CitationFactory.prototype.getCitation = function(citation, u
return citationText;
}
Scholar.Integration.CitationFactory.prototype.clearCache = function() {
Zotero.Integration.CitationFactory.prototype.clearCache = function() {
this.cache = new Object();
this.dateModified = new Object();
}

View file

@ -15,7 +15,7 @@
/*
* Constructor the the ItemTreeView object
*/
Scholar.ItemTreeView = function(itemGroup, sourcesOnly)
Zotero.ItemTreeView = function(itemGroup, sourcesOnly)
{
this._itemGroup = itemGroup;
this._sourcesOnly = sourcesOnly;
@ -23,13 +23,13 @@ Scholar.ItemTreeView = function(itemGroup, sourcesOnly)
this._treebox = null;
this.refresh();
this._unregisterID = Scholar.Notifier.registerItemTree(this);
this._unregisterID = Zotero.Notifier.registerItemTree(this);
}
/*
* Called by the tree itself
*/
Scholar.ItemTreeView.prototype.setTree = function(treebox)
Zotero.ItemTreeView.prototype.setTree = function(treebox)
{
if(this._treebox)
return;
@ -49,7 +49,7 @@ Scholar.ItemTreeView.prototype.setTree = function(treebox)
* Reload the rows from the data access methods
* (doesn't call the tree.invalidate methods, etc.)
*/
Scholar.ItemTreeView.prototype.refresh = function()
Zotero.ItemTreeView.prototype.refresh = function()
{
this._dataItems = new Array();
this.rowCount = 0;
@ -62,7 +62,7 @@ Scholar.ItemTreeView.prototype.refresh = function()
if(newRows[i] &&
(!this._sourcesOnly || (!newRows[i].isAttachment() && !newRows[i].isNote())))
{
this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],0,false), i+1); //item ref, before row
this._showItem(new Zotero.ItemTreeView.TreeRow(newRows[i],0,false), i+1); //item ref, before row
}
}
}
@ -71,15 +71,15 @@ Scholar.ItemTreeView.prototype.refresh = function()
}
/*
* Called by Scholar.Notifier on any changes to items in the data layer
* Called by Zotero.Notifier on any changes to items in the data layer
*/
Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
{
var madeChanges = false;
this.selection.selectEventsSuppressed = true;
var savedSelection = this.saveSelection();
ids = Scholar.flattenArguments(ids);
ids = Zotero.flattenArguments(ids);
// See if we're in the active window
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
@ -140,7 +140,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
else if (!this.isContainer(row) && this.getParentIndex(row)==-1
&& this._getItemAtRow(row).ref.getSource())
{
Scholar.debug('row is here2');
Zotero.debug('row is here2');
this._hideItem(row);
this._treebox.rowCountChanged(row+1, -1)
}
@ -148,13 +148,13 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
else if (!this.isContainer(row) && this.getParentIndex(row)!=-1
&& !this._getItemAtRow(row).ref.getSource())
{
var item = Scholar.Items.get(ids[i]);
this._showItem(new Scholar.ItemTreeView.TreeRow(item, 0, false), this.rowCount);
var item = Zotero.Items.get(ids[i]);
this._showItem(new Zotero.ItemTreeView.TreeRow(item, 0, false), this.rowCount);
this._treebox.rowCountChanged(this.rowCount-1, 1);
}
else
{
Scholar.debug('row is here3');
Zotero.debug('row is here3');
this._treebox.invalidateRow(row);
}
madeChanges = true;
@ -163,12 +163,12 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
//else if(this._itemGroup.isLibrary() || this._itemGroup.ref.hasItem(ids[i]))
else
{
var item = Scholar.Items.get(ids[i]);
var item = Zotero.Items.get(ids[i]);
if(item.isRegularItem() || !item.getSource())
{
//most likely, the note or attachment's parent was removed.
this._showItem(new Scholar.ItemTreeView.TreeRow(item,0,false),this.rowCount);
this._showItem(new Zotero.ItemTreeView.TreeRow(item,0,false),this.rowCount);
this._treebox.rowCountChanged(this.rowCount-1,1);
madeChanges = true;
}
@ -188,7 +188,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
// If no quicksearch, process new items manually
if (quicksearch.value == '')
{
var items = Scholar.Items.get(ids);
var items = Zotero.Items.get(ids);
for (var i in items)
{
@ -199,7 +199,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
// Regular item or standalone note/attachment
&& (items[i].isRegularItem() || !items[i].getSource()))
{
this._showItem(new Scholar.ItemTreeView.TreeRow(items[i],0,false),this.rowCount);
this._showItem(new Zotero.ItemTreeView.TreeRow(items[i],0,false),this.rowCount);
this._treebox.rowCountChanged(this.rowCount-1,1);
madeChanges = true;
@ -237,7 +237,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
{
// Reset to Info tab
this._treebox.treeBody.ownerDocument.
getElementById('scholar-view-tabs').selectedIndex = 0;
getElementById('zotero-view-tabs').selectedIndex = 0;
this.selectItem(ids[0]);
}
@ -250,11 +250,11 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
}
/*
* Unregisters view from Scholar.Notifier (called on window close)
* Unregisters view from Zotero.Notifier (called on window close)
*/
Scholar.ItemTreeView.prototype.unregister = function()
Zotero.ItemTreeView.prototype.unregister = function()
{
Scholar.Notifier.unregisterItemTree(this._unregisterID);
Zotero.Notifier.unregisterItemTree(this._unregisterID);
}
////////////////////////////////////////////////////////////////////////////////
@ -264,7 +264,7 @@ Scholar.ItemTreeView.prototype.unregister = function()
///
////////////////////////////////////////////////////////////////////////////////
Scholar.ItemTreeView.prototype.getCellText = function(row, column)
Zotero.ItemTreeView.prototype.getCellText = function(row, column)
{
var obj = this._getItemAtRow(row);
var val;
@ -277,7 +277,7 @@ Scholar.ItemTreeView.prototype.getCellText = function(row, column)
}
else if(column.id == "typeIcon")
{
val = Scholar.getString('itemTypes.'+Scholar.ItemTypes.getName(obj.getType()));
val = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(obj.getType()));
}
else
{
@ -292,48 +292,48 @@ Scholar.ItemTreeView.prototype.getCellText = function(row, column)
return val;
}
Scholar.ItemTreeView.prototype.getImageSrc = function(row, col)
Zotero.ItemTreeView.prototype.getImageSrc = function(row, col)
{
if(col.id == 'title')
{
var item = this._getItemAtRow(row);
var itemType = Scholar.ItemTypes.getName(item.getType());
var itemType = Zotero.ItemTypes.getName(item.getType());
if(itemType == 'attachment')
{
var linkMode = item.ref.getAttachmentLinkMode();
if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_FILE)
if(linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_FILE)
{
itemType = itemType + "-file";
}
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_FILE)
else if(linkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE)
{
itemType = itemType + "-link";
}
else if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
else if(linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
{
itemType = itemType + "-snapshot";
}
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_URL)
else if(linkMode == Zotero.Attachments.LINK_MODE_LINKED_URL)
{
itemType = itemType + "-web-link";
}
}
return "chrome://scholar/skin/treeitem-"+itemType+".png";
return "chrome://zotero/skin/treeitem-"+itemType+".png";
}
}
Scholar.ItemTreeView.prototype.isContainer = function(row)
Zotero.ItemTreeView.prototype.isContainer = function(row)
{
return this._getItemAtRow(row).isRegularItem();
}
Scholar.ItemTreeView.prototype.isContainerOpen = function(row)
Zotero.ItemTreeView.prototype.isContainerOpen = function(row)
{
return this._dataItems[row].isOpen;
}
Scholar.ItemTreeView.prototype.isContainerEmpty = function(row)
Zotero.ItemTreeView.prototype.isContainerEmpty = function(row)
{
if(this._sourcesOnly) {
return true;
@ -342,13 +342,13 @@ Scholar.ItemTreeView.prototype.isContainerEmpty = function(row)
}
}
Scholar.ItemTreeView.prototype.getLevel = function(row)
Zotero.ItemTreeView.prototype.getLevel = function(row)
{
return this._getItemAtRow(row).level;
}
// Gets the index of the row's container, or -1 if none (container itself or top-level)
Scholar.ItemTreeView.prototype.getParentIndex = function(row)
Zotero.ItemTreeView.prototype.getParentIndex = function(row)
{
if (row==-1)
{
@ -362,7 +362,7 @@ Scholar.ItemTreeView.prototype.getParentIndex = function(row)
return -1;
}
Scholar.ItemTreeView.prototype.hasNextSibling = function(row,afterIndex)
Zotero.ItemTreeView.prototype.hasNextSibling = function(row,afterIndex)
{
var thisLevel = this.getLevel(row);
for(var i = afterIndex + 1; i < this.rowCount; i++)
@ -373,7 +373,7 @@ Scholar.ItemTreeView.prototype.hasNextSibling = function(row,afterIndex)
}
}
Scholar.ItemTreeView.prototype.toggleOpenState = function(row)
Zotero.ItemTreeView.prototype.toggleOpenState = function(row)
{
var count = 0; //used to tell the tree how many rows were added/removed
var thisLevel = this.getLevel(row);
@ -401,12 +401,12 @@ Scholar.ItemTreeView.prototype.toggleOpenState = function(row)
else if(notes)
newRows = notes;
newRows = Scholar.Items.get(newRows);
newRows = Zotero.Items.get(newRows);
for(var i = 0; i < newRows.length; i++)
{
count++;
this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],thisLevel+1,false), row+i+1); //item ref, before row
this._showItem(new Zotero.ItemTreeView.TreeRow(newRows[i],thisLevel+1,false), row+i+1); //item ref, before row
}
}
@ -419,7 +419,7 @@ Scholar.ItemTreeView.prototype.toggleOpenState = function(row)
this._refreshHashMap();
}
Scholar.ItemTreeView.prototype.isSorted = function()
Zotero.ItemTreeView.prototype.isSorted = function()
{
for(var i=0, len=this._treebox.columns.count; i<len; i++)
if(this._treebox.columns.getColumnAt(i).element.getAttribute('sortActive'))
@ -427,7 +427,7 @@ Scholar.ItemTreeView.prototype.isSorted = function()
return false;
}
Scholar.ItemTreeView.prototype.cycleHeader = function(column)
Zotero.ItemTreeView.prototype.cycleHeader = function(column)
{
for(var i=0, len=this._treebox.columns.count; i<len; i++)
{
@ -456,7 +456,7 @@ Scholar.ItemTreeView.prototype.cycleHeader = function(column)
* Sort the items by the currently sorted column.
* Simply uses Array.sort() function, and refreshes the hash map.
*/
Scholar.ItemTreeView.prototype.sort = function()
Zotero.ItemTreeView.prototype.sort = function()
{
var column = this._treebox.columns.getSortedColumn()
var order = column.element.getAttribute('sortDirection') == 'descending';
@ -465,8 +465,8 @@ Scholar.ItemTreeView.prototype.sort = function()
{
function columnSort(a,b)
{
var typeA = Scholar.getString('itemTypes.'+Scholar.ItemTypes.getName(a.getType()));
var typeB = Scholar.getString('itemTypes.'+Scholar.ItemTypes.getName(b.getType()));
var typeA = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(a.getType()));
var typeB = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(b.getType()));
return (typeA > typeB) ? -1 : (typeA < typeB) ? 1 : 0;
}
@ -545,12 +545,12 @@ Scholar.ItemTreeView.prototype.sort = function()
/*
* Select an item
*/
Scholar.ItemTreeView.prototype.selectItem = function(id)
Zotero.ItemTreeView.prototype.selectItem = function(id)
{
var row = this._itemRowMap[id];
if(row == null)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
this.toggleOpenState(this._itemRowMap[item.getSource()]); //opens the parent of the item
row = this._itemRowMap[id];
}
@ -564,7 +564,7 @@ Scholar.ItemTreeView.prototype.selectItem = function(id)
*
* _force_ deletes item from DB even if removing from a collection
*/
Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren, force)
Zotero.ItemTreeView.prototype.deleteSelection = function(eraseChildren, force)
{
if(this.selection.count == 0)
return;
@ -601,7 +601,7 @@ Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren, force)
/*
* Set the search filter on the view
*/
Scholar.ItemTreeView.prototype.searchText = function(search)
Zotero.ItemTreeView.prototype.searchText = function(search)
{
this.selection.selectEventsSuppressed = true;
var savedSelection = this.saveSelection();
@ -624,7 +624,7 @@ Scholar.ItemTreeView.prototype.searchText = function(search)
* item: reference to the Item
* beforeRow: row index to insert new row before
*/
Scholar.ItemTreeView.prototype._showItem = function(item, beforeRow)
Zotero.ItemTreeView.prototype._showItem = function(item, beforeRow)
{
this._dataItems.splice(beforeRow, 0, item);
this.rowCount++;
@ -633,16 +633,16 @@ Scholar.ItemTreeView.prototype._showItem = function(item, beforeRow)
/*
* Called by view to hide specified row
*/
Scholar.ItemTreeView.prototype._hideItem = function(row)
Zotero.ItemTreeView.prototype._hideItem = function(row)
{
this._dataItems.splice(row,1);
this.rowCount--;
}
/*
* Returns a reference to the item at row (see Scholar.Item in data_access.js)
* Returns a reference to the item at row (see Zotero.Item in data_access.js)
*/
Scholar.ItemTreeView.prototype._getItemAtRow = function(row)
Zotero.ItemTreeView.prototype._getItemAtRow = function(row)
{
return this._dataItems[row];
}
@ -650,7 +650,7 @@ Scholar.ItemTreeView.prototype._getItemAtRow = function(row)
/*
* Create hash map of item ids to row indexes
*/
Scholar.ItemTreeView.prototype._refreshHashMap = function()
Zotero.ItemTreeView.prototype._refreshHashMap = function()
{
this._itemRowMap = new Array();
for(var i=0; i < this.rowCount; i++)
@ -663,7 +663,7 @@ Scholar.ItemTreeView.prototype._refreshHashMap = function()
/*
* Saves the ids of currently selected items for later
*/
Scholar.ItemTreeView.prototype.saveSelection = function()
Zotero.ItemTreeView.prototype.saveSelection = function()
{
var savedSelection = new Array();
@ -683,7 +683,7 @@ Scholar.ItemTreeView.prototype.saveSelection = function()
/*
* Sets the selection based on saved selection ids (see above)
*/
Scholar.ItemTreeView.prototype.rememberSelection = function(selection)
Zotero.ItemTreeView.prototype.rememberSelection = function(selection)
{
this.selection.clearSelection();
for(var i=0; i < selection.length; i++)
@ -700,28 +700,28 @@ Scholar.ItemTreeView.prototype.rememberSelection = function(selection)
///
////////////////////////////////////////////////////////////////////////////////
Scholar.ItemTreeCommandController = function(tree)
Zotero.ItemTreeCommandController = function(tree)
{
this.tree = tree;
}
Scholar.ItemTreeCommandController.prototype.supportsCommand = function(cmd)
Zotero.ItemTreeCommandController.prototype.supportsCommand = function(cmd)
{
return (cmd == 'cmd_selectAll');
}
Scholar.ItemTreeCommandController.prototype.isCommandEnabled = function(cmd)
Zotero.ItemTreeCommandController.prototype.isCommandEnabled = function(cmd)
{
return (cmd == 'cmd_selectAll');
}
Scholar.ItemTreeCommandController.prototype.doCommand = function(cmd)
Zotero.ItemTreeCommandController.prototype.doCommand = function(cmd)
{
if(cmd == 'cmd_selectAll')
this.tree.view.selection.selectAll();
}
Scholar.ItemTreeCommandController.prototype.onEvent = function(evt)
Zotero.ItemTreeCommandController.prototype.onEvent = function(evt)
{
}
@ -736,24 +736,24 @@ Scholar.ItemTreeCommandController.prototype.onEvent = function(evt)
/*
* Begin a drag
*/
Scholar.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
{
transferData.data=new TransferData();
transferData.data.addDataForFlavour("scholar/item", this.saveSelection());
transferData.data.addDataForFlavour("zotero/item", this.saveSelection());
}
/*
* Called by nsDragAndDrop.js for any sort of drop on the tree
*/
Scholar.ItemTreeView.prototype.getSupportedFlavours = function ()
Zotero.ItemTreeView.prototype.getSupportedFlavours = function ()
{
var flavors = new FlavourSet();
flavors.appendFlavour("scholar/item");
flavors.appendFlavour("zotero/item");
flavors.appendFlavour("text/x-moz-url");
return flavors;
}
Scholar.ItemTreeView.prototype.canDrop = function(row, orient)
Zotero.ItemTreeView.prototype.canDrop = function(row, orient)
{
try
{
@ -790,7 +790,7 @@ Scholar.ItemTreeView.prototype.canDrop = function(row, orient)
// already exist in target
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
// Skip non-top-level items
if (!item.isRegularItem() && item.getSource())
@ -810,20 +810,20 @@ Scholar.ItemTreeView.prototype.canDrop = function(row, orient)
return false;
}
//Scholar.debug('row is ' + row);
//Scholar.debug('orient is ' + orient);
//Zotero.debug('row is ' + row);
//Zotero.debug('orient is ' + orient);
// Highlight the rows correctly on drag
var rowItem = this._getItemAtRow(row).ref; //the item we are dragging over
if (dataType == 'scholar/item')
if (dataType == 'zotero/item')
{
// Directly on a row
if (orient == 0)
{
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
// Only allow dragging of notes and attachments
// that aren't already children of the item
if (!item.isRegularItem() && item.getSource()!=rowItem.getID())
@ -839,7 +839,7 @@ Scholar.ItemTreeView.prototype.canDrop = function(row, orient)
for each(var id in ids)
{
// Don't allow drag if any top-level items
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
if (item.isRegularItem() || !item.getSource())
{
return false;
@ -863,7 +863,7 @@ Scholar.ItemTreeView.prototype.canDrop = function(row, orient)
/*
* Called when something's been dropped on or next to a row
*/
Scholar.ItemTreeView.prototype.drop = function(row, orient)
Zotero.ItemTreeView.prototype.drop = function(row, orient)
{
try
{
@ -883,7 +883,7 @@ Scholar.ItemTreeView.prototype.drop = function(row, orient)
var data = dataSet.first.first;
var dataType = data.flavour.contentType;
if (dataType == 'scholar/item' && this.canDrop(row, orient))
if (dataType == 'zotero/item' && this.canDrop(row, orient))
{
var ids = data.data.split(','); // ids of rows we are dragging in
@ -895,7 +895,7 @@ Scholar.ItemTreeView.prototype.drop = function(row, orient)
rowItem = this._getItemAtRow(row).ref; // the item we are dragging over
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
item.setSource(rowItem.getID());
}
}
@ -908,7 +908,7 @@ Scholar.ItemTreeView.prototype.drop = function(row, orient)
{
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
if (!item.isRegularItem())
{
item.setSource();
@ -920,7 +920,7 @@ Scholar.ItemTreeView.prototype.drop = function(row, orient)
{
for each(var id in ids)
{
var item = Scholar.Items.get(id);
var item = Zotero.Items.get(id);
var source = item.isRegularItem() ? false : item.getSource();
// Top-level item
@ -943,7 +943,7 @@ Scholar.ItemTreeView.prototype.drop = function(row, orient)
var url = data.data.split("\n")[0];
/* WAITING FOR INGESTER SUPPORT
var newItem = Scholar.Ingester.scrapeURL(url);
var newItem = Zotero.Ingester.scrapeURL(url);
if(newItem)
this._getItemAtRow(row).ref.addItem(newItem.getID());
@ -954,9 +954,9 @@ Scholar.ItemTreeView.prototype.drop = function(row, orient)
/*
* Called by nsDragAndDrop.js for any sort of drop on the tree
*/
Scholar.ItemTreeView.prototype.onDrop = function (evt,dropdata,session){ }
Zotero.ItemTreeView.prototype.onDrop = function (evt,dropdata,session){ }
Scholar.ItemTreeView.prototype.onDragOver = function (evt,dropdata,session) { }
Zotero.ItemTreeView.prototype.onDragOver = function (evt,dropdata,session) { }
////////////////////////////////////////////////////////////////////////////////
///
@ -964,44 +964,44 @@ Scholar.ItemTreeView.prototype.onDragOver = function (evt,dropdata,session) { }
///
////////////////////////////////////////////////////////////////////////////////
Scholar.ItemTreeView.prototype.isSeparator = function(row) { return false; }
Scholar.ItemTreeView.prototype.getRowProperties = function(row, prop) { }
Scholar.ItemTreeView.prototype.getColumnProperties = function(col, prop) { }
Scholar.ItemTreeView.prototype.getCellProperties = function(row, col, prop) { }
Zotero.ItemTreeView.prototype.isSeparator = function(row) { return false; }
Zotero.ItemTreeView.prototype.getRowProperties = function(row, prop) { }
Zotero.ItemTreeView.prototype.getColumnProperties = function(col, prop) { }
Zotero.ItemTreeView.prototype.getCellProperties = function(row, col, prop) { }
Scholar.ItemTreeView.TreeRow = function(ref, level, isOpen)
Zotero.ItemTreeView.TreeRow = function(ref, level, isOpen)
{
this.ref = ref; //the item associated with this
this.level = level;
this.isOpen = isOpen;
}
Scholar.ItemTreeView.TreeRow.prototype.isNote = function()
Zotero.ItemTreeView.TreeRow.prototype.isNote = function()
{
return this.ref.isNote();
}
Scholar.ItemTreeView.TreeRow.prototype.isAttachment = function()
Zotero.ItemTreeView.TreeRow.prototype.isAttachment = function()
{
return this.ref.isAttachment();
}
Scholar.ItemTreeView.TreeRow.prototype.isRegularItem = function()
Zotero.ItemTreeView.TreeRow.prototype.isRegularItem = function()
{
return this.ref.isRegularItem();
}
Scholar.ItemTreeView.TreeRow.prototype.getField = function(field)
Zotero.ItemTreeView.TreeRow.prototype.getField = function(field)
{
return this.ref.getField(field);
}
Scholar.ItemTreeView.TreeRow.prototype.getType = function()
Zotero.ItemTreeView.TreeRow.prototype.getType = function()
{
return this.ref.getType();
}
Scholar.ItemTreeView.TreeRow.prototype.numChildren = function()
Zotero.ItemTreeView.TreeRow.prototype.numChildren = function()
{
if(this.isRegularItem())
return this.ref.numChildren();
@ -1009,7 +1009,7 @@ Scholar.ItemTreeView.TreeRow.prototype.numChildren = function()
return 0;
}
Scholar.ItemTreeView.TreeRow.prototype.numNotes = function()
Zotero.ItemTreeView.TreeRow.prototype.numNotes = function()
{
if(this.isRegularItem())
return this.ref.numNotes();
@ -1017,7 +1017,7 @@ Scholar.ItemTreeView.TreeRow.prototype.numNotes = function()
return 0;
}
Scholar.ItemTreeView.TreeRow.prototype.numAttachments = function()
Zotero.ItemTreeView.TreeRow.prototype.numAttachments = function()
{
if(this.isRegularItem())
return this.ref.numAttachments();

View file

@ -1,4 +1,4 @@
Scholar.MIME = new function(){
Zotero.MIME = new function(){
this.isExternalTextExtension = isExternalTextExtension;
this.sniffForMIMEType = sniffForMIMEType;
this.sniffForBinary = sniffForBinary;
@ -81,19 +81,19 @@ Scholar.MIME = new function(){
function getMIMETypeFromData(str, ext){
var mimeType = this.sniffForMIMEType(str);
if (mimeType){
Scholar.debug('Detected MIME type ' + mimeType);
Zotero.debug('Detected MIME type ' + mimeType);
return mimeType;
}
try {
var mimeType = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Components.interfaces.nsIMIMEService).getTypeFromExtension(ext);
Scholar.debug('Got MIME type ' + mimeType + ' from extension');
Zotero.debug('Got MIME type ' + mimeType + ' from extension');
return mimeType;
}
catch (e){
var mimeType = this.sniffForBinary(str);
Scholar.debug('Cannot determine MIME type -- settling for ' + mimeType);
Zotero.debug('Cannot determine MIME type -- settling for ' + mimeType);
return mimeType;
}
}
@ -104,8 +104,8 @@ Scholar.MIME = new function(){
* techniques
*/
function getMIMETypeFromFile(file){
var str = Scholar.File.getSample(file);
var ext = Scholar.File.getExtension(file);
var str = Zotero.File.getSample(file);
var ext = Zotero.File.getExtension(file);
return this.getMIMETypeFromData(str, ext);
}
@ -127,14 +127,14 @@ Scholar.MIME = new function(){
function hasInternalHandler(mimeType, ext){
if (mimeType=='text/plain'){
if (this.isExternalTextExtension(ext)){
Scholar.debug('text/plain file has extension that should be handled externally');
Zotero.debug('text/plain file has extension that should be handled externally');
return false;
}
return true;
}
if (_nativeMIMETypes[mimeType]){
Scholar.debug('MIME type ' + mimeType + ' can be handled natively');
Zotero.debug('MIME type ' + mimeType + ' can be handled natively');
return true;
}
@ -145,19 +145,19 @@ Scholar.MIME = new function(){
for (var i in types){
if (types[i].type==mimeType){
Scholar.debug('MIME type ' + mimeType + ' can be handled by plugins');
Zotero.debug('MIME type ' + mimeType + ' can be handled by plugins');
return true;
}
}
Scholar.debug('MIME type ' + mimeType + ' cannot be handled natively');
Zotero.debug('MIME type ' + mimeType + ' cannot be handled natively');
return false;
}
function fileHasInternalHandler(file){
var mimeType = this.getMIMETypeFromFile(file);
var ext = Scholar.File.getExtension(file);
var ext = Zotero.File.getExtension(file);
return this.hasInternalHandler(mimeType, ext);
}

View file

@ -1,8 +1,8 @@
Scholar.Notifier = new function(){
Zotero.Notifier = new function(){
var _observers = new Array();
var _disabled = false;
_observers['columnTree'] = new Scholar.Hash();
_observers['itemTree'] = new Scholar.Hash();
_observers['columnTree'] = new Zotero.Hash();
_observers['itemTree'] = new Zotero.Hash();
this.registerColumnTree = registerColumnTree;
this.registerItemTree = registerItemTree;
@ -51,13 +51,13 @@ Scholar.Notifier = new function(){
throw('Invalid type ' + type + ' in Notifier.trigger()');
}
Scholar.debug("Notifier.trigger('" + event + "', '" + type + "', "
Zotero.debug("Notifier.trigger('" + event + "', '" + type + "', "
+ (typeof ids=='object' ? '[' + ids.join() + ']' : ids) + ") called "
+ "[column trees: " + _observers['columnTree'].length
+ ", item trees: " + _observers['itemTree'].length + "]");
for (i in _observers[treeType].items){
Scholar.debug("Calling notify() on " + treeType + " with hash '"
Zotero.debug("Calling notify() on " + treeType + " with hash '"
+ i + "'", 4);
_observers[treeType].get(i).notify(event, type, ids);
}
@ -67,13 +67,13 @@ Scholar.Notifier = new function(){
function disable(){
Scholar.debug('Disabling Notifier notifications');
Zotero.debug('Disabling Notifier notifications');
_disabled = true;
}
function enable(){
Scholar.debug('Enabling Notifier notifications');
Zotero.debug('Enabling Notifier notifications');
_disabled = false;
}
@ -93,18 +93,18 @@ Scholar.Notifier = new function(){
tries = 10;
}
var hash = Scholar.randomString(len);
var hash = Zotero.randomString(len);
tries--;
}
while (_observers[type].get(hash));
Scholar.debug('Registering ' + type + " in notifier with hash '" + hash + "'", 4);
Zotero.debug('Registering ' + type + " in notifier with hash '" + hash + "'", 4);
_observers[type].set(hash, ref);
return hash;
}
function _unregister(type, hash){
Scholar.debug("Unregistering " + type + " in notifier with hash '" + hash + "'", 4);
Zotero.debug("Unregistering " + type + " in notifier with hash '" + hash + "'", 4);
_observers[type].remove(hash);
}
}

View file

@ -3,7 +3,7 @@
*
* Pass the active window into the constructor
*/
Scholar.ProgressWindow = function(_window){
Zotero.ProgressWindow = function(_window){
if (!_window){
var _window =
Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
@ -33,7 +33,7 @@ Scholar.ProgressWindow = function(_window){
if(_windowLoading || _windowLoaded) { // already loading or loaded
return false;
}
_progressWindow = _window.openDialog("chrome://scholar/chrome/progressWindow.xul",
_progressWindow = _window.openDialog("chrome://zotero/chrome/progressWindow.xul",
"", "chrome,dialog=no,titlebar=no,popup=yes");
_progressWindow.addEventListener("load", _onWindowLoaded, false);
_windowLoading = true;

View file

@ -1,4 +1,4 @@
Scholar.Schema = new function(){
Zotero.Schema = new function(){
var _dbVersions = [];
var _schemaVersions = [];
var _repositoryTimer;
@ -15,7 +15,7 @@ Scholar.Schema = new function(){
// 'schema' check is for old (<= 1.0b1) schema system
if (!dbVersion && !_getDBVersion('schema')){
Scholar.debug('Database does not exist -- creating\n');
Zotero.debug('Database does not exist -- creating\n');
_initializeSchema();
return;
}
@ -27,7 +27,7 @@ Scholar.Schema = new function(){
var schemaVersion = _getSchemaSQLVersion('user');
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
_migrateUserSchema(dbVersion);
@ -35,14 +35,14 @@ Scholar.Schema = new function(){
_updateSchema('scrapers');
// Rebuild fulltext cache if necessary
if (Scholar.Fulltext.cacheIsOutdated()){
Scholar.Fulltext.rebuildCache();
if (Zotero.Fulltext.cacheIsOutdated()){
Zotero.Fulltext.rebuildCache();
}
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
catch(e){
Scholar.debug(e);
Scholar.DB.rollbackTransaction();
Zotero.debug(e);
Zotero.DB.rollbackTransaction();
throw(e);
}
return;
@ -58,20 +58,20 @@ Scholar.Schema = new function(){
function updateScrapersRemote(force){
if (!force){
// Check user preference for automatic updates
if (!Scholar.Prefs.get('automaticScraperUpdates')){
Scholar.debug('Automatic scraper updating disabled -- not checking repository', 4);
if (!Zotero.Prefs.get('automaticScraperUpdates')){
Zotero.debug('Automatic scraper updating disabled -- not checking repository', 4);
return false;
}
// Determine the earliest local time that we'd query the repository again
var nextCheck = new Date();
nextCheck.setTime((parseInt(_getDBVersion('lastcheck'))
+ SCHOLAR_CONFIG['REPOSITORY_CHECK_INTERVAL']) * 1000); // JS uses ms
+ ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']) * 1000); // JS uses ms
var now = new Date();
// If enough time hasn't passed, don't update
if (now < nextCheck){
Scholar.debug('Not enough time since last update -- not checking repository', 4);
Zotero.debug('Not enough time since last update -- not checking repository', 4);
// Set the repository timer to the remaining time
_setRepositoryTimer(Math.round((nextCheck.getTime() - now.getTime()) / 1000));
return false;
@ -79,8 +79,8 @@ Scholar.Schema = new function(){
}
// If transaction already in progress, delay by a few seconds
if (Scholar.DB.transactionInProgress()){
Scholar.debug('Transaction in progress -- delaying repository check', 4)
if (Zotero.DB.transactionInProgress()){
Zotero.debug('Transaction in progress -- delaying repository check', 4)
_setRepositoryTimer(30);
return false;
}
@ -88,24 +88,24 @@ Scholar.Schema = new function(){
// Get the last timestamp we got from the server
var lastUpdated = _getDBVersion('repository');
var url = SCHOLAR_CONFIG['REPOSITORY_URL'] + '/updated?'
var url = ZOTERO_CONFIG['REPOSITORY_URL'] + '/updated?'
+ (lastUpdated ? 'last=' + lastUpdated + '&' : '')
+ 'version=' + Scholar.version;
+ 'version=' + Zotero.version;
Scholar.debug('Checking repository for updates (' + url + ')');
var get = Scholar.Utilities.HTTP.doGet(url, _updateScrapersRemoteCallback);
Zotero.debug('Checking repository for updates (' + url + ')');
var get = Zotero.Utilities.HTTP.doGet(url, _updateScrapersRemoteCallback);
// TODO: instead, add an observer to start and stop timer on online state change
if (!get){
Scholar.debug('Browser is offline -- skipping check');
_setRepositoryTimer(SCHOLAR_CONFIG['REPOSITORY_RETRY_INTERVAL']);
Zotero.debug('Browser is offline -- skipping check');
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']);
}
}
function stopRepositoryTimer(){
if (_repositoryTimer){
Scholar.debug('Stopping repository check timer');
Zotero.debug('Stopping repository check timer');
_repositoryTimer.cancel();
}
}
@ -131,8 +131,8 @@ Scholar.Schema = new function(){
return _dbVersions[schema];
}
if (Scholar.DB.tableExists('version')){
var dbVersion = Scholar.DB.valueQuery("SELECT version FROM "
if (Zotero.DB.tableExists('version')){
var dbVersion = Zotero.DB.valueQuery("SELECT version FROM "
+ "version WHERE schema='" + schema + "'");
_dbVersions[schema] = dbVersion;
return dbVersion;
@ -157,8 +157,8 @@ Scholar.Schema = new function(){
var file = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager)
.getInstallLocation(SCHOLAR_CONFIG['GUID'])
.getItemLocation(SCHOLAR_CONFIG['GUID']);
.getInstallLocation(ZOTERO_CONFIG['GUID'])
.getItemLocation(ZOTERO_CONFIG['GUID']);
file.append(schemaFile);
// Open an input stream from file
@ -195,8 +195,8 @@ Scholar.Schema = new function(){
// it when necessary
var file = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager)
.getInstallLocation(SCHOLAR_CONFIG['GUID'])
.getItemLocation(SCHOLAR_CONFIG['GUID']);
.getInstallLocation(ZOTERO_CONFIG['GUID'])
.getItemLocation(ZOTERO_CONFIG['GUID']);
file.append(schemaFile);
// Open an input stream from file
@ -241,8 +241,8 @@ Scholar.Schema = new function(){
// it when necessary
var file = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager)
.getInstallLocation(SCHOLAR_CONFIG['GUID'])
.getItemLocation(SCHOLAR_CONFIG['GUID']);
.getInstallLocation(ZOTERO_CONFIG['GUID'])
.getItemLocation(ZOTERO_CONFIG['GUID']);
file.append(schemaFile);
// Open an input stream from file
@ -275,31 +275,31 @@ Scholar.Schema = new function(){
* Create new DB schema
*/
function _initializeSchema(){
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
Scholar.DB.query(_getSchemaSQL('user'));
Zotero.DB.query(_getSchemaSQL('user'));
_updateDBVersion('user', _getSchemaSQLVersion('user'));
Scholar.DB.query(_getSchemaSQL('system'));
Zotero.DB.query(_getSchemaSQL('system'));
_updateDBVersion('system', _getSchemaSQLVersion('system'));
Scholar.DB.query(_getSchemaSQL('scrapers'));
Zotero.DB.query(_getSchemaSQL('scrapers'));
_updateDBVersion('scrapers', _getSchemaSQLVersion('scrapers'));
var sql = "INSERT INTO items VALUES(1233, 14, "
+ "'Zotero - Quick Start Guide', '2006-08-31 20:00:00', "
+ "'2006-08-31 20:00:00')";
Scholar.DB.query(sql);
Zotero.DB.query(sql);
var sql = "INSERT INTO itemAttachments VALUES(1233, NULL, 3, "
+ "'text/html', 25, "
+ "'http://www.zotero.org/docs/quick_start_guide.php', NULL)";
Scholar.DB.query(sql);
Zotero.DB.query(sql);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
catch(e){
Scholar.debug(e, 1);
Scholar.DB.rollbackTransaction();
Zotero.debug(e, 1);
Zotero.DB.rollbackTransaction();
alert('Error initializing Zotero database'); // TODO: localize
throw(e);
}
@ -312,7 +312,7 @@ Scholar.Schema = new function(){
function _updateDBVersion(schema, version){
_dbVersions[schema] = version;
var sql = "REPLACE INTO version (schema,version) VALUES (?,?)";
return Scholar.DB.query(sql, [{'string':schema},{'int':version}]);
return Zotero.DB.query(sql, [{'string':schema},{'int':version}]);
}
@ -324,15 +324,15 @@ Scholar.Schema = new function(){
return;
}
else if (dbVersion < schemaVersion){
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
Scholar.DB.query(_getSchemaSQL(schema));
Zotero.DB.query(_getSchemaSQL(schema));
_updateDBVersion(schema, schemaVersion);
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
catch (e){
Scholar.debug(e, 1);
Scholar.DB.rollbackTransaction();
Zotero.debug(e, 1);
Zotero.DB.rollbackTransaction();
alert('Error updating Zotero database'); // TODO: localize
throw(e);
}
@ -350,12 +350,12 @@ Scholar.Schema = new function(){
function _updateScrapersRemoteCallback(xmlhttp){
if (!xmlhttp.responseXML){
if (xmlhttp.status>1000){
Scholar.debug('No network connection', 2);
Zotero.debug('No network connection', 2);
}
else {
Scholar.debug('Invalid response from repository', 2);
Zotero.debug('Invalid response from repository', 2);
}
_setRepositoryTimer(SCHOLAR_CONFIG['REPOSITORY_RETRY_INTERVAL']);
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']);
return false;
}
@ -363,7 +363,7 @@ Scholar.Schema = new function(){
getElementsByTagName('currentTime')[0].firstChild.nodeValue;
var updates = xmlhttp.responseXML.getElementsByTagName('translator');
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
// Store the timestamp provided by the server
_updateDBVersion('repository', currentTime);
@ -373,9 +373,9 @@ Scholar.Schema = new function(){
_updateDBVersion('lastcheck', Math.round(d.getTime()/1000)); // JS uses ms
if (!updates.length){
Scholar.debug('All scrapers are up-to-date');
Scholar.DB.commitTransaction();
_setRepositoryTimer(SCHOLAR_CONFIG['REPOSITORY_CHECK_INTERVAL']);
Zotero.debug('All scrapers are up-to-date');
Zotero.DB.commitTransaction();
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']);
return false;
}
@ -384,16 +384,16 @@ Scholar.Schema = new function(){
_scraperXMLToDBQuery(updates[i]);
}
catch (e) {
Scholar.debug(e, 1);
Scholar.DB.rollbackTransaction();
Zotero.debug(e, 1);
Zotero.DB.rollbackTransaction();
var breakout = true;
break;
}
}
if (!breakout){
Scholar.DB.commitTransaction();
_setRepositoryTimer(SCHOLAR_CONFIG['REPOSITORY_CHECK_INTERVAL']);
Zotero.DB.commitTransaction();
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']);
}
}
@ -405,7 +405,7 @@ Scholar.Schema = new function(){
**/
function _setRepositoryTimer(interval){
if (!interval){
interval = SCHOLAR_CONFIG['REPOSITORY_CHECK_INTERVAL'];
interval = ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL'];
}
var fudge = 2; // two seconds
@ -413,13 +413,13 @@ Scholar.Schema = new function(){
var interval = (interval + fudge) * 1000; // convert to ms
if (!_repositoryTimer || _repositoryTimer.delay!=interval){
Scholar.debug('Setting repository check interval to ' + displayInterval + ' seconds');
Zotero.debug('Setting repository check interval to ' + displayInterval + ' seconds');
_repositoryTimer = Components.classes["@mozilla.org/timer;1"].
createInstance(Components.interfaces.nsITimer);
_repositoryTimer.initWithCallback({
// implements nsITimerCallback
notify: function(timer){
Scholar.Schema.updateScrapersRemote();
Zotero.Schema.updateScrapersRemote();
}
}, interval, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
}
@ -451,7 +451,7 @@ Scholar.Schema = new function(){
]
var sql = "REPLACE INTO translators VALUES (?,?,?,?,?,?,?,?)";
return Scholar.DB.query(sql, sqlValues);
return Zotero.DB.query(sql, sqlValues);
}
@ -469,9 +469,9 @@ Scholar.Schema = new function(){
throw("Zotero user DB version is newer than SQL file");
}
Scholar.debug('Updating user tables from version ' + fromVersion + ' to ' + toVersion);
Zotero.debug('Updating user tables from version ' + fromVersion + ' to ' + toVersion);
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
try {
// Step through version changes until we reach the current version
@ -480,24 +480,24 @@ Scholar.Schema = new function(){
// previous revision to that one.
for (var i=fromVersion + 1; i<=toVersion; i++){
if (i==1){
Scholar.DB.query("DELETE FROM version WHERE schema='schema'");
Zotero.DB.query("DELETE FROM version WHERE schema='schema'");
}
if (i==5){
Scholar.DB.query("REPLACE INTO itemData SELECT itemID, 1, originalPath FROM itemAttachments WHERE linkMode=1");
Scholar.DB.query("REPLACE INTO itemData SELECT itemID, 1, path FROM itemAttachments WHERE linkMode=3");
Scholar.DB.query("REPLACE INTO itemData SELECT itemID, 27, dateAdded FROM items NATURAL JOIN itemAttachments WHERE linkMode IN (1,3)");
Scholar.DB.query("UPDATE itemAttachments SET originalPath=NULL WHERE linkMode=1");
Scholar.DB.query("UPDATE itemAttachments SET path=NULL WHERE linkMode=3");
try { Scholar.DB.query("DELETE FROM fulltextItems WHERE itemID IS NULL"); } catch(e){}
Zotero.DB.query("REPLACE INTO itemData SELECT itemID, 1, originalPath FROM itemAttachments WHERE linkMode=1");
Zotero.DB.query("REPLACE INTO itemData SELECT itemID, 1, path FROM itemAttachments WHERE linkMode=3");
Zotero.DB.query("REPLACE INTO itemData SELECT itemID, 27, dateAdded FROM items NATURAL JOIN itemAttachments WHERE linkMode IN (1,3)");
Zotero.DB.query("UPDATE itemAttachments SET originalPath=NULL WHERE linkMode=1");
Zotero.DB.query("UPDATE itemAttachments SET path=NULL WHERE linkMode=3");
try { Zotero.DB.query("DELETE FROM fulltextItems WHERE itemID IS NULL"); } catch(e){}
}
}
_updateSchema('user');
Scholar.DB.commitTransaction();
Zotero.DB.commitTransaction();
}
catch(e){
Scholar.debug(e);
Zotero.debug(e);
alert('Error migrating Zotero database');
throw(e);
}

View file

@ -1,4 +1,4 @@
const SCHOLAR_CONFIG = {
const ZOTERO_CONFIG = {
GUID: 'zotero@chnm.gmu.edu',
DB_FILE: 'zotero.sqlite',
DB_REBUILD: false, // erase DB and recreate from schema
@ -12,7 +12,7 @@ const SCHOLAR_CONFIG = {
/*
* Core functions
*/
var Scholar = new function(){
var Zotero = new function(){
var _initialized = false;
var _shutdown = false;
var _localizedStringBundle;
@ -21,9 +21,9 @@ var Scholar = new function(){
this.init = init;
this.shutdown = shutdown;
this.getProfileDirectory = getProfileDirectory;
this.getScholarDirectory = getScholarDirectory;
this.getZoteroDirectory = getZoteroDirectory;
this.getStorageDirectory = getStorageDirectory;
this.getScholarDatabase = getScholarDatabase;
this.getZoteroDatabase = getZoteroDatabase;
this.backupDatabase = backupDatabase;
this.debug = debug;
this.varDump = varDump;
@ -52,17 +52,17 @@ var Scholar = new function(){
return false;
}
// Register shutdown handler to call Scholar.shutdown()
// Register shutdown handler to call Zotero.shutdown()
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver({
observe: function(subject, topic, data){
Scholar.shutdown(subject, topic, data)
Zotero.shutdown(subject, topic, data)
}
}, "xpcom-shutdown", false);
// Load in the preferences branch for the extension
Scholar.Prefs.init();
Zotero.Prefs.init();
// Load in the extension version from the extension manager
var nsIUpdateItem = Components.interfaces.nsIUpdateItem;
@ -71,7 +71,7 @@ var Scholar = new function(){
.getService(Components.interfaces.nsIExtensionManager);
var itemType = nsIUpdateItem.TYPE_EXTENSION;
this.version
= gExtensionManager.getItemForID(SCHOLAR_CONFIG['GUID']).version;
= gExtensionManager.getItemForID(ZOTERO_CONFIG['GUID']).version;
// OS platform
var win = Components.classes["@mozilla.org/appshell/appShellService;1"]
@ -86,7 +86,7 @@ var Scholar = new function(){
this.locale = localeService.getLocaleComponentForUserAgent();
// Load in the localization stringbundle for use by getString(name)
var src = 'chrome://scholar/locale/scholar.properties';
var src = 'chrome://zotero/locale/zotero.properties';
var localeService =
Components.classes["@mozilla.org/intl/nslocaleservice;1"]
.getService(Components.interfaces.nsILocaleService);
@ -97,12 +97,12 @@ var Scholar = new function(){
_localizedStringBundle = stringBundleService.createBundle(src, appLocale);
// Trigger updating of schema and scrapers
Scholar.Schema.updateSchema();
Scholar.Schema.updateScrapersRemote();
Zotero.Schema.updateSchema();
Zotero.Schema.updateScrapersRemote();
// Initialize integration web server
Scholar.Integration.SOAP.init();
Scholar.Integration.init();
Zotero.Integration.SOAP.init();
Zotero.Integration.init();
_initialized = true;
return true;
@ -117,7 +117,7 @@ var Scholar = new function(){
_shutdown = true;
Scholar.backupDatabase();
Zotero.backupDatabase();
return true;
}
@ -130,8 +130,8 @@ var Scholar = new function(){
}
function getScholarDirectory(){
var file = Scholar.getProfileDirectory();
function getZoteroDirectory(){
var file = Zotero.getProfileDirectory();
file.append('zotero');
// If it doesn't exist, create
@ -143,7 +143,7 @@ var Scholar = new function(){
function getStorageDirectory(){
var file = Scholar.getScholarDirectory();
var file = Zotero.getZoteroDirectory();
file.append('storage');
// If it doesn't exist, create
@ -153,11 +153,11 @@ var Scholar = new function(){
return file;
}
function getScholarDatabase(ext){
function getZoteroDatabase(ext){
ext = ext ? '.' + ext : '';
var file = Scholar.getScholarDirectory();
file.append(SCHOLAR_CONFIG['DB_FILE'] + ext);
var file = Zotero.getZoteroDirectory();
file.append(ZOTERO_CONFIG['DB_FILE'] + ext);
return file;
}
@ -169,19 +169,19 @@ var Scholar = new function(){
* haven't been flushed to disk -- proceed with caution
*/
function backupDatabase(){
if (Scholar.DB.transactionInProgress()){
Scholar.debug('Transaction in progress--skipping DB backup', 2);
if (Zotero.DB.transactionInProgress()){
Zotero.debug('Transaction in progress--skipping DB backup', 2);
return false;
}
Scholar.debug('Backing up database');
Zotero.debug('Backing up database');
var file = Scholar.getScholarDatabase();
var backupFile = Scholar.getScholarDatabase('bak');
var file = Zotero.getZoteroDatabase();
var backupFile = Zotero.getZoteroDatabase('bak');
// Copy via a temporary file so we don't run into disk space issues
// after deleting the old backup file
var tmpFile = Scholar.getScholarDatabase('tmp');
var tmpFile = Zotero.getZoteroDatabase('tmp');
if (tmpFile.exists()){
tmpFile.remove(null);
}
@ -215,19 +215,19 @@ var Scholar = new function(){
* Defaults to log level 3 if level not provided
*/
function debug(message, level) {
if (!SCHOLAR_CONFIG['DEBUG_LOGGING']){
if (!ZOTERO_CONFIG['DEBUG_LOGGING']){
return false;
}
if (typeof message!='string'){
message = Scholar.varDump(message);
message = Zotero.varDump(message);
}
if (!level){
level = 3;
}
if (!SCHOLAR_CONFIG['DEBUG_TO_CONSOLE']){
if (!ZOTERO_CONFIG['DEBUG_TO_CONSOLE']){
try {
var logManager =
Components.classes["@mozmonkey.com/debuglogger/manager;1"]
@ -437,7 +437,7 @@ var Scholar = new function(){
max = max * 128;
}
var rnd = Math.floor(Math.random()*max);
var exists = Scholar.DB.valueQuery(sql + rnd);
var exists = Zotero.DB.valueQuery(sql + rnd);
tries--;
}
while (exists);
@ -459,7 +459,7 @@ var Scholar = new function(){
Scholar.Prefs = new function(){
Zotero.Prefs = new function(){
// Privileged methods
this.init = init;
this.get = get;
@ -470,12 +470,12 @@ Scholar.Prefs = new function(){
this.observe = observe;
// Public properties
this.prefBranch; // set in Scholar.init()
this.prefBranch; // set in Zotero.init()
function init(){
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
this.prefBranch = prefs.getBranch("extensions.scholar.");
this.prefBranch = prefs.getBranch("extensions.zotero.");
// Register observer to handle pref changes
this.register();
@ -546,10 +546,10 @@ Scholar.Prefs = new function(){
switch (data){
case "automaticScraperUpdates":
if (this.get('automaticScraperUpdates')){
Scholar.Schema.updateScrapersRemote();
Zotero.Schema.updateScrapersRemote();
}
else {
Scholar.Schema.stopRepositoryTimer();
Zotero.Schema.stopRepositoryTimer();
}
break;
}
@ -563,7 +563,7 @@ Scholar.Prefs = new function(){
*
* Hashes can be created in the constructor by alternating key and val:
*
* var hasharray = new Scholar.Hash('foo','foovalue','bar','barvalue');
* var hasharray = new Zotero.Hash('foo','foovalue','bar','barvalue');
*
* Or using hasharray.set(key, val)
*
@ -580,7 +580,7 @@ Scholar.Prefs = new function(){
* (c) Mojavelinux, Inc.
* License: Creative Commons
**/
Scholar.Hash = function(){
Zotero.Hash = function(){
this.length = 0;
this.items = new Array();
@ -594,11 +594,11 @@ Scholar.Hash = function(){
}
}
Scholar.Hash.prototype.get = function(in_key){
Zotero.Hash.prototype.get = function(in_key){
return this.items[in_key] ? this.items[in_key] : false;
}
Scholar.Hash.prototype.set = function(in_key, in_value){
Zotero.Hash.prototype.set = function(in_key, in_value){
// Default to a boolean hash if value not provided
if (typeof(in_value) == 'undefined'){
in_value = true;
@ -613,7 +613,7 @@ Scholar.Hash.prototype.set = function(in_key, in_value){
return in_value;
}
Scholar.Hash.prototype.remove = function(in_key){
Zotero.Hash.prototype.remove = function(in_key){
var tmp_value;
if (typeof(this.items[in_key]) != 'undefined') {
this.length--;
@ -624,13 +624,13 @@ Scholar.Hash.prototype.remove = function(in_key){
return tmp_value;
}
Scholar.Hash.prototype.has = function(in_key){
Zotero.Hash.prototype.has = function(in_key){
return typeof(this.items[in_key]) != 'undefined';
}
Scholar.Date = new function(){
Zotero.Date = new function(){
this.sqlToDate = sqlToDate;
this.strToDate = strToDate;
this.formatDate = formatDate;
@ -667,7 +667,7 @@ Scholar.Date = new function(){
timeparts[0], timeparts[1], timeparts[2]);
}
catch (e){
Scholar.debug(sqldate + ' is not a valid SQL date', 2)
Zotero.debug(sqldate + ' is not a valid SQL date', 2)
return false;
}
}
@ -706,7 +706,7 @@ Scholar.Date = new function(){
} else {
// local style date (middle or little endian)
date.year = m[5];
var country = Scholar.locale.substr(3);
var country = Zotero.locale.substr(3);
if(country == "US" || // The United States
country == "FM" || // The Federated States of Micronesia
country == "PW" || // Palau
@ -748,7 +748,7 @@ Scholar.Date = new function(){
}
date.month--; // subtract one for JS style
Scholar.debug("DATE: retrieved with algorithms: "+date.toSource());
Zotero.debug("DATE: retrieved with algorithms: "+date.toSource());
return date;
}
}
@ -759,11 +759,11 @@ Scholar.Date = new function(){
if(m) {
date.year = m[2];
date.part = m[1]+m[3];
Scholar.debug("DATE: got year ("+date.year+", "+date.part+")");
Zotero.debug("DATE: got year ("+date.year+", "+date.part+")");
// get short month strings from CSL interpreter
if(!months) {
var months = Scholar.CSL.getMonthStrings("short");
var months = Zotero.CSL.getMonthStrings("short");
}
if(!_monthRe) {
// then, see if have anything resembling a month anywhere
@ -774,11 +774,11 @@ Scholar.Date = new function(){
if(m) {
date.month = months.indexOf(m[2][0].toUpperCase()+m[2].substr(1).toLowerCase());
date.part = m[1]+m[3];
Scholar.debug("DATE: got month ("+date.month+", "+date.part+")");
Zotero.debug("DATE: got month ("+date.month+", "+date.part+")");
// then, see if there's a day
if(!_dayRe) {
var daySuffixes = Scholar.getString("date.daySuffixes").replace(/, ?/g, "|");
var daySuffixes = Zotero.getString("date.daySuffixes").replace(/, ?/g, "|");
_dayRe = new RegExp("\\b([0-9]{1,2})(?:"+daySuffixes+")?\\b(.*)", "i");
}
var m = _dayRe.exec(date.part);
@ -794,7 +794,7 @@ Scholar.Date = new function(){
date.part = m[2];
}
Scholar.debug("DATE: got day ("+date.day+", "+date.part+")");
Zotero.debug("DATE: got day ("+date.day+", "+date.part+")");
}
}
}
@ -820,11 +820,11 @@ Scholar.Date = new function(){
}
if(!months) {
var months = Scholar.CSL.getMonthStrings("short");
var months = Zotero.CSL.getMonthStrings("short");
}
if(date.month != undefined && months[date.month]) {
// get short month strings from CSL interpreter
var months = Scholar.CSL.getMonthStrings("long");
var months = Zotero.CSL.getMonthStrings("long");
string += months[date.month];
if(date.day) {
string += " "+date.day+", ";
@ -854,7 +854,7 @@ Scholar.Date = new function(){
}
}
Scholar.Browser = new function() {
Zotero.Browser = new function() {
this.createHiddenBrowser = createHiddenBrowser;
this.deleteHiddenBrowser = deleteHiddenBrowser;
@ -868,7 +868,7 @@ Scholar.Browser = new function() {
// Create a hidden browser
var newHiddenBrowser = myWindow.document.createElement("browser");
myWindow.document.documentElement.appendChild(newHiddenBrowser);
Scholar.debug("created hidden browser ("
Zotero.debug("created hidden browser ("
+ myWindow.document.getElementsByTagName('browser').length + ")");
return newHiddenBrowser;
}
@ -877,6 +877,6 @@ Scholar.Browser = new function() {
// Delete a hidden browser
myBrowser.parentNode.removeChild(myBrowser);
delete myBrowser;
Scholar.debug("deleted hidden browser");
Zotero.debug("deleted hidden browser");
}
}

View file

@ -1,4 +1,4 @@
Scholar.Search = function(){
Zotero.Search = function(){
this._sql = null;
this._sqlParams = null;
this._maxSearchConditionID = 0;
@ -13,7 +13,7 @@ Scholar.Search = function(){
*
* Must be called before save() for new searches
*/
Scholar.Search.prototype.setName = function(name){
Zotero.Search.prototype.setName = function(name){
if (!name){
throw("Invalid saved search name '" + name + '"');
}
@ -25,12 +25,12 @@ Scholar.Search.prototype.setName = function(name){
/*
* Load a saved search from the DB
*/
Scholar.Search.prototype.load = function(savedSearchID){
Zotero.Search.prototype.load = function(savedSearchID){
var sql = "SELECT savedSearchName, MAX(searchConditionID) AS maxID "
+ "FROM savedSearches LEFT JOIN savedSearchConditions "
+ "USING (savedSearchID) WHERE savedSearchID=" + savedSearchID
+ " GROUP BY savedSearchID";
var row = Scholar.DB.rowQuery(sql);
var row = Zotero.DB.rowQuery(sql);
if (!row){
throw('Saved search ' + savedSearchID + ' does not exist');
@ -43,16 +43,16 @@ Scholar.Search.prototype.load = function(savedSearchID){
this._savedSearchID = savedSearchID;
this._savedSearchName = row['savedSearchName'];
var conditions = Scholar.DB.query("SELECT * FROM savedSearchConditions "
var conditions = Zotero.DB.query("SELECT * FROM savedSearchConditions "
+ "WHERE savedSearchID=" + savedSearchID + " ORDER BY searchConditionID");
for (var i in conditions){
// Parse "condition[/mode]"
var [condition, mode] =
Scholar.SearchConditions.parseCondition(conditions[i]['condition']);
Zotero.SearchConditions.parseCondition(conditions[i]['condition']);
if (!Scholar.SearchConditions.get(condition)){
Scholar.debug("Invalid saved search condition '"
if (!Zotero.SearchConditions.get(condition)){
Zotero.debug("Invalid saved search condition '"
+ condition + "' -- skipping", 2);
continue;
}
@ -69,12 +69,12 @@ Scholar.Search.prototype.load = function(savedSearchID){
}
Scholar.Search.prototype.getID = function(){
Zotero.Search.prototype.getID = function(){
return this._savedSearchID;
}
Scholar.Search.prototype.getName = function(){
Zotero.Search.prototype.getName = function(){
return this._savedSearchName;
}
@ -84,29 +84,29 @@ Scholar.Search.prototype.getName = function(){
*
* For new searches, setName() must be called before saving
*/
Scholar.Search.prototype.save = function(){
Zotero.Search.prototype.save = function(){
if (!this._savedSearchName){
throw('Name not provided for saved search');
}
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
if (this._savedSearchID){
var sql = "UPDATE savedSearches SET savedSearchName=? WHERE savedSearchID=?";
Scholar.DB.query(sql, [this._savedSearchName, this._savedSearchID]);
Zotero.DB.query(sql, [this._savedSearchName, this._savedSearchID]);
Scholar.DB.query("DELETE FROM savedSearchConditions "
Zotero.DB.query("DELETE FROM savedSearchConditions "
+ "WHERE savedSearchID=" + this._savedSearchID);
}
else {
var isNew = true;
this._savedSearchID
= Scholar.getRandomID('savedSearches', 'savedSearchID');
= Zotero.getRandomID('savedSearches', 'savedSearchID');
var sql = "INSERT INTO savedSearches (savedSearchID, savedSearchName) "
+ "VALUES (?,?)";
Scholar.DB.query(sql,
Zotero.DB.query(sql,
[this._savedSearchID, {string: this._savedSearchName}]);
}
@ -130,19 +130,19 @@ Scholar.Search.prototype.save = function(){
this._conditions[i]['required']
? 1 : null
];
Scholar.DB.query(sql, sqlParams);
Zotero.DB.query(sql, sqlParams);
}
Scholar.DB.commitTransaction();
Scholar.Notifier.trigger(
Zotero.DB.commitTransaction();
Zotero.Notifier.trigger(
(isNew ? 'add' : 'modify'), 'search', this._savedSearchID
);
return this._savedSearchID;
}
Scholar.Search.prototype.addCondition = function(condition, operator, value, required){
if (!Scholar.SearchConditions.hasOperator(condition, operator)){
Zotero.Search.prototype.addCondition = function(condition, operator, value, required){
if (!Zotero.SearchConditions.hasOperator(condition, operator)){
throw ("Invalid operator '" + operator + "' for condition " + condition);
}
@ -151,7 +151,7 @@ Scholar.Search.prototype.addCondition = function(condition, operator, value, req
this.addCondition('joinMode', 'any');
// Quicksearch words don't need to be phrases
var words = Scholar.Fulltext.semanticSplitter(value);
var words = Zotero.Fulltext.semanticSplitter(value);
for each(var i in words){
this.addCondition('blockStart');
this.addCondition('title', operator, i, false);
@ -168,7 +168,7 @@ Scholar.Search.prototype.addCondition = function(condition, operator, value, req
var searchConditionID = ++this._maxSearchConditionID;
var [condition, mode] = Scholar.SearchConditions.parseCondition(condition);
var [condition, mode] = Zotero.SearchConditions.parseCondition(condition);
this._conditions[searchConditionID] = {
id: searchConditionID,
@ -185,12 +185,12 @@ Scholar.Search.prototype.addCondition = function(condition, operator, value, req
}
Scholar.Search.prototype.updateCondition = function(searchConditionID, condition, operator, value, required){
Zotero.Search.prototype.updateCondition = function(searchConditionID, condition, operator, value, required){
if (typeof this._conditions[searchConditionID] == 'undefined'){
throw ('Invalid searchConditionID ' + searchConditionID + ' in updateCondition()');
}
if (!Scholar.SearchConditions.hasOperator(condition, operator)){
if (!Zotero.SearchConditions.hasOperator(condition, operator)){
throw ("Invalid operator '" + operator + "' for condition " + condition);
}
@ -207,7 +207,7 @@ Scholar.Search.prototype.updateCondition = function(searchConditionID, condition
}
Scholar.Search.prototype.removeCondition = function(searchConditionID){
Zotero.Search.prototype.removeCondition = function(searchConditionID){
if (typeof this._conditions[searchConditionID] == 'undefined'){
throw ('Invalid searchConditionID ' + searchConditionID + ' in removeCondition()');
}
@ -220,7 +220,7 @@ Scholar.Search.prototype.removeCondition = function(searchConditionID){
* Returns an array with 'condition', 'operator', 'value', 'required'
* for the given searchConditionID
*/
Scholar.Search.prototype.getSearchCondition = function(searchConditionID){
Zotero.Search.prototype.getSearchCondition = function(searchConditionID){
return this._conditions[searchConditionID];
}
@ -229,7 +229,7 @@ Scholar.Search.prototype.getSearchCondition = function(searchConditionID){
* Returns a multidimensional array of conditions/operator/value sets
* used in the search, indexed by searchConditionID
*/
Scholar.Search.prototype.getSearchConditions = function(){
Zotero.Search.prototype.getSearchConditions = function(){
// TODO: make copy
return this._conditions;
}
@ -238,12 +238,12 @@ Scholar.Search.prototype.getSearchConditions = function(){
/*
* Run the search and return an array of item ids for results
*/
Scholar.Search.prototype.search = function(){
Zotero.Search.prototype.search = function(){
if (!this._sql){
this._buildQuery();
}
var ids = Scholar.DB.columnQuery(this._sql, this._sqlParams);
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
if (!ids){
return false;
@ -252,7 +252,7 @@ Scholar.Search.prototype.search = function(){
// Filter results with fulltext search
for each(var condition in this._conditions){
if (condition['condition']=='fulltextContent'){
var fulltextIDs = Scholar.Fulltext.findTextInItems(ids,
var fulltextIDs = Zotero.Fulltext.findTextInItems(ids,
condition['value'], condition['mode']);
var hash = {};
@ -288,7 +288,7 @@ Scholar.Search.prototype.search = function(){
/*
* Get the SQL string for the search
*/
Scholar.Search.prototype.getSQL = function(){
Zotero.Search.prototype.getSQL = function(){
if (!this._sql){
this._buildQuery();
}
@ -296,7 +296,7 @@ Scholar.Search.prototype.getSQL = function(){
}
Scholar.Search.prototype.getSQLParams = function(){
Zotero.Search.prototype.getSQLParams = function(){
if (!this._sql){
this._buildQuery();
}
@ -307,7 +307,7 @@ Scholar.Search.prototype.getSQLParams = function(){
/*
* Build the SQL query for the search
*/
Scholar.Search.prototype._buildQuery = function(){
Zotero.Search.prototype._buildQuery = function(){
var sql = 'SELECT itemID FROM items';
var sqlParams = [];
// Separate ANY conditions for 'required' condition support
@ -317,7 +317,7 @@ Scholar.Search.prototype._buildQuery = function(){
var conditions = [];
for (var i in this._conditions){
var data = Scholar.SearchConditions.get(this._conditions[i]['condition']);
var data = Zotero.SearchConditions.get(this._conditions[i]['condition']);
if (data['table']){
conditions.push({
@ -405,7 +405,7 @@ Scholar.Search.prototype._buildQuery = function(){
}
condSQL += 'fieldID=? AND ';
condSQLParams.push(
Scholar.ItemFields.getID(condition['alias'])
Zotero.ItemFields.getID(condition['alias'])
);
break;
@ -415,7 +415,7 @@ Scholar.Search.prototype._buildQuery = function(){
// And descendents if recursive search
if (recursive){
var col = Scholar.Collections.get(condition['value']);
var col = Zotero.Collections.get(condition['value']);
var descendents = col.getDescendents(false, 'collection');
if (descendents){
for (var k in descendents){
@ -437,7 +437,7 @@ Scholar.Search.prototype._buildQuery = function(){
condSQL += "NOT ";
}
condSQL += "IN (";
var search = new Scholar.Search();
var search = new Zotero.Search();
search.load(condition['value']);
// Check if there are any post-search filters
@ -585,7 +585,7 @@ Scholar.Search.prototype._buildQuery = function(){
}
Scholar.Searches = new function(){
Zotero.Searches = new function(){
this.get = get;
this.getAll = getAll;
this.erase = erase;
@ -594,7 +594,7 @@ Scholar.Searches = new function(){
function get(id){
var sql = "SELECT savedSearchID AS id, savedSearchName AS name "
+ "FROM savedSearches WHERE savedSearchID=?";
return Scholar.DB.rowQuery(sql, [id]);
return Zotero.DB.rowQuery(sql, [id]);
}
@ -604,7 +604,7 @@ Scholar.Searches = new function(){
function getAll(){
var sql = "SELECT savedSearchID AS id, savedSearchName AS name "
+ "FROM savedSearches ORDER BY name";
return Scholar.DB.query(sql);
return Zotero.DB.query(sql);
}
@ -612,22 +612,22 @@ Scholar.Searches = new function(){
* Delete a given saved search from the DB
*/
function erase(savedSearchID){
Scholar.DB.beginTransaction();
Zotero.DB.beginTransaction();
var sql = "DELETE FROM savedSearchConditions WHERE savedSearchID="
+ savedSearchID;
Scholar.DB.query(sql);
Zotero.DB.query(sql);
var sql = "DELETE FROM savedSearches WHERE savedSearchID="
+ savedSearchID;
Scholar.DB.query(sql);
Scholar.DB.commitTransaction();
Zotero.DB.query(sql);
Zotero.DB.commitTransaction();
Scholar.Notifier.trigger('remove', 'search', savedSearchID);
Zotero.Notifier.trigger('remove', 'search', savedSearchID);
}
}
Scholar.SearchConditions = new function(){
Zotero.SearchConditions = new function(){
this.get = get;
this.getStandardConditions = getStandardConditions;
this.hasOperator = hasOperator;
@ -641,7 +641,7 @@ Scholar.SearchConditions = new function(){
* Define the advanced search operators
*/
var _operators = {
// Standard -- these need to match those in scholarsearch.xml
// Standard -- these need to match those in zoterosearch.xml
is: true,
isNot: true,
contains: true,
@ -831,7 +831,7 @@ Scholar.SearchConditions = new function(){
},
table: 'itemData',
field: 'value',
aliases: Scholar.DB.columnQuery("SELECT fieldName FROM fields " +
aliases: Zotero.DB.columnQuery("SELECT fieldName FROM fields " +
"WHERE fieldName NOT IN ('accessDate', 'date', 'pages', " +
"'section','accessionNumber','seriesNumber','issue')"),
template: true // mark for special handling
@ -918,10 +918,10 @@ Scholar.SearchConditions = new function(){
}
try {
var localized = Scholar.getString('searchConditions.' + i)
var localized = Zotero.getString('searchConditions.' + i)
}
catch (e){
var localized = Scholar.getString('itemFields.' + i);
var localized = Zotero.getString('itemFields.' + i);
}
sortKeys.push(localized);

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,31 @@
// Scholar for Firefox Utilities
// Zotero for Firefox Utilities
/////////////////////////////////////////////////////////////////
//
// Scholar.Utilities
// Zotero.Utilities
//
/////////////////////////////////////////////////////////////////
Scholar.Utilities = function () {}
Zotero.Utilities = function () {}
Scholar.Utilities.prototype.debug = function(msg) {
Scholar.debug(msg, 4);
Zotero.Utilities.prototype.debug = function(msg) {
Zotero.debug(msg, 4);
}
/*
* See Scholar.Date
* See Zotero.Date
*/
Scholar.Utilities.prototype.formatDate = function(date) {
return Scholar.Date.formatDate(date);
Zotero.Utilities.prototype.formatDate = function(date) {
return Zotero.Date.formatDate(date);
}
Scholar.Utilities.prototype.strToDate = function(date) {
return Scholar.Date.strToDate(date);
Zotero.Utilities.prototype.strToDate = function(date) {
return Zotero.Date.strToDate(date);
}
/*
* Cleans extraneous punctuation off an author name
*/
Scholar.Utilities.prototype.cleanAuthor = function(author, type, useComma) {
Zotero.Utilities.prototype.cleanAuthor = function(author, type, useComma) {
if(typeof(author) != "string") {
throw "cleanAuthor: author must be a string";
}
@ -57,7 +57,7 @@ Scholar.Utilities.prototype.cleanAuthor = function(author, type, useComma) {
/*
* Cleans whitespace off a string and replaces multiple spaces with one
*/
Scholar.Utilities.prototype.cleanString = function(s) {
Zotero.Utilities.prototype.cleanString = function(s) {
if(typeof(s) != "string") {
throw "cleanString: argument must be a string";
}
@ -70,7 +70,7 @@ Scholar.Utilities.prototype.cleanString = function(s) {
/*
* Cleans any non-word non-parenthesis characters off the ends of a string
*/
Scholar.Utilities.prototype.superCleanString = function(x) {
Zotero.Utilities.prototype.superCleanString = function(x) {
if(typeof(x) != "string") {
throw "superCleanString: argument must be a string";
}
@ -82,7 +82,7 @@ Scholar.Utilities.prototype.superCleanString = function(x) {
/*
* Eliminates HTML tags, replacing <br>s with /ns
*/
Scholar.Utilities.prototype.cleanTags = function(x) {
Zotero.Utilities.prototype.cleanTags = function(x) {
if(typeof(x) != "string") {
throw "cleanTags: argument must be a string";
}
@ -94,7 +94,7 @@ Scholar.Utilities.prototype.cleanTags = function(x) {
/*
* Test if a string is an integer
*/
Scholar.Utilities.prototype.isInt = function(x) {
Zotero.Utilities.prototype.isInt = function(x) {
if(parseInt(x) == x) {
return true;
}
@ -102,17 +102,17 @@ Scholar.Utilities.prototype.isInt = function(x) {
}
/*
* Get current scholar version
* Get current zotero version
*/
Scholar.Utilities.prototype.getVersion = function() {
return Scholar.version;
Zotero.Utilities.prototype.getVersion = function() {
return Zotero.version;
}
/*
* Get a page range, given a user-entered set of pages
*/
Scholar.Utilities.prototype._pageRangeRegexp = /^\s*([0-9]+)-([0-9]+)\s*$/;
Scholar.Utilities.prototype.getPageRange = function(pages) {
Zotero.Utilities.prototype._pageRangeRegexp = /^\s*([0-9]+)-([0-9]+)\s*$/;
Zotero.Utilities.prototype.getPageRange = function(pages) {
var pageNumbers;
var m = this._pageRangeRegexp.exec(pages);
if(m) {
@ -128,12 +128,12 @@ Scholar.Utilities.prototype.getPageRange = function(pages) {
/*
* provide inArray function
*/
Scholar.Utilities.prototype.inArray = Scholar.inArray;
Zotero.Utilities.prototype.inArray = Zotero.inArray;
/*
* pads a number or other string with a given string on the left
*/
Scholar.Utilities.prototype.lpad = function(string, pad, length) {
Zotero.Utilities.prototype.lpad = function(string, pad, length) {
while(string.length < length) {
string = pad + string;
}
@ -143,8 +143,8 @@ Scholar.Utilities.prototype.lpad = function(string, pad, length) {
/*
* returns true if an item type exists, false if it does not
*/
Scholar.Utilities.prototype.itemTypeExists = function(type) {
if(Scholar.ItemTypes.getID(type)) {
Zotero.Utilities.prototype.itemTypeExists = function(type) {
if(Zotero.ItemTypes.getID(type)) {
return true;
} else {
return false;
@ -154,10 +154,10 @@ Scholar.Utilities.prototype.itemTypeExists = function(type) {
/*
* Cleans a title, capitalizing the proper words and replacing " :" with ":"
*/
Scholar.Utilities.capitalizeSkipWords = ["but", "or", "yet", "so", "for", "and",
Zotero.Utilities.capitalizeSkipWords = ["but", "or", "yet", "so", "for", "and",
"nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to",
"with", "up", "down"];
Scholar.Utilities.prototype.capitalizeTitle = function(title) {
Zotero.Utilities.prototype.capitalizeTitle = function(title) {
title = this.cleanString(title);
title = title.replace(/ : /g, ": ");
var words = title.split(" ");
@ -172,7 +172,7 @@ Scholar.Utilities.prototype.capitalizeTitle = function(title) {
if(words.length > 2) {
for(var i=1; i<lastWordIndex; i++) {
// if not a skip word
if(Scholar.Utilities.capitalizeSkipWords.indexOf(words[i].toLowerCase()) == -1 ||
if(Zotero.Utilities.capitalizeSkipWords.indexOf(words[i].toLowerCase()) == -1 ||
(words[i-1].length && words[i-1][words[i-1].length-1] == ":")) {
words[i] = words[i][0].toUpperCase() + words[i].substr(1);
} else {
@ -186,25 +186,25 @@ Scholar.Utilities.prototype.capitalizeTitle = function(title) {
}
/*
* END SCHOLAR FOR FIREFOX EXTENSIONS
* END ZOTERO FOR FIREFOX EXTENSIONS
*/
/////////////////////////////////////////////////////////////////
//
// Scholar.Utilities.Ingester
// Zotero.Utilities.Ingester
//
/////////////////////////////////////////////////////////////////
// Scholar.Utilities.Ingester extends Scholar.Utilities, offering additional
// Zotero.Utilities.Ingester extends Zotero.Utilities, offering additional
// classes relating to data extraction specifically from HTML documents.
Scholar.Utilities.Ingester = function(translate, proxiedURL) {
Zotero.Utilities.Ingester = function(translate, proxiedURL) {
this.translate = translate;
}
Scholar.Utilities.Ingester.prototype = new Scholar.Utilities();
Zotero.Utilities.Ingester.prototype = new Zotero.Utilities();
// Takes an XPath query and returns the results
Scholar.Utilities.Ingester.prototype.gatherElementsOnXPath = function(doc, parentNode, xpath, nsResolver) {
Zotero.Utilities.Ingester.prototype.gatherElementsOnXPath = function(doc, parentNode, xpath, nsResolver) {
var elmts = [];
var iterator = doc.evaluate(xpath, parentNode, nsResolver, Components.interfaces.nsIDOMXPathResult.ANY_TYPE,null);
@ -220,7 +220,7 @@ Scholar.Utilities.Ingester.prototype.gatherElementsOnXPath = function(doc, paren
/*
* Gets a given node as a string containing all child nodes
*/
Scholar.Utilities.Ingester.prototype.getNodeString = function(doc, contextNode, xpath, nsResolver) {
Zotero.Utilities.Ingester.prototype.getNodeString = function(doc, contextNode, xpath, nsResolver) {
var elmts = this.gatherElementsOnXPath(doc, contextNode, xpath, nsResolver);
var returnVar = "";
for(var i=0; i<elmts.length; i++) {
@ -232,7 +232,7 @@ Scholar.Utilities.Ingester.prototype.getNodeString = function(doc, contextNode,
/*
* Grabs items based on URLs
*/
Scholar.Utilities.Ingester.prototype.getItemArray = function(doc, inHere, urlRe, rejectRe) {
Zotero.Utilities.Ingester.prototype.getItemArray = function(doc, inHere, urlRe, rejectRe) {
var availableItems = new Object(); // Technically, associative arrays are objects
// Require link to match this
@ -282,30 +282,30 @@ Scholar.Utilities.Ingester.prototype.getItemArray = function(doc, inHere, urlRe,
return availableItems;
}
Scholar.Utilities.Ingester.prototype.lookupContextObject = function(co, done, error) {
return Scholar.OpenURL.lookupContextObject(co, done, error);
Zotero.Utilities.Ingester.prototype.lookupContextObject = function(co, done, error) {
return Zotero.OpenURL.lookupContextObject(co, done, error);
}
Scholar.Utilities.Ingester.prototype.parseContextObject = function(co, item) {
return Scholar.OpenURL.parseContextObject(co, item);
Zotero.Utilities.Ingester.prototype.parseContextObject = function(co, item) {
return Zotero.OpenURL.parseContextObject(co, item);
}
// Ingester adapters for Scholar.Utilities.HTTP to handle proxies
// Ingester adapters for Zotero.Utilities.HTTP to handle proxies
Scholar.Utilities.Ingester.prototype.loadDocument = function(url, succeeded, failed) {
Zotero.Utilities.Ingester.prototype.loadDocument = function(url, succeeded, failed) {
this.processDocuments([ url ], succeeded, null, failed);
}
Scholar.Utilities.Ingester._protocolRe = new RegExp();
Scholar.Utilities.Ingester._protocolRe.compile("^(?:(?:http|https|ftp):|[^:]*/)", "i");
Scholar.Utilities.Ingester.prototype.processDocuments = function(urls, processor, done, exception) {
Zotero.Utilities.Ingester._protocolRe = new RegExp();
Zotero.Utilities.Ingester._protocolRe.compile("^(?:(?:http|https|ftp):|[^:]*/)", "i");
Zotero.Utilities.Ingester.prototype.processDocuments = function(urls, processor, done, exception) {
if(this.translate.locationIsProxied) {
for(var i in urls) {
if(this.translate.locationIsProxied) {
urls[i] = Scholar.Ingester.ProxyMonitor.properToProxy(urls[i]);
urls[i] = Zotero.Ingester.ProxyMonitor.properToProxy(urls[i]);
}
// check for a protocol colon
if(!Scholar.Utilities.Ingester._protocolRe.test(urls[i])) {
if(!Zotero.Utilities.Ingester._protocolRe.test(urls[i])) {
throw("invalid URL in processDocuments");
}
}
@ -320,23 +320,23 @@ Scholar.Utilities.Ingester.prototype.processDocuments = function(urls, processor
}
}
Scholar.Utilities.HTTP.processDocuments(null, urls, processor, done, exception);
Zotero.Utilities.HTTP.processDocuments(null, urls, processor, done, exception);
}
Scholar.Utilities.Ingester.HTTP = function(translate) {
Zotero.Utilities.Ingester.HTTP = function(translate) {
this.translate = translate;
}
Scholar.Utilities.Ingester.HTTP.prototype.doGet = function(url, onDone) {
Zotero.Utilities.Ingester.HTTP.prototype.doGet = function(url, onDone) {
if(this.translate.locationIsProxied) {
url = Scholar.Ingester.ProxyMonitor.properToProxy(url);
url = Zotero.Ingester.ProxyMonitor.properToProxy(url);
}
if(!Scholar.Utilities.Ingester._protocolRe.test(url)) {
if(!Zotero.Utilities.Ingester._protocolRe.test(url)) {
throw("invalid URL in processDocuments");
}
var translate = this.translate;
Scholar.Utilities.HTTP.doGet(url, function(xmlhttp) {
Zotero.Utilities.HTTP.doGet(url, function(xmlhttp) {
try {
onDone(xmlhttp.responseText, xmlhttp);
} catch(e) {
@ -345,16 +345,16 @@ Scholar.Utilities.Ingester.HTTP.prototype.doGet = function(url, onDone) {
})
}
Scholar.Utilities.Ingester.HTTP.prototype.doPost = function(url, body, onDone) {
Zotero.Utilities.Ingester.HTTP.prototype.doPost = function(url, body, onDone) {
if(this.translate.locationIsProxied) {
url = Scholar.Ingester.ProxyMonitor.properToProxy(url);
url = Zotero.Ingester.ProxyMonitor.properToProxy(url);
}
if(!Scholar.Utilities.Ingester._protocolRe.test(url)) {
if(!Zotero.Utilities.Ingester._protocolRe.test(url)) {
throw("invalid URL in processDocuments");
}
var translate = this.translate;
Scholar.Utilities.HTTP.doPost(url, body, function(xmlhttp) {
Zotero.Utilities.HTTP.doPost(url, body, function(xmlhttp) {
try {
onDone(xmlhttp.responseText, xmlhttp);
} catch(e) {
@ -366,7 +366,7 @@ Scholar.Utilities.Ingester.HTTP.prototype.doPost = function(url, body, onDone) {
// These are front ends for XMLHttpRequest. XMLHttpRequest can't actually be
// accessed outside the sandbox, and even if it could, it wouldn't let scripts
// access across domains, so everything's replicated here.
Scholar.Utilities.HTTP = new function() {
Zotero.Utilities.HTTP = new function() {
this.doGet = doGet;
this.doPost = doPost;
this.doHead = doHead;
@ -380,10 +380,10 @@ Scholar.Utilities.HTTP = new function() {
* Returns false if browser is offline
*
* doGet can be called as:
* Scholar.Utilities.HTTP.doGet(url, onDone)
* Zotero.Utilities.HTTP.doGet(url, onDone)
**/
function doGet(url, onDone, onError) {
Scholar.debug("HTTP GET "+url);
Zotero.debug("HTTP GET "+url);
if (this.browserIsOffline()){
return false;
}
@ -409,10 +409,10 @@ Scholar.Utilities.HTTP = new function() {
* Returns false if browser is offline
*
* doPost can be called as:
* Scholar.Utilities.HTTP.doPost(url, body, onDone)
* Zotero.Utilities.HTTP.doPost(url, body, onDone)
**/
function doPost(url, body, onDone) {
Scholar.debug("HTTP POST "+body+" to "+url);
Zotero.debug("HTTP POST "+body+" to "+url);
if (this.browserIsOffline()){
return false;
}
@ -434,7 +434,7 @@ Scholar.Utilities.HTTP = new function() {
function doHead(url, onDone) {
Scholar.debug("HTTP HEAD "+url);
Zotero.debug("HTTP HEAD "+url);
if (this.browserIsOffline()){
return false;
}
@ -458,13 +458,13 @@ Scholar.Utilities.HTTP = new function() {
* Send an HTTP OPTIONS request via XMLHTTPRequest
*
* doOptions can be called as:
* Scholar.Utilities.HTTP.doOptions(url, body, onDone)
* Zotero.Utilities.HTTP.doOptions(url, body, onDone)
*
* The status handler, which doesn't really serve a very noticeable purpose
* in our code, is required for compatiblity with the Piggy Bank project
**/
function doOptions(url, body, onDone) {
Scholar.debug("HTTP OPTIONS "+url);
Zotero.debug("HTTP OPTIONS "+url);
if (this.browserIsOffline()){
return false;
}
@ -519,11 +519,11 @@ Scholar.Utilities.HTTP = new function() {
// processor - a function to execute to process each document
// done - a function to execute when all document processing is complete
// exception - a function to execute if an exception occurs (exceptions are
// also logged in the Scholar for Firefox log)
// also logged in the Zotero for Firefox log)
// saveBrowser - whether to save the hidden browser object; usually, you don't
// want to do this, because it makes it easier to leak memory
Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, done, exception, saveBrowser) {
var hiddenBrowser = Scholar.Browser.createHiddenBrowser();
Zotero.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, done, exception, saveBrowser) {
var hiddenBrowser = Zotero.Browser.createHiddenBrowser();
hiddenBrowser.docShell.allowImages = false;
var prevUrl, url;
@ -540,7 +540,7 @@ Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, do
var removeListeners = function() {
hiddenBrowser.removeEventListener("load", onLoad, true);
if(!saveBrowser) {
Scholar.Browser.deleteHiddenBrowser(hiddenBrowser);
Zotero.Browser.deleteHiddenBrowser(hiddenBrowser);
}
}
var doLoad = function() {
@ -548,7 +548,7 @@ Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, do
if (urlIndex < urls.length) {
url = urls[urlIndex];
try {
Scholar.debug("loading "+url);
Zotero.debug("loading "+url);
hiddenBrowser.loadURI(url);
} catch (e) {
removeListeners();
@ -567,7 +567,7 @@ Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, do
}
};
var onLoad = function() {
Scholar.debug(hiddenBrowser.contentDocument.location.href+" has been loaded");
Zotero.debug(hiddenBrowser.contentDocument.location.href+" has been loaded");
if(hiddenBrowser.contentDocument.location.href != prevUrl) { // Just in case it fires too many times
prevUrl = hiddenBrowser.contentDocument.location.href;
try {
@ -601,7 +601,7 @@ Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, do
/*
* This would probably be better as a separate XPCOM service
*/
Scholar.Utilities.AutoComplete = new function(){
Zotero.Utilities.AutoComplete = new function(){
this.getResultComment = getResultComment;
function getResultComment(textbox){

View file

@ -1,6 +1,6 @@
<!ENTITY scholar.name "Zotero">
<!ENTITY scholar.version "version">
<!ENTITY scholar.createdby "Created by:">
<!ENTITY scholar.directors "Directors:">
<!ENTITY scholar.developers "Developers:">
<!ENTITY scholar.thanks "Special thanks:">
<!ENTITY zotero.name "Zotero">
<!ENTITY zotero.version "version">
<!ENTITY zotero.createdby "Created by:">
<!ENTITY zotero.directors "Directors:">
<!ENTITY zotero.developers "Developers:">
<!ENTITY zotero.thanks "Special thanks:">

View file

@ -1,11 +1,11 @@
<!ENTITY scholar.name "Zotero">
<!ENTITY scholar.preferences.title "Zotero Preferences">
<!ENTITY scholar.preferences.autoUpdate.label "Automatically check for updated scrapers">
<!ENTITY scholar.preferences.position.label "Display Zotero">
<!ENTITY scholar.preferences.position.above "above">
<!ENTITY scholar.preferences.position.below "below">
<!ENTITY scholar.preferences.position.browser "browser content">
<!ENTITY scholar.preferences.parseEndnote.label "Use Zotero for downloaded EndNote files">
<!ENTITY scholar.preferences.openurl.caption "OpenURL">
<!ENTITY scholar.preferences.openurl.server "Resolver:">
<!ENTITY scholar.preferences.openurl.version "Version:">
<!ENTITY zotero.name "Zotero">
<!ENTITY zotero.preferences.title "Zotero Preferences">
<!ENTITY zotero.preferences.autoUpdate.label "Automatically check for updated scrapers">
<!ENTITY zotero.preferences.position.label "Display Zotero">
<!ENTITY zotero.preferences.position.above "above">
<!ENTITY zotero.preferences.position.below "below">
<!ENTITY zotero.preferences.position.browser "browser content">
<!ENTITY zotero.preferences.parseEndnote.label "Use Zotero for downloaded EndNote files">
<!ENTITY zotero.preferences.openurl.caption "OpenURL">
<!ENTITY zotero.preferences.openurl.server "Resolver:">
<!ENTITY zotero.preferences.openurl.version "Version:">

View file

@ -1,4 +1,4 @@
<!ENTITY scholar.name "Zotero">
<!ENTITY zotero.name "Zotero">
<!ENTITY tabs.info.label "Info">
<!ENTITY tabs.notes.label "Notes">

View file

@ -99,7 +99,7 @@ db.dbCorruptedNoBackup = The Zotero database appears to have become corrupted,
db.dbRestored = The Zotero database appears to have become corrupted.\n\nYour data was restored from the last automatic backup made on %1 at %2. The damaged file was saved in your Zotero directory.
db.dbRestoreFailed = The Zotero database appears to have become corrupted, and an attempt to restore from the last automatic backup failed.\n\nA new database file has been created. The damaged file was saved in your Zotero directory.
scholar.preferences.status.positionChange = Position change will take effect in new windows only
zotero.preferences.status.positionChange = Position change will take effect in new windows only
fileInterface.itemsImported = Importing items...
fileInterface.itemsExported = Exporting items...

View file

@ -1,4 +1,4 @@
<!ENTITY scholar.search.textModes.phrase "Phrase">
<!ENTITY scholar.search.textModes.phraseBinary "Phrase (incl. binary files)">
<!ENTITY scholar.search.textModes.regexp "Regexp">
<!ENTITY scholar.search.textModes.regexpCS "Regexp (case-sensitive)">
<!ENTITY zotero.search.textModes.phrase "Phrase">
<!ENTITY zotero.search.textModes.phraseBinary "Phrase (incl. binary files)">
<!ENTITY zotero.search.textModes.regexp "Regexp">
<!ENTITY zotero.search.textModes.regexpCS "Regexp (case-sensitive)">

View file

@ -1,15 +1,15 @@
#citation-add {
list-style-image: url('chrome://scholar/skin/citation-add.png');
list-style-image: url('chrome://zotero/skin/citation-add.png');
}
#citation-add[disabled="true"] {
list-style-image: url('chrome://scholar/skin/citation-add-gray.png');
list-style-image: url('chrome://zotero/skin/citation-add-gray.png');
}
#citation-delete {
list-style-image: url('chrome://scholar/skin/citation-delete.png');
list-style-image: url('chrome://zotero/skin/citation-delete.png');
}
#citation-delete[disabled="true"] {
list-style-image: url('chrome://scholar/skin/citation-delete-gray.png');
list-style-image: url('chrome://zotero/skin/citation-delete-gray.png');
}
#item-locator {

View file

@ -1,11 +1,11 @@
#scholar-status-bar-icon
#zotero-status-bar-icon
{
width: 49px;
margin:0 0 -1px;
padding:0 5px 1px;
}
#scholar-pane
#zotero-pane
{
background: #f5f5f5;
min-height: 170px;
@ -23,7 +23,7 @@
margin-right: 5px;
}
#scholar-pane splitter
#zotero-pane splitter
{
background: #f5f5f5;
border:0;
@ -45,49 +45,49 @@
min-width: 300px;
}
#scholar-pane toolbar
#zotero-pane toolbar
{
border-bottom: none;
background: #f5f5f5;
height: 24px;
}
#scholar-pane toolbarseparator {
#zotero-pane toolbarseparator {
height:24px;
}
#scholar-pane toolbar .toggler
#zotero-pane toolbar .toggler
{
margin: 4px;
}
#scholar-toolbar-name
#zotero-toolbar-name
{
font-size: larger;
}
#tb-collection-add
{
list-style-image: url('chrome://scholar/skin/toolbar-collection-add.png');
list-style-image: url('chrome://zotero/skin/toolbar-collection-add.png');
}
#tb-collection-rename
{
list-style-image: url('chrome://scholar/skin/toolbar-collection-edit.png');
list-style-image: url('chrome://zotero/skin/toolbar-collection-edit.png');
}
#tb-collection-rename[disabled="true"]
{
list-style-image: url('chrome://scholar/skin/toolbar-collection-edit-gray.png');
list-style-image: url('chrome://zotero/skin/toolbar-collection-edit-gray.png');
}
/* These fix a rendering bug in Fx2.0b2 */
#scholar-pane toolbarbutton .toolbarbutton-text
#zotero-pane toolbarbutton .toolbarbutton-text
{
margin:0 2px;
}
#scholar-pane .toolbarbutton-menu-dropmarker
#zotero-pane .toolbarbutton-menu-dropmarker
{
margin-right:4px;
}
@ -99,62 +99,62 @@
#tb-collection-menu
{
list-style-image: url('chrome://scholar/skin/cog.png');
list-style-image: url('chrome://zotero/skin/cog.png');
}
#tb-add
{
list-style-image: url('chrome://scholar/skin/toolbar-item-add.png');
list-style-image: url('chrome://zotero/skin/toolbar-item-add.png');
}
#tb-item-from-page
{
list-style-image: url('chrome://scholar/skin/toolbar-item-from-page.png');
list-style-image: url('chrome://zotero/skin/toolbar-item-from-page.png');
}
#tb-link-page
{
list-style-image: url('chrome://scholar/skin/toolbar-link-add.png');
list-style-image: url('chrome://zotero/skin/toolbar-link-add.png');
}
#tb-snapshot-page
{
list-style-image: url('chrome://scholar/skin/toolbar-snapshot-add.png');
list-style-image: url('chrome://zotero/skin/toolbar-snapshot-add.png');
}
#tb-note-add
{
list-style-image: url('chrome://scholar/skin/toolbar-note-add.png');
list-style-image: url('chrome://zotero/skin/toolbar-note-add.png');
}
#tb-item-attachments-file
{
list-style-image: url('chrome://scholar/skin/treeitem-attachment-file.png');
list-style-image: url('chrome://zotero/skin/treeitem-attachment-file.png');
}
#tb-item-attachments-link
{
list-style-image: url('chrome://scholar/skin/treeitem-attachment-link.png');
list-style-image: url('chrome://zotero/skin/treeitem-attachment-link.png');
}
#tb-item-attachments-snapshot
{
list-style-image: url('chrome://scholar/skin/treeitem-attachment-snapshot.png');
list-style-image: url('chrome://zotero/skin/treeitem-attachment-snapshot.png');
}
#tb-item-attachments-web-link
{
list-style-image: url('chrome://scholar/skin/treeitem-attachment-web-link.png');
list-style-image: url('chrome://zotero/skin/treeitem-attachment-web-link.png');
}
#tb-fullscreen
{
list-style-image: url('chrome://scholar/skin/toolbar-fullscreen-bottom.png');
list-style-image: url('chrome://zotero/skin/toolbar-fullscreen-bottom.png');
}
#tb-fullscreen[scholartop="true"]
#tb-fullscreen[zoterotop="true"]
{
list-style-image: url('chrome://scholar/skin/toolbar-fullscreen-top.png');
list-style-image: url('chrome://zotero/skin/toolbar-fullscreen-top.png');
}
#tb-fullscreen[fullscreenmode="true"]
@ -170,7 +170,7 @@
#tb-collection-addsearch
{
list-style-image: url('chrome://scholar/skin/treesource-search.png');
list-style-image: url('chrome://zotero/skin/treesource-search.png');
margin-bottom:-5px;
}
@ -179,26 +179,26 @@
margin: 0px;
padding: 0px;
cursor: default;
list-style-image: url('chrome://scholar/skin/search-cancel.png');
list-style-image: url('chrome://zotero/skin/search-cancel.png');
}
#tb-search-cancel:hover:active
{
list-style-image: url('chrome://scholar/skin/search-cancel-active.png');
list-style-image: url('chrome://zotero/skin/search-cancel-active.png');
}
#tb-go-to-url, #tb-openurl
{
list-style-image: url('chrome://scholar/skin/toolbar-go-arrow.png');
list-style-image: url('chrome://zotero/skin/toolbar-go-arrow.png');
-moz-box-direction: reverse;
}
#tb-go-to-url[disabled=true], #tb-openurl[disabled=true]
{
list-style-image: url('chrome://scholar/skin/toolbar-go-arrow-disabled.png');
list-style-image: url('chrome://zotero/skin/toolbar-go-arrow-disabled.png');
}
#scholar-view-item > vbox
#zotero-view-item > vbox
{
overflow: auto;
margin-left: 5px;
@ -227,7 +227,7 @@
margin-left:0;
}
#scholar-splitter
#zotero-splitter
{
border-top: none;
border-bottom: 1px solid #A3A3A3;

View file

@ -1,51 +1,51 @@
#zotero-toolbar-button
{
list-style-image: url('chrome://scholar/skin/zotero-z-24px.png');
list-style-image: url('chrome://zotero/skin/zotero-z-24px.png');
}
#zotero-toolbar-button:hover
{
list-style-image: url('chrome://scholar/skin/zotero-z-24px-hover.png');
list-style-image: url('chrome://zotero/skin/zotero-z-24px-hover.png');
}
#zotero-toolbar-button:active
{
list-style-image: url('chrome://scholar/skin/zotero-z-24px-active.png');
list-style-image: url('chrome://zotero/skin/zotero-z-24px-active.png');
}
toolbar[iconsize="small"] #zotero-toolbar-button
{
list-style-image: url('chrome://scholar/skin/zotero-z-16px.png');
list-style-image: url('chrome://zotero/skin/zotero-z-16px.png');
}
toolbar[iconsize="small"] #zotero-toolbar-button:hover
{
list-style-image: url('chrome://scholar/skin/zotero-z-16px-hover.png');
list-style-image: url('chrome://zotero/skin/zotero-z-16px-hover.png');
}
toolbar[iconsize="small"] #zotero-toolbar-button:active
{
list-style-image: url('chrome://scholar/skin/zotero-z-16px-active.png');
list-style-image: url('chrome://zotero/skin/zotero-z-16px-active.png');
}
textbox[multiline="true"][type="timed"]
{
-moz-binding: url('chrome://scholar/content/bindings/timedtextarea.xml#timed-textarea');
-moz-binding: url('chrome://zotero/content/bindings/timedtextarea.xml#timed-textarea');
}
noteeditor
{
-moz-binding: url('chrome://scholar/content/bindings/noteeditor.xml#note-editor');
-moz-binding: url('chrome://zotero/content/bindings/noteeditor.xml#note-editor');
}
linksbox
{
-moz-binding: url('chrome://scholar/content/bindings/noteeditor.xml#links-box');
-moz-binding: url('chrome://zotero/content/bindings/noteeditor.xml#links-box');
}
tagsbox
{
-moz-binding: url('chrome://scholar/content/bindings/tagsbox.xml#tags-box');
-moz-binding: url('chrome://zotero/content/bindings/tagsbox.xml#tags-box');
}
tagsbox row
@ -55,18 +55,18 @@ tagsbox row
seealsobox
{
-moz-binding: url('chrome://scholar/content/bindings/relatedbox.xml#seealso-box');
-moz-binding: url('chrome://zotero/content/bindings/relatedbox.xml#seealso-box');
}
scholarsearch
zoterosearch
{
-moz-binding: url('chrome://scholar/content/bindings/scholarsearch.xml#search-box');
-moz-binding: url('chrome://zotero/content/bindings/zoterosearch.xml#search-box');
width:60em;
}
searchcondition
{
-moz-binding: url('chrome://scholar/content/bindings/scholarsearch.xml#search-condition');
-moz-binding: url('chrome://zotero/content/bindings/zoterosearch.xml#search-condition');
}
searchcondition menulist[id="operatorsmenu"]
@ -76,7 +76,7 @@ searchcondition menulist[id="operatorsmenu"]
zoterosearchtextbox
{
-moz-binding: url('chrome://scholar/content/bindings/searchtextbox.xml#zotero-search-textbox');
-moz-binding: url('chrome://zotero/content/bindings/searchtextbox.xml#zotero-search-textbox');
}
zoterosearchtextbox toolbarbutton
@ -138,7 +138,7 @@ zoterosearchtextbox .toolbarbutton-menu-dropmarker
background: #666666;
}
#zotero-progress-box, #scholar-progress-box
#zotero-progress-box, #zotero-progress-box
{
border: 2px solid #7a0000;
margin: 0;
@ -147,35 +147,35 @@ zoterosearchtextbox .toolbarbutton-menu-dropmarker
padding-bottom: 3px;
}
.zotero-progress-item-icon, .scholar-progress-item-icon
.zotero-progress-item-icon, .zotero-progress-item-icon
{
width: 16px;
height: 16px;
}
.zotero-progress-item-hbox, .scholar-progress-item-hbox
.zotero-progress-item-hbox, .zotero-progress-item-hbox
{
padding-left: 5px;
margin-top: 3px;
margin-bottom: 3px;
}
.scholar-progress-item-label
.zotero-progress-item-label
{
width: 210px;
}
.scholar-progress-description
.zotero-progress-description
{
width: 220px;
}
.scholar-scrape-popup-library
.zotero-scrape-popup-library
{
list-style-image: url('chrome://scholar/skin/treesource-library.png');
list-style-image: url('chrome://zotero/skin/treesource-library.png');
}
.scholar-scrape-popup-collection
.zotero-scrape-popup-collection
{
list-style-image: url('chrome://scholar/skin/treesource-collection.png');
list-style-image: url('chrome://zotero/skin/treesource-collection.png');
}

View file

@ -1,13 +1,13 @@
const SCHOLAR_CONTRACTID = '@chnm.gmu.edu/Zotero;1';
const SCHOLAR_CLASSNAME = 'Zotero';
const SCHOLAR_CID = Components.ID('{e4c61080-ec2d-11da-8ad9-0800200c9a66}');
const SCHOLAR_IID = Components.interfaces.chnmIZoteroService;
const ZOTERO_CONTRACTID = '@chnm.gmu.edu/Zotero;1';
const ZOTERO_CLASSNAME = 'Zotero';
const ZOTERO_CID = Components.ID('{e4c61080-ec2d-11da-8ad9-0800200c9a66}');
const ZOTERO_IID = Components.interfaces.chnmIZoteroService;
const Cc = Components.classes;
const Ci = Components.interfaces;
// Assign the global scope to a variable to passed via wrappedJSObject
var ScholarWrapped = this;
var ZoteroWrapped = this;
/********************************************************************
@ -101,17 +101,17 @@ Cc["@mozilla.org/moz/jssubscript-loader;1"]
/********************************************************************/
// Initialize the Scholar service
// Initialize the Zotero service
//
// This runs when ScholarService is first requested.
// This runs when ZoteroService is first requested.
// Calls to other XPCOM components must be in here rather than in top-level
// code, as other components may not have yet been initialized.
function setupService(){
Scholar.init();
Zotero.init();
}
function ScholarService(){
this.wrappedJSObject = ScholarWrapped.Scholar;
function ZoteroService(){
this.wrappedJSObject = ZoteroWrapped.Zotero;
setupService();
}
@ -150,10 +150,10 @@ function setTimeout(func, ms){
//
// XPCOM goop
//
ScholarService.prototype = {
ZoteroService.prototype = {
QueryInterface: function(iid){
if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(SCHOLAR_IID)){
!iid.equals(ZOTERO_IID)){
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
@ -161,17 +161,17 @@ ScholarService.prototype = {
};
var ScholarFactory = {
var ZoteroFactory = {
createInstance: function(outer, iid){
if (outer != null){
throw Components.results.NS_ERROR_NO_AGGREGATION;
}
return new ScholarService().QueryInterface(iid);
return new ZoteroService().QueryInterface(iid);
}
};
var ScholarModule = {
var ZoteroModule = {
_firstTime: true,
registerSelf: function(compMgr, fileSpec, location, type){
@ -183,9 +183,9 @@ var ScholarModule = {
compMgr =
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(SCHOLAR_CID,
SCHOLAR_CLASSNAME,
SCHOLAR_CONTRACTID,
compMgr.registerFactoryLocation(ZOTERO_CID,
ZOTERO_CLASSNAME,
ZOTERO_CONTRACTID,
fileSpec,
location,
type);
@ -194,20 +194,20 @@ var ScholarModule = {
unregisterSelf: function(compMgr, location, type){
compMgr =
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(SCHOLAR_CID, location);
compMgr.unregisterFactoryLocation(ZOTERO_CID, location);
},
getClassObject: function(compMgr, cid, iid){
if (!cid.equals(SCHOLAR_CID)){
if (!cid.equals(ZOTERO_CID)){
throw Components.results.NS_ERROR_NO_INTERFACE;
}
if (!iid.equals(Components.interfaces.nsIFactory)){
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}
return ScholarFactory;
return ZoteroFactory;
},
canUnload: function(compMgr){ return true; }
};
function NSGetModule(comMgr, fileSpec){ return ScholarModule; }
function NSGetModule(comMgr, fileSpec){ return ZoteroModule; }

View file

@ -1,11 +0,0 @@
// These are DEFAULT prefs for the INSTALL. You will have to reinstall the extension to see differences!
// Display internal shortcut
pref("extensions.scholar.automaticScraperUpdates",true);
pref("extensions.scholar.cacheTranslatorData",true);
pref("extensions.scholar.scholarPaneOnTop",false);
pref("extensions.scholar.openURL.resolver","http://athene.gmu.edu:8888/lfp/LinkFinderPlus/Display");
pref("extensions.scholar.openURL.version","0.1");
pref("extensions.scholar.parseEndNoteMIMETypes",true);
pref("extensions.scholar.downloadAssociatedFiles",false);
pref("extensions.scholar.reportTranslationFailure",true);

View file

@ -0,0 +1,11 @@
// These are DEFAULT prefs for the INSTALL. You will have to reinstall the extension to see differences!
// Display internal shortcut
pref("extensions.zotero.automaticScraperUpdates",true);
pref("extensions.zotero.cacheTranslatorData",true);
pref("extensions.zotero.zoteroPaneOnTop",false);
pref("extensions.zotero.openURL.resolver","http://athene.gmu.edu:8888/lfp/LinkFinderPlus/Display");
pref("extensions.zotero.openURL.version","0.1");
pref("extensions.zotero.parseEndNoteMIMETypes",true);
pref("extensions.zotero.downloadAssociatedFiles",false);
pref("extensions.zotero.reportTranslationFailure",true);

View file

@ -15,9 +15,9 @@
<em:developer>David Norton</em:developer>
<em:developer>Dan Stillman</em:developer>
<em:homepageURL>http://www.zotero.org</em:homepageURL>
<em:optionsURL>chrome://scholar/content/preferences.xul</em:optionsURL>
<em:aboutURL>chrome://scholar/content/about.xul</em:aboutURL>
<em:iconURL>chrome://scholar/skin/zotero_z_32px.png</em:iconURL>
<em:optionsURL>chrome://zotero/content/preferences.xul</em:optionsURL>
<em:aboutURL>chrome://zotero/content/about.xul</em:aboutURL>
<em:iconURL>chrome://zotero/skin/zotero_z_32px.png</em:iconURL>
<em:updateURL>http://www.zotero.org/download/update-svn.rdf</em:updateURL>
<em:type>2</em:type> <!-- type=extension -->

File diff suppressed because it is too large Load diff