- Removed AngularJS 1.4.8 completely — no more framework dependency - Extracted core RCON logic into pure vanilla JS (js/rcon.js) - Added lightweight hash-based SPA router (js/router.js) - Rewrote all 6 pages as vanilla JS modules in js/pages/ - Migrated Bootstrap 3 → Bootstrap 5 (cards instead of panels, bootstrap-icons instead of glyphicons) - Removed jQuery dependency (Bootstrap 5 is vanilla JS) - Purged all Angular templates from html/ - Removed npm artifacts (package.json, node_modules) - Added nginx.example.conf for static hosting - Updated rcon.css dark theme for BS5 variables - Static file only — no Node.js backend required Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
48 lines
1010 B
JavaScript
48 lines
1010 B
JavaScript
/**
|
|
* Utility functions shared across pages.
|
|
*/
|
|
|
|
/**
|
|
* Convert seconds to a human-readable duration string.
|
|
* e.g., 3723 → "1h2m3s"
|
|
*/
|
|
function secondsToDuration(input) {
|
|
input = parseInt(input, 10);
|
|
if (isNaN(input)) return '0s';
|
|
|
|
var out = '';
|
|
var hours = Math.floor(input / 3600);
|
|
if (hours > 0) out += hours + 'h';
|
|
|
|
var minutes = Math.floor((input % 3600) / 60);
|
|
if (minutes > 0) out += minutes + 'm';
|
|
|
|
var seconds = input % 60;
|
|
out += seconds + 's';
|
|
|
|
return out;
|
|
}
|
|
|
|
/**
|
|
* Strip HTML tags from a string.
|
|
*/
|
|
function stripHtml(text) {
|
|
return text ? String(text).replace(/<[^>]+>/gm, '') : '';
|
|
}
|
|
|
|
/**
|
|
* Format a number with locale-aware separators (fallback).
|
|
*/
|
|
function formatNumber(n) {
|
|
n = parseInt(n, 10);
|
|
if (isNaN(n)) return '0';
|
|
return n.toLocaleString ? n.toLocaleString() : String(n);
|
|
}
|
|
|
|
/**
|
|
* Check if user is scrolled to the bottom of an element.
|
|
*/
|
|
function isScrolledToBottom(el) {
|
|
return (el.scrollTop + el.clientHeight) >= (el.scrollHeight - 10);
|
|
}
|