-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mi-yo/feature/tb68
Feature/tb68
- Loading branch information
Showing
10 changed files
with
395 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!bin/sh | ||
#!/bin/sh | ||
|
||
VERSION=`grep em:version install.rdf | tr -d "[:space:]<em:version>/"` | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<tree.treeBody.children.length; i++){ | ||
let removal = {}; | ||
removal.removalString = tree.view.getCellText(i, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_REMOVAL_STRING)); | ||
removal.caseSensitive = tree.view.getCellValue(i, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_CASE_SENSITIVE)); | ||
removal.regexp = tree.view.getCellValue(i, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_REGULAR_EXPRESSION)); | ||
removalList.push(removal); | ||
} | ||
return removalList; | ||
}, | ||
|
||
createTreeItem : function(removalString, caseSensitive, regexp){ | ||
let createTreeElement = function(name){ | ||
let treeElement = document.createElement(name); | ||
treeElement.setAttribute("id", Math.random()); | ||
return treeElement; | ||
} | ||
let createTreeCell = function(attrs){ | ||
let treeCell = createTreeElement("treecell"); | ||
for(let key in attrs) { | ||
treeCell.setAttribute(key, attrs[key]); | ||
} | ||
return treeCell; | ||
}; | ||
|
||
let treeRow = createTreeElement("treerow"); | ||
treeRow.appendChild(createTreeCell({"label":"", "editable":"false"})); | ||
treeRow.appendChild(createTreeCell({"label":removalString, "properties":"inputtext"})); | ||
treeRow.appendChild(createTreeCell({"value":caseSensitive})); | ||
treeRow.appendChild(createTreeCell({"value":regexp})); | ||
treeRow.appendChild(createTreeCell({"value":"true", "editable":"false", "properties":"delete"})); | ||
let treeItem = createTreeElement("treeitem"); | ||
treeItem.appendChild(treeRow); | ||
|
||
return treeItem; | ||
}, | ||
|
||
addTreeItem : function(tree, row, _removalString, _caseSensitive, _regexp){ | ||
let removalString = _removalString || ""; | ||
let caseSensitive = _caseSensitive || false; | ||
let regexp = _regexp || false; | ||
|
||
let newTreeItem = SubjectCleanerOptions.createTreeItem(removalString, caseSensitive, regexp); | ||
tree.treeBody.appendChild(newTreeItem); | ||
SubjectCleanerOptions.resfreshNo(tree); | ||
}, | ||
|
||
deleteTreeItem : function(tree, row){ | ||
tree.treeBody.removeChild(tree.treeBody.children[row]) | ||
SubjectCleanerOptions.resfreshNo(tree) | ||
}, | ||
|
||
resfreshNo : function(tree){ | ||
for(let i=0; i<tree.treeBody.children.length; i++){ | ||
tree.view.setCellText(i, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_NO), i + 1); | ||
} | ||
}, | ||
|
||
add : function(event){ | ||
let tree = SubjectCleanerOptions.getRemovalListTree(); | ||
let row = tree.view.rowCount; | ||
SubjectCleanerOptions.addTreeItem(tree, row); | ||
tree.startEditing(row, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_REMOVAL_STRING)); | ||
}, | ||
|
||
test : function(event){ | ||
let testBox = document.getElementById("testBox"); | ||
let testBoxResult = document.getElementById("testBoxResult"); | ||
|
||
let testValue = testBox.value; | ||
if(testBox.value === null || testBox.value.length === 0){ | ||
testValue = testBox.placeholder; | ||
} | ||
let cleanResult = SubjectCleanerClean.clean(testValue, SubjectCleanerOptions.getCurrentRemovalList()); | ||
if(testBoxResult.value !== cleanResult){ | ||
testBoxResult.value = cleanResult; | ||
} | ||
}, | ||
|
||
fill : function(removalList, autoRemove, autoFocus){ | ||
let tree = SubjectCleanerOptions.getRemovalListTree(); | ||
if(removalList !== null && removalList.length !== 0){ | ||
// clear current | ||
for(let i=tree.view.rowCount-1; i>=0; i--){ | ||
SubjectCleanerOptions.deleteTreeItem(tree, i); | ||
} | ||
|
||
for(let i=0; i<removalList.length; i++){ | ||
SubjectCleanerOptions.addTreeItem(tree, i, removalList[i].removalString, removalList[i].caseSensitive, removalList[i].regexp); | ||
} | ||
tree.view.selection.clearSelection(); | ||
} | ||
|
||
document.getElementById("autoRemove").checked = autoRemove; | ||
document.getElementById("autoFocus").checked = autoFocus; | ||
SubjectCleanerOptions.setAutoFocusStatus(); | ||
}, | ||
|
||
setAutoFocusStatus : function(){ | ||
document.getElementById("autoFocus").setAttribute("disabled", !document.getElementById("autoRemove").checked); | ||
}, | ||
|
||
default : function(event){ | ||
SubjectCleanerOptions.fill( | ||
SubjectCleanerPrefUtil.getDefaultRemovalList(), | ||
SubjectCleanerPrefUtil.isDefaultAutoRemove(), | ||
SubjectCleanerPrefUtil.isDefaultAutoFocus()); | ||
}, | ||
|
||
apply : function(){ | ||
SubjectCleanerPrefUtil.setRemovalList(SubjectCleanerOptions.getCurrentRemovalList()); | ||
|
||
let autoRemove = document.getElementById("autoRemove").checked || false; | ||
SubjectCleanerPrefUtil.setAutoRemove(autoRemove); | ||
|
||
let autoFocus = false; | ||
if(autoRemove){ | ||
autoFocus = document.getElementById("autoFocus").checked || false; | ||
} | ||
SubjectCleanerPrefUtil.setAutoFocus(autoFocus); | ||
|
||
return true; | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0"?> | ||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> | ||
<?xml-stylesheet href="chrome://global/skin/in-content/common.css" type="text/css"?> | ||
<?xml-stylesheet href="chrome://subjectcleaner/content/options.css" type="text/css"?> | ||
<!DOCTYPE window SYSTEM "chrome://subjectcleaner/locale/subjectcleaner.dtd"> | ||
|
||
<html id="options" title="&setting.title;" | ||
xmlns:html="http://www.w3.org/1999/xhtml" | ||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" | ||
onload="SubjectCleanerOptions.startup()"> | ||
|
||
<script type="application/x-javascript" src="chrome://global/content/nsUserSettings.js"/> | ||
<script type="application/x-javascript" src="chrome://subjectcleaner/content/prefutil.js"/> | ||
<script type="application/x-javascript" src="chrome://subjectcleaner/content/clean.js"/> | ||
<script type="application/x-javascript" src="chrome://subjectcleaner/content/options.js"/> | ||
|
||
<vbox> | ||
<label class="header" value="&setting.title;"/> | ||
|
||
<label class="indent group" value="&setting.tab.setting;"/> | ||
<hbox class="indent"> | ||
<tree id="removalListTree" seltype="single" editable="true"> | ||
<treecols mousethrough="always"> | ||
<treecol class="right" type="text" editable="false" label="No."/> | ||
<treecol type="text" editable="true" label="&setting.removallist.removalstring;" flex="1"/> | ||
<treecol type="checkbox" editable="true" label="&setting.removallist.casesensitive;"/> | ||
<treecol type="checkbox" editable="true" label="&setting.removallist.regexp;"/> | ||
<treecol class="noheader" type="checkbox" editable="false" label="delete" ignoreincolumnpicker="true"/> | ||
</treecols> | ||
<treechildren/> | ||
</tree> | ||
<spacer flex="1"/> | ||
<vbox> | ||
<button id="add" label="&setting.removallist.button.add;"/> | ||
</vbox> | ||
</hbox> | ||
<separator class="thin"/> | ||
<vbox class="indent"> | ||
<hbox> | ||
<checkbox id="autoRemove" label="&setting.checkbox.autoremove;"/> | ||
<spacer flex="1"/> | ||
</hbox> | ||
<hbox> | ||
<checkbox id="autoFocus" label="&setting.checkbox.autofocus;"/> | ||
<spacer flex="1"/> | ||
</hbox> | ||
</vbox> | ||
|
||
<separator class="groove-thin"/> | ||
|
||
<label class="indent group" value="&setting.tab.test;"/> | ||
<vbox class="indent"> | ||
<hbox> | ||
<textbox id="testBox" class="testbox" placeholder="Re: [ml:0002] Re: [ml:0001] meeting"/> | ||
<spacer flex="1"/> | ||
<button id="test" label="&setting.test.button.execute;"/> | ||
</hbox> | ||
<hbox> | ||
<textbox id="testBoxResult" class="testbox result" disabled="true"/> | ||
<spacer flex="1"/> | ||
</hbox> | ||
</vbox> | ||
|
||
<separator class="groove-thin"/> | ||
|
||
<hbox align="right"> | ||
<button id="default" label="&setting.default;"/> | ||
<button id="apply" label="&setting.apply;"/> | ||
</hbox> | ||
</vbox> | ||
|
||
</html> |
Oops, something went wrong.