mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-07 03:27:16 +02:00
Remove obsolete code
This commit is contained in:
@@ -56,15 +56,15 @@ var folderChange = class extends ExtensionCommon.ExtensionAPI {
|
||||
return {
|
||||
// Again, this key must have the same name.
|
||||
folderChange: {
|
||||
setVersion: function (version) {
|
||||
setVersion: async function (version) {
|
||||
SysTrayX.setVersion(version);
|
||||
},
|
||||
|
||||
setCountType: function (type) {
|
||||
setCountType: async function (type) {
|
||||
SysTrayX.setCountType(type);
|
||||
},
|
||||
|
||||
setFilters: function (filters) {
|
||||
setFilters: async function (filters) {
|
||||
SysTrayX.setFilters(filters);
|
||||
},
|
||||
|
||||
|
||||
@@ -1,36 +1,4 @@
|
||||
/* eslint-disable object-shorthand */
|
||||
|
||||
// Get various parts of the WebExtension framework that we need.
|
||||
var { ExtensionCommon } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionCommon.jsm"
|
||||
);
|
||||
|
||||
// You probably already know what this does.
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// ChromeUtils.import() works in experiments for core resource urls as it did
|
||||
// in legacy add-ons. However, chrome:// urls that point to add-on resources no
|
||||
// longer work, as the "chrome.manifest" file is no longer supported, which
|
||||
// defined the root path for each add-on. Instead, ChromeUtils.import() needs
|
||||
// a url generated by
|
||||
//
|
||||
// let url = context.extension.rootURI.resolve("path/to/file.jsm")
|
||||
//
|
||||
// Instead of taking the extension object from the context, you may generate
|
||||
// the extension object from a given add-on ID as shown in the example below.
|
||||
// This allows to import a JSM without context, for example inside another JSM.
|
||||
//
|
||||
var { ExtensionParent } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionParent.jsm"
|
||||
);
|
||||
var extension = ExtensionParent.GlobalManager.getExtension(
|
||||
"systray-x@Ximi1970"
|
||||
);
|
||||
var { windowEvent } = ChromeUtils.import(
|
||||
extension.rootURI.resolve("modules/windowEvent.jsm")
|
||||
);
|
||||
|
||||
// This is the important part. It implements the functions and events defined in schema.json.
|
||||
/// This is the important part. It implements the functions and events defined in schema.json.
|
||||
// The variable must have the same name you've been using so far, "myapi" in this case.
|
||||
var windowEvent = class extends ExtensionCommon.ExtensionAPI {
|
||||
getAPI(context) {
|
||||
@@ -43,7 +11,7 @@ var windowEvent = class extends ExtensionCommon.ExtensionAPI {
|
||||
return {
|
||||
// Again, this key must have the same name.
|
||||
windowEvent: {
|
||||
setCloseType: function (type) {
|
||||
setCloseType: async function (type) {
|
||||
windowListener.setCloseType(type);
|
||||
},
|
||||
|
||||
@@ -136,7 +104,6 @@ var windowListener = new (class extends ExtensionCommon.EventEmitter {
|
||||
windowListener.onCloseButton,
|
||||
true
|
||||
);
|
||||
windowListener.hijackTitlebarCloseButton(window);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -171,58 +138,4 @@ var windowListener = new (class extends ExtensionCommon.EventEmitter {
|
||||
if (event) event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
hijackTitlebarCloseButton(window) {
|
||||
if (
|
||||
windowListener.replaceCommand(window, "titlebar-close", function () {
|
||||
return windowListener.onCloseButton(null);
|
||||
})
|
||||
) {
|
||||
console.log("replaced command= " + "titlebar-close");
|
||||
}
|
||||
}
|
||||
|
||||
replaceCommand(window, eltId, gotHidden) {
|
||||
let elt = window.document.getElementById(eltId);
|
||||
if (!elt) {
|
||||
console.log("Element '" + eltId + "' not found. Command not replaced.");
|
||||
return false;
|
||||
}
|
||||
|
||||
let prevent = null;
|
||||
if (elt.command) {
|
||||
prevent = {
|
||||
event: "click",
|
||||
func: function (e) {
|
||||
e.preventDefault();
|
||||
},
|
||||
};
|
||||
} else if (elt.getAttribute("oncommand")) {
|
||||
prevent = {
|
||||
event: "command",
|
||||
func: function (e) {
|
||||
e.stopPropagation();
|
||||
},
|
||||
};
|
||||
} else {
|
||||
console.warn("Could not replace oncommand on " + eltId);
|
||||
return false;
|
||||
}
|
||||
|
||||
let callback = function (event) {
|
||||
if (event.target.id === eltId) {
|
||||
console.debug(prevent.event + " on " + eltId);
|
||||
if (gotHidden()) prevent.func(event);
|
||||
}
|
||||
};
|
||||
|
||||
/* We put listeners on the "titlebar" parent node, because:
|
||||
- we can hardly short-circuit command/oncommand (probably because they are
|
||||
registered first)
|
||||
- we'd have otherwise to alter "oncommand"/"command" attribute and use
|
||||
Function(), which do not pass review nowadays. */
|
||||
elt.parentNode.addEventListener(prevent.event, callback, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"name": "setVersion",
|
||||
"type": "function",
|
||||
"description": "Set the TB version.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -19,6 +20,7 @@
|
||||
"name": "setCountType",
|
||||
"type": "function",
|
||||
"description": "Set the count type.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -32,6 +34,7 @@
|
||||
"name": "setFilters",
|
||||
"type": "function",
|
||||
"description": "Set the account filters.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"name": "filters",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"name": "setCloseType",
|
||||
"type": "function",
|
||||
"description": "Set the close type.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
|
||||
Reference in New Issue
Block a user