Skip to content

Commit

Permalink
Stub chatroom support
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarel committed Nov 4, 2018
1 parent 31642ff commit 84fed0d
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 65 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ node_modules/
/js/panels.js
/js/panel-mainmenu.js
/js/panel-rooms.js
/js/panel-chat.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ package-lock.json
/js/panels.js
/js/panel-mainmenu.js
/js/panel-rooms.js
/js/panel-chat.js

.vscode
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@ PS loads itself in phases:
- User model
- Generic Room model
- PS model
- `client-frame.tsx`
- Main view
- SockJS
- `client-connection.ts`
- Connect to server
- Preact
- SoundManager
- `panel-mainmenu.tsx`
- `panel-rooms.tsx`
- `panels.tsx`
- URL router
- global listeners
- Main view

**Phase 3:** Lightweight panels

- Caja (HTML sanitizer)
- `panel-chat.tsx`
- `panel-ladder.tsx`
- `panel`

**Phase 4:** Heavyweight panels - loaded only when a user opens one

Expand Down
54 changes: 0 additions & 54 deletions js/panel-chat.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/client-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PSConnection {
connected = false;
queue = [] as string[];
constructor() {
// this.connect();
this.connect();
}
connect() {
const server = PS.server;
Expand Down
26 changes: 26 additions & 0 deletions src/client-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ class PlaceholderRoom extends PSRoom {
type RoomType = {Model: typeof PSRoom, Component: typeof PSRoomPanel};

const PS = new class extends PSModel {
down: string | boolean = false;

prefs = new PSPrefs();
teams = new PSTeams();
user = new PSUser();
Expand Down Expand Up @@ -376,6 +378,30 @@ const PS = new class extends PSModel {
window.addEventListener('resize', () => this.updateLayout());
}

lineParse(str: string): [string, ...string[]] {
if (!str.startsWith('|')) {
return ['', str];
}
const index = str.indexOf('|', 1);
const cmd = str.slice(1, index);
switch (cmd) {
case 'html':
case 'raw':
case '':
return [cmd, str.slice(index + 1)];
case 'c':
// three parts
const index2a = str.indexOf('|', index + 1);
return [cmd, str.slice(index + 1, index2a), str.slice(index2a + 1)];
case 'c:':
// four parts
const index2b = str.indexOf('|', index + 1);
const index3b = str.indexOf('|', index2b + 1);
return [cmd, str.slice(index + 1, index2b), str.slice(index2b + 1, index3b), str.slice(index3b + 1)];
}
return str.slice(1).split('|') as [string, ...string[]];
}

// Panel layout
///////////////
/**
Expand Down
Loading

0 comments on commit 84fed0d

Please sign in to comment.