summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-04-13 22:36:16 +0200
committerJo-Philipp Wich <jow@openwrt.org>2014-04-13 22:36:16 +0200
commite314622aa9ad41f5d3083dfd21ff0f61175c237f (patch)
treebd3725adfd25396e03f426eda17cb9459f9a7abc
parent2823ef651678ef296faf68eceb51aa5afaae4e83 (diff)
downloadluci2-ui-e314622aa9ad41f5d3083dfd21ff0f61175c237f.tar.gz
luci2: add get_first(), set_first() and unset_first() helper to L.UCIContext
-rw-r--r--luci2/htdocs/luci2/luci2.js29
1 files changed, 29 insertions, 0 deletions
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 = [ ];