···
"github.com/go-chi/chi/v5"
"battleship-arena/internal/storage"
···
259
-
padding: 0.375rem 0.75rem;
260
-
border-radius: 0.375rem;
259
+
padding: 0.5rem 0.875rem;
260
+
border-radius: 0.5rem;
font-family: 'Monaco', 'Courier New', monospace;
264
+
border: 1px solid #1e3a8a;
265
+
display: inline-block;
270
+
position: relative;
271
+
background: #0f172a;
272
+
border: 1px solid #1e3a8a;
273
+
border-radius: 0.5rem;
278
+
.code-block-header {
279
+
background: #1e3a8a;
280
+
padding: 0.5rem 1rem;
282
+
justify-content: space-between;
283
+
align-items: center;
284
+
border-bottom: 1px solid #1e3a8a;
289
+
font-size: 0.75rem;
291
+
text-transform: uppercase;
292
+
letter-spacing: 0.05em;
296
+
background: #3b82f6;
299
+
padding: 0.25rem 0.75rem;
300
+
border-radius: 0.25rem;
301
+
font-size: 0.75rem;
303
+
transition: background 0.2s;
306
+
.code-block-copy:hover {
307
+
background: #2563eb;
310
+
.code-block-copy.copied {
311
+
background: #10b981;
321
+
background: transparent;
328
+
.code-block .token-command {
332
+
.code-block .token-flag {
336
+
.code-block .token-string {
340
+
.code-block .token-comment {
342
+
font-style: italic;
···
window.addEventListener('DOMContentLoaded', () => {
621
+
function copyCode(button, text) {
622
+
// Decode HTML entities in template variables
623
+
const tempDiv = document.createElement('div');
624
+
tempDiv.innerHTML = text;
625
+
const decodedText = tempDiv.textContent || tempDiv.innerText;
627
+
navigator.clipboard.writeText(decodedText).then(() => {
628
+
const originalText = button.textContent;
629
+
button.textContent = 'Copied!';
630
+
button.classList.add('copied');
632
+
button.textContent = originalText;
633
+
button.classList.remove('copied');
636
+
console.error('Failed to copy:', err);
···
<p><strong>First time?</strong> Connect via SSH to create your account:</p>
614
-
<p><code>ssh -p 2222 username@{{.ServerURL}}</code></p>
713
+
<div class="code-block">
714
+
<div class="code-block-header">
715
+
<span class="code-block-lang">bash</span>
716
+
<button class="code-block-copy" onclick="copyCode(this, 'ssh -p 2222 {{.ServerURL}}')">Copy</button>
718
+
<pre><code><span class="token-command">ssh</span> <span class="token-flag">-p</span> <span class="token-string">2222</span> <span class="token-string">{{.ServerURL}}</span></code></pre>
<p style="margin-top: 0.5rem; color: #94a3b8;">You'll be prompted for your name, bio, and link. Your SSH key will be registered.</p>
<p style="margin-top: 1rem;"><strong>Upload your AI:</strong></p>
618
-
<p><code>scp -P 2222 memory_functions_yourname.cpp username@{{.ServerURL}}:~/</code></p>
725
+
<div class="code-block">
726
+
<div class="code-block-header">
727
+
<span class="code-block-lang">bash</span>
728
+
<button class="code-block-copy" onclick="copyCode(this, 'scp -P 2222 memory_functions_yourname.cpp {{.ServerURL}}:~/')">Copy</button>
730
+
<pre><code><span class="token-command">scp</span> <span class="token-flag">-P</span> <span class="token-string">2222</span> <span class="token-string">memory_functions_yourname.cpp</span> <span class="token-string">{{.ServerURL}}:~/</span></code></pre>
<p style="margin-top: 1rem; color: #94a3b8;">
<a href="/users" style="color: #60a5fa;">View all players →</a>
···
entries = []storage.LeaderboardEntry{}
// Get matches for bracket
matches, err := storage.GetAllMatches()
···
json.NewEncoder(w).Encode(entries)
func calculateTotalGames(entries []storage.LeaderboardEntry) int {
for _, e := range entries {
···
http.Error(w, "Username required", http.StatusBadRequest)
// Get submission ID for this username
err := storage.DB.QueryRow(
"SELECT id FROM submissions WHERE username = ? AND is_active = 1",
http.Error(w, "Player not found", http.StatusNotFound)
history, err := storage.GetRatingHistory(submissionID)
http.Error(w, fmt.Sprintf("Failed to get rating history: %v", err), http.StatusInternalServerError)
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(history)
···
http.Redirect(w, r, "/", http.StatusSeeOther)
tmpl := template.Must(template.New("player").Parse(playerPageHTML))
tmpl.Execute(w, map[string]string{"Username": username})
···