Changeset 8416

Show
Ignore:
Timestamp:
03/26/08 23:41:27 (5 years ago)
Author:
trapezoid
Message:

lang/javascript/vimperator-plugins/direct_hb.js: XUL/MigemoによるタグのMigemo検索の対応

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/direct_hb.js

    r8231 r8416  
    11// Vimperator plugin: 'Direct Hatena Bookmark' 
    2 // Last Change: 21-Mar-2008. Jan 2008 
     2// Last Change: 26-Mar-2008. Jan 2008 
    33// License: Creative Commons 
    44// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid 
     
    99// 
    1010// Hatena bookmark direct add script for vimperator0.6.* 
     11// for Migemo search: require XUL/Migemo Extension 
    1112(function(){ 
    1213    var isNormalize = true; 
     14 
     15    try{ 
     16        var XMigemoCore = Components 
     17            .classes['@piro.sakura.ne.jp/xmigemo/factory;1'] 
     18            .getService(Components.interfaces.pIXMigemoFactory) 
     19            .getService("ja"); 
     20    }catch(ex){ 
     21        var XMigemoCore = undefined; 
     22    } 
    1323 
    1424    function WSSEUtils(aUserName, aPassword){ 
     
    202212        },{ 
    203213            completer: function(filter){ 
    204                 var match_result = filter.match(/(.*)\[(\w*)$/); //[all, commited , now inputting] 
    205                 var m = new RegExp("^" + match_result[2]); 
     214                //var match_result = filter.match(/(.*)\[(\w*)$/); //[all, commited , now inputting] 
     215                var match_result = filter.match(/(\[.*\])?(?:\[)?(.*)/); //[all, commited , now inputting] 
     216                //var m = new RegExp("^" + match_result[2]); 
     217                var m = new RegExp(XMigemoCore ? XMigemoCore.getRegExp(match_result[2]) : "^" + match_result[2]); 
    206218                var completionList = []; 
    207219                for(var i in liberator.plugins.hatena_tags) 
    208220                    if(m.test(liberator.plugins.hatena_tags[i])){ 
    209                         completionList.push([match_result[1] + "[" + liberator.plugins.hatena_tags[i] + "]","Tag"]); 
     221                        completionList.push([(match_result[1] || "") + "[" + liberator.plugins.hatena_tags[i] + "]","Tag"]); 
    210222                    } 
    211223                return [0, completionList];