diff --git a/chrome.manifest b/chrome.manifest index 58cdf7d477..d6ad9a7643 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -49,8 +49,13 @@ skin zotero default chrome/skin/default/zotero/ overlay chrome://browser/content/browser.xul chrome://zotero/content/statusBarOverlay.xul appversion<4.0 overlay chrome://browser/content/browser.xul chrome://zotero/content/overlay.xul -overlay chrome://zotero/content/preferences/preferences.xul chrome://zotero/content/preferences/preferences_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} + +overlay chrome://zotero/content/preferences/preferences.xul chrome://zotero/content/preferences/preferences_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} overlay chrome://zotero/content/preferences/preferences.xul#cite chrome://zotero/content/preferences/preferences_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} +overlay chrome://zotero/content/preferences/preferences_general.xul chrome://zotero/content/preferences/preferences_general_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} +overlay chrome://zotero/content/preferences/preferences_export.xul chrome://zotero/content/preferences/preferences_export_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} +overlay chrome://zotero/content/preferences/preferences_advanced.xul chrome://zotero/content/preferences/preferences_advanced_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} + overlay chrome://mozapps/content/downloads/unknownContentType.xul chrome://zotero/content/downloadOverlay.xul style chrome://browser/content/browser.xul chrome://zotero/skin/zotero.css diff --git a/chrome/content/zotero/bindings/merge.xml b/chrome/content/zotero/bindings/merge.xml index 220b0d3197..2fe1e3020e 100644 --- a/chrome/content/zotero/bindings/merge.xml +++ b/chrome/content/zotero/bindings/merge.xml @@ -24,7 +24,7 @@ ***** END LICENSE BLOCK ***** --> - + - - diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 4a1d0b576a..05b065446e 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -401,7 +401,7 @@ var Zotero_Browser = new function() { } // set annotation bar status - if(tab.page.annotations) { + if(tab.page.annotations && tab.page.annotations.annotations.length) { document.getElementById('zotero-annotate-tb').hidden = false; toggleMode(); } else { diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index 85b6ac4f0b..0cfa35dc54 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -1,7 +1,7 @@ /* ***** BEGIN LICENSE BLOCK ***** - Copyright © 2009 Center for History and New Media + Copyright © 2006–2013 Center for History and New Media George Mason University, Fairfax, Virginia, USA http://zotero.org @@ -23,15 +23,40 @@ ***** END LICENSE BLOCK ***** */ -var openURLResolvers; -var proxies; -var charsets; -var _io = {}; - +"use strict"; var Zotero_Preferences = { + init: function () { + if(Zotero.isConnector) { + Zotero.activateStandalone(); + window.close(); + return; + } + + observerService.addObserver(function() { + if(Zotero.isConnector) window.close(); + }, "zotero-reloaded", false); + + if(window.arguments) { + var io = window.arguments[0]; + + if(io.pane) { + var pane = document.getElementById(io.pane); + document.getElementById('zotero-prefs').showPane(pane); + // Quick hack to support install prompt from PDF recognize option + if (io.action && io.action == 'pdftools-install') { + this.Search.checkPDFToolsDownloadVersion(); + } + } + } else if(document.location.hash == "#cite") { + document.getElementById('zotero-prefs').showPane(document.getElementById("zotero-prefpane-cite")); + } + }, + onUnload: function () { - Zotero_Preferences.Debug_Output.onUnload(); + if (Zotero_Preferences.Debug_Output) { + Zotero_Preferences.Debug_Output.onUnload(); + } }, openHelpLink: function () { @@ -69,2185 +94,39 @@ var Zotero_Preferences = { ); } } - } -} - -function init() -{ - if(Zotero.isConnector) { - Zotero.activateStandalone(); - window.close(); - return; - } - - observerService.addObserver(function() { - if(Zotero.isConnector) window.close(); - }, "zotero-reloaded", false); - - // Display the appropriate modifier keys for the platform - var rows = document.getElementById('zotero-prefpane-keys').getElementsByTagName('row'); - for (var i=0; i -1 && index < treechildren.childNodes.length) { - var treerow = treechildren.childNodes[index].firstChild; - var domain = treerow.childNodes[0].getAttribute('label'); - var format = treerow.childNodes[1].getAttribute('label'); - var asHTML = treerow.childNodes[2].getAttribute('label') != ''; - } - - var format = Zotero.QuickCopy.getSettingFromFormattedName(format); - if (asHTML) { - format = format.replace('bibliography=', 'bibliography/html='); - } - - var io = {domain: domain, format: format, ok: false}; - window.openDialog('chrome://zotero/content/preferences/quickCopySiteEditor.xul', "zotero-preferences-quickCopySiteEditor", "chrome, modal", io); - - if (!io.ok) { - return; - } - - if (domain && domain != io.domain) { - Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domain]); - } - - Zotero.DB.query("REPLACE INTO settings VALUES ('quickCopySite', ?, ?)", [io.domain, io.format]); - - refreshQuickCopySiteList(); -} - -function refreshQuickCopySiteList() { - var treechildren = document.getElementById('quickCopy-siteSettings-rows'); - while (treechildren.hasChildNodes()) { - treechildren.removeChild(treechildren.firstChild); - } - - var sql = "SELECT key AS domainPath, value AS format FROM settings " - + "WHERE setting='quickCopySite' ORDER BY domainPath COLLATE NOCASE"; - var siteData = Zotero.DB.query(sql); - - if (!siteData) { - return; - } - - for (var i=0; i' - + Zotero.Fulltext.pdfToolsName + '']); - var parts = Zotero.Utilities.parseMarkup(str); - for (var i=0; i'; - var str = Zotero.getString('zotero.preferences.search.pdf.advancedUsers', link); - var parts = Zotero.Utilities.parseMarkup(str); - - for (var i=0; i Zotero.Fulltext.pdfConverterVersion); - var infoVersionAvailable = infoVersion && - (!infoIsRegistered || - Zotero.Fulltext.pdfInfoVersion == 'UNKNOWN' || - infoVersion > Zotero.Fulltext.pdfInfoVersion); - var bothAvailable = converterVersionAvailable && infoVersionAvailable; - - /* - Zotero.debug(converterIsRegistered); - Zotero.debug(infoIsRegistered); - Zotero.debug(converterVersion); - Zotero.debug(infoVersion); - Zotero.debug(Zotero.Fulltext.pdfConverterVersion); - Zotero.debug(Zotero.Fulltext.pdfInfoVersion); - Zotero.debug(converterVersionAvailable); - Zotero.debug(infoVersionAvailable); - */ - - // Up to date -- disable update button - if (!converterVersionAvailable && !infoVersionAvailable) { - var button = document.getElementById('pdftools-update-button'); - button.setAttribute('label', Zotero.getString('zotero.preferences.update.upToDate')); - button.setAttribute('disabled', true); - } - // New version available -- display update prompt - else { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]. - createInstance(Components.interfaces.nsIPromptService); - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); - - var msg = Zotero.getString('zotero.preferences.search.pdf.available' - + ((converterIsRegistered || infoIsRegistered) ? 'Updates' : 'Downloads'), - [Zotero.platform, 'zotero.org']) + '\n\n'; - - if (converterVersionAvailable) { - tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform', - [Zotero.Fulltext.pdfConverterName, converterVersion]); - msg += '- ' + tvp + '\n'; - } - if (infoVersionAvailable) { - tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform', - [Zotero.Fulltext.pdfInfoName, infoVersion]); - msg += '- ' + tvp + '\n'; - } - msg += '\n'; - msg += Zotero.getString('zotero.preferences.search.pdf.zoteroCanInstallVersion' - + (bothAvailable ? 's' : '')); - - var index = ps.confirmEx(null, - converterIsRegistered ? - Zotero.getString('general.updateAvailable') : '', - msg, - buttonFlags, - converterIsRegistered ? - Zotero.getString('general.upgrade') : - Zotero.getString('general.install'), - null, null, null, {}); - - if (index == 0) { - var installVersions = { - converter: converterVersionAvailable ? - converterVersion : null, - info: infoVersionAvailable ? - infoVersion : null - }; - installPDFTools(installVersions); - } - } - } - // Version not found for platform - else if (xmlhttp.status == 404) { - onPDFToolsDownloadError(404); - } - } - catch (e) { - onPDFToolsDownloadError(e); - } - }); - - // Browser is offline - if (!sent) { - onPDFToolsDownloadError(); - } -} - - -/* - * Begin installation of specified PDF tools from server -- does a HEAD call to - * make sure file exists and then calls downloadPDFTool() if so - */ -function installPDFTools(installVersions) { - if (!installVersions) { - installVersions = { - converter: true, - info: true - }; - } - - // We install the converter first if it's available - var url = Zotero.Fulltext.pdfToolsDownloadBaseURL; - if (installVersions.converter) { - var tool = 'converter'; - var version = installVersions.converter; - url += Zotero.Fulltext.pdfConverterFileName + '-' + installVersions.converter; - } - else if (installVersions.info) { - var tool = 'info'; - var version = installVersions.info; - url += Zotero.Fulltext.pdfInfoFileName + '-' + installVersions.info; - } - else { - return; - } - - // Find latest version for this platform - var sent = Zotero.HTTP.doHead(url, function (xmlhttp) { - try { - if (xmlhttp.status == 200) { - // If doing both and on converter, chain pdfinfo - if (installVersions.converter && installVersions.info) { - downloadPDFTool(tool, version, function () { - return installPDFTools({ info: installVersions.info }); - }); - } - else { - downloadPDFTool(tool, version); - } - } - // Version not found for platform - else if (xmlhttp.status == 404) { - onPDFToolsDownloadError(404); - } - } - catch (e) { - onPDFToolsDownloadError(e); - } - }); - - // Browser is offline - if (!sent) { - onPDFToolsDownloadError(); - } -} - - -/* - * Download and install specified PDF tool - */ -function downloadPDFTool(tool, version, callback) { - var ioService = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); - - if (tool == 'converter') { - var fileName = Zotero.Fulltext.pdfConverterFileName; - } - else { - var fileName = Zotero.Fulltext.pdfInfoFileName; - } - - - var url = Zotero.Fulltext.pdfToolsDownloadBaseURL + fileName + '-' + version; - var uri = ioService.newURI(url, null, null); - - var file = Zotero.getZoteroDirectory(); - file.append(fileName); - var fileURL = ioService.newFileURI(file); - - const nsIWBP = Components.interfaces.nsIWebBrowserPersist; - var wbp = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] - .createInstance(nsIWBP); - - var progressListener = new Zotero.WebProgressFinishListener(function () { - // Set permissions to 755 - if (Zotero.isMac) { - file.permissions = 33261; - } - else if (Zotero.isLinux) { - file.permissions = 493; - } - - // Write the version number to a file - var versionFile = Zotero.getZoteroDirectory(); - versionFile.append(fileName + '.version'); - Zotero.File.putContents(versionFile, version + ''); - - Zotero.Fulltext.registerPDFTool(tool); - - // Used to install info tool after converter - if (callback) { - callback(); - } - // If done - else { - updatePDFToolsStatus(); - } - }); - - /* - var tr = Components.classes["@mozilla.org/transfer;1"]. - createInstance(Components.interfaces.nsITransfer); - tr.init(uri, fileURL, "", null, null, null, wbp); - */ - - document.getElementById('pdftools-update-button').disabled = true; - var str = Zotero.getString('zotero.preferences.search.pdf.downloading'); - document.getElementById('pdftools-update-button').setAttribute('label', str); - - wbp.progressListener = progressListener; - Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec); - try { - wbp.saveURI(uri, null, null, null, null, fileURL); - } catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") { - // https://bugzilla.mozilla.org/show_bug.cgi?id=794602 - // XXX Always use when we no longer support Firefox < 18 - wbp.saveURI(uri, null, null, null, null, fileURL, null); - } -} - - -function onPDFToolsDownloadError(e) { - if (e == 404) { - var str = Zotero.getString('zotero.preferences.search.pdf.toolDownloadsNotAvailable', - Zotero.Fulltext.pdfToolsName) + ' ' - + Zotero.getString('zotero.preferences.search.pdf.viewManualInstructions'); - } - else if (e) { - Components.utils.reportError(e); - var str = Zotero.getString('zotero.preferences.search.pdf.toolsDownloadError', Zotero.Fulltext.pdfToolsName) - + ' ' + Zotero.getString('zotero.preferences.search.pdf.tryAgainOrViewManualInstructions'); - } - else { - var info = Components.classes["@mozilla.org/xre/app-info;1"] - .getService(Components.interfaces.nsIXULAppInfo); - var browser = info.name; // Returns "Firefox" for Firefox - var str = Zotero.getString('general.browserIsOffline', browser); - } - alert(str); -} - - -function updateIndexStats() { - var stats = Zotero.Fulltext.getIndexStats(); - document.getElementById('fulltext-stats-indexed'). - lastChild.setAttribute('value', stats.indexed); - document.getElementById('fulltext-stats-partial'). - lastChild.setAttribute('value', stats.partial); - document.getElementById('fulltext-stats-unindexed'). - lastChild.setAttribute('value', stats.unindexed); - document.getElementById('fulltext-stats-words'). - lastChild.setAttribute('value', stats.words); -} - - -function revealDataDirectory() { - var dataDir = Zotero.getZoteroDirectory(); - dataDir.QueryInterface(Components.interfaces.nsILocalFile); - try { - dataDir.reveal(); - } - catch (e) { - // On platforms that don't support nsILocalFile.reveal() (e.g. Linux), - // launch the directory - window.opener.ZoteroPane_Local.launchFile(dataDir); - } -} - - -function runIntegrityCheck() { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - var ok = Zotero.DB.integrityCheck(); - if (ok) { - ok = Zotero.Schema.integrityCheck(); - if (!ok) { - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); - var index = ps.confirmEx(window, - Zotero.getString('general.failed'), - Zotero.getString('db.integrityCheck.failed') + "\n\n" + - Zotero.getString('db.integrityCheck.repairAttempt') + " " + - Zotero.getString('db.integrityCheck.appRestartNeeded', Zotero.appName), - buttonFlags, - Zotero.getString('db.integrityCheck.fixAndRestart', Zotero.appName), - null, null, null, {} - ); - - if (index == 0) { - // Safety first - Zotero.DB.backupDatabase(); - - // Fix the errors - Zotero.Schema.integrityCheck(true); - - // And run the check again - ok = Zotero.Schema.integrityCheck(); - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING); - if (ok) { - var str = 'success'; - var msg = Zotero.getString('db.integrityCheck.errorsFixed'); - } - else { - var str = 'failed'; - var msg = Zotero.getString('db.integrityCheck.errorsNotFixed') - + "\n\n" + Zotero.getString('db.integrityCheck.reportInForums'); - } - - ps.confirmEx(window, - Zotero.getString('general.' + str), - msg, - buttonFlags, - Zotero.getString('general.restartApp', Zotero.appName), - null, null, null, {} - ); - - var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"] - .getService(Components.interfaces.nsIAppStartup); - appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit - | Components.interfaces.nsIAppStartup.eRestart); - } - - return; - } - } - var str = ok ? 'passed' : 'failed'; - - ps.alert(window, - Zotero.getString('general.' + str), - Zotero.getString('db.integrityCheck.' + str) - + (!ok ? "\n\n" + Zotero.getString('db.integrityCheck.dbRepairTool') : '')); -} - - -function updateTranslators() { - Zotero.Schema.updateFromRepository(true, function (xmlhttp, updated) { - var button = document.getElementById('updateButton'); - if (button) { - if (updated===-1) { - var label = Zotero.getString('zotero.preferences.update.upToDate'); - } - else if (updated) { - var label = Zotero.getString('zotero.preferences.update.updated'); - } - else { - var label = Zotero.getString('zotero.preferences.update.error'); - } - button.setAttribute('label', label); - - if (updated) { - refreshStylesList(); - } - } - }); -} - - -function resetTranslatorsAndStyles() { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); - - var index = ps.confirmEx(null, - Zotero.getString('general.warning'), - Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles.changesLost'), - buttonFlags, - Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles'), - null, null, null, {}); - - if (index == 0) { - Zotero.Schema.resetTranslatorsAndStyles(function (xmlhttp, updated) { - populateQuickCopyList(); - }); - } -} - - -function resetTranslators() { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); - - var index = ps.confirmEx(null, - Zotero.getString('general.warning'), - Zotero.getString('zotero.preferences.advanced.resetTranslators.changesLost'), - buttonFlags, - Zotero.getString('zotero.preferences.advanced.resetTranslators'), - null, null, null, {}); - - if (index == 0) { - Zotero.Schema.resetTranslators(); - } -} - - -function resetStyles() { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); - - var index = ps.confirmEx(null, - Zotero.getString('general.warning'), - Zotero.getString('zotero.preferences.advanced.resetStyles.changesLost'), - buttonFlags, - Zotero.getString('zotero.preferences.advanced.resetStyles'), - null, null, null, {}); - - if (index == 0) { - Zotero.Schema.resetStyles(function (xmlhttp, updated) { - populateQuickCopyList(); - }); - } -} - - -Zotero_Preferences.Debug_Output = { - _timer: null, - - init: function () { - var storing = Zotero.Debug.storing; - this._updateButton(); - this.updateLines(); - if (storing) { - this._initTimer(); - } }, - toggleStore: function () { - this.setStore(!Zotero.Debug.storing); - }, - - - setStore: function (set) { - Zotero.Debug.setStore(set); - if (set) { - this._initTimer(); - } - else { - if (this._timerID) { - this._timer.cancel(); - this._timerID = null; + /** + * Opens a URI in the basic viewer in Standalone, or a new window in Firefox + */ + openInViewer: function (uri, newTab) { + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + const features = "menubar=yes,toolbar=no,location=no,scrollbars,centerscreen,resizable"; + + if(Zotero.isStandalone) { + var win = wm.getMostRecentWindow("zotero:basicViewer"); + if(win) { + win.loadURI(uri); + } else { + window.openDialog("chrome://zotero/content/standalone/basicViewer.xul", + "basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri); } - } - this._updateButton(); - this.updateLines(); - }, - - - view: function () { - openInViewer("zotero://debug/"); - }, - - - submit: function () { - document.getElementById('debug-output-submit').disabled = true; - document.getElementById('debug-output-submit-progress').hidden = false; - - var url = "https://repo.zotero.org/repo/report?debug=1"; - var output = Zotero.Debug.get( - Zotero.Prefs.get('debug.store.submitSize'), - Zotero.Prefs.get('debug.store.submitLineLength') - ); - Zotero_Preferences.Debug_Output.setStore(false); - - var uploadCallback = function (xmlhttp) { - document.getElementById('debug-output-submit').disabled = false; - document.getElementById('debug-output-submit-progress').hidden = true; - - Zotero.debug(xmlhttp.responseText); - - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - if (!xmlhttp.responseXML) { - ps.alert( - null, - Zotero.getString('general.error'), - Zotero.getString('general.invalidResponseServer') - ); - return; - } - var reported = xmlhttp.responseXML.getElementsByTagName('reported'); - if (reported.length != 1) { - ps.alert( - null, - Zotero.getString('general.error'), - Zotero.getString('general.serverError') - ); - return; - } - - var reportID = reported[0].getAttribute('reportID'); - ps.alert( - null, - Zotero.getString('zotero.preferences.advanced.debug.title'), - Zotero.getString('zotero.preferences.advanced.debug.sent', reportID) - ); - } - - var bufferUploader = function (data) { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - var oldLen = output.length; - var newLen = data.length; - var savings = Math.round(((oldLen - newLen) / oldLen) * 100) - Zotero.debug("HTTP POST " + newLen + " bytes to " + url - + " (gzipped from " + oldLen + " bytes; " - + savings + "% savings)"); - - if (Zotero.HTTP.browserIsOffline()) { - ps.alert( - null, - Zotero.getString('general.error'), - Zotero.getString('general.browserIsOffline', Zotero.appName) - ); - return false; - } - - var req = - Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]. - createInstance(); - req.open('POST', url, true); - req.setRequestHeader('Content-Type', "text/plain"); - req.setRequestHeader('Content-Encoding', 'gzip'); - - req.channel.notificationCallbacks = { - onProgress: function (request, context, progress, progressMax) { - var pm = document.getElementById('debug-output-submit-progress'); - pm.mode = 'determined' - pm.value = progress; - pm.max = progressMax; - }, - - // nsIInterfaceRequestor - getInterface: function (iid) { - try { - return this.QueryInterface(iid); - } - catch (e) { - throw Components.results.NS_NOINTERFACE; - } - }, - - QueryInterface: function(iid) { - if (iid.equals(Components.interfaces.nsISupports) || - iid.equals(Components.interfaces.nsIInterfaceRequestor) || - iid.equals(Components.interfaces.nsIProgressEventSink)) { - return this; - } - throw Components.results.NS_NOINTERFACE; - }, - - } - req.onreadystatechange = function () { - if (req.readyState == 4) { - uploadCallback(req); - } - }; - try { - req.sendAsBinary(data); - } - catch (e) { - ps.alert( - null, - Zotero.getString('general.error'), - Zotero.getString('zotero.preferences.advanced.debug.error') - ); - } - } - - // Get input stream from debug output data - var unicodeConverter = - Components.classes["@mozilla.org/intl/scriptableunicodeconverter"] - .createInstance(Components.interfaces.nsIScriptableUnicodeConverter); - unicodeConverter.charset = "UTF-8"; - var bodyStream = unicodeConverter.convertToInputStream(output); - - // Get listener for when compression is done - var listener = new Zotero.BufferedInputListener(bufferUploader); - - // Initialize stream converter - var converter = - Components.classes["@mozilla.org/streamconv;1?from=uncompressed&to=gzip"] - .createInstance(Components.interfaces.nsIStreamConverter); - converter.asyncConvertData("uncompressed", "gzip", listener, null); - - // Send input stream to stream converter - var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]. - createInstance(Components.interfaces.nsIInputStreamPump); - pump.init(bodyStream, -1, -1, 0, 0, true); - pump.asyncRead(converter, null); - }, - - - clear: function () { - Zotero.Debug.clear(); - this.updateLines(); - }, - - - updateLines: function () { - var enabled = Zotero.Debug.storing; - var lines = Zotero.Debug.count(); - document.getElementById('debug-output-lines').value = lines; - var empty = lines == 0; - document.getElementById('debug-output-view').disabled = !enabled && empty; - document.getElementById('debug-output-clear').disabled = empty; - document.getElementById('debug-output-submit').disabled = empty; - }, - - - _initTimer: function () { - this._timer = Components.classes["@mozilla.org/timer;1"]. - createInstance(Components.interfaces.nsITimer); - this._timer.initWithCallback({ - notify: function() { - Zotero_Preferences.Debug_Output.updateLines(); - } - }, 10000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK); - }, - - - _updateButton: function () { - var storing = Zotero.Debug.storing - - var button = document.getElementById('debug-output-enable'); - if (storing) { - button.label = Zotero.getString('general.disable'); - } - else { - button.label = Zotero.getString('general.enable'); - } - }, - - - onUnload: function () { - if (this._timer) { - this._timer.cancel(); - } - } -} - -function onOpenURLSelected() -{ - var openURLServerField = document.getElementById('openURLServerField'); - var openURLVersionMenu = document.getElementById('openURLVersionMenu'); - var openURLMenu = document.getElementById('openURLMenu'); - - if(openURLMenu.value == "custom") - { - openURLServerField.focus(); - } - else - { - openURLServerField.value = openURLResolvers[openURLMenu.selectedIndex]['url']; - openURLVersionMenu.value = openURLResolvers[openURLMenu.selectedIndex]['version']; - Zotero.Prefs.set("openURL.resolver", openURLResolvers[openURLMenu.selectedIndex]['url']); - Zotero.Prefs.set("openURL.version", openURLResolvers[openURLMenu.selectedIndex]['version']); - } -} - -function onOpenURLCustomized() -{ - document.getElementById('openURLMenu').value = "custom"; -} - -/** STYLES **/ - -/** - * Refreshes the list of styles in the styles pane - * @param {String} cslID Style to select - */ -function refreshStylesList(cslID) { - var treechildren = document.getElementById('styleManager-rows'); - while (treechildren.hasChildNodes()) { - treechildren.removeChild(treechildren.firstChild); - } - - var styles = Zotero.Styles.getVisible(); - - var selectIndex = false; - var i = 0; - for each(var style in styles) { - var treeitem = document.createElement('treeitem'); - var treerow = document.createElement('treerow'); - var titleCell = document.createElement('treecell'); - var updatedCell = document.createElement('treecell'); - var cslCell = document.createElement('treecell'); - - if (style.updated) { - var updatedDate = Zotero.Date.formatDate(Zotero.Date.strToDate(style.updated), true); - } - else { - var updatedDate = ''; - } - - treeitem.setAttribute('id', 'zotero-csl-' + style.styleID); - titleCell.setAttribute('label', style.title); - updatedCell.setAttribute('label', updatedDate); - // if not EN - if(style.type == "csl") { - cslCell.setAttribute('src', 'chrome://zotero/skin/tick.png'); - } - - treerow.appendChild(titleCell); - treerow.appendChild(updatedCell); - treerow.appendChild(cslCell); - treeitem.appendChild(treerow); - treechildren.appendChild(treeitem); - - if (cslID == style.styleID) { - document.getElementById('styleManager').view.selection.select(i); - } - i++; - } -} - -/** - * Adds a new style to the style pane - **/ -function addStyle() { - const nsIFilePicker = Components.interfaces.nsIFilePicker; - var fp = Components.classes["@mozilla.org/filepicker;1"] - .createInstance(nsIFilePicker); - fp.init(window, Zotero.getString("zotero.preferences.styles.addStyle"), nsIFilePicker.modeOpen); - - fp.appendFilter("CSL Style", "*.csl"); - fp.appendFilter("ENS Style", "*.ens"); - - var rv = fp.show(); - if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) { - Zotero.Styles.install(fp.file); - } -} - -/** - * Deletes selected styles from the styles pane - **/ -function deleteStyle() { - // get selected cslIDs - var tree = document.getElementById('styleManager'); - var treeItems = tree.lastChild.childNodes; - var cslIDs = []; - var start = {}; - var end = {}; - var nRanges = tree.view.selection.getRangeCount(); - for(var i=0; i a.scheme) { - return 1; - } - - return 0; - }); - - // erase old children - var treechildren = document.getElementById('proxyTree-rows'); - while (treechildren.hasChildNodes()) { - treechildren.removeChild(treechildren.firstChild); - } - - // add proxies to list - for (var i=0; i - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -