From bcc62e7c2527821f0615bc457b19e783a7bfebf4 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 19 Dec 2013 14:16:42 +0900 Subject: [PATCH] define echoTabInfo and set locationchange hook --- _keysnail.js | 56 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index f7e7155..b5ab4d6 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -246,7 +246,46 @@ plugins.options["twitter_client.jmp_key"] = plugins.options["twitter_client.use_jmp"] = true; //////////////////////////////////////////// -// my ext +// my exts and functions + +var echoTabInfo = (function(){ + var currenttab; + function _display(msg){ + display.prettyPrint(msg, { + timeout: 2000, + style: { + "font-size": "18px" + } + }); + } + + function __display(msg){ + display.echoStatusBar(msg); + } + + function echo(){ + var newtab = getBrowser().mCurrentTab; + if (currenttab === newtab) { + return; + } + + currenttab = newtab; + var len = getBrowser().tabs.length; + var idx = currenttab._tPos; + var title = window.content.document.title; + var url = window.content.location.href; + _display( + (idx + 1).toString() + " / " + + len.toString() + " : " + + title + " <" + + url + ">" + ); + } + + return { + echo: echo + }; +})(); ext.add("open-remote-init-file", function(ev, arg){ const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js"; @@ -295,17 +334,6 @@ ext.add("my-index-html", function(ev, arg){ } }, "open my index.html"); -ext.add("echo-tab-info", function(){ - var all = getBrowser().tabs.length; - var ix = getBrowser().mCurrentTab._tPos; - var title = window.document.title; - var url = window.content.location.href; - display.echoStatusBar((ix + 1).toString() + " / " + - all.toString() + " : " + - title + " <" + - url + ">"); -}, "echo tab info"); - ext.add("strong-fullscreen", function(){ var elemids = [ "navigator-toolbox" @@ -771,7 +799,9 @@ hook.setHook('Unload', function () { }); }); - +hook.setHook('LocationChange', function (aNsURI) { + echoTabInfo.echo(); +}); // ============================= Key bindings ============================== // key.setGlobalKey('C-', function () {