Skip to content

Node.js based forum software built for the modern web

added debug info to console on ajaxify, added throttler so requests only go through once every half second

Julian Lam1d9c2f49d2f7
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index 955acab7bb..58bd66c282 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -7,6 +7,7 @@ $(document).ready(function () {
var location = document.location || window.location;
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
var apiXHR = null;
+ var ajaxifyTimer;
var translator;
var retry = true;
@@ -48,6 +49,12 @@ $(document).ready(function () {
$(window).on('action:reconnected', ajaxify.reconnectAction);
}
+ // Abort subsequent requests if clicked multiple times within a short window of time
+ if (ajaxifyTimer && (Date.now() - ajaxifyTimer) < 500) {
+ return true;
+ }
+ ajaxifyTimer = Date.now();
+
if (ajaxify.handleRedirects(url)) {
return true;
}
@@ -205,6 +212,11 @@ $(document).ready(function () {
$(window).trigger('action:ajaxify.contentLoaded', {url: url, tpl: tpl_url});
app.processPage();
+
+ var timeElapsed = Date.now() - ajaxifyTimer;
+ if (config.environment === 'development' && !isNaN(timeElapsed)) {
+ console.info('[ajaxify ' + url + '] Time elapsed:', timeElapsed + 'ms');
+ }
};
ajaxify.parseData = function () {