Skip to content

Commit 4aaa119

Browse files
committed
docs: embed end-of-life script in page
1 parent 335c7b2 commit 4aaa119

3 files changed

Lines changed: 46 additions & 41 deletions

File tree

‎docs/EN/Maintenance/EndOfLife.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,49 @@ To choose an AAPS version for your phone, use the [Android version guidance in t
3434
<tbody></tbody>
3535
</table>
3636
</div>
37+
38+
```{raw} html
39+
40+
<script>
41+
document.addEventListener('DOMContentLoaded', async () => {
42+
const status = document.getElementById('aaps-eol-status');
43+
if (!status) return;
44+
45+
function showRows(id, rows) {
46+
const container = document.getElementById(id);
47+
const body = container.querySelector('tbody');
48+
for (const values of rows) {
49+
const row = body.insertRow();
50+
for (const value of values) row.insertCell().textContent = value;
51+
}
52+
container.hidden = rows.length === 0;
53+
}
54+
55+
try {
56+
const response = await fetch('https://raw.githubusercontent.com/nightscout/AndroidAPS/refs/heads/versions/definition.json');
57+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
58+
const data = await response.json();
59+
if (!Array.isArray(data)) throw new Error('Invalid version data');
60+
61+
const versions = data.filter(entry =>
62+
entry && typeof entry.version === 'string' &&
63+
typeof entry.endDate === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(entry.endDate)
64+
).sort((a, b) => b.version.localeCompare(a.version, undefined, { numeric: true }));
65+
const android = data.filter(entry =>
66+
entry && Number.isInteger(entry.minAndroid) && Number.isInteger(entry.maxAndroid)
67+
).sort((a, b) => b.minAndroid - a.minAndroid);
68+
if (!versions.length && !android.length) throw new Error('No version data');
69+
70+
showRows('aaps-eol-versions', versions.map(entry => [entry.version, entry.endDate]));
71+
showRows('aaps-eol-android', android.map(entry => [
72+
entry.minAndroid === entry.maxAndroid
73+
? String(entry.minAndroid) : `${entry.minAndroid}–${entry.maxAndroid}`,
74+
typeof entry.supported === 'string' && entry.supported ? entry.supported : 'None listed'
75+
]));
76+
status.remove();
77+
} catch {
78+
status.textContent = 'Could not load AAPS version data. Please try again later.';
79+
}
80+
});
81+
</script>
82+
```

‎docs/EN/conf.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
# relative to this directory. They are copied after the builtin static files,
2929
# so a file named "default.css" will overwrite the builtin "default.css".
3030
html_static_path = ['../_static']
31-
html_js_files = ['end-of-life.js']
3231

3332
# A list of paths that contain extra templates (or templates that overwrite builtin/theme-specific templates). Relative paths
3433
# are taken as relative to the configuration directory.

‎docs/_static/end-of-life.js‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)