+ switch (c[0])
+ {
+ case 'order':
+ break;
+
+ case 'remove':
+ if (c.length < 3)
+ log.push('uci delete %s.<del>%s</del>'.format(config, c[1]));
+ else
+ log.push('uci delete %s.%s.<del>%s</del>'.format(config, c[1], c[2]));
+ break;
+
+ case 'rename':
+ if (c.length < 4)
+ log.push('uci rename %s.<ins>%s=<strong>%s</strong></ins>'.format(config, c[1], c[2], c[3]));
+ else
+ log.push('uci rename %s.%s.<ins>%s=<strong>%s</strong></ins>'.format(config, c[1], c[2], c[3], c[4]));
+ break;
+
+ case 'add':
+ log.push('uci add %s <ins>%s</ins> (= <ins><strong>%s</strong></ins>)'.format(config, c[2], c[1]));
+ break;
+
+ case 'list-add':
+ log.push('uci add_list %s.%s.<ins>%s=<strong>%s</strong></ins>'.format(config, c[1], c[2], c[3], c[4]));
+ break;
+
+ case 'list-del':
+ log.push('uci del_list %s.%s.<del>%s=<strong>%s</strong></del>'.format(config, c[1], c[2], c[3], c[4]));
+ break;
+
+ case 'set':
+ if (c.length < 4)
+ log.push('uci set %s.<ins>%s=<strong>%s</strong></ins>'.format(config, c[1], c[2]));
+ else
+ log.push('uci set %s.%s.<ins>%s=<strong>%s</strong></ins>'.format(config, c[1], c[2], c[3], c[4]));
+ break;
+ }
+ }
+
+ html += '<code>/etc/config/%s</code><pre class="uci-changes">%s</pre>'.format(config, log.join('\n'));
+ n += changes[config].length;
+ }
+
+ if (n > 0)
+ $('#changes')
+ .empty()
+ .show()
+ .append($('<a />')
+ .attr('href', '#')
+ .addClass('label')
+ .addClass('notice')
+ .text(_luci2.trcp('Pending configuration changes', '1 change', '%d changes', n).format(n))
+ .click(function(ev) {
+ _luci2.ui.dialog(_luci2.tr('Staged configuration changes'), html, { style: 'close' });
+ ev.preventDefault();
+ }));
+ else
+ $('#changes')
+ .hide();
+ });
+ },
+
+ init: function()
+ {
+ _luci2.ui.loading(true);
+
+ $.when(
+ _luci2.ui.updateHostname(),
+ _luci2.ui.updateChanges(),
+ _luci2.ui.renderMainMenu()
+ ).then(function() {
+ _luci2.ui.renderView(_luci2.globals.defaultNode).then(function() {
+ _luci2.ui.loading(false);
+ })
+ });
+ },
+
+ button: function(label, style, title)
+ {
+ style = style || 'default';
+
+ return $('<button />')
+ .attr('type', 'button')
+ .attr('title', title ? title : '')
+ .addClass('btn btn-' + style)
+ .text(label);
+ }
+ };
+
+ this.ui.AbstractWidget = Class.extend({
+ i18n: function(text) {
+ return text;
+ },
+
+ label: function() {
+ var key = arguments[0];
+ var args = [ ];
+
+ for (var i = 1; i < arguments.length; i++)
+ args.push(arguments[i]);
+
+ switch (typeof(this.options[key]))
+ {
+ case 'undefined':
+ return '';
+
+ case 'function':
+ return this.options[key].apply(this, args);
+
+ default:
+ return ''.format.apply('' + this.options[key], args);
+ }
+ },
+
+ toString: function() {
+ return $('<div />').append(this.render()).html();
+ },
+
+ insertInto: function(id) {
+ return $(id).empty().append(this.render());
+ },
+
+ appendTo: function(id) {
+ return $(id).append(this.render());
+ }
+ });
+
+ this.ui.view = this.ui.AbstractWidget.extend({
+ _fetch_template: function()
+ {
+ return $.ajax(_luci2.globals.resource + '/template/' + this.options.name + '.htm', {
+ method: 'GET',
+ cache: true,
+ dataType: 'text',
+ success: function(data) {
+ data = data.replace(/<%([#:=])?(.+?)%>/g, function(match, p1, p2) {