From cec8bf186e1c210ddf939bdfaa7d6e4958301191 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 25 Aug 2013 00:17:42 +0200 Subject: [PATCH 1/9] Fix #1262. --- src/General/Get.coffee | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/General/Get.coffee b/src/General/Get.coffee index eba405cae..d19e8db11 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -118,17 +118,18 @@ Get = Build.spoilerRange[boardID] = posts[0].custom_spoiler for post in posts break if post.no is postID # we found it! - if post.no > postID - # The post can be deleted by the time we check a quote. - if url = Redirect.to 'post', {boardID, postID} - $.cache url, - -> Get.archivedPost @, boardID, postID, root, context - , - withCredentials: url.archive.withCredentials - else - $.addClass root, 'warning' - root.textContent = "Post No.#{postID} was not found." - return + + if post.no isnt postID + # The post can be deleted by the time we check a quote. + if url = Redirect.to 'post', {boardID, postID} + $.cache url, + -> Get.archivedPost @, boardID, postID, root, context + , + withCredentials: url.archive.withCredentials + else + $.addClass root, 'warning' + root.textContent = "Post No.#{postID} was not found." + return board = g.boards[boardID] or new Board boardID From 386888e4d14ee644b241d19578c77b1e2ed396ac Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 25 Aug 2013 22:18:17 +0200 Subject: [PATCH 2/9] Tiny linkifier fix. --- src/Linkification/Linkify.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 5136cdfce..caaedd069 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -26,7 +26,7 @@ Linkify = Linkify.cleanLink anchor, link if Conf['Clean Links'] walker.currentNode = anchor.lastChild else - walker.currentNode = boundaries.endNode + walker.previousNode() range.detach() find: (link, walker) -> From 5c36d646a5267098d98b404d4269940c020a6533 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 26 Aug 2013 21:31:30 +0200 Subject: [PATCH 3/9] Start desktop notification closing timeout only after they appeared. --- src/Monitoring/Unread.coffee | 7 ++++--- src/Posting/QR.coffee | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index fdcbc7f16..6ccdf0244 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -104,9 +104,10 @@ Unread = notif.onclick = -> Header.scrollToPost post.nodes.root window.focus() - setTimeout -> - notif.close() - , 7 * $.SECOND + notif.onshow = -> + setTimeout -> + notif.close() + , 7 * $.SECOND onUpdate: (e) -> if e.detail[404] diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index cad8ea4b4..2091d9045 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -122,10 +122,11 @@ QR = # Firefox automatically closes notifications # so we can't control the onclose properly. notif.onclose = -> notice.close() - setTimeout -> - notif.onclose = null - notif.close() - , 7 * $.SECOND + notif.onshow = -> + setTimeout -> + notif.onclose = null + notif.close() + , 7 * $.SECOND <% } %> notifications: [] cleanNotifications: -> @@ -1108,9 +1109,10 @@ QR = QR.open() QR.captcha.nodes.input.focus() window.focus() - setTimeout -> - notif.close() - , 7 * $.SECOND + notif.onshow = -> + setTimeout -> + notif.close() + , 7 * $.SECOND unless Conf['Persistent QR'] or QR.cooldown.auto QR.close() From 44bde8781f54635d8bbcf9a6b0f572941d97ac4e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 18 Aug 2013 19:04:05 +0200 Subject: [PATCH 4/9] Drop support for prefixed flexbox. --- css/style.css | 31 ------------------------------- src/General/UI.coffee | 6 ++---- src/Meta/manifest.json | 2 +- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/css/style.css b/css/style.css index 63ad3c85a..c2646837c 100644 --- a/css/style.css +++ b/css/style.css @@ -16,7 +16,6 @@ margin: 0; padding: 2px 4px 3px; outline: none; - transition: color .25s, border-color .25s, -webkit-flex .25s; transition: color .25s, border-color .25s, flex .25s; } .field::-moz-placeholder, @@ -118,7 +117,6 @@ a[href="javascript:;"] { } #header-bar { border-width: 0; - display: -webkit-flex; display: flex; padding: 3px; position: relative; @@ -132,9 +130,7 @@ a[href="javascript:;"] { border-top-width: 1px; } #board-list { - -webkit-flex: 1; flex: 1; - -webkit-align-self: center; align-self: center; text-align: center; } @@ -245,7 +241,6 @@ a[href="javascript:;"] { } #overlay { background-color: rgba(0, 0, 0, .5); - display: -webkit-flex; display: flex; position: fixed; top: 0; @@ -263,13 +258,10 @@ a[href="javascript:;"] { max-width: 100%; margin: auto; padding: 3px; - display: -webkit-flex; display: flex; - -webkit-flex-direction: column; flex-direction: column; } #fourchanx-settings > nav { - display: -webkit-flex; display: flex; padding: 2px 2px 0; } @@ -281,14 +273,12 @@ a[href="javascript:;"] { padding: 2px; } .sections-list { - -webkit-flex: 1; flex: 1; } .tab-selected { font-weight: 700; } .section-container { - -webkit-flex: 1; flex: 1; position: relative; } @@ -419,13 +409,10 @@ a.hide-announcement { position: absolute; } #thread-watcher > div:first-child { - display: -webkit-flex; display: flex; - -webkit-align-items: center; align-items: center; } #thread-watcher .move { - -webkit-flex: 1; flex: 1; } #watcher-status:not(:empty)::before { @@ -587,15 +574,11 @@ a.hide-announcement { } #qr > div { min-width: 300px; - display: -webkit-flex; display: flex; - -webkit-align-items: center; align-items: center; } #qr .move { - -webkit-align-self: stretch; align-self: stretch; - -webkit-flex: 1; flex: 1; } #qr select { @@ -615,22 +598,17 @@ a.hide-announcement { padding: 0 3px; } #qr > form { - display: -webkit-flex; display: flex; - -webkit-flex-direction: column; flex-direction: column; } .persona { - display: -webkit-flex; display: flex; } .persona .field { - -webkit-flex: 1; flex: 1; } .persona .field:hover, .persona .field:focus { - -webkit-flex: 3; flex: 3; } #dump-button { @@ -807,9 +785,7 @@ a.hide-announcement { right: 0; bottom: 0; left: 0; - display: -webkit-flex; display: flex; - -webkit-align-items: center; align-items: center; } #file-n-submit-container input[type='file'] { @@ -821,7 +797,6 @@ a.hide-announcement { padding: 0; } #file-n-submit input[type='submit'] { - -webkit-order: 1; order: 1; } #file-n-submit.has-file #qr-no-file, @@ -841,7 +816,6 @@ a.hide-announcement { } #qr-no-file { cursor: default; - -webkit-flex: 1; flex: 1; } #qr-filename { @@ -852,7 +826,6 @@ a.hide-announcement { border: none !important; color: inherit; font: inherit; - -webkit-flex: 1; flex: 1; text-overflow: ellipsis; } @@ -888,10 +861,8 @@ a.hide-announcement { } #menu { border-bottom: 0; - display: -webkit-flex; display: flex; margin: 2px 0; - -webkit-flex-direction: column; flex-direction: column; position: absolute; outline: none; @@ -937,9 +908,7 @@ a.hide-announcement { } .submenu { border-bottom: 0; - display: -webkit-flex; display: flex; - -webkit-flex-direction: column; flex-direction: column; position: absolute; margin: -1px 0; diff --git a/src/General/UI.coffee b/src/General/UI.coffee index c2ad0d09d..dff2be93f 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -105,8 +105,7 @@ UI = do -> findNextEntry: (entry, direction) -> entries = [entry.parentNode.children...] - entries.sort (first, second) -> - +(first.style.order or first.style.webkitOrder) - +(second.style.order or second.style.webkitOrder) + entries.sort (first, second) -> first.style.order - second.style.order entries[entries.indexOf(entry) + direction] keybinds: (e) => @@ -179,8 +178,7 @@ UI = do -> e.stopPropagation() @focus el ).bind @ - {style} = el - style.webkitOrder = style.order = entry.order or 100 + el.style.order = entry.order or 100 return unless subEntries $.addClass el, 'has-submenu' for subEntry in subEntries diff --git a/src/Meta/manifest.json b/src/Meta/manifest.json index 53039fd37..b7c607807 100644 --- a/src/Meta/manifest.json +++ b/src/Meta/manifest.json @@ -15,7 +15,7 @@ "run_at": "document_start" }], "homepage_url": "<%= meta.page %>", - "minimum_chrome_version": "27", + "minimum_chrome_version": "29", "permissions": [ "storage" ] From a1efe855e24d97f02e41c89cdc853ebaba599fa8 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 28 Aug 2013 00:12:36 +0200 Subject: [PATCH 5/9] Make use of xhr.timeout. --- src/Monitoring/ThreadUpdater.coffee | 48 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index fa3d81963..206401e3c 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -56,7 +56,7 @@ ThreadUpdater = online: -> if ThreadUpdater.online = navigator.onLine ThreadUpdater.outdateCount = 0 - ThreadUpdater.set 'timer', ThreadUpdater.getInterval() + ThreadUpdater.setInterval() ThreadUpdater.update() if ThreadUpdater.isUpdating ThreadUpdater.set 'status', null, null else @@ -72,7 +72,7 @@ ThreadUpdater = # Reset the counter when we focus this tab. ThreadUpdater.outdateCount = 0 if ThreadUpdater.seconds > ThreadUpdater.interval - ThreadUpdater.set 'timer', ThreadUpdater.getInterval() + ThreadUpdater.setInterval() scrollBG: -> ThreadUpdater.scrollBG = if Conf['Scroll BG'] -> true @@ -81,32 +81,38 @@ ThreadUpdater = autoUpdate: (e) -> ThreadUpdater.isUpdating = @checked if e if ThreadUpdater.isUpdating and ThreadUpdater.online - ThreadUpdater.timeoutID = setTimeout ThreadUpdater.timeout, 1000 + ThreadUpdater.timeout() else clearTimeout ThreadUpdater.timeoutID interval: (e) -> val = Math.max 5, parseInt @value, 10 ThreadUpdater.interval = @value = val $.cb.value.call @ if e - load: -> + load: (e) -> {req} = ThreadUpdater + if e.type isnt 'loadend' # timeout or abort + req.onloadend = null + delete ThreadUpdater.req + if e.type is 'timeout' + ThreadUpdater.set 'status', 'Retrying', null + ThreadUpdater.update() + return switch req.status when 200 g.DEAD = false ThreadUpdater.parse JSON.parse(req.response).posts - ThreadUpdater.set 'timer', ThreadUpdater.getInterval() + ThreadUpdater.setInterval() when 404 g.DEAD = true ThreadUpdater.set 'timer', null ThreadUpdater.set 'status', '404', 'warning' - clearTimeout ThreadUpdater.timeoutID ThreadUpdater.thread.kill() $.event 'ThreadUpdate', 404: true thread: ThreadUpdater.thread else ThreadUpdater.outdateCount++ - ThreadUpdater.set 'timer', ThreadUpdater.getInterval() + ThreadUpdater.setInterval() [text, klass] = if req.status is 304 [null, null] else @@ -114,13 +120,16 @@ ThreadUpdater = ThreadUpdater.set 'status', text, klass delete ThreadUpdater.req - getInterval: -> + setInterval: -> i = ThreadUpdater.interval j = Math.min ThreadUpdater.outdateCount, 10 unless d.hidden # Lower the max refresh rate limit on visible tabs. j = Math.min j, 7 ThreadUpdater.seconds = Math.max i, [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] + ThreadUpdater.set 'timer', ThreadUpdater.seconds + clearTimeout ThreadUpdater.timeoutID + ThreadUpdater.timeout() set: (name, text, klass) -> el = ThreadUpdater[name] @@ -134,24 +143,21 @@ ThreadUpdater = timeout: -> ThreadUpdater.timeoutID = setTimeout ThreadUpdater.timeout, 1000 - unless n = --ThreadUpdater.seconds - ThreadUpdater.update() - else if n <= -60 - ThreadUpdater.set 'status', 'Retrying', null - ThreadUpdater.update() - else if n > 0 - ThreadUpdater.set 'timer', n + ThreadUpdater.set 'timer', --ThreadUpdater.seconds + ThreadUpdater.update() if ThreadUpdater.seconds <= 0 update: -> return unless ThreadUpdater.online - ThreadUpdater.seconds = 0 + clearTimeout ThreadUpdater.timeoutID ThreadUpdater.set 'timer', '...' - if ThreadUpdater.req - # abort() triggers onloadend, we don't want that. - ThreadUpdater.req.onloadend = null - ThreadUpdater.req.abort() + ThreadUpdater.req.abort() if ThreadUpdater.req url = "//api.4chan.org/#{ThreadUpdater.thread.board}/res/#{ThreadUpdater.thread}.json" - ThreadUpdater.req = $.ajax url, onloadend: ThreadUpdater.cb.load, + ThreadUpdater.req = $.ajax url, + onabort: ThreadUpdater.cb.load + onloadend: ThreadUpdater.cb.load + ontimeout: ThreadUpdater.cb.load + timeout: $.MINUTE + , whenModified: true updateThreadStatus: (title, OP) -> From 455778f865be3ecdce872a243670e6190d5fd700 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 28 Aug 2013 20:32:58 +0200 Subject: [PATCH 6/9] Fix image contraction not always moving us back to the post. --- src/Images/ImageExpand.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index b9153461f..a64b75458 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -57,7 +57,6 @@ ImageExpand = unless post.file.isExpanded or $.hasClass thumb, 'expanding' ImageExpand.expand post return - ImageExpand.contract post # Scroll back to the thumbnail when contracting the image # to avoid being left miles away from the relevant post. @@ -70,6 +69,7 @@ ImageExpand = if rect.left < 0 x = -window.scrollX window.scrollBy x, y if x or y + ImageExpand.contract post contract: (post) -> $.rmClass post.nodes.root, 'expanded-image' From 4742e7dac6c5d77cbbc0b738b47277a2050a5734 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 28 Aug 2013 20:38:32 +0200 Subject: [PATCH 7/9] Fix the QR showing incorrect file data when opening multiple files at once. --- src/Posting/QR.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 2091d9045..b13b83f15 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -586,7 +586,7 @@ QR = @filesize = $.bytesToString file.size @nodes.label.hidden = false if QR.spoiler URL.revokeObjectURL @URL - @showFileData() + @showFileData() if @ is QR.selected unless /^image/.test file.type @nodes.el.style.backgroundImage = null return From 0e3222312cf2d767cf697f4022650f88fab07eff Mon Sep 17 00:00:00 2001 From: Mayhem Date: Thu, 29 Aug 2013 16:18:52 +0200 Subject: [PATCH 8/9] Remove a Chrome bug notice as it didn't seem to actually work. --- src/General/Main.coffee | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index afcdbe910..4ba842fc2 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -32,18 +32,6 @@ Main = Conf['archives'] = Redirect.archives $.get Conf, (items) -> $.extend Conf, items - <% if (type === 'crx') { %> - unless items - new Notice 'error', $.el 'span', - innerHTML: """ - It seems like your <%= meta.name %> settings became corrupted due to a Chrome bug.
- Unfortunately, you'll have to fix it yourself. - """ - # Track resolution of this bug. - Main.logError - message: 'Chrome Storage API bug' - error: new Error '~' - <% } %> Main.initFeatures() $.on d, '4chanMainInit', Main.initStyle From fde52b440245cee92354598038d6d1cf08a44540 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 30 Aug 2013 22:19:27 +0200 Subject: [PATCH 9/9] Uncomment that for xtra stability. --- src/Linkification/Linkify.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index caaedd069..db0e22bce 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -16,7 +16,7 @@ Linkify = range = d.createRange() for link in links boundaries = Linkify.find link, walker - # break unless boundaries + continue unless boundaries anchor = Linkify.createLink link if Linkify.surround anchor, range, boundaries if (parent = anchor.parentNode).href is anchor.href @@ -35,7 +35,7 @@ Linkify = while node = walker.nextNode() text += node.data break if text.indexOf(link) > -1 - # return unless node + return unless node startNode = endNode = node # Walk backwards to find the startNode.