Show
Ignore:
Timestamp:
06/28/08 23:16:54 (5 months ago)
Author:
kga
Message:
  • j/k 移動はハイライトがおかしくなるので一旦コメントアウト
  • (unsafeWindow への依存)--
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/ldr_show_sbm_comments/ldr_show_sbm_comments.user.js

    r14782 r14791  
    55// @resource       styles http://svn.coderepos.org/share/lang/javascript/userscripts/ldr_show_sbm_comments/styles.css 
    66// @require        http://svn.coderepos.org/share/lang/javascript/jsdeferred/trunk/jsdeferred.userscript.js 
     7// @require        http://fastladder.googlecode.com/svn/trunk/fastladder/public/js/common.js 
    78// ==/UserScript== 
    89 
     
    1415    var w = (typeof unsafeWindow == 'undefined') ? window : unsafeWindow; 
    1516 
    16     if (GM_getValue('hide', false)) w.addClass('right_body', 'nocomment'); 
     17    if (GM_getValue('hide', false)) addClass('right_body', 'nocomment'); 
    1718 
    1819    w.Keybind.add('n', function () { 
     
    2223        var item_link = item.link; 
    2324        var item_id   = item.id; 
    24         var url       = encodeURIComponent(unescapeHTML(item_link)); 
    25         var elem      = w.$('sbm_' + item_id); 
     25        var url       = encodeURIComponent(item_link.replace(/%23/g, '#').unescapeHTML()); 
     26        var elem      = $('sbm_' + item_id); 
    2627 
    2728        var hatena = { 
     
    3233            }, 
    3334            makeTag : function (tags, id) { 
    34                 return tags.map(escapeHTML).map(function (tag) { 
     35                return tags.map(function (tag) { 
     36                    tag = tag.escapeHTML() || ''; 
    3537                    return [ 
    3638                        '<span class="sbm_tag">', 
     
    4244            makeComment : function (o) { 
    4345                var id   = o.user; 
    44                 var dt   = new Date(o.timestamp); 
     46                var dt   = new DateTime(o.timestamp); 
    4547                var com  = (o.comment.length > 0) ? '' : 'out'; 
    4648                var tags = hatena.makeTag(o.tags, id); 
    4749                return { 
    48                     sort_key : dt.getTime(), 
     50                    sort_key : dt.valueOf(), 
    4951                    comment : [ 
    5052                        '<div class="flat_menu sbm_comment hatebu with', com, '_comment">', 
     53                            '<span class="date">', dt.ymd_jp(), ' ', dt.hms(), '</span>', 
    5154                            '<a href="http://b.hatena.ne.jp/', id, '/">', 
    5255                            '<img src="http://www.hatena.ne.jp/users/', id.substr(0, 2), '/', id, '/profile_s.gif" width="16" height="16">', id, '</a>', 
    53                             '<span class="date">', dt.toLocaleString(), '</span>', tags, o.comment, 
     56                            tags, o.comment, 
    5457                        '</div>' 
    5558                    ].join('') 
     
    6568            }, 
    6669            makeTag : function (tags, id) { 
    67                 return tags.map(escapeHTML).map(function (tag) { 
     70                return tags.map(function (tag) { 
     71                    tag = tag.escapeHTML() || ''; 
    6872                    return [ 
    6973                        '<span class="sbm_tag">', 
     
    7579            makeComment : function (o) { 
    7680                var id   = o.livedoor_id; 
    77                 var dt   = new Date(o.created_on * 1000); 
     81                var dt   = new DateTime(o.created_on * 1000); 
    7882                var com  = (o.notes.length > 0) ? '' : 'out'; 
    7983                var tags = livedoor.makeTag(o.tags, id); 
    8084                return { 
    81                     sort_key : dt.getTime(), 
     85                    sort_key : dt.valueOf(), 
    8286                    comment : [ 
    8387                        '<div class="flat_menu sbm_comment ldc with', com, '_comment">', 
     88                            '<span class="date">', dt.ymd_jp(), ' ', dt.hms(), '</span>', 
    8489                            '<a href="http://clip.livedoor.com/clips/', id, '">', 
    8590                            '<img src="http://image.profile.livedoor.jp/icon/', id, '_16.gif" width="16" height="16">', id, '</a>', 
    86                             '<span class="date">', dt.toLocaleString(), '</span>', tags, escapeHTML(o.notes), 
     91                            tags, o.notes.escapeHTML(), 
    8792                        '</div>' 
    8893                    ].join('') 
     
    103108            }).map(function (c) { return c.comment }).join('\n'); 
    104109 
    105             var d = w.$N('div', { 
     110            var d = $N('div', { 
    106111                id    : 'sbm_' + item_id, 
    107112                style : 'display: block;', 
    108113                class : 'sbm_comments' 
    109114            }); 
    110             d.innerHTML = '<h2 class="flat_menu sbm_comment">SBM Comments</h2>' + comments; 
     115            d.innerHTML = comments; 
     116//            d.innerHTML = '<h2 class="flat_menu sbm_comment">SBM Comments</h2>' + comments; 
    111117 
    112             try { w.$('item_' + item_id).appendChild(d); } catch (e) {} 
     118            try { $('item_' + item_id).appendChild(d); } catch (e) { alert(e) } 
    113119        }).error(function (e) { 
    114120            alert(e); 
     
    117123 
    118124    w.register_command('tc|togglecomment', function () { 
    119         w.toggleClass('right_body', 'nocomment'); 
     125        toggleClass('right_body', 'nocomment'); 
    120126        w.message( 
    121             ((w.contain(w.$('right_body').className, 'nocomment')) ? 'Hide' : 'Show') 
    122             + ' without comment' 
     127            (hasClass('right_body', 'nocomment') ? 'Hide' : 'Show') + ' without comment' 
    123128        ); 
    124129        setTimeout(function () { 
     
    129134}}, true); 
    130135 
    131 function escapeHTML (str) { 
    132     if (typeof str == 'undefined' || str == null) return ''; 
    133     return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); 
    134 } 
    135  
    136 function unescapeHTML (str) { 
    137     return str.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/%23/g, '#'); 
    138 } 
    139  
    140136function merge (obj) { 
    141137    var tmp = [];