Skip to content

Commit b23c49d

Browse files
committed
chore: sub url setter keep name provided
1 parent 81e3010 commit b23c49d

File tree

5 files changed

+11
-31
lines changed

5 files changed

+11
-31
lines changed

luci-app-openclash/luasrc/controller/openclash.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,12 @@ function get_sub_url(filename)
665665
string.gsub(s.url, '[^\n]+', function(w) table.insert(info_tb, w) end)
666666
end
667667
if #info_tb == 1 then
668-
local url, _ = parse_url_with_name(info_tb[1], filename)
669-
sub_url = url
668+
local url, name = parse_url_with_name(info_tb[1], filename)
669+
if url ~= info_tb[1] then
670+
table.insert(providers, {name = name, url = url})
671+
else
672+
sub_url = url
673+
end
670674
elseif #info_tb > 1 then
671675
for _, raw in ipairs(info_tb) do
672676
local url, name = parse_url_with_name(raw, filename)

luci-app-openclash/luasrc/view/openclash/config_edit.htm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,11 +2738,7 @@
27382738
model.querySelector('#overwrite-add-close').onclick = function() {
27392739
document.body.removeChild(ocDiv);
27402740
};
2741-
overlay.onclick = function(e) {
2742-
if (e.target === overlay) {
2743-
document.body.removeChild(ocDiv);
2744-
}
2745-
};
2741+
27462742
model.querySelector('#overwrite-upload-cancel').onclick = function() {
27472743
document.body.removeChild(ocDiv);
27482744
};

luci-app-openclash/luasrc/view/openclash/config_upload.htm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,12 +1128,6 @@
11281128
}
11291129
});
11301130

1131-
this.overlay.addEventListener('click', function(e) {
1132-
if (e.target === self.overlay && !self.isProcessing) {
1133-
self.hide();
1134-
}
1135-
});
1136-
11371131
document.addEventListener('keydown', function(e) {
11381132
if (e.key === 'Escape' && !self.isProcessing && self.overlay.classList.contains('show')) {
11391133
self.hide();

luci-app-openclash/luasrc/view/openclash/status.htm

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,8 +3227,8 @@
32273227
}
32283228

32293229
var needsErrorHandling = false;
3230-
if (x && x.status == 200 && status.providers) {
3231-
var newProvidersLength = (status.providers) ? status.providers.length : 0;
3230+
if (x && x.status == 200 && status.providers.length > 0) {
3231+
var newProvidersLength = status.providers.length;
32323232
var cachedProvidersLength = (parsedData && parsedData.providers) ? parsedData.providers.length : 0;
32333233

32343234
if (newProvidersLength !== cachedProvidersLength && cachedProvidersLength > newProvidersLength) {
@@ -3597,26 +3597,18 @@
35973597

35983598
bindEvents: function() {
35993599
var textarea = document.getElementById('subscription-url-textarea');
3600-
var overlay = document.getElementById('subscription-url-overlay');
36013600

36023601
if (textarea) {
36033602
textarea.addEventListener('keydown', this.handleKeyDown.bind(this));
36043603
}
3605-
if (overlay) {
3606-
overlay.addEventListener('click', this.handleOverlayClick.bind(this));
3607-
}
36083604
},
36093605

36103606
unbindEvents: function() {
36113607
var textarea = document.getElementById('subscription-url-textarea');
3612-
var overlay = document.getElementById('subscription-url-overlay');
36133608

36143609
if (textarea) {
36153610
textarea.removeEventListener('keydown', this.handleKeyDown.bind(this));
36163611
}
3617-
if (overlay) {
3618-
overlay.removeEventListener('click', this.handleOverlayClick.bind(this));
3619-
}
36203612
},
36213613

36223614
handleKeyDown: function(event) {
@@ -3627,12 +3619,6 @@
36273619
}
36283620
},
36293621

3630-
handleOverlayClick: function(event) {
3631-
if (event.target.id === 'subscription-url-overlay') {
3632-
this.hide();
3633-
}
3634-
},
3635-
36363622
submit: function() {
36373623
var textarea = document.getElementById('subscription-url-textarea');
36383624
if (!textarea) return;

luci-app-openclash/luasrc/view/openclash/sub_info_show.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,9 +815,9 @@
815815

816816
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "sub_info_get")%>', {filename: "<%=filename%>"}, function(x, status) {
817817
var needsErrorHandling = false;
818-
if (x && x.status == 200 && status.providers) {
818+
if (x && x.status == 200 && status.providers.length > 0) {
819819
var save_info_length = (save_info && save_info.providers) ? save_info.providers.length : 0;
820-
var newProvidersLength = (status && status.providers) ? status.providers.length : 0;
820+
var newProvidersLength = status.providers.length;
821821
if (save_info_length !== newProvidersLength && save_info_length > newProvidersLength) {
822822
needsErrorHandling = true;
823823
}

0 commit comments

Comments
 (0)