mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-15 18:26:15 +01:00
added debug info to console on ajaxify, added throttler so requests only go through once every half second
This commit is contained in:
@@ -7,6 +7,7 @@ $(document).ready(function () {
|
|||||||
var location = document.location || window.location;
|
var location = document.location || window.location;
|
||||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||||
var apiXHR = null;
|
var apiXHR = null;
|
||||||
|
var ajaxifyTimer;
|
||||||
|
|
||||||
var translator;
|
var translator;
|
||||||
var retry = true;
|
var retry = true;
|
||||||
@@ -48,6 +49,12 @@ $(document).ready(function () {
|
|||||||
$(window).on('action:reconnected', ajaxify.reconnectAction);
|
$(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)) {
|
if (ajaxify.handleRedirects(url)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -205,6 +212,11 @@ $(document).ready(function () {
|
|||||||
$(window).trigger('action:ajaxify.contentLoaded', {url: url, tpl: tpl_url});
|
$(window).trigger('action:ajaxify.contentLoaded', {url: url, tpl: tpl_url});
|
||||||
|
|
||||||
app.processPage();
|
app.processPage();
|
||||||
|
|
||||||
|
var timeElapsed = Date.now() - ajaxifyTimer;
|
||||||
|
if (config.environment === 'development' && !isNaN(timeElapsed)) {
|
||||||
|
console.info('[ajaxify ' + url + '] Time elapsed:', timeElapsed + 'ms');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ajaxify.parseData = function () {
|
ajaxify.parseData = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user