2017-05-11 01:16:08 +08:00
|
|
|
<<<<<<< HEAD
|
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();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
2017-05-11 01:16:08 +08:00
|
|
|
=======
|
2008-09-30 16:41:23 +08:00
|
|
|
function checkState( element )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
|
|
|
var form = element.form;
|
|
|
|
|
|
|
|
var minIndex = running?2:1;
|
2008-10-07 17:02:17 +08:00
|
|
|
if ( form.runState.selectedIndex < minIndex )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
|
|
|
form.saveBtn.disabled = true;
|
|
|
|
form.deleteBtn.disabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
form.saveBtn.disabled = false;
|
|
|
|
form.deleteBtn.disabled = false;
|
|
|
|
}
|
2015-08-26 23:21:29 +08:00
|
|
|
|
2008-10-07 17:02:17 +08:00
|
|
|
if ( form.newState.value != '' )
|
2008-07-14 21:54:50 +08:00
|
|
|
form.saveBtn.disabled = false;
|
2015-08-26 23:21:29 +08:00
|
|
|
|
|
|
|
// PP if we are in 'default' state, disable delete
|
|
|
|
// you can still save
|
|
|
|
if (element.value.toLowerCase() == 'default' )
|
|
|
|
{
|
|
|
|
form.saveBtn.disabled = false;
|
2017-03-18 15:00:51 +08:00
|
|
|
form.deleteBtn.disabled = true;
|
2015-08-26 23:21:29 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function saveState( element )
|
|
|
|
{
|
|
|
|
var form = element.form;
|
2015-08-26 23:21:29 +08:00
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
form.view.value = currentView;
|
|
|
|
form.action.value = 'save';
|
|
|
|
form.submit();
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteState( element )
|
|
|
|
{
|
|
|
|
var form = element.form;
|
|
|
|
form.view.value = currentView;
|
|
|
|
form.action.value = 'delete';
|
|
|
|
form.submit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( applying )
|
|
|
|
{
|
|
|
|
function submitForm()
|
|
|
|
{
|
|
|
|
$('contentForm').submit();
|
|
|
|
}
|
|
|
|
window.addEvent( 'domready', function() { submitForm.delay( 1000 ); } );
|
|
|
|
}
|
2017-05-11 01:16:08 +08:00
|
|
|
>>>>>>> master
|