From b96f196e06e290923fb77efb09e99fdea74594dd Mon Sep 17 00:00:00 2001 From: zPlus Date: Fri, 4 Dec 2020 13:49:07 +0100 Subject: [PATCH] Remove "quick submit" feature. This feature was an old request for submitting comments and posts by hitting Ctrl+Enter instead of having to click the "Submit" button. Unfortunately it's been causing a lot of issues by submitting the comments preemptively (before actually hitting the Ctrl+Enter combo) and also by submitting duplicate copies of the same comment. Will need to redo this function from scratch, if requested. --- freepost/static/javascript/freepost.js | 25 ------------------------- freepost/templates/edit_comment.html | 5 +---- freepost/templates/edit_post.html | 5 +---- freepost/templates/post.html | 5 +---- freepost/templates/reply.html | 5 +---- freepost/templates/submit.html | 5 +---- 6 files changed, 5 insertions(+), 45 deletions(-) diff --git a/freepost/static/javascript/freepost.js b/freepost/static/javascript/freepost.js index ef28937d..fcf63c6e 100644 --- a/freepost/static/javascript/freepost.js +++ b/freepost/static/javascript/freepost.js @@ -27,14 +27,6 @@ @licend The above is the entire license notice for the JavaScript code in this page. */ -/** - * Store which keys have been pressed. - * When a key has been pressed, pressed_key[e.keyCode] will be set - * to TRUE. When a key is released, pressed_key[e.keyCode] will be - * set to FALSE. - */ -var pressed_key = []; - /** * Change arrows class when voting. */ @@ -127,23 +119,6 @@ document.addEventListener ('DOMContentLoaded', function() { }); } - // Bind onkeydown()/onkeyup() event to keys - document.onkeydown = document.onkeyup = function(e) { - // Set the current key code as TRUE/FALSE - pressed_key[e.keyCode] = e.type == 'keydown'; - - // If Ctrl+Enter have been pressed - // Key codes: Ctrl=17, Enter=13 - if (pressed_key[17] && pressed_key[13]) - { - // Select all forms in the current page with class "shortcut-submit" - var forms = document.querySelectorAll ("form.shortcut-submit"); - - for (var i = 0; i < forms.length; i++) - forms[i].submit (); - } - } - // Function to hide/show menu when burger-icon has been clicked var burger_menus = document.getElementsByClassName ('burger-icon') for (var i = 0; i < burger_menus.length; i++) diff --git a/freepost/templates/edit_comment.html b/freepost/templates/edit_comment.html index 96d835c1..cb829fa9 100644 --- a/freepost/templates/edit_comment.html +++ b/freepost/templates/edit_comment.html @@ -16,10 +16,7 @@ {{ comment.text|md2html|safe }} - {# "shortcut-submit" is a class used exclusively from javascript - # to submit the form when a key (Ctrl+Enter) is pressed. - #} -
+
diff --git a/freepost/templates/edit_post.html b/freepost/templates/edit_post.html index fd84c186..2de67cf6 100644 --- a/freepost/templates/edit_post.html +++ b/freepost/templates/edit_post.html @@ -3,10 +3,7 @@ {% block content %}
- {# "shortcut-submit" is a class used exclusively from javascript - # to submit the form when a key (Ctrl+Enter) is pressed. - #} - +

Title (required)

diff --git a/freepost/templates/post.html b/freepost/templates/post.html index 1b85fb8e..d31344dd 100644 --- a/freepost/templates/post.html +++ b/freepost/templates/post.html @@ -65,10 +65,7 @@ {% endif %}
- {# "shortcut-submit" is a class used exclusively from javascript - # to submit the form when a key (Ctrl+Enter) is pressed. - #} - +