Skip to content

Commit

Permalink
Update to allow limiting of Period choices
Browse files Browse the repository at this point in the history
Taken from the uncommitted PR here  shawnchin#17
This allows us to supply the Periods that can be selected
  • Loading branch information
mike-azility authored Jul 8, 2023
1 parent 59a6e7c commit c4a486c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cron/jquery-cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
closeEffect : "slide",
hideOnMouseOut : true
},
periods : ["minute", "hour", "day", "week", "month", "year"],
url_set : undefined,
customValues : undefined,
onChange: undefined, // callback function each time value changes
Expand Down Expand Up @@ -139,13 +140,6 @@
str_opt_dow += "<option value='"+i+"'>" + days[i] + "</option>\n";
}

// options for period
var str_opt_period = "";
var periods = ["minute", "hour", "day", "week", "month", "year"];
for (var i = 0; i < periods.length; i++) {
str_opt_period += "<option value='"+periods[i]+"'>" + periods[i] + "</option>\n";
}

// display matrix
var toDisplay = {
"minute" : [],
Expand Down Expand Up @@ -298,6 +292,12 @@

// ---- define select boxes in the right order -----

// options for period
var str_opt_period = "";
for (var i = 0; i < o.periods.length; i++) {
str_opt_period += "<option value='" + o.periods[i] + "'>" + o.periods[i] + "</option>\n";
}

var block = [], custom_periods = "", cv = o.customValues;
if (defined(cv)) { // prepend custom values if specified
for (var key in cv) {
Expand Down Expand Up @@ -389,9 +389,9 @@
var block = this.data("block");
var useGentleSelect = o.useGentleSelect;
var t = getCronType(cron_str, o);

if (!defined(t)) { return false; }

if (defined(o.customValues) && o.customValues.hasOwnProperty(t)) {
t = o.customValues[t];
} else {
Expand Down Expand Up @@ -420,7 +420,7 @@
}
}
}

// trigger change event
var bp = block["period"].find("select").val(t);
if (useGentleSelect) bp.gentleSelect("update");
Expand Down

0 comments on commit c4a486c

Please sign in to comment.