Skip to content

Commit 6d04e56

Browse files
committed
luci-app-argon-config: cleanup
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
1 parent 0c2f220 commit 6d04e56

File tree

1 file changed

+22
-38
lines changed
  • applications/luci-app-argon-config/htdocs/luci-static/resources/view

1 file changed

+22
-38
lines changed

applications/luci-app-argon-config/htdocs/luci-static/resources/view/argon-config.js

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,54 +57,38 @@ return view.extend({
5757
o.value('wallhaven', _('Wallhaven'));
5858
o.default = 'bing';
5959
o.rmempty = false;
60-
o.cfgvalue = function(section_id) {
61-
let value = uci.get('argon', section_id, 'online_wallpaper');
62-
if (!value) return 'bing';
63-
// 分割存储的值,返回wallpaper来源
64-
return value.split('_')[0];
65-
}
66-
o.write = function(section_id, value) {
67-
// 获取collection_id的值
68-
let collectionId = this.map.lookupOption('collection_id', section_id)[0].formvalue(section_id);
69-
// 如果有collection_id,则合并存储
70-
if (collectionId && (value === 'unsplash' || value === 'wallhaven')) {
71-
value = value + '_' + collectionId;
72-
}
73-
uci.set('argon', section_id, 'online_wallpaper', value);
74-
}
60+
o.cfgvalue = function(section_id) {
61+
let value = uci.get(data[0], section_id, 'online_wallpaper') || 'bing';
62+
return value.split('_')[0];
63+
}
64+
o.write = function(section_id, value) {
65+
let collection_id = this.section.formvalue(section_id, 'collection_id');
66+
if (collection_id && (value === 'unsplash' || value === 'wallhaven')) {
67+
value = value + '_' + collection_id;
68+
}
69+
uci.set(data[0], section_id, 'online_wallpaper', value);
70+
}
7571

7672
o = s.option(form.Value, 'collection_id', _('Collection ID'), _('Collection ID for Unsplash or Wallhaven.'));
73+
o.datatype = 'uinteger';
7774
o.depends('online_wallpaper', 'unsplash');
7875
o.depends('online_wallpaper', 'wallhaven');
79-
o.datatype = 'uinteger';
80-
o.rmempty = true;
81-
o.cfgvalue = function(section_id) {
82-
let value = uci.get('argon', section_id, 'online_wallpaper');
83-
if (!value || !value.includes('_')) return '';
84-
// 分割存储的值,返回collection_id
85-
return value.split('_')[1];
86-
}
87-
o.write = function(section_id, value) {
88-
// 获取online_wallpaper的值
89-
let online_wallpaper = this.map.lookupOption('online_wallpaper', section_id)[0].formvalue(section_id);
90-
// 如果有collection_id,则合并存储
91-
if (value && (online_wallpaper === 'unsplash' || online_wallpaper === 'wallhaven')) {
92-
online_wallpaper = online_wallpaper + '_' + value;
93-
}
94-
uci.set('argon', section_id, 'online_wallpaper', online_wallpaper);
95-
}
76+
o.cfgvalue = function(section_id) {
77+
let value = uci.get(data[0], section_id, 'online_wallpaper');
78+
if (!value || !value.includes('_'))
79+
return '';
80+
81+
return value.split('_')[1];
82+
}
83+
o.write = function() { };
9684

9785
o = s.option(form.Value, 'use_api_key', _('API key'), _('Specify API key for Unsplash or Wallhaven.'));
9886
o.depends('online_wallpaper', 'unsplash');
9987
o.depends('online_wallpaper', 'wallhaven');
10088

101-
o = s.option(form.ListValue, 'use_exact_resolution', _('Resolutions Tag'),
102-
_('Use exact resolution or atleast 1080P for Wallhaven.'));
103-
o.value('0', _('Atleast'));
104-
o.value('1', _('Exact'));
89+
o = s.option(form.Flag, 'use_exact_resolution', _('Use exact resolution'), _('Use exact resolution or at least 1080P for Wallhaven.'));
10590
o.default = '1';
106-
o.depends('online_wallpaper', 'wallhaven');
107-
o.rmempty = true;
91+
o.depends('online_wallpaper', 'wallhaven');
10892

10993
o = s.option(form.ListValue, 'mode', _('Theme mode'));
11094
o.value('normal', _('Follow system'));

0 commit comments

Comments
 (0)