Skip to content

Commit

Permalink
luci: optimize the display of the xhttp_extra
Browse files Browse the repository at this point in the history
  • Loading branch information
lwb1978 committed Jan 12, 2025
1 parent 7866380 commit a7173ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,12 @@ o = s:option(Value, _n("xhttp_path"), translate("XHTTP Path"))
o.placeholder = "/"
o:depends({ [_n("transport")] = "xhttp" })

o = s:option(TextValue, _n("xhttp_extra"), translate("XHTTP Extra"), translate("An XHttpObject in JSON format, used for sharing."))
o = s:option(Flag, _n("use_xhttp_extra"), translate("XHTTP Extra"))
o.default = "0"
o:depends({ [_n("transport")] = "xhttp" })

o = s:option(TextValue, _n("xhttp_extra"), " ", translate("An XHttpObject in JSON format, used for sharing."))
o:depends({ [_n("use_xhttp_extra")] = true })
o.rows = 15
o.wrap = "off"
o.custom_write = function(self, section, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@
params += opt.query("host", dom_prefix + "xhttp_host");
params += opt.query("path", dom_prefix + "xhttp_path");
params += opt.query("mode", dom_prefix + "xhttp_mode");
params += opt.query("extra", dom_prefix + "xhttp_extra");
if (opt.get(dom_prefix + "use_xhttp_extra").checked) {
params += opt.query("extra", dom_prefix + "xhttp_extra");
}
} else if (v_transport === "httpupgrade") {
v_transport = "httpupgrade";
params += opt.query("host", dom_prefix + "httpupgrade_host");
Expand Down Expand Up @@ -1266,6 +1268,7 @@
opt.set(dom_prefix + 'xhttp_host', queryParam.host || "");
opt.set(dom_prefix + 'xhttp_path', queryParam.path || "");
opt.set(dom_prefix + 'xhttp_mode', queryParam.mode || "auto");
opt.set(dom_prefix + 'use_xhttp_extra', !!queryParam.extra);
opt.set(dom_prefix + 'xhttp_extra', queryParam.extra || "");
} else if (queryParam.type === "httpupgrade") {
opt.set(dom_prefix + 'httpupgrade_host', queryParam.host || "");
Expand Down
3 changes: 2 additions & 1 deletion luci-app-passwall/root/usr/share/passwall/subscribe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,8 @@ local function processData(szType, content, add_mode, add_from)
result.xhttp_host = params.host
result.xhttp_path = params.path
result.xhttp_mode = params.mode or "auto"
result.xhttp_extra = params.extra
result.use_xhttp_extra = (params.extra and params.extra ~= "") and "1" or nil
result.xhttp_extra = (params.extra and params.extra ~= "") and params.extra or nil
local success, Data = pcall(jsonParse, params.extra)
if success and Data then
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
Expand Down

0 comments on commit a7173ee

Please sign in to comment.