aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrmr19932016-01-30 13:00:53 +0000
committermrmr19932016-01-30 13:07:14 +0000
commit91fb337c9d92f6291ef42c55c4d29ca35b710203 (patch)
treedc3fbc4f3e0dab37c9fbce5dd61ff46cb6c9c8a4
parentc3373252db73430ec466eb0b81a16a5953975e19 (diff)
downloadvimium-91fb337c9d92f6291ef42c55c4d29ca35b710203.tar.bz2
Add a basic log page
-rw-r--r--background_scripts/main.coffee11
-rw-r--r--pages/logging.html37
2 files changed, 45 insertions, 3 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index df817e8d..2c93f6fb 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -96,6 +96,11 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) ->
# Ensure the sendResponse callback is freed.
return false)
+logMessage = (message) ->
+ for viewWindow in chrome.extension.getViews {type: "tab"}
+ if viewWindow.location.pathname == "/pages/logging.html"
+ viewWindow.document.getElementById("log-text").value += "#{(new Date()).toISOString()}: #{message}\n"
+
#
# Used by the content scripts to get their full URL. This is needed for URLs like "view-source:http:# .."
# because window.location doesn't know anything about the Chrome-specific "view-source:".
@@ -513,12 +518,12 @@ splitKeyQueue = (queue) ->
handleKeyDown = (request, port) ->
key = request.keyChar
if (key == "<ESC>")
- console.log("clearing keyQueue")
+ logMessage "clearing keyQueue"
keyQueue = ""
else
- console.log("checking keyQueue: [", keyQueue + key, "]")
+ logMessage "checking keyQueue: [#{keyQueue + key}]"
keyQueue = checkKeyQueue(keyQueue + key, port.sender.tab.id, request.frameId)
- console.log("new KeyQueue: " + keyQueue)
+ logMessage "new KeyQueue: #{keyQueue}"
# Tell the content script whether there are keys in the queue.
# FIXME: There is a race condition here. The behaviour in the content script depends upon whether this message gets
# back there before or after the next keystroke.
diff --git a/pages/logging.html b/pages/logging.html
new file mode 100644
index 00000000..2de04bce
--- /dev/null
+++ b/pages/logging.html
@@ -0,0 +1,37 @@
+<html>
+ <head>
+ <title>Vimium Options</title>
+ <script src="content_script_loader.js"></script>
+ <style type="text/css">
+ body {
+ font: 14px "DejaVu Sans", "Arial", sans-serif;
+ color: #303942;
+ margin: 0 auto;
+ }
+ div#wrapper {
+ margin: 0px 35px;
+ width: calc(100% - 70px);
+ }
+ header {
+ font-size: 18px;
+ font-weight: normal;
+ border-bottom: 1px solid #eee;
+ padding: 20px 0 15px 0;
+ width: 100%;
+ }
+ #log-text {
+ width: 100%;
+ height: 80%;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div id="wrapper">
+ <header>Vimium Log</header>
+ <br />
+ <textarea id="log-text" readonly></textarea>
+ <br />
+ </div>
+ </body>
+</html>