From 432b7d3779521317a4dbb809d1130e8c843f40ee Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 12 Jan 2009 06:08:27 +0000 Subject: * following vimperator 2.0 * fix bug (response user name) * add PLUGIN_INFO for pluginManager git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@28314 d0d07461-0603-4401-acd4-de1884942a52 --- haiku.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 15 deletions(-) (limited to 'haiku.js') diff --git a/haiku.js b/haiku.js index 39176c9..e7536db 100644 --- a/haiku.js +++ b/haiku.js @@ -1,5 +1,5 @@ // Vimperator plugin: "Update Haiku" -// Last Change: 22-Aug-2008. Jan 2008 +// Last Change: 12-Jan-2009. Jan 2008 // License: Creative Commons // Maintainer: mattn - http://mattn.kaoriya.net/ // @@ -22,8 +22,41 @@ // un-fav someone's last status.. mean remove hatena star. // :haiku! #keyword // show the keyword timeline. +var PLUGIN_INFO = + + {NAME} + Hatena Haiku Client + mattn + Creative Commons + 2.0a1 + 2.0 + +; (function(){ + liberator.plugins.haiku = { + get cache() statuses + }; var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); var CLIENT_NAME = encodeURIComponent(config.name + "::plugin::haiku.js"); var evalFunc = window.eval; @@ -128,9 +161,9 @@ replies.* += <>
{rep.user.screen_name} - {rep.user_name} + {rep.user.name}
-
{rep.text.substr(keyword.length+1)}
+
{rep.text.substr(keyword.length)}
; }); } @@ -194,7 +227,8 @@ return new XMLList(str); } commands.addUserCommand(["haiku"], "Change Haiku status", - function(arg, special){ + function(args){ + var special = args.bang; var password; var username; try { @@ -221,7 +255,7 @@ liberator.echoerr(ex); } - arg = arg.string.replace(/%URL%/g, buffer.URL) + var arg = args.string.replace(/%URL%/g, buffer.URL) .replace(/%TITLE%/g, buffer.title); if (special && arg.match(/^\+\s*(.*)/)) @@ -237,30 +271,32 @@ }, { bang: true, hereDoc: true, - completer: function(filter, special){ - if (!filter || !statuses) return [0,[]]; - var matches= filter.match(/^([@#]|[-+]\s*)([^\s]*)$/); - if (!matches) return [0,[]]; + completer: function(context, args){ + if (!statuses) return; + var matches= context.filter.match(/^([@#]|[-+]\s*)([^\s]*)$/); + if (!matches) return; var list = []; var [prefix, target] = [matches[1],matches[2]]; switch (prefix.charAt(0)){ case "+": case "-": - if (!special) return; + if (!args.bang) return; case "@": - if (special) - list = statuses.map(function(entry) [entry.user.id, entry.text]); + context.title = ["ID","Entry"]; + if (args.bang) + list = statuses.map(function(entry) ["@" + entry.user.id, entry.text]); else - list = statuses.map(function(entry) [entry.user.id + "#" + entry.id, entry.text]); + list = statuses.map(function(entry) ["@" + entry.user.id + "#" + entry.id, entry.text]); break; case "#": - list = statuses.map(function(entry) [entry.keyword, entry.text]); + context.title = ["Keyword","Entry"]; + list = statuses.map(function(entry) ["#" + entry.keyword, entry.text]); break; } if (target){ list = list.filter(function($_) $_[0].indexOf(target) >= 0); } - return [prefix.length, list]; + context.completions = list; } } ); -- cgit v1.2.3