5951e92e51773b552c27d3fc7110a44beae995b1
5 'require shadowsocks-libev as ss';
7 var conf
= 'shadowsocks-libev';
13 m
= new form
.Map(conf
, _('Remote Servers'),
14 _('Definition of remote shadowsocks servers. \
15 Disable any of them will also disable instances referring to it.'));
17 s
= m
.section(form
.GridSection
, 'server');
19 s
.handleLinkImport = function() {
20 var textarea
= new ui
.Textarea();
21 ui
.showModal(_('Import Links'), [
23 E('div', { class: 'right' }, [
30 class: 'btn cbi-button-action',
31 click
: ui
.createHandlerFn(this, function() {
32 textarea
.getValue().split('\n').forEach(function(s
) {
33 var config
= ss
.parse_uri(s
);
36 if (tag
&& !tag
.match(/^[a-zA-Z0-9_]+$/)) tag
= null;
37 var sid
= uci
.add(conf
, 'server', tag
);
39 Object
.keys(config
).forEach(function(k
) {
40 uci
.set(conf
, sid
, k
, config
[k
]);
45 .then(L
.bind(this.map
.load
, this.map
))
46 .then(L
.bind(this.map
.reset
, this.map
))
48 .catch(function() {});
54 s
.renderSectionAdd = function(extra_class
) {
55 var el
= form
.GridSection
.prototype.renderSectionAdd
.apply(this, arguments
);
56 el
.appendChild(E('button', {
57 'class': 'cbi-button cbi-button-add',
58 'title': _('Import Links'),
59 'click': ui
.createHandlerFn(this, 'handleLinkImport')
60 }, [ _('Import Links') ]));
64 o
= s
.option(form
.Flag
, 'disabled', _('Disable'));
71 addFooter: function() {
73 if (location
.hash
.indexOf(p
) === 0) {
74 var section_id
= location
.hash
.substring(p
.length
);
75 var editBtn
= document
.querySelector('#cbi-shadowsocks-libev-' + section_id
+ ' button.cbi-button-edit');
79 return this.super('addFooter', arguments
);