Skip to content

Commit

Permalink
Merge pull request #9 from mi-yo/revert-8-feature/tb68
Browse files Browse the repository at this point in the history
Revert "Feature/tb68"
  • Loading branch information
mi-yo authored Apr 15, 2020
2 parents e2f92ac + f76a762 commit 9e4caf2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 79 deletions.
3 changes: 1 addition & 2 deletions content/prefutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ if("undefined" == typeof(SubjectCleanerPrefUtil)){
},
getDefaultRemovalList : function(){
try{
return JSON.parse("[{\"removalString\":\"\\\\[\\\\w+:\\\\d+\\\\](\\\\s|)\",\"caseSensitive\":false,\"regexp\":true},{\"removalString\":\"\\\\sRe:+\",\"caseSensitive\":false,\"regexp\":true}]");
//return JSON.parse(SubjectCleanerPrefUtil.PREF_DEFAULT.getComplexValue(SubjectCleanerPrefUtil.PREF_KEY_REMOVALLIST, SubjectCleanerPrefUtil.getInterfaceComplexValueAtype()).data);
return JSON.parse(SubjectCleanerPrefUtil.PREF_DEFAULT.getComplexValue(SubjectCleanerPrefUtil.PREF_KEY_REMOVALLIST, SubjectCleanerPrefUtil.getInterfaceComplexValueAtype()).data);
}catch(e){
console.log(e);
return new Array();
Expand Down
65 changes: 18 additions & 47 deletions content/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ if("undefined" == typeof(SubjectCleanerSetting)){
document.getElementById("test").addEventListener("command", SubjectCleanerSetting.test, true);
document.getElementById("default").addEventListener("command", SubjectCleanerSetting.default, true);
document.getElementById("autoRemove").addEventListener("CheckboxStateChange", SubjectCleanerSetting.setAutoFocusStatus, true);

document.addEventListener("dialogaccept", function(event) {
let ret = SubjectCleanerSetting.doOK();
if (ret == -1) { //onAccept()がエラーを返したときに、ダイアログを閉じない場合
event.preventDefault();
}
});
document.addEventListener("dialogcancel", function(event) {
let ret = SubjectCleanerSetting.doCancel();
if (ret == -1) { //onAccept()がエラーを返したときに、ダイアログを閉じない場合
event.preventDefault();
}
});

SubjectCleanerSetting.fill(
SubjectCleanerPrefUtil.getRemovalList(),
Expand All @@ -35,48 +22,34 @@ if("undefined" == typeof(SubjectCleanerSetting)){
},

setSelectedItem : function(item){
var removalList = document.getElementById("removalList");

SubjectCleanerSetting.selectedItem = removalList.selectedItem;//item;
SubjectCleanerSetting.selectedItem = item;
},

getRemovalList : function(){
var removalList = new Array();
var nodes = document.getElementById("removalList").childNodes;


for(var i=0; i<nodes.length; i++){
if(nodes[i].nodeName === "richlistitem"){
var listCells = nodes[i].children
if(nodes[i].nodeName === "listitem"){
var listCells = nodes[i].childNodes;
var removal = {};
removal.removalString = listCells[0].value;
removal.caseSensitive = listCells[1].getAttribute("checked");
removal.regexp = listCells[2].getAttribute("checked");
removal.removalString = listCells[0].getAttribute("label");
removal.caseSensitive = JSON.parse(listCells[1].getAttribute("checked"));
removal.regexp = JSON.parse(listCells[2].getAttribute("checked"));
removalList.push(removal);
}
}
return removalList;
},

createListItem : function(removalString, caseSensitive, regexp){
var listItem = document.createElement("richlistitem");
var listItem = document.createElement("listitem");
listItem.setAttribute("class", "subjectcleaner-setting-listitem");
listItem.setAttribute("id", Math.random());

let newLabel = document.createElement("label");
newLabel.value = removalString;
newLabel.setAttribute("width", 200);
listItem.appendChild(newLabel);

let casesensitiveCheckbox = document.createElement("checkbox");
casesensitiveCheckbox.setAttribute("checked", caseSensitive);
casesensitiveCheckbox.setAttribute("width", 60);
listItem.appendChild(casesensitiveCheckbox);

let regexpCheckbox = document.createElement("checkbox");
regexpCheckbox.setAttribute("width", 60);
regexpCheckbox.setAttribute("checked", regexp);
listItem.appendChild(regexpCheckbox);
SubjectCleanerSetting.createListCell(listItem, {"label":removalString});
var checkboxClass = "subjectcleaner-setting-checkbox";
SubjectCleanerSetting.createListCell(listItem, {"class":checkboxClass, "type":"checkbox", "checked":caseSensitive});
SubjectCleanerSetting.createListCell(listItem, {"class":checkboxClass, "type":"checkbox", "checked":regexp});

return listItem;
},
Expand All @@ -100,7 +73,6 @@ if("undefined" == typeof(SubjectCleanerSetting)){

if(addDialogDto.confirmOK){
if(addDialogDto.removal.removalString.length > 0){

var removalList = document.getElementById("removalList");
var listItem = SubjectCleanerSetting.createListItem(
addDialogDto.removal.removalString,
Expand All @@ -115,18 +87,18 @@ if("undefined" == typeof(SubjectCleanerSetting)){
},

edit : function(event){
var listCells = SubjectCleanerSetting.selectedItem.children;
var listCells = SubjectCleanerSetting.selectedItem.childNodes;
var removal = {};
removal.removalString = SubjectCleanerSetting.selectedItem.children[0].value;
removal.caseSensitive = JSON.parse(SubjectCleanerSetting.selectedItem.children[1].checked);
removal.regexp = JSON.parse(SubjectCleanerSetting.selectedItem.children[2].checked);
removal.removalString = listCells[0].getAttribute("label");
removal.caseSensitive = JSON.parse(listCells[1].getAttribute("checked"));
removal.regexp = JSON.parse(listCells[2].getAttribute("checked"));
var addDialogDto = new SubjectCleanerSetting.AddDialogDto(removal);
window.openDialog("chrome://subjectcleaner/content/settingadd.xul",
"SubjectCleanerSettingDialog", "chrome,modal,titlebar,centerscreen", addDialogDto);

if(addDialogDto.confirmOK){
if(addDialogDto.removal.removalString.length > 0){
listCells[0].setAttribute("value", addDialogDto.removal.removalString);
listCells[0].setAttribute("label", addDialogDto.removal.removalString);
listCells[1].setAttribute("checked", addDialogDto.removal.caseSensitive);
listCells[2].setAttribute("checked", addDialogDto.removal.regexp);
}
Expand All @@ -138,7 +110,7 @@ if("undefined" == typeof(SubjectCleanerSetting)){
var removeIndex = removalList.selectedIndex;
var nextSelectedIndex = (removeIndex > 0) ? removeIndex - 1 : 0;
removalList.scrollToIndex(nextSelectedIndex);
removalList.getItemAtIndex(removeIndex).remove();
removalList.removeItemAt(removeIndex);
removalList.selectedIndex = nextSelectedIndex;
},

Expand All @@ -162,12 +134,11 @@ if("undefined" == typeof(SubjectCleanerSetting)){
},

fill : function(removalList, autoRemove, autoFocus){

var viewRemovalList = document.getElementById("removalList");
if(removalList !== null && removalList.length !== 0){
var itemCount = viewRemovalList.itemCount;
for(var i=itemCount-1; i>=0; i--){
viewRemovalList.getItemAtIndex(i).remove();
viewRemovalList.removeItemAt(i);
}

for(var i=0; i<removalList.length; i++){
Expand Down
21 changes: 14 additions & 7 deletions content/setting.xul
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@
<tabpanel>
<vbox>
<hbox>
<richlistbox id="removalList" width="350" height="146" rows="4" flex="1" onselect="SubjectCleanerSetting.setSelectedItem(this.selectedItem);">
<listheader>
<treecol style="font-weight:bold;" label="&setting.removallist.removalstring;" width="200" flex="1" />
<treecol style="font-weight:bold;" label="&setting.removallist.casesensitive;" width="60" flex="1" />
<treecol style="font-weight:bold;" label="&setting.removallist.regexp;" width="60" flex="1" />
</listheader>
</richlistbox>
<listbox id="removalList" width="500" height="146" onselect="SubjectCleanerSetting.setSelectedItem(this.selectedItem);">
<listhead>
<listheader label="&setting.removallist.removalstring;"/>
<listheader label="&setting.removallist.casesensitive;"/>
<listheader label="&setting.removallist.regexp;"/>
<listheader/>
</listhead>
<listcols>
<listcol flex="1"/>
<listcol/>
<listcol/>
<listcol/>
</listcols>
</listbox>
<vbox>
<button id="add" label="&setting.removallist.button.add;"/>
<button id="edit" label="&setting.removallist.button.edit;"/>
Expand Down
21 changes: 0 additions & 21 deletions content/settingadd.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
function log(aText){
var console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
console.logStringMessage(aText);
}

if("undefined" == typeof(SubjectCleanerSettingAdd)){
var SubjectCleanerSettingAdd = {
addDialogDto : null,

startup : function(){
log("startup");
SubjectCleanerSettingAdd.addDialogDto = window.arguments[0];
document.getElementById("removalString").value = SubjectCleanerSettingAdd.addDialogDto.removal.removalString;
document.getElementById("caseSensitive").checked = SubjectCleanerSettingAdd.addDialogDto.removal.caseSensitive;
document.getElementById("regexp").checked = SubjectCleanerSettingAdd.addDialogDto.removal.regexp;

document.addEventListener("dialogaccept", function(event) {
let ret = SubjectCleanerSettingAdd.doOK();
if (ret == -1) { //onAccept()がエラーを返したときに、ダイアログを閉じない場合
event.preventDefault();
}
});
document.addEventListener("dialogcancel", function(event) {
let ret = SubjectCleanerSettingAdd.doCancel();
if (ret == -1) { //onAccept()がエラーを返したときに、ダイアログを閉じない場合
event.preventDefault();
}
});
},

doOK : function(){
log("doOK");
try{
var removal = {};
removal.removalString = document.getElementById("removalString").value;
Expand All @@ -45,7 +25,6 @@ if("undefined" == typeof(SubjectCleanerSettingAdd)){
},

doCancel : function(){
log("doCancel");
SubjectCleanerSettingAdd.addDialogDto.confirmOK = false;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<em:targetApplication>
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>68.*</em:minVersion>
<em:maxVersion>68.*</em:maxVersion>
<em:minVersion>3.1</em:minVersion>
<em:maxVersion>60.*</em:maxVersion>
</Description>
</em:targetApplication>
<em:optionsURL>chrome://subjectcleaner/content/setting.xul</em:optionsURL>
Expand Down

0 comments on commit 9e4caf2

Please sign in to comment.