summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/htdocs')
-rwxr-xr-xmodules/luci-base/htdocs/cgi-bin/luci46
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js4
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/form.js2
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js31
4 files changed, 65 insertions, 18 deletions
diff --git a/modules/luci-base/htdocs/cgi-bin/luci b/modules/luci-base/htdocs/cgi-bin/luci
index c5c9847346..442e427d41 100755
--- a/modules/luci-base/htdocs/cgi-bin/luci
+++ b/modules/luci-base/htdocs/cgi-bin/luci
@@ -1,5 +1,41 @@
-#!/usr/bin/lua
-require "luci.cacheloader"
-require "luci.sgi.cgi"
-luci.dispatcher.indexcache = "/tmp/luci-indexcache"
-luci.sgi.cgi.run()
+#!/usr/bin/env ucode
+
+'use strict';
+
+import { stdin, stdout } from 'fs';
+
+import dispatch from 'luci.dispatcher';
+import request from 'luci.http';
+
+const input_bufsize = 4096;
+let input_available = +getenv('CONTENT_LENGTH') || 0;
+
+function read(len) {
+ if (input_available == 0) {
+ stdin.close();
+
+ return null;
+ }
+
+ let chunk = stdin.read(min(input_available, len ?? input_bufsize, input_bufsize));
+
+ if (chunk == null) {
+ input_available = 0;
+ stdin.close();
+ }
+ else {
+ input_available -= length(chunk);
+ }
+
+ return chunk;
+}
+
+function write(data) {
+ return stdout.write(data);
+}
+
+let req = request(getenv(), read, write);
+
+dispatch(req);
+
+req.close();
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 65ea6bce3c..3fc6edf29f 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -796,5 +796,7 @@ document.addEventListener('DOMContentLoaded', function() {
L.hideTooltip(ev);
});
- document.querySelectorAll('.table').forEach(cbi_update_table);
+ L.require('ui').then(function(ui) {
+ document.querySelectorAll('.table').forEach(cbi_update_table);
+ });
});
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js
index 2d540420bc..3c538b88ca 100644
--- a/modules/luci-base/htdocs/luci-static/resources/form.js
+++ b/modules/luci-base/htdocs/luci-static/resources/form.js
@@ -2259,7 +2259,7 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio
if (this.map.readonly !== true) {
ui.addValidator(nameEl, 'uciname', true, function(v) {
- var button = document.querySelector('.cbi-section-create > .cbi-button-add');
+ var button = createEl.querySelector('.cbi-section-create > .cbi-button-add');
if (v !== '') {
button.disabled = null;
return true;
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index ef6e334216..c7b7ccd773 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -3231,20 +3231,25 @@ var UITable = baseclass.extend(/** @lends LuCI.ui.table.prototype */ {
this.placeholder = placeholder;
var n = 0,
- rows = this.node.querySelectorAll('tr'),
+ rows = this.node.querySelectorAll('tr, .tr'),
trows = [],
- headings = [].slice.call(this.node.firstElementChild.querySelectorAll('th')),
- captionClasses = this.options.captionClasses;
+ headings = [].slice.call(this.node.firstElementChild.querySelectorAll('th, .th')),
+ captionClasses = this.options.captionClasses,
+ trTag = (rows[0] && rows[0].nodeName == 'DIV') ? 'div' : 'tr',
+ tdTag = (headings[0] && headings[0].nodeName == 'DIV') ? 'div' : 'td';
data.forEach(function(row) {
- trows[n] = E('tr', { 'class': 'tr' });
+ trows[n] = E(trTag, { 'class': 'tr' });
for (var i = 0; i < headings.length; i++) {
var text = (headings[i].innerText || '').trim();
- var td = trows[n].appendChild(E('td', {
+ var raw_val = Array.isArray(row[i]) ? row[i][0] : null;
+ var disp_val = Array.isArray(row[i]) ? row[i][1] : row[i];
+ var td = trows[n].appendChild(E(tdTag, {
'class': 'td',
- 'data-title': (text !== '') ? text : null
- }, (row[i] != null) ? row[i] : ''));
+ 'data-title': (text !== '') ? text : null,
+ 'data-value': raw_val
+ }, (disp_val != null) ? ((disp_val instanceof DocumentFragment) ? disp_val.cloneNode(true) : disp_val) : ''));
if (typeof(captionClasses) == 'object')
DOMTokenList.prototype.add.apply(td.classList, L.toArray(captionClasses[i]));
@@ -3267,8 +3272,8 @@ var UITable = baseclass.extend(/** @lends LuCI.ui.table.prototype */ {
this.node.removeChild(rows[n]);
if (placeholder && this.node.firstElementChild === this.node.lastElementChild) {
- var trow = this.node.appendChild(E('tr', { 'class': 'tr placeholder' })),
- td = trow.appendChild(E('td', { 'class': 'td' }, placeholder));
+ var trow = this.node.appendChild(E(trTag, { 'class': 'tr placeholder' })),
+ td = trow.appendChild(E(tdTag, { 'class': 'td' }, placeholder));
if (typeof(captionClasses) == 'object')
DOMTokenList.prototype.add.apply(td.classList, L.toArray(captionClasses[0]));
@@ -3321,8 +3326,12 @@ var UITable = baseclass.extend(/** @lends LuCI.ui.table.prototype */ {
else if (typeof( opts.sortable) == 'object')
hint = opts.sortable[index];
- if (dom.elem(value))
- value = value.innerText.trim();
+ if (dom.elem(value)) {
+ if (value.hasAttribute('data-value'))
+ value = value.getAttribute('data-value');
+ else
+ value = (value.innerText || '').trim();
+ }
switch (hint || 'auto') {
case true: