I’m looking at a Chrome addon that does pretty much what I want, and there is some notation that they are using to invoke context menus and prompts.
It invokes a function x (thank you for one letter non-descriptive names) using the following
x(A, "[b]", "[b]{{a}}");
x(A, "[i]", "[i]{{a}}");
x(A, "[url]", "[url]{{a}}");
x(A, "[url=sel]prompt", "[url={{a}}]{{b}}", "Description of the link");
x(A, "[url=prompt]sel", "[url={{b}}]{{a}}", "URL of the link");
There are either 3 or 4 variables, with the 4th variable being a title of a pop up asking for text.
Item 1 is the parent menu, Item 3 is a description, but Item 2 is completely incomprehensible to me as to how it works.
The text is straightforward, but I do not understand how the double curly brace terms parse, though I know that {{a}} is the selected text, and {{b}} is a request for information from a popup.
It seems to me that this notation is clean and elegant, but I don’t get it.
FWIW, here is function x():
function x(d, e, f, k) {
k = q(k);
var s = g({
title: e,
contexts: ["editable"],
parentId: d,
onclick: v
});
b[c(s)] = {
a: f,
b: k,
c: e.replace(/^.*?(?=CTRL)/, "").replace(/CTRL\+/g, ""),
d: c(d)
}
}
And here is the initial variable declaration:
var a = {},
b = {},
c = JSON.stringify,
g = chrome.contextMenus.create,
h = chrome.contextMenus.remove,
l = "title:",
m = "template:",
n = "prompt:";
I am rather confused here.