luci-app-jd-dailybonus:“bug fix” from jerrykuku (#6547)

This commit is contained in:
EnnawYang 2021-03-16 15:18:30 +08:00 committed by GitHub
parent 4824ae9e85
commit 0b4bdc43c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 37 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-jd-dailybonus
PKG_VERSION:=1.0.4
PKG_RELEASE:=20210315
PKG_VERSION:=1.0.5
PKG_RELEASE:=20210316
define Package/$(PKG_NAME)/conffiles
/etc/config/jd-dailybonus

View File

@ -8,14 +8,14 @@ m = Map(jd)
s = m:section(TypedSection, 'global', translate('基本设置'))
s.anonymous = true
o = s:option(DummyValue, '', '')
o.rawhtml = true
o.template = 'jd-dailybonus/cookie_tools'
o = s:option(DynamicList, "Cookies", translate("账号 Cookie 列表"))
o.rmempty = false
o.description = translate('双击输入框即可调出二维码,扫描后自动填入。')
o = s:option(DummyValue, '', '')
o.rawhtml = true
o.template = 'jd-dailybonus/cookie_tools'
o = s:option(Value, 'stop', translate('延迟签到'))
o.rmempty = false
o.default = 0

View File

@ -81,9 +81,11 @@
<script type="text/javascript">
const QRCODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","qrcode")%>';
const CHECK_LOGIN_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","check_login")%>';
let ckid = 0;
let config_index = document.querySelector(".cbi-section-node").getAttribute("id").split("-").pop();
let ck_input_name ="cbid.jd-dailybonus."+config_index+".Cookies";
let ck_input_container = document.getElementById("cbi-jd-dailybonus-"+config_index+"-Cookies");
//初始化二维码
try {
qrcode = new QRCode(document.getElementById("qrcode"),
@ -91,20 +93,15 @@
text: "sample",
correctLevel: QRCode.CorrectLevel.L
});
$(document).ready(function(){
$("div[id$='-Cookies']").dblclick(function ( e ) {
if ( e.target.className == "cbi-input-text" ) {
var index = $(e.target).attr("id");
ckid = index.substring(index.indexOf(".Cookies") + 9);
get_code();
}
});
});
ck_input_container.addEventListener('dblclick', function(e){
let el_name = e.target.getAttribute("name");
if (el_name == ck_input_name){
ckid = e.target.getAttribute("id").split(".").pop();
get_code();
}
});
} catch (error) {
alert("网络离线状态无法使用二维码获取Cookie请刷新后重试")
cookieBtn.forEach(e => {
e.disabled = true;
});
}
//获取二维码
@ -120,23 +117,23 @@
}
function checkLogin(check_url){
var timeId = setInterval(() => {
let cname = "cookie" + ckid
jQuery.post( CHECK_LOGIN_URL, { check_url:check_url,id: cname}, function( data ) {
if (data.error == 0) {
clearInterval(timeId)
$("#qrcontainer").addClass("hidden")
$("#refresh_qrcode").addClass("hidden")
let prefix_array = $(".cbi-input-text").eq(0).attr("id").split(".");
prefix_array.pop()
let prefix = prefix_array.join(".")+".";
document.getElementById(prefix+ckid).value =data.cookie
} else if (data.error == 21 || data.error == 261) {
clearInterval(timeId)
$("#refresh_qrcode").removeClass("hidden")
}
}, "json");
}, 3000)
let cname = "cookie" + ckid
XHR.poll(3, CHECK_LOGIN_URL, { check_url: check_url, id: cname }, (x, d) => {
if (d.error == 0) {
XHR.halt();
XHR._q = [];
document.getElementById("qrcontainer").classList.add("hidden");
document.getElementById("refresh_qrcode").classList.add("hidden");
let prefix_array = document.getElementsByClassName("cbi-input-text")[0].getAttribute("id").split(".")
prefix_array.pop()
let prefix = prefix_array.join(".")+".";
document.getElementById(prefix+ckid).value = d.cookie
} else if (d.error == 21 || d.error == 261) {
XHR.halt();
XHR._q = [];
document.getElementById("refresh_qrcode").classList.remove("hidden");
}
});
}
</script>