misc: don't accept more than a single exclamation mark in issue subjects
(this could later be changed to refuse them all, one step at a time)
This commit is contained in:
parent
e5958c1d1d
commit
10ae4a0ab1
|
@ -77,6 +77,38 @@ function sort_table() {
|
|||
$(table).find('tr:first-child td').on('click', sort_table).css('cursor', 'row-resize');
|
||||
}
|
||||
|
||||
function alter_new_issue_page() {
|
||||
$('input#issue_subject').on('keypress', function(evt) {
|
||||
/* initial code from
|
||||
* https://stackoverflow.com/questions/3579219/show-different-keyboard-character-from-the-typed-one-in-google-chrome/3580352#3580352
|
||||
*/
|
||||
var val = this.value;
|
||||
evt = evt || window.event;
|
||||
|
||||
// Ensure we only handle printable keys, excluding enter and space
|
||||
var charCode = typeof evt.which == "number" ? evt.which : evt.keyCode;
|
||||
if (charCode && charCode != 13 && charCode != 32) {
|
||||
var keyChar = String.fromCharCode(charCode);
|
||||
if (keyChar != '!') return true;
|
||||
if (val.indexOf('!') == -1) return true; /* we still allow one */
|
||||
|
||||
var mappedChar = '❤';
|
||||
|
||||
var start, end;
|
||||
if (typeof this.selectionStart == "number" && typeof this.selectionEnd == "number") {
|
||||
// Non-IE browsers and IE 9
|
||||
start = this.selectionStart;
|
||||
end = this.selectionEnd;
|
||||
this.value = val.slice(0, start) + mappedChar + val.slice(end);
|
||||
|
||||
// Move the caret
|
||||
this.selectionStart = this.selectionEnd = start + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('.wiki table tr:first-child td').on('click', sort_table).css('cursor', 'row-resize');
|
||||
|
||||
|
@ -84,6 +116,11 @@ $(function() {
|
|||
var timestamp = ((new Date().getTime() / 1000) % 86400 ) / (86400 / 440);
|
||||
$('#top-menu').css('background-position', '0 -' + timestamp + 'px');
|
||||
|
||||
if ($('body.controller-issues.action-new').length == 1) {
|
||||
alter_new_issue_page();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($('body.controller-issues.action-show').length == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue