mirror of
https://github.com/ZeroDream-CN/PHPMC7
synced 2026-05-24 23:41:08 +08:00
7.3.1709 发布
增加更新检测功能,现在可以自动下载最新版本的 PHPMC 了。 修正部分逻辑判断问题。 修改了部分 AJAX 请求超时时间 增加操作过渡动画效果
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// 此处设置 AJAX 延迟,可根据自己的情况进行调整
|
||||
// 单位毫秒,例如 1000 就代表 1 秒
|
||||
var ajaxtimeout = 1000;
|
||||
var oldlog;
|
||||
var ConnectURL;
|
||||
var server;
|
||||
@@ -11,7 +14,7 @@ function ajaxload() {
|
||||
try {
|
||||
$(document).ready(function(){
|
||||
var start = new Date();
|
||||
var htmlobj = $.ajax({url:ConnectURL, async:true, timeout:5000, error: function(){
|
||||
var htmlobj = $.ajax({url:ConnectURL, async:true, timeout:10000, error: function(){
|
||||
$("#ping").html("连接超时");
|
||||
window.parent.frames.showmsg("与 Daemon 服务器的连接已断开。");
|
||||
clearInterval(Interval);
|
||||
@@ -20,18 +23,18 @@ function ajaxload() {
|
||||
$("#ping").html(end + " 毫秒");
|
||||
if(oldlog != htmlobj.responseText) {
|
||||
$("#debug").html("<code style='color: #FFF;background-color: none;padding: 0px;'>"
|
||||
+ htmlobj.responseText.replace(/</g, "<").replace(/>/g, ">").replace(/\n/g,"<br />")
|
||||
.replace(/INFO\]/g, "<span style='color: #00B100'>信息</span>]").replace(/WARN\]/g, "<span style='color: #FF8700'>警告</span>]")
|
||||
.replace(/ERROR\]/g, "<span style='color: #FF0000'>错误</span>]").replace(/\[Server/g, "[服务器").replace(/thread\//g, "主线程/")
|
||||
.replace(/Done \(/g, "<span style='color: #00B100'>启动完成,耗时 (")
|
||||
.replace(/s\)\! For help\, type \"help\" or \"\?\"/g, " 秒)!需要帮助,请输入 “help” 或 “?”</span>")
|
||||
.replace(/Unknown command\. Type \"\/help\" for help\./g, "未知命令,请输入 “help” 查看帮助。")
|
||||
.replace(/Usage\:/g, "使用方法:").replace(/Stopping the server/g, "正在关闭服务器")
|
||||
.replace(/You need to agree to the EULA in order to run the server. Go to eula.txt for more info./,
|
||||
+ htmlobj.responseText.replace("<", "<").replace(">", ">").replace("\n","<br />")
|
||||
.replace("INFO]", "<span style='color: #00B100'>信息</span>]").replace("WARN]", "<span style='color: #FF8700'>警告</span>]")
|
||||
.replace("ERROR]", "<span style='color: #FF0000'>错误</span>]").replace("[Server", "[服务器").replace("thread/", "主线程/")
|
||||
.replace("Done (", "启动完成,耗时 (").replace("s)! For help, type \"help\" or \"?\"", " 秒)!需要帮助,请输入 “help” 或 “?”")
|
||||
.replace("Unknown command. Type \"/help\" for help.", "未知命令,请输入 “help” 查看帮助。")
|
||||
.replace("Usage:", "使用方法:").replace("Stopping the server", "正在关闭服务器")
|
||||
.replace("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.",
|
||||
"<span style='color: #FF8700'>你需要接受 EULA 协议才能开启服务器,编辑服务端的 eula.txt ,将 eula=false 改为 eula=true 并保存即可。</span>")
|
||||
.replace(/Stopping server/, "正在终止服务器进程").replace(/Loading properties/, "正在加载配置文件")
|
||||
.replace(/Failed to load/, "无法加载").replace(/Starting minecraft server version/, "正在启动 Minecraft 服务器,版本:")
|
||||
.replace(/Default game type:/, "默认游戏模式:") + "</code>");
|
||||
.replace("Stopping server", "正在终止服务器进程").replace("Loading properties", "正在加载配置文件")
|
||||
.replace("Failed to load", "无法加载").replace("Starting minecraft server version", "正在启动 Minecraft 服务器,版本:")
|
||||
.replace("Default game type:", "默认游戏模式:").replace("Container not found", "提示:服务器未在运行状态")
|
||||
.replace("Token Error", "错误:授权验证失败,请检查 Daemon 设置。") + "</code>");
|
||||
if(autoflush.checked == true) {
|
||||
debug.scrollTop = debug.scrollHeight;
|
||||
}
|
||||
@@ -61,7 +64,7 @@ window.onkeydown = function(event){
|
||||
};
|
||||
|
||||
function sendCommand(cmd) {
|
||||
var htmlobj = $.ajax({url:"?action=sendcommand&id=" + server + "&cmd=" + encodeURIComponent(cmd), async:true, timeout:5000, error: function(){
|
||||
var htmlobj = $.ajax({url:"?action=sendcommand&id=" + server + "&cmd=" + encodeURIComponent(cmd), async:true, timeout:10000, error: function(){
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
}});
|
||||
}
|
||||
@@ -73,31 +76,32 @@ window.onload = function() {
|
||||
};
|
||||
|
||||
function startServer() {
|
||||
var htmlobj = $.ajax({url:"?action=start&id=" + server, async:true, timeout:5000, error: function(){
|
||||
var htmlobj = $.ajax({url:"?action=start&id=" + server, async:true, timeout:10000, error: function(){
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
}});
|
||||
};
|
||||
|
||||
function stopServer() {
|
||||
var htmlobj = $.ajax({url:"?action=stop&id=" + server, async:true, timeout:5000, error: function(){
|
||||
var htmlobj = $.ajax({url:"?action=stop&id=" + server, async:true, timeout:10000, error: function(){
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
}});
|
||||
};
|
||||
|
||||
function restartServer() {
|
||||
var htmlobj = $.ajax({url:"?action=restart&id=" + server, async:true, timeout:5000, error: function(){
|
||||
var htmlobj = $.ajax({url:"?action=restart&id=" + server, async:true, timeout:10000, error: function(){
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
}});
|
||||
};
|
||||
|
||||
function selectServer(id, element) {
|
||||
window.parent.frames.progressshow("请稍后,正在加载...");
|
||||
clearInterval(Interval);
|
||||
$(".server-hover").attr("style", "");
|
||||
element.style.border = "1px solid rgba(255,255,255,0.3)";
|
||||
var htmlobj = $.ajax({
|
||||
url:"?action=getserver&id=" + id,
|
||||
async:true,
|
||||
timeout:5000,
|
||||
timeout:10000,
|
||||
error: function() {
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
},
|
||||
@@ -111,14 +115,15 @@ function selectServer(id, element) {
|
||||
ftppass.innerHTML = obj.ftppass;
|
||||
oldlog = "";
|
||||
ConnectURL = obj.host + "?action=getlogs&token=" + obj.token + "&name=" + obj.uuid;
|
||||
Interval = setInterval("ajaxload()", 1000);
|
||||
window.parent.frames.progressunshow();
|
||||
Interval = setInterval("ajaxload()", ajaxtimeout);
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function serverStatus() {
|
||||
var htmlobjs = $.ajax({url:"?action=status&id=" + server, async:true, timeout:5000, success: function(){
|
||||
var htmlobjs = $.ajax({url:"?action=status&id=" + server, async:true, timeout:10000, success: function(){
|
||||
var rpt = htmlobjs.responseText;
|
||||
var fallback = rpt.split("\/");
|
||||
$("#online").html(fallback[0]);
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
<script type="text/javascript">
|
||||
var selected;
|
||||
function selectDaemon(id, element) {
|
||||
window.parent.frames.progressshow("请稍后,正在加载...");
|
||||
$(".server-hover").attr("style", "");
|
||||
element.style.border = "1px solid rgba(255,255,255,0.3)";
|
||||
var htmlobj = $.ajax({
|
||||
@@ -119,6 +120,7 @@
|
||||
$("#Type_" + obj.type).attr("selected", "selected");
|
||||
$("#changedaemon").fadeIn();
|
||||
selected = id;
|
||||
window.parent.frames.progressunshow();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<script type="text/javascript">
|
||||
var selected;
|
||||
function selectServer(id, element) {
|
||||
window.parent.frames.progressshow("请稍后,正在加载...");
|
||||
$(".server-hover").attr("style", "");
|
||||
element.style.border = "1px solid rgba(255,255,255,0.3)";
|
||||
var htmlobj = $.ajax({
|
||||
@@ -136,6 +137,7 @@
|
||||
$("#User_" + obj.owner).attr("selected", "selected");
|
||||
$("#changeserver").fadeIn();
|
||||
selected = id;
|
||||
window.parent.frames.progressunshow();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
+38
-10
@@ -51,32 +51,60 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>检查更新</h5>
|
||||
</div>
|
||||
<div class="ibox-content addfrp" id="update">
|
||||
<p>请稍后,正在检查软件更新...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var selected;
|
||||
function saveConfig() {
|
||||
var version = "{{ PHPMC_VERSION; }}";
|
||||
var newversion;
|
||||
function checkUpdate() {
|
||||
var htmlobj = $.ajax({
|
||||
url: "?action=saveconfig",
|
||||
async:true,
|
||||
url: "https://www.phpmc.cn/update.php?version={{ PHPMC_VERSION; }}",
|
||||
async: true,
|
||||
timeout:5000,
|
||||
data: {
|
||||
SiteName: $("#SiteName").val(),
|
||||
Description: $("#Description").val(),
|
||||
Theme: $("#Theme").val()
|
||||
error: function(e) {
|
||||
window.parent.frames.showmsg("检查更新错误:" + htmlobj.responseText);
|
||||
},
|
||||
error: function() {
|
||||
success: function() {
|
||||
console.log(htmlobj.responseText);
|
||||
var data = JSON.parse(htmlobj.responseText);
|
||||
newversion = data.version;
|
||||
if(version == newversion) {
|
||||
$("#update").html("<p>本地版本:" + version + "</p><p>最新版本:" + newversion + "</p><p>您的 PHPMC 已经是最新版本,无需更新。</p>");
|
||||
return;
|
||||
}
|
||||
$("#update").html("<p>本地版本:" + version + "</p><p>最新版本:" + newversion + "</p><p>更新内容:<br>" + data.feature + "</p><p><button class='btn btn-primary' onclick='update()'>立即更新</button></p>");
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
function update() {
|
||||
window.parent.frames.showmsg("请稍后,正在执行系统更新...");
|
||||
var htmlobj = $.ajax({
|
||||
url: "?action=update",
|
||||
async:true,
|
||||
timeout:100000,
|
||||
error: function(e) {
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
},
|
||||
success: function() {
|
||||
console.log(htmlobj.responseText);
|
||||
window.parent.frames.showmsg(htmlobj.responseText);
|
||||
location = '?page=setting'
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
window.onload = function() {
|
||||
checkUpdate();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user