diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-12-15 23:08:17 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-12-15 23:08:17 +0100 |
commit | f25c4e07bc9642e0491d3a4ab3942a69545891e9 (patch) | |
tree | e61fe5d6376b55eb71754401ea4730675d4bd2b5 /modules/luci-base/htdocs | |
parent | 19b85c34fcac8ad9b2829b4e034d7fefa42fb145 (diff) | |
parent | 986baa5ccee13692e9c1ef5a23535e15b7fcb948 (diff) |
Merge pull request #564 from cshore/pull-request-app-firewall-timedate
Pull request app firewall timedate
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 8a3cb6fca7..4b7227f1a4 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -322,6 +322,47 @@ var cbi_validators = { 'phonedigit': function() { return (this.match(/^[0-9\*#!\.]+$/) != null); + }, + 'timehhmmss': function() + { + return (this.match(/^[0-6][0-9]:[0-6][0-9]:[0-6][0-9]$/) != null); + }, + 'dateyyyymmdd': function() + { + if (this == null) { + return false; + } + if (this.match(/^(\d\d\d\d)-(\d\d)-(\d\d)/)) { + var year = RegExp.$1; + var month = RegExp.$2; + var day = RegExp.$2 + + var days_in_month = [ 31, 28, 31, 30, 31, 30, 31, 31, 30 , 31, 30, 31 ]; + function is_leap_year(year) { + return ((year % 4) == 0) && ((year % 100) != 0) || ((year % 400) == 0); + } + function get_days_in_month(month, year) { + if ((month == 2) && is_leap_year(year)) { + return 29; + } else { + return days_in_month[month]; + } + } + /* Firewall rules in the past don't make sense */ + if (year < 2015) { + return false; + } + if ((month <= 0) || (month > 12)) { + return false; + } + if ((day <= 0) || (day > get_days_in_month(month, year))) { + return false; + } + return true; + + } else { + return false; + } } }; |