diff --git a/build.sh b/build.sh index 81a9cfa..48ceef1 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!bin/sh +#!/bin/sh -VERSION=`grep em:version install.rdf | tr -d "[:space:]/"` -zip -r subject_cleaner-$VERSION-tb.xpi content defaults locale chrome.manifest install.rdf +VERSION=`grep '"version":' manifest.json | tr -d '[:space:],:"version'` +zip -r subject_cleaner-$VERSION-tb.xpi content defaults locale chrome.manifest install.rdf manifest.json diff --git a/content/options.css b/content/options.css new file mode 100644 index 0000000..ae73619 --- /dev/null +++ b/content/options.css @@ -0,0 +1,72 @@ +html { + background-color: #f9f9fa; +} + +label.header { + margin: 15px; +} + +label.group { + font-weight: bold; +} + +tree { + width: 800px; + height: 204px; +} + +treecol { + color: #000 !important; + border-inline-start-style: none !important; +} + +treecol.right { + text-align: right; +} + +treecol.noheader label { + opacity: 0; +} + +treechildren::-moz-tree-row { + background-color: #fff; +} + +treechildren::-moz-tree-cell { + padding: 0px 10px; +} + +treechildren::-moz-tree-cell-text { + color: #000; +} + +treechildren::-moz-tree-cell-text(inputtext,hover) { + margin-top: 2px; + border-bottom: 2px solid #2292d0; +} + +treechildren::-moz-tree-checkbox(checked) { + list-style-image: url("chrome://global/skin/icons/check.svg"); + -moz-context-properties: fill, stroke; + fill: #2292d0; +} + +treechildren::-moz-tree-checkbox(checked,delete) { + list-style-image: url("chrome://messenger/skin/icons/delete.svg"); + -moz-context-properties: fill, stroke; + fill: #2292d0; +} + +checkbox { + margin: 2px 5px !important; +} + +textbox.testbox { + width: 800px; + margin: 5px; +} + +textbox.testbox.result { + color: #2292d0 !important; + opacity: 1; +} diff --git a/content/options.js b/content/options.js new file mode 100644 index 0000000..f58bdd2 --- /dev/null +++ b/content/options.js @@ -0,0 +1,209 @@ +if("undefined" == typeof(SubjectCleanerOptions)){ + var SubjectCleanerOptions = { + COLINDEX_NO : 0, + COLINDEX_REMOVAL_STRING : 1, + COLINDEX_CASE_SENSITIVE : 2, + COLINDEX_REGULAR_EXPRESSION : 3, + COLINDEX_DELETE : 4, + + getRemovalListTree : function(){ + return document.getElementById("removalListTree"); + }, + + startup : function(){ + let tree = SubjectCleanerOptions.getRemovalListTree(); + tree.isEditing = function(){ + return this.editingRow !== -1 && this.editingColumn !== null; + } + // ignore empty removal string + tree.view.setCellText = (function(row, col, value){ + let context = tree.view; + let baseFunc = tree.view.setCellText; + return function(row, col, value){ + // for Escape key at new treeItem + if(tree.view.rowCount <= row){ + return; + } + if(value === ""){ + let prevValue = context.getCellText(row, col); + if(prevValue === ""){ + SubjectCleanerOptions.deleteTreeItem(tree, row); + } + }else{ + baseFunc.call(context, row, col, value); + tree.view.selection.select(row); + } + }; + })(); + + tree.addEventListener("click", SubjectCleanerOptions.treeClick, true); + tree.addEventListener("keydown", SubjectCleanerOptions.treeKeyDown, true); + + document.getElementById("add").addEventListener("command", SubjectCleanerOptions.add, true); + document.getElementById("autoRemove").addEventListener("CheckboxStateChange", SubjectCleanerOptions.setAutoFocusStatus, true); + document.getElementById("test").addEventListener("command", SubjectCleanerOptions.test, true); + document.getElementById("default").addEventListener("command", SubjectCleanerOptions.default, true); + document.getElementById("apply").addEventListener("command", SubjectCleanerOptions.apply, true); + + SubjectCleanerOptions.fill( + SubjectCleanerPrefUtil.getRemovalList(), + SubjectCleanerPrefUtil.isAutoRemove(), + SubjectCleanerPrefUtil.isAutoFocus()); + }, + + treeClick : function(event){ + if(event.target.localName === "treechildren"){ + let tree = SubjectCleanerOptions.getRemovalListTree(); + let treeCellInfo = tree.getCellAt(event.clientX, event.clientY); + if(treeCellInfo.row >= 0){ + switch(treeCellInfo.col.index){ + case SubjectCleanerOptions.COLINDEX_REMOVAL_STRING: + tree.startEditing(treeCellInfo.row, treeCellInfo.col); + break; + case SubjectCleanerOptions.COLINDEX_DELETE: + SubjectCleanerOptions.deleteTreeItem(tree, treeCellInfo.row); + break; + default: + break; + } + } + } + }, + + treeKeyDown : function(event){ + // ignore empty removal string when Escape key down + if(event.key === "Escape"){ + let tree = SubjectCleanerOptions.getRemovalListTree(); + if(tree.isEditing() && tree.view.getCellText(tree.editingRow, tree.editingColumn) === ""){ + SubjectCleanerOptions.deleteTreeItem(tree, tree.editingRow); + } + } + }, + + getCurrentRemovalList : function(){ + let removalList = new Array(); + let tree = SubjectCleanerOptions.getRemovalListTree(); + for(let i=0; i=0; i--){ + SubjectCleanerOptions.deleteTreeItem(tree, i); + } + + for(let i=0; i + + + + + + + +