Commit r2393: https://sourceforge.net/p/mrbs/code/2393/
------------------------------------------------------------------------
r2393 | cimorrison | 2012-09-05 15:21:11 +0100 (Wed, 05 Sep 2012) | 1 line
Changed paths:
M /mrbs/trunk/web/js/edit_entry.js.php
Kept track of how many Ajax requests are outstanding on the server so that we
don't swamp the server with requests if for some reason the server is taking a
long time to process them. See SF Support Request 258.
------------------------------------------------------------------------
Index: mrbs/trunk/web/js/edit_entry.js.php
===================================================================
--- mrbs/trunk/web/js/edit_entry.js.php (revision 2392)
+++ mrbs/trunk/web/js/edit_entry.js.php (revision 2393)
@@ -218,10 +218,30 @@
// function to check whether the proposed booking would (a) conflict with
any other bookings
// and (b) conforms to the booking policies. Makes an Ajax call to
edit_entry_handler but does
// not actually make the booking.
+ //
+ // If optional is true then the check is not carried out if there's already
an
+ // outstanding request in the queue
?>
- function checkConflicts()
+ function checkConflicts(optional)
{
<?php
+ // Keep track of how many requests are still with the server. We don't
want
+ // to keep sending them if they're not coming back
+ ?>
+ if (checkConflicts.nOutstanding === undefined)
+ {
+ checkConflicts.nOutstanding = 0;
+ }
+ <?php
+ // If this is an optional request and there are already some check requests
+ // in the queue, then don't bother with this one.
+ ?>
+ if (optional && checkConflicts.nOutstanding)
+ {
+ return;
+ }
+
+ <?php
// We set a small timeout on checking the booking in order to allow time
for
// the click handler on the Submit buttons to set the data in the form.
We then
// test the data and if it is set we don't validate the booking because
we're going off
@@ -272,8 +292,10 @@
delete params[i];
}
});
-
+
+ checkConflicts.nOutstanding++;
$.post('edit_entry_handler.php', params, function(result) {
+ checkConflicts.nOutstanding--;
var conflictDiv = $('#conflict_check');
var scheduleDetails = $('#schedule_details');
var policyDetails = $('#policy_details');
@@ -984,7 +1006,7 @@
{
?>
window.setInterval(function() {
- checkConflicts();
+ checkConflicts(true);
}, <?php echo $ajax_refresh_rate * 1000 ?>);
<?php
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits