Author
|
zPlus <zplus@peers.community>
2020-12-04 12:49:07
|
Committer
|
zPlus <zplus@peers.community>
2020-12-04 12:49:07
|
Commit
|
b96f196
(patch)
|
Tree
|
9b7aade
|
Parent(s)
|
|
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.
commits diff:
575e16c..b96f196
6 files changed,
5 insertions,
45 deletions
—
download
Diffstat
Diff options
+0/-25
M freepost/static/javascript/freepost.js
28
|
28
|
|
*/
|
29
|
29
|
|
|
30
|
30
|
|
/**
|
31
|
|
- |
* Store which keys have been pressed.
|
32
|
|
- |
* When a key has been pressed, pressed_key[e.keyCode] will be set
|
33
|
|
- |
* to TRUE. When a key is released, pressed_key[e.keyCode] will be
|
34
|
|
- |
* set to FALSE.
|
35
|
|
- |
*/
|
36
|
|
- |
var pressed_key = [];
|
37
|
|
- |
|
38
|
|
- |
/**
|
39
|
31
|
|
* Change arrows class when voting.
|
40
|
32
|
|
*/
|
41
|
33
|
|
function vote (action, vote_dom)
|
127
|
119
|
|
});
|
128
|
120
|
|
}
|
129
|
121
|
|
|
130
|
|
- |
// Bind onkeydown()/onkeyup() event to keys
|
131
|
|
- |
document.onkeydown = document.onkeyup = function(e) {
|
132
|
|
- |
// Set the current key code as TRUE/FALSE
|
133
|
|
- |
pressed_key[e.keyCode] = e.type == 'keydown';
|
134
|
|
- |
|
135
|
|
- |
// If Ctrl+Enter have been pressed
|
136
|
|
- |
// Key codes: Ctrl=17, Enter=13
|
137
|
|
- |
if (pressed_key[17] && pressed_key[13])
|
138
|
|
- |
{
|
139
|
|
- |
// Select all forms in the current page with class "shortcut-submit"
|
140
|
|
- |
var forms = document.querySelectorAll ("form.shortcut-submit");
|
141
|
|
- |
|
142
|
|
- |
for (var i = 0; i < forms.length; i++)
|
143
|
|
- |
forms[i].submit ();
|
144
|
|
- |
}
|
145
|
|
- |
}
|
146
|
|
- |
|
147
|
122
|
|
// Function to hide/show menu when burger-icon has been clicked
|
148
|
123
|
|
var burger_menus = document.getElementsByClassName ('burger-icon')
|
149
|
124
|
|
for (var i = 0; i < burger_menus.length; i++)
|
+1/-4
M freepost/templates/edit_comment.html
16
|
16
|
|
{{ comment.text|md2html|safe }}
|
17
|
17
|
|
</div>
|
18
|
18
|
|
|
19
|
|
- |
{# "shortcut-submit" is a class used exclusively from javascript
|
20
|
|
- |
# to submit the form when a key (Ctrl+Enter) is pressed.
|
21
|
|
- |
#}
|
22
|
|
- |
<form action="" method="post" class="shortcut-submit">
|
|
19
|
+ |
<form action="" method="post">
|
23
|
20
|
|
<input type="hidden" name="comment" value="{{ comment.hashId }}" />
|
24
|
21
|
|
|
25
|
22
|
|
<div style="margin: 2em 0;">
|
+1/-4
M freepost/templates/edit_post.html
3
|
3
|
|
{% block content %}
|
4
|
4
|
|
|
5
|
5
|
|
<div class="edit">
|
6
|
|
- |
{# "shortcut-submit" is a class used exclusively from javascript
|
7
|
|
- |
# to submit the form when a key (Ctrl+Enter) is pressed.
|
8
|
|
- |
#}
|
9
|
|
- |
<form action="" method="post" class="submit shortcut-submit">
|
|
6
|
+ |
<form action="" method="post" class="submit">
|
10
|
7
|
|
<input type="hidden" name="post" value="{{ post.hashId }}" />
|
11
|
8
|
|
|
12
|
9
|
|
<h3>Title <em>(required)</em></h3>
|
+1/-4
M freepost/templates/post.html
65
|
65
|
|
{% endif %}
|
66
|
66
|
|
</div>
|
67
|
67
|
|
|
68
|
|
- |
{# "shortcut-submit" is a class used exclusively from javascript
|
69
|
|
- |
# to submit the form when a key (Ctrl+Enter) is pressed.
|
70
|
|
- |
#}
|
71
|
|
- |
<form action="" method="post" class="new_comment shortcut-submit">
|
|
68
|
+ |
<form action="" method="post" class="new_comment">
|
72
|
69
|
|
<textarea
|
73
|
70
|
|
name="new_comment"
|
74
|
71
|
|
required="required"
|
+1/-4
M freepost/templates/reply.html
14
|
14
|
|
{{ comment.text|md2html|safe }}
|
15
|
15
|
|
</div>
|
16
|
16
|
|
|
17
|
|
- |
{# "shortcut-submit" is a class used exclusively from javascript
|
18
|
|
- |
# to submit the form when a key (Ctrl+Enter) is pressed.
|
19
|
|
- |
#}
|
20
|
|
- |
<form action="" method="post" class="shortcut-submit">
|
|
17
|
+ |
<form action="" method="post">
|
21
|
18
|
|
<input type="hidden" name="parent_comment" value="{{ comment.hashId }}" />
|
22
|
19
|
|
|
23
|
20
|
|
<div style="margin: 2em 0;">
|
+1/-4
M freepost/templates/submit.html
12
|
12
|
|
</div>
|
13
|
13
|
|
{% endif %}
|
14
|
14
|
|
|
15
|
|
- |
{# "shortcut-submit" is a class used exclusively from javascript
|
16
|
|
- |
# to submit the form when a key (Ctrl+Enter) is pressed.
|
17
|
|
- |
#}
|
18
|
|
- |
<form action="" method="post" class="submit shortcut-submit">
|
|
15
|
+ |
<form action="" method="post" class="submit">
|
19
|
16
|
|
<h3>Title</h3>
|
20
|
17
|
|
<div>
|
21
|
18
|
|
<input type="text" name="title" class="form-control" required='required' autofocus />
|