From e54d2dfaa4cd71fb2c2bc7bbb8ad6e9fc194accc Mon Sep 17 00:00:00 2001 From: Oliver Salzburg Date: Fri, 13 Mar 2015 13:32:51 +0100 Subject: [PATCH 01/11] Removed dead code --- src/autoreviewcomments.user.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/autoreviewcomments.user.js b/src/autoreviewcomments.user.js index 714531e..2ffa073 100644 --- a/src/autoreviewcomments.user.js +++ b/src/autoreviewcomments.user.js @@ -334,8 +334,6 @@ with_jquery(function ($) { ul.empty(); for(var i = 0; i < GetStorage("commentcount"); i++) { var commentName = GetStorage('name-' + i); - //var commenttype = GetCommentType(GetStorage('name-' + i)); - //if(commenttype == "any" || (commenttype == popup.posttype)) { if( IsCommentValidForPostType( commentName, popup.posttype ) ) { commentName = commentName.replace( Target.MATCH_ALL, "" ); var desc = GetStorage('desc-' + i).replace(/\$SITENAME\$/g, sitename).replace(/\$SITEURL\$/g, siteurl).replace(/\$MYUSERID\$/g, myuserid).replace(/\$/g, "$$$"); @@ -362,12 +360,6 @@ with_jquery(function ($) { return ( -1 < designator.indexOf( postType ) ); } - function GetCommentType(comment) { - if(comment.indexOf('[Q]') > -1) return Target.CommentQuestion; - if(comment.indexOf('[A]') > -1) return Target.CommentAnswer; - return "any"; - } - function AddOptionEventHandlers(popup) { popup.find('label > span').dblclick(function () { ToEditable($(this)); }); popup.find('label > .quick-insert').click(function () { From 80b40751a1d1e8053e92f15a0b5fb2aecf9f68fb Mon Sep 17 00:00:00 2001 From: Izzy Date: Fri, 13 Mar 2015 22:18:21 +0100 Subject: [PATCH 02/11] fix for #87 (upstream): getUserId fails with FF36 due to broken reference --- src/autoreviewcomments.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autoreviewcomments.user.js b/src/autoreviewcomments.user.js index 714531e..9dd23e3 100644 --- a/src/autoreviewcomments.user.js +++ b/src/autoreviewcomments.user.js @@ -700,7 +700,7 @@ with_jquery(function ($) { StackExchange.helpers.bindMovablePopups(); //Get user info and inject - var userid = getUserId($(this)); + var userid = getUserId(targetObject); getUserInfo(userid, popup); OP = getOP(); From 97e299766112bd0becd2f6a1f34f2a5866ed82f6 Mon Sep 17 00:00:00 2001 From: Oliver Salzburg Date: Tue, 17 Mar 2015 11:35:45 +0100 Subject: [PATCH 03/11] Don't add auto links if they already exist on the target --- src/autoreviewcomments.user.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/autoreviewcomments.user.js b/src/autoreviewcomments.user.js index df25bb9..8e84828 100644 --- a/src/autoreviewcomments.user.js +++ b/src/autoreviewcomments.user.js @@ -592,6 +592,12 @@ with_jquery(function ($) { * @param {jQuery} placeCommentIn The DOM element into which the comment should be placed. */ function injectAutoLink( where, what, placeCommentIn ) { + // Don't add auto links if one already exists + var existingAutoLinks = where.siblings( ".comment-auto-link" ); + if( existingAutoLinks && existingAutoLinks.length ) { + return; + } + var posttype = where.parents(".question, .answer").attr("class").split(' ')[0]; //slightly fragile if( "answer" == posttype ) posttype = Target.CommentAnswer; if( "question" == posttype ) posttype = Target.CommentQuestion; @@ -608,7 +614,13 @@ with_jquery(function ($) { * @param {Function} what The function that will be called when the link is clicked. * @param {jQuery} placeCommentIn The DOM element into which the comment should be placed. */ - function injectAutoLinkEdit( where, what, placeCommentIn ){ + function injectAutoLinkEdit( where, what, placeCommentIn ) { + // Don't add auto links if one already exists + var existingAutoLinks = where.siblings( ".comment-auto-link" ); + if( existingAutoLinks && existingAutoLinks.length ) { + return; + } + where.css( "width", "510px" ); where.siblings( ".actual-edit-overlay" ).css( "width", "510px" ); @@ -629,6 +641,12 @@ with_jquery(function ($) { * @param {jQuery} placeCommentIn The DOM element into which the comment should be placed. */ function injectAutoLinkClosure( where, what, placeCommentIn ) { + // Don't add auto links if one already exists + var existingAutoLinks = where.siblings( ".comment-auto-link" ); + if( existingAutoLinks && existingAutoLinks.length ) { + return; + } + var _autoLinkAction = function(){ what( placeCommentIn, Target.Closure ); }; From 93aa104ef82bb0a028085dd8e4f22cf4d2e3e525 Mon Sep 17 00:00:00 2001 From: Oliver Salzburg Date: Tue, 17 Mar 2015 12:06:12 +0100 Subject: [PATCH 04/11] Disable insert functionality for messages that are being edited --- src/autoreviewcomments.user.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/autoreviewcomments.user.js b/src/autoreviewcomments.user.js index df25bb9..c14adc0 100644 --- a/src/autoreviewcomments.user.js +++ b/src/autoreviewcomments.user.js @@ -273,18 +273,23 @@ with_jquery(function ($) { } //Replace contents of element with a textarea (containing markdown of contents), and save/cancel buttons - function ToEditable(el) { + function ToEditable(popup, el) { var backup = el.html(); var html = Tag(el.html().replace(greeting, '')); //remove greeting before editing.. if(html.indexOf(' -1) return; //don't want to create a new textarea inside this one! var txt = $('