mirror of
https://github.com/JamesonHuang/OpenWrt_Luci_Lua.git
synced 2024-11-24 14:20:10 +00:00
75 lines
2.2 KiB
HTML
75 lines
2.2 KiB
HTML
|
<%
|
||
|
--[[
|
||
|
Info Predownload
|
||
|
]]--
|
||
|
local ver = require("xiaoqiang.XQVersion").webVersion
|
||
|
%>
|
||
|
|
||
|
<%include('web/inc/head')%>
|
||
|
<title>小米路由器</title>
|
||
|
<link rel="stylesheet" href="<%=resource%>/web/css/page.set.default.css?v=<%=ver%>"/>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<div class="mod-setting-panel">
|
||
|
<div class="hd">
|
||
|
<h3>升级包预下载</h3>
|
||
|
<a href="#" data-status="0" class="btn-offon btn-off" id="btnpredownload"></a>
|
||
|
</div>
|
||
|
<div class="bd">
|
||
|
<div class="mod-nof" id="noflushd" style="">
|
||
|
<p>开启此功能后后台会自动检测是否有可用升级包并自动下载。</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<%include('web/inc/g.js.base')%>
|
||
|
<script>
|
||
|
var predownload = (function(){
|
||
|
|
||
|
function predownloadStatus(){
|
||
|
$.getJSON('<%=luci.dispatcher.build_url("api", "xqsystem", "pred_status")%>', {}, function(rsp){
|
||
|
if (rsp.code == 0) {
|
||
|
var btnpredownload = $('#btnpredownload')[0];
|
||
|
if (rsp.status == 0 || rsp.status == 2) {
|
||
|
btnpredownload.className = 'btn-offon btn-off';
|
||
|
}else{ // 开启
|
||
|
btnpredownload.className = 'btn-offon btn-on';
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function predownloadSwitch(){
|
||
|
var btnpredownload = $('#btnpredownload');
|
||
|
btnpredownload.on('click', function(e){
|
||
|
e.preventDefault();
|
||
|
var st = $(this).hasClass('btn-on') ? 0 : 1,
|
||
|
btn = this;
|
||
|
btn.className = 'btn-offon btn-off';
|
||
|
$.getJSON('<%=luci.dispatcher.build_url("api", "xqsystem", "pred_switch")%>', {'switch': st}, function(rsp){
|
||
|
if (rsp.code == 0) {
|
||
|
if (st == 1) {
|
||
|
btnpredownload[0].className = 'btn-offon btn-on';
|
||
|
} else {
|
||
|
btnpredownload[0].className = 'btn-offon btn-off';
|
||
|
}
|
||
|
} else {
|
||
|
$.lightalert().setContent(rsp.msg).show();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
init : function(){
|
||
|
predownloadStatus();
|
||
|
predownloadSwitch();
|
||
|
}
|
||
|
}
|
||
|
}());
|
||
|
$(function(){
|
||
|
predownload.init();
|
||
|
});
|
||
|
</script>
|