OpenWrt_Luci_Lua/Mi_Lua/luci/view/web/inc/reboot.js.htm

120 lines
2.8 KiB
HTML
Raw Normal View History

2015-05-09 10:48:46 +00:00
<%
local lanIp = require("xiaoqiang.XQVersion").webDefaultHost
%>
<script>
// reboot
var global_api_reboot = {
url : '<%=luci.dispatcher.build_url("api", "xqsystem","reboot")%>',
param : {"client":"web"}
};
function reboot_window(){
art.dialog({
title:'重启路由',
content: '是否确定重启路由器,重启将断开和小米路由器的连接。',
okValue: '重启',
ok: function () {
var dlg = this;
$.getJSON(global_api_reboot.url, global_api_reboot.param, function(rsp){
if(rsp.code != 0){
art.dialog({title:false,content:"重启失败"}).time(1.5*1000);
}else{
var ip = rsp.lanIp[0].ip;
// global_dorestart('正在重启', ip, true);
$(global_event).trigger('reboot:wait', {
lanIp : ip,
action : '重启路由器',
refresh : true
});
}
});
dlg.close();
return false;
},
cancelValue: '取消',
cancel: function(){
this.close();
return false;
}
}).lock();
}
// shutdown
function shutdown_window(){
art.dialog({
title:'关闭路由器',
content: '是否确定关闭路由器,操作将断开和小米路由器的连接。',
okValue: '关闭',
ok: function () {
$.getJSON('<%=luci.dispatcher.build_url("api", "xqsystem","shutdown")%>', {}, function(rsp){
if(rsp.code != 0){
art.dialog({title:false,content:"关闭路由器失败"}).time(1.5*1000);
}else{
art.dialog({
title: '关闭路由器',
content: '关机中,请等待路由器指示灯熄灭后再断开电源',
cancel: false
}).lock();
}
});
},
cancelValue: '取消',
cancel: function(){
this.close();
}
}).lock();
}
//reset
function reset_window(format){
var reset = (function(format){
var request_data = {
format: format ? 1 : 0
};
function wait(){
$(global_event).trigger('reboot:wait', {
action : '恢复出厂设置',
refresh : true,
lanIp: '<%=lanIp%>'
});
}
function clearCookies(){
var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
if (keys) {
for (var i = keys.length; i--;){
document.cookie=keys[i]+'=0;path=/;expires=' + new Date(0).toUTCString();
}
}
}
return function(){
console.log(request_data);
$.getJSON('<%=luci.dispatcher.build_url("api", "xqsystem","reset")%>', request_data, function(rsp){
if (rsp.code != 0) {
window.parent.art.dialog({
title : false,
content : rsp.msg
}).time(3*1000);
}else{
// clear cookies
clearCookies();
//block wait
wait();
}
});
}
})(format);
window.top.art.dialog({
title : '恢复出厂设置',
content : '是否确定恢复出厂设置,并让小米路由器回到初始状态?',
okValue: '确认',
ok : function(){
reset();
},
cancelValue: '取消',
cancel: function(){
this.close();
}
}).lock();
}
</script>