Skip to content

Commit 289a65d

Browse files
authored
Add files via upload
1 parent 2144b78 commit 289a65d

1 file changed

Lines changed: 30 additions & 19 deletions

File tree

index.html

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,32 @@ <h3>Edit Stream Label</h3>
10431043
</div>
10441044

10451045
<script>
1046+
// ========== GUN RELAY SERVERS ==========
1047+
const GUN_RELAYS = [
1048+
'https://gun-us.herokuapp.com/gun',
1049+
'https://gunjs.herokuapp.com/gun',
1050+
'https://gun-eu.herokuapp.com/gun'
1051+
];
1052+
1053+
// ========== GLOBAL STATE ==========
1054+
let gun = null;
1055+
let roomRef = null;
1056+
let chatRef = null;
1057+
let isHost = false;
1058+
let streams = [];
1059+
let settings = { layout: 'grid', featuredId: null, weather: { enabled: false, lat: 40.7128, lon: -74.006 }, display: { gridGap: 2, labels: 'hover', theme: 'dark', accent: '#00d4ff' } };
1060+
let chatExpanded = true;
1061+
let username = localStorage.getItem('ms-user') || '';
1062+
let sessionId = localStorage.getItem('ms-sid') || ('s' + Math.random().toString(36).substr(2, 9));
1063+
localStorage.setItem('ms-sid', sessionId);
1064+
const seenStreams = new Map();
1065+
const msgEls = new Map();
1066+
1067+
// ========== URL PARAMS ==========
1068+
const params = new URLSearchParams(location.search);
1069+
const roomId = params.get('room');
1070+
const hostKey = params.get('host');
1071+
10461072
// ========== SETUP PAGE ==========
10471073
let createdRoom = null;
10481074
let createdKey = null;
@@ -1068,8 +1094,8 @@ <h3>Edit Stream Label</h3>
10681094
saveRecentRoom(name, key, title);
10691095

10701096
// Pre-set title
1071-
const gun = Gun(['https://gun-manhattan.herokuapp.com/gun']);
1072-
gun.get('ms4-' + name).get('meta').get('title').put(title);
1097+
const tempGun = Gun(GUN_RELAYS);
1098+
tempGun.get('ms4-' + name).get('meta').get('title').put(title);
10731099
}
10741100

10751101
function goToRoom() {
@@ -1117,11 +1143,7 @@ <h3>Edit Stream Label</h3>
11171143
`).join('');
11181144
}
11191145

1120-
// ========== VIEWER PAGE ==========
1121-
const params = new URLSearchParams(location.search);
1122-
const roomId = params.get('room');
1123-
const hostKey = params.get('host');
1124-
1146+
// ========== PAGE INIT ==========
11251147
if (roomId) {
11261148
document.getElementById('setupPage').style.display = 'none';
11271149
document.getElementById('viewerPage').classList.add('active');
@@ -1131,19 +1153,8 @@ <h3>Edit Stream Label</h3>
11311153
}
11321154

11331155
// ========== VIEWER INIT ==========
1134-
let gun, roomRef, chatRef;
1135-
let isHost = false;
1136-
let streams = [];
1137-
let settings = { layout: 'grid', featuredId: null, weather: { enabled: false, lat: 40.7128, lon: -74.006 }, display: { gridGap: 2, labels: 'hover', theme: 'dark', accent: '#00d4ff' } };
1138-
let chatExpanded = true;
1139-
let username = localStorage.getItem('ms-user') || '';
1140-
let sessionId = localStorage.getItem('ms-sid') || ('s' + Math.random().toString(36).substr(2, 9));
1141-
localStorage.setItem('ms-sid', sessionId);
1142-
const seenStreams = new Map();
1143-
const msgEls = new Map();
1144-
11451156
function initViewer() {
1146-
gun = Gun(['https://gun-manhattan.herokuapp.com/gun']);
1157+
gun = Gun(GUN_RELAYS);
11471158
roomRef = gun.get('ms4-' + roomId);
11481159
chatRef = gun.get('ms4-chat-' + roomId);
11491160

0 commit comments

Comments
 (0)