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