Changeset 14791 for lang/javascript/userscripts/ldr_show_sbm_comments
- Timestamp:
- 06/28/08 23:16:54 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/ldr_show_sbm_comments/ldr_show_sbm_comments.user.js
r14782 r14791 5 5 // @resource styles http://svn.coderepos.org/share/lang/javascript/userscripts/ldr_show_sbm_comments/styles.css 6 6 // @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 7 8 // ==/UserScript== 8 9 … … 14 15 var w = (typeof unsafeWindow == 'undefined') ? window : unsafeWindow; 15 16 16 if (GM_getValue('hide', false)) w.addClass('right_body', 'nocomment');17 if (GM_getValue('hide', false)) addClass('right_body', 'nocomment'); 17 18 18 19 w.Keybind.add('n', function () { … … 22 23 var item_link = item.link; 23 24 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); 26 27 27 28 var hatena = { … … 32 33 }, 33 34 makeTag : function (tags, id) { 34 return tags.map(escapeHTML).map(function (tag) { 35 return tags.map(function (tag) { 36 tag = tag.escapeHTML() || ''; 35 37 return [ 36 38 '<span class="sbm_tag">', … … 42 44 makeComment : function (o) { 43 45 var id = o.user; 44 var dt = new Date (o.timestamp);46 var dt = new DateTime(o.timestamp); 45 47 var com = (o.comment.length > 0) ? '' : 'out'; 46 48 var tags = hatena.makeTag(o.tags, id); 47 49 return { 48 sort_key : dt. getTime(),50 sort_key : dt.valueOf(), 49 51 comment : [ 50 52 '<div class="flat_menu sbm_comment hatebu with', com, '_comment">', 53 '<span class="date">', dt.ymd_jp(), ' ', dt.hms(), '</span>', 51 54 '<a href="http://b.hatena.ne.jp/', id, '/">', 52 55 '<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, 54 57 '</div>' 55 58 ].join('') … … 65 68 }, 66 69 makeTag : function (tags, id) { 67 return tags.map(escapeHTML).map(function (tag) { 70 return tags.map(function (tag) { 71 tag = tag.escapeHTML() || ''; 68 72 return [ 69 73 '<span class="sbm_tag">', … … 75 79 makeComment : function (o) { 76 80 var id = o.livedoor_id; 77 var dt = new Date (o.created_on * 1000);81 var dt = new DateTime(o.created_on * 1000); 78 82 var com = (o.notes.length > 0) ? '' : 'out'; 79 83 var tags = livedoor.makeTag(o.tags, id); 80 84 return { 81 sort_key : dt. getTime(),85 sort_key : dt.valueOf(), 82 86 comment : [ 83 87 '<div class="flat_menu sbm_comment ldc with', com, '_comment">', 88 '<span class="date">', dt.ymd_jp(), ' ', dt.hms(), '</span>', 84 89 '<a href="http://clip.livedoor.com/clips/', id, '">', 85 90 '<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(), 87 92 '</div>' 88 93 ].join('') … … 103 108 }).map(function (c) { return c.comment }).join('\n'); 104 109 105 var d = w.$N('div', {110 var d = $N('div', { 106 111 id : 'sbm_' + item_id, 107 112 style : 'display: block;', 108 113 class : 'sbm_comments' 109 114 }); 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; 111 117 112 try { w.$('item_' + item_id).appendChild(d); } catch (e) {}118 try { $('item_' + item_id).appendChild(d); } catch (e) { alert(e) } 113 119 }).error(function (e) { 114 120 alert(e); … … 117 123 118 124 w.register_command('tc|togglecomment', function () { 119 w.toggleClass('right_body', 'nocomment');125 toggleClass('right_body', 'nocomment'); 120 126 w.message( 121 ((w.contain(w.$('right_body').className, 'nocomment')) ? 'Hide' : 'Show') 122 + ' without comment' 127 (hasClass('right_body', 'nocomment') ? 'Hide' : 'Show') + ' without comment' 123 128 ); 124 129 setTimeout(function () { … … 129 134 }}, true); 130 135 131 function escapeHTML (str) {132 if (typeof str == 'undefined' || str == null) return '';133 return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');134 }135 136 function unescapeHTML (str) {137 return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/%23/g, '#');138 }139 140 136 function merge (obj) { 141 137 var tmp = [];
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)