diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 42adb44..301e978 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ version: 2 updates: - - package-ecosystem: "npm" - directory: "/" + - package-ecosystem: 'npm' + directory: '/' schedule: - interval: "weekly" + interval: 'weekly' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec6c22e..50062bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version-file: "package.json" + node-version-file: 'package.json' - name: Install dependencies run: npm ci - name: Lint diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 627ca96..2c661d5 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: concurrency: - group: "gh-pages" + group: 'gh-pages' cancel-in-progress: false jobs: @@ -21,7 +21,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version-file: "package.json" + node-version-file: 'package.json' - name: Install dependencies run: npm ci - name: Build diff --git a/.prettierrc.json b/.prettierrc.json index 8cf5d1d..db76700 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,5 @@ { "printWidth": 1000, - "useTabs": true + "useTabs": true, + "singleQuote": true } diff --git a/eslint.config.js b/eslint.config.js index e8ca6af..07b1e7f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,12 +1,4 @@ -import eslint from "@eslint/js"; -import tseslint from "typescript-eslint"; +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; -export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked, { - ignores: ["node_modules"], - languageOptions: { - parserOptions: { - project: true, - tsconfigRootDir: import.meta.dirname, - }, - }, -}); +export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended); diff --git a/public/404.html b/public/404.html index 7657efd..b3b25d6 100644 --- a/public/404.html +++ b/public/404.html @@ -3,7 +3,7 @@
- + diff --git a/public/home/archive/index.html b/public/home/archive/index.html index d3b7c79..cc16fac 100644 --- a/public/home/archive/index.html +++ b/public/home/archive/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/home/clients/index.html b/public/home/clients/index.html index 3e59d51..47a57a2 100644 --- a/public/home/clients/index.html +++ b/public/home/clients/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/home/downloads/index.html b/public/home/downloads/index.html index 6d7fc74..b9d5965 100644 --- a/public/home/downloads/index.html +++ b/public/home/downloads/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/home/game/index.html b/public/home/game/index.html index 0eff225..1caf7c7 100644 --- a/public/home/game/index.html +++ b/public/home/game/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/index.html b/public/index.html index 5561ee2..e66fd97 100644 --- a/public/index.html +++ b/public/index.html @@ -19,15 +19,15 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/mods/client/index.html b/public/mods/client/index.html index cfa8b05..a5033f2 100644 --- a/public/mods/client/index.html +++ b/public/mods/client/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/mods/mods/index.html b/public/mods/mods/index.html index f8dabb9..a6556da 100644 --- a/public/mods/mods/index.html +++ b/public/mods/mods/index.html @@ -12,8 +12,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/mods/resourcepacks/index.html b/public/mods/resourcepacks/index.html index cc84f38..e80847b 100644 --- a/public/mods/resourcepacks/index.html +++ b/public/mods/resourcepacks/index.html @@ -12,8 +12,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/resources/styles/default.css b/public/resources/styles/default.css index f382ab6..ce2128b 100644 --- a/public/resources/styles/default.css +++ b/public/resources/styles/default.css @@ -1,6 +1,6 @@ body { margin: 0; - font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #1e1e1e; color: #fff; overflow: hidden; @@ -188,7 +188,7 @@ nav { display: flex; align-items: center; justify-content: center; - font-family: "MinecraftRegular", sans-serif; + font-family: 'MinecraftRegular', sans-serif; font-size: 1em; padding: 7px; border: 2px solid #000; @@ -273,7 +273,7 @@ nav { } .play-button::before { - content: ""; + content: ''; position: absolute; top: 50%; left: 50%; @@ -441,14 +441,14 @@ nav { select { width: 100%; padding: 10px; - font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: bold; color: #e0e0e0; background-color: #08a74a; box-shadow: 4px 4px 0px #2a2a2a, -4px -4px 0px #2a2a2a; border-radius: 3px; appearance: none; - background-image: url("/resources/images/icons/dropdown-selector.png"), linear-gradient(45deg, #0a8338, #086126); + background-image: url('/resources/images/icons/dropdown-selector.png'), linear-gradient(45deg, #0a8338, #086126); background-repeat: no-repeat, repeat; background-position: right 10px center, 0 0; background-size: 15px auto, 100%; diff --git a/public/servers/index.html b/public/servers/index.html index c8d8672..63fd198 100644 --- a/public/servers/index.html +++ b/public/servers/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/settings/index.html b/public/settings/index.html index b1a14f7..a44aa75 100644 --- a/public/settings/index.html +++ b/public/settings/index.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/temp.html b/public/temp.html index 81d6c73..8b920dc 100644 --- a/public/temp.html +++ b/public/temp.html @@ -11,8 +11,8 @@ function gtag() { dataLayer.push(arguments); } - gtag("js", new Date()); - gtag("config", "G-972V2NZ2ZK"); + gtag('js', new Date()); + gtag('config', 'G-972V2NZ2ZK'); diff --git a/public/updates/index.html b/public/updates/index.html index ebbf97f..d30191b 100644 --- a/public/updates/index.html +++ b/public/updates/index.html @@ -3,7 +3,7 @@ - + diff --git a/routes/index.js b/routes/index.js index b74eae6..e94eedb 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,9 +1,9 @@ -import { Router } from "express"; +import { Router } from 'express'; const router = Router(); /* GET home page. */ -router.get("/", function (req, res, next) { - res.render("index", { title: "Express" }); +router.get('/', function (req, res, next) { + res.render('index', { title: 'Express' }); }); export default router; diff --git a/routes/users.js b/routes/users.js index 2b0d593..e2e5cd4 100644 --- a/routes/users.js +++ b/routes/users.js @@ -1,9 +1,9 @@ -import { Router } from "express"; +import { Router } from 'express'; const router = Router(); /* GET users listing. */ -router.get("/", function (req, res, next) { - res.send("respond with a resource"); +router.get('/', function (req, res, next) { + res.send('respond with a resource'); }); export default router; diff --git a/server.js b/server.js index 3873a52..c4b4f82 100755 --- a/server.js +++ b/server.js @@ -1,28 +1,28 @@ -import createError from "http-errors"; -import express, { json, urlencoded, static as serveStatic } from "express"; -import { join } from "path"; -import cookieParser from "cookie-parser"; -import logger from "morgan"; -import debug from "debug"; -import { createServer } from "http"; -import indexRouter from "./routes/index.js"; -import usersRouter from "./routes/users.js"; +import createError from 'http-errors'; +import express, { json, urlencoded, static as serveStatic } from 'express'; +import { join } from 'path'; +import cookieParser from 'cookie-parser'; +import logger from 'morgan'; +import debug from 'debug'; +import { createServer } from 'http'; +import indexRouter from './routes/index.js'; +import usersRouter from './routes/users.js'; const __dirname = import.meta.dirname; const app = express(); -app.set("views", join(__dirname, "views")); -app.set("view engine", "pug"); +app.set('views', join(__dirname, 'views')); +app.set('view engine', 'pug'); -app.use(logger("dev")); +app.use(logger('dev')); app.use(json()); app.use(urlencoded({ extended: false })); app.use(cookieParser()); -app.use(serveStatic(join(__dirname, "public"))); +app.use(serveStatic(join(__dirname, 'public'))); -app.use("/", indexRouter); -app.use("/users", usersRouter); +app.use('/', indexRouter); +app.use('/users', usersRouter); app.use(function (req, res, next) { next(createError(404)); @@ -30,22 +30,22 @@ app.use(function (req, res, next) { app.use(function (err, req, res, next) { res.locals.message = err.message; - res.locals.error = req.app.get("env") === "development" ? err : {}; + res.locals.error = req.app.get('env') === 'development' ? err : {}; res.status(err.status || 500); - res.render("error"); + res.render('error'); }); -const debugLogger = debug("minexlauncher:server"); +const debugLogger = debug('minexlauncher:server'); -const port = normalizePort(process.env.PORT || "3000"); -app.set("port", port); +const port = normalizePort(process.env.PORT || '3000'); +app.set('port', port); const server = createServer(app); server.listen(port); -server.on("error", onError); -server.on("listening", onListening); +server.on('error', onError); +server.on('listening', onListening); function normalizePort(val) { const port = parseInt(val, 10); @@ -59,17 +59,17 @@ function normalizePort(val) { } function onError(error) { - if (error.syscall !== "listen") { + if (error.syscall !== 'listen') { throw error; } - const bind = typeof port === "string" ? "Pipe " + port : "Port " + port; + const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; switch (error.code) { - case "EACCES": - console.error(bind + " requires elevated privileges"); + case 'EACCES': + console.error(bind + ' requires elevated privileges'); process.exit(1); break; - case "EADDRINUSE": - console.error(bind + " is already in use"); + case 'EADDRINUSE': + console.error(bind + ' is already in use'); process.exit(1); break; default: @@ -79,6 +79,6 @@ function onError(error) { function onListening() { const addr = server.address(); - const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port; - debugLogger("Listening on " + bind); + const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; + debugLogger('Listening on ' + bind); } diff --git a/src/resources/scripts/main.ts b/src/resources/scripts/main.ts index cc2b695..ffe2e0a 100644 --- a/src/resources/scripts/main.ts +++ b/src/resources/scripts/main.ts @@ -1,52 +1,44 @@ -let selectedVersion = ""; - -document.addEventListener("DOMContentLoaded", function () { - const usernameForm = document.getElementById("username-form") as HTMLFormElement; - const usernameInput = document.getElementById("username-input") as HTMLInputElement; - const profileName = document.getElementById("profile-name"); - - const savedUsername = cookie.get("launcher_username"); - if (profileName && savedUsername) { - profileName.textContent = savedUsername; - } else if (profileName && !savedUsername) { - profileName.textContent = "Default"; - } - - if (profileName && window.location.pathname === "/settings/") { - usernameForm.addEventListener("submit", function (event) { - event.preventDefault(); - const username = usernameInput.value.trim(); - if (username) { - profileName.textContent = username; - cookie.set("launcher_username", username, 30); - } - }); - } -}); +const theme = { + load() { + const setTheme = cookie.get('minexlauncher.theme'); + if (setTheme === null) { + theme.set('default'); + } else if (setTheme !== 'default') { + const link = document.createElement('link'); + link.rel = 'stylesheet'; + link.href = '/resources/styles/' + setTheme + '.css'; + document.head.appendChild(link); + } + }, + set(setTheme: string) { + cookie.set('minexlauncher.theme', setTheme, 30); + window.location.reload(); + }, +}; const versionSelector = { open() { - const customOptions = document.querySelector(".custom-options"); - const customSelect = document.querySelector(".custom-select"); + const customOptions = document.querySelector('.custom-options'); + const customSelect = document.querySelector('.custom-select'); if (customOptions && customSelect) { - customOptions.classList.add("open"); - customSelect.classList.add("open"); + customOptions.classList.add('open'); + customSelect.classList.add('open'); } }, close() { - const customOptions = document.querySelector(".custom-options"); - const customSelect = document.querySelector(".custom-select"); + const customOptions = document.querySelector('.custom-options'); + const customSelect = document.querySelector('.custom-select'); if (customOptions && customSelect) { - customOptions.classList.remove("open"); - customSelect.classList.remove("open"); + customOptions.classList.remove('open'); + customSelect.classList.remove('open'); } }, toggle() { - const customOptions = document.querySelector(".custom-options"); - const customSelect = document.querySelector(".custom-select"); + const customOptions = document.querySelector('.custom-options'); + const customSelect = document.querySelector('.custom-select'); if (customOptions && customSelect) { - customOptions.classList.toggle("open"); - customSelect.classList.toggle("open"); + customOptions.classList.toggle('open'); + customSelect.classList.toggle('open'); } }, }; @@ -55,20 +47,20 @@ const game = { play(version?: string) { if (version) { embed.remove(); - // @ts-expect-error 1234567890 + // @ts-expect-error 123 window.top.location.href = version; } else if (selectedVersion) { embed.remove(); - // @ts-expect-error 1234567890 + // @ts-expect-error 123 window.top.location.href = selectedVersion; } else { - alert("Please select a version to play."); + alert('Please select a version to play.'); return; } }, select(path: string, name: string) { selectedVersion = path; - const selector = document.querySelector(".custom-select"); + const selector = document.querySelector('.custom-select'); if (selector?.textContent) { if (name) { selector.textContent = `Selected: ${name}`; @@ -80,13 +72,13 @@ const game = { }, archive(client: string) { const clients: Record${mod.description}
${mod.description}