zoneminder/web/skins/classic/views/js/state.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-05-13 23:08:04 +08:00
$j(document).ready(function() {
// 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();
if ( (runstate == 'stop') || (runstate == 'restart') || (runstate == 'start') || (runstate == 'default') ) {
2016-05-13 23:08:04 +08:00
$j("#btnDelete").prop( "disabled", true );
} else {
2016-05-13 23:08:04 +08:00
$j("#btnDelete").prop( "disabled", false );
}
});
// 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;
console.log(length);
if (length < 1) {
2016-05-13 23:08:04 +08:00
$j("#btnSave").prop( "disabled", true );
} else {
2016-05-13 23:08:04 +08:00
$j("#btnSave").prop( "disabled", false );
}
});
// Delete a state
2016-05-13 23:08:04 +08:00
$j("#btnDelete").click(function() {
stateStuff( 'delete', $j("#runState").val( ));
});
// Save a new state
2016-05-13 23:08:04 +08:00
$j("#btnSave").click(function() {
stateStuff( 'save', undefined, $j("#newState").val() );
});
// Change state
2016-05-13 23:08:04 +08:00
$j("#btnApply").click(function() {
stateStuff( 'state', $j("#runState").val() );
});
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-05-13 23:08:04 +08:00
$j.ajax({
type: 'POST',
2017-10-02 23:55:17 +08:00
url: thisUrl,
data: formData,
dataType: 'html',
enocde: true
}).done(function(data) {
location.reload();
});
}
});