From dc1fcde002830caaca12fbb470f5a8ba82c810ba Mon Sep 17 00:00:00 2001 From: Matt Gambogi Date: Fri, 29 Mar 2013 19:12:44 -0400 Subject: [PATCH] Prevents negative drop delays Corrected error message handling --- js/websocket.js | 19 ++++++++++++++----- lib/views/webdrink.php | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/js/websocket.js b/js/websocket.js index 3e4d80b..a3c8523 100644 --- a/js/websocket.js +++ b/js/websocket.js @@ -56,8 +56,12 @@ WebsocketConn.prototype.init_click_events = function(){ var drop_data = pending_drop; var delay = $(this).parent().parent().find('input[type="number"]').val(); - - self.drop(drop_data.slot_num, drop_data.machine_alias, delay); + if(~~delay >= 0){ + self.drop(drop_data.slot_num, drop_data.machine_alias, delay); + } + else{ + $(this).closest('#drop_modal').find('.form-feedback').html("That's in the past now, you retard."); + } }); // Hitting 'enter' on the delay field @@ -65,9 +69,14 @@ WebsocketConn.prototype.init_click_events = function(){ var drop_data = pending_drop; var delay = $(this).parent().parent().find('input[type="number"]').val(); - - self.drop(drop_data.slot_num, drop_data.machine_alias, delay); - }); + + if(~~delay >= 0){ + self.drop(drop_data.slot_num, drop_data.machine_alias, delay); + } + else{ + $(this).closest('#drop_modal').find('.form-feedback').html("That's in the past now, you retard."); + } + }); $('#drop_modal input:button[btn-action="cancel_drop"]').on('click', function(){ $('#drop_modal').modal('hide'); diff --git a/lib/views/webdrink.php b/lib/views/webdrink.php index c14a88b..874dacc 100644 --- a/lib/views/webdrink.php +++ b/lib/views/webdrink.php @@ -147,6 +147,8 @@