$(document).ready(function() {
$(".sub-menu a.sub-menu-a").click(function() {
$(this).next(".sub").slideToggle("slow").siblings(".sub:visible").slideUp("slow");
});
});
function randomStrPwd(b) {
b = b || 32;
var c = "AaBbCcDdEeFfGHhiJjKkLMmNnPpRSrTsWtXwYxZyz2345678";
var a = c.length;
var d = "";
for(i = 0; i < b; i++) {
d += c.charAt(Math.floor(Math.random() * a))
}
return d
}
function msgTpl(msg, args){
if (typeof args == 'string'){
return msg.replace('{1}', args);
} else if (typeof args == 'object'){
for (var i = 0; i < args.length; i++) {
rep = '{' + (i + 1) + '}';
msg = msg.replace(rep, args[i]);
}
}
return msg;
}
function refresh() {
window.location.reload()
}
var mdw = {
};
function repeatPwd(a) {
$("#MyPassword").val(RandomStrPwd(a))
}
function GetBakPost(b) {
$(".baktext").hide().prev().show();
var c = $(".baktext").attr("data-id");
var a = $(".baktext").val();
if(a == "") {
a = lan.bt.empty;
}
setWebPs(b, c, a);
$("a[data-id='" + c + "']").html(a);
$(".baktext").remove()
}
$(".menu-icon").click(function() {
$(".sidebar-scroll").toggleClass("sidebar-close");
$(".main-content").toggleClass("main-content-open");
if($(".sidebar-close")) {
$(".sub-menu").find(".sub").css("display", "none")
}
});
var Upload, percentage;
Date.prototype.format = function(b) {
var c = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
S: this.getMilliseconds()
};
if(/(y+)/.test(b)) {
b = b.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
}
for(var a in c) {
if(new RegExp("(" + a + ")").test(b)) {
b = b.replace(RegExp.$1, RegExp.$1.length == 1 ? c[a] : ("00" + c[a]).substr(("" + c[a]).length))
}
}
return b
};
function getLocalTime(a) {
a = a.toString();
if(a.length > 10) {
a = a.substring(0, 10)
}
return new Date(parseInt(a) * 1000).format("yyyy/MM/dd hh:mm:ss")
}
function toSize(a) {
var d = [" B", " KB", " MB", " GB", " TB", " PB"];
var e = 1024;
for(var b = 0; b < d.length; b++) {
if(a < e) {
return(b == 0 ? a : a.toFixed(2)) + d[b]
}
a /= e
}
}
function ChangePath(d) {
setCookie("SetId", d);
setCookie("SetName", "");
var c = layer.open({
type: 1,
area: "650px",
title: lan.bt.dir,
closeBtn: 2,
shift: 5,
shadeClose: false,
content: "
"+lan.public.return+""+lan.bt.path+":
"+lan.bt.filename+" "+lan.bt.etime+" "+lan.bt.access+" "+lan.bt.own+"
"+lan.bt.adddir+" "+lan.public.close+" "+lan.bt.path_ok+"
"
});
setCookie("ChangePath", c);
var b = $("#" + d).val();
tmp = b.split(".");
if(tmp[tmp.length - 1] == "gz") {
tmp = b.split("/");
b = "";
for(var a = 0; a < tmp.length - 1; a++) {
b += "/" + tmp[a]
}
setCookie("SetName", tmp[tmp.length - 1])
}
b = b.replace(/\/\//g, "/");
GetDiskList(b);
ActiveDisk()
}
function GetDiskList(b) {
var d = "";
var a = "";
var c = "path=" + b + "&disk=True";
$.post("/files?action=GetDir", c, function(h) {
if(h.DISK != undefined) {
for(var f = 0; f < h.DISK.length; f++) {
a += " " + h.DISK[f].path + " "
}
$("#changecomlist").html(a)
}
for(var f = 0; f < h.DIR.length; f++) {
var g = h.DIR[f].split(";");
var e = g[0];
if(e.length > 20) {
e = e.substring(0, 20) + "..."
}
if(isChineseChar(e)) {
if(e.length > 10) {
e = e.substring(0, 10) + "..."
}
}
d += " " + e + "" + getLocalTime(g[2]) + " " + g[3] + " " + g[4] + " X "
}
if(h.FILES != null && h.FILES != "") {
for(var f = 0; f < h.FILES.length; f++) {
var g = h.FILES[f].split(";");
var e = g[0];
if(e.length > 20) {
e = e.substring(0, 20) + "..."
}
if(isChineseChar(e)) {
if(e.length > 10) {
e = e.substring(0, 10) + "..."
}
}
d += " " + e + "" + getLocalTime(g[2]) + " " + g[3] + " " + g[4] + " "
}
}
$(".default").hide();
$(".file-list").show();
$("#tbody").html(d);
if(h.PATH.substr(h.PATH.length - 1, 1) != "/") {
h.PATH += "/"
}
$("#PathPlace").find("span").html(h.PATH);
ActiveDisk();
return
})
}
function CreateFolder() {
var a = " "+lan.public.ok+" "+lan.public.cancel+" ";
if($("#tbody tr").length == 0) {
$("#tbody").append(a)
} else {
$("#tbody tr:first-child").before(a)
}
$(".newFolderName").focus();
$("#nameOk").click(function() {
var c = $("#newFolderName").val();
var b = $("#PathPlace").find("span").text();
newTxt = b.replace(new RegExp(/(\/\/)/g), "/") + c;
var d = "path=" + newTxt;
$.post("/files?action=CreateDir", d, function(e) {
if(e.status == true) {
layer.msg(e.msg, {
icon: 1
})
} else {
layer.msg(e.msg, {
icon: 2
})
}
GetDiskList(b)
})
});
$("#nameNOk").click(function() {
$(this).parents("tr").remove()
})
}
function NewDelFile(c) {
var a = $("#PathPlace").find("span").text();
newTxt = c.replace(new RegExp(/(\/\/)/g), "/");
var b = "path=" + newTxt + "&empty=True";
$.post("/files?action=DeleteDir", b, function(d) {
if(d.status == true) {
layer.msg(d.msg, {
icon: 1
})
} else {
layer.msg(d.msg, {
icon: 2
})
}
GetDiskList(a)
})
}
function ActiveDisk() {
var a = $("#PathPlace").find("span").text().substring(0, 1);
switch(a) {
case "C":
$(".path-con-left dd:nth-of-type(1)").css("background", "#eee").siblings().removeAttr("style");
break;
case "D":
$(".path-con-left dd:nth-of-type(2)").css("background", "#eee").siblings().removeAttr("style");
break;
case "E":
$(".path-con-left dd:nth-of-type(3)").css("background", "#eee").siblings().removeAttr("style");
break;
case "F":
$(".path-con-left dd:nth-of-type(4)").css("background", "#eee").siblings().removeAttr("style");
break;
case "G":
$(".path-con-left dd:nth-of-type(5)").css("background", "#eee").siblings().removeAttr("style");
break;
case "H":
$(".path-con-left dd:nth-of-type(6)").css("background", "#eee").siblings().removeAttr("style");
break;
default:
$(".path-con-left dd").removeAttr("style")
}
}
function BackMyComputer() {
$(".default").show();
$(".file-list").hide();
$("#PathPlace").find("span").html("");
ActiveDisk()
}
function BackFile() {
var c = $("#PathPlace").find("span").text();
if(c.substr(c.length - 1, 1) == "/") {
c = c.substr(0, c.length - 1)
}
var d = c.split("/");
var a = "";
if(d.length > 1) {
var e = d.length - 1;
for(var b = 0; b < e; b++) {
a += d[b] + "/"
}
GetDiskList(a.replace("//", "/"))
} else {
a = d[0]
}
if(d.length == 1) {}
}
function GetfilePath() {
var a = $("#PathPlace").find("span").text();
a = a.replace(new RegExp(/(\\)/g), "/");
$("#" + getCookie("SetId")).val(a + getCookie("SetName"));
layer.close(getCookie("ChangePath"))
}
function setCookie(a, c) {
var b = 30;
var d = new Date();
d.setTime(d.getTime() + b * 24 * 60 * 60 * 1000);
document.cookie = a + "=" + escape(c) + ";expires=" + d.toGMTString()
}
function getCookie(b) {
var a, c = new RegExp("(^| )" + b + "=([^;]*)(;|$)");
if(a = document.cookie.match(c)) {
return unescape(a[2])
} else {
return null
}
}
function aotuHeight() {
var a = $("body").height() - 40;
$(".main-content").css("min-height", a)
}
$(function() {
aotuHeight()
});
$(window).resize(function() {
aotuHeight()
});
function showHidePwd() {
var a = "glyphicon-eye-open",
b = "glyphicon-eye-close";
$(".pw-ico").click(function() {
var g = $(this).attr("class"),
e = $(this).prev();
if(g.indexOf(a) > 0) {
var h = e.attr("data-pw");
$(this).removeClass(a).addClass(b);
e.text(h)
} else {
$(this).removeClass(b).addClass(a);
e.text("**********")
}
var d = $(this).next().position().left;
var f = $(this).next().position().top;
var c = $(this).next().width();
$(this).next().next().css({
left: d + c + "px",
top: f + "px"
})
})
}
function showMsg(msg, callback ,icon, time){
if (typeof time == 'undefined'){
time = 2000;
}
if (typeof icon == 'undefined'){
icon = {};
}
var loadT = layer.msg(msg, icon);
setTimeout(function() {
layer.close(loadT);
if (typeof callback == 'function'){
callback();
}
}, time);
}
function openPath(a) {
setCookie("Path", a);
window.location.href = "/files"
}
function onlineEditFile(k, f) {
if(k != 0) {
var l = $("#PathPlace input").val();
var h = encodeURIComponent($("#textBody").val());
var a = $("select[name=encoding]").val();
var loadT = layer.msg(lan.bt.save_file, {
icon: 16,
time: 0
});
$.post("/files/save_body", "data=" + h + "&path=" + encodeURIComponent(f) + "&encoding=" + a, function(m) {
if(k == 1) {
layer.close(loadT);
}
layer.msg(m.msg, {
icon: m.status ? 1 : 2
});
},'json');
return
}
var e = layer.msg(lan.bt.read_file, {
icon: 16,
time: 0
});
var g = f.split(".");
var b = g[g.length - 1];
var d;
switch(b) {
case "html":
var j = {
name: "htmlmixed",
scriptTypes: [{
matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null
}, {
matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"
}]
};
d = j;
break;
case "htm":
var j = {
name: "htmlmixed",
scriptTypes: [{
matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null
}, {
matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"
}]
};
d = j;
break;
case "js":
d = "text/javascript";
break;
case "json":
d = "application/ld+json";
break;
case "css":
d = "text/css";
break;
case "php":
d = "application/x-httpd-php";
break;
case "tpl":
d = "application/x-httpd-php";
break;
case "xml":
d = "application/xml";
break;
case "sql":
d = "text/x-sql";
break;
case "conf":
d = "text/x-nginx-conf";
break;
default:
var j = {
name: "htmlmixed",
scriptTypes: [{
matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null
}, {
matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"
}]
};
d = j
}
$.post("/files/get_body", "path=" + encodeURIComponent(f), function(s) {
if(s.status === false){
layer.msg(s.msg,{icon:5});
return;
}
layer.close(e);
var u = ["utf-8", "GBK", "GB2312", "BIG5"];
var n = "";
var m = "";
var o = "";
for(var p = 0; p < u.length; p++) {
m = s.encoding == u[p] ? "selected" : "";
n += '" + u[p] + " "
}
var r = layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: ["90%", "90%"],
title: lan.bt.edit_title+"[" + f + "]",
content: ''
});
$("#textBody").text(s.data.data);
var q = $(window).height() * 0.9;
$("#textBody").height(q - 160);
var t = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
$("#textBody").text(t.getValue());
onlineEditFile(2, f)
}
},
mode: d,
lineNumbers: true,
matchBrackets: true,
matchtags: true,
autoMatchParens: true
});
t.focus();
t.setSize("auto", q - 150);
$("#OnlineEditFileBtn").click(function() {
$("#textBody").text(t.getValue());
onlineEditFile(1, f);
});
$(".btn-editor-close").click(function() {
layer.close(r);
});
},'json');
}
function divcenter() {
$(".layui-layer").css("position", "absolute");
var c = $(window).width();
var b = $(".layui-layer").outerWidth();
var g = $(window).height();
var f = $(".layui-layer").outerHeight();
var a = (c - b) / 2;
var e = (g - f) / 2 > 0 ? (g - f) / 2 : 10;
var d = $(".layui-layer").offset().left - $(".layui-layer").position().left;
var h = $(".layui-layer").offset().top - $(".layui-layer").position().top;
a = a + $(window).scrollLeft() - d;
e = e + $(window).scrollTop() - h;
$(".layui-layer").css("left", a + "px");
$(".layui-layer").css("top", e + "px")
}
function btcopy(password) {
$("#bt_copys").attr('data-clipboard-text',password);
$("#bt_copys").click();
}
var clipboard = new ClipboardJS('#bt_copys');
clipboard.on('success', function (e) {
layer.msg('复制成功!',{icon:1});
});
clipboard.on('error', function (e) {
layer.msg('复制失败,浏览器不兼容!',{icon:2});
});
function isChineseChar(b) {
var a = /[\u4E00-\u9FA5\uF900-\uFA2D]/;
return a.test(b)
}
function SafeMessage(j, h, g, f) {
if(f == undefined) {
f = ""
}
var d = Math.round(Math.random() * 9 + 1);
var c = Math.round(Math.random() * 9 + 1);
var e = "";
e = d + c;
sumtext = d + " + " + c;
setCookie("vcodesum", e);
var mess = layer.open({
type: 1,
title: j,
area: "350px",
closeBtn: 2,
shadeClose: true,
content: ""
});
$("#vcodeResult").focus().keyup(function(a) {
if(a.keyCode == 13) {
$("#toSubmit").click()
}
});
$(".bt-cancel").click(function(){
layer.close(mess);
});
$("#toSubmit").click(function() {
var a = $("#vcodeResult").val().replace(/ /g, "");
if(a == undefined || a == "") {
layer.msg('请正确输入计算结果!');
return
}
if(a != getCookie("vcodesum")) {
layer.msg('请正确输入计算结果!');
return
}
layer.close(mess);
g();
})
}
//isAction();
function isAction() {
hrefs = window.location.href.split("/");
name = hrefs[hrefs.length - 1];
if(!name) {
$("#memuA").addClass("current");
return
}
$("#memuA" + name).addClass("current")
}
var W_window = $(window).width();
if(W_window <= 980) {
$(window).scroll(function() {
var a = $(window).scrollTop();
$(".sidebar-scroll").css({
position: "absolute",
top: a
})
})
} else {
$(".sidebar-scroll").css({
position: "fixed",
top: "0"
})
}
$(function() {
$(".fb-ico").hover(function() {
$(".fb-text").css({
left: "36px",
top: 0,
width: "80px"
})
}, function() {
$(".fb-text").css({
left: 0,
width: "36px"
})
}).click(function() {
$(".fb-text").css({
left: 0,
width: "36px"
});
$(".zun-feedback-suggestion").show()
});
$(".fb-close").click(function() {
$(".zun-feedback-suggestion").hide()
});
$(".fb-attitudes li").click(function() {
$(this).addClass("fb-selected").siblings().removeClass("fb-selected")
})
});
$("#dologin").click(function() {
layer.confirm(lan.bt.loginout, {icon:3,
closeBtn: 2
}, function() {
window.location.href = "/login?dologin=True"
});
return false
});
function setPassword(a) {
if(a == 1) {
p1 = $("#p1").val();
p2 = $("#p2").val();
if(p1 == "" || p1.length < 8) {
layer.msg(lan.bt.pass_err_len, {
icon: 2
});
return
}
//准备弱口令匹配元素
var checks = ['admin888','123123123','12345678','45678910','87654321','asdfghjkl','password','qwerqwer'];
pchecks = 'abcdefghijklmnopqrstuvwxyz1234567890';
for(var i=0;i"+lan.bt.pass_rep_btn+" "+lan.public.close+" "+lan.public.edit+"
"
});
}
function randPwd(){
var pwd = RandomStrPwd(12);
$("#p1").val(pwd);
$("#p2").val(pwd);
layer.msg(lan.bt.pass_rep_ps,{time:2000})
}
function setUserName(a) {
if(a == 1) {
p1 = $("#p1").val();
p2 = $("#p2").val();
if(p1 == "" || p1.length < 3) {
layer.msg(lan.bt.user_len, {
icon: 2
});
return
}
if(p1 != p2) {
layer.msg(lan.bt.user_err_re, {
icon: 2
});
return
}
$.post("/config?action=setUsername", "username1=" + encodeURIComponent(p1) + "&username2=" + encodeURIComponent(p2), function(b) {
if(b.status) {
layer.closeAll();
layer.msg(b.msg, {
icon: 1
});
$("input[name='username_']").val(p1)
} else {
layer.msg(b.msg, {
icon: 2
})
}
});
return
}
layer.open({
type: 1,
area: "290px",
title: lan.bt.user_title,
closeBtn: 2,
shift: 5,
shadeClose: false,
content: ""
})
}
var openWindow = null;
var downLoad = null;
var speed = null;
function task() {
messagebox();
}
function ActionTask() {
var a = layer.msg(lan.public.the_del, {
icon: 16,
time: 0,
shade: [0.3, "#000"]
});
$.post("/files?action=ActionTask", "", function(b) {
layer.close(a);
layer.msg(b.msg, {
icon: b.status ? 1 : 5
})
})
}
function RemoveTask(b) {
var a = layer.msg(lan.public.the_del, {
icon: 16,
time: 0,
shade: [0.3, "#000"]
});
$.post("/files?action=RemoveTask", "id=" + b, function(c) {
layer.close(a);
layer.msg(c.msg, {
icon: c.status ? 1 : 5
});
}).error(function(){
layer.msg(lan.bt.task_close,{icon:1});
});
}
function GetTaskList(a) {
a = a == undefined ? 1 : a;
$.post("/task/list", "tojs=GetTaskList&table=tasks&limit=10&p=" + a, function(g) {
console.log(g);
var e = "";
var b = "";
var c = "";
var f = false;
for(var d = 0; d < g.data.length; d++) {
switch(g.data[d].status) {
case "-1":
f = true;
if(g.data[d].type != "download") {
b = "" + g.data[d].name + " "+lan.bt.task_install+" | "+lan.public.close+" "
} else {
b = "
" + g.data[d].name + "0.0M/12.5M 0% "+lan.bt.task_downloading+" | "+lan.public.close+" "
}
break;
case "0":
c += "" + g.data[d].name + " "+lan.bt.task_sleep+" | "+lan.public.del+" ";
break;
case "1":
e += "" + g.data[d].name + " " + g.data[d].addtime + " "+lan.bt.task_ok+" "+ lan.bt.time + (g.data[d].end - g.data[d].start) + lan.bt.s+" "
}
}
$("#srunning").html(b + c);
$("#sbody").html(e);
return f
})
}
function getTaskCount() {
$.get("/task/count", "", function(a) {
$(".task").text(a)
})
}
function setSelectChecked(c, d) {
var a = document.getElementById(c);
for(var b = 0; b < a.options.length; b++) {
if(a.options[b].innerHTML == d) {
a.options[b].selected = true;
break
}
}
}
getTaskCount();
function RecInstall() {
$.post("/ajax?action=GetSoftList", "", function(l){
var c = "";
var g = "";
var e = "";
for(var h = 0; h < l.length; h++) {
if(l[h].name == "Tomcat") {
continue
}
var o = "";
var m = " ";
for(var b = 0; b < l[h].versions.length; b++) {
var d = "";
if((l[h].name == "PHP" && (l[h].versions[b].version == "5.4" || l[h].versions[b].version == "54")) || (l[h].name == "MySQL" && l[h].versions[b].version == "5.5") || (l[h].name == "phpMyAdmin" && l[h].versions[b].version == "4.4")) {
d = "selected";
m = " "
}
o += "" + l[h].name + " " + l[h].versions[b].version + " "
}
var f = "" + o + " " + m + " ";
if(l[h].name == "Nginx") {
c = f
} else {
if(l[h].name == "Apache") {
g = f
} else {
e += f
}
}
}
c += e;
g += e;
g = g.replace(new RegExp(/(data_)/g), "apache_").replace(new RegExp(/(select_)/g), "apache_select_");
var k = layer.open({
type: 1,
title: lan.bt.install_title,
area: ["658px", "423px"],
closeBtn: 2,
shadeClose: false,
content: ""
});
$(".fangshi input").click(function() {
$(this).attr("checked", "checked").parent().siblings().find("input").removeAttr("checked")
});
$(".sl-s-info").change(function() {
var p = $(this).find("option:selected").text();
var n = $(this).attr("id");
p = p.toLowerCase();
$(this).parents("li").find("input").attr("data-info", p)
});
$("#apache_select_PHP").change(function() {
var n = $(this).val();
j(n, "apache_select_", "apache_")
});
$("#select_PHP").change(function() {
var n = $(this).val();
j(n, "select_", "data_")
});
function j(p, r, q) {
var n = "4.4";
switch(p) {
case "5.2":
n = "4.0";
break;
case "5.3":
n = "4.0";
break;
case "5.4":
n = "4.4";
break;
case "5.5":
n = "4.4";
break;
default:
n = "4.7"
}
$("#" + r + "phpMyAdmin option[value='" + n + "']").attr("selected", "selected").siblings().removeAttr("selected");
$("#" + r + "_phpMyAdmin").attr("data-info", "phpmyadmin " + n)
}
$("#select_MySQL,#apache_select_MySQL").change(function() {
var n = $(this).val();
a(n)
});
$("#apache_select_Apache").change(function(){
var apacheVersion = $(this).val();
if(apacheVersion == '2.2'){
layer.msg(lan.bt.install_apache22);
}else{
layer.msg(lan.bt.install_apache24);
}
});
$("#apache_select_PHP").change(function(){
var apacheVersion = $("#apache_select_Apache").val();
var phpVersion = $(this).val();
if(apacheVersion == '2.2'){
if(phpVersion != '5.2' && phpVersion != '5.3' && phpVersion != '5.4'){
layer.msg(lan.bt.insatll_s22+'PHP-' + phpVersion,{icon:5});
$(this).val("5.4");
$("#apache_PHP").attr('data-info','php 5.4');
return false;
}
}else{
if(phpVersion == '5.2'){
layer.msg(lan.bt.insatll_s24+'PHP-' + phpVersion,{icon:5});
$(this).val("5.4");
$("#apache_PHP").attr('data-info','php 5.4');
return false;
}
}
});
function a(n) {
memSize = getCookie("memSize");
max = 64;
msg = "64M";
switch(n) {
case "5.1":
max = 256;
msg = "256M";
break;
case "5.7":
max = 1500;
msg = "2GB";
break;
case "5.6":
max = 800;
msg = "1GB";
break;
case "AliSQL":
max = 800;
msg = "1GB";
break;
case "mariadb_10.0":
max = 800;
msg = "1GB";
break;
case "mariadb_10.1":
max = 1500;
msg = "2GB";
break
}
if(memSize < max) {
layer.msg( lan.bt.insatll_mem.replace("{1}",msg).replace("{2}",n), {
icon: 5
})
}
}
var de = null;
$(".onekey").click(function() {
if(de) return;
var v = $(this).prev().find("input").eq(0).prop("checked") ? "1" : "0";
var r = $(this).parents(".rec-box-con").find(".rec-list li").length;
var n = "";
var q = "";
var p = "";
var x = "";
var s = "";
de = true;
for(var t = 0; t < r; t++) {
var w = $(this).parents(".rec-box-con").find("ul li").eq(t);
var u = w.find("input");
if(u.prop("checked")) {
n += u.attr("data-info") + ","
}
}
q = n.split(",");
loadT = layer.msg(lan.bt.install_to, {
icon: 16,
time: 0,
shade: [0.3, "#000"]
});
for(var t = 0; t < q.length - 1; t++) {
p = q[t].split(" ")[0].toLowerCase();
x = q[t].split(" ")[1];
s = "name=" + p + "&version=" + x + "&type=" + v + "&id=" + (t + 1);
$.ajax({
url: "/files?action=InstallSoft",
data: s,
type: "POST",
async: false,
success: function(y) {}
});
}
layer.close(loadT);
layer.close(k);
setTimeout(function() {
GetTaskCount()
}, 2000);
layer.msg(lan.bt.install_ok, {
icon: 1
});
setTimeout(function() {
task()
}, 1000)
});
InstallTips();
fly("onekey")
})
}
function jump() {
layer.closeAll();
window.location.href = "/soft"
}
function InstallTips() {
$(".fangshi label").mouseover(function() {
var a = $(this).attr("data-title");
layer.tips(a, this, {
tips: [1, "#787878"],
time: 0
})
}).mouseout(function() {
$(".layui-layer-tips").remove()
})
}
function fly(a) {
var b = $("#task").offset();
$("." + a).click(function(d) {
var e = $(this);
var c = $(' ');
c.fly({
start: {
left: d.pageX,
top: d.pageY
},
end: {
left: b.left + 10,
top: b.top + 10,
width: 0,
height: 0
},
onEnd: function() {
layer.closeAll();
layer.msg(lan.bt.task_add, {
icon: 1
});
GetTaskCount()
}
});
});
};
//检查选中项
function checkSelect(){
setTimeout(function(){
var checkList = $("input[name=id]");
var count = 0;
for(var i=0;i 0){
$("#allDelete").show();
}else{
$("#allDelete").hide();
}
},5);
}
//处理排序
function listOrder(skey,type,obj){
or = getCookie('order');
orderType = 'desc';
if(or){
if(or.split(' ')[1] == 'desc'){
orderType = 'asc';
}
}
setCookie('order',skey + ' ' + orderType);
switch(type){
case 'site':
getWeb(1);
break;
case 'database':
getData(1);
break;
case 'ftp':
getFtp(1);
break;
}
$(obj).find(".glyphicon-triangle-bottom").remove();
$(obj).find(".glyphicon-triangle-top").remove();
if(orderType == 'asc'){
$(obj).append(" ");
}else{
$(obj).append(" ");
}
}
//添加面板快捷登录
function bindBTPanel(a,type,ip,btid,url,user,pw){
var titleName = lan.bt.panel_add;
if(type == "b"){
btn = ""+lan.public.add+" ";
}
else{
titleName = lan.bt.panel_edit+ip;
btn = ""+lan.public.del+" "+lan.public.edit+" ";
}
if(url == undefined) url="http://";
if(user == undefined) user="";
if(pw == undefined) pw="";
if(ip == undefined) ip="";
if(a == 1) {
var gurl = "/config?action=AddPanelInfo";
var btaddress = $("#btaddress").val();
if(!btaddress.match(/^(http|https)+:\/\/([\w-]+\.)+[\w-]+:\d+/)){
layer.msg(lan.bt.panel_err_format+'http://192.168.0.1:8888
',{icon:5,time:5000});
return;
}
var btuser = encodeURIComponent($("#btuser").val());
var btpassword = encodeURIComponent($("#btpassword").val());
var bttitle = $("#bttitle").val();
var data = "title="+bttitle+"&url="+encodeURIComponent(btaddress)+"&username="+btuser+"&password="+btpassword;
if(btaddress =="" || btuser=="" || btpassword=="" || bttitle==""){
layer.msg(lan.bt.panel_err_empty,{icon:8});
return;
}
if(type=="c"){
gurl = "/config?action=SetPanelInfo";
data = data+"&id="+btid;
}
$.post(gurl, data, function(b) {
if(b.status) {
layer.closeAll();
layer.msg(b.msg, {icon: 1});
GetBtpanelList();
} else {
layer.msg(b.msg, {icon: 2})
}
});
return
}
layer.open({
type: 1,
area: "400px",
title: titleName,
closeBtn: 2,
shift: 5,
shadeClose: false,
content: ""
});
$("#btaddress").on("input",function(){
var str =$(this).val();
var isip = /([\w-]+\.){2,6}\w+/;
var iptext = str.match(isip);
if(iptext) $("#bttitle").val(iptext[0]);
}).blur(function(){
var str =$(this).val();
var isip = /([\w-]+\.){2,6}\w+/;
var iptext = str.match(isip);
if(iptext) $("#bttitle").val(iptext[0]);
});
}
//删除快捷登录
function bindBTPaneldel(id){
$.post("/config?action=DelPanelInfo","id="+id,function(rdata){
layer.closeAll();
layer.msg(rdata.msg,{icon:rdata.status?1:2});
GetBtpanelList();
})
}
function getSpeed(sele){
if(!$(sele)) return;
$.get('/ajax?action=GetSpeed',function(speed){
if(speed.title === null) return;
mspeed = '';
if(speed.speed > 0){
mspeed = ''+ToSize(speed.speed)+'/s ';
}
body = ''+speed.title+'
\
\
'+speed.used+'/'+speed.total+' '+mspeed+'
';
$(sele).prev().hide();
$(sele).css({"margin-left":"-37px","width":"380px"});
$(sele).parents(".layui-layer").css({"margin-left":"-100px"});
$(sele).html(body);
setTimeout(function(){
getSpeed(sele);
},1000);
});
}
//消息盒子
function messagebox() {
layer.open({
type: 1,
title: lan.bt.task_title,
area: "640px",
closeBtn: 2,
shadeClose: false,
content: ''
});
$(".bt-w-menu p").click(function(){
$(this).addClass("bgw").siblings().removeClass("bgw");
});
tasklist();
}
//取执行日志
function execLog(){
$.post('/task/get_exec_log',{},function(logs){
var lbody = ''+logs+' ';
$(".taskcon").html(lbody);
var ob = document.getElementById('exec_log');
ob.scrollTop = ob.scrollHeight;
});
}
function remind(a){
a = a == undefined ? 1 : a;
$.post("/task/list", "tojs=remind&table=tasks&result=2,4,6,8&limit=8&p=" + a, function(g) {
var e = "";
var f = false;
var task_count = 0;
for(var d = 0; d < g.data.length; d++) {
if(g.data[d].status != '1'){
task_count++;
continue;
}
e += ''+g.data[d].name+'【'+lan.bt.task_ok+'】'+ lan.bt.time + (g.data[d].end - g.data[d].start) + lan.bt.s+'
'+g.data[d].addtime+' '
}
var con = '\
\
'+lan.public.del+' '+lan.bt.task_tip_read+' '+lan.bt.task_tip_all+'
\
\
';
$(".task_count").text(task_count);
$(".msg_count").text(g.data.length);
$(".taskcon").html(con);
$("#taskPage").html(g.page);
$("#Rs-checkAll").click(function(){
if($(this).prop("checked")){
$("#remind").find("input").prop("checked",true)
}
else{
$("#remind").find("input").prop("checked",false)
}
});
},'json');
}
function GetReloads() {
var a = 0;
var mm = $(".bt-w-menu .bgw").html()
if(mm == undefined || mm.indexOf(lan.bt.task_list) == -1) {
clearInterval(speed);
a = 0;
speed = null;
return
}
if(speed) return;
speed = setInterval(function() {
var mm = $(".bt-w-menu .bgw").html()
if(mm == undefined || mm.indexOf(lan.bt.task_list) == -1) {
clearInterval(speed);
speed = null;
a = 0;
return
}
a++;
$.post("/task/get_task_speed", "", function(h) {
if(h.task == undefined) {
$(".cmdlist").html(lan.bt.task_not_list);
return
}
var b = "";
var d = "";
$("#task").text(h.task.length);
$(".task_count").text(h.task.length);
for(var g = 0; g < h.task.length; g++) {
if(h.task[g].status == "-1") {
if(h.task[g].type != "download") {
var c = "";
var f = h.msg.split("\n");
for(var e = 0; e < f.length; e++) {
c += f[e] + " "
}
if(h.task[g].name.indexOf("扫描") != -1) {
b = "" + h.task[g].name + " "+lan.bt.task_scan+" | "+lan.public.close+" " + c + "
"
} else {
b = "" + h.task[g].name + " "+lan.bt.task_install+" | "+lan.public.close+" " + c + "
"
}
} else {
b = "
" + h.task[g].name + "" + (ToSize(h.msg.used) + "/" + ToSize(h.msg.total)) + " " + h.msg.pre + "% "+lan.bt.task_downloading+" | "+lan.public.close+" "
}
} else {
d += "" + h.task[g].name + " "+lan.bt.task_sleep+" | '+lan.public.del+' '
}
}
$(".cmdlist").html(b + d);
$(".cmd").html(c);
try{
if($(".cmd")[0].scrollHeight) $(".cmd").scrollTop($(".cmd")[0].scrollHeight);
}catch(e){
return;
}
},'json').error(function(){});
}, 1000);
}
//检查选中项
function RscheckSelect(){
setTimeout(function(){
var checkList = $("#remind").find("input");
var count = 0;
for(var i=0;i 0){
$(".buttongroup .btn").removeAttr("disabled");
}else{
$(".rs-del,.rs-read").attr("disabled","disabled");
}
},5);
}
function tasklist(a){
var con='若任务长时间未执行,请尝试在首页点【重启面板】来重置任务队列 ';
$(".taskcon").html(con);
a = a == undefined ? 1 : a;
$.post("/task/list", "tojs=GetTaskList&table=tasks&limit=10&p=" + a, function(g) {
var e = "";
var b = "";
var c = "";
var f = false;
var task_count =0;
for(var d = 0; d < g.data.length; d++) {
switch(g.data[d].status) {
case "-1":
f = true;
if(g.data[d].type != "download") {
b = "" + g.data[d].name + " "+lan.bt.task_install+" | "+lan.public.close+" "
} else {
b = "
" + g.data[d].name + "0.0M/12.5M 0% "+lan.bt.task_downloading+" | "+lan.public.close+" "
}
task_count++;
break;
case "0":
c += "" + g.data[d].name + " "+lan.bt.task_sleep+" | "+lan.public.del+" ";
task_count++;
break;
}
}
$(".task_count").text(task_count);
$(".cmdlist").html(b + c);
GetReloads();
return f
},'json')
}
//检查登陆状态
function check_login(){
$.post('/check_login',{},function(rdata){
if(rdata === true) return;
});
}
//登陆跳转
function to_login(){
layer.confirm('您的登陆状态已过期,请重新登陆!',{title:'会话已过期',icon:2,closeBtn: 1,shift: 5},function(){
location.reload();
});
}
//表格头固定
function table_fixed(name){
var tableName = document.querySelector('#'+name);
tableName.addEventListener('scroll',scroll_handle);
}
function scroll_handle(e){
var scrollTop = this.scrollTop;
$(this).find("thead").css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"});
}
$(function(){
setInterval(function(){
check_login();
},60000);
});
/*** 其中功能,针对插件通过库使用 start ***/
function pluginService(_name){
$.post('/plugins/run', {name:_name, func:'status'}, function(data) {
if(!data.status){
layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']});
return;
}
if (data.data == 'start'){
pluginSetService(_name, true);
} else {
pluginSetService(_name, false);
}
},'json');
}
function pluginSetService(_name ,status){
var serviceCon ='当前状态:'+(status ? '开启' : '关闭' )+
'
\
'+(status?'停止':'启动')+' \
重启 \
重载配置 \
';
$(".soft-man-con").html(serviceCon);
}
function pluginOpService(a, b) {
var c = "name=" + a + "&func=" + b;
var d = "";
switch(b) {
case "stop":d = '停止';break;
case "start":d = '启动';break;
case "restart":d = '重启';break;
case "reload":d = '重载';break;
}
layer.confirm( '您真的要{1}{2}服务吗?'.replace('{1}', d).replace('{2}', a), {icon:3,closeBtn: 2}, function() {
var e = layer.msg('正在{1}{2}服务,请稍候...'.replace('{1}', d).replace('{2}', a), {icon: 16,time: 0});
$.post("/plugins/run", c, function(g) {
layer.close(e);
var f = g.data == 'ok' ? '{1}服务已{2}'.replace('{1}', a).replace('{2}', d):'{1}服务{2}失败!'.replace('{1}', a).replace('{2}', d);
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
if(b != "reload" && g.data == 'ok') {
if (b == 'start') {
pluginSetService(a, true);
} else if (b=='stop'){
pluginSetService(a, false);
} else {
}
}
if(g.data != 'ok') {
layer.msg(g.data, {icon: 2,time: 0,shade: 0.3,shadeClose: true});
}
},'json').error(function() {
layer.close(e);
layer.msg('操作成功!', {icon: 1});
});
})
}
//配置修改 --- start
function pluginConfig(_name){
var con = '提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!
\
保存 \
\
此处为'+ _name +'主配置文件,若您不了解配置规则,请勿随意修改。 \
';
$(".soft-man-con").html(con);
var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/plugins/run', {name:_name, func:'conf'},function (data) {
layer.close(loadT);
var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']});
var fileName = data.data;
$.post('/files/get_body', 'path=' + fileName, function(rdata) {
layer.close(loadT2);
if (!rdata.status){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$("#textBody").empty().text(rdata.data.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-Space": "autocomplete",
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
pluginConfigSave(fileName);
}
},
lineNumbers: true,
matchBrackets:true,
});
editor.focus();
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#OnlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName);
});
},'json');
},'json');
}
//配置保存
function pluginConfigSave(fileName) {
var data = encodeURIComponent($("#textBody").val());
var encoding = 'utf-8';
var loadT = layer.msg('保存中...', {
icon: 16,
time: 0
});
$.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
},'json');
}
/*** 其中功能,针对插件通过库使用 end ***/