first commit

This commit is contained in:
2026-01-23 15:55:56 +01:00
commit b3827576da
34 changed files with 3805 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
const loader = document.querySelector(".loader")
function toggleLoadingBar() {
if (loader.hasAttribute("hidden")) {
loader.removeAttribute("hidden")
} else {
loader.setAttribute("hidden", "")
}
}
function showLoadingBar() {
if (loader.hasAttribute("hidden")) {
loader.removeAttribute("hidden")
}
}
function hideLoadingBar() {
if (!loader.hasAttribute("hidden")) {
loader.setAttribute("hidden", "")
}
}
window.addEventListener("wheel", (e) => {
if (e.ctrlKey) {
e.preventDefault()
}
}, { passive: false })
window.onpopstate = (event) => {
window.history.pushState(null, document.title, window.location.href)
}

View File

@@ -0,0 +1,10 @@
const frames = document.querySelectorAll("article.frame")
function showFrame(frameIdentifier) {
for (const frame of frames) {
frame.setAttribute("hidden", "")
if (frame.classList.contains(frameIdentifier)) {
frame.removeAttribute("hidden")
}
}
}

34
wwwroot/assets/js/ipc.js Normal file
View File

@@ -0,0 +1,34 @@
const system = {
_pendingRequests: new Map(),
init: function() {
window.external.receiveMessage(response => {
try {
const res = JSON.parse(response)
if (res.requestId && this._pendingRequests.has(res.requestId)) {
const { resolve } = this._pendingRequests.get(res.requestId)
this._pendingRequests.delete(res.requestId)
resolve(res.payload)
}
} catch (e) {
console.error("Erreur format message :", e)
}
})
},
call: function(functionName, data = {}) {
return new Promise((resolve, reject) => {
const requestId = Math.random().toString(36).substring(7)
this._pendingRequests.set(requestId, { resolve, reject })
window.external.sendMessage(JSON.stringify({
requestId: requestId,
functionName: functionName,
payload: data
}))
})
}
}
system.init()

112
wwwroot/assets/js/logged.js Normal file
View File

@@ -0,0 +1,112 @@
const player = await system.call("launcher::profile")
const buttons = document.querySelectorAll("button[frame]")
const dynmapFrame = document.querySelector("article.frame.dynmap > iframe")
const skinViewer = new skinview3d.SkinViewer({
canvas: document.getElementById("skin"),
width: 390,
height: 490,
skin: "assets/img/debug_skin.png"
})
skinViewer.animation = new skinview3d.IdleAnimation()
skinViewer.animation.speed = 1
function setActiveButton(frameIdentifier) {
for (const button of buttons) {
button.classList.remove("active")
if (button.getAttribute("frame") == frameIdentifier) {
button.classList.add("active")
}
}
}
function fixedTo(number, n) {
const k = Math.pow(10, n)
const result = (Math.round(number * k) / k)
return Number.isInteger(result) ? result.toFixed(2) : result
}
function flattenSettings(obj, prefix = "") {
return Object.keys(obj).reduce((acc, k) => {
const pre = prefix.length ? prefix + ".": "";
if (typeof obj[k] === "object" && obj[k] !== null && !Array.isArray(obj[k])) {
Object.assign(acc, flattenSettings(obj[k], pre + k));
} else {
acc[pre + k] = obj[k];
}
return acc;
}, {});
}
window.setting = {}
window.setting.set = async function settingSet(key, value) {
console.log(key, value)
await system.call("settings::set", { key, value })
}
window.showPage = function showPage(frameIdentifier) {
showFrame(frameIdentifier)
setActiveButton(frameIdentifier)
}
window.initDynmap = async function initDynmap() {
const dynampUrl = await system.call("lentia::dynamp") || "http://azures.fr:8123/"
if (dynmapFrame.src != dynampUrl) {
dynmapFrame.src = dynampUrl
}
}
window.getRamInformation = async function getRamInformation() {
const $ram = await system.call("hardware::ram")
ram.setAttribute("max", Math.floor($ram.freeGb * 1024))
freeRam.innerText = `${$ram.totalGb} Gb`
totalRam.innerText = `${$ram.freeGb} Gb`
}
window.handleSettingsChanges = async function handleSettingsChanges(key, value) {
const span = document.querySelector(`span#${key.includes("ram") ? "currentRam" : key}`)
setting.set(key, value)
if (span) {
span.innerText = key.includes("ram") ? fixedTo(value / 1024, 2) + " G" : value
}
}
window.initSettings = async function initSettings() {
const settings = await system.call("settings::read")
ram.value = settings.ram.max
javaPath.value = settings.javaPath
currentRam.innerText = fixedTo(settings.ram.max / 1024, 2) + " G"
getRamInformation()
}
window.initSkin = async function initSkin() {
const container = document.querySelector(".skinview3d")
if (container.clientWidth === 0 || container.clientHeight === 0) {
requestAnimationFrame(initSkin)
return
}
const skinViewer = new skinview3d.SkinViewer({
canvas: document.getElementById("skin"),
width: container.clientWidth,
height: container.clientHeight,
skin: "assets/img/debug_skin.png"
})
const ro = new ResizeObserver(() => {
skinViewer.width = container.clientWidth
skinViewer.height = container.clientHeight
})
skinViewer.animation = new skinview3d.IdleAnimation()
window.skinViewer = skinViewer
ro.observe(container)
}
initSkin()
initSettings()

View File

@@ -0,0 +1,39 @@
const version = document.querySelector("#version")
const information = document.querySelector(".information")
document.addEventListener("DOMContentLoaded", async () => {
version.innerText = `Launcher ${await system.call("launcher::version")}`
})
function showInformation() {
return information.removeAttribute("hidden")
}
function hideInformation() {
return information.setAttribute("hidden", "")
}
async function login() {
const username = document.querySelector("#username").value
const password = document.querySelector("#password").value
const result = await system.call("auth::lentia", { username, password })
if (result.success == false) {
await system.call("dialog::error", {
title: result.error.error,
message: result.error.errorMessage
})
}
}
function clearPassword() {
password.value = ""
}
function requestLoginWithOAuth2() {
showFrame("oauth2")
hideInformation()
showLoadingBar()
}
hideLoadingBar()
showFrame("provider")

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long