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

83 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-09-16 21:30:45 +08:00
// Load the Server Modal HTML via Ajax call
function getServerModal(sid) {
$j.getJSON(thisUrl + '?request=modal&modal=server&id=' + sid)
.done(function(data) {
if ( $j('#ServerModal').length ) {
$j('#ServerModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
$j('#ServerModal').modal('show');
// Manage the Save button
$j('#serverSubmitBtn').click(function(evt) {
evt.preventDefault();
$j('#serverModalForm').submit();
});
})
.fail(logAjaxFail);
2020-09-16 21:30:45 +08:00
}
function enableServerModal() {
$j(".serverCol").click(function(evt) {
evt.preventDefault();
var sid = $j(this).data('sid');
getServerModal(sid);
});
$j('#NewServerBtn').click(function(evt) {
evt.preventDefault();
getServerModal(0);
});
}
2020-09-14 22:50:04 +08:00
// Load the Storage Modal HTML via Ajax call
function getStorageModal(sid) {
$j.getJSON(thisUrl + '?request=modal&modal=storage&id=' + sid)
.done(function(data) {
if ( $j('#storageModal').length ) {
$j('#storageModal').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
$j('#storageModal').modal('show');
// Manage the Save button
$j('#storageSubmitBtn').click(function(evt) {
evt.preventDefault();
$j('#storageModalForm').submit();
});
})
.fail(logAjaxFail);
2020-09-14 22:50:04 +08:00
}
function enableStorageModal() {
$j(".storageCol").click(function(evt) {
evt.preventDefault();
var sid = $j(this).data('sid');
getStorageModal(sid);
});
$j('#NewStorageBtn').click(function(evt) {
evt.preventDefault();
getStorageModal(0);
});
}
2020-10-04 06:12:44 +08:00
// Manage the Add New User button
function AddNewUser(el) {
url = el.getAttribute('data-url');
window.location.assign(url);
}
2020-09-14 22:50:04 +08:00
function initPage() {
var NewStorageBtn = $j('#NewStorageBtn');
2020-09-16 21:30:45 +08:00
var NewServerBtn = $j('#NewServerBtn');
2020-09-14 23:31:44 +08:00
2020-09-14 22:50:04 +08:00
if ( canEditSystem ) enableStorageModal();
2020-09-16 21:30:45 +08:00
if ( canEditSystem ) enableServerModal();
2020-09-14 23:31:44 +08:00
2020-09-14 22:50:04 +08:00
NewStorageBtn.prop('disabled', !canEditSystem);
2020-09-16 21:30:45 +08:00
NewServerBtn.prop('disabled', !canEditSystem);
2020-09-14 22:50:04 +08:00
}
$j(document).ready(function() {
initPage();
});