From 5f31fc0b25269acab33c53e74551c0162cc193a8 Mon Sep 17 00:00:00 2001 From: theopolisme Date: Tue, 17 Sep 2013 20:17:04 -0500 Subject: [PATCH 1/4] Fix regexp --- src/submissions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/submissions.js b/src/submissions.js index 69febfc..159bc90 100644 --- a/src/submissions.js +++ b/src/submissions.js @@ -1364,7 +1364,7 @@ function afcHelper_warnings(pagetext) { var errormsg = ''; // test if there are 30+ character html comments in the page text - var recomment = /\|$)/gi; + var recomment = /\|$)/gi; var matched; while (matched = recomment.exec(texttest)) { if (errormsg == '') errormsg += '

Please check the source code! This page contains one or more long (30+ characters) HTML comments! (please report false positives)

'; From 96412227987ac87479996aa9506682b9bdbffaa3 Mon Sep 17 00:00:00 2001 From: theopolisme Date: Tue, 17 Sep 2013 20:17:41 -0500 Subject: [PATCH 2/4] Store each html comment with a unique identifier to a dictionary --- src/submissions.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/submissions.js b/src/submissions.js index 159bc90..b743a82 100644 --- a/src/submissions.js +++ b/src/submissions.js @@ -19,6 +19,7 @@ var not_draft_afc_re = /\{\{\s*afc submission\s*\|\s*[^t](?:\{\{[^\{\}]*\}\}|[^\ var submissiontemplate_re = /(\{\{\s*afc submission\s*\|\s*([||t|r|d])(?:\{\{[^\{\}]*\}\}|[^\}\{])*)(\|\s*ts\s*=\s*([0-9]{14})|\{\{subst:LOCALTIMESTAMP\}\}|\{\{REVISIONTIMESTAMP\}\})((?:\{\{[^\{\}]*\}\}|[^\}\{]))*\}\}/i; var exclusive_pending_afc_re = /(\{\{\s*afc submission\s*\|)(\s*[\|]\s*)((?:\{\{[^\{\}]*\}\}|[^\}\{])*\}\})/i; var afcHelper_cache = {}; +var afcHelper_longcomments = {}; var afcHelper_reasonhash = [{ label: 'DUPLICATE ARTICLES', value: 'Duplicate articles', @@ -1366,9 +1367,12 @@ function afcHelper_warnings(pagetext) { // test if there are 30+ character html comments in the page text var recomment = /\|$)/gi; var matched; + var matchct = 0; while (matched = recomment.exec(texttest)) { - if (errormsg == '') errormsg += '

Please check the source code! This page contains one or more long (30+ characters) HTML comments! (please report false positives)

'; - errormsg += 'The hidden text is: ' + matched[1] + '
'; + matchct += 1; + if (errormsg == '') errormsg += '

Please check the source code! This page contains one or more long (30+ characters) HTML comments!

'; + errormsg += '
Hidden text: ' + matched[1] + ' (automatically delete comment from page)
'; + afcHelper_longcomments[matchct.toString()] = matched[0]; } //Check the deletion log and list it! From f33df9ad1611f4cdc2bf3ecdde8af05c9a1cec47 Mon Sep 17 00:00:00 2001 From: theopolisme Date: Tue, 17 Sep 2013 20:18:02 -0500 Subject: [PATCH 3/4] afcHelper_removehtmlcomment() to removes the selected HTML comment from wikitext --- src/submissions.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/submissions.js b/src/submissions.js index b743a82..67c6859 100644 --- a/src/submissions.js +++ b/src/submissions.js @@ -1605,6 +1605,18 @@ function afcHelper_turnvisible(id, visible) { else $("#" + id).css("display", "none"); } +function afcHelper_removehtmlcomment() { + // Removes the selected HTML comment from wikitext + var parent = $(this).parent(); + var comment = afcHelper_longcomments[parent.attr('id')]; + pagetext = pagetext.replace(comment,''); + parent.html('Comment removed!'); + setTimeout(function() { + parent.fadeOut(); + if ($('.afcHelper_hidden:visible').length < 2) $('#afcHelper_hiddenheader').fadeOut(); + },1000); +} + // Finally display the Review link var afcportletLink = mw.util.addPortletLink('p-cactions', '#', 'Review', 'ca-afcHelper', 'Review', 'a'); $(afcportletLink).click(function(e) { From 9c41db7d1f8c06ca785703c607af3848943347ab Mon Sep 17 00:00:00 2001 From: theopolisme Date: Tue, 17 Sep 2013 20:18:12 -0500 Subject: [PATCH 4/4] When "remove comment" is clicked, trigger afcHelper_removehtmlcomment() --- src/submissions.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/submissions.js b/src/submissions.js index 67c6859..a8e05ce 100644 --- a/src/submissions.js +++ b/src/submissions.js @@ -1375,6 +1375,9 @@ function afcHelper_warnings(pagetext) { afcHelper_longcomments[matchct.toString()] = matched[0]; } + // When "remove comment" is clicked, trigger afcHelper_removehtmlcomment() + $('body').on('click', '.afcHelper_hidden a', afcHelper_removehtmlcomment); + //Check the deletion log and list it! var request = { 'action': 'query',