Bug 15855 - Disabling multiple submission on search form
Summary: Disabling multiple submission on search form
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-18 10:12 UTC by Arthur Suzuki
Modified: 2017-08-09 17:14 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Extract from koha-opac-access_log (6.39 KB, text/plain)
2016-02-18 10:12 UTC, Arthur Suzuki
Details
Bug 18555: Create patron list from patron import (5.17 KB, patch)
2017-05-08 14:23 UTC, Marc Véron
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Suzuki 2016-02-18 10:12:38 UTC
Created attachment 48203 [details]
Extract from koha-opac-access_log

Some impatient users tends to click several times on the “Go” button of the search form on OPAC.
Probably in a desperate hope that this will speed up the whole process.
However the result is quite opposite, as Zebra is then queried multiple times which increases the server cpu load, until it reach 100% and cause Denial of Service (boooh…)

We had the idea of disabling the “searchsubmit” button upon first click.
This is done by adding onclick=”this.disabled=true;this.form.submit();return true;” after “id=searchsubmit” in masthead.inc.

It is also possible to solve this issue by adding the following section to opacuser.js:
$(document).ready(function() {
 $('#searchform').submit(function() {
   $('#searchsubmit').prop('disabled',true).text('searching...');
 });
});

Thanks to Frederic Demians and Olivier Crouzet for their help.
Comment 1 Arthur Suzuki 2016-02-19 14:21:25 UTC
Here is the code designed by Olivier :

// multi soumission Enter
var submitted;
$('#translControl1').bind('keyup',function() {
    submitted = false;
});  
$('#translControl1').bind('keydown',function(event) {
       code = event.keyCode||event.which||event.charCode||event.char||0;
       if(code == 13) {
           if (submitted == false) {
               submitted = true;		   
               $('#searchform').submit();
           } else {
	       event.preventDefault();
	       event.returnValue = false;
               return false;
           }
       }
});

The use of keyCode permits to submit form only once, and only uppon key down event.
It prevents the users to fire multiple searches while holding the "Return" key down (a behavior which is still possible with previously shared code).
Comment 2 Marc Véron 2017-05-08 14:23:34 UTC Comment hidden (obsolete)
Comment 3 Marc Véron 2017-05-08 14:26:19 UTC Comment hidden (obsolete)