Skip to content

Commit 8445649

Browse files
author
Marius Burkard
committed
- prevent some clicks while ajax requests still running
1 parent 768b3f3 commit 8445649

File tree

1 file changed

+20
-60
lines changed

1 file changed

+20
-60
lines changed

interface/web/themes/default/assets/javascripts/ispconfig.js

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ var ISPConfig = {
2323
},
2424

2525
reportError: function(request) {
26-
/* Error reporting is disabled by default as some browsers like safari
27-
sometimes throw errors when a ajax request is delayed even if the
28-
ajax request worked. */
29-
30-
/*alert(request);*/
26+
3127
},
3228

3329
registerHook: function(name, callback) {
@@ -142,55 +138,6 @@ var ISPConfig = {
142138
ISPConfig.callHook('onAfterContentLoad', {'url': url, 'data': data });
143139
},
144140

145-
/* THIS ONE SHOULD BE REMOVED AFTER CREATING THE STATIC LOGIN PAGE!!! */
146-
/*submitLoginForm: function(formname) {
147-
//* Validate form. TODO: username and password with strip();
148-
var frm = document.getElementById(formname);
149-
var userNameObj = frm.username;
150-
if(userNameObj.value == ''){
151-
userNameObj.focus();
152-
return;
153-
}
154-
var passwordObj = frm.passwort;
155-
if(passwordObj.value == ''){
156-
passwordObj.focus();
157-
return;
158-
}
159-
160-
$('#dummy_username').val(userNameObj.value);
161-
$('#dummy_passwort').val(passwordObj.value);
162-
$('#dummy_login_form').submit();
163-
164-
var submitFormObj = $.ajax({
165-
type: "POST",
166-
url: "content.php",
167-
data: $('#'+formname).serialize(),
168-
dataType: "html",
169-
beforeSend: function() {
170-
ISPConfig.showLoadIndicator();
171-
},
172-
success: function(data, textStatus, jqXHR) {
173-
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
174-
var parts = jqXHR.responseText.split(':');
175-
ISPConfig.loadContent(parts[1]);
176-
} else if (jqXHR.responseText.indexOf('LOGIN_REDIRECT:') > -1) {
177-
// Go to the login page
178-
document.location.href = 'index.php';
179-
} else {
180-
$('#pageContent').html(jqXHR.responseText);
181-
ISPConfig.onAfterContentLoad('content.php', $('#'+formname).serialize());
182-
ISPConfig.pageFormChanged = false;
183-
}
184-
ISPConfig.loadMenus();
185-
ISPConfig.hideLoadIndicator();
186-
},
187-
error: function() {
188-
ISPConfig.hideLoadIndicator();
189-
ISPConfig.reportError('Ajax Request was not successful.110');
190-
}
191-
});
192-
},*/
193-
194141
submitForm: function(formname, target, confirmation) {
195142
var successMessage = arguments[3];
196143
if(!confirmation) confirmation = false;
@@ -320,11 +267,6 @@ var ISPConfig = {
320267
var newUrl= jqXHR.responseText.substr(jqXHR.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length);
321268
document.location.href = newUrl;
322269
} else {
323-
//document.getElementById('pageContent').innerHTML = jqXHR.responseText;
324-
//var reponse = $(jqXHR.responseText);
325-
//var reponseScript = reponse.filter("script");
326-
//$.each(reponseScript, function(idx, val) { eval(val.text); } );
327-
328270
$('#pageContent').html(jqXHR.responseText);
329271
ISPConfig.onAfterContentLoad(pagename, (params ? params : null));
330272
ISPConfig.pageFormChanged = false;
@@ -444,7 +386,10 @@ var ISPConfig = {
444386
},
445387

446388
changeTab: function(tab, target, force) {
447-
if(ISPConfig.requestsRunning > 0) return false;
389+
if(ISPConfig.requestsRunning > 0) {
390+
console.log('tab change interrupted, request still running.');
391+
return false;
392+
}
448393

449394
document.pageForm.next_tab.value = tab;
450395

@@ -622,6 +567,11 @@ var $page = $('html, body');
622567

623568
$(document).on('click', 'a[data-load-content],button[data-load-content]', function(e) {
624569
e.preventDefault();
570+
if(ISPConfig.requestsRunning > 0) {
571+
console.log('preventing click because there is still a request running.');
572+
return;
573+
}
574+
625575
$page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); });
626576
$page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); });
627577

@@ -633,6 +583,11 @@ $(document).on('click', 'a[data-load-content],button[data-load-content]', functi
633583

634584
$(document).on('click', 'a[data-capp],button[data-capp]', function(e) {
635585
e.preventDefault();
586+
if(ISPConfig.requestsRunning > 0) {
587+
console.log('preventing click because there is still a request running.');
588+
return;
589+
}
590+
636591
$page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); });
637592
$page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); });
638593

@@ -644,6 +599,11 @@ $(document).on('click', 'a[data-capp],button[data-capp]', function(e) {
644599

645600
$(document).on('click', 'a[data-submit-form],button[data-submit-form]', function(e) {
646601
e.preventDefault();
602+
if(ISPConfig.requestsRunning > 0) {
603+
console.log('preventing click because there is still a request running.');
604+
return;
605+
}
606+
647607
$page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); });
648608
$page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); });
649609

0 commit comments

Comments
 (0)