mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
The host pages lose their last inline scripts: the overview's charts (host_graphs.js), the New pool, New network and New interface dialogs (pool_dialog.js, network_dialog.js, interface_dialog.js), a network's and a network filter's XML editors and dialogs (network_page.js, nwfilter_page.js, nwfilters_page.js), the secrets page's labels (secrets_page.js, its texts from the view as usage_texts) and a pool's page with the ISO upload (storage_page.js). Their URLs and messages are data attributes of the elements they belong to; the upload reads its token and address from its form. No template has an inline script or an inline event handler any more.
31 lines
1.6 KiB
JavaScript
31 lines
1.6 KiB
JavaScript
// The New pool dialog (create_stg_block.html).
|
|
// the ISO pool is a directory named iso; a path follows the pool's name
|
|
// until it is edited (after the page's scripts, Bootstrap's among them)
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
var form = document.getElementById('pool-form');
|
|
var name = form.elements.namedItem('name');
|
|
var otherName = name.value;
|
|
var hasCephSecrets = "cephSecrets" in form.dataset;
|
|
form.querySelectorAll('[data-follow-name]').forEach(function (path) {
|
|
path.dataset.derived = name.value ? path.dataset.followName + name.value : '';
|
|
});
|
|
name.addEventListener('input', function () {
|
|
form.querySelectorAll('[data-follow-name]').forEach(function (path) {
|
|
var derived = name.value ? path.dataset.followName + name.value : '';
|
|
if (!path.value || path.value === path.dataset.derived) path.value = derived;
|
|
path.dataset.derived = derived;
|
|
});
|
|
});
|
|
// a new device or name: the erasing is agreed to again
|
|
form.querySelectorAll('#pool_lvm_source, #pool_name').forEach(function (field) {
|
|
field.addEventListener('input', function () { document.getElementById('pool_lvm_erase').checked = false; });
|
|
});
|
|
choiceDialog(document.getElementById('AddStgPool'), 'pool_kind', function (kind) {
|
|
var iso = kind === 'iso';
|
|
if (!name.readOnly) otherName = name.value;
|
|
name.value = iso ? 'iso' : otherName;
|
|
name.readOnly = iso;
|
|
form.elements.namedItem('stg_type').value = iso ? 'dir' : kind;
|
|
form.querySelector('button[name=create]').disabled = kind === 'rbd' && !hasCephSecrets;
|
|
});
|
|
});
|