mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
The VM page's thirteen inline script blocks and its inline handlers move to static files: instance_page.js (tabs, OS details, clone names and MACs, Add disk dialog, boot order, host devices, migrate plan, console window, switches that send their form), instance_stats.js (charts and the Logs view) and instance_status.js (the reload when the VM's state changes). Their values and messages come as data attributes of the elements they belong to, page-wide ones on #vm-summary; a form marked data-please-wait shows the please-wait dialog. Three blocks that did nothing are dropped: popovers (the page has none), the video model preselection (the server selects it) and the delete form's poll stop (that form is on the destroy page). The HTML sink inventory now also reads the app's own scripts.
13 lines
675 B
JavaScript
13 lines
675 B
JavaScript
// The VM page reloads when the VM's state changes (instance.html, #vm-summary).
|
|
backgroundJobRunning = false;
|
|
// not "status": that is window.status, which the browser may not keep
|
|
var vm_summary = document.getElementById("vm-summary");
|
|
var vm_status = Number(vm_summary.dataset.status);
|
|
var status_poll = pollWhileVisible(5000, function () {
|
|
return $.getJSON(vm_summary.dataset.statusUrl);
|
|
}, function get_status(data) {
|
|
// an XML edit not saved yet stays: the reload waits until it is saved or undone
|
|
if (data['status'] != vm_status && !backgroundJobRunning && !(window.xmlEditUnsaved && window.xmlEditUnsaved())) {
|
|
window.location.reload();
|
|
}
|
|
});
|