Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from mikehardy/eslint
Browse files Browse the repository at this point in the history
Eslint work
  • Loading branch information
mikehardy authored Nov 9, 2018
2 parents 1af14c8 + 323d63a commit eee3040
Show file tree
Hide file tree
Showing 10 changed files with 2,089 additions and 444 deletions.
32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"extends": [
"airbnb-base"
],
"globals": {
"Components": false,
"document": false,
"fixIterator": false,
"gDBView": false,
"GlodaUtils": false,
"MailServices": false,
"MailUtils": false,
"window": false,
"XPCOMUtils": false
},
"rules": {
"camelcase": 0,
"prefer-template": 0,
"no-console": 0,
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"no-param-reassign": ["error", { "props": true, "ignorePropertyModificationsFor": ["aCommandLine", "count"] }],
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"no-unused-vars": ["error", {
"varsIgnorePattern": "NSGetFactory|MAPI_STARTUP_ARG",
"argsIgnorePattern": "[iI]gnored"
}],
"no-var": 0,
"object-shorthand": 0,
"quotes": 0,
"vars-on-top": 0
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.swp
*.swo
*.xpi
node_modules
.vscode
2 changes: 0 additions & 2 deletions chrome.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ overlay chrome://messenger/content/mailWindowOverlay.xul chrome://thunderlink/co
component {547bfe26-688b-4e63-a1da-07da0e8367e1} components/thunderlinkCommandLineHandler.js
contract @mozilla.org/commandlinehandler/general-startup;1?type=thunderlink {547bfe26-688b-4e63-a1da-07da0e8367e1}
category command-line-handler ThunderLink @mozilla.org/commandlinehandler/general-startup;1?type=thunderlink


262 changes: 128 additions & 134 deletions chrome/thunderlink/content/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,143 +6,137 @@
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

var ThunderLinkPrefNS = {


CreateCustomStringTabbox: function() {

Components.utils.import("resource:///modules/mailServices.js");
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

function createCstrTabPanel(cstrnum) {
var tabpanel = window.document.createElementNS(XUL_NS, "tabpanel");
var vbox = window.document.createElementNS(XUL_NS, "vbox");
vbox.setAttribute("align", "left");
tabpanel.appendChild(vbox);

var tTextbox = window.document.createElementNS(XUL_NS, "textbox");
tTextbox.setAttribute("id", "prefCustomTlString" + cstrnum + "-title");
tTextbox.setAttribute("preference", "prefs_customTlString" + cstrnum + "title");
tTextbox.setAttribute("size", 51);
var tLabel = window.document.createElementNS(XUL_NS, "label");
tLabel.setAttribute("label", "Custom String title:");
tLabel.setAttribute("control", tTextbox.id);
vbox.appendChild(tLabel);
vbox.appendChild(tTextbox);

var csTextbox = window.document.createElementNS(XUL_NS, "textbox");
csTextbox.setAttribute("id", "prefCustomTlString" + cstrnum + "-textbox");
csTextbox.setAttribute("preference", "prefs_customTlString" + cstrnum);
csTextbox.setAttribute("multiline", "true");
csTextbox.setAttribute("cols", "50");
csTextbox.setAttribute("rows", "5");
var csLabel = window.document.createElementNS(XUL_NS, "label");
csLabel.setAttribute("label", "Custom String:");
csLabel.setAttribute("control", csTextbox.id);
vbox.appendChild(csLabel);
vbox.appendChild(csTextbox);

var tagCheckbox = window.document.createElementNS(XUL_NS, "checkbox");
tagCheckbox.setAttribute("id", "prefCustomTlString" + cstrnum + "-tagcheckbox");
tagCheckbox.setAttribute("checked", "false");
tagCheckbox.setAttribute("preference", "prefs_customTlString" + cstrnum + "tagcheckbox");
tagCheckbox.setAttribute("label", "Tag email upon copying the ThunderLink:");
tagCheckbox.setAttribute("oncommand", "ThunderLinkPrefNS.ToggleTlTagField("+cstrnum+");");
vbox.appendChild(tagCheckbox);

var tagLabel = window.document.createElementNS(XUL_NS, "label");
tagLabel.setAttribute("control", "prefCustomTlString" + cstrnum + "-tag");
tagLabel.setAttribute("value", "using tag:");

function appendMenuItems(menuPopup){

let tagArray = MailServices.tags.getAllTags({});
for (var j = 0; j < tagArray.length; ++j)
{
var menuItem = window.document.createElementNS(XUL_NS, "menuitem");

menuItem.setAttribute("label", tagArray[j].tag);
menuItem.setAttribute("value", j+1);
menuPopup.appendChild(menuItem);
}
}
var menuList = window.document.createElementNS(XUL_NS, "menulist");
menuList.setAttribute("id", "prefCustomTlString" + cstrnum + "-tag");
var menuPopup = window.document.createElementNS(XUL_NS, "menupopup");
menuList.setAttribute("preference", "prefs_customTlString" + cstrnum + "tag");
menuList.setAttribute("disabled", !ThunderLinkPrefNS.GetPreferenceValue("custom-tl-string-"+cstrnum+"-tagcheckbox", "bool"));
appendMenuItems(menuPopup);
menuList.appendChild(menuPopup);

var labelbox = window.document.createElementNS(XUL_NS, "hbox");
labelbox.appendChild(tagLabel);
labelbox.appendChild(menuList);
vbox.appendChild(labelbox);

var keyLabel = window.document.createElementNS(XUL_NS, "label");
keyLabel.setAttribute("value", "Shortcut: CTRL + ALT + " + cstrnum);
vbox.appendChild(keyLabel);

return tabpanel;
CreateCustomStringTabbox: () => {
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
Components.utils.import("resource:///modules/mailServices.js");
function createCstrTabPanel(cstrnum) {
var tabpanel = window.document.createElementNS(XUL_NS, "tabpanel");
var vbox = window.document.createElementNS(XUL_NS, "vbox");
vbox.setAttribute("align", "left");
tabpanel.appendChild(vbox);

var tTextbox = window.document.createElementNS(XUL_NS, "textbox");
tTextbox.setAttribute("id", "prefCustomTlString" + cstrnum + "-title");
tTextbox.setAttribute("preference", "prefs_customTlString" + cstrnum + "title");
tTextbox.setAttribute("size", 51);
var tLabel = window.document.createElementNS(XUL_NS, "label");
tLabel.setAttribute("label", "Custom String title:");
tLabel.setAttribute("control", tTextbox.id);
vbox.appendChild(tLabel);
vbox.appendChild(tTextbox);

var csTextbox = window.document.createElementNS(XUL_NS, "textbox");
csTextbox.setAttribute("id", "prefCustomTlString" + cstrnum + "-textbox");
csTextbox.setAttribute("preference", "prefs_customTlString" + cstrnum);
csTextbox.setAttribute("multiline", "true");
csTextbox.setAttribute("cols", "50");
csTextbox.setAttribute("rows", "5");
var csLabel = window.document.createElementNS(XUL_NS, "label");
csLabel.setAttribute("label", "Custom String:");
csLabel.setAttribute("control", csTextbox.id);
vbox.appendChild(csLabel);
vbox.appendChild(csTextbox);

var tagCheckbox = window.document.createElementNS(XUL_NS, "checkbox");
tagCheckbox.setAttribute("id", "prefCustomTlString" + cstrnum + "-tagcheckbox");
tagCheckbox.setAttribute("checked", "false");
tagCheckbox.setAttribute("preference", "prefs_customTlString" + cstrnum + "tagcheckbox");
tagCheckbox.setAttribute("label", "Tag email upon copying the ThunderLink:");
tagCheckbox.setAttribute("oncommand", "ThunderLinkPrefNS.ToggleTlTagField(" + cstrnum + ");");
vbox.appendChild(tagCheckbox);

var tagLabel = window.document.createElementNS(XUL_NS, "label");
tagLabel.setAttribute("control", "prefCustomTlString" + cstrnum + "-tag");
tagLabel.setAttribute("value", "using tag:");

function appendMenuItems(menuPopup) {
var tagArray = MailServices.tags.getAllTags({});
for (let j = 0; j < tagArray.length; ++j) {
var menuItem = window.document.createElementNS(XUL_NS, "menuitem");

menuItem.setAttribute("label", tagArray[j].tag);
menuItem.setAttribute("value", j + 1);
menuPopup.appendChild(menuItem);
}


function createCstrTab(cstrnum) {
var tab = window.document.createElementNS(XUL_NS, "tab");
tab.setAttribute("label", "String " + cstrnum);
return tab;
}


var tabbox = window.document.getElementById("thunderlink-custom-strings-tabbox");
if (tabbox.hasChildNodes()){
while (tabbox.firstChild) {
tabbox.removeChild(tabbox.firstChild);
}
}

var tabs = window.document.createElementNS(XUL_NS, "tabs");
var tabpanels = window.document.createElementNS(XUL_NS, "tabpanels");

var nrOfCStrings = 8
for (let i = 1; i <= nrOfCStrings; i++){
tabs.appendChild(createCstrTab(i));
tabpanels.appendChild(createCstrTabPanel(i));
}
tabbox.appendChild(tabs);
tabbox.appendChild(tabpanels);
},

ToggleTlTagField: function(cstrnum) {
function $(aID) { return document.getElementById(aID); }
tlTagCheckbox = $("prefCustomTlString" + cstrnum + "-tagcheckbox")
tlTagField = $("prefCustomTlString" + cstrnum + "-tag")
if (tlTagCheckbox.checked) {
tlTagField.disabled = false;
}
else {
tlTagField.disabled = true;
}
},

GetPreferenceValue: function(prefname, type){
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("extensions.thunderlink.");
prefService.QueryInterface(Components.interfaces.nsIPrefBranch2);

result = prefService.getBoolPref(prefname);
return result;
},

LOG: function(msg) {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(msg);
},


}
}
var menuList = window.document.createElementNS(XUL_NS, "menulist");
menuList.setAttribute("id", "prefCustomTlString" + cstrnum + "-tag");
var menuPopup = window.document.createElementNS(XUL_NS, "menupopup");
menuList.setAttribute("preference", "prefs_customTlString" + cstrnum + "tag");
menuList.setAttribute("disabled", !ThunderLinkPrefNS.GetPreferenceValue("custom-tl-string-" + cstrnum + "-tagcheckbox", "bool"));
appendMenuItems(menuPopup);
menuList.appendChild(menuPopup);

var labelbox = window.document.createElementNS(XUL_NS, "hbox");
labelbox.appendChild(tagLabel);
labelbox.appendChild(menuList);
vbox.appendChild(labelbox);

var keyLabel = window.document.createElementNS(XUL_NS, "label");
keyLabel.setAttribute("value", "Shortcut: CTRL + ALT + " + cstrnum);
vbox.appendChild(keyLabel);

return tabpanel;
}


function createCstrTab(cstrnum) {
var tab = window.document.createElementNS(XUL_NS, "tab");
tab.setAttribute("label", "String " + cstrnum);
return tab;
}


var tabbox = window.document.getElementById("thunderlink-custom-strings-tabbox");
if (tabbox.hasChildNodes()) {
while (tabbox.firstChild) {
tabbox.removeChild(tabbox.firstChild);
}
}

var tabs = window.document.createElementNS(XUL_NS, "tabs");
var tabpanels = window.document.createElementNS(XUL_NS, "tabpanels");

var nrOfCStrings = 8;
for (let i = 1; i <= nrOfCStrings; i++) {
tabs.appendChild(createCstrTab(i));
tabpanels.appendChild(createCstrTabPanel(i));
}
tabbox.appendChild(tabs);
tabbox.appendChild(tabpanels);
},

ToggleTlTagField: (cstrnum) => {
function $(aID) { return document.getElementById(aID); }
var tlTagCheckbox = $("prefCustomTlString" + cstrnum + "-tagcheckbox");
var tlTagField = $("prefCustomTlString" + cstrnum + "-tag");
if (tlTagCheckbox.checked) {
tlTagField.disabled = false;
} else {
tlTagField.disabled = true;
}
},

GetPreferenceValue: (prefname, argIgnored) => {
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("extensions.thunderlink.");
prefService.QueryInterface(Components.interfaces.nsIPrefBranch2);

return prefService.getBoolPref(prefname);
},

LOG: (msg) => {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(msg);
},


};
Loading

0 comments on commit eee3040

Please sign in to comment.