[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [vidalia-plugins/master] Add sanity checks for bandwidth scheduler



commit a1decc38737c83e579993d8ead1f527ce3a84925
Author: Feroze Naina <ferozenaina@xxxxxxxxx>
Date:   Mon Aug 20 18:56:18 2012 +0530

    Add sanity checks for bandwidth scheduler
---
 bwscheduler/bwscheduler.js |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/bwscheduler/bwscheduler.js b/bwscheduler/bwscheduler.js
index 2ce553b..03d96c9 100644
--- a/bwscheduler/bwscheduler.js
+++ b/bwscheduler/bwscheduler.js
@@ -156,7 +156,29 @@ var bwscheduler = {
 
     enableApply: function() {
         this.btnDiscard.enabled = true;
-        this.btnApply.enabled = true;
+        if (this.sanityCheck())
+            this.btnApply.enabled = true;
+        else
+            this.btnApply.enabled = false;
+    },
+
+    sanityCheck: function() {
+        for (var i = 0; i < this.customwidget.length; i++) {
+            if (this.timeStart[i].time > this.timeEnd[i].time) {
+                this.lineError[i].setText("Start Time must be lesser than End Time");
+                this.lineError[i].show();
+                return false;
+            }
+            if (this.cmbUnit[i].currentText == "KB") {
+                if (this.spinRate[i].value > 0 && this.spinRate[i].value < 25) {
+                    this.lineError[i].setText("Bandwidth Rate must be atleast 25 KB");
+                    this.lineError[i].show();
+                    return false;
+                }
+            }
+        }
+
+        return true;
     },
 
     enableRemove: function() {

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits