From 788db8e3829ce980fcc7bd2ac41759f2b659af93 Mon Sep 17 00:00:00 2001 From: trapezoid Date: Wed, 26 Mar 2008 14:41:27 +0000 Subject: lang/javascript/vimperator-plugins/direct_hb.js: XUL/MigemoによるタグのMigemo検索の対応 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8416 d0d07461-0603-4401-acd4-de1884942a52 --- direct_hb.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'direct_hb.js') diff --git a/direct_hb.js b/direct_hb.js index 98bec69..7eb205f 100644 --- a/direct_hb.js +++ b/direct_hb.js @@ -1,5 +1,5 @@ // Vimperator plugin: 'Direct Hatena Bookmark' -// Last Change: 21-Mar-2008. Jan 2008 +// Last Change: 26-Mar-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid - http://unsigned.g.hatena.ne.jp/Trapezoid // Parts: @@ -8,9 +8,19 @@ // AutoPagerize(c) id:swdyh // // Hatena bookmark direct add script for vimperator0.6.* +// for Migemo search: require XUL/Migemo Extension (function(){ var isNormalize = true; + try{ + var XMigemoCore = Components + .classes['@piro.sakura.ne.jp/xmigemo/factory;1'] + .getService(Components.interfaces.pIXMigemoFactory) + .getService("ja"); + }catch(ex){ + var XMigemoCore = undefined; + } + function WSSEUtils(aUserName, aPassword){ this._init(aUserName, aPassword); } @@ -201,12 +211,14 @@ addHatenaBookmarks(hatenaUser,hatenaPassword,liberator.buffer.URL,arg,isNormalize); },{ completer: function(filter){ - var match_result = filter.match(/(.*)\[(\w*)$/); //[all, commited , now inputting] - var m = new RegExp("^" + match_result[2]); + //var match_result = filter.match(/(.*)\[(\w*)$/); //[all, commited , now inputting] + var match_result = filter.match(/(\[.*\])?(?:\[)?(.*)/); //[all, commited , now inputting] + //var m = new RegExp("^" + match_result[2]); + var m = new RegExp(XMigemoCore ? XMigemoCore.getRegExp(match_result[2]) : "^" + match_result[2]); var completionList = []; for(var i in liberator.plugins.hatena_tags) if(m.test(liberator.plugins.hatena_tags[i])){ - completionList.push([match_result[1] + "[" + liberator.plugins.hatena_tags[i] + "]","Tag"]); + completionList.push([(match_result[1] || "") + "[" + liberator.plugins.hatena_tags[i] + "]","Tag"]); } return [0, completionList]; } -- cgit v1.2.3