mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-30 01:21:54 +08:00
index
This commit is contained in:
58
web/js/index/main.js
Normal file
58
web/js/index/main.js
Normal file
@@ -0,0 +1,58 @@
|
||||
function main() {
|
||||
__setAppText();
|
||||
__loadKvmdInfo();
|
||||
}
|
||||
|
||||
function __setAppText() {
|
||||
var url = window.location.href;
|
||||
$("app-text").innerHTML = `
|
||||
<span class="code-comment"># On Linux using Chromium/Chrome via any terminal:<br>
|
||||
$</span> \which chromium 2>/dev/null || which chrome 2>/dev/null\ --app="${url}"<br>
|
||||
<br>
|
||||
<span class="code-comment"># On MacOS using Terminal application:<br>
|
||||
$</span> /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app="${url}"<br>
|
||||
<br>
|
||||
<span class="code-comment"># On Windows via cmd.exe:<br>
|
||||
C:\></span> start chrome --app="${url}"
|
||||
`;
|
||||
}
|
||||
|
||||
function __loadKvmdInfo() {
|
||||
var http = tools.makeRequest("GET", "/kvmd/info", function() {
|
||||
if (http.readyState === 4) {
|
||||
if (http.status === 200) {
|
||||
var info = JSON.parse(http.responseText).result;
|
||||
|
||||
var apps = Object.values(info.extras).sort(function(a, b) {
|
||||
if (a["place"] < b["place"]) {
|
||||
return -1;
|
||||
} else if (a["place"] > b["place"]) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
apps.forEach(function(app) {
|
||||
$("apps").innerHTML += `
|
||||
<li>
|
||||
<div class="app">
|
||||
<a href="${app.path}">
|
||||
<div>
|
||||
<img class="svg-gray" src="${app.icon}">
|
||||
${app.name}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
`;
|
||||
});
|
||||
|
||||
if (info.meta && info.meta.server && info.meta.server.host) {
|
||||
$("kvmd-meta-server-host").innerHTML = info.meta.server.host;
|
||||
}
|
||||
} else {
|
||||
setTimeout(__loadKvmdInfo, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user