diff options
Diffstat (limited to 'js/thread-watcher.js')
| -rw-r--r-- | js/thread-watcher.js | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/js/thread-watcher.js b/js/thread-watcher.js index 22656e48..0796193b 100644 --- a/js/thread-watcher.js +++ b/js/thread-watcher.js @@ -28,10 +28,10 @@ watchlist.render = function(reset) { JSON.parse(localStorage.watchlist).forEach(function(e, i) { //look at line 69, that's what (e) is here. threads.push('<div class="watchlist-inner" id="watchlist-'+i+'">' + - '<span>Board: '+e[0]+'</span> ' + - '<span>Thread: '+'<a href="'+e[3]+'">'+e[1]+'</a></span> ' + - '<span>Replies: '+e[2]+'</span> ' + - '<a class="watchlist-remove">[Unwatch]</a>'+ + '<span>/'+e[0]+'/ - ' + + '<a href="'+e[3]+'">'+e[1].replace("thread_", _("Thread #"))+'</a>' + + ' ('+e[2]+') </span>' + + '<a class="watchlist-remove">X</a>'+ '</div>'); }); if ($('#watchlist').length) { @@ -40,17 +40,15 @@ watchlist.render = function(reset) { $('#watchlist').append(threads.join('')); } else { //If the watchlist has not yet been rendered, create it. - $('form[name="post"]').before( + var menuStyle = getComputedStyle($('.boardlist')[0]); + $((active_page == 'ukko') ? 'hr:first' : (active_page == 'catalog') ? 'body>span:first' : 'form[name="post"]').before( $('<div id="watchlist">'+ '<div class="watchlist-controls">'+ - '<span><a id="clearList">[Clear List]</a></span> '+ - '<span><a id="clearGhosts">[Clear Ghosts]</a></span>'+ + '<span><a id="clearList">['+_('Clear List')+']</a></span> '+ + '<span><a id="clearGhosts">['+_('Clear Ghosts')+']</a></span>'+ '</div>'+ threads.join('')+ - '</div>').css({ - background: $('.reply').css('background'), - borderColor : $('.reply').css('border-color') - })); + '</div>').css("background-color", menuStyle.backgroundColor).css("border", menuStyle.borderBottomWidth+" "+menuStyle.borderBottomStyle+" "+menuStyle.borderBottomColor)); } return this; }; @@ -62,6 +60,8 @@ watchlist.render = function(reset) { watchlist.add = function(sel) { var threadName, threadInfo; + var board_name = $(sel).parents('.thread').data('board'); + if (active_page === 'thread') { if ($('.subject').length){ //If a subject is given, use the first 20 characters as the thread name. @@ -72,7 +72,7 @@ watchlist.add = function(sel) { //board name, thread name as defined above, current amount of posts, thread url threadInfo = [board_name, threadName, $('.post').length, location.href]; - } else if (active_page === 'index') { + } else if (active_page === 'index' || active_page === 'ukko') { var postCount; //Figure out the post count. @@ -81,8 +81,8 @@ watchlist.add = function(sel) { } else { postCount = $(sel).parents('.op').siblings('.post').length+1; } - //Grab the reply link. - var threadLink = $(sel).siblings('a:contains("[Reply]")').attr('href'); + //Grab the reply link.; + var threadLink = $(sel).siblings('a:not(.watchThread)').last().attr('href'); //Figure out the thread name. If anon, use the thread id. if ($(sel).parent().find('.subject').length) { threadName = $(sel).parent().find('.subject').text().substring(0,20); @@ -144,16 +144,21 @@ watchlist.exists = function(sel) { }; $(document).ready(function(){ + if (!(active_page == 'thread' || active_page == 'index' || active_page == 'catalog' || active_page == 'ukko')) { + return; + } + //Append the watchlist toggle button. - $('.boardlist').append('<span>[ <a id="watchlist-toggle">watchlist</a> ]</span>'); + $('.boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>'); //Append a watch thread button after every OP. - $('.op>.intro').append('<a class="watchThread">[Watch Thread]</a>'); + $('.op>.intro').append('<a class="watchThread" href="#">['+_('Watch Thread')+']</a>'); //Draw the watchlist, hidden. watchlist.render(); //Show or hide the watchlist. - $('#watchlist-toggle').on('click', function(e) { + $('.watchlist-toggle').on('click', function(e) { + e.preventDefault(); //if ctrl+click, reset the watchlist. if (e.ctrlKey) { watchlist.render(true); @@ -167,7 +172,8 @@ $(document).ready(function(){ //Trigger the watchlist add function. //The selector is passed as an argument in case the page is not a thread. - $('.watchThread').on('click', function() { + $('.watchThread').on('click', function(e) { + e.preventDefault(); watchlist.add(this).render(); }); |
