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

chiiph at torproject.org chiiph at torproject.org
Tue Sep 25 22:29:33 UTC 2012


commit a1decc38737c83e579993d8ead1f527ce3a84925
Author: Feroze Naina <ferozenaina at gmail.com>
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() {



More information about the tor-commits mailing list