Changeset 9692

Show
Ignore:
Timestamp:
04/18/08 18:49:53 (8 months ago)
Author:
mattn
Message:

lang/javascript/vimperator-plugins/trunk/direct_bookmark.js:

  • タグの補完が動かなくなっていたので修正
  • parseHTMLで無視するタグを設定出来る様にし、若干だがスピードアップ
Files:
1 modified

Legend:

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

    r9631 r9692  
    11// Vimperator plugin: 'Direct Post to Social Bookmarks' 
    22// Version: 0.03 
    3 // Last Change: 17-Apr-2008. Jan 2008 
     3// Last Change: 18-Apr-2008. Jan 2008 
    44// License: Creative Commons 
    55// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid 
     
    136136 
    137137    // copied from Pagerization (c) id:ofk 
    138     function parseHTML(str){ 
     138    function parseHTML(str, ignore_tags){ 
    139139        str = str.replace(/^[\s\S]*?<html(?:\s[^>]+?)?>|<\/html\s*>[\S\s]*$/ig, ''); 
     140        if (ignore_tags && ignore_tags instanceof Array) 
     141            str = str.replace(new RegExp('<' + ignore_tags.join('[^>]+?>|<') + '[^>]+?>', 'ig'), ''); 
    140142        var res = document.implementation.createDocument(null, 'html', null); 
    141143        var range = document.createRange(); 
     
    254256                xhr.send(null); 
    255257 
    256                 var mypage_html = parseHTML(xhr.responseText); 
     258                var mypage_html = parseHTML(xhr.responseText, ['img']); 
    257259                var tags = getElementsByXPath("//ul[@id=\"taglist\"]/li/a",mypage_html); 
    258260 
     
    329331                xhr.send(null); 
    330332 
    331                 var mypage_html = parseHTML(xhr.responseText); 
     333                var mypage_html = parseHTML(xhr.responseText, ['img']); 
    332334                var tags = getElementsByXPath("id(\"tag_list\")/span",mypage_html); 
    333335 
     
    367369        }); 
    368370        // unique tags 
    369         for(var i = tags.length; i --> 0; tags.indexOf(tag) == i || tags.splice(i, 1)); 
     371        for(var i = tags.length; i --> 0; tags.indexOf(tags[i]) == i || tags.splice(i, 1)); 
    370372        liberator.plugins.direct_bookmark.tags = tags.sort(); 
    371373    }