Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Chang <[email protected]>
  • Loading branch information
aa65535 committed Sep 6, 2018
1 parent 77758fb commit c5897fd
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 125 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2016-2017 Jian Chang <[email protected]>
# Copyright (C) 2016-2018 Jian Chang <[email protected]>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
Expand All @@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-shadowsocks
PKG_VERSION:=1.9.0
PKG_VERSION:=1.9.1
PKG_RELEASE:=1

PKG_LICENSE:=GPLv3
Expand Down
5 changes: 1 addition & 4 deletions files/luci/model/cbi/shadowsocks/general.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Copyright (C) 2014-2017 Jian Chang <[email protected]>
-- Copyright (C) 2014-2018 Jian Chang <[email protected]>
-- Licensed to the public under the GNU General Public License v3.

local m, s, o
Expand Down Expand Up @@ -82,7 +82,6 @@ if has_redir then
s.anonymous = true

o = s:option(DynamicList, "main_server", translate("Main Server"))
o.template = "shadowsocks/dynamiclist"
o:value("nil", translate("Disable"))
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
o.default = "nil"
Expand Down Expand Up @@ -116,7 +115,6 @@ if has_local then
s.anonymous = true

o = s:option(DynamicList, "server", translate("Server"))
o.template = "shadowsocks/dynamiclist"
o:value("nil", translate("Disable"))
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
o.default = "nil"
Expand All @@ -139,7 +137,6 @@ if has_tunnel then
s.anonymous = true

o = s:option(DynamicList, "server", translate("Server"))
o.template = "shadowsocks/dynamiclist"
o:value("nil", translate("Disable"))
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
o.default = "nil"
Expand Down
98 changes: 0 additions & 98 deletions files/luci/view/shadowsocks/dynamiclist.htm

This file was deleted.

77 changes: 72 additions & 5 deletions files/luci/view/shadowsocks/general.htm
Original file line number Diff line number Diff line change
@@ -1,21 +1,88 @@
<%#
Copyright (C) 2017 Jian Chang <aa65535@live.com>
Copyright (C) 2017-2018 Jian Chang <aa65535@live.com>
Licensed to the public under the GNU General Public License v3.
-%>

<% include("cbi/map") %>

<script type="text/javascript">//<![CDATA[
(function() {
window.cbi_combobox = function(id, values, def, man, focus) {
var selid = "cbi.combobox." + id;
if (document.getElementById(selid)) {
return;
}

var obj = document.getElementById(id);
var sel = document.createElement("select");
sel.id = selid;
sel.index = obj.index;
sel.className = obj.className.replace(/cbi-input-text/, 'cbi-input-select');

if (obj.nextSibling) {
obj.parentNode.insertBefore(sel, obj.nextSibling);
} else {
obj.parentNode.appendChild(sel);
}

var dt = obj.getAttribute('cbi_datatype');
var op = obj.getAttribute('cbi_optional');

if (!values[obj.value]) {
if (obj.value != "") {
var opt = document.createElement("option");
opt.value = obj.value;
opt.selected = "selected";
opt.appendChild(document.createTextNode(obj.value));
sel.appendChild(opt);
}
}

for (var i in values) {
var opt = document.createElement("option");
opt.value = i;

if (obj.value == i) {
opt.selected = "selected";
}

opt.appendChild(document.createTextNode(values[i]));
sel.appendChild(opt);
}

obj.style.display = "none";

if (dt)
cbi_validate_field(sel, op == 'true', dt);

cbi_bind(sel, "change", function() {
obj.value = sel.options[sel.selectedIndex].value;

try {
cbi_d_update();
} catch (e) {
//Do nothing
}
})

// Retrigger validation in select
if (focus !== false) {
sel.focus();
sel.blur();
}
};

var elements = {
ss_redir: document.getElementById("_redir_status"),
ss_local: document.getElementById("_local_status"),
ss_tunnel: document.getElementById("_tunnel_status"),
};
XHR.poll(5, "<%=luci.dispatcher.build_url("admin", "services", "shadowsocks", "status")%>", null, function(x, status) {
for (var k in elements) {
if (elements[k]) {
elements[k].textContent = status[k] ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
XHR.poll(5, "<%=luci.dispatcher.build_url("admin", "services", "shadowsocks", "status")%>", null, function(xhr, status) {
if (xhr.status === 200) {
for (var k in elements) {
if (elements[k]) {
elements[k].textContent = status[k] ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
}
}
}
});
Expand Down
32 changes: 16 additions & 16 deletions files/luci/view/shadowsocks/servers-details.htm
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<%#
Copyright (C) 2017 Jian Chang <aa65535@live.com>
Copyright (C) 2017-2018 Jian Chang <aa65535@live.com>
Licensed to the public under the GNU General Public License v3.
-%>

<% include("cbi/map") %>

<script type="text/javascript">//<![CDATA[
(function() {
var getElementById = function(id) {
return document.getElementById("cbid.<%=self.config%>.<%=self.sid%>." + id);
};
var password = getElementById("password");
var key = getElementById("key");
(function($) {
var password = $("password");
var key = $("key");
var form = key.form;
var checkCryptoConfig = function() {
password.className = password.className.replace(/ cbi-input-invalid/g, '');
key.className = key.className.replace(/ cbi-input-invalid/g, '');
password.className = password.className.replace(/ cbi-input-invalid/g, "");
key.className = key.className.replace(/ cbi-input-invalid/g, "");
if (password.value.length == 0 && key.value.length == 0) {
password.className += ' cbi-input-invalid';
key.className += ' cbi-input-invalid';
password.className += " cbi-input-invalid";
key.className += " cbi-input-invalid";
return false;
}
return true;
};
password.onkeyup = checkCryptoConfig;
key.onkeyup = checkCryptoConfig;
if (key.form) {
if (!key.form.cbi_validators) {
key.form.cbi_validators = [];
if (form) {
if (!form.cbi_validators) {
form.cbi_validators = [];
}
key.form.cbi_validators.push(checkCryptoConfig);
form.cbi_validators.push(checkCryptoConfig);
}
checkCryptoConfig();
}());
}(function(id) {
return document.getElementById("cbid.<%=self.config%>.<%=self.sid%>." + id);
}));
//]]></script>

0 comments on commit c5897fd

Please sign in to comment.