luci/applications/luci-app-example/htdocs/luci-static/resources/view/example/htmlview.js
Andreas Bräu 02a86624ec luci-app-example: add app
add a minimalistic example app for modern js-based apps

Signed-off-by: Andreas Bräu <ab@andi95.de>
2021-10-22 10:02:53 -10:00

30 lines
920 B
JavaScript

'use strict';
'require uci';
'require view';
return view.extend({
handleSaveApply: null,
handleSave: null,
handleReset: null,
load: function() {
return Promise.all([
uci.load('example')
]);
},
render: function(data) {
var body = E([
E('h2', _('Example HTML Page'))
]);
var sections = uci.sections('example');
var listContainer = E('div');
var list = E('ul');
list.appendChild(E('li', { 'class': 'css-class' }, ['First Option in first section: ', E('em', {}, [sections[0].first_option])]));
list.appendChild(E('li', { 'class': 'css-class' }, ['Flag in second section: ', E('em', {}, [sections[1].flag])]));
list.appendChild(E('li', { 'class': 'css-class' }, ['Select in second section: ', E('em', {}, [sections[1].select])]));
listContainer.appendChild(list);
body.appendChild(listContainer);
console.log(sections);
return body;
}
});