diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 371868821..43b734a47 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -66,7 +66,7 @@ Build = url: if boardID is 'f' "#{location.protocol}//i.4cdn.org/#{boardID}/#{encodeURIComponent data.filename}#{data.ext}" else - "#{location.protocol}//i.4cdn.org/#{boardID}/#{data.tim}#{data.ext}" + "#{location.protocol}//#{if data.no % 3 then 'i.4cdn.org' else 'is.4chan.org'}/#{boardID}/#{data.tim}#{data.ext}" height: data.h width: data.w MD5: data.md5 @@ -76,6 +76,7 @@ Build = twidth: data.tn_w isSpoiler: !!data.spoiler tag: data.tag + hasDownscale: !!data.m_img o.file.dimensions = "#{o.file.width}x#{o.file.height}" unless /\.pdf$/.test o.file.url o @@ -83,8 +84,6 @@ Build = html = html .replace(//gi, '\n') .replace(/\n\nRolled [^<]*<\/b>/i, '') # Rolls (/tg/) - .replace(/]*>/g, '') Build.unescape html @@ -93,6 +92,9 @@ Build = unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers'] while (html2 = html.replace /(?:(?!<\/?s>).)*<\/s>/g, '[spoiler]') isnt html html = html2 + html = html + .replace(/^Rolled [^<]*<\/b>/i, '') # Rolls (/tg/, /qst/) + .replace(/ (${file.size}, ${file.dimensions || "PDF"}) - + ${file.size} 73 excerpt threadFromRoot: (root) -> @@ -18,7 +18,7 @@ Get = index = root.dataset.clone if index then post.clones[index] else post postFromNode: (root) -> - Get.postFromRoot $.x '(ancestor-or-self::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root + Get.postFromRoot $.x 'ancestor-or-self::div[contains(@class,"postContainer")][1]', root postDataFromLink: (link) -> if link.hostname is 'boards.4chan.org' path = link.pathname.split /\/+/ diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 0789fa93f..c651b4227 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -84,42 +84,39 @@ Header = $.on window, 'load popstate', Header.hashScroll $.on d, 'CreateNotification', @createNotification - $.asap (-> d.body), => + $.onExists doc, 'body', => return unless Main.isThisPageLegit() - # Wait for #boardNavMobile instead of #boardNavDesktop, - # it might be incomplete otherwise. - $.asap (-> $.id('boardNavMobile') or d.readyState isnt 'loading'), -> + $.prepend d.body, @bar + $.add d.body, Header.hover + @setBarPosition Conf['Bottom Header'] + + $.onExists doc, '#boardNavDesktop > *', Header.setBoardList + + Main.ready -> + if not (footer = $.id 'boardNavDesktopFoot') + return unless (absbot = $.id 'absbot') footer = $.id('boardNavDesktop').cloneNode true footer.id = 'boardNavDesktopFoot' $('#navtopright', footer).id = 'navbotright' $('#settingsWindowLink', footer).id = 'settingsWindowLinkBot' - Header.bottomBoardList = $ '.boardList', footer - if a = $ "a[href*='/#{g.BOARD}/']", footer - a.className = 'current' - Main.ready -> - if (oldFooter = $.id 'boardNavDesktopFoot') - $.replace $('.boardList', oldFooter), Header.bottomBoardList - else if (absbot = $.id 'absbot') - $.before absbot, footer - $.globalEval 'window.cloneTopNav = function() {};' - Header.setBoardList() - $.prepend d.body, @bar - $.add d.body, Header.hover - @setBarPosition Conf['Bottom Header'] - @ + $.before absbot, footer + $.globalEval 'window.cloneTopNav = function() {};' + if (a = $ "a[href*='/#{g.BOARD}/']", footer) + a.className = 'current' + Header.bottomBoardList = $ '.boardList', footer + CatalogLinks.setLinks Header.bottomBoardList - Main.ready => - if g.VIEW is 'catalog' or !Conf['Disable Native Extension'] - cs = $.el 'a', href: 'javascript:;' - if g.VIEW is 'catalog' - cs.title = cs.textContent = 'Catalog Settings' - cs.className = 'fa fa-book' - else - cs.title = cs.textContent = '4chan Settings' - cs.className = 'native-settings' - $.on cs, 'click', () -> - $.id('settingsWindowLink').click() - @addShortcut 'native', cs, 810 + if g.VIEW is 'catalog' or !Conf['Disable Native Extension'] + cs = $.el 'a', href: 'javascript:;' + if g.VIEW is 'catalog' + cs.title = cs.textContent = 'Catalog Settings' + cs.className = 'fa fa-book' + else + cs.title = cs.textContent = '4chan Settings' + cs.className = 'native-settings' + $.on cs, 'click', () -> + $.id('settingsWindowLink').click() + @addShortcut 'native', cs, 810 @enableDesktopNotifications() @@ -170,7 +167,9 @@ Header = a = node.cloneNode true a.className = 'current' if a.pathname.split('/')[1] is g.BOARD.ID nodes.push a - $.add $('.boardList', boardList), nodes + fullBoardList = $ '.boardList', boardList + $.add fullBoardList, nodes + CatalogLinks.setLinks fullBoardList $.add Header.bar, [Header.boardList, Header.shortcuts, Header.noticesRoot, Header.toggle] @@ -188,9 +187,8 @@ Header = as = $$ '#full-board-list a[title]', Header.boardList re = /[\w@]+(-(all|title|replace|full|index|catalog|archive|expired|(mode|sort|text):"[^"]+"(,"[^"]+")?))*|[^\w@]+/g nodes = (Header.mapCustomNavigation t, as for t in boardnav.match re) - $.add list, nodes - $.ready CatalogLinks.initBoardList + CatalogLinks.setLinks list mapCustomNavigation: (t, as) -> if /^[^\w@]/.test t diff --git a/src/General/Index.coffee b/src/General/Index.coffee index a6d24ff75..12f81c64f 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -95,17 +95,20 @@ Index = @hideLabel = $ '#hidden-label', @navLinks $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads - # Drop-down menus + # Drop-down menus and reverse sort toggle + @selectRev = $ '#index-rev', @navLinks @selectMode = $ '#index-mode', @navLinks @selectSort = $ '#index-sort', @navLinks @selectSize = $ '#index-size', @navLinks + $.on @selectRev, 'change', @cb.sort $.on @selectMode, 'change', @cb.mode $.on @selectSort, 'change', @cb.sort $.on @selectSize, 'change', $.cb.value $.on @selectSize, 'change', @cb.size for select in [@selectMode, @selectSize] select.value = Conf[select.name] - @selectSort.value = Index.currentSort + @selectRev.checked = /-rev$/.test Index.currentSort + @selectSort.value = Index.currentSort.replace /-rev$/, '' # Thread container @root = $.el 'div', className: 'board json-index' @@ -252,7 +255,8 @@ Index = Index.pageLoad false sort: -> - Index.pushState {sort: @value} + value = if Index.selectRev.checked then Index.selectSort.value + "-rev" else Index.selectSort.value + Index.pushState {sort: value} Index.pageLoad false resort: (e) -> @@ -357,12 +361,12 @@ Index = 'all-pages': 'all pages' 'catalog': 'catalog' sort: - 'bump-order': 'bump' - 'last-reply': 'lastreply' - 'last-long-reply': 'lastlong' - 'creation-date': 'birth' - 'reply-count': 'replycount' - 'file-count': 'filecount' + 'bump-order': 'bump' + 'last-reply': 'lastreply' + 'last-long-reply': 'lastlong' + 'creation-date': 'birth' + 'reply-count': 'replycount' + 'file-count': 'filecount' processHash: -> # XXX https://bugzilla.mozilla.org/show_bug.cgi?id=483304 @@ -377,8 +381,9 @@ Index = else if command is 'index' state.mode = Conf['Previous Index Mode'] state.page = 1 - else if (sort = Index.hashCommands.sort[command]) + else if (sort = Index.hashCommands.sort[command.replace(/-rev$/, '')]) state.sort = sort + state.sort += '-rev' if /-rev$/.test(command) else if /^s=/.test command state.search = decodeURIComponent(command[2..]).replace(/\+/g, ' ').trim() else @@ -461,7 +466,8 @@ Index = $('#hidden-toggle a', Index.navLinks).textContent = 'Show' setupSort: -> - Index.selectSort.value = Index.currentSort + Index.selectRev.checked = /-rev$/.test Index.currentSort + Index.selectSort.value = Index.currentSort.replace /-rev$/, '' getPagesNum: -> if Index.search @@ -759,7 +765,7 @@ Index = sort: -> {liveThreadIDs, liveThreadData} = Index return unless liveThreadData - Index.sortedThreadIDs = switch Index.currentSort + Index.sortedThreadIDs = switch Index.currentSort.replace(/-rev$/, '') when 'lastreply' [liveThreadData...].sort((a, b) -> a = num[num.length - 1] if (num = a.last_replies) @@ -779,6 +785,8 @@ Index = when 'replycount' then [liveThreadData...].sort((a, b) -> b.replies - a.replies).map (post) -> post.no when 'filecount' then [liveThreadData...].sort((a, b) -> b.images - a.images ).map (post) -> post.no else liveThreadIDs + if /-rev$/.test(Index.currentSort) + Index.sortedThreadIDs = [Index.sortedThreadIDs...].reverse() if Index.search and (threadIDs = Index.querySearch Index.search) Index.sortedThreadIDs = threadIDs # Sticky threads diff --git a/src/General/Index/NavLinks.html b/src/General/Index/NavLinks.html index 90d1794fc..e69e93af2 100644 --- a/src/General/Index/NavLinks.html +++ b/src/General/Index/NavLinks.html @@ -6,6 +6,7 @@ × +