releases.js: move list insertion code together

This commit is contained in:
Daniel Micay 2019-04-29 11:21:05 -04:00
parent ed1231475e
commit aa1f670bae

View File

@ -50,8 +50,6 @@ for (const channel of channels) {
const updateFilename = device + "-ota_update-" + metadata[0] + ".zip"; const updateFilename = device + "-ota_update-" + metadata[0] + ".zip";
const updateUrl = baseUrl + updateFilename; const updateUrl = baseUrl + updateFilename;
const list = document.getElementById(channel);
const model = deviceModel(device); const model = deviceModel(device);
const release = document.createElement("div"); const release = document.createElement("div");
@ -73,13 +71,13 @@ for (const channel of channels) {
release.appendChild(document.createElement("br")); release.appendChild(document.createElement("br"));
release.appendChild(createLink(updateUrl, updateFilename)); release.appendChild(createLink(updateUrl, updateFilename));
const list = document.getElementById(channel);
for (const item of list.children) { for (const item of list.children) {
if (model < item.dataset.model) { if (model < item.dataset.model) {
list.insertBefore(release, item); list.insertBefore(release, item);
return; return;
} }
} }
list.appendChild(release); list.appendChild(release);
}); });
} }