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
4 changes: 0 additions & 4 deletions source/jquery.js

This file was deleted.

2 changes: 1 addition & 1 deletion source/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ a {
}

/* Disable Popup */
.disable-popup-saved {
#disable-popup-saved {
color: #5cb85c;
font-weight: bold;
margin-left: 5px;
Expand Down
5 changes: 2 additions & 3 deletions source/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="options.css">

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="options.js"></script>
<script src="options.js" defer></script>
</head>

<body>
Expand Down Expand Up @@ -71,7 +70,7 @@ <h3>Disable Popup</h3>
<input type="checkbox" id="disable-popup" value="1">
<span>Disable Popup</span>
</label>
<span class="disable-popup-saved fade">Saved</span>
<span id="disable-popup-saved" class="fade">Saved</span>
</p>

<footer id="footer">
Expand Down
55 changes: 27 additions & 28 deletions source/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

// setTimeout() return value
let disablePopupTimeout;
const slctIde = document.getElementById("ide");
const inptIdeKey = document.getElementById("idekey");
const inptRacetrigger = document.getElementById("tracetrigger");
const inptProfiletrigger = document.getElementById("profiletrigger");

function save_options()
{
Expand All @@ -23,75 +27,70 @@

if (idekey == "XDEBUG_ECLIPSE" || idekey == "netbeans-xdebug" || idekey == "macgdbp" || idekey == "PHPSTORM")
{
$("#ide").val(idekey);
$("#idekey").prop('disabled', true);
slctIde.value = idekey;
inptIdeKey.disabled = true;
}
else
{
$("#ide").val("null");
$("#idekey").prop('disabled', false);
slctIde.value = "null";
inptIdeKey.disabled = false;
}
$('#idekey').val(idekey);
inptIdeKey.value = idekey;

// Restore Trace Triggers
var traceTrigger = localStorage["xdebugTraceTrigger"];
if (traceTrigger !== null) {
$("#tracetrigger").val(traceTrigger);
} else {
$("#tracetrigger").val(null);
}
inptRacetrigger.value = traceTrigger || "";

// Restore Profile Triggers
var profileTrigger = localStorage["xdebugProfileTrigger"];
if (profileTrigger !== null) {
$("#profiletrigger").val(profileTrigger);
} else {
$("#profiletrigger").val(null);
}
inptProfiletrigger.value = profileTrigger || "";

// Restore Disable Popup
document.getElementById('disable-popup').checked = (localStorage.xdebugDisablePopup === '1') ? true : false;
}

$(function()
(function()
{
$("#ide").change(function ()
slctIde.addEventListener("change", function ()
{
if ($("#ide").val() != "null")
if (slctIde.value != "null")
{
$("#idekey").prop('disabled', true);
$("#idekey").val($("#ide").val());
inptIdeKey.disabled = true;
inptIdeKey.value = inptIdeKey.value;

save_options();
}
else
{
$("#idekey").prop('disabled', false);
inptIdeKey.disabled = false;
}
});

$("#idekey").change(save_options);
inptIdeKey.addEventListener("change", save_options);

// Persist Disable Popup on onChange event
$('#disable-popup').change(disablePopupChanged);
document.getElementById("disable-popup").addEventListener("change", disablePopupChanged);

$('.save-button').click(save_options);
const saveBtns = document.getElementsByClassName("save-button");
for (const saveBtn of saveBtns) {
saveBtn.addEventListener("click", save_options);
}

restore_options();
});
})();

/**
* Disable Popup checkbox changed, persist it.
*/
function disablePopupChanged() {
const $disablePopupSaved = $('.disable-popup-saved');
const disablePopupSaved = document.getElementById("disable-popup-saved");

$disablePopupSaved.addClass('show');
disablePopupSaved.classList.add("show");

// First clear interval
clearInterval(disablePopupTimeout);
// Hide after 2 seconds
disablePopupTimeout = setTimeout(() => $disablePopupSaved.removeClass('show'), 2000);
disablePopupTimeout = setTimeout(() => disablePopupSaved.classList.remove("show"), 2000);

// Persist
save_options();
Expand Down
5 changes: 2 additions & 3 deletions source/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="popup.css">

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="keymaster.js"></script>
<script type="text/javascript" src="popup.js"></script>
<script type="text/javascript" src="keymaster.js" defer></script>
<script type="text/javascript" src="popup.js" defer></script>
</head>

<body>
Expand Down
54 changes: 32 additions & 22 deletions source/popup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
$(function() {
(function() {
var ideKey = "XDEBUG_ECLIPSE";
var traceTrigger = ideKey;
var profileTrigger = ideKey;
const anchors = document.getElementsByTagName("a");
const actions = document.getElementsByClassName("action");

// Check if localStorage is available and get the ideKey out of it if any
if (localStorage)
Expand Down Expand Up @@ -36,14 +38,14 @@ $(function() {
function(response)
{
// Highlight the correct option
$('a[data-status="' + response.status + '"]').addClass("active");
document.querySelector('a[data-status="' + response.status + '"]').classList.add("active");
}
);
});

// Attach handler when user clicks on
$("a").on("click", function(eventObject) {
var newStatus = $(this).data("status");
const anchorClickHanlder = function(eventObject) {
var newStatus = eventObject.currentTarget.dataset.status;

// Set the new state on the active tab
chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs)
Expand All @@ -67,43 +69,51 @@ $(function() {
}
);
});
});
};
for (const anchor of anchors) {
anchor.addEventListener("click", anchorClickHanlder);
}

// Shortcuts
key("d", function() { $("#action-debug").click(); });
key("p", function() { $("#action-profile").click(); });
key("t", function() { $("#action-trace").click(); });
key("s", function() { $("#action-disable").click(); });
key("space,enter", function() { $("a:focus").click(); });
key("d", function() { document.getElementById("action-debug").click(); });
key("p", function() { document.getElementById("action-profile").click(); });
key("t", function() { document.getElementById("action-trace").click(); });
key("s", function() { document.getElementById("action-disable").click(); });
key("space,enter", function() { document.querySelector("a:focus").click(); });
key("down,right", function()
{
var current = $(".action:focus");
if (current.length === 0)
var current = document.querySelector(".action:focus");
if (current === null)
{
$(".action:first").focus();
actions[0].focus();
}
else
{
current.parent().next().find("a").focus();
current.parentElement.nextElementSibling.querySelector("a").focus();
}
});
key("up,left", function()
{
var current = $(".action:focus");
var current = document.querySelector(".action:focus");
if (current.length === 0)
{
$(".action:last").focus();
actions[actions.length - 1].focus();
}
else
{
current.parent().prev().find("a").focus();
current.parentElement.previousElementSibling.querySelector("a").focus();
}
});

// Bit of a hack to prevent Chrome from focussing the first option automaticly
$("a").on("focus", function()
const focusHandler = function(eventObject)
{
$(this).blur();
$("a").off("focus");
});
});
eventObject.currentTarget.blur();
for (const anchor of anchors) {
anchor.removeEventListener("focus", focusHandler);
}
};
for (const anchor of anchors) {
anchor.addEventListener("focus", focusHandler);
}
})();