A dark, mysterious five-act ARG built around hidden archives and forgotten witnesses.

Download ZIP
assets/js/ui.js 87 lines · 2.3 KB · javascript
1
// UI Router and main interface controller
2
3
const UIRouter = {
4
  currentPage: 'landing',
5
  
6
  navigate(page) {
7
    this.currentPage = page;
8
    this.render();
9
    GameState.currentPage = page;
10
    GameState.save();
11
  },
12
  
13
  render() {
14
    const content = document.getElementById('content-area');
15
    let html = '';
16
    
17
    if (this.currentPage === 'landing') {
18
      html = LandingPage.render();
19
    } else if (this.currentPage.startsWith('act')) {
20
      const actNum = parseInt(this.currentPage.replace('act', ''));
21
      html = Acts.render('act' + actNum);
22
    } else if (this.currentPage === 'inventory') {
23
      html = InventoryPage.render();
24
    } else if (this.currentPage === 'evidence') {
25
      html = EvidencePage.render();
26
    } else if (this.currentPage === 'decoder') {
27
      html = DecoderPage.render();
28
    } else if (this.currentPage === 'terminal') {
29
      html = TerminalPage.render();
30
    }
31
    
32
    content.innerHTML = html;
33
    
34
    // Attach event handlers
35
    if (this.currentPage === 'landing') {
36
      LandingPage.attach();
37
    } else if (this.currentPage.startsWith('act')) {
38
      Acts.attach();
39
    } else if (this.currentPage === 'terminal') {
40
      TerminalPage.attach();
41
    } else if (this.currentPage === 'decoder') {
42
      // Decoder already has inline handlers
43
    }
44
    
45
    // Update nav
46
    this.updateNav();
47
  },
48
  
49
  updateNav() {
50
    document.querySelectorAll('.nav-menu a').forEach(link => {
51
      link.classList.remove('active');
52
      const section = link.dataset.section;
53
      if (section === this.currentPage) {
54
        link.classList.add('active');
55
      }
56
    });
57
  }
58
};
59
60
// Sidebar navigation
61
document.addEventListener('DOMContentLoaded', () => {
62
  const toggle = document.querySelector('.nav-toggle');
63
  const menu = document.querySelector('.nav-menu');
64
  
65
  toggle.addEventListener('click', () => {
66
    menu.classList.toggle('open');
67
  });
68
  
69
  document.querySelectorAll('.nav-menu a').forEach(link => {
70
    link.addEventListener('click', (e) => {
71
      e.preventDefault();
72
      const section = link.dataset.section;
73
      UIRouter.navigate(section);
74
      menu.classList.remove('open');
75
    });
76
  });
77
});
78
79
// Footer time updater
80
function updateFooterTime() {
81
  const now = new Date();
82
  const time = now.toLocaleTimeString();
83
  document.getElementById('footer-time').textContent = time;
84
}
85
86
setInterval(updateFooterTime, 1000);
87
updateFooterTime();