Skip to content

Commit 3977381

Browse files
committed
Merge branch 'refs/heads/v1.3'
2 parents 79b9147 + 01577ba commit 3977381

14 files changed

+543
-449
lines changed

Readme.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,29 @@ XDebug Helper for Google Chrome
22
===============================
33

44
Debugging, profiling and tracing PHP code with [Xdebug](http://xdebug.org/) is very powerful, but enabling
5-
Xdebug by setting a cookie or adding POST/GET variables is unnecessary hard. This extension will
6-
help you to enable/disable the debugging, profiling and tracing features with a single click.
5+
Xdebug with cookies or adding POST/GET variables is way too hard. This extension will help you to enable/disable
6+
debugging, profiling and tracing of your PHP-code easily.
77

88
How to install this extension?
99
------------------------------
10-
The easiest and recommended way is to go to the [Google Chrome Web Store](https://chrome.google.com/webstore/detail/eadndfjplgieldjbigjakmdgkmoaaaoc)
11-
and install the latest stable version from there.
10+
**Stable version:** Go to the [Google Chrome Web Store](https://chrome.google.com/webstore/detail/eadndfjplgieldjbigjakmdgkmoaaaoc)
11+
ans click "Add to Chrome".
1212

13-
Want to get the latest development version? [Download the source from GitHub](https://github.com/wrep/xdebug-helper-for-chrome/zipball/master)
14-
and [load the extension into Chrome](http://developer.chrome.com/extensions/getstarted.html)
13+
**Development version:** [Download the source from GitHub](https://github.com/wrep/xdebug-helper-for-chrome/archive/master.zip)
14+
and [load the extension into Chrome](http://developer.chrome.com/extensions/getstarted.html#unpacked)
1515
yourself!
1616

17-
Why is this on GitHub?
18-
----------------------
19-
We want you to help us make this extension better and we think GitHub will help a lot with
20-
that since you can contribute by submitting issues and pull request.
21-
2217
How do I contribute?
2318
--------------------
24-
There are basicly two options to contribute. First one; Submit an issue or feature request
25-
so we know what we can do to make this extension better. It's easy, just write a clear and
26-
positive issue and we'll look into it! (Can't promise we fix and add everything, but we will
27-
take it into consideration.)
19+
A: [Submit issues and ideas](https://github.com/wrep/xdebug-helper-for-chrome/issues)
20+
21+
B: [Submit a pull request](https://help.github.com/articles/using-pull-requests)
22+
23+
1. Fork this repo and create a branch
24+
2. Commit and push your changes to your branch
25+
3. When you're happy send us a pull request!
2826

29-
Second, if you know how to code Chrome Extension fix an issue or enchantment yourself by
30-
forking our code and submitting a pull request. Please keep pull requests small and make sure
31-
you're working on top of the most recent code. We'll love to work with you on this project
32-
so don't hesitate to submit a pull request!
27+
Pro-tip: Make sure to build upon the latest version of the code and keep pull request as small as possible. This makes your pull request easy to merge.
3328

3429
License
3530
-------
@@ -47,4 +42,4 @@ and slogans from any fork you make, especially if you want to publish your own v
4742
Special thanks
4843
--------------
4944
* [remailednet](http://blog.remailed.net) for creating the original [XDebug Enabler](https://chrome.google.com/webstore/detail/eippbhbeglgcphcjmpjcjinjamabeoln) for Chrome
50-
* [Guilherme Pim](https://github.com/pimguilherme) for contributing a Manifest v2 version
45+
* [Guilherme Pim](https://github.com/pimguilherme) for contributing a Manifest v2 version

source/License

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ licensed under the [Creative Commons Attribution 3.0 License](http://creativecom
2222
The name "Wrep" and all of the Wrep trademarks, slogans, text or logo representation used
2323
or referred in this project are the property of [Wrep](http://www.wrep.nl/) and may not be
2424
used in any way without written permission by Wrep. So please remove our logo, name, icons
25-
and slogans from any fork you make, especially if you want to publish your own version somewhere.
25+
and slogans from any fork you make, especially if you want to publish your own version somewhere.

source/background.html

Lines changed: 0 additions & 123 deletions
This file was deleted.

source/background.js

Lines changed: 59 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,97 @@
1-
chrome.tabs.onUpdated.addListener(function(tabid)
1+
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
22
{
3-
chrome.tabs.getSelected(null, function(tab)
3+
// We only react on a complete load of a http(s) page,
4+
// only then we're sure the content.js is loaded.
5+
if (changeInfo.status !== "complete" || tab.url.indexOf("http") !== 0)
46
{
5-
if (!localStorage)
6-
{
7-
return;
8-
}
7+
return;
8+
}
9+
10+
// Prep some variables
11+
var sites = [],
12+
ideKey = "XDEBUG_ECLIPSE",
13+
match = false,
14+
domain;
915

10-
sites = localStorage["sites"];
11-
if (!sites)
16+
// Check if localStorage is available and get the settings out of it
17+
if (localStorage)
18+
{
19+
if (localStorage["sites"])
1220
{
13-
sites = "[]";
21+
sites = JSON.parse(localStorage["sites"]);
1422
}
15-
sites = JSON.parse(sites);
16-
17-
baseDomain = tab.url.match(/:\/\/(.[^\/]+)/)[1];
18-
19-
match = isValueInArray(sites, baseDomain);
2023

21-
if (match || sites.length === 0)
24+
if (localStorage["xdebugIdeKey"])
2225
{
23-
chrome.pageAction.show(tabid);
24-
chrome.tabs.getSelected(null, function(tab)
25-
{
26-
chrome.tabs.sendRequest(
27-
tab.id,
28-
{
29-
cmd: "status",
30-
idekey: localStorage["xdebugIdeKey"]
31-
},
32-
function(response)
33-
{
34-
updateIcon(response.result, tabid);
35-
}
36-
);
37-
});
26+
ideKey = localStorage["xdebugIdeKey"];
3827
}
39-
});
40-
});
28+
}
4129

42-
chrome.pageAction.onClicked.addListener(function(tab)
43-
{
44-
chrome.tabs.getSelected(null, function(tab)
30+
// Get the current domain out of the tab URL and check if it matches anything in the sites array
31+
domain = tab.url.match(/:\/\/(.[^\/]+)/)[1];
32+
match = isValueInArray(sites, domain);
33+
34+
// Check if we have a match or don't need to match at all
35+
if (match || sites.length === 0)
4536
{
46-
chrome.tabs.sendRequest(
47-
tab.id,
37+
// Show the pageAction
38+
chrome.pageAction.show(tabId);
39+
40+
// Request the current status and update the icon accordingly
41+
chrome.tabs.sendMessage(
42+
tabId,
4843
{
49-
cmd: "toggle", idekey: localStorage["xdebugIdeKey"]
44+
cmd: "getStatus",
45+
idekey: ideKey
5046
},
5147
function(response)
5248
{
53-
updateIcon(response.result, tab.id);
49+
updateIcon(response.status, tabId);
5450
}
5551
);
56-
});
52+
}
5753
});
5854

59-
function updateIcon(status, tabid)
55+
function updateIcon(status, tabId)
6056
{
57+
// Figure the correct title/image with the given state
58+
var title = "Debugging, profiling & tracing disabled",
59+
image = "images/bug-gray.png";
60+
6161
if (status == 1)
6262
{
63-
chrome.pageAction.setTitle({
64-
tabId: tabid,
65-
title: "Debugging enabled"
66-
});
67-
68-
chrome.pageAction.setIcon({
69-
tabId: tabid,
70-
path: "images/bug.png"
71-
});
63+
title = "Debugging enabled";
64+
image = "images/bug.png";
7265
}
7366
else if (status == 2)
7467
{
75-
chrome.pageAction.setTitle({
76-
tabId: tabid,
77-
title: "Profiling enabled"
78-
});
79-
80-
chrome.pageAction.setIcon({
81-
tabId: tabid,
82-
path: "images/clock.png"
83-
});
68+
title = "Profiling enabled";
69+
image = "images/clock.png";
8470
}
8571
else if (status == 3)
8672
{
87-
chrome.pageAction.setTitle({
88-
tabId: tabid,
89-
title: "Tracing enabled"
90-
});
91-
92-
chrome.pageAction.setIcon({
93-
tabId: tabid,
94-
path: "images/script.png"
95-
});
73+
title = "Tracing enabled";
74+
image = "images/script.png";
9675
}
97-
else
98-
{
99-
chrome.pageAction.setTitle({
100-
tabId: tabid,
101-
title: "Debugging, profiling & tracing disabled"
102-
});
10376

104-
chrome.pageAction.setIcon({
105-
tabId: tabid,
106-
path: "images/bug-gray.png"
107-
});
108-
}
77+
// Update title
78+
chrome.pageAction.setTitle({
79+
tabId: tabId,
80+
title: title
81+
});
82+
83+
// Update image
84+
chrome.pageAction.setIcon({
85+
tabId: tabId,
86+
path: image
87+
});
10988
}
11089

11190
function isValueInArray(arr, val)
11291
{
11392
for (i = 0; i < arr.length; i++)
11493
{
115-
re = new RegExp(arr[i], "gi");
94+
var re = new RegExp(arr[i], "gi");
11695
if (re.test(val))
11796
{
11897
return true;

0 commit comments

Comments
 (0)