Merged revisions 3080-3081,3084,3087-3088,3090,3092,3099-3103,3113-3114,3132,3134-3143,3145,3148-3151,3154-3159,3165,3174,3194,3234-3235,3239-3240,3244,3246-3254,3258-3262,3268,3270,3274,3279,3286-3288,3294-3295 from 1.0 branch via svnmerge
|
@ -10,7 +10,7 @@ locale zotero cs-CZ chrome/locale/cs-CZ/zotero/
|
|||
locale zotero da-DK chrome/locale/da-DK/zotero/
|
||||
locale zotero de-AT chrome/locale/de-AT/zotero/
|
||||
locale zotero de-CH chrome/locale/de-CH/zotero/
|
||||
locale zotero de-DE chrome/locale/de-DE/zotero/
|
||||
locale zotero de chrome/locale/de-DE/zotero/
|
||||
locale zotero el-GR chrome/locale/el-GR/zotero/
|
||||
locale zotero es-ES chrome/locale/es-ES/zotero/
|
||||
locale zotero et-EE chrome/locale/et-EE/zotero/
|
||||
|
|
|
@ -136,20 +136,22 @@
|
|||
<method name="_doPopupItemEnabling">
|
||||
<parameter name="popupNode"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var controller = document.commandDispatcher.getControllerForCommand(command);
|
||||
<![CDATA[
|
||||
var children = popupNode.childNodes;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var command = children[i].getAttribute("cmd");
|
||||
if (command) {
|
||||
var enabled = controller.isCommandEnabled(command);
|
||||
if (enabled)
|
||||
children[i].removeAttribute("disabled");
|
||||
else
|
||||
children[i].setAttribute("disabled", "true");
|
||||
}
|
||||
var command = children[i].getAttribute("cmd");
|
||||
if (command) {
|
||||
var controller = document.commandDispatcher.getControllerForCommand(command);
|
||||
var enabled = controller.isCommandEnabled(command);
|
||||
if (enabled) {
|
||||
children[i].removeAttribute("disabled");
|
||||
}
|
||||
else {
|
||||
children[i].setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ var Zotero_Browser = new function() {
|
|||
this.scrapeThisPage = scrapeThisPage;
|
||||
this.annotatePage = annotatePage;
|
||||
this.toggleMode = toggleMode;
|
||||
this.setCollapsed = setCollapsed;
|
||||
this.toggleCollapsed = toggleCollapsed;
|
||||
this.chromeLoad = chromeLoad;
|
||||
this.chromeUnload = chromeUnload;
|
||||
this.contentLoad = contentLoad;
|
||||
|
@ -141,8 +141,6 @@ var Zotero_Browser = new function() {
|
|||
else {
|
||||
var tab = _getTabObject(this.tabbrowser.selectedBrowser);
|
||||
}
|
||||
tab.annotateNextLoad = true;
|
||||
tab.annotateID = id;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -182,9 +180,9 @@ var Zotero_Browser = new function() {
|
|||
/*
|
||||
* expands all annotations
|
||||
*/
|
||||
function setCollapsed(status) {
|
||||
function toggleCollapsed() {
|
||||
var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
|
||||
tab.page.annotations.setCollapsed(status);
|
||||
tab.page.annotations.toggleCollapsed();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -340,34 +338,26 @@ var Zotero_Browser = new function() {
|
|||
var tab = _getTabObject(browser);
|
||||
|
||||
if(isHTML) {
|
||||
if(tab.annotateNextLoad) {
|
||||
if(Zotero.Annotate.isAnnotated(tab.annotateID)) {
|
||||
var annotationID = Zotero.Annotate.getAnnotationIDFromURL(browser.currentURI.spec);
|
||||
if(annotationID) {
|
||||
if(Zotero.Annotate.isAnnotated(annotationID)) {
|
||||
window.alert(Zotero.getString("annotations.oneWindowWarning"));
|
||||
} else {
|
||||
} else if(!tab.page.annotations) {
|
||||
// enable annotation
|
||||
tab.page.annotations = new Zotero.Annotations(this, browser, tab.annotateID);
|
||||
Zotero.Annotate.setAnnotated(tab.annotateID, true);
|
||||
browser.contentWindow.addEventListener('beforeunload', function() {
|
||||
// save annotations
|
||||
try {
|
||||
tab.page.annotations.save();
|
||||
} catch(e) {
|
||||
throw(e);
|
||||
} finally {
|
||||
Zotero.Annotate.setAnnotated(tab.page.annotations.itemID, false);
|
||||
}
|
||||
}, false);
|
||||
tab.page.annotations = new Zotero.Annotations(this, browser, annotationID);
|
||||
var saveAnnotations = function() {
|
||||
tab.page.annotations.save();
|
||||
tab.page.annotations = undefined;
|
||||
};
|
||||
browser.contentWindow.addEventListener('beforeunload', saveAnnotations, false);
|
||||
browser.contentWindow.addEventListener('close', saveAnnotations, false);
|
||||
tab.page.annotations.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// detect translators
|
||||
tab.detectTranslators(rootDoc, doc);
|
||||
|
||||
// clear annotateNextLoad
|
||||
if(tab.annotateNextLoad) {
|
||||
tab.annotateNextLoad = tab.annotateID = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -410,7 +400,7 @@ var Zotero_Browser = new function() {
|
|||
|
||||
// To execute if document object does not exist
|
||||
_deleteTabObject(event.target.linkedBrowser);
|
||||
toggleMode(null);
|
||||
toggleMode();
|
||||
}
|
||||
|
||||
|
||||
|
@ -556,7 +546,7 @@ var Zotero_Browser = new function() {
|
|||
if(selection.isCollapsed) return;
|
||||
|
||||
if(type == "highlight") {
|
||||
tab.page.annotations.createHighlight(selection.getRangeAt(0));
|
||||
tab.page.annotations.highlight(selection.getRangeAt(0));
|
||||
} else if(type == "unhighlight") {
|
||||
tab.page.annotations.unhighlight(selection.getRangeAt(0));
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ Zotero_Charset_Menu = new function() {
|
|||
* closer to the top
|
||||
*
|
||||
* @param {DOMElement} charsetMenu The menu to populate
|
||||
* @param {Boolean} showEndian Whether to show endian (e.g., UTF-32) options
|
||||
* @param {Boolean} exportMenu Whether the menu is to be used for export
|
||||
**/
|
||||
function populate(charsetMenu, showEndian) {
|
||||
function populate(charsetMenu, exportMenu) {
|
||||
var charsetMap = {};
|
||||
|
||||
// get charset popup and charset RDF
|
||||
|
@ -60,16 +60,16 @@ Zotero_Charset_Menu = new function() {
|
|||
|
||||
var isUTF16 = charset.length >= 6 && charset.substr(0, 6) == "UTF-16";
|
||||
|
||||
// Show UTF-16 element appropriately depending on showEndian
|
||||
if(isUTF16 && showEndian == (charset == "UTF-16") ||
|
||||
(!showEndian && charset == "UTF-32LE")) {
|
||||
// Show UTF-16 element appropriately depending on exportMenu
|
||||
if(isUTF16 && exportMenu == (charset == "UTF-16") ||
|
||||
(!exportMenu && charset == "UTF-32LE")) {
|
||||
continue;
|
||||
} else if(charset == "x-mac-roman") {
|
||||
// use the IANA name
|
||||
value = "macintosh";
|
||||
} else if(!showEndian && charset == "UTF-32BE") {
|
||||
charset = "macintosh";
|
||||
} else if(!exportMenu && charset == "UTF-32BE") {
|
||||
label = "Unicode (UTF-32)";
|
||||
value = "UTF-32";
|
||||
charset = "UTF-32";
|
||||
}
|
||||
|
||||
// add element
|
||||
|
@ -85,7 +85,7 @@ Zotero_Charset_Menu = new function() {
|
|||
var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null);
|
||||
charsetPopup.insertBefore(itemNode, oldFirst);
|
||||
// also add (without BOM) if requested
|
||||
if(showEndian) {
|
||||
if(exportMenu) {
|
||||
var itemNode = document.createElement("menuitem");
|
||||
itemNode.setAttribute("label", Zotero.getString("charset.UTF8withoutBOM"));
|
||||
itemNode.setAttribute("value", charset+"xBOM");
|
||||
|
@ -97,6 +97,14 @@ Zotero_Charset_Menu = new function() {
|
|||
}
|
||||
}
|
||||
|
||||
if(!exportMenu) {
|
||||
var itemNode = document.createElement("menuitem");
|
||||
itemNode.setAttribute("label", Zotero.getString("charset.autoDetect"));
|
||||
itemNode.setAttribute("value", "auto");
|
||||
charsetMap["auto"] = itemNode;
|
||||
charsetPopup.insertBefore(itemNode, charsetPopup.firstChild);
|
||||
}
|
||||
|
||||
return charsetMap;
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ var Zotero_File_Interface_Export = new function() {
|
|||
this.accept = accept;
|
||||
this.cancel = cancel;
|
||||
|
||||
var _charsets;
|
||||
var _charsets = false;
|
||||
|
||||
/*
|
||||
* add options to export
|
||||
|
@ -100,7 +100,9 @@ var Zotero_File_Interface_Export = new function() {
|
|||
}
|
||||
|
||||
// from charsetMenu.js
|
||||
_charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true);
|
||||
if(Zotero.Prefs.get("export.displayCharsetOption")) {
|
||||
_charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true);
|
||||
}
|
||||
|
||||
updateOptions(Zotero.Prefs.get("export.translatorSettings"));
|
||||
}
|
||||
|
@ -156,11 +158,11 @@ var Zotero_File_Interface_Export = new function() {
|
|||
}
|
||||
|
||||
// handle charset popup
|
||||
var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset");
|
||||
if(translatorOptions.exportCharset) {
|
||||
document.getElementById("charset-box").hidden = undefined;
|
||||
if(_charsets && translatorOptions.exportCharset) {
|
||||
optionsBox.hidden = undefined;
|
||||
var charset = "UTF-8xBOM";
|
||||
document.getElementById("charset-box").hidden = undefined;
|
||||
var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset");
|
||||
var charset = "UTF-8";
|
||||
if(options && options.exportCharset && _charsets[options.exportCharset]) {
|
||||
charset = options.exportCharset;
|
||||
} else if(translatorOptions.exportCharset && _charsets[translatorOptions.exportCharset]) {
|
||||
|
@ -168,6 +170,8 @@ var Zotero_File_Interface_Export = new function() {
|
|||
}
|
||||
|
||||
charsetMenu.selectedItem = _charsets[charset];
|
||||
} else {
|
||||
document.getElementById("charset-box").hidden = true;
|
||||
}
|
||||
|
||||
window.sizeToContent();
|
||||
|
@ -192,17 +196,16 @@ var Zotero_File_Interface_Export = new function() {
|
|||
var element = document.getElementById(OPTION_PREFIX+option);
|
||||
|
||||
if(option == "exportCharset") {
|
||||
optionsAvailable[option] = element.selectedItem.value;
|
||||
if(_charsets) {
|
||||
optionsAvailable[option] = element.selectedItem.value;
|
||||
}
|
||||
} else if(typeof(defValue) == "boolean") {
|
||||
optionsAvailable[option] = !!element.checked;
|
||||
}
|
||||
}
|
||||
|
||||
// save options
|
||||
Zotero.debug("EXPORT OPTIONS");
|
||||
Zotero.debug(optionsAvailable);
|
||||
optionString = Zotero.JSON.serialize(optionsAvailable);
|
||||
Zotero.debug(optionString);
|
||||
Zotero.Prefs.set("export.translatorSettings", optionString);
|
||||
}
|
||||
|
||||
|
|
|
@ -850,6 +850,7 @@ var ZoteroPane = new function()
|
|||
// Create a <description> element, essentially
|
||||
else
|
||||
{
|
||||
label.removeAttribute('value');
|
||||
label.appendChild(document.createTextNode(val));
|
||||
}
|
||||
|
||||
|
@ -863,11 +864,35 @@ var ZoteroPane = new function()
|
|||
var checkState = { value: Zotero.Prefs.get('lastRenameAssociatedFile') };
|
||||
|
||||
while (true) {
|
||||
var result = nsIPS.prompt(window,
|
||||
// Don't show "Rename associated file" option for
|
||||
// linked URLs
|
||||
if (linkMode = item.ref.getAttachmentLinkMode() ==
|
||||
Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
||||
var result = nsIPS.prompt(
|
||||
window,
|
||||
'',
|
||||
Zotero.getString('pane.item.attachments.rename.title'),
|
||||
newTitle,
|
||||
null,
|
||||
{}
|
||||
);
|
||||
|
||||
// If they hit cancel or left it blank
|
||||
if (!result || !newTitle.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var result = nsIPS.prompt(
|
||||
window,
|
||||
'',
|
||||
Zotero.getString('pane.item.attachments.rename.title'),
|
||||
'', newTitle,
|
||||
newTitle,
|
||||
Zotero.getString('pane.item.attachments.rename.renameAssociatedFile'),
|
||||
checkState);
|
||||
checkState
|
||||
);
|
||||
|
||||
// If they hit cancel or left it blank
|
||||
if (!result || !newTitle.value) {
|
||||
|
@ -1701,36 +1726,13 @@ var ZoteroPane = new function()
|
|||
var tab = gBrowser.addTab(uri);
|
||||
var browser = gBrowser.getBrowserForTab(tab);
|
||||
|
||||
if (data && data.attachmentID) {
|
||||
Zotero_Browser.annotatePage(data.attachmentID, browser);
|
||||
// In case the page has already loaded, update
|
||||
Zotero_Browser.updateStatus();
|
||||
}
|
||||
|
||||
if (event.shiftKey) {
|
||||
gBrowser.selectedTab = tab;
|
||||
}
|
||||
}
|
||||
else if (event.shiftKey) {
|
||||
} else if (event.shiftKey) {
|
||||
window.open(uri, "zotero-loaded-page",
|
||||
"menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes");
|
||||
|
||||
if (data && data.attachmentID) {
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var newWindow = wm.getMostRecentWindow("navigator:browser");
|
||||
//var browser = newWindow.getBrowser();
|
||||
|
||||
newWindow.Zotero_Browser.annotatePage(data.attachmentID);
|
||||
// In case the page has already loaded, update
|
||||
newWindow.Zotero_Browser.updateStatus();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (data && data.attachmentID) {
|
||||
// Enable annotation
|
||||
Zotero_Browser.annotatePage(data.attachmentID);
|
||||
}
|
||||
} else {
|
||||
window.loadURI(uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,8 +404,7 @@
|
|||
<!-- Annotation Toolbar -->
|
||||
<toolbar id="zotero-annotate-tb" crop="end" insertbefore="content" hidden="true">
|
||||
<toolbarbutton id="zotero-annotate-tb-add" tooltiptext="&zotero.annotate.toolbar.add.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
|
||||
<toolbarbutton id="zotero-annotate-tb-collapse" tooltiptext="&zotero.annotate.toolbar.collapse.label;" oncommand="Zotero_Browser.setCollapsed(true);"/>
|
||||
<toolbarbutton id="zotero-annotate-tb-expand" tooltiptext="&zotero.annotate.toolbar.expand.label;" oncommand="Zotero_Browser.setCollapsed(false);"/>
|
||||
<toolbarbutton id="zotero-annotate-tb-collapse" tooltiptext="&zotero.annotate.toolbar.collapse.label;" oncommand="Zotero_Browser.toggleCollapsed();"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton id="zotero-annotate-tb-highlight" tooltiptext="&zotero.annotate.toolbar.highlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
|
||||
<toolbarbutton id="zotero-annotate-tb-unhighlight" tooltiptext="&zotero.annotate.toolbar.unhighlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
var openURLServerField;
|
||||
var openURLVersionMenu;
|
||||
var proxies;
|
||||
var charsets;
|
||||
|
||||
function init()
|
||||
{
|
||||
|
@ -37,6 +38,10 @@ function init()
|
|||
populateQuickCopyList();
|
||||
updateQuickCopyInstructions();
|
||||
initSearchPane();
|
||||
|
||||
var charsetMenu = document.getElementById("zotero-import-charsetMenu");
|
||||
charsetMap = Zotero_Charset_Menu.populate(charsetMenu, false);
|
||||
charsetMenu.selectedItem = charsetMap[Zotero.Prefs.get("import.charset")] ? charsetMap[Zotero.Prefs.get("import.charset")] : charsetMap["auto"];
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,7 +59,7 @@ function onDataDirUpdate(event) {
|
|||
|
||||
// If triggered from the Choose button, don't show the dialog, since
|
||||
// Zotero.chooseZoteroDirectory() shows its own
|
||||
if (event.originalTarget.tagName == 'button') {
|
||||
if (event.originalTarget && event.originalTarget.tagName == 'button') {
|
||||
return true;
|
||||
}
|
||||
// If directory not set or invalid, prompt for location
|
||||
|
|
|
@ -568,6 +568,8 @@ To add a new preference:
|
|||
<preferences>
|
||||
<preference id="pref-useDataDir" name="extensions.zotero.useDataDir" type="bool"/>
|
||||
<preference id="pref-dataDir" name="extensions.zotero.dataDir" type="string"/>
|
||||
<preference id="pref-export-displayCharsetOption" name="extensions.zotero.export.displayCharsetOption" type="bool"/>
|
||||
<preference id="pref-import-charset" name="extensions.zotero.import.charset" type="string"/>
|
||||
</preferences>
|
||||
|
||||
<groupbox>
|
||||
|
@ -598,10 +600,29 @@ To add a new preference:
|
|||
<button label="&zotero.preferences.dbMaintenance.resetTranslatorsAndStyles;" oncommand="resetTranslatorsAndStyles()"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&zotero.preferences.charset;"/>
|
||||
|
||||
<checkbox id="zotero-export-displayCharsetOption" label="&zotero.preferences.charset.displayExportOption;"
|
||||
preference="pref-export-displayCharsetOption"/>
|
||||
|
||||
<hbox align="center">
|
||||
<label value="&zotero.preferences.charset.importCharset;:" control="zotero-import-charsetMenu"/>
|
||||
<menulist id="zotero-import-charsetMenu" preference="pref-import-charset"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</prefpane>
|
||||
|
||||
<!-- These mess up the prefwindow (more) if they come before the prefpanes
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=296418 -->
|
||||
<script src="chrome://zotero/content/include.js"/>
|
||||
<script src="chrome://zotero/content/charsetMenu.js"/>
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
|
||||
observerService.notifyObservers(null, "charsetmenu-selected", "other");
|
||||
]]>
|
||||
</script>
|
||||
<script src="preferences.js"/>
|
||||
</prefwindow>
|
|
@ -137,7 +137,7 @@
|
|||
var bibliography = '<hr/><h1>Bibliography</h1>' +
|
||||
csl.formatBibliography(itemSet, "HTML");
|
||||
iframe.contentDocument.documentElement.innerHTML =
|
||||
'<div style="white-space: pre">'
|
||||
'<div style="white-space: pre-wrap">'
|
||||
+ citations + multCitations + bibliography
|
||||
+ '</div>';
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
|
||||
// Generate bibliography
|
||||
var bibliography = '<p>' + csl.formatBibliography(itemSet, "HTML");
|
||||
return '<div style="white-space: pre">' +
|
||||
return '<div style="white-space: pre-wrap">' +
|
||||
citations + bibliography + '</div>';
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ Zotero.Attachments = new function(){
|
|||
Zotero.debug('Importing attachment from URL');
|
||||
|
||||
// Throw error on invalid URLs
|
||||
urlRe = /^https?:\/\/[^\s]*$/;
|
||||
var urlRe = /^https?:\/\/[^\s]*$/;
|
||||
var matches = urlRe.exec(url);
|
||||
if (!matches) {
|
||||
throw ("Invalid URL '" + url + "' in Zotero.Attachments.importFromURL()");
|
||||
|
@ -365,7 +365,7 @@ Zotero.Attachments = new function(){
|
|||
Zotero.debug('Linking attachment from URL');
|
||||
|
||||
// Throw error on invalid URLs
|
||||
urlRe = /^https?:\/\/[^\s]*$/;
|
||||
var urlRe = /^https?:\/\/[^\s]*$/;
|
||||
var matches = urlRe.exec(url);
|
||||
if (!matches) {
|
||||
throw ("Invalid URL '" + url + "' in Zotero.Attachments.linkFromURL()");
|
||||
|
@ -1099,27 +1099,24 @@ Zotero.Attachments = new function(){
|
|||
|
||||
var browser = Zotero.Browser.createHiddenBrowser();
|
||||
|
||||
Zotero.File.addCharsetListener(browser, new function(){
|
||||
return function(charset, id){
|
||||
var charsetID = Zotero.CharacterSets.getID(charset);
|
||||
|
||||
var callback = function(charset, args) {
|
||||
var charsetID = Zotero.CharacterSets.getID(charset);
|
||||
if (charsetID) {
|
||||
var disabled = Zotero.Notifier.disable();
|
||||
|
||||
var item = Zotero.Items.get(itemID);
|
||||
item.attachmentCharset = charsetID;
|
||||
item.save();
|
||||
|
||||
if (disabled) {
|
||||
Zotero.Notifier.enable();
|
||||
}
|
||||
|
||||
// Chain fulltext indexer inside the charset callback,
|
||||
// since it's asynchronous and a prerequisite
|
||||
Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
|
||||
|
||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||
};
|
||||
}, itemID);
|
||||
}
|
||||
|
||||
// Chain fulltext indexer inside the charset callback,
|
||||
// since it's asynchronous and a prerequisite
|
||||
Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
|
||||
};
|
||||
|
||||
Zotero.File.addCharsetListener(browser, callback, itemID);
|
||||
|
||||
var url = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||
.getService(Components.interfaces.nsIFileProtocolHandler)
|
||||
|
|
|
@ -2252,8 +2252,8 @@ Zotero.CSL.Item._optionalTypeMap = {
|
|||
audioRecording:"song", // ??
|
||||
presentation:"speech",
|
||||
videoRecording:"motion_picture",
|
||||
tvBroadcast:"motion_picture",
|
||||
radioBroadcast:"motion_picture",
|
||||
tvBroadcast:"broadcast",
|
||||
radioBroadcast:"broadcast",
|
||||
podcast:"song", // ??
|
||||
computerProgram:"book" // ??
|
||||
};
|
||||
|
|
|
@ -2210,6 +2210,7 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) {
|
|||
Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
|
||||
var file = this.getFile();
|
||||
if (!file) {
|
||||
Zotero.debug("Attachment file not found in renameAttachmentFile()", 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2234,6 +2235,8 @@ Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
|
|||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.debug(e);
|
||||
Components.utils.reportError(e);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ Zotero.File = new function(){
|
|||
/*
|
||||
* Not implemented, but it'd sure be great if it were
|
||||
*/
|
||||
function getCharsetFromString(str){
|
||||
function getCharsetFromByteArray(arr) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,10 @@ Zotero.File = new function(){
|
|||
.getService(Components.interfaces.nsIFileProtocolHandler)
|
||||
.getURLSpecFromFile(file);
|
||||
|
||||
this.addCharsetListener(browser, callback, args);
|
||||
this.addCharsetListener(browser, function (charset, args) {
|
||||
callback(charset, args);
|
||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||
}, args);
|
||||
|
||||
browser.loadURI(url);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ Zotero.MIME = new function(){
|
|||
'text/css': true,
|
||||
'image/jpeg': true,
|
||||
'image/gif': true,
|
||||
'image/png': true,
|
||||
'image/svg+xml': true,
|
||||
'text/xml': true,
|
||||
'application/xhtml+xml': true,
|
||||
'application/xml': true,
|
||||
|
|
|
@ -1387,7 +1387,8 @@ Zotero.Search.prototype._buildQuery = function(){
|
|||
if (includeParentsAndChildren || includeChildren) {
|
||||
var childrenSQL = "SELECT itemID FROM itemAttachments WHERE "
|
||||
+ "sourceItemID IN (" + condSQL + ") UNION "
|
||||
+ "SELECT itemID FROM itemNotes WHERE sourceItemID IN (" + condSQL + ")";
|
||||
+ "SELECT itemID FROM itemNotes "
|
||||
+ "WHERE sourceItemID IN (" + condSQL + ")";
|
||||
var childSQLParams = condSQLParams.concat(condSQLParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -437,7 +437,7 @@ Zotero.Translate.prototype.runHandler = function(type, argument) {
|
|||
var returnValue = undefined;
|
||||
if(this._handlers[type]) {
|
||||
for(var i in this._handlers[type]) {
|
||||
Zotero.debug("Translate: running handler "+i+" for "+type);
|
||||
Zotero.debug("Translate: running handler "+i+" for "+type, 5);
|
||||
try {
|
||||
if(this._parentTranslator) {
|
||||
returnValue = this._handlers[type][i](null, argument);
|
||||
|
@ -453,7 +453,7 @@ Zotero.Translate.prototype.runHandler = function(type, argument) {
|
|||
} else {
|
||||
// otherwise, fail silently, so as not to interfere with
|
||||
// interface cleanup
|
||||
Zotero.debug("Translate: "+e+' in handler '+i+' for '+type);
|
||||
Zotero.debug("Translate: "+e+' in handler '+i+' for '+type, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ Zotero.Translate.prototype.getTranslators = function() {
|
|||
this._setSandboxMode("detect");
|
||||
|
||||
var possibleTranslators = new Array();
|
||||
Zotero.debug("Translate: searching for translators for "+(this.path ? this.path : "an undisclosed location"));
|
||||
Zotero.debug("Translate: Searching for translators for "+(this.path ? this.path : "an undisclosed location"), 3);
|
||||
|
||||
// see which translators can translate
|
||||
this._translatorSearch = new Zotero.Translate.TranslatorSearch(this, translators);
|
||||
|
@ -518,7 +518,7 @@ Zotero.Translate.prototype._loadTranslator = function() {
|
|||
// parse detect code for the translator
|
||||
this._parseDetectCode(this.translator[0]);
|
||||
|
||||
Zotero.debug("Translate: parsing code for "+this.translator[0].label);
|
||||
Zotero.debug("Translate: Parsing code for "+this.translator[0].label, 4);
|
||||
|
||||
try {
|
||||
Components.utils.evalInSandbox(this.translator[0].code, this._sandbox);
|
||||
|
@ -526,7 +526,7 @@ Zotero.Translate.prototype._loadTranslator = function() {
|
|||
if(this._parentTranslator) {
|
||||
throw(e);
|
||||
} else {
|
||||
this._debug(e+' in parsing code for '+this.translator[0].label);
|
||||
this._debug(e+' in parsing code for '+this.translator[0].label, 3);
|
||||
this._translationComplete(false, e);
|
||||
return false;
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ Zotero.Translate.prototype._parseDetectCode = function(translator) {
|
|||
try {
|
||||
Components.utils.evalInSandbox(detectCode, this._sandbox);
|
||||
} catch(e) {
|
||||
this._debug(e+' in parsing detectCode for '+translator.label);
|
||||
this._debug(e+' in parsing detectCode for '+translator.label, 3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -620,50 +620,37 @@ Zotero.Translate.prototype._parseDetectCode = function(translator) {
|
|||
/*
|
||||
* generates a sandbox for scraping/scraper detection
|
||||
*/
|
||||
Zotero.Translate._searchSandboxRegexp = new RegExp();
|
||||
Zotero.Translate._searchSandboxRegexp.compile("^http://[\\w.]+/");
|
||||
Zotero.Translate.prototype._generateSandbox = function() {
|
||||
var me = this;
|
||||
|
||||
if(this.type == "web" || this.type == "search") {
|
||||
// get sandbox URL
|
||||
var sandboxLocation = "http://www.example.com/";
|
||||
if(this.type == "web") {
|
||||
// use real URL, not proxied version, to create sandbox
|
||||
sandboxLocation = this.document.defaultView;
|
||||
Zotero.debug("Translate: binding sandbox to "+this.document.location.href);
|
||||
} else {
|
||||
// generate sandbox for search by extracting domain from translator
|
||||
// target, if one exists
|
||||
// get sandbox URL
|
||||
var sandboxLocation = "http://www.example.com/";
|
||||
if(this.type == "web") {
|
||||
// use real URL, not proxied version, to create sandbox
|
||||
sandboxLocation = this.document.defaultView;
|
||||
Zotero.debug("Translate: Binding sandbox to "+this.document.location.href, 4);
|
||||
} else {
|
||||
if (this.type == "search") {
|
||||
// generate sandbox for search by extracting domain from translator target
|
||||
if(this.translator && this.translator[0] && this.translator[0].target) {
|
||||
// so that web translators work too
|
||||
const searchSandboxRe = /^http:\/\/[\w.]+\//;
|
||||
var tempURL = this.translator[0].target.replace(/\\/g, "").replace(/\^/g, "");
|
||||
var m = Zotero.Translate._searchSandboxRegexp.exec(tempURL);
|
||||
if(m) {
|
||||
sandboxLocation = m[0];
|
||||
}
|
||||
var m = searchSandboxRe.exec(tempURL);
|
||||
if(m) sandboxLocation = m[0];
|
||||
}
|
||||
Zotero.debug("Translate: binding sandbox to "+sandboxLocation);
|
||||
}
|
||||
this._sandbox = new Components.utils.Sandbox(sandboxLocation);
|
||||
|
||||
this._sandbox.Zotero = new Object();
|
||||
|
||||
// add ingester utilities
|
||||
this._sandbox.Zotero.Utilities = new Zotero.Utilities.Ingester(this);
|
||||
this._sandbox.Zotero.Utilities.HTTP = new Zotero.Utilities.Ingester.HTTP(this);
|
||||
|
||||
// set up selectItems handler
|
||||
this._sandbox.Zotero.selectItems = function(options) { return me._selectItems(options) };
|
||||
} else {
|
||||
// use null URL to create sandbox. no idea why a blank string doesn't
|
||||
// work on all installations, but this should fix things.
|
||||
this._sandbox = new Components.utils.Sandbox("http://www.example.com/");
|
||||
this._sandbox.Zotero = new Object();
|
||||
|
||||
this._sandbox.Zotero.Utilities = new Zotero.Utilities();
|
||||
Zotero.debug("Translate: Binding sandbox to "+sandboxLocation, 4);
|
||||
}
|
||||
|
||||
// set up sandbox
|
||||
this._sandbox = new Components.utils.Sandbox(sandboxLocation);
|
||||
this._sandbox.Zotero = new Object();
|
||||
|
||||
// add utilities
|
||||
this._sandbox.Zotero.Utilities = new Zotero.Utilities.Translate(this);
|
||||
this._sandbox.Zotero.Utilities.HTTP = this._sandbox.Zotero.Utilities;
|
||||
|
||||
if(this.type == "export") {
|
||||
// add routines to retrieve items and collections
|
||||
this._sandbox.Zotero.nextItem = function() { return me._exportGetItem() };
|
||||
|
@ -678,13 +665,16 @@ Zotero.Translate.prototype._generateSandbox = function() {
|
|||
this._sandbox.Zotero.Collection = Zotero.Translate.GenerateZoteroCollectionClass();
|
||||
// attach the function to be run when a collection is done
|
||||
this._sandbox.Zotero.Collection.prototype.complete = function() {me._collectionDone(this)};
|
||||
} else if(this.type == "web" || this.type == "search") {
|
||||
// set up selectItems handler
|
||||
this._sandbox.Zotero.selectItems = function(options) { return me._selectItems(options) };
|
||||
}
|
||||
}
|
||||
|
||||
this._sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
|
||||
|
||||
// for debug messages
|
||||
this._sandbox.Zotero.debug = function(string) {me._debug(string)};
|
||||
this._sandbox.Zotero.debug = function(string) {me._debug(string, 4)};
|
||||
|
||||
// for adding configuration options
|
||||
this._sandbox.Zotero.configure = function(option, value) {me._configure(option, value) };
|
||||
|
@ -706,7 +696,7 @@ Zotero.Translate.prototype._generateSandbox = function() {
|
|||
// note that setLocation() is not allowed
|
||||
var safeTranslator = new Object();
|
||||
safeTranslator.setSearch = function(arg) { return translation.setSearch(arg) };
|
||||
safeTranslator.setBrowser = function(arg) { return translation.setBrowser(arg) };
|
||||
safeTranslator.setDocument = function(arg) { return translation.setDocument(arg) };
|
||||
safeTranslator.setHandler = function(arg1, arg2) { translation.setHandler(arg1, arg2) };
|
||||
safeTranslator.setString = function(arg) { translation.setString(arg) };
|
||||
safeTranslator.setTranslator = function(arg) { return translation.setTranslator(arg) };
|
||||
|
@ -799,7 +789,7 @@ Zotero.Translate.prototype._setSandboxMode = function(mode) {
|
|||
*/
|
||||
Zotero.Translate.prototype._configure = function(option, value) {
|
||||
this.configOptions[option] = value;
|
||||
Zotero.debug("Translate: setting configure option "+option+" to "+value);
|
||||
Zotero.debug("Translate: Setting configure option "+option+" to "+value, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -811,7 +801,7 @@ Zotero.Translate.prototype._configure = function(option, value) {
|
|||
*/
|
||||
Zotero.Translate.prototype._addOption = function(option, value) {
|
||||
this.displayOptions[option] = value;
|
||||
Zotero.debug("Translate: setting display option "+option+" to "+value);
|
||||
Zotero.debug("Translate: Setting display option "+option+" to "+value, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -884,8 +874,8 @@ Zotero.Translate.prototype._translationComplete = function(returnValue, error) {
|
|||
if(this.type == "search" && !this._itemsDone) {
|
||||
// if we're performing a search and didn't get any results, go on
|
||||
// to the next translator
|
||||
Zotero.debug("Translate: could not find a result using "+this.translator[0].label+": \n"
|
||||
+this._generateErrorString(error));
|
||||
Zotero.debug("Translate: Could not find a result using "+this.translator[0].label+": \n"
|
||||
+this._generateErrorString(error), 3);
|
||||
if(this.translator.length > 1) {
|
||||
this.translator.shift();
|
||||
this.translate();
|
||||
|
@ -903,7 +893,7 @@ Zotero.Translate.prototype._translationComplete = function(returnValue, error) {
|
|||
|
||||
// report error to debug log
|
||||
var errorString = this._generateErrorString(error);
|
||||
this._debug("Translation using "+(this.translator && this.translator[0] && this.translator[0].label ? this.translator[0].label : "no translator")+" failed: \n"+errorString);
|
||||
this._debug("Translation using "+(this.translator && this.translator[0] && this.translator[0].label ? this.translator[0].label : "no translator")+" failed: \n"+errorString, 2);
|
||||
|
||||
if(this.type == "web") {
|
||||
// report translation error for webpages
|
||||
|
@ -937,12 +927,8 @@ Zotero.Translate.prototype._generateErrorString = function(error) {
|
|||
}
|
||||
|
||||
errorString += "\nurl => "+this.path
|
||||
+ "\nextensions.zotero.cacheTranslatorData => "+Zotero.Prefs.get("cacheTranslatorData")
|
||||
// TODO: Currently using automaticSnapshots pref for everything
|
||||
// Eventually downloadAssociatedFiles may be a separate pref
|
||||
// for PDFs and other large files
|
||||
+ "\nextensions.zotero.downloadAssociatedFiles => "+Zotero.Prefs.get("downloadAssociatedFiles");
|
||||
+ "\nextensions.zotero.automaticSnapshots => "+Zotero.Prefs.get("automaticSnapshots");
|
||||
+ "\ndownloadAssociatedFiles => "+Zotero.Prefs.get("downloadAssociatedFiles")
|
||||
+ "\nautomaticSnapshots => "+Zotero.Prefs.get("automaticSnapshots");
|
||||
return errorString.substr(1);
|
||||
}
|
||||
|
||||
|
@ -951,10 +937,10 @@ Zotero.Translate.prototype._generateErrorString = function(error) {
|
|||
*/
|
||||
Zotero.Translate.prototype._reportTranslationFailure = function(errorData) {
|
||||
if(this.translator[0].inRepository && Zotero.Prefs.get("reportTranslationFailure")) {
|
||||
var postBody = "ids[]="+escape(this.translator[0].translatorID)+
|
||||
"&lastUpdated="+escape(this.translator[0].lastUpdated)+
|
||||
"&extVersion="+escape(Zotero.version)+
|
||||
"&errorData="+escape(errorData);
|
||||
var postBody = "id=" + encodeURIComponent(this.translator[0].translatorID) +
|
||||
"&lastUpdated=" + encodeURIComponent(this.translator[0].lastUpdated) +
|
||||
"&diagnostic=" + encodeURIComponent(Zotero.getSystemInfo()) +
|
||||
"&errorData=" + encodeURIComponent(errorData);
|
||||
Zotero.Utilities.HTTP.doPost("http://www.zotero.org/repo/report", postBody);
|
||||
}
|
||||
}
|
||||
|
@ -1081,7 +1067,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
if(this._parentTranslator) {
|
||||
var pt = this._parentTranslator;
|
||||
item.complete = function() { pt._itemDone(this) };
|
||||
Zotero.debug("Translate: calling done from parent sandbox");
|
||||
Zotero.debug("Translate: Calling done from parent sandbox", 4);
|
||||
}
|
||||
this.runHandler("itemDone", item);
|
||||
return;
|
||||
|
@ -1111,14 +1097,14 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
// create new item
|
||||
if(type == "attachment") {
|
||||
if(this.type != "import") {
|
||||
Zotero.debug("Translate: discarding standalone attachment");
|
||||
Zotero.debug("Translate: Discarding standalone attachment", 2);
|
||||
return;
|
||||
}
|
||||
|
||||
Zotero.debug("Translate: adding attachment");
|
||||
Zotero.debug("Translate: Adding attachment", 4);
|
||||
|
||||
if(!item.url && !item.path) {
|
||||
Zotero.debug("Translate: ignoring attachment: no path or URL specified");
|
||||
Zotero.debug("Translate: Ignoring attachment: no path or URL specified", 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1130,7 +1116,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
item.path = item.url;
|
||||
item.url = false;
|
||||
} else if(protocol != "http" && protocol != "https") {
|
||||
Zotero.debug("Translate: unrecognized protocol "+protocol);
|
||||
Zotero.debug("Translate: Unrecognized protocol "+protocol, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1142,10 +1128,10 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
(item.mimeType ? item.mimeType : undefined),
|
||||
(item.title ? item.title : undefined));
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: error adding attachment "+item.url);
|
||||
Zotero.debug("Translate: Error adding attachment "+item.url, 2);
|
||||
return;
|
||||
}
|
||||
Zotero.debug("Translate: created attachment; id is "+myID);
|
||||
Zotero.debug("Translate: Created attachment; id is "+myID, 4);
|
||||
var newItem = Zotero.Items.get(myID);
|
||||
} else {
|
||||
// generate nsIFile
|
||||
|
@ -1205,7 +1191,11 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
for(var j in data) {
|
||||
// try to assign correct creator type
|
||||
if(data[j].creatorType) {
|
||||
var creatorTypeID = Zotero.CreatorTypes.getID(data[j].creatorType);
|
||||
try {
|
||||
var creatorType = Zotero.CreatorTypes.getID(data[j].creatorType);
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: Invalid creator type "+data[j].creatorType+" for creator index "+j, 2);
|
||||
}
|
||||
}
|
||||
if(!creatorTypeID) {
|
||||
var creatorTypeID = 1;
|
||||
|
@ -1240,14 +1230,14 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
// try to map from base field
|
||||
if(Zotero.ItemFields.isBaseField(fieldID)) {
|
||||
var fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID);
|
||||
if(fieldID) Zotero.debug("Translate: mapping "+field+" to "+Zotero.ItemFields.getName(fieldID));
|
||||
if(fieldID) Zotero.debug("Translate: Mapping "+field+" to "+Zotero.ItemFields.getName(fieldID), 5);
|
||||
}
|
||||
|
||||
// if field is valid for this type, set field
|
||||
if(fieldID && Zotero.ItemFields.isValidForType(fieldID, typeID)) {
|
||||
newItem.setField(fieldID, data);
|
||||
} else {
|
||||
Zotero.debug("Translate: discarded field "+field+" for item: field not valid for type "+type);
|
||||
Zotero.debug("Translate: Discarded field "+field+" for item: field not valid for type "+type, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1316,11 +1306,13 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
var downloadAssociatedFiles = Zotero.Prefs.get("downloadAssociatedFiles");
|
||||
|
||||
// handle attachments
|
||||
if(item.attachments && this.saveAttachments && (automaticSnapshots || downloadAssociatedFiles)) {
|
||||
if(item.attachments && this.saveAttachments &&
|
||||
// DEBUG: is "this.type == 'import'" still necessary with this.saveAttachments?
|
||||
(this.type == 'import' || automaticSnapshots || downloadAssociatedFiles)) {
|
||||
for each(var attachment in item.attachments) {
|
||||
if(this.type == "web") {
|
||||
if(!attachment.url && !attachment.document) {
|
||||
Zotero.debug("Translate: not adding attachment: no URL specified");
|
||||
Zotero.debug("Translate: Not adding attachment: no URL specified", 2);
|
||||
} else {
|
||||
if(attachment.snapshot === false) {
|
||||
if(!automaticSnapshots) {
|
||||
|
@ -1334,7 +1326,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
(attachment.title ? attachment.title : attachment.document.title));
|
||||
} else {
|
||||
if(!attachment.mimeType || !attachment.title) {
|
||||
Zotero.debug("Translate: NOTICE: either mimeType or title is missing; attaching file will be slower");
|
||||
Zotero.debug("Translate: Either mimeType or title is missing; attaching file will be slower", 3);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1342,7 +1334,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
(attachment.mimeType ? attachment.mimeType : undefined),
|
||||
(attachment.title ? attachment.title : undefined));
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: error adding attachment "+attachment.url);
|
||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||
}
|
||||
}
|
||||
} else if(attachment.document
|
||||
|
@ -1354,7 +1346,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
try {
|
||||
Zotero.Attachments.importFromDocument(attachment.document, myID, attachment.title);
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: error attaching document");
|
||||
Zotero.debug("Translate: Error attaching document", 2);
|
||||
}
|
||||
// Save attachment if snapshot pref enabled or not HTML
|
||||
// (in which case downloadAssociatedFiles applies)
|
||||
|
@ -1386,7 +1378,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
|||
try {
|
||||
Zotero.Attachments.importFromURL(attachment.url, myID, title, fileBaseName);
|
||||
} catch(e) {
|
||||
Zotero.debug("Zotero.Translate: error adding attachment "+attachment.url);
|
||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1493,10 +1485,10 @@ Zotero.Translate.prototype._processCollection = function(collection, parentID) {
|
|||
} else {
|
||||
// add mapped items to collection
|
||||
if(this._IDMap[child.id]) {
|
||||
Zotero.debug("Translate: adding "+this._IDMap[child.id]);
|
||||
Zotero.debug("Translate: Adding "+this._IDMap[child.id], 5);
|
||||
newCollection.addItem(this._IDMap[child.id]);
|
||||
} else {
|
||||
Zotero.debug("Translate: could not map "+child.id+" to an imported item");
|
||||
Zotero.debug("Translate: Could not map "+child.id+" to an imported item", 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1507,10 +1499,13 @@ Zotero.Translate.prototype._processCollection = function(collection, parentID) {
|
|||
/*
|
||||
* logs a debugging message
|
||||
*/
|
||||
Zotero.Translate.prototype._debug = function(string) {
|
||||
Zotero.Translate.prototype._debug = function(string, level) {
|
||||
// if handler does not return anything explicitly false, show debug
|
||||
// message in console
|
||||
if(this.runHandler("debug", string) !== false) Zotero.debug(string, 4);
|
||||
if(this.runHandler("debug", string) !== false) {
|
||||
if(typeof string == "string") string = "Translate: "+string;
|
||||
Zotero.debug(string, level);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1550,41 +1545,41 @@ Zotero.Translate.prototype._search = function() {
|
|||
**/
|
||||
Zotero.Translate.prototype._import = function() {
|
||||
this.waitForCompletion = true;
|
||||
var me = this;
|
||||
this._importGetCharacterSet(function(charset) { me._importDoComplete(charset) });
|
||||
return true;
|
||||
this._importSniffCharacterSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sniff file if a real file exists
|
||||
*
|
||||
* @param {Function} callback A callback function to be executed after sniffing
|
||||
**/
|
||||
Zotero.Translate.prototype._importGetCharacterSet = function(callback) {
|
||||
* Sniff file for its character set, then proceed with the rest of translation
|
||||
*/
|
||||
Zotero.Translate.prototype._importSniffCharacterSet = function(callback) {
|
||||
if(!this._storage) {
|
||||
// need to check charset
|
||||
|
||||
if(this._charset) {
|
||||
// have charset already; just go on
|
||||
callback(this._charset);
|
||||
this._importDoneSniffing(this._charset);
|
||||
} else {
|
||||
// look for charset
|
||||
var me = this;
|
||||
Zotero.File.getCharsetFromFile(this.location, "text/plain",
|
||||
function(charset) {
|
||||
me._charset = charset;
|
||||
callback(charset);
|
||||
});
|
||||
// need to check charset
|
||||
importCharset = Zotero.Prefs.get("import.charset");
|
||||
if(importCharset == "auto") {
|
||||
// look for charset
|
||||
var me = this;
|
||||
Zotero.File.getCharsetFromFile(this.location, "text/plain",
|
||||
function(charset) {
|
||||
me._charset = charset;
|
||||
me._importDoneSniffing(charset);
|
||||
});
|
||||
} else {
|
||||
this._importDoneSniffing(importCharset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
callback();
|
||||
this._importDoneSniffing();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete import (used as callback after sniffing)
|
||||
**/
|
||||
Zotero.Translate.prototype._importDoComplete = function(charset) {
|
||||
Zotero.Translate.prototype._importDoneSniffing = function(charset) {
|
||||
this._importConfigureIO(charset);
|
||||
|
||||
try {
|
||||
|
@ -1659,19 +1654,22 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
this._streams.push(this._inputStream);
|
||||
}
|
||||
|
||||
var filePosition = 0;
|
||||
|
||||
if(charset) { // if have detected charset
|
||||
Zotero.debug("Using detected character set "+charset);
|
||||
var bomLength = 0;
|
||||
if(charset === undefined || (charset && charset.length > 3 && charset.substr(0, 3) == "UTF")) {
|
||||
// seek past BOM
|
||||
if(charset.length > 3 && charset.substr(0, 3) == "UTF") {
|
||||
var BOMLength = this._importGetBOMLength();
|
||||
this._inputStream.QueryInterface(Components.interfaces.nsISeekableStream)
|
||||
.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, BOMLength);
|
||||
}
|
||||
|
||||
var bomCharset = this._importGetBOM();
|
||||
var bomLength = (bomCharset ? BOMs[bomCharset].length : 0);
|
||||
this._inputStream.QueryInterface(Components.interfaces.nsISeekableStream)
|
||||
.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, bomLength);
|
||||
if(bomCharset) charset = this._charset = bomCharset;
|
||||
}
|
||||
|
||||
var intlStream = null;
|
||||
if(charset) {
|
||||
// if have detected charset
|
||||
Zotero.debug("Translate: Using detected character set "+charset, 3);
|
||||
// convert from detected charset
|
||||
var intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
||||
intlStream.init(this._inputStream, charset, 65535,
|
||||
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
|
@ -1680,12 +1678,9 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
|
||||
// allow translator to set charset
|
||||
this._sandbox.Zotero.setCharacterSet = function(charset) {
|
||||
// seek
|
||||
if(filePosition != 0) {
|
||||
me._inputStream.QueryInterface(Components.interfaces.nsISeekableStream)
|
||||
.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, filePosition);
|
||||
me._inputStream.QueryInterface(Components.interfaces.nsIFileInputStream);
|
||||
}
|
||||
// seek back to the beginning
|
||||
me._inputStream.QueryInterface(Components.interfaces.nsISeekableStream)
|
||||
.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, bomLength);
|
||||
|
||||
intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
||||
|
@ -1695,7 +1690,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
} catch(e) {
|
||||
throw "Text encoding not supported";
|
||||
}
|
||||
|
||||
me._streams.push(intlStream);
|
||||
}
|
||||
|
||||
|
@ -1710,7 +1704,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
var amountRead = me._inputStream.readLine(str);
|
||||
}
|
||||
if(amountRead) {
|
||||
filePosition += amountRead;
|
||||
return str.value;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1725,7 +1718,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
var amountRead = intlStream.readString(amount, str);
|
||||
|
||||
if(amountRead) {
|
||||
filePosition += amountRead;
|
||||
return str.value;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1740,7 +1732,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
|
||||
// read from the scriptable input stream
|
||||
var string = sStream.read(amount);
|
||||
filePosition += string.length;
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
@ -1757,7 +1748,7 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
|
|||
*
|
||||
* @return The length of the UTF BOM.
|
||||
*/
|
||||
Zotero.Translate.prototype._importGetBOMLength = function() {
|
||||
Zotero.Translate.prototype._importGetBOM = function() {
|
||||
// if not checked for a BOM, open a binary input stream and read
|
||||
var binStream = Components.classes["@mozilla.org/binaryinputstream;1"].
|
||||
createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||
|
@ -1778,7 +1769,7 @@ Zotero.Translate.prototype._importGetBOMLength = function() {
|
|||
if(possibleBOMs[charset][0] == readChar) {
|
||||
if(possibleBOMs[charset].length == 1) {
|
||||
// have checked entire BOM
|
||||
return BOMs[charset].length;
|
||||
return charset;
|
||||
} else {
|
||||
// keep checking
|
||||
newBOMs[charset] = possibleBOMs[charset].substr(1);
|
||||
|
@ -1790,7 +1781,7 @@ Zotero.Translate.prototype._importGetBOMLength = function() {
|
|||
possibleBOMs = newBOMs;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1940,7 +1931,6 @@ Zotero.Translate.prototype._exportConfigureIO = function() {
|
|||
if(streamCharset == "MACINTOSH") {
|
||||
// fix buggy Mozilla MacRoman
|
||||
splitData = data.split(/([\r\n]+)/);
|
||||
Zotero.debug(splitData);
|
||||
for(var i=0; i<splitData.length; i+=2) {
|
||||
// write raw newlines straight to the string
|
||||
intlStream.writeString(splitData[i]);
|
||||
|
@ -2291,20 +2281,16 @@ Zotero.Translate.TranslatorSearch.prototype.execute = function() {
|
|||
|
||||
if(this.translate.type == "import") {
|
||||
var me = this;
|
||||
this.translate._importGetCharacterSet(function(charset) {
|
||||
try {
|
||||
me.translate._importConfigureIO(charset); // so it can read
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: "+e+' in opening IO for '+translator.label);
|
||||
me.execute();
|
||||
return;
|
||||
}
|
||||
|
||||
me.runDetectCode(translator);
|
||||
});
|
||||
} else {
|
||||
this.runDetectCode(translator);
|
||||
|
||||
try {
|
||||
this.translate._importConfigureIO(); // so it can read
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: "+e+' in opening IO for '+translator.label);
|
||||
this.execute();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.runDetectCode(translator);
|
||||
} else {
|
||||
this.execute();
|
||||
}
|
||||
|
@ -2336,7 +2322,7 @@ Zotero.Translate.TranslatorSearch.prototype.runDetectCode = function(translator)
|
|||
return;
|
||||
}
|
||||
|
||||
Zotero.debug("Translate: executed detectCode for "+translator.label);
|
||||
Zotero.debug("Translate: Executed detectCode for "+translator.label, 4);
|
||||
|
||||
if(this.translate.type == "web" && this.translate.waitForCompletion) {
|
||||
this.asyncMode = true;
|
||||
|
@ -2382,7 +2368,7 @@ Zotero.Translate.TranslatorSearch.prototype.checkDone = function() {
|
|||
* Processes the return value from a translator
|
||||
*/
|
||||
Zotero.Translate.TranslatorSearch.prototype.processReturnValue = function(translator, returnValue) {
|
||||
Zotero.debug("Translate: found translator "+translator.label);
|
||||
Zotero.debug("Translate: Found translator "+translator.label, 3);
|
||||
|
||||
if(typeof(returnValue) == "string") {
|
||||
translator.itemType = returnValue;
|
||||
|
@ -2402,7 +2388,7 @@ Zotero.Translate.TranslatorSearch.prototype.complete = function(returnValue, err
|
|||
this.processReturnValue(this.currentTranslator, returnValue);
|
||||
} else if(error) {
|
||||
var errorString = this.translate._generateErrorString(error);
|
||||
this.translate._debug("detectCode for "+(this.currentTranslator ? this.currentTranslator.label : "no translator")+" failed: \n"+errorString);
|
||||
this.translate._debug("detectCode for "+(this.currentTranslator ? this.currentTranslator.label : "no translator")+" failed: \n"+errorString, 4);
|
||||
}
|
||||
|
||||
this.currentTranslator = undefined;
|
||||
|
|
|
@ -38,10 +38,13 @@ var Zotero = new function(){
|
|||
this.stateCheck = stateCheck;
|
||||
//this.shutdown = shutdown;
|
||||
this.getProfileDirectory = getProfileDirectory;
|
||||
this.getInstallDirectory = getInstallDirectory;
|
||||
this.getZoteroDirectory = getZoteroDirectory;
|
||||
this.getStorageDirectory = getStorageDirectory;
|
||||
this.getZoteroDatabase = getZoteroDatabase;
|
||||
this.getTempDirectory = getTempDirectory;
|
||||
this.convertChromeURLToFile = convertChromeURLToFile;
|
||||
this.convertChromeURLToFileURL = convertChromeURLToFileURL;
|
||||
this.chooseZoteroDirectory = chooseZoteroDirectory;
|
||||
this.debug = debug;
|
||||
this.log = log;
|
||||
|
@ -310,6 +313,15 @@ var Zotero = new function(){
|
|||
}
|
||||
|
||||
|
||||
function getInstallDirectory() {
|
||||
var id = ZOTERO_CONFIG.GUID;
|
||||
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
||||
getService(Components.interfaces.nsIExtensionManager);
|
||||
var installDir = em.getInstallLocation(id).getItemLocation(id);
|
||||
return installDir;
|
||||
}
|
||||
|
||||
|
||||
function getZoteroDirectory(){
|
||||
if (_zoteroDirectory != false) {
|
||||
// Return a clone of the file pointer so that callers can modify it
|
||||
|
@ -319,7 +331,14 @@ var Zotero = new function(){
|
|||
if (Zotero.Prefs.get('useDataDir')) {
|
||||
var file = Components.classes["@mozilla.org/file/local;1"].
|
||||
createInstance(Components.interfaces.nsILocalFile);
|
||||
file.persistentDescriptor = Zotero.Prefs.get('dataDir');
|
||||
try {
|
||||
file.persistentDescriptor = Zotero.Prefs.get('dataDir');
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.debug("Persistent descriptor in extensions.zotero.dataDir did not resolve", 1);
|
||||
e = { name: "NS_ERROR_FILE_NOT_FOUND" };
|
||||
throw (e);
|
||||
}
|
||||
if (!file.exists()) {
|
||||
var e = { name: "NS_ERROR_FILE_NOT_FOUND" };
|
||||
throw (e);
|
||||
|
@ -378,6 +397,72 @@ var Zotero = new function(){
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a file from a chrome://zotero URL
|
||||
*
|
||||
* Currently only works for skin URLs
|
||||
*
|
||||
* @param {String} chromeURI
|
||||
* @return {nsIFile}
|
||||
*/
|
||||
function convertChromeURLToFile(chromeURL) {
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var uri = ios.newURI(chromeURL, null, null);
|
||||
uri.QueryInterface(Components.interfaces.nsIStandardURL);
|
||||
|
||||
if (uri.scheme != 'chrome') {
|
||||
throw ("URI " + uri.spec +
|
||||
" not a chrome URI in Zotero.convertChromeURLToFileURL()");
|
||||
}
|
||||
|
||||
if (uri.host != 'zotero') {
|
||||
throw ("URI " + uri.spec +
|
||||
" not a Zotero chrome URI in Zotero.convertChromeURLToFileURL()");
|
||||
}
|
||||
|
||||
var parts = uri.path.substr(1).split('/');
|
||||
|
||||
// Auto-expand URL if necessary
|
||||
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIChromeRegistry);
|
||||
uri = chromeReg.convertChromeURL(uri);
|
||||
|
||||
var file = this.getInstallDirectory();
|
||||
file.append('chrome');
|
||||
|
||||
switch (parts[0]) {
|
||||
case 'skin':
|
||||
file.append('skin');
|
||||
file.append('default');
|
||||
file.append('zotero');
|
||||
|
||||
for (var i=1; i<parts.length; i++) {
|
||||
file.append(parts[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ("Chrome URI part '" + parts[0]
|
||||
+ "' not implemented in Zotero.convertChromeURLToFileURL()")
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {String} chromeURI
|
||||
* @return {nsIURL} file:// nsIURL
|
||||
*/
|
||||
function convertChromeURLToFileURL(chromeURL) {
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var file = this.convertChromeURLToFile(chromeURL);
|
||||
return ios.newFileURI(file).spec;
|
||||
}
|
||||
|
||||
|
||||
function chooseZoteroDirectory(forceRestartNow, useProfileDir) {
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
|
@ -590,7 +675,8 @@ var Zotero = new function(){
|
|||
platform: Zotero.platform,
|
||||
locale: Zotero.locale,
|
||||
appName: appInfo.name,
|
||||
appVersion: appInfo.version
|
||||
appVersion: appInfo.version,
|
||||
extensions: this.getInstalledExtensions().join(', ')
|
||||
};
|
||||
|
||||
var str = '';
|
||||
|
@ -602,6 +688,31 @@ var Zotero = new function(){
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return {String[]} Array of extension names and versions
|
||||
*/
|
||||
this.getInstalledExtensions = function () {
|
||||
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
||||
getService(Components.interfaces.nsIExtensionManager);
|
||||
var installed = em.getItemList(
|
||||
Components.interfaces.nsIUpdateItem.TYPE_ANY, {}
|
||||
);
|
||||
|
||||
var addons = [];
|
||||
for each(var addon in installed) {
|
||||
switch (addon.id) {
|
||||
case "zotero@chnm.gmu.edu":
|
||||
case "{972ce4c6-7e08-4474-a285-3208198ce6fd}": // Default theme
|
||||
continue;
|
||||
}
|
||||
|
||||
addons.push(addon.name + " (" + addon.version
|
||||
+ (addon.type != 2 ? ", " + addon.type : "") + ")");
|
||||
}
|
||||
return addons;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHP var_dump equivalent for JS
|
||||
*
|
||||
|
@ -1803,6 +1914,11 @@ Zotero.Browser = new function() {
|
|||
hiddenBrowser.setAttribute('type', 'content');
|
||||
hiddenBrowser.setAttribute('disablehistory', 'true');
|
||||
win.document.documentElement.appendChild(hiddenBrowser);
|
||||
// Disable some features
|
||||
hiddenBrowser.docShell.allowImages = false;
|
||||
hiddenBrowser.docShell.allowJavascript = false;
|
||||
hiddenBrowser.docShell.allowMetaRedirects = false;
|
||||
hiddenBrowser.docShell.allowPlugins = false;
|
||||
Zotero.debug("created hidden browser ("
|
||||
+ win.document.getElementsByTagName('browser').length + ")");
|
||||
return hiddenBrowser;
|
||||
|
|
|
@ -102,6 +102,10 @@
|
|||
|
||||
<!ENTITY zotero.preferences.prefpane.advanced "Advanced">
|
||||
|
||||
<!ENTITY zotero.preferences.charset "Character Encoding">
|
||||
<!ENTITY zotero.preferences.charset.importCharset "Import Character Encoding">
|
||||
<!ENTITY zotero.preferences.charset.displayExportOption "Display character encoding option on export">
|
||||
|
||||
<!ENTITY zotero.preferences.dataDir "Storage Location">
|
||||
<!ENTITY zotero.preferences.dataDir.useProfile "Use Firefox profile directory">
|
||||
<!ENTITY zotero.preferences.dataDir.custom "Custom:">
|
||||
|
|
|
@ -123,7 +123,6 @@
|
|||
|
||||
<!ENTITY zotero.charset.label "Character Encoding">
|
||||
<!ENTITY zotero.moreEncodings.label "More Encodings">
|
||||
<!ENTITY zotero.charset.auto "auto detect">
|
||||
|
||||
<!ENTITY zotero.citation.keepSorted.label "Keep Sources Sorted">
|
||||
|
||||
|
|
|
@ -455,6 +455,7 @@ fulltext.indexState.partial = Partial
|
|||
exportOptions.exportNotes = Export Notes
|
||||
exportOptions.exportFileData = Export Files
|
||||
charset.UTF8withoutBOM = Unicode (UTF-8 without BOM)
|
||||
charset.autoDetect = (auto detect)
|
||||
|
||||
date.daySuffixes = st, nd, rd, th
|
||||
date.abbreviation.year = y
|
||||
|
|
Before Width: | Height: | Size: 771 B After Width: | Height: | Size: 657 B |
Before Width: | Height: | Size: 682 B After Width: | Height: | Size: 530 B |
Before Width: | Height: | Size: 670 B |
BIN
chrome/skin/default/zotero/annotate-collapse.png
Normal file
After Width: | Height: | Size: 557 B |
Before Width: | Height: | Size: 678 B |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 788 B |
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 927 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 845 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 976 B |
54
chrome/skin/default/zotero/annotation.css
Normal file
|
@ -0,0 +1,54 @@
|
|||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #fff580;
|
||||
border: 1px solid #878244;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#bar {
|
||||
display: block;
|
||||
padding: 1px 1px 1px 0;
|
||||
background-color: #c0b860;
|
||||
border-bottom: 1px solid #878244;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
#close, #move, #collapse {
|
||||
position: absolute;
|
||||
display: block;
|
||||
top: 2px;
|
||||
cursor: pointer;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
#close {
|
||||
left: 1px;
|
||||
}
|
||||
|
||||
#move {
|
||||
right: 14px;
|
||||
}
|
||||
|
||||
#collapse {
|
||||
right: 2px;
|
||||
}
|
||||
|
||||
#grippy {
|
||||
position: absolute;
|
||||
display: block;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
cursor: se-resize;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
#text {
|
||||
font-family: Arial, Lucida Grande, FreeSans, sans;
|
||||
font-size: 12px;
|
||||
border: none;
|
||||
margin: 3px 2px 5px 2px;
|
||||
background-color: #fff580;
|
||||
}
|
16
chrome/skin/default/zotero/annotation.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link type="text/css" rel="stylesheet" href="annotation.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="bar">
|
||||
<img id="close" src="annotation-close.png"/>
|
||||
<img id="move" src="annotation-move.png"/>
|
||||
<img id="collapse" src="annotation-hide.png"/>
|
||||
</div>
|
||||
<img id="grippy" src="annotation-grippy.png"/>
|
||||
<textarea id="text" wrap="soft"></textarea>
|
||||
</body>
|
||||
</html>
|
|
@ -345,12 +345,7 @@
|
|||
|
||||
#zotero-annotate-tb-collapse
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/annotate-collapse-all.png');
|
||||
}
|
||||
|
||||
#zotero-annotate-tb-expand
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/annotate-expand-all.png');
|
||||
list-style-image: url('chrome://zotero/skin/annotate-collapse.png');
|
||||
}
|
||||
|
||||
#zotero-annotate-tb-highlight
|
||||
|
|
|
@ -28,7 +28,6 @@ ul.report {
|
|||
font-size: 1.4em;
|
||||
width: 680px;
|
||||
margin: 0 auto;
|
||||
overflow: auto;
|
||||
padding: 20px 20px;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ function ChromeExtensionHandler() {
|
|||
var ReportExtension = new function(){
|
||||
this.newChannel = newChannel;
|
||||
|
||||
this.__defineGetter__('loadAsChrome', function () { return true; });
|
||||
|
||||
function newChannel(uri){
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
@ -413,7 +415,9 @@ function ChromeExtensionHandler() {
|
|||
|
||||
var TimelineExtension = new function(){
|
||||
this.newChannel = newChannel;
|
||||
|
||||
|
||||
this.__defineGetter__('loadAsChrome', function () { return true; });
|
||||
|
||||
/*
|
||||
queryString key abbreviations: intervals = i | dateType = t | timelineDate = d
|
||||
|
||||
|
@ -625,6 +629,8 @@ function ChromeExtensionHandler() {
|
|||
var AttachmentExtension = new function() {
|
||||
this.newChannel = newChannel;
|
||||
|
||||
this.__defineGetter__('loadAsChrome', function () { return false; });
|
||||
|
||||
function newChannel(uri) {
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
@ -638,15 +644,29 @@ function ChromeExtensionHandler() {
|
|||
var [id, fileName] = uri.path.substr(1).split('/');
|
||||
|
||||
if (parseInt(id) != id) {
|
||||
return _errorChannel("Attachment id not an integer");
|
||||
// Proxy annotation icons
|
||||
if (id.match(/^annotation.*\.(png|html|css|gif)$/)) {
|
||||
var chromeURL = 'chrome://zotero/skin/' + id;
|
||||
var file = Zotero.convertChromeURLToFile(chromeURL);
|
||||
if (!file.exists()) {
|
||||
Zotero.debug(file.path + " not found");
|
||||
Components.utils.reportError(file.path + " not found");
|
||||
return _errorChannel("File not found");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return _errorChannel("Attachment id not an integer");
|
||||
}
|
||||
}
|
||||
|
||||
var item = Zotero.Items.get(id);
|
||||
if (!item) {
|
||||
return _errorChannel("Item not found");
|
||||
if (!file) {
|
||||
var item = Zotero.Items.get(id);
|
||||
if (!item) {
|
||||
return _errorChannel("Item not found");
|
||||
}
|
||||
var file = item.getFile();
|
||||
}
|
||||
|
||||
var file = item.getFile();
|
||||
if (!file) {
|
||||
return _errorChannel("File not found");
|
||||
}
|
||||
|
@ -661,7 +681,7 @@ function ChromeExtensionHandler() {
|
|||
|
||||
var ph = Components.classes["@mozilla.org/network/protocol;1?name=file"].
|
||||
createInstance(Components.interfaces.nsIFileProtocolHandler);
|
||||
fileURI = ph.newFileURI(file);
|
||||
var fileURI = ph.newFileURI(file);
|
||||
var channel = ioService.newChannelFromURI(fileURI);
|
||||
return channel;
|
||||
}
|
||||
|
@ -688,7 +708,7 @@ function ChromeExtensionHandler() {
|
|||
*/
|
||||
var SelectExtension = new function(){
|
||||
this.newChannel = newChannel;
|
||||
|
||||
|
||||
function newChannel(uri) {
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
@ -745,8 +765,11 @@ ChromeExtensionHandler.prototype = {
|
|||
|
||||
defaultPort : -1,
|
||||
|
||||
protocolFlags : Components.interfaces.nsIProtocolHandler.URI_STD,
|
||||
|
||||
protocolFlags :
|
||||
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Components.interfaces.nsIProtocolHandler.URI_NOAUTH |
|
||||
Components.interfaces.nsIProtocolHandler.URI_IS_LOCAL_FILE,
|
||||
|
||||
allowPort : function(port, scheme) {
|
||||
return false;
|
||||
},
|
||||
|
@ -755,7 +778,6 @@ ChromeExtensionHandler.prototype = {
|
|||
var newURL = Components.classes["@mozilla.org/network/standard-url;1"]
|
||||
.createInstance(Components.interfaces.nsIStandardURL);
|
||||
newURL.init(1, -1, spec, charset, baseURI);
|
||||
|
||||
return newURL.QueryInterface(Components.interfaces.nsIURI);
|
||||
},
|
||||
|
||||
|
@ -771,11 +793,11 @@ ChromeExtensionHandler.prototype = {
|
|||
try {
|
||||
var uriString = uri.spec.toLowerCase();
|
||||
|
||||
for (extSpec in this._extensions) {
|
||||
for (var extSpec in this._extensions) {
|
||||
var ext = this._extensions[extSpec];
|
||||
|
||||
if (uriString.indexOf(extSpec) == 0) {
|
||||
if (this._systemPrincipal == null) {
|
||||
if (ext.loadAsChrome && this._systemPrincipal == null) {
|
||||
var chromeURI = chromeService.newURI(DUMMY_CHROME_URL, null, null);
|
||||
var chromeChannel = chromeService.newChannel(chromeURI);
|
||||
|
||||
|
@ -796,8 +818,8 @@ ChromeExtensionHandler.prototype = {
|
|||
chromeRequest.cancel(0x804b0002); // BINDING_ABORTED
|
||||
}
|
||||
|
||||
if (this._systemPrincipal != null) {
|
||||
// applying cached system principal to extension channel
|
||||
// Apply cached system principal to extension channel
|
||||
if (ext.loadAsChrome) {
|
||||
extChannel.owner = this._systemPrincipal;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ pref("extensions.zotero.export.lastStyle", 'http://www.zotero.org/styles/chicago
|
|||
pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
|
||||
pref("extensions.zotero.export.bibliographyLocale", '');
|
||||
pref("extensions.zotero.export.citePaperJournalArticleURL", false);
|
||||
pref("extensions.zotero.export.displayCharsetOption", false);
|
||||
pref("extensions.zotero.import.charset", "auto");
|
||||
|
||||
pref("extensions.zotero.export.quickCopy.setting", 'bibliography=http://www.zotero.org/styles/chicago-note');
|
||||
|
||||
|
|