modified: .gitignore modified: Cargo.lock modified: Cargo.toml modified: src/config.rs modified: src/launcher.rs modified: src/main.rs modified: src/minecraft.rs modified: src/www/portable.html
702 lines
34 KiB
HTML
702 lines
34 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script src=" https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js "></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<style>
|
|
::-webkit-scrollbar { display: none; }
|
|
body { overflow: hidden; }
|
|
</style>
|
|
</head>
|
|
<body class="flex bg-gray-100 h-screen">
|
|
<div id="sidebar" class="flex h-screen bg-white w-16 flex-col justify-between border-e border-gray-100 hidden">
|
|
<div>
|
|
<div class="inline-flex size-16 items-center justify-center">
|
|
<a href="#" onclick="showSection(this, 'appearance')">
|
|
<span class="grid size-10 place-content-center rounded-lg bg-[url(https://www.mc-heads.net/avatar/notch)] text-xs text-gray-600">
|
|
N
|
|
</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="border-t border-gray-100">
|
|
<div class="px-2">
|
|
<div class="py-4">
|
|
<a
|
|
href="#"
|
|
onclick="showSection(this, 'instances'); showInstancesSection()"
|
|
class="menu-btn t group relative flex justify-center rounded-sm bg-green-50 px-2 py-1.5 text-green-700"
|
|
>
|
|
<i class="fa-solid fa-gamepad"></i>
|
|
|
|
<span
|
|
class="invisible absolute start-full top-1/2 ms-4 -translate-y-1/2 rounded-sm bg-gray-900 px-2 py-1.5 text-xs font-medium text-white group-hover:visible"
|
|
>
|
|
Play
|
|
</span>
|
|
</a>
|
|
</div>
|
|
|
|
<ul class="space-y-1 border-t border-gray-100 pt-4">
|
|
<li>
|
|
<a
|
|
href="#"
|
|
onclick="showSection(this, 'add')"
|
|
class="menu-btn group relative flex justify-center rounded-sm px-2 py-1.5 text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
|
>
|
|
<i class="fa-solid fa-download"></i>
|
|
|
|
<span
|
|
class="invisible absolute start-full top-1/2 ms-4 -translate-y-1/2 rounded-sm bg-gray-900 px-2 py-1.5 text-xs font-medium text-white group-hover:visible"
|
|
>
|
|
Download
|
|
</span>
|
|
</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a
|
|
href="#"
|
|
onclick="showSection(this, 'servers'); showServersSection()"
|
|
class="menu-btn group relative flex justify-center rounded-sm px-2 py-1.5 text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
|
>
|
|
<i class="fa-solid fa-network-wired"></i>
|
|
|
|
<span
|
|
class="invisible absolute start-full top-1/2 ms-4 -translate-y-1/2 rounded-sm bg-gray-900 px-2 py-1.5 text-xs font-medium text-white group-hover:visible"
|
|
>
|
|
Servers
|
|
</span>
|
|
</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a
|
|
href="#"
|
|
onclick="showSection(this, 'accounts'); showAccountsSection()"
|
|
class="menu-btn group relative flex justify-center rounded-sm px-2 py-1.5 text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
|
>
|
|
<i class="fa-solid fa-user-group"></i>
|
|
|
|
<span
|
|
class="invisible absolute start-full top-1/2 ms-4 -translate-y-1/2 rounded-sm bg-gray-900 px-2 py-1.5 text-xs font-medium text-white group-hover:visible"
|
|
>
|
|
Accounts
|
|
</span>
|
|
</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a
|
|
href="#"
|
|
onclick="showSection(this, 'screenshots'); loadScreenshots()"
|
|
class="menu-btn group relative flex justify-center rounded-sm px-2 py-1.5 text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
|
>
|
|
<i class="fa-solid fa-image"></i>
|
|
|
|
<span
|
|
class="invisible absolute start-full top-1/2 ms-4 -translate-y-1/2 rounded-sm bg-gray-900 px-2 py-1.5 text-xs font-medium text-white group-hover:visible"
|
|
>
|
|
Screenshots
|
|
</span>
|
|
</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a
|
|
href="#"
|
|
onclick="showSection(this, 'settings')"
|
|
class="menu-btn group relative flex justify-center rounded-sm px-2 py-1.5 text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
|
>
|
|
<i class="fa-solid fa-gear"></i>
|
|
|
|
<span
|
|
class="invisible absolute start-full top-1/2 ms-4 -translate-y-1/2 rounded-sm bg-gray-900 px-2 py-1.5 text-xs font-medium text-white group-hover:visible"
|
|
>
|
|
Settings
|
|
</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex flex-col justify-center items-center">
|
|
|
|
<div id="popup" role="alert" class="mt-5 rounded-xl border border-gray-100 bg-white p-4 w-96 hidden">
|
|
<div class="flex items-start gap-4">
|
|
<span class="text-green-600">
|
|
<i class="fa-solid fa-info"></i>
|
|
</span>
|
|
|
|
<div class="flex-1">
|
|
<p id="popup_text" class="mt-1 text-sm text-gray-700">Your product changes have been saved.</p>
|
|
</div>
|
|
|
|
<button onClick="dismissPopup()" class="text-gray-500 transition hover:text-gray-600">
|
|
<span class="sr-only">Dismiss popup</span>
|
|
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke-width="1.5"
|
|
stroke="currentColor"
|
|
class="size-6"
|
|
>
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-center items-center w-screen h-screen">
|
|
<div id="logs-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h2 class="text-2xl font-semibold text-gray-700">Minecraft Logs</h2>
|
|
|
|
<!-- Log Output -->
|
|
<div id="log-container" class="mt-4 p-2 h-48 overflow-auto bg-gray-200 rounded text-left text-sm text-gray-800 font-mono">
|
|
|
|
</div>
|
|
|
|
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
|
|
</div>
|
|
|
|
<div id="loading-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h2 class="text-2xl font-semibold text-gray-700">Launching Minecraft</h2>
|
|
|
|
<p id="loading-text" class="mt-2 text-gray-500">Preparing...</p>
|
|
|
|
<div class="mt-4 w-full bg-gray-200 rounded-full">
|
|
<div id="progress-bar" class="h-4 bg-green-500 rounded-full transition-all" style="width: 0%;"></div>
|
|
</div>
|
|
|
|
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
|
|
</div>
|
|
|
|
<div id="installation-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center">
|
|
<h1 class="text-2xl font-semibold text-gray-700">Welcome to XCraft</h1>
|
|
<p class="mt-2 text-gray-600">Choose how you want to set up Minecraft.</p>
|
|
|
|
<button onclick="runPortable()"
|
|
class="mt-6 w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded transition">
|
|
Run in Portable Mode
|
|
</button>
|
|
<p class="text-sm text-gray-500 mt-1">No installation required. Saves everything in a local folder.</p>
|
|
|
|
<button onclick="installMinecraft()"
|
|
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
|
|
Install Minecraft
|
|
</button>
|
|
<p class="text-sm text-gray-500 mt-1">Installs Minecraft on your system for long-term use.</p>
|
|
</div>
|
|
|
|
<div id="login-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h2 class="text-2xl font-semibold text-gray-700">CraftX v1.0</h2>
|
|
|
|
|
|
<input id="sign_up_username" type="text" placeholder="Username" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500"> <!-- bg-red-50 border border-red-500 text-red-900 placeholder-red-700 focus:ring-2 focus:ring-red-500 -->
|
|
<p class="mt-2 text-sm text-red-600 dark:text-red-500 text-left hidden">Username has invalid characters or too short</p>
|
|
|
|
<button
|
|
onclick="signUp()"
|
|
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
|
|
Sign Up
|
|
</button>
|
|
|
|
|
|
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
|
|
</div>
|
|
|
|
<div id="add-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h1 class="text-2xl font-semibold text-gray-700">New instance</h1>
|
|
|
|
<label class="block mt-4 text-gray-600">Select Version:</label>
|
|
<select id="mc-version" class="mt-2 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
|
|
|
|
</select>
|
|
|
|
<button
|
|
onclick="downloadSelectedVersion()"
|
|
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
|
|
<i class="fa-solid fa-download"></i> Download Version
|
|
</button>
|
|
|
|
<div class="mt-4 text-gray-500 text-sm">or</div>
|
|
|
|
<button
|
|
class="mt-3 w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded transition">
|
|
<i class="fa-solid fa-file-zipper"></i> Add MultiMC Instance
|
|
</button>
|
|
|
|
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
|
|
</div>
|
|
|
|
<div id="settings-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h2 class="text-2xl font-semibold text-gray-700">XCraft Settings</h2>
|
|
|
|
<div class="mt-4 flex justify-around text-gray-600">
|
|
<button onClick="setSettingsTab('launcher')" class="py-2 px-4 focus:text-green-500"><i class="fa-solid fa-rocket"></i></br>Launcher</button>
|
|
<button onClick="setSettingsTab('appearance')" class="py-2 px-4 focus:text-green-500"><i class="fa-solid fa-palette"></i></br>Appearance</button>
|
|
<button onClick="setSettingsTab('java')" class="py-2 px-4 focus:text-green-500"><i class="fa-solid fa-mug-hot"></i></br>Java</button>
|
|
</div>
|
|
|
|
<div id="launcher-settings" class="settings-tab mt-4">
|
|
<div class="mt-4 flex justify-between items-center">
|
|
<label class="inline-flex items-center cursor-pointer">
|
|
<input id="show-beta" type="checkbox" value="" class="sr-only peer">
|
|
<div class="relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 dark:peer-focus:ring-green-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-green-600 dark:peer-checked:bg-green-600"></div>
|
|
<span class="ms-3 text-sm font-medium text-gray-900 dark:text-gray-300">Show beta versions</span>
|
|
</label>
|
|
</div>
|
|
<div class="mt-4 flex justify-between items-center">
|
|
<label class="inline-flex items-center cursor-pointer">
|
|
<input id="show-alpha" type="checkbox" value="" class="sr-only peer">
|
|
<div class="relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 dark:peer-focus:ring-green-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-green-600 dark:peer-checked:bg-green-600"></div>
|
|
<span class="ms-3 text-sm font-medium text-gray-900 dark:text-gray-300">Show alpha versions</span>
|
|
</label>
|
|
</div>
|
|
<div class="mt-4 flex justify-between items-center">
|
|
<label class="inline-flex items-center cursor-pointer">
|
|
<input id="show-snapshots" type="checkbox" value="" class="sr-only peer">
|
|
<div class="relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 dark:peer-focus:ring-green-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-green-600 dark:peer-checked:bg-green-600"></div>
|
|
<span class="ms-3 text-sm font-medium text-gray-900 dark:text-gray-300">Show snapshots</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="appearance-settings" class="settings-tab mt-4 hidden">
|
|
<div class="mt-4 flex items-center border border-gray-300 rounded-lg overflow-hidden">
|
|
<input type="file" id="bg-picker" class="hidden" accept=".jpg, .jpeg, .png" onchange="bgSelected(event)">
|
|
<input id="background-path" type="text" placeholder="Custom background name"
|
|
class="flex-1 px-4 py-2 focus:outline-none">
|
|
<button onclick="$('#bg-picker').click()"
|
|
class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 font-bold transition">
|
|
Set
|
|
</button>
|
|
</div>
|
|
<div class="mt-4 flex justify-between items-center">
|
|
<label class="inline-flex items-center cursor-pointer">
|
|
<input id="enable-blur" type="checkbox" value="" class="sr-only peer">
|
|
<div class="relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 dark:peer-focus:ring-green-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-green-600 dark:peer-checked:bg-green-600"></div>
|
|
<span class="ms-3 text-sm font-medium text-gray-900 dark:text-gray-300">Enable blur</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="java-settings" class="settings-tab mt-4 hidden">
|
|
<div class="mt-4 flex items-center border border-gray-300 rounded-lg overflow-hidden">
|
|
<input id="java-path" type="text" placeholder="Enter Java Path"
|
|
class="flex-1 px-4 py-2 focus:outline-none">
|
|
<button onclick="locateJava()"
|
|
class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 font-bold transition">
|
|
Auto
|
|
</button>
|
|
</div>
|
|
<label for="ram-input" class="block mb-2 text-sm font-medium text-gray-800 dark:text-white">Allocate memory (MB):</label>
|
|
<input type="number" id="ram-input" min="1024" step="1" aria-describedby="helper-text-explanation" class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-green-500 focus:border-green-500 block w-full p-2.5" placeholder="1024" value="1024" required />
|
|
</div>
|
|
|
|
<button
|
|
onClick="saveSettings()" class="w-full mt-6 bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
|
|
<i class="fa-solid fa-floppy-disk"></i> Save
|
|
</button>
|
|
|
|
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
|
|
</div>
|
|
|
|
<div id="appearance-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h2 class="text-2xl font-semibold text-gray-700">Account Settings</h2>
|
|
|
|
<div class="mt-6 text-left">
|
|
<label class="text-gray-600 font-medium">Offline username</label>
|
|
<input type="text" placeholder="Username" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
|
|
</div>
|
|
|
|
<!-- Skin Upload -->
|
|
<div class="mt-6 text-left">
|
|
<label class="text-gray-600 font-medium">Minecraft Skin</label>
|
|
<div class="mt-2 flex items-center gap-4">
|
|
<img id="skin-preview" src="https://www.mc-heads.net/avatar/notch" class="w-16 h-16 rounded-md border" alt="Skin Preview">
|
|
<input id="skin-upload" type="file" accept=".png" class="hidden" onchange="previewSkin()">
|
|
<button onclick="document.getElementById('skin-upload').click()"
|
|
class="bg-green-500 hover:bg-green-700 text-white px-4 py-2 rounded">
|
|
Upload
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Cape Upload -->
|
|
<div class="mt-6 text-left">
|
|
<label class="text-gray-600 font-medium">Minecraft Cape</label>
|
|
<div class="mt-2 flex items-center gap-4">
|
|
<img id="cape-preview" src="https://skinmc.net/capes/77863/download" class="w-16 h-16 rounded-md border" alt="Cape Preview">
|
|
<input id="cape-upload" type="file" accept=".png" class="hidden" onchange="previewCape()">
|
|
<button onclick="document.getElementById('cape-upload').click()"
|
|
class="bg-green-500 hover:bg-green-700 text-white px-4 py-2 rounded">
|
|
Upload
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Save Button -->
|
|
<button
|
|
class="mt-6 w-full bg-green-500 hover:bg-green-700 text-white py-2 rounded font-bold transition">
|
|
Save Settings
|
|
</button>
|
|
</div>
|
|
|
|
<div id="accounts-section" class="xsection grid grid-cols-3 gap-4 p-6 w-fill hidden">
|
|
<div class="bg-white cursor-pointer hover:bg-green-500 hover:text-white shadow-lg rounded-xl w-48 h-24 flex justify-center items-center">
|
|
<img src="https://www.mc-heads.net/avatar/MHF_Steve" class="w-12 h-12 rounded-full">
|
|
<div class="h-fill ms-2">
|
|
<h2 class="text-lg font-semibold">DartJevder</h2>
|
|
<h2 class="text-sm font-semibold">Blatnoe Pivo</h2>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="instances-section" class="xsection grid grid-cols-3 gap-4 p-6 w-fill hidden">
|
|
</div>
|
|
|
|
<div id="screenshots-section" class="xsection grid grid-cols-3 gap-4 p-6 w-fill h-screen overflow-y-auto hidden">
|
|
|
|
</div>
|
|
|
|
<div id="add-server-section" class="xsection bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
|
|
<h2 class="text-2xl font-semibold text-gray-700">Add Server</h2>
|
|
<input id="server_address" type="text" placeholder="127.0.0.1:25565#8999" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
|
|
<p class="mt-2 text-sm text-green-500 text-left">XCraft servers are using their own session servers, to specify its port, use #PORT, or don't if it's 8999</p>
|
|
|
|
<input id="server_username" type="text" placeholder="Username" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500"> <!-- bg-red-50 border border-red-500 text-red-900 placeholder-red-700 focus:ring-2 focus:ring-red-500 -->
|
|
<p class="mt-2 text-sm text-red-600 dark:text-red-500 text-left hidden">Username has invalid characters or too short</p>
|
|
|
|
<input id="server_password" type="password" placeholder="Password" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
|
|
<!-- Sign In Button -->
|
|
<button
|
|
onclick="addServerInstance()"
|
|
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
|
|
Add
|
|
</button>
|
|
|
|
<!-- Footer -->
|
|
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
|
|
</div>
|
|
|
|
<div id="servers-section" class="xsection grid grid-cols-3 gap-4 p-6 w-fill hidden">
|
|
<div onClick="addServer()" class="bg-white shadow-lg rounded-xl w-48 h-24 flex justify-center items-center text-3xl text-green-500 cursor-pointer hover:bg-green-500 hover:text-white"><i class="fa-solid fa-plus"></i></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var chosenDomain = undefined;
|
|
var chosenNickname = undefined;
|
|
|
|
function processParams(r) {
|
|
let params = JSON.parse(r).params;
|
|
for( let i = 0; i < params.length; i++ ) {
|
|
if( params[i].startsWith("show_") ) {
|
|
showSection(undefined, params[i].substring(5));
|
|
} else if( params[i] == "sidebar_on" ) {
|
|
$("#sidebar").removeClass('hidden');
|
|
} else if( params[i] == "sidebar_off") {
|
|
$("#sidebar").addClass('hidden');
|
|
}
|
|
|
|
if( params[i] == "show_add" ) {
|
|
showAddSection();
|
|
} else if( params[i] == "set_downloadable_versions" ) {
|
|
setDownloadableVersions(params.slice(i+1));
|
|
break;
|
|
} else if( params[i] == "update_downloads" ) {
|
|
updateDownloads(params.slice(i+1));
|
|
break;
|
|
} else if( params[i] == "show_instances") {
|
|
showInstancesSection();
|
|
} else if( params[i] == "set_instances_list" ) {
|
|
setInstancesList(params.slice(i+1));
|
|
break;
|
|
} else if( params[i] == "fetch_servers_list" ) {
|
|
setServersList(params.slice(i+1));
|
|
break;
|
|
} else if( params[i] == "locate_java" ) {
|
|
setJavaPath(params[i+1]);
|
|
break;
|
|
} else if( params[i] == "add_server_response" ) {
|
|
addServerResponse(params[i+1], params[i+2]);
|
|
break;
|
|
} else if( params[i] == "fetch_settings_response" ) {
|
|
setSettings(params.slice(i+1));
|
|
break;
|
|
} else if( params[i] == "load_screenshots" ) {
|
|
setScreenshots(params.slice(i+1));
|
|
break;
|
|
} else if( params[i] == "fetch_bg") {
|
|
setBackground(params[i+1]);
|
|
i++;
|
|
} else if( params[i] == "update_logs" ) {
|
|
updateLogs(params[i+1]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function showAccountsSection() {
|
|
//$.post({url: "fetch_credentials_list" }, processParams);
|
|
}
|
|
|
|
function updateLogs(text) {
|
|
$("#log-container").append("<p>"+text+"</p>");
|
|
$("#log-container").scrollTop($("#log-container")[0].scrollHeight);
|
|
}
|
|
|
|
function setBackground(bg) {
|
|
$("body").removeClass("bg-gray-100");
|
|
$("body").css("background-image", 'url("'+bg+'")');
|
|
$("body").css("background-size", "cover");
|
|
$("body").css("background-repeat", "no-repeat");
|
|
$("body").css("background-position", "center center");
|
|
}
|
|
|
|
function setScreenshots(params) {
|
|
$("#screenshots-section").html("");
|
|
for( let i = 0; i < params.length; i+=2 ) {
|
|
$("#screenshots-section").append(
|
|
`<div onclick="openFile('`+params[i].replaceAll("\\", "\\\\")+`')" class="bg-white cursor-pointer hover:bg-green-500 hover:text-white shadow-lg rounded-xl w-48 h-[7rem] flex justify-center items-center">
|
|
<img src="`+params[i+1]+`" class="w-fill h-fill rounded-xl">
|
|
</div>`
|
|
);
|
|
}
|
|
}
|
|
|
|
function openFile(path) {
|
|
$.post({url: "open_file", data: JSON.stringify({ params: [path] })}, processParams);
|
|
}
|
|
|
|
function loadScreenshots() {
|
|
$.post({url: "load_screenshots" }, processParams);
|
|
}
|
|
|
|
function bgSelected(event) {
|
|
let file = event.target.files[0];
|
|
if(file) {
|
|
let allowedTypes = ["image/jpeg", "image/png"];
|
|
if (allowedTypes.includes(file.type)) {
|
|
$("#background-path").val(file.name);
|
|
let reader = new FileReader();
|
|
reader.onload = function(e) {
|
|
$.post({url: "save_bg", data: JSON.stringify({ params: [e.target.result] })}, processParams);
|
|
}
|
|
reader.readAsDataURL(file);
|
|
} else {
|
|
showPopup("This format is not allowed!");
|
|
}
|
|
}
|
|
}
|
|
|
|
function saveSettings() {
|
|
let show_alpha = $("#show-alpha").prop('checked');
|
|
let show_beta = $("#show-beta").prop('checked');
|
|
let show_snapshots = $("#show-snapshots").prop('checked');
|
|
let java_path = $("#java-path").val();
|
|
let ram_input = $("#ram-input").val();
|
|
let enable_blur = $("#enable-blur").prop('checked');
|
|
$.post({url: "update_settings", data: JSON.stringify({ params: [show_alpha+"", show_beta+"", show_snapshots+"", java_path, ram_input+"", enable_blur+""] }) }, processParams);
|
|
showPopup("Saved!");
|
|
}
|
|
|
|
function setSettings(params) {
|
|
$("#show-alpha").prop('checked', (params[0] === 'true'));
|
|
$("#show-beta").prop('checked', (params[1] === 'true'));
|
|
$("#show-snapshots").prop('checked', (params[2] === 'true'));
|
|
$("#java-path").val(params[3]);
|
|
$("#ram-input").val(params[4]);
|
|
$("#enable-blur").prop('checked', (params[5] == 'true'));
|
|
if( params[5] == 'true' ) {
|
|
enableBlur();
|
|
}
|
|
}
|
|
|
|
function enableBlur() {
|
|
$(".xsection").removeClass("bg-white");
|
|
$(".xsection").addClass("backdrop-blur-md");
|
|
$("#sidebar").removeClass("bg-white");
|
|
$("#sidebar").addClass("backdrop-blur-md");
|
|
}
|
|
|
|
function dismissPopup() {
|
|
$("#popup").addClass("hidden");
|
|
}
|
|
|
|
function showPopup(text) {
|
|
$("#popup_text").html(text);
|
|
$("#popup").removeClass("hidden");
|
|
}
|
|
|
|
function addServerResponse(status, msg) {
|
|
showPopup(msg);
|
|
}
|
|
|
|
function addServerInstance() {
|
|
let server = $("#server_address").val();
|
|
let username = $("#server_username").val();
|
|
let password = $("#server_password").val();
|
|
|
|
$.post({url: "add_server", data: JSON.stringify({ params: [server, username, password] }) }, processParams);
|
|
}
|
|
|
|
function addServer() {
|
|
showSection(undefined, "add-server");
|
|
}
|
|
|
|
function setJavaPath(javaPath) {
|
|
$("#java-path").val(javaPath);
|
|
}
|
|
|
|
function locateJava() {
|
|
$.post({url: "locate_java" }, processParams);
|
|
}
|
|
|
|
function setInstancesList(params) {
|
|
$("#instances-section").html("");
|
|
for( let i = 0; i < params.length; i+=3 ) {
|
|
let instance = `<div onclick="runInstance('`+params[i]+`')" class="bg-white cursor-pointer hover:bg-green-500 hover:text-white shadow-lg rounded-xl w-48 h-24 flex justify-center items-center">
|
|
<img src="`+params[i+2]+`" class="w-12 h-12 rounded-full">
|
|
<div class="h-fill ms-2">
|
|
<h2 class="text-lg font-semibold">` + params[i+1] + `</h2>
|
|
<h2 class="text-sm font-semibold">` + params[i] + `</h2>
|
|
</div>
|
|
</div>`;
|
|
$("#instances-section").append(instance);
|
|
}
|
|
}
|
|
|
|
function setServersList(params) {
|
|
$(".server-instance").remove();
|
|
for( let i = 0; i < params.length; i+=3) {
|
|
let instance = `<div onclick="runServerConnection('`+params[i]+`', '`+params[i+1]+`')" class="server-instance bg-white cursor-pointer hover:bg-green-500 hover:text-white shadow-lg rounded-xl w-48 h-24 flex justify-center items-center">
|
|
<img src="`+params[i+2]+`" class="w-12 h-12 rounded-full">
|
|
<div class="h-fill ms-2">
|
|
<h2 class="text-lg font-semibold">`+params[i]+`</h2>
|
|
<h2 class="text-sm font-semibold">`+params[i+1]+`</h2>
|
|
</div>
|
|
</div>`;
|
|
$("#servers-section").append(instance);
|
|
}
|
|
}
|
|
|
|
function runServerConnection(domain, nickname) {
|
|
chosenDomain = domain;
|
|
chosenNickname = nickname;
|
|
showSection(undefined, "instances");
|
|
showInstancesSection();
|
|
}
|
|
|
|
function updateDownloads(params) {
|
|
let text = params[0];
|
|
let percentage = params[1];
|
|
if( text != "_" ) {
|
|
$("#loading-text").html(text);
|
|
$("#progress-bar").css("width", percentage+"%");
|
|
} else {
|
|
$("#sidebar").removeClass('hidden');
|
|
showSection(undefined, "instances");
|
|
showInstancesSection();
|
|
}
|
|
}
|
|
|
|
function showServersSection() {
|
|
$.post({url: "fetch_servers_list" }, processParams);
|
|
}
|
|
|
|
function showInstancesSection() {
|
|
$.post({url: "fetch_instances_list" }, processParams);
|
|
}
|
|
|
|
function runInstance(version) {
|
|
$("#log-container").html("");
|
|
if( chosenDomain == undefined || chosenNickname == undefined ) {
|
|
$.post({url: "run_instance", data: JSON.stringify({ params: [version] })}, processParams);
|
|
} else {
|
|
$.post({url: "run_server_instance", data: JSON.stringify({ params: [version, chosenDomain, chosenNickname] })}, processParams);
|
|
chosenDomain = undefined;
|
|
chosenNickname = undefined;
|
|
}
|
|
showSection(undefined, "logs");
|
|
}
|
|
|
|
function downloadSelectedVersion() {
|
|
let version = $('#mc-version :selected').text();
|
|
$.post({url: "download_vanilla", data: JSON.stringify({ params: [version] })}, processParams);
|
|
}
|
|
|
|
function showAddSection() {
|
|
$.post({url: "fetch_official_versions" }, processParams);
|
|
}
|
|
|
|
function setDownloadableVersions(versions) {
|
|
$("#mc-version").html("");
|
|
for( let i = 0; i < versions.length; i++ ) {
|
|
$("#mc-version").append(new Option(versions[i], versions[i]));
|
|
}
|
|
}
|
|
|
|
function signUp() {
|
|
$.post({url: "sign_up", data: JSON.stringify({params: [$("#sign_up_username").val()]})}, processParams)
|
|
}
|
|
|
|
function runPortable() {
|
|
$.get("portable", processParams);
|
|
}
|
|
|
|
function installMinecraft() {
|
|
$.get("installation", processParams);
|
|
}
|
|
|
|
function setSettingsTab(tab_name) {
|
|
$(".settings-tab").each(function(i, d) {
|
|
$(d).addClass('hidden');
|
|
});
|
|
$("#"+tab_name+"-settings").removeClass('hidden');
|
|
}
|
|
|
|
function showSection(obj, section) {
|
|
|
|
$(".menu-btn").each(function(i, d) {
|
|
$(d).removeClass('bg-green-50');
|
|
$(d).addClass('text-gray-500');
|
|
$(d).removeClass('text-green-700');
|
|
});
|
|
$(obj).addClass('bg-green-50');
|
|
$(obj).addClass('text-green-700');
|
|
$(obj).removeClass('text-gray-500');
|
|
$(".xsection").each(function(i, d) {
|
|
$(d).addClass('hidden');
|
|
});
|
|
$("#"+section+"-section").removeClass('hidden');
|
|
}
|
|
|
|
$( document ).ready(async function() {
|
|
$.get("check_installation", processParams);
|
|
$.get("fetch_settings", processParams);
|
|
$.get("fetch_bg", processParams);
|
|
setInterval(function() {
|
|
if( !$("#loading-section").hasClass("hidden") ) {
|
|
$.get("check_download_status", processParams);
|
|
}
|
|
if( !$("#logs-section").hasClass("hidden") ) {
|
|
$.get("check_logs_status", processParams);
|
|
}
|
|
}, 10);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |