2016-05-13 23:08:04 +08:00
|
|
|
$j(document).ready(function() {
|
2019-01-19 23:32:40 +08:00
|
|
|
// Enable or disable the Delete button depending on the selected run state
|
|
|
|
$j("#runState").change(function() {
|
|
|
|
runstate = $j(this).val();
|
|
|
|
|
|
|
|
if ( (runstate == 'stop') || (runstate == 'restart') || (runstate == 'start') || (runstate == 'default') ) {
|
2019-01-31 03:36:46 +08:00
|
|
|
$j("#btnDelete").prop("disabled", true);
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2019-01-31 03:36:46 +08:00
|
|
|
$j("#btnDelete").prop("disabled", false);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Enable or disable the Save button when entering a new state
|
|
|
|
$j("#newState").keyup(function() {
|
|
|
|
length = $j(this).val().length;
|
2019-01-31 03:36:46 +08:00
|
|
|
if ( length < 1 ) {
|
|
|
|
$j("#btnSave").prop("disabled", true);
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2019-01-31 03:36:46 +08:00
|
|
|
$j("#btnSave").prop("disabled", false);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Delete a state
|
|
|
|
$j("#btnDelete").click(function() {
|
2019-01-31 03:36:46 +08:00
|
|
|
stateStuff('delete', $j("#runState").val());
|
2019-01-19 23:32:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Save a new state
|
|
|
|
$j("#btnSave").click(function() {
|
2019-01-31 03:36:46 +08:00
|
|
|
stateStuff('save', undefined, $j("#newState").val());
|
2019-01-19 23:32:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Change state
|
|
|
|
$j("#btnApply").click(function() {
|
2019-01-31 03:36:46 +08:00
|
|
|
stateStuff('state', $j("#runState").val());
|
2019-01-19 23:32:40 +08:00
|
|
|
});
|
|
|
|
|
2019-01-31 03:36:46 +08:00
|
|
|
function stateStuff(action, runState, newState) {
|
2019-02-06 01:35:06 +08:00
|
|
|
// the state action will redirect to console
|
2019-01-19 23:32:40 +08:00
|
|
|
var formData = {
|
2019-01-31 03:36:46 +08:00
|
|
|
'view': 'state',
|
2019-01-19 23:32:40 +08:00
|
|
|
'action': action,
|
|
|
|
'apply': 1,
|
|
|
|
'runState': runState,
|
|
|
|
'newState': newState
|
|
|
|
};
|
|
|
|
|
|
|
|
$j("#pleasewait").toggleClass("hidden");
|
|
|
|
|
|
|
|
$j.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: thisUrl,
|
|
|
|
data: formData,
|
|
|
|
dataType: 'html',
|
2019-12-21 05:10:30 +08:00
|
|
|
timeout: 0
|
2019-01-19 23:32:40 +08:00
|
|
|
}).done(function(data) {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
2016-04-24 12:47:07 +08:00
|
|
|
});
|