修复表达式错误BUG,如果后一项不为* 那么前一项肯定不为*,要不然就成了每秒执行了

Signed-off-by: 小马1988 <1010895047@qq.com>
This commit is contained in:
小马1988 2022-08-27 11:00:08 +00:00 committed by Gitee
parent 5a3714e9bc
commit 11bf71e937
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 33 additions and 1 deletions

View File

@ -922,5 +922,37 @@ function gen_cron() {
+ $("#v_month").val() + " " + $("#v_month").val() + " "
+ $("#v_week").val() + " " + $("#v_week").val() + " "
+ $("#v_year").val(); + $("#v_year").val();
$("#cron").val(str); var vals = $("input[name^='v_']");
var cron = $("#cron");
var item = [];
vals.each(function() {
item.push(this.value);
});
// 修复表达式错误BUG如果后一项不为* 那么前一项肯定不为*,要不然就成了每秒执行了
// 获取当前选中tab
var currentIndex = 0;
$(".nav-tabs>li").each(function(i, item) {
if ($(item).hasClass("active")) {
currentIndex = i;
return false;
}
});
// 当前选中项之前的如果为*则都设置成0
for (var i = currentIndex; i >= 1; i--) {
if (item[i] != "*" && item[i - 1] == "*") {
item[i - 1] = "0";
}
}
// 当前选中项之后的如果不为*则都设置成*
if (item[currentIndex] == "*") {
for (var i = currentIndex + 1; i < item.length; i++) {
if (i == 5) {
item[i] = "?";
} else {
item[i] = "*";
}
}
}
cron.val(item.join(" ")).change();
} }