From a993b440dc79a5a588614ed4401940b2cf547072 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 19 Jan 2014 15:18:57 -0700 Subject: [PATCH 1/4] Try to get some better errors out of QR.req.onerror Conflicts: builds/4chan-X.user.js builds/crx/script.js src/General/css/layout.css --- LICENSE | 2 +- builds/4chan-X.user.js | 7 +++++-- builds/crx/script.js | 7 +++++-- src/Posting/QR.coffee | 8 +++++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index 6c15e974c..63b08e1b2 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.3.2 - 2014-01-18 +* 4chan X - Version 1.3.2 - 2014-01-19 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 75dbae7a6..a09638157 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -22,7 +22,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.3.2 - 2014-01-18 +* 4chan X - Version 1.3.2 - 2014-01-19 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -6212,11 +6212,14 @@ responseType: 'document', withCredentials: true, onload: QR.response, - onerror: function() { + onerror: function(err, url, line) { delete QR.req; post.unlock(); QR.cooldown.auto = false; QR.status(); + console.log(err); + console.log(url); + console.log(line); return QR.error($.el('span', { innerHTML: "4chan X encountered an error while posting. \n[Banned?] [More info]" })); diff --git a/builds/crx/script.js b/builds/crx/script.js index b2050c249..ef1e9fdee 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.3.2 - 2014-01-18 +* 4chan X - Version 1.3.2 - 2014-01-19 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -6203,11 +6203,14 @@ responseType: 'document', withCredentials: true, onload: QR.response, - onerror: function() { + onerror: function(err, url, line) { delete QR.req; post.unlock(); QR.cooldown.auto = false; QR.status(); + console.log(err); + console.log(url); + console.log(line); return QR.error($.el('span', { innerHTML: "4chan X encountered an error while posting. \n[Banned?] [More info]" })); diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index bc5831b73..64a99ceff 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -590,13 +590,15 @@ QR = responseType: 'document' withCredentials: true onload: QR.response - onerror: -> - # Connection error, or - # www.4chan.org/banned + onerror: (err, url, line) -> + # Connection error, or www.4chan.org/banned delete QR.req post.unlock() QR.cooldown.auto = false QR.status() + console.log err + console.log url + console.log line QR.error $.el 'span', innerHTML: """ 4chan X encountered an error while posting. From f37484cd33ded841c9b266efda1339b3f3d81491 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 19 Jan 2014 15:25:22 -0700 Subject: [PATCH 2/4] HTTPS for posting, always. --- builds/4chan-X.user.js | 2 +- builds/crx/script.js | 2 +- src/Posting/QR.coffee | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a09638157..f2aa12fc2 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6240,7 +6240,7 @@ } } }; - QR.req = $.ajax("//sys.4chan.org/" + g.BOARD + "/post", options, extra); + QR.req = $.ajax("https://sys.4chan.org/" + g.BOARD + "/post", options, extra); QR.req.uploadStartTime = Date.now(); QR.req.progress = '...'; return QR.status(); diff --git a/builds/crx/script.js b/builds/crx/script.js index ef1e9fdee..5803bd0b7 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6231,7 +6231,7 @@ } } }; - QR.req = $.ajax("//sys.4chan.org/" + g.BOARD + "/post", options, extra); + QR.req = $.ajax("https://sys.4chan.org/" + g.BOARD + "/post", options, extra); QR.req.uploadStartTime = Date.now(); QR.req.progress = '...'; return QR.status(); diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 64a99ceff..de208e863 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -618,7 +618,7 @@ QR = QR.req.progress = "#{Math.round e.loaded / e.total * 100}%" QR.status() - QR.req = $.ajax "//sys.4chan.org/#{g.BOARD}/post", options, extra + QR.req = $.ajax "https://sys.4chan.org/#{g.BOARD}/post", options, extra # Starting to upload might take some time. # Provide some feedback that we're starting to submit. QR.req.uploadStartTime = Date.now() From 11e5f348f055c8004d7bf21b8c0d39e4040adef4 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 19 Jan 2014 21:38:46 -0700 Subject: [PATCH 3/4] Still hate switches. --- builds/4chan-X.user.js | 39 +++++++++++++-------------------------- builds/crx/script.js | 39 +++++++++++++-------------------------- src/General/Get.coffee | 38 +++++++++++++------------------------- 3 files changed, 39 insertions(+), 77 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f2aa12fc2..117f1b822 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3408,32 +3408,19 @@ return Get.insert(post, root, context); }, parseMarkup: function(text) { - switch (text) { - case '\n': - return '
'; - case '[b]': - return ''; - case '[/b]': - return ''; - case '[spoiler]': - return ''; - case '[/spoiler]': - return ''; - case '[code]': - return '
';
-        case '[/code]':
-          return '
'; - case '[moot]': - return '
'; - case '[/moot]': - return '
'; - case '[banned]': - return ''; - case '[/banned]': - return ''; - default: - return text.replace(':lit', ''); - } + return { + '\n': '
', + '[b]': '', + '[/b]': '', + '[spoiler]': '', + '[/spoiler]': '', + '[code]': '
',
+        '[/code]': '
', + '[moot]': '
', + '[/moot]': '
', + '[banned]': '', + '[/banned]': '' + }[text] || text.replace(':lit', ''); } }; diff --git a/builds/crx/script.js b/builds/crx/script.js index 5803bd0b7..d019b6295 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3418,32 +3418,19 @@ return Get.insert(post, root, context); }, parseMarkup: function(text) { - switch (text) { - case '\n': - return '
'; - case '[b]': - return ''; - case '[/b]': - return ''; - case '[spoiler]': - return ''; - case '[/spoiler]': - return ''; - case '[code]': - return '
';
-        case '[/code]':
-          return '
'; - case '[moot]': - return '
'; - case '[/moot]': - return '
'; - case '[banned]': - return ''; - case '[/banned]': - return ''; - default: - return text.replace(':lit', ''); - } + return { + '\n': '
', + '[b]': '', + '[/b]': '', + '[spoiler]': '', + '[/spoiler]': '', + '[code]': '
',
+        '[/code]': '
', + '[moot]': '
', + '[/moot]': '
', + '[banned]': '', + '[/banned]': '' + }[text] || text.replace(':lit', ''); } }; diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 0f41b7f9e..d3676ae15 100755 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -215,28 +215,16 @@ Get = Main.callbackNodes Post, [post] Get.insert post, root, context parseMarkup: (text) -> - switch text - when '\n' - '
' - when '[b]' - '' - when '[/b]' - '' - when '[spoiler]' - '' - when '[/spoiler]' - '' - when '[code]' - '
'
-      when '[/code]'
-        '
' - when '[moot]' - '
' - when '[/moot]' - '
' - when '[banned]' - '' - when '[/banned]' - '' - else - text.replace ':lit', '' + { + '\n': '
' + '[b]': '' + '[/b]': '' + '[spoiler]': '' + '[/spoiler]': '' + '[code]': '
'
+      '[/code]':    '
' + '[moot]': '
' + '[/moot]': '
' + '[banned]': '' + '[/banned]': '' + }[text] or text.replace ':lit', '' \ No newline at end of file From 702a343f5ed1585308d7e4a4fc5ce9a327793411 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 21 Jan 2014 13:57:28 -0700 Subject: [PATCH 4/4] Fix image expansion DURR --- LICENSE | 2 +- builds/4chan-X.user.js | 10 +++++----- builds/crx/script.js | 10 +++++----- src/Images/ImageExpand.coffee | 10 +++++++--- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/LICENSE b/LICENSE index 63b08e1b2..6c50e8b36 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.3.2 - 2014-01-19 +* 4chan X - Version 1.3.2 - 2014-01-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 117f1b822..77eb99cb1 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -22,7 +22,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.3.2 - 2014-01-19 +* 4chan X - Version 1.3.2 - 2014-01-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -7506,9 +7506,9 @@ return ImageExpand.toggle(Get.postFromNode(this)); }, toggleAll: function() { - var func; + var func, toggle; $.event('CloseMenu'); - func = function(post) { + toggle = function(post) { var file; file = post.file; if (!(file && file.isImage && doc.contains(post.nodes.root))) { @@ -7530,11 +7530,11 @@ } return g.posts.forEach(function(post) { var _i, _len, _ref; - func(post); + toggle(post); _ref = post.clones; for (_i = 0, _len = _ref.length; _i < _len; _i++) { post = _ref[_i]; - func(post); + toggle(post); } }); }, diff --git a/builds/crx/script.js b/builds/crx/script.js index d019b6295..66f1a0152 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.3.2 - 2014-01-19 +* 4chan X - Version 1.3.2 - 2014-01-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -7489,9 +7489,9 @@ return ImageExpand.toggle(Get.postFromNode(this)); }, toggleAll: function() { - var func; + var func, toggle; $.event('CloseMenu'); - func = function(post) { + toggle = function(post) { var file; file = post.file; if (!(file && file.isImage && doc.contains(post.nodes.root))) { @@ -7513,11 +7513,11 @@ } return g.posts.forEach(function(post) { var _i, _len, _ref; - func(post); + toggle(post); _ref = post.clones; for (_i = 0, _len = _ref.length; _i < _len; _i++) { post = _ref[_i]; - func(post); + toggle(post); } }); }, diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index b4e1f1ed5..71916d684 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -30,9 +30,10 @@ ImageExpand = return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 e.preventDefault() ImageExpand.toggle Get.postFromNode @ + toggleAll: -> $.event 'CloseMenu' - func = (post) -> + toggle = (post) -> {file} = post return unless file and file.isImage and doc.contains post.nodes.root if ImageExpand.on and @@ -40,6 +41,7 @@ ImageExpand = Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0) return $.queueTask func, post + if ImageExpand.on = $.hasClass ImageExpand.EAI, 'expand-all-shortcut' ImageExpand.EAI.className = 'contract-all-shortcut fa fa-compress' ImageExpand.EAI.title = 'Contract All Images' @@ -48,10 +50,12 @@ ImageExpand = ImageExpand.EAI.className = 'expand-all-shortcut fa fa-expand' ImageExpand.EAI.title = 'Expand All Images' func = ImageExpand.contract + g.posts.forEach (post) -> - func post - func post for post in post.clones + toggle post + toggle post for post in post.clones return + setFitness: -> (if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'