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
10 changes: 10 additions & 0 deletions src/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ module Content {
setTimeout(function() {fn.call(null, data);}, timeout);
}

var cleanupMonitor = null; function startCleanupMonitor() {
cleanupMonitor = setTimeout(function() {clear()}, 500)
} ; function stopCleanupMonitor(afterStop) { if (cleanupMonitor != null)
{ clearTimeout(cleanupMonitor); afterStop();}
}

chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
Log.debug("Received command " + request.command);
Expand All @@ -60,6 +66,7 @@ module Content {
flags = "gi";
}
clear();
startCleanupMonitor();
infoSpan.add();
infoSpan.setText("Searching...");
var re = new RegExp(request.regexp, flags);
Expand All @@ -73,6 +80,8 @@ module Content {
move(false);
} else if (request.command == "next") {
move(true);
} else if (request.command == "ping") {
stopCleanupMonitor(() => startCleanupMonitor()); // restart the monitor
} else {
Log.debug("Invalid command");
}
Expand Down Expand Up @@ -177,6 +186,7 @@ module Content {
// Remove all matches
function clear(): void {
infoSpan.setText("Clearing...");
stopCleanupMonitor(() => cleanupMonitor = null)
setTimeout(function() {
cur = 0;
for (var i = 0; i < marks.length; i++) {
Expand Down
21 changes: 10 additions & 11 deletions src/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ module Popup {
} else {
search(id, tabStates);
}
} else if (event.keyCode == 27) {
Log.info("Esc pressed");
setSearching(id, false, tabStates);
Utils.sendCommand("clear");
}
}

var queryInputInput = function() {
tabStates.set(id, "query", queryInput.value);

function clear() {
if (tabStates.isSearching(id)) {
setSearching(id, false, tabStates);
Utils.sendCommand("clear");
}
}

var queryInputInput = function() {
tabStates.set(id, "query", queryInput.value);

clear();

// Remove the invalid class if it's there
queryInput.className = '';
Expand All @@ -103,17 +103,16 @@ module Popup {
Log.info("Set checkbox state to " + caseInsensitiveCheckbox.checked);
tabStates.set(id, "caseInsensitive", caseInsensitiveCheckbox.checked);

if (tabStates.isSearching(id)) {
setSearching(id, false, tabStates);
Utils.sendCommand("clear");
}
clear();
}

prevButton.addEventListener("click", prevButtonClick);
nextButton.addEventListener("click", nextButtonClick);
queryInput.addEventListener("keydown", queryInputKeyDown);
queryInput.addEventListener("input", queryInputInput);
caseInsensitiveCheckbox.onclick = checkboxClick;

setInterval(function(){Utils.sendCommand("ping")}, 300)
}

function restoreState(tabId: number, tabStates: TabStateManager) {
Expand Down