-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparticiones.html
More file actions
73 lines (68 loc) · 2.67 KB
/
particiones.html
File metadata and controls
73 lines (68 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>S.O.S.B.I Wizard</title>
</head>
<body>
<h1>Choose a partition</h1>
<div id="partitionList"></div>
<button onclick="window.location.href = 'os.html';">Back</button>
<button id="startBtn">Start</button>
<script>
const partitionList = document.getElementById('partitionList');
const startBtn = document.getElementById('startBtn');
function renderPartitions(parts) {
partitionList.innerHTML = '';
if (!Array.isArray(parts) || parts.length === 0) {
const p = document.createElement('p');
p.textContent = 'No partitions available';
partitionList.appendChild(p);
startBtn.disabled = true;
return;
}
parts.forEach(p => {
if (!p || !p.device) return;
if (String(p.device).toUpperCase() === 'C:') return;
const label = document.createElement('label');
const cb = document.createElement('input');
cb.type = 'checkbox';
cb.value = p.device;
label.appendChild(cb);
label.appendChild(document.createTextNode(' ' + p.device));
partitionList.appendChild(label);
partitionList.appendChild(document.createElement('br'));
});
startBtn.disabled = false;
}
async function loadState() {
try {
const resp = await fetch('state.json', { cache: 'no-store' });
if (!resp.ok) throw new Error('HTTP ' + resp.status);
const data = await resp.json();
renderPartitions(data.partitions || []);
} catch (err) {
renderPartitions([]);
console.warn('loadState error:', err);
}
}
async function postSelection() {
const selected = Array.from(partitionList.querySelectorAll('input[type="checkbox"]:checked'))
.map(cb => cb.value);
try {
await fetch('/api/state', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ selected_partitions: selected })
});
} catch (err) {
console.warn('postSelection error:', err);
}
window.location.href = 'instalacion.html';
}
startBtn.addEventListener('click', postSelection);
loadState();
</script>
</body>
</html>