Changeset 12543

Show
Ignore:
Timestamp:
05/27/08 19:01:08 (5 years ago)
Author:
mattn
Message:

* :bicon で被bookmark数アイコン表示(iconでなくcountの方がよかったか?)

Files:
1 modified

Legend:

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

    r11924 r12543  
    11// Vimperator plugin: 'Direct Post to Social Bookmarks' 
    2 // Version: 0.06 
    3 // Last Change: 18-May-2008. Jan 2008 
     2// Version: 0.07 
     3// Last Change: 27-May-2008. Jan 2008 
    44// License: Creative Commons 
    55// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid 
     
    4444//  ':bentry' 
    4545//      Goto Bookmark Entry Page 
     46//  ':bicon' 
     47//      Show Bookmark Count as Icon 
    4648(function(){ 
    4749    var useServicesByPost = liberator.globalVariables.direct_sbm_use_services_by_post || 'hdl'; 
     
    348350                liberator.echo("Hatena Bookmark: Tag parsing is finished. Taglist length: " + tags.length); 
    349351                return hatena_tags; 
     352            }, 
     353            icon:function(url){ 
     354                return '<img src="http://b.hatena.ne.jp/entry/image/' + url + '" style="vertical-align: middle;" />'; 
    350355            }, 
    351356        }, 
     
    382387                return returnValue; 
    383388            }, 
     389            icon:function(url){ 
     390                var url = liberator.buffer.URL; 
     391                var cryptoHash = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash); 
     392                cryptoHash.init(Ci.nsICryptoHash.MD5); 
     393                var inputStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); 
     394                inputStream.setData(url, url.length); 
     395                cryptoHash.updateFromStream(inputStream, -1); 
     396                var hash = cryptoHash.finish(false), ascii = []; 
     397                const hexchars = '0123456789ABCDEF'; 
     398                var hexrep = new Array(hash.length * 2); 
     399                for(var i = 0; i < hash.length; i++) { 
     400                    ascii[i * 2] = hexchars.charAt((hash.charCodeAt(i) >> 4) & 0xF); 
     401                    ascii[i * 2 + 1] = hexchars.charAt(hash.charCodeAt(i) & 0xF); 
     402                } 
     403                return '<img src="http://del.icio.us/feeds/img/savedcount/' + ascii.join('').toLowerCase() + '?aggregate" style="vertical-align: middle;" />'; 
     404            }, 
    384405        }, 
    385406        'l': { 
     
    417438                liberator.echo("livedoor clip: Tag parsing is finished. Taglist length: " + tags.length); 
    418439                return ldc_tags; 
     440            }, 
     441            icon:function(url){ 
     442                return '<img src="http://image.clip.livedoor.com/counter/' + url + '" style="vertical-align: middle;" />'; 
    419443            }, 
    420444        }, 
     
    512536        } 
    513537    ); 
     538    liberator.commands.addUserCommand(['bicon'],"Show Bookmark Count as Icon", 
     539        function(arg){ 
     540            var url = getNormalizedPermalink(liberator.buffer.URL); 
     541            var html = useServicesByTag.split(/\s*/).map(function(service){ 
     542                var currentService = services[service] || null; 
     543                return (currentService && typeof currentService.icon === 'function') ? 
     544                        (currentService.description + ': ' + currentService.icon(url)) : null; 
     545            }).join('<br />'); 
     546            liberator.echo(html, true); 
     547        }, {}); 
    514548    liberator.commands.addUserCommand(['sbm'],"Post to Social Bookmark", 
    515549        function(arg){