From: Jo-Philipp Wich Date: Sun, 13 Apr 2014 20:36:16 +0000 (+0200) Subject: luci2: add get_first(), set_first() and unset_first() helper to L.UCIContext X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci2%2Fui.git;a=commitdiff_plain;h=e314622aa9ad41f5d3083dfd21ff0f61175c237f;hp=2823ef651678ef296faf68eceb51aa5afaae4e83 luci2: add get_first(), set_first() and unset_first() helper to L.UCIContext --- diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js index ea64074..5947791 100644 --- a/luci2/htdocs/luci2/luci2.js +++ b/luci2/htdocs/luci2/luci2.js @@ -1109,6 +1109,35 @@ function LuCI2() return this.set(conf, sid, opt, undefined); }, + get_first: function(conf, type, opt) + { + var sid = undefined; + + L.uci.sections(conf, type, function(s) { + if (typeof(sid) != 'string') + sid = s['.name']; + }); + + return this.get(conf, sid, opt); + }, + + set_first: function(conf, type, opt, val) + { + var sid = undefined; + + L.uci.sections(conf, type, function(s) { + if (typeof(sid) != 'string') + sid = s['.name']; + }); + + return this.set(conf, sid, opt, val); + }, + + unset_first: function(conf, type, opt) + { + return this.set_first(conf, type, opt, undefined); + }, + _reload: function() { var pkgs = [ ];