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