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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Delete a state
|
2016-05-13 23:08:04 +08:00
|
|
|
$j("#btnDelete").click(function() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
StateStuff( 'state', $j("#runState").val() );
|
2016-04-24 12:47:07 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
function StateStuff( action, runState, newState ){
|
|
|
|
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',
|
|
|
|
url: '/index.php',
|
|
|
|
data: formData,
|
|
|
|
dataType: 'html',
|
|
|
|
enocde: true
|
|
|
|
}).done(function(data) {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|