Skip to content

Commit

Permalink
index.js: fix model selection on version change
Browse files Browse the repository at this point in the history
In OpenWrt, model titles, id and even the target might be renamed.
To allow a better experience when the version changes, we now search
for a matching id/target and title.

Signed-off-by: Moritz Warning <[email protected]>
  • Loading branch information
mwarning committed Jul 5, 2023
1 parent e517d20 commit e807fb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,11 @@ function updateImages(mobj, overview) {
}

// Update model title in search box.
// Device id might change between releases.
function setModel(overview, target, id) {
if (target && id && $("#models").value.length == 0) {
if (target && id) {
const title = $("#models").value;
for (const mobj of Object.values(overview.profiles)) {
if (mobj.id === id && mobj.target === target) {
if ((mobj.target === target && mobj.id === id) || mobj.title === title) {
$("#models").value = mobj.title;
$("#models").oninput();
return;
Expand Down

0 comments on commit e807fb5

Please sign in to comment.