mirror of
https://github.com/xiaorouji/openwrt-passwall2.git
synced 2025-05-01 13:19:08 +08:00
luci: optimize add the node via the link
This commit is contained in:
parent
fa4439262b
commit
8999da1d5d
@ -2,22 +2,6 @@
|
||||
local api = require "luci.passwall2.api"
|
||||
-%>
|
||||
|
||||
<style>
|
||||
#add_link_div{
|
||||
display: none;
|
||||
width: auto;
|
||||
position: absolute;
|
||||
left:50%;
|
||||
top:50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 99;
|
||||
text-align: center;
|
||||
background: white;
|
||||
box-shadow: darkgrey 10px 10px 30px 5px;
|
||||
padding: 30px 15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function ajax_add_node(link) {
|
||||
@ -47,7 +31,8 @@ local api = require "luci.passwall2.api"
|
||||
|
||||
function add_node() {
|
||||
var nodes_link = document.getElementById("nodes_link").value;
|
||||
if (nodes_link.trim() != "") {
|
||||
nodes_link = nodes_link.replace(/\t/g, "").replace(/\r\n|\r/g, "\n").trim();
|
||||
if (nodes_link != "") {
|
||||
var s = nodes_link.split('://');
|
||||
if (s.length > 1) {
|
||||
ajax_add_node(nodes_link);
|
||||
@ -79,15 +64,13 @@ local api = require "luci.passwall2.api"
|
||||
</script>
|
||||
|
||||
<div id="add_link_div">
|
||||
<div id="add_link_modal_container">
|
||||
<h3><%:Add the node via the link%></h3>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Share Link%></label>
|
||||
<div class="cbi-value-field">
|
||||
<p><textarea id="nodes_link" rows="5" cols="50"></textarea></p>
|
||||
<font color="red"><%:Not a subscription link!!!%></font>
|
||||
<textarea id="nodes_link" rows="10"></textarea>
|
||||
<p id="nodes_link_text"><%:Enter share links, one per line. Subscription links are not supported!%></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<div class="cbi-value-field" style="display: unset">
|
||||
<div id="add_link_button_container">
|
||||
<input class="btn cbi-button cbi-button-add" type="button" onclick="add_node()" value="<%:Add%>" />
|
||||
<input class="btn cbi-button cbi-button-remove" type="button" onclick="close_add_link_div()" value="<%:Close%>" />
|
||||
</div>
|
||||
@ -108,3 +91,55 @@ local api = require "luci.passwall2.api"
|
||||
<div id="div_node_count"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#add_link_div {
|
||||
display: none;
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border: 2px solid #ccc;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.5);
|
||||
z-index: 1000;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
#add_link_modal_container {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
#nodes_link {
|
||||
width: 100%;
|
||||
height: 180px;
|
||||
resize: vertical;
|
||||
font-family: monospace;
|
||||
padding: 5px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#nodes_link_text {
|
||||
color: red;
|
||||
font-size: 14px;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#add_link_button_container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
|
@ -265,11 +265,8 @@ msgstr "添加节点"
|
||||
msgid "Add the node via the link"
|
||||
msgstr "通过链接添加节点"
|
||||
|
||||
msgid "Share Link"
|
||||
msgstr "分享链接"
|
||||
|
||||
msgid "Not a subscription link!!!"
|
||||
msgstr "不是订阅链接!!!"
|
||||
msgid "Enter share links, one per line. Subscription links are not supported!"
|
||||
msgstr "输入分享链接,支持多个节点,每行一个。请勿输入订阅链接!"
|
||||
|
||||
msgid "Please enter the correct link."
|
||||
msgstr "请输入正确的链接。"
|
||||
|
@ -1593,7 +1593,7 @@ local function parse_link(raw, add_mode, add_from, cfgid)
|
||||
end
|
||||
|
||||
for _, v in ipairs(nodes) do
|
||||
if v then
|
||||
if v and not string.match(v, "^%s*$") then
|
||||
xpcall(function ()
|
||||
local result
|
||||
if szType == 'ssd' then
|
||||
@ -1771,12 +1771,9 @@ if arg[1] then
|
||||
log('订阅完毕...')
|
||||
elseif arg[1] == "add" then
|
||||
local f = assert(io.open("/tmp/links.conf", 'r'))
|
||||
local content = f:read('*all')
|
||||
local raw = f:read('*all')
|
||||
f:close()
|
||||
local nodes = split(content:gsub(" ", "\n"), "\n")
|
||||
for _, raw in ipairs(nodes) do
|
||||
parse_link(raw, "1", "导入")
|
||||
end
|
||||
update_node(1)
|
||||
luci.sys.call("rm -f /tmp/links.conf")
|
||||
elseif arg[1] == "truncate" then
|
||||
|
Loading…
Reference in New Issue
Block a user