Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions WicketSourceForChrome/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
chrome.runtime.onMessage.addListener(function(request, sender, callback) {
function getServer() {
if (localStorage["server"]) {
return localStorage["server"];
}
return "localhost";
}
function getPort() {
if (localStorage["port"]) {
return localStorage["port"];
}
return "9123";
}
function getPassword() {
if (localStorage["password"]) {
return localStorage["password"];
}
return "";
}

if (request.method == "getWicketsourceSidebarUrl") {
var url = "sidebar.html?ws=" + encodeURIComponent(request.wicketsourceString)
+ "&wid=" + encodeURIComponent(request.wicketIdString)
+ "&server=" + encodeURIComponent(getServer())
+ "&port=" + encodeURIComponent(getPort())
+ "&p=" + encodeURIComponent(getPassword());
callback(url);
}
else {
callback(null);
}
});
53 changes: 19 additions & 34 deletions WicketSourceForChrome/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@ chrome.devtools.panels.elements.createSidebarPane("WicketSource", function(sideb
function Message() {
this.message = "Select a node with a wicketsource attribute to see details.";
}

function getServer() {
if (localStorage["server"]) {
return localStorage["server"];
}
return "localhost";
}
function getPort() {
if (localStorage["port"]) {
return localStorage["port"];
}
return "9123";
}
function getPassword() {
if (localStorage["password"]) {
return localStorage["password"];
}
return "";
}


// Listener event callback initiates "inspected-page context" data retrieval
// (which understands currently selected node in the Inspect Element tab).
function update() {
Expand All @@ -34,35 +15,39 @@ chrome.devtools.panels.elements.createSidebarPane("WicketSource", function(sideb
}
function wicketIdEval(result, isException)
{
if (!isException) {
this.wicketIdString = result;
} else {
if (isException) {
this.wicketIdString = null;
} else {
this.wicketIdString = result;
}
}
function wicketsourceEval(result, isException)
{
if (!isException) {
this.wicketsourceString = result;
if (isException) {
this.wicketsourceString = null;
} else {
this.wicketsourceString = null;
this.wicketsourceString = result;
}
displaySidebar();
}
function displaySidebar()
{
if (this.wicketsourceString == null) {
var msg = new Message();
var msg = new Message();
sidebar.setObject(msg);
return;
}
sidebar.setPage("sidebar.html?ws=" + encodeURIComponent(this.wicketsourceString)
+ "&wid=" + encodeURIComponent(this.wicketIdString)
+ "&server=" + encodeURIComponent(getServer())
+ "&port=" + encodeURIComponent(getPort())
+ "&p=" + encodeURIComponent(getPassword())
);
}
chrome.runtime.sendMessage(
{
method: "getWicketsourceSidebarUrl",
wicketsourceString: this.wicketsourceString,
wicketIdString: this.wicketIdString
},
function(url) {
sidebar.setPage(url);
}
);
}


// On the way in the first time, show an instructional message.
Expand Down
5 changes: 4 additions & 1 deletion WicketSourceForChrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"description": "Adds a Developer Tools sidebar with Wicket source code location for the selected DOM element.",
"devtools_page": "devtools.html",
"options_page": "options.html",
"icons": {
"background": {
"scripts": ["background.js"]
},
"icons": {
"16": "go_icon.png",
"48": "icon48.png",
"64": "icon64.png",
Expand Down