From e314622aa9ad41f5d3083dfd21ff0f61175c237f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 13 Apr 2014 22:36:16 +0200 Subject: [PATCH 1/1] luci2: add get_first(), set_first() and unset_first() helper to L.UCIContext --- luci2/htdocs/luci2/luci2.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 = [ ]; -- 2.30.2