From 8b01a46f30a7d48749f93babc8c9cbbed720853c Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 7 Aug 2013 01:54:29 -0700 Subject: [PATCH] I have a thing about these kinda things. --- builds/4chan-X.user.js | 57 +++++++++++++++--------------- builds/crx/script.js | 57 +++++++++++++++--------------- src/General/Build.coffee | 53 +--------------------------- src/General/Get.coffee | 49 +++++++++++++------------- src/General/html/Build/post.html | 59 ++++++++++++++++++++++++++++++++ src/General/lib/post.class | 2 +- 6 files changed, 144 insertions(+), 133 deletions(-) create mode 100644 src/General/html/Build/post.html diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index e19d45057..a54e6a059 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -975,7 +975,7 @@ nodes = $.X('.//br|.//text()', bq); i = 0; while (node = nodes.snapshotItem(i++)) { - text = +node.data || '\n'; + text += node.data || '\n'; } return this.info.comment = text.trim().replace(/\s+$/gm, ''); }; @@ -1972,7 +1972,7 @@ container = $.el('div', { id: "pc" + postID, className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", - innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + (comment || '') + capcodeReplies + "
") + '
' + innerHTML: "" + (isOP ? '' : "
>>
") + "
" + (isOP ? fileHTML : '') + "" + (isOP ? '' : fileHTML) + "
" + (comment || '') + capcodeReplies + "
" + " " + "
" }); _ref = $$('.quotelink', container); for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -2176,32 +2176,7 @@ bq = $.el('blockquote', { textContent: data.comment }); - bq.innerHTML = bq.innerHTML.replace(/\n|\[\/?b\]|\[\/?spoiler\]|\[\/?code\]|\[\/?moot\]|\[\/?banned\]/g, 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 ''; - } - }); + bq.innerHTML = bq.innerHTML.replace(/\n|\[\/?b\]|\[\/?spoiler\]|\[\/?code\]|\[\/?moot\]|\[\/?banned\]/g, Get.parseMarkup); comment = bq.innerHTML.replace(/(^|>)(>[^<$]*)(<|$)/g, '$1$2$3').replace(/((>){2}(>\/[a-z\d]+\/)?\d+)/g, '$1'); threadID = +data.thread_num; o = { @@ -2251,6 +2226,32 @@ }); Main.callbackNodes(Post, [post]); 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 ''; + } } }; diff --git a/builds/crx/script.js b/builds/crx/script.js index 5e80d1718..29c696204 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -986,7 +986,7 @@ nodes = $.X('.//br|.//text()', bq); i = 0; while (node = nodes.snapshotItem(i++)) { - text = +node.data || '\n'; + text += node.data || '\n'; } return this.info.comment = text.trim().replace(/\s+$/gm, ''); }; @@ -1984,7 +1984,7 @@ container = $.el('div', { id: "pc" + postID, className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", - innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + (comment || '') + capcodeReplies + "
") + '
' + innerHTML: "" + (isOP ? '' : "
>>
") + "
" + (isOP ? fileHTML : '') + "" + (isOP ? '' : fileHTML) + "
" + (comment || '') + capcodeReplies + "
" + " " + "
" }); _ref = $$('.quotelink', container); for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -2188,32 +2188,7 @@ bq = $.el('blockquote', { textContent: data.comment }); - bq.innerHTML = bq.innerHTML.replace(/\n|\[\/?b\]|\[\/?spoiler\]|\[\/?code\]|\[\/?moot\]|\[\/?banned\]/g, 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 ''; - } - }); + bq.innerHTML = bq.innerHTML.replace(/\n|\[\/?b\]|\[\/?spoiler\]|\[\/?code\]|\[\/?moot\]|\[\/?banned\]/g, Get.parseMarkup); comment = bq.innerHTML.replace(/(^|>)(>[^<$]*)(<|$)/g, '$1$2$3').replace(/((>){2}(>\/[a-z\d]+\/)?\d+)/g, '$1'); threadID = +data.thread_num; o = { @@ -2263,6 +2238,32 @@ }); Main.callbackNodes(Post, [post]); 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 ''; + } } }; diff --git a/src/General/Build.coffee b/src/General/Build.coffee index bb0903db1..cd4f73e01 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -214,58 +214,7 @@ Build = container = $.el 'div', id: "pc#{postID}" className: "postContainer #{if isOP then 'op' else 'reply'}Container" - innerHTML: \ - (if isOP then '' else "
>>
") + - "
" + - - "' + - - (if isOP then fileHTML else '') + - - "' + - - (if isOP then '' else fileHTML) + - - "
#{comment or ''}#{capcodeReplies}
" + - - '
' + innerHTML: <%= grunt.file.read('src/General/html/Build/post.html').replace(/>\s+/g, '>').replace(/\s+ for quote in $$ '.quotelink', container href = quote.getAttribute 'href' diff --git a/src/General/Get.coffee b/src/General/Get.coffee index a5c1a54c1..50d32684b 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -153,30 +153,7 @@ Get = | \[/?code\] | \[/?moot\] | \[/?banned\] - ///g, (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]' - '' + ///g, Get.parseMarkup comment = bq.innerHTML # greentext @@ -228,3 +205,27 @@ Get = isArchived: true 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]' + '' \ No newline at end of file diff --git a/src/General/html/Build/post.html b/src/General/html/Build/post.html new file mode 100644 index 000000000..cf833ebdd --- /dev/null +++ b/src/General/html/Build/post.html @@ -0,0 +1,59 @@ +"""#{if isOP then '' else "
>>
"} +
+ + + + #{if isOP then fileHTML else ''} + + + + #{if isOP then '' else fileHTML} + +
#{comment or ''}#{capcodeReplies}
#{" "} + +
""" \ No newline at end of file diff --git a/src/General/lib/post.class b/src/General/lib/post.class index 8529473ba..ee4391bbf 100644 --- a/src/General/lib/post.class +++ b/src/General/lib/post.class @@ -80,7 +80,7 @@ class Post nodes = $.X './/br|.//text()', bq i = 0 while node = nodes.snapshotItem i++ - text =+ node.data or '\n' + text += node.data or '\n' @info.comment = text.trim().replace /\s+$/gm, '' parseQuotes: ->