Skip to content

Commit 2c91228

Browse files
committed
Merge pull request mac-cain13#57 from thornview/master
trigger value support
2 parents 39c948b + 9212122 commit 2c91228

File tree

7 files changed

+140
-31
lines changed

7 files changed

+140
-31
lines changed

source/background.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
1111
var sites = [],
1212
ideKey = "XDEBUG_ECLIPSE",
1313
match = true,
14+
tt = ideKey,
15+
pt = ideKey,
1416
domain;
1517

1618
// Check if localStorage is available and get the settings out of it
@@ -25,6 +27,16 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
2527
{
2628
ideKey = localStorage["xdebugIdeKey"];
2729
}
30+
31+
if (localStorage["xdebugTraceTrigger"])
32+
{
33+
tt = localStorage["xdebugTraceTrigger"];
34+
}
35+
36+
if (localStorage["xdebugProfileTrigger"])
37+
{
38+
pt = localStorage["xdebugProfileTrigger"];
39+
}
2840
}
2941

3042
// Get the current domain out of the tab URL and check if it matches anything in the sites array
@@ -42,11 +54,17 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
4254
tabId,
4355
{
4456
cmd: "getStatus",
45-
idekey: ideKey
57+
idekey: ideKey,
58+
tt: tt,
59+
pt: pt
4660
},
4761
function(response)
4862
{
49-
updateIcon(response.status, tabId);
63+
if (chrome.runtime.lastError) {
64+
console.log("Error: ", chrome.runtime.lastError);
65+
} else {
66+
updateIcon(response.status, tabId);
67+
}
5068
}
5169
);
5270
}
@@ -57,13 +75,25 @@ chrome.commands.onCommand.addListener(function(command)
5775
if ('toggle_debug_action' == command)
5876
{
5977
var ideKey = "XDEBUG_ECLIPSE";
78+
var tt = ideKey;
79+
var pt = ideKey;
6080

6181
// Check if localStorage is available and get the settings out of it
6282
if (localStorage && localStorage["xdebugIdeKey"])
6383
{
6484
ideKey = localStorage["xdebugIdeKey"];
6585
}
6686

87+
if (localStorage && localStorage["xdebugTraceTrigger"])
88+
{
89+
tt = localStorage["xdebugTraceTrigger"];
90+
}
91+
92+
if (localStorage && localStorage["xdebugProfileTrigger"])
93+
{
94+
pt = localStorage["xdebugProfileTrigger"];
95+
}
96+
6797
// Fetch the active tab
6898
chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs)
6999
{
@@ -72,7 +102,9 @@ chrome.commands.onCommand.addListener(function(command)
72102
tabs[0].id,
73103
{
74104
cmd: "getStatus",
75-
idekey: ideKey
105+
idekey: ideKey,
106+
tt: tt,
107+
pt: pt
76108
},
77109
function(response)
78110
{
@@ -84,7 +116,9 @@ chrome.commands.onCommand.addListener(function(command)
84116
{
85117
cmd: "setStatus",
86118
status: newState,
87-
idekey: ideKey
119+
idekey: ideKey,
120+
tt: tt,
121+
pt: pt
88122
},
89123
function(response)
90124
{

source/content.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,56 @@ var xdebug = (function() {
4444
messageListener : function(request, sender, sendResponse)
4545
{
4646
var newStatus,
47-
idekey = "XDEBUG_ECLIPSE";
47+
idekey = "XDEBUG_ECLIPSE",
48+
tt = null,
49+
pt = null;
4850

4951
// Use the IDE key from the request, if any is given
5052
if (request.idekey)
5153
{
5254
idekey = request.idekey;
5355
}
56+
if (request.tt)
57+
{
58+
tt = request.tt;
59+
}
60+
if (request.pt)
61+
{
62+
pt = request.pt;
63+
}
5464

5565
// Execute the requested command
5666
if (request.cmd == "getStatus")
5767
{
58-
newStatus = exposed.getStatus(idekey);
68+
newStatus = exposed.getStatus(idekey, tt, pt);
5969
}
6070
else if (request.cmd == "toggleStatus")
6171
{
62-
newStatus = exposed.toggleStatus(idekey);
72+
newStatus = exposed.toggleStatus(idekey, tt, pt);
6373
}
6474
else if (request.cmd == "setStatus")
6575
{
66-
newStatus = exposed.setStatus(request.status, idekey);
76+
newStatus = exposed.setStatus(request.status, idekey, tt, pt);
6777
}
6878

6979
// Respond with the current status
7080
sendResponse({ status: newStatus });
7181
},
7282

7383
// Get current state
74-
getStatus : function(idekey)
84+
getStatus : function(idekey, tt, pt)
7585
{
7686
var status = 0;
7787

7888
if (getCookie("XDEBUG_SESSION") == idekey)
7989
{
8090
status = 1;
8191
}
82-
else if (getCookie("XDEBUG_PROFILE") == idekey)
92+
else if (getCookie("XDEBUG_PROFILE") == pt)
8393
{
8494
status = 2;
8595
}
86-
else if (getCookie("XDEBUG_TRACE") == idekey)
96+
else if (getCookie("XDEBUG_TRACE") == tt)
8797
{
8898
status = 3;
8999
}
@@ -92,14 +102,14 @@ var xdebug = (function() {
92102
},
93103

94104
// Toggle to the next state
95-
toggleStatus : function(idekey)
105+
toggleStatus : function(idekey, tt, pt)
96106
{
97-
var nextStatus = (exposed.getStatus(idekey) + 1) % 4;
98-
return exposed.setStatus(nextStatus, idekey);
107+
var nextStatus = (exposed.getStatus(idekey, tt, pt) + 1) % 4;
108+
return exposed.setStatus(nextStatus, idekey, tt, pt);
99109
},
100110

101111
// Set the state
102-
setStatus : function(status, idekey)
112+
setStatus : function(status, idekey, tt, pt)
103113
{
104114
if (status == 1)
105115
{
@@ -112,15 +122,16 @@ var xdebug = (function() {
112122
{
113123
// Set profiling on
114124
deleteCookie("XDEBUG_SESSION");
115-
setCookie("XDEBUG_PROFILE", idekey, 24);
125+
setCookie("XDEBUG_PROFILE", pt, 24);
116126
deleteCookie("XDEBUG_TRACE");
127+
117128
}
118129
else if (status == 3)
119130
{
120131
// Set tracing on
121132
deleteCookie("XDEBUG_SESSION");
122133
deleteCookie("XDEBUG_PROFILE");
123-
setCookie("XDEBUG_TRACE", idekey, 24);
134+
setCookie("XDEBUG_TRACE", tt, 24);
124135
}
125136
else
126137
{
@@ -131,7 +142,7 @@ var xdebug = (function() {
131142
}
132143

133144
// Return the new status
134-
return exposed.getStatus(idekey);
145+
return exposed.getStatus(idekey, tt, pt);
135146
}
136147
};
137148

source/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "Xdebug helper",
2+
"name": "Xdebug helper - DEV",
33
"description": "Easy debugging, profiling and tracing extension for Xdebug",
4-
"version": "1.4.3",
4+
"version": "1.5",
55
"author": "Mathijs Kadijk",
66

77
"manifest_version": 2,

source/options.css

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ h1, h2, h3 {
1313
margin-bottom: -5px;
1414
}
1515

16+
h3 {
17+
background-color: rgba(61, 167, 41, 0.48);
18+
color: rgba(27, 54, 23, 0.99);
19+
padding: 5px;
20+
}
21+
1622
h1 {
1723
margin: 0 0 -15px 0;
1824
}
@@ -37,6 +43,13 @@ body {
3743
font-size: 0.95em;
3844
}
3945

46+
button {
47+
float: right;
48+
margin: 5px;
49+
font-size: 1.25em;
50+
color: rgba(27, 54, 23, 0.99);
51+
}
52+
4053
.contentTxt {
4154
margin-bottom: 5px;
4255
}
@@ -84,16 +97,16 @@ body {
8497
margin-right: -7px;
8598
}
8699

87-
#hint {
100+
.hint {
88101
font-size: 0.8em;
89102
padding: 7px;
90103
width: 190px;
91104
text-align: center;
92-
background-color: #c8e8c3;
105+
background-color: rgb(251, 242, 185);
93106
border-radius: 5px;
94107
}
95108

96-
#hint img {
109+
.hint img {
97110
vertical-align: bottom;
98111
}
99112

source/options.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h3>Introduction</h3>
2727
<img class="inlineicon" alt="" src="images/clock.png" /> Profiling enabled<br />
2828
<img class="inlineicon" alt="" src="images/script.png" /> Tracing enabled
2929
</p>
30-
<p id="hint"><img src="images/lightbulb.png" alt="Tip!" title="Tip!" /> Love hotkeys? Try Ctrl+Shift+X</p>
30+
<p class="hint"><img src="images/lightbulb.png" alt="Tip!" title="Tip!" /> Love hotkeys? Try Ctrl+Shift+X</p>
3131

3232
<h3>IDE key</h3>
3333
<p class="note">Select your IDE to use the default sessionkey or choose other to use a custom key.</p>
@@ -39,7 +39,21 @@ <h3>IDE key</h3>
3939
<option value="PHPSTORM">PhpStorm</option>
4040
<option value="null">Other</option>
4141
</select>
42-
<span id="customkey"><input type="text" id="idekey" /> <a href="#" id="save-options"><img id="saveButton" src="images/disk.png" alt="Save" title="Save" /></a></span>
42+
<span id="customkey"><input type="text" id="idekey" /> </span>
43+
</p>
44+
45+
<h3>Trace Trigger Value</h3>
46+
<p class="note">If your xdebug is configured with a unique trace trigger key,
47+
set that value here. This value is blank by default.</p>
48+
<p>
49+
<input type="text" id="tracetrigger" value="">
50+
</p>
51+
52+
<h3>Profile Trigger Value</h3>
53+
<p class="note">If your xdebug is configured with a unique profile trigger key,
54+
set that value here. This value is blank by default.</p>
55+
<p>
56+
<input type="text" id="profiletrigger" value="">
4357
</p>
4458

4559
<h3>Domain filter</h3>
@@ -51,7 +65,10 @@ <h3>Domain filter</h3>
5165
<a id='remove-site'><img id="removeButton" src="images/delete.png" alt="Remove selected" title="Remove selected" /></a>
5266
</p>
5367

54-
<p id="hint"><img class="inlineicon" src="images/lightbulb.png" alt="Tip!" title="Tip!" /> <a href="http://wrepblog.tumblr.com/post/31720573340/xdebug-helper-for-chrome-how-to-use-the-domain-filter" target="_blank">Need help? Read our <span>blogpost</span>!</a></p>
68+
<p>
69+
<button class="button" id="save-options">Save Changes</button>
70+
</p>
71+
<p class="hint"><img class="inlineicon" src="images/lightbulb.png" alt="Tip!" title="Tip!" /> <a href="http://wrepblog.tumblr.com/post/31720573340/xdebug-helper-for-chrome-how-to-use-the-domain-filter" target="_blank">Need help? Read our <span>blogpost</span>!</a></p>
5572
</div>
5673

5774
<div id="footer">

source/options.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function save_options()
22
{
3-
input = document.getElementById("idekey");
4-
idekey = input.value;
5-
localStorage["xdebugIdeKey"] = idekey;
3+
localStorage["xdebugIdeKey"] = document.getElementById("idekey").value;
4+
localStorage["xdebugTraceTrigger"] = document.getElementById("tracetrigger").value;
5+
localStorage["xdebugProfileTrigger"] = document.getElementById("profiletrigger").value;
66

77
siteBox = document.getElementById("siteBox");
88
sites = [];
@@ -15,6 +15,7 @@ function save_options()
1515

1616
function restore_options()
1717
{
18+
// Restore IDE Key
1819
idekey = localStorage["xdebugIdeKey"];
1920

2021
if (!idekey)
@@ -33,6 +34,23 @@ function restore_options()
3334
}
3435
$('#idekey').val(idekey);
3536

37+
// Restore Trace Triggers
38+
var tt = localStorage["xdebugTraceTrigger"];
39+
if (tt !== null) {
40+
$("#tracetrigger").val(tt);
41+
} else {
42+
$("#tracetrigger").val(null);
43+
}
44+
45+
// Restore Profile Triggers
46+
var pt = localStorage["xdebugProfileTrigger"];
47+
if (pt !== null) {
48+
$("#profiletrigger").val(pt);
49+
} else {
50+
$("#profiletrigger").val(null);
51+
}
52+
53+
// Restore Sites
3654
sites = localStorage["sites"];
3755
if (sites)
3856
{

source/popup.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
$(function() {
22
var ideKey = "XDEBUG_ECLIPSE";
3+
var tt = ideKey;
4+
var pt = ideKey;
35

46
// Check if localStorage is available and get the ideKey out of it if any
57
if (localStorage && localStorage["xdebugIdeKey"])
68
{
79
ideKey = localStorage["xdebugIdeKey"];
810
}
911

12+
if (localStorage && localStorage["xdebugTraceTrigger"])
13+
{
14+
tt = localStorage["xdebugTraceTrigger"];
15+
}
16+
17+
if (localStorage && localStorage["xdebugProfileTrigger"])
18+
{
19+
pt = localStorage["xdebugProfileTrigger"];
20+
}
21+
1022
// Request the current state from the active tab
1123
chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs)
1224
{
1325
chrome.tabs.sendMessage(
1426
tabs[0].id,
1527
{
1628
cmd: "getStatus",
17-
idekey: ideKey
29+
idekey: ideKey,
30+
tt: tt,
31+
pt: pt
1832
},
1933
function(response)
2034
{
@@ -36,7 +50,9 @@ $(function() {
3650
{
3751
cmd: "setStatus",
3852
status: newStatus,
39-
idekey: ideKey
53+
idekey: ideKey,
54+
tt : tt,
55+
pt : pt
4056
},
4157
function(response)
4258
{

0 commit comments

Comments
 (0)