From 815824b36be57bfc05146ff69ee6038c87417421 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 17 Apr 2020 09:30:20 +0200 Subject: [PATCH] luci-base: ui.js: order indicators by ID value Signed-off-by: Jo-Philipp Wich (cherry picked from commit 01d8283ecea730191ce41302acb7ecd1aaf0631f) --- .../htdocs/luci-static/resources/ui.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index d0045007b..47f3e9892 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -3205,12 +3205,23 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { } var handlerFn = (typeof(handler) == 'function') ? handler : null, - indicatorElem = indicatorDiv.querySelector('span[data-indicator="%s"]'.format(id)) || - indicatorDiv.appendChild(E('span', { + indicatorElem = indicatorDiv.querySelector('span[data-indicator="%s"]'.format(id)); + + if (indicatorElem == null) { + var beforeElem = null; + + for (beforeElem = indicatorDiv.firstElementChild; + beforeElem != null; + beforeElem = beforeElem.nextElementSibling) + if (beforeElem.getAttribute('data-indicator') > id) + break; + + indicatorElem = indicatorDiv.insertBefore(E('span', { 'data-indicator': id, 'data-clickable': handlerFn ? true : null, 'click': handlerFn - }, [''])); + }, ['']), beforeElem); + } if (label == indicatorElem.firstChild.data && style == indicatorElem.getAttribute('data-style')) return false; -- 2.25.1