-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontextMenu.js
More file actions
37 lines (35 loc) · 989 Bytes
/
Copy pathcontextMenu.js
File metadata and controls
37 lines (35 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function() {
var menu = chrome.contextMenus.create({
title: "Wicket Source",
contexts: [ "all" ],
enabled: false,
onclick: function() {}
});
chrome.extension.onRequest.addListener(function (request) {
if (request.hasOwnProperty('wicketsource')) {
var ws = request.wicketsource;
if (ws == null) {
chrome.contextMenus.update(menu, {
enabled: false,
title: "Wicket Source"
});
return;
}
var idx = ws.indexOf(':');
if (idx > -1) {
ws = ws.substring(idx + 1);
}
ws = ws.replace(/\.java:/, ':');
chrome.contextMenus.update(menu, {
enabled: true,
title: "Wicket Source - " + ws,
onclick: function () {
var ajax = new XMLHttpRequest();
var url = "http://localhost:9123/open?src=" + encodeURIComponent(request.wicketsource);
ajax.open("GET", url, true);
ajax.send();
}
});
}
});
})();