From 6efd6d2cc42d65bab7c462156643e2856b11e103 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 8 Aug 2006 23:00:33 +0000 Subject: [PATCH] closes #99, add options for export --- .../content/scholar/exportOptions.js | 72 +++++++++++++++++++ .../content/scholar/exportOptions.xul | 14 ++++ .../content/scholar/fileInterface.js | 57 ++++----------- .../content/scholar/xpcom/translate.js | 47 ++++++++++-- .../locale/en-US/scholar/scholar.dtd | 4 +- .../locale/en-US/scholar/scholar.properties | 5 +- scrapers.sql | 54 ++++++++------ 7 files changed, 178 insertions(+), 75 deletions(-) create mode 100644 chrome/chromeFiles/content/scholar/exportOptions.js create mode 100644 chrome/chromeFiles/content/scholar/exportOptions.xul diff --git a/chrome/chromeFiles/content/scholar/exportOptions.js b/chrome/chromeFiles/content/scholar/exportOptions.js new file mode 100644 index 000000000..51dc33be8 --- /dev/null +++ b/chrome/chromeFiles/content/scholar/exportOptions.js @@ -0,0 +1,72 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Scholar_File_Interface_Export +// +////////////////////////////////////////////////////////////////////////////// + +// Class to provide options for export + +Scholar_File_Interface_Export = new function() { + var _options; + + this.init = init; + this.accept = accept; + this.cancel = cancel; + + /* + * add options to export + */ + function init() { + _options = window.arguments[0].options; + + // add options to dialog + var dialog = document.getElementById("scholar-export-options"); + for(var option in _options) { + var defValue = _options[option]; + + // get readable name for option + try { + var optionLabel = Scholar.getString("exportOptions."+option); + } catch(e) { + var optionLabel = option; + } + + // right now, option interface supports only boolean values, which + // it interprets as checkboxes + Scholar.debug(option+" ("+optionLabel+") = "+defValue+" ("+typeof(defValue)+")"); + if(typeof(defValue) == "boolean") { + var checkbox = document.createElement("checkbox"); + checkbox.setAttribute("id", option); + checkbox.setAttribute("label", optionLabel); + checkbox.setAttribute("checked", (defValue ? "true" : "false")); + dialog.appendChild(checkbox); + } + } + } + + /* + * make option array reflect status + */ + function accept() { + for(var option in _options) { + var defValue = _options[option]; + var element = document.getElementById(option); + + if(typeof(defValue) == "bool") { + if(element.checked == "true") { + _options[option] = true; + } else { + _options[option] = false; + } + } + } + Scholar.debug(_options); + } + + /* + * make option array reflect status + */ + function cancel() { + window.arguments[0].options = false; + } +} \ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/exportOptions.xul b/chrome/chromeFiles/content/scholar/exportOptions.xul new file mode 100644 index 000000000..8d70005de --- /dev/null +++ b/chrome/chromeFiles/content/scholar/exportOptions.xul @@ -0,0 +1,14 @@ + + + + + +