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

63 lines
1.5 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
$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);
} else {
2019-01-31 03:36:46 +08:00
$j("#btnDelete").prop("disabled", false);
}
});
// 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);
} else {
2019-01-31 03:36:46 +08:00
$j("#btnSave").prop("disabled", false);
}
});
// Delete a state
$j("#btnDelete").click(function() {
2019-01-31 03:36:46 +08:00
stateStuff('delete', $j("#runState").val());
});
// Save a new state
$j("#btnSave").click(function() {
2019-01-31 03:36:46 +08:00
stateStuff('save', undefined, $j("#newState").val());
});
// Change state
$j("#btnApply").click(function() {
2019-01-31 03:36:46 +08:00
stateStuff('state', $j("#runState").val());
});
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
var formData = {
2019-01-31 03:36:46 +08:00
'view': 'state',
'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
}).done(function(data) {
location.reload();
});
}
});