-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos.html
More file actions
97 lines (91 loc) · 3.47 KB
/
os.html
File metadata and controls
97 lines (91 loc) · 3.47 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!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 system</h1>
<h2>Backup first. Install safe and simple.</h2>
<div>
<label><input type="radio" name="source" value="list" checked> System list</label>
<select id="osSelect"></select>
</div>
<div>
<label><input type="radio" name="source" value="url"> Manual URL</label>
<input id="urlInput" type="text" placeholder="https://example.com/os.iso">
</div>
<div>
<label><input type="radio" name="source" value="file"> Archivo descargado</label>
<input id="fileInput" type="text" placeholder="D:\\descargas\\windows10.iso">
</div>
<button onclick="window.location.href = 'usb.html';">Back</button>
<button id="nextBtn">Next</button>
<script>
const osSelect = document.getElementById('osSelect');
const nextBtn = document.getElementById('nextBtn');
const urlInput = document.getElementById('urlInput');
const fileInput = document.getElementById('fileInput');
function getSourceValue() {
const selected = document.querySelector('input[name="source"]:checked');
return selected ? selected.value : 'list';
}
function setOptions(systems) {
osSelect.innerHTML = '';
if (!systems || typeof systems !== 'object') {
const opt = document.createElement('option');
opt.value = '';
opt.textContent = 'No systems available';
osSelect.appendChild(opt);
osSelect.disabled = true;
nextBtn.disabled = true;
return;
}
Object.keys(systems).forEach(k => {
const opt = document.createElement('option');
opt.value = k;
opt.textContent = systems[k].nombre || k;
osSelect.appendChild(opt);
});
osSelect.disabled = false;
nextBtn.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();
setOptions(data.systems);
} catch (err) {
setOptions(null);
console.warn('loadState error:', err);
}
}
async function postSelection() {
const source = getSourceValue();
let selected = '';
if (source === 'url') {
selected = urlInput.value.trim();
} else if (source === 'file') {
selected = fileInput.value.trim();
} else {
selected = osSelect.value;
}
if (!selected) return;
try {
await fetch('/api/state', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ selected_system: selected })
});
} catch (err) {
console.warn('postSelection error:', err);
}
window.location.href = 'particiones.html';
}
nextBtn.addEventListener('click', postSelection);
loadState();
</script>
</body>
</html>