From f9487ce24ddab1af5378db22e830a3d5b275015b Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Sun, 8 Jun 2025 16:58:43 -0700 Subject: [PATCH] delete old game file, fix duplicate nodes bug when exporting design --- game.html | 1136 ------------------------------------------ static/app.js | 6 +- static/connection.js | 10 +- static/game.html | 2 + static/node.js | 1 - static/utils.js | 3 +- 6 files changed, 15 insertions(+), 1143 deletions(-) delete mode 100644 game.html diff --git a/game.html b/game.html deleted file mode 100644 index 22d00f2..0000000 --- a/game.html +++ /dev/null @@ -1,1136 +0,0 @@ - - - - - - System Design Game - - - -
-
System Design Game
-
-
- - -
    -
  • -
    Url Shortener
    -
    Easy
    -
  • -
  • -
    Url Shortener
    -
    Easy
    -
  • -
  • -
    Url Shortener
    -
    Medium
    -
  • -
  • -
    Something hard
    -
    Hard
    -
  • -
-
-
- - - - -
-
- - - -
- - -
-
-

Functional Requirements

-
    -
  • Something
  • -
  • Something else
  • -
-
- -
-

Non-Functional Requirements

-
    -
  • Something
  • -
  • Something else
  • -
-
- -
- - -
- - -
-
- -
-
-
-
level constraints
-
🎯 target rps:
-
⏱️ max p95 latency:
-
💸 max cost:
-
🔒 availability:
-
- -
-
simulation results
-
✅ cost:
-
⚡ p95 latency:
-
📈 achieved rps:
-
🛡️ availability:
-
-
- - - - - - - - -
-

node properties

-
- -
-
- -
-
- -
- -
-
- - -
- -
- -
- - -
This is Tab 3 content.
-
-
-
-
- - - - - diff --git a/static/app.js b/static/app.js index 3c92e43..0fef3fd 100644 --- a/static/app.js +++ b/static/app.js @@ -78,7 +78,6 @@ export class CanvasApp { const node = new ComponentNode(type, x, y, this); node.x = x; node.y = y; - this.placedComponents.push(node) if (this.placeholderText) { this.placeholderText.remove(); this.placeholderText = null; @@ -87,7 +86,7 @@ export class CanvasApp { this.runButton.addEventListener('click', () => { const designData = this.exportDesign(); - alert(JSON.stringify(designData)); + console.log(JSON.stringify(designData)); }); this.canvas.addEventListener('click', () => { @@ -218,7 +217,8 @@ export class CanvasApp { label: c.label || '', direction: c.direction, protocol: c.protocol || '', - tls: !!c.tls + tls: !!c.tls, + capacity: c.capacity || 1000 })); return { nodes, connections }; diff --git a/static/connection.js b/static/connection.js index 43f4d33..7e41fa2 100644 --- a/static/connection.js +++ b/static/connection.js @@ -4,7 +4,7 @@ export class Connection { static _activeConnection = null; static modalSetupDone = false; - constructor(startNode, endNode, label, protocol, app, tls) { + constructor(startNode, endNode, label, protocol, app, tls, capacity = 1000) { this.start = startNode; this.end = endNode; this.app = app; @@ -12,6 +12,7 @@ export class Connection { this.protocol = protocol; this.direction = "forward"; this.tls = tls; + this.capacity = capacity; this.line = createSVGElement('line', { stroke: '#ccc', 'stroke-width': 2, 'marker-end': 'url(#arrowhead-end)' }); @@ -137,6 +138,7 @@ export class Connection { Connection.labelInput = document.getElementById('connection-label'); Connection.tlsCheckbox = document.getElementById('connection-tls'); Connection.protocolInput = document.getElementById('connection-protocol'); + Connection.capacityInput = document.getElementById('connection-capacity'); Connection.saveBtn = document.getElementById('connection-save'); Connection.cancelBtn = document.getElementById('connection-cancel'); @@ -144,6 +146,7 @@ export class Connection { const label = Connection.labelInput.value.trim(); const protocol = Connection.protocolInput.value.trim(); const tls = Connection.tlsCheckbox.checked; + const capacity = parseInt(Connection.capacityInput.value.trim(), 10) || 1000; if (!label || !protocol) return; if (Connection._activeConnection) { @@ -153,12 +156,13 @@ export class Connection { conn.protocol = protocol; conn.text.textContent = label; conn.tls = tls; + conn.capacity = capacity; conn.protocolText.textContent = protocol; conn.updatePosition(); } else if (app.pendingConnection) { // Creating a new connection const { start, end } = app.pendingConnection; - const conn = new Connection(start, end, label, protocol, app, tls); + const conn = new Connection(start, end, label, protocol, app, tls, capacity); app.connections.push(conn); } @@ -197,6 +201,7 @@ export class Connection { Connection.labelInput.value = 'Read traffic'; Connection.protocolInput.value = 'HTTP'; Connection.tlsCheckbox.checked = false; + Connection.capacityInput.value = '1000'; Connection.modal.style.display = 'block'; } } @@ -208,6 +213,7 @@ export class Connection { Connection.labelInput.value = this.label; Connection.protocolInput.value = this.protocol; Connection.tlsCheckbox.checked = this.tls; + Connection.capacityInput.value = this.capacity || 1000; Connection.modal.style.display = 'block'; } diff --git a/static/game.html b/static/game.html index 7bd82b4..e4af213 100644 --- a/static/game.html +++ b/static/game.html @@ -681,6 +681,8 @@ Enable TLS (encryption) + +