Refactor store UI into dynamic multi-view shell

- Replace static HTML markup with app root and runtime asset loading
- Rebuild `script.js` as state-driven category/weapon/catalog views
- Add cart overlay scaffold, breadcrumbs, and window-style navigation UI
This commit is contained in:
Jacob Schmidt 2026-03-10 00:13:56 -05:00
parent 9cd7278746
commit 4ee6537fbc
3 changed files with 1543 additions and 977 deletions

View File

@ -1,149 +1,61 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FORGE Supply Exchange</title>
<script>
const addonRoot = "forge\\forge_client\\addons\\store\\ui\\_site\\";
const styleFiles = ["style.css"];
const scriptFiles = ["script.js"];
<head> function requestText(path) {
<meta charset="UTF-8"> if (
<meta name="viewport" content="width=device-width, initial-scale=1.0"> typeof A3API !== "undefined" &&
<title>Store</title> typeof A3API.RequestFile === "function"
<!-- <link rel="stylesheet" href="style.css" /> --> ) {
<!-- return A3API.RequestFile(addonRoot + path);
Dynamic Resource Loading }
The following script loads CSS and JavaScript files dynamically using the A3API
This approach is used instead of static HTML imports to work with Arma 3's file system
-->
<script>
Promise.all([
A3API.RequestFile(
"forge\\forge_client\\addons\\store\\ui\\_site\\style.css",
),
A3API.RequestFile(
"forge\\forge_client\\addons\\store\\ui\\_site\\script.js",
),
]).then(([css, js]) => {
const style = document.createElement("style");
style.textContent = css;
document.head.appendChild(style);
const script = document.createElement("script"); return fetch(path).then((response) => {
script.text = js; if (!response.ok) {
document.head.appendChild(script); throw new Error("Failed to load " + path);
}); }
</script>
</head>
<body> return response.text();
<div class="store-container"> });
<!-- Header Section --> }
<div class="store-header">
<div class="store-logo">
<div class="logo-icon">🛒</div>
</div>
<div class="store-info">
<h1 class="store-title">Supply Store</h1>
<p class="store-subtitle">Equipment & Resources</p>
</div>
<div class="balance-display">
<span class="balance-label">Available Funds</span>
<span class="balance-amount">$45,750</span>
</div>
<div class="header-actions">
<button class="action-btn cart-btn" id="cartToggle">
<span class="cart-icon">Cart</span>
<span class="cart-count">0</span>
</button>
<button class="action-btn close-btn">Close</button>
</div>
</div>
<!-- Main Content --> function appendStyle(css) {
<div class="store-content"> const style = document.createElement("style");
<!-- Left Panel - Categories --> style.textContent = css;
<div class="store-panel categories-panel"> document.head.appendChild(style);
<div class="panel-header"> }
<h2 class="panel-title">Categories</h2>
</div>
<div class="panel-content">
<div class="category-list">
<button class="category-item active" data-category="all">
<span class="category-icon"></span>
<span class="category-name">All Items</span>
<span class="category-count">24</span>
</button>
<button class="category-item" data-category="weapons">
<span class="category-icon"></span>
<span class="category-name">Weapons</span>
<span class="category-count">8</span>
</button>
<button class="category-item" data-category="equipment">
<span class="category-icon"></span>
<span class="category-name">Equipment</span>
<span class="category-count">6</span>
</button>
<button class="category-item" data-category="medical">
<span class="category-icon"></span>
<span class="category-name">Medical</span>
<span class="category-count">5</span>
</button>
<button class="category-item" data-category="supplies">
<span class="category-icon"></span>
<span class="category-name">Supplies</span>
<span class="category-count">5</span>
</button>
</div>
</div>
</div>
<!-- Center Panel - Items Grid --> function appendScript(js) {
<div class="store-panel items-panel"> const script = document.createElement("script");
<div class="panel-header"> script.text = js;
<h2 class="panel-title">Available Items</h2> document.head.appendChild(script);
<div class="search-box"> }
<input type="text" class="search-input" placeholder="Search items..." id="searchInput">
</div>
</div>
<div class="panel-content">
<div class="items-grid" id="itemsGrid">
<!-- Items will be dynamically generated -->
</div>
</div>
</div>
<!-- Right Panel - Cart (Initially Hidden) --> Promise.all(styleFiles.map(requestText))
<div class="store-panel cart-panel" id="cartPanel" style="display: none;"> .then((styles) => {
<div class="panel-header"> styles.forEach(appendStyle);
<h2 class="panel-title">Shopping Cart</h2> return Promise.all(scriptFiles.map(requestText));
<button class="clear-cart-btn" id="clearCart">Clear</button> })
</div> .then((scripts) => {
<div class="panel-content"> scripts.forEach(appendScript);
<div class="cart-items" id="cartItems"> })
<div class="empty-cart"> .catch((error) => {
<span class="empty-icon"></span> console.error(
<span class="empty-text">Your cart is empty</span> "[Store UI] Failed to load site assets.",
</div> error,
</div> );
<div class="cart-summary"> });
<div class="summary-row"> </script>
<span class="summary-label">Subtotal</span> </head>
<span class="summary-value" id="cartSubtotal">$0</span>
</div>
<div class="summary-row">
<span class="summary-label">Tax (5%)</span>
<span class="summary-value" id="cartTax">$0</span>
</div>
<div class="summary-row summary-total">
<span class="summary-label">Total</span>
<span class="summary-value" id="cartTotal">$0</span>
</div>
<button class="action-btn action-btn-primary checkout-btn" id="checkoutBtn">
Complete Purchase
</button>
</div>
</div>
</div>
</div>
</div>
<!-- <script src="script.js"></script> -->
</body>
<body>
<div id="app"></div>
</body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff