2023-09-07 06:03:12 +00:00
|
|
|
|
<script>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
import HelloWorld from './components/HelloWorld.vue'
|
|
|
|
|
import TheWelcome from './components/TheWelcome.vue'
|
2023-09-07 06:03:12 +00:00
|
|
|
|
import LoginModal from './components/LoginModal.vue';
|
|
|
|
|
import ExplicitOpenModal from './components/ExplicitOpenModal.vue';
|
|
|
|
|
import ReportModal from './components/ReportModal.vue';
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
import LocalStorage from './lib/LocalStorage';
|
2023-09-07 00:15:02 +00:00
|
|
|
|
import { SoundEffects, DefaultSounds } from './lib/sounds';
|
2023-09-07 06:03:12 +00:00
|
|
|
|
import { isAppleWebkit } from './lib/browsers';
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// WebRTC configuration.
|
|
|
|
|
const configuration = {
|
2023-06-14 04:57:31 +00:00
|
|
|
|
iceServers: TURN.URLs.map(val => {
|
|
|
|
|
let row = {
|
|
|
|
|
urls: val,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (val.indexOf('turn:') === 0) {
|
|
|
|
|
row.username = TURN.Username;
|
|
|
|
|
row.credential = TURN.Credential;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return row;
|
|
|
|
|
})
|
2023-01-27 06:54:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-03-22 04:29:24 +00:00
|
|
|
|
const FileUploadMaxSize = 1024 * 1024 * 8; // 8 MB
|
|
|
|
|
|
2023-09-07 00:15:02 +00:00
|
|
|
|
export default {
|
|
|
|
|
name: 'BareRTC',
|
2023-09-07 06:03:12 +00:00
|
|
|
|
components: {
|
|
|
|
|
LoginModal,
|
|
|
|
|
ExplicitOpenModal,
|
|
|
|
|
ReportModal,
|
|
|
|
|
},
|
2023-01-11 06:38:48 +00:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
2023-02-10 07:03:06 +00:00
|
|
|
|
// busy: false, // TODO: not used
|
2023-02-11 06:46:39 +00:00
|
|
|
|
disconnect: false, // don't try to reconnect (e.g. kicked)
|
2023-02-10 07:03:06 +00:00
|
|
|
|
windowFocused: true, // browser tab is active
|
|
|
|
|
windowFocusedAt: new Date(),
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
2023-02-20 05:36:36 +00:00
|
|
|
|
// Disconnect spamming: don't retry too many times.
|
2023-03-31 04:26:45 +00:00
|
|
|
|
disconnectLimit: 3,
|
2023-02-20 05:36:36 +00:00
|
|
|
|
disconnectCount: 0,
|
|
|
|
|
|
2023-08-31 01:14:49 +00:00
|
|
|
|
// Temp: spam counting for OF links
|
|
|
|
|
spamWarningCount: 0,
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Website configuration provided by chat.html template.
|
|
|
|
|
config: {
|
2023-09-07 00:15:02 +00:00
|
|
|
|
branding: Branding,
|
2023-02-05 08:53:50 +00:00
|
|
|
|
channels: PublicChannels,
|
2023-02-06 01:42:09 +00:00
|
|
|
|
website: WebsiteURL,
|
2023-02-11 06:46:39 +00:00
|
|
|
|
permitNSFW: PermitNSFW,
|
2023-08-13 04:35:41 +00:00
|
|
|
|
webhookURLs: WebhookURLs,
|
2023-09-03 19:08:23 +00:00
|
|
|
|
VIP: VIP,
|
2023-03-25 05:10:44 +00:00
|
|
|
|
fontSizeClasses: [
|
2023-09-07 06:03:12 +00:00
|
|
|
|
["x-2", "Very small chat room text"],
|
|
|
|
|
["x-1", "50% smaller chat room text"],
|
|
|
|
|
["", "Default size"],
|
|
|
|
|
["x1", "50% larger chat room text"],
|
|
|
|
|
["x2", "2x larger chat room text"],
|
|
|
|
|
["x3", "3x larger chat room text"],
|
|
|
|
|
["x4", "4x larger chat room text"],
|
2023-03-25 05:10:44 +00:00
|
|
|
|
],
|
2023-08-15 02:59:35 +00:00
|
|
|
|
imageDisplaySettings: [
|
2023-09-07 06:03:12 +00:00
|
|
|
|
["show", "Always show images in chat"],
|
|
|
|
|
["collapse", "Collapse images in chat, clicking to expand (default)"],
|
|
|
|
|
["hide", "Never show images shared in chat"],
|
2023-08-13 04:35:41 +00:00
|
|
|
|
],
|
2023-02-06 21:27:29 +00:00
|
|
|
|
sounds: {
|
|
|
|
|
available: SoundEffects,
|
|
|
|
|
settings: DefaultSounds,
|
|
|
|
|
ready: false,
|
|
|
|
|
audioContext: null,
|
|
|
|
|
audioTracks: {},
|
2023-07-01 03:00:21 +00:00
|
|
|
|
},
|
|
|
|
|
reactions: [
|
2023-07-01 04:48:09 +00:00
|
|
|
|
['❤️', '👍', '😂', '😉', '😢', '😡', '🥰'],
|
2023-07-09 20:41:40 +00:00
|
|
|
|
['😘', '👎', '☹️', '😭', '🤔', '🙄', '🤩'],
|
2023-07-01 18:39:08 +00:00
|
|
|
|
['👋', '🔥', '😈', '🍑', '🍆', '💦', '🍌'],
|
2023-07-01 04:48:09 +00:00
|
|
|
|
['😋', '⭐', '😇', '😴', '😱', '👀', '🎃'],
|
2023-07-09 20:41:40 +00:00
|
|
|
|
['🤮', '🥳', '🙏', '🤦', '💩', '🤯', '💯'],
|
|
|
|
|
['😏', '🙈', '🙉', '🙊', '☀️', '🌈', '🎂'],
|
2023-07-30 17:32:08 +00:00
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
// Cached blocklist for the current user sent by your website.
|
|
|
|
|
CachedBlocklist: CachedBlocklist,
|
2023-02-06 01:42:09 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// User JWT settings if available.
|
|
|
|
|
jwt: {
|
|
|
|
|
token: UserJWTToken,
|
|
|
|
|
valid: UserJWTValid,
|
|
|
|
|
claims: UserJWTClaims
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
channel: "lobby",
|
|
|
|
|
username: "", //"test",
|
2023-02-25 00:47:28 +00:00
|
|
|
|
autoLogin: false, // e.g. from JWT auth
|
2023-01-11 06:38:48 +00:00
|
|
|
|
message: "",
|
2023-08-29 00:49:50 +00:00
|
|
|
|
messageBox: null, // HTML element for message entry box
|
2023-02-10 07:03:06 +00:00
|
|
|
|
typingNotifDebounce: null,
|
2023-03-28 04:13:04 +00:00
|
|
|
|
status: "online", // away/idle status
|
|
|
|
|
|
|
|
|
|
// Idle detection variables
|
|
|
|
|
idleTimeout: null,
|
2023-07-23 22:49:04 +00:00
|
|
|
|
idleThreshold: 300, // number of seconds you must be idle
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
|
|
|
|
// WebSocket connection.
|
|
|
|
|
ws: {
|
|
|
|
|
conn: null,
|
|
|
|
|
connected: false,
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Who List for the room.
|
|
|
|
|
whoList: [],
|
2023-03-23 03:21:04 +00:00
|
|
|
|
whoTab: 'online',
|
2023-08-05 19:15:16 +00:00
|
|
|
|
whoSort: 'a-z',
|
2023-02-06 01:42:09 +00:00
|
|
|
|
whoMap: {}, // map username to wholist entry
|
2023-03-23 03:21:04 +00:00
|
|
|
|
muted: {}, // muted usernames for client side state
|
2023-01-27 04:34:58 +00:00
|
|
|
|
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// Misc. user preferences (TODO: move all of them here)
|
|
|
|
|
prefs: {
|
|
|
|
|
joinMessages: true, // show "has entered the room" in public channels
|
|
|
|
|
exitMessages: false, // hide exit messages by default in public channels
|
2023-08-29 00:49:50 +00:00
|
|
|
|
watchNotif: true, // notify in chat about cameras being watched
|
2023-08-29 05:46:40 +00:00
|
|
|
|
closeDMs: false, // ignore unsolicited DMs
|
2023-09-02 00:11:17 +00:00
|
|
|
|
muteSounds: false, // mute all sound effects
|
2023-08-29 05:46:40 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// My video feed.
|
|
|
|
|
webcam: {
|
|
|
|
|
busy: false,
|
|
|
|
|
active: false,
|
|
|
|
|
elem: null, // <video id="localVideo"> element
|
|
|
|
|
stream: null, // MediaStream object
|
2023-02-06 04:26:00 +00:00
|
|
|
|
muted: false, // our outgoing mic is muted, not by default
|
2023-08-12 01:56:22 +00:00
|
|
|
|
autoMute: false, // mute our mic automatically when going live (user option)
|
2023-02-11 06:46:39 +00:00
|
|
|
|
nsfw: false, // user has flagged their camera to be NSFW
|
2023-04-01 02:46:42 +00:00
|
|
|
|
mutual: false, // user wants viewers to share their own videos
|
|
|
|
|
mutualOpen: false, // user wants to open video mutually
|
2023-09-03 19:08:23 +00:00
|
|
|
|
vipOnly: false, // only show camera to fellow VIP users
|
2023-02-06 04:26:00 +00:00
|
|
|
|
|
|
|
|
|
// Who all is watching me? map of users.
|
|
|
|
|
watching: {},
|
2023-02-10 07:03:06 +00:00
|
|
|
|
|
|
|
|
|
// Scaling setting for the videos drawer, so the user can
|
|
|
|
|
// embiggen the webcam sizes so a suitable size.
|
|
|
|
|
videoScale: "",
|
|
|
|
|
videoScaleOptions: [
|
2023-09-07 06:03:12 +00:00
|
|
|
|
["", "Default size"],
|
|
|
|
|
["x1", "50% larger videos"],
|
|
|
|
|
["x2", "2x larger videos"],
|
|
|
|
|
["x3", "3x larger videos"],
|
|
|
|
|
["x4", "4x larger videos (not recommended)"],
|
2023-02-10 07:03:06 +00:00
|
|
|
|
],
|
2023-04-19 05:18:12 +00:00
|
|
|
|
|
|
|
|
|
// Available cameras and microphones for the Settings modal.
|
2023-08-18 01:45:43 +00:00
|
|
|
|
gettingDevices: false, // busy indicator for refreshing devices
|
2023-04-19 05:18:12 +00:00
|
|
|
|
videoDevices: [],
|
|
|
|
|
videoDeviceID: null,
|
|
|
|
|
audioDevices: [],
|
|
|
|
|
audioDeviceID: null,
|
2023-08-19 01:54:45 +00:00
|
|
|
|
|
|
|
|
|
// After we get a device selected, remember it (by name) so that we
|
|
|
|
|
// might hopefully re-select it by default IF we are able to enumerate
|
|
|
|
|
// devices before they go on camera the first time.
|
|
|
|
|
preferredDeviceNames: {
|
|
|
|
|
video: null,
|
|
|
|
|
audio: null,
|
|
|
|
|
},
|
2023-01-27 04:34:58 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-07-01 01:41:06 +00:00
|
|
|
|
// Video flag constants (sync with values in messages.go)
|
|
|
|
|
VideoFlag: {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
Active: 1 << 0,
|
|
|
|
|
NSFW: 1 << 1,
|
|
|
|
|
Muted: 1 << 2,
|
|
|
|
|
IsTalking: 1 << 3,
|
2023-07-01 01:41:06 +00:00
|
|
|
|
MutualRequired: 1 << 4,
|
2023-09-07 06:03:12 +00:00
|
|
|
|
MutualOpen: 1 << 5,
|
|
|
|
|
VipOnly: 1 << 6,
|
2023-07-01 01:41:06 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// WebRTC sessions with other users.
|
|
|
|
|
WebRTC: {
|
|
|
|
|
// Streams per username.
|
|
|
|
|
streams: {},
|
2023-02-06 04:26:00 +00:00
|
|
|
|
muted: {}, // muted bool per username
|
2023-08-05 02:24:42 +00:00
|
|
|
|
booted: {}, // booted bool per username
|
2023-04-20 05:00:31 +00:00
|
|
|
|
poppedOut: {}, // popped-out video per username
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
|
|
|
|
// RTCPeerConnections per username.
|
|
|
|
|
pc: {},
|
2023-08-09 00:51:52 +00:00
|
|
|
|
|
|
|
|
|
// Video stream freeze detection.
|
|
|
|
|
frozenStreamInterval: {}, // map usernames to intervals
|
|
|
|
|
frozenStreamDetected: {}, // map usernames to bools
|
|
|
|
|
|
|
|
|
|
// Debounce connection attempts since now every click = try to connect.
|
|
|
|
|
debounceOpens: {}, // map usernames to bools
|
2023-08-29 05:46:40 +00:00
|
|
|
|
|
|
|
|
|
// Timeouts for open camera attempts. e.g.: when you click to view
|
|
|
|
|
// a camera, the icon changes to a spinner for a few seconds to see
|
|
|
|
|
// whether the video goes on to open.
|
|
|
|
|
openTimeouts: {}, // map usernames to timeouts
|
2023-01-27 06:54:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-01-11 06:38:48 +00:00
|
|
|
|
// Chat history.
|
|
|
|
|
history: [],
|
2023-02-05 08:53:50 +00:00
|
|
|
|
channels: {
|
|
|
|
|
// There will be values here like:
|
|
|
|
|
// "lobby": {
|
|
|
|
|
// "history": [],
|
|
|
|
|
// "updated": timestamp,
|
|
|
|
|
// "unread": 4,
|
|
|
|
|
// },
|
|
|
|
|
// "@username": {
|
|
|
|
|
// "history": [],
|
|
|
|
|
// ...
|
|
|
|
|
// }
|
|
|
|
|
},
|
2023-01-27 04:34:58 +00:00
|
|
|
|
historyScrollbox: null,
|
2023-03-25 04:56:40 +00:00
|
|
|
|
autoscroll: true, // scroll to bottom on new messages
|
2023-03-25 05:10:44 +00:00
|
|
|
|
fontSizeClass: "", // font size magnification
|
2023-08-17 05:40:17 +00:00
|
|
|
|
imageDisplaySetting: "collapse", // image show/hide setting
|
2023-07-23 01:30:45 +00:00
|
|
|
|
scrollback: 1000, // scrollback buffer (messages to keep per channel)
|
2023-01-11 06:38:48 +00:00
|
|
|
|
DMs: {},
|
2023-07-01 03:00:21 +00:00
|
|
|
|
messageReactions: {
|
|
|
|
|
// Will look like:
|
|
|
|
|
// "123": { (message ID)
|
|
|
|
|
// "❤️": [ (reaction emoji)
|
|
|
|
|
// "username" // users who reacted
|
|
|
|
|
// ]
|
|
|
|
|
// }
|
|
|
|
|
},
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
2023-02-10 07:03:06 +00:00
|
|
|
|
// Responsive CSS controls for mobile.
|
2023-02-05 08:53:50 +00:00
|
|
|
|
responsive: {
|
|
|
|
|
leftDrawerOpen: false,
|
|
|
|
|
rightDrawerOpen: false,
|
|
|
|
|
nodes: {
|
|
|
|
|
// DOM nodes for the CSS grid cells.
|
|
|
|
|
$container: null,
|
|
|
|
|
$left: null,
|
|
|
|
|
$center: null,
|
|
|
|
|
$right: null,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-11 06:38:48 +00:00
|
|
|
|
loginModal: {
|
|
|
|
|
visible: false,
|
|
|
|
|
},
|
2023-02-06 21:27:29 +00:00
|
|
|
|
|
|
|
|
|
settingsModal: {
|
|
|
|
|
visible: false,
|
2023-07-23 01:30:45 +00:00
|
|
|
|
tab: 'prefs', // selected setting tab
|
2023-02-06 21:27:29 +00:00
|
|
|
|
},
|
2023-02-11 06:46:39 +00:00
|
|
|
|
|
|
|
|
|
nsfwModalCast: {
|
|
|
|
|
visible: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
nsfwModalView: {
|
|
|
|
|
visible: false,
|
|
|
|
|
dontShowAgain: false,
|
|
|
|
|
user: null, // staged User we wanted to open
|
|
|
|
|
},
|
2023-08-13 04:35:41 +00:00
|
|
|
|
|
|
|
|
|
reportModal: {
|
|
|
|
|
visible: false,
|
|
|
|
|
busy: false,
|
2023-09-07 06:03:12 +00:00
|
|
|
|
user: {}, // full copy of the user for the modal component
|
2023-08-13 04:35:41 +00:00
|
|
|
|
message: {},
|
|
|
|
|
origMessage: {}, // pointer, so we can set the "reported" flag
|
|
|
|
|
},
|
2023-01-11 06:38:48 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
2023-03-25 05:10:44 +00:00
|
|
|
|
this.setupConfig(); // localSettings persisted settings
|
2023-03-28 04:13:04 +00:00
|
|
|
|
this.setupIdleDetection();
|
2023-02-06 21:27:29 +00:00
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.webcam.elem = document.querySelector("#localVideo");
|
|
|
|
|
this.historyScrollbox = document.querySelector("#chatHistory");
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
this.responsive.nodes = {
|
|
|
|
|
$container: document.querySelector(".chat-container"),
|
|
|
|
|
$left: document.querySelector(".left-column"),
|
|
|
|
|
$center: document.querySelector(".chat-column"),
|
|
|
|
|
$right: document.querySelector(".right-column"),
|
|
|
|
|
};
|
2023-08-29 00:49:50 +00:00
|
|
|
|
this.messageBox = document.getElementById("messageBox");
|
2023-02-05 08:53:50 +00:00
|
|
|
|
|
2023-02-10 07:03:06 +00:00
|
|
|
|
// Reset CSS overrides for responsive display on any window size change. In effect,
|
|
|
|
|
// making the chat panel the current screen again on phone rotation.
|
2023-02-05 08:53:50 +00:00
|
|
|
|
window.addEventListener("resize", () => {
|
|
|
|
|
this.resetResponsiveCSS();
|
|
|
|
|
});
|
|
|
|
|
|
2023-02-10 07:03:06 +00:00
|
|
|
|
// Listen for window focus/unfocus events. Being on a different browser tab, for
|
|
|
|
|
// sound effect alert purposes, counts as not being "in" that chat channel when
|
|
|
|
|
// a message comes in.
|
|
|
|
|
window.addEventListener("focus", () => {
|
|
|
|
|
this.windowFocused = true;
|
|
|
|
|
this.windowFocusedAt = new Date();
|
|
|
|
|
});
|
|
|
|
|
window.addEventListener("blur", () => {
|
|
|
|
|
this.windowFocused = false;
|
2023-06-12 02:21:06 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Set up sound effects on first page interaction.
|
|
|
|
|
window.addEventListener("click", () => {
|
|
|
|
|
this.setupSounds();
|
|
|
|
|
});
|
2023-06-12 03:33:26 +00:00
|
|
|
|
window.addEventListener("keydown", () => {
|
|
|
|
|
this.setupSounds();
|
|
|
|
|
});
|
2023-02-10 07:03:06 +00:00
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
for (let channel of this.config.channels) {
|
|
|
|
|
this.initHistory(channel.ID);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 04:26:00 +00:00
|
|
|
|
this.ChatClient("Welcome to BareRTC!");
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
2023-02-06 01:42:09 +00:00
|
|
|
|
// Auto login with JWT token?
|
|
|
|
|
// TODO: JWT validation on the WebSocket as well.
|
|
|
|
|
if (this.jwt.valid && this.jwt.claims.sub) {
|
|
|
|
|
this.username = this.jwt.claims.sub;
|
2023-02-25 00:47:28 +00:00
|
|
|
|
this.autoLogin = true;
|
2023-02-06 01:42:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scrub JWT token from query string parameters.
|
|
|
|
|
history.pushState(null, "", location.href.split("?")[0]);
|
|
|
|
|
|
2023-02-25 00:47:28 +00:00
|
|
|
|
// XX: always show login dialog to test if this helps iOS devices.
|
2023-03-14 04:26:37 +00:00
|
|
|
|
// this.loginModal.visible = true;
|
2023-01-11 06:38:48 +00:00
|
|
|
|
if (!this.username) {
|
|
|
|
|
this.loginModal.visible = true;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
} else {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
this.signIn(this.username);
|
2023-01-11 06:38:48 +00:00
|
|
|
|
}
|
2023-03-14 04:26:37 +00:00
|
|
|
|
},
|
|
|
|
|
watch: {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"webcam.videoScale": function () {
|
2023-03-14 04:26:37 +00:00
|
|
|
|
document.querySelectorAll(".video-feeds > .feed").forEach(node => {
|
|
|
|
|
node.style.width = null;
|
|
|
|
|
node.style.height = null;
|
|
|
|
|
});
|
2023-09-07 06:03:12 +00:00
|
|
|
|
LocalStorage.set('videoScale', this.webcam.videoScale);
|
2023-03-14 04:26:37 +00:00
|
|
|
|
},
|
2023-03-25 05:10:44 +00:00
|
|
|
|
fontSizeClass() {
|
|
|
|
|
// Store the setting persistently.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
LocalStorage.set('fontSizeClass', this.fontSizeClass);
|
2023-03-25 05:10:44 +00:00
|
|
|
|
},
|
2023-08-15 02:59:35 +00:00
|
|
|
|
imageDisplaySetting() {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
LocalStorage.set('imageDisplaySetting', this.imageDisplaySetting);
|
2023-08-15 02:59:35 +00:00
|
|
|
|
},
|
2023-07-23 01:30:45 +00:00
|
|
|
|
scrollback() {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
LocalStorage.set('scrollback', this.scrollback);
|
2023-07-23 01:30:45 +00:00
|
|
|
|
},
|
2023-03-28 04:13:04 +00:00
|
|
|
|
status() {
|
|
|
|
|
// Send presence updates to the server.
|
|
|
|
|
this.sendMe();
|
2023-08-12 01:42:06 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Webcam preferences that the user can edit while live.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"webcam.nsfw": function () {
|
2023-08-12 01:42:06 +00:00
|
|
|
|
if (this.webcam.active) {
|
|
|
|
|
this.sendMe();
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"webcam.mutual": function () {
|
2023-08-12 01:42:06 +00:00
|
|
|
|
if (this.webcam.active) {
|
|
|
|
|
this.sendMe();
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"webcam.mutualOpen": function () {
|
2023-08-12 01:42:06 +00:00
|
|
|
|
if (this.webcam.active) {
|
|
|
|
|
this.sendMe();
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"webcam.vipOnly": function () {
|
2023-09-03 19:08:23 +00:00
|
|
|
|
if (this.webcam.active) {
|
|
|
|
|
this.sendMe();
|
|
|
|
|
}
|
2023-09-03 19:36:15 +00:00
|
|
|
|
|
|
|
|
|
// If we have toggled this while already connected to people:
|
|
|
|
|
// Hang up on any that have a mutual viewership requirement, if
|
|
|
|
|
// they can not see our VIP-only camera.
|
|
|
|
|
for (username of Object.keys(this.WebRTC.pc)) {
|
|
|
|
|
if (this.whoMap[username] != undefined && this.isVideoNotAllowed(this.whoMap[username])) {
|
|
|
|
|
this.closeVideo(username);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-03 19:08:23 +00:00
|
|
|
|
},
|
2023-08-29 05:46:40 +00:00
|
|
|
|
|
|
|
|
|
// Misc preference watches
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"prefs.joinMessages": function () {
|
|
|
|
|
LocalStorage.set('joinMessages', this.prefs.joinMessages);
|
2023-08-29 05:46:40 +00:00
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"prefs.exitMessages": function () {
|
|
|
|
|
LocalStorage.set('exitMessages', this.prefs.exitMessages);
|
2023-08-29 05:46:40 +00:00
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"prefs.watchNotif": function () {
|
|
|
|
|
LocalStorage.set('watchNotif', this.prefs.watchNotif);
|
2023-08-29 00:49:50 +00:00
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"prefs.muteSounds": function () {
|
|
|
|
|
LocalStorage.set('muteSounds', this.prefs.muteSounds);
|
2023-09-02 00:11:17 +00:00
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"prefs.closeDMs": function () {
|
|
|
|
|
LocalStorage.set('closeDMs', this.prefs.closeDMs);
|
2023-08-29 00:49:50 +00:00
|
|
|
|
|
|
|
|
|
// Tell ChatServer if we have gone to/from DND.
|
|
|
|
|
this.sendMe();
|
2023-08-29 05:46:40 +00:00
|
|
|
|
},
|
2023-01-11 06:38:48 +00:00
|
|
|
|
},
|
2023-02-05 08:53:50 +00:00
|
|
|
|
computed: {
|
|
|
|
|
chatHistory() {
|
|
|
|
|
if (this.channels[this.channel] == undefined) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let history = this.channels[this.channel].history;
|
|
|
|
|
|
|
|
|
|
// How channels work:
|
|
|
|
|
// - Everything going to a public channel like "lobby" goes
|
|
|
|
|
// into the "lobby" channel in the front-end
|
|
|
|
|
// - Direct messages are different: they are all addressed
|
|
|
|
|
// "to" the channel of the current @user, but they are
|
|
|
|
|
// divided into DM threads based on the username.
|
|
|
|
|
if (this.channel.indexOf("@") === 0) {
|
|
|
|
|
// DM thread, divide them by sender.
|
|
|
|
|
// let username = this.channel.substring(1);
|
|
|
|
|
// return history.filter(v => {
|
|
|
|
|
// return v.username === username;
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
return history;
|
|
|
|
|
},
|
2023-07-23 01:30:45 +00:00
|
|
|
|
activeDMs() {
|
|
|
|
|
// List your currently open DM threads, sorted by most recent.
|
|
|
|
|
let result = [];
|
|
|
|
|
for (let channel of Object.keys(this.channels)) {
|
|
|
|
|
// @mentions only
|
|
|
|
|
if (channel.indexOf("@") !== 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.push({
|
|
|
|
|
channel: channel,
|
|
|
|
|
name: channel.substring(1),
|
|
|
|
|
updated: this.channels[channel].updated,
|
|
|
|
|
unread: this.channels[channel].unread,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.sort((a, b) => b.updated - a.updated);
|
|
|
|
|
return result;
|
|
|
|
|
},
|
2023-02-05 08:53:50 +00:00
|
|
|
|
channelName() {
|
|
|
|
|
// Return a suitable channel title.
|
|
|
|
|
if (this.channel.indexOf("@") === 0) {
|
|
|
|
|
// A DM, return it directly as is.
|
|
|
|
|
return this.channel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the friendly name from our config.
|
|
|
|
|
for (let channel of this.config.channels) {
|
|
|
|
|
if (channel.ID === this.channel) {
|
|
|
|
|
return channel.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.channel;
|
|
|
|
|
},
|
2023-02-06 01:42:09 +00:00
|
|
|
|
isDM() {
|
|
|
|
|
// Is the current channel a DM?
|
|
|
|
|
return this.channel.indexOf("@") === 0;
|
|
|
|
|
},
|
2023-07-30 17:32:08 +00:00
|
|
|
|
canUploadFile() {
|
|
|
|
|
// Public channels: OK
|
|
|
|
|
if (!this.channel.indexOf('@') === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// User is an admin?
|
|
|
|
|
if (this.jwt.claims.op) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// User is in a DM thread with an admin?
|
|
|
|
|
if (this.isDM) {
|
|
|
|
|
let partner = this.normalizeUsername(this.channel);
|
|
|
|
|
if (this.whoMap[partner] != undefined && this.whoMap[partner].op) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !this.isDM;
|
|
|
|
|
},
|
2023-06-24 20:08:15 +00:00
|
|
|
|
isOp() {
|
|
|
|
|
// Returns if the current user has operator rights
|
|
|
|
|
return this.jwt.claims.op;
|
|
|
|
|
},
|
2023-09-03 19:08:23 +00:00
|
|
|
|
isVIP() {
|
|
|
|
|
// Returns if the current user has VIP rights.
|
|
|
|
|
return this.jwt.claims.vip;
|
|
|
|
|
},
|
2023-07-01 01:41:06 +00:00
|
|
|
|
myVideoFlag() {
|
|
|
|
|
// Compute the current user's video status flags.
|
|
|
|
|
let status = 0;
|
2023-08-09 00:51:52 +00:00
|
|
|
|
if (!this.webcam.active) return 0; // unset all flags if not active now
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if (this.webcam.active) status |= this.VideoFlag.Active;
|
|
|
|
|
if (this.webcam.muted) status |= this.VideoFlag.Muted;
|
|
|
|
|
if (this.webcam.nsfw) status |= this.VideoFlag.NSFW;
|
|
|
|
|
if (this.webcam.mutual) status |= this.VideoFlag.MutualRequired;
|
|
|
|
|
if (this.webcam.mutualOpen) status |= this.VideoFlag.MutualOpen;
|
2023-09-03 19:08:23 +00:00
|
|
|
|
if (this.webcam.vipOnly && this.isVIP) status |= this.VideoFlag.VipOnly;
|
2023-07-01 01:41:06 +00:00
|
|
|
|
return status;
|
|
|
|
|
},
|
2023-08-05 19:15:16 +00:00
|
|
|
|
sortedWhoList() {
|
|
|
|
|
let result = [...this.whoList];
|
|
|
|
|
|
|
|
|
|
switch (this.whoSort) {
|
|
|
|
|
case "broadcasting":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
return (b.video & this.VideoFlag.Active) - (a.video & this.VideoFlag.Active);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case "nsfw":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
let left = (a.video & (this.VideoFlag.Active | this.VideoFlag.NSFW)),
|
|
|
|
|
right = (b.video & (this.VideoFlag.Active | this.VideoFlag.NSFW));
|
|
|
|
|
return right - left;
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case "status":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
if (a.status === b.status) return 0;
|
|
|
|
|
return b.status < a.status ? -1 : 1;
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case "op":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
return b.op - a.op;
|
|
|
|
|
});
|
|
|
|
|
break;
|
2023-08-06 02:38:04 +00:00
|
|
|
|
case "emoji":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
if (a.emoji === b.emoji) return 0;
|
|
|
|
|
return a.emoji < b.emoji ? -1 : 1;
|
|
|
|
|
})
|
|
|
|
|
break;
|
2023-08-07 04:06:27 +00:00
|
|
|
|
case "login":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
return b.loginAt - a.loginAt;
|
|
|
|
|
});
|
|
|
|
|
break;
|
2023-08-06 02:38:04 +00:00
|
|
|
|
case "gender":
|
|
|
|
|
result.sort((a, b) => {
|
|
|
|
|
if (a.gender === b.gender) return 0;
|
|
|
|
|
let left = a.gender || 'z',
|
|
|
|
|
right = b.gender || 'z';
|
|
|
|
|
return left < right ? -1 : 1;
|
|
|
|
|
})
|
|
|
|
|
break;
|
2023-08-05 19:15:16 +00:00
|
|
|
|
case "z-a":
|
|
|
|
|
result = result.reverse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default ordering from ChatServer = a-z
|
|
|
|
|
return result;
|
|
|
|
|
},
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
2023-01-11 06:38:48 +00:00
|
|
|
|
methods: {
|
2023-03-25 05:10:44 +00:00
|
|
|
|
// Load user prefs from localStorage, called on startup
|
|
|
|
|
setupConfig() {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
const settings = LocalStorage.getSettings();
|
|
|
|
|
|
|
|
|
|
if (settings.fontSizeClass != undefined) {
|
|
|
|
|
this.fontSizeClass = settings.fontSizeClass;
|
2023-03-25 05:10:44 +00:00
|
|
|
|
}
|
2023-04-01 03:25:53 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.videoScale != undefined) {
|
|
|
|
|
this.webcam.videoScale = settings.videoScale;
|
2023-07-09 19:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.imageDisplaySetting != undefined) {
|
|
|
|
|
this.imageDisplaySetting = settings.imageDisplaySetting;
|
2023-08-15 02:59:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.scrollback != undefined) {
|
|
|
|
|
this.scrollback = parseInt(settings.scrollback);
|
2023-07-23 01:30:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-19 01:54:45 +00:00
|
|
|
|
// Stored user preferred device names for webcam/audio.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.preferredDeviceNames != undefined) {
|
|
|
|
|
let dev = settings.preferredDeviceNames;
|
2023-08-19 01:54:45 +00:00
|
|
|
|
this.webcam.preferredDeviceNames.video = dev.video;
|
|
|
|
|
this.webcam.preferredDeviceNames.audio = dev.audio;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 03:25:53 +00:00
|
|
|
|
// Webcam mutality preferences from last broadcast.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.videoMutual === "true") {
|
2023-04-01 03:25:53 +00:00
|
|
|
|
this.webcam.mutual = true;
|
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.videoMutualOpen === "true") {
|
2023-04-01 03:25:53 +00:00
|
|
|
|
this.webcam.mutualOpen = true;
|
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.videoAutoMute === "true") {
|
2023-08-12 01:56:22 +00:00
|
|
|
|
this.webcam.autoMute = true;
|
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.videoVipOnly === "true") {
|
2023-09-03 19:08:23 +00:00
|
|
|
|
this.webcam.vipOnly = true;
|
|
|
|
|
}
|
2023-08-29 05:46:40 +00:00
|
|
|
|
|
|
|
|
|
// Misc preferences
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.joinMessages != undefined) {
|
|
|
|
|
this.prefs.joinMessages = settings.joinMessages === "true";
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.exitMessages != undefined) {
|
|
|
|
|
this.prefs.exitMessages = settings.exitMessages === "true";
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.watchNotif != undefined) {
|
|
|
|
|
this.prefs.watchNotif = settings.watchNotif === "true";
|
2023-08-29 00:49:50 +00:00
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.muteSounds != undefined) {
|
|
|
|
|
this.prefs.muteSounds = settings.muteSounds === "true";
|
2023-09-02 00:11:17 +00:00
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (settings.closeDMs != undefined) {
|
|
|
|
|
this.prefs.closeDMs = settings.closeDMs === "true";
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}
|
2023-03-25 05:10:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
signIn(username) {
|
|
|
|
|
this.username = username;
|
2023-01-11 06:38:48 +00:00
|
|
|
|
this.loginModal.visible = false;
|
|
|
|
|
this.dial();
|
|
|
|
|
},
|
|
|
|
|
|
2023-06-15 03:45:54 +00:00
|
|
|
|
// Normalize a DM channel name into a username (remove the @ prefix)
|
|
|
|
|
normalizeUsername(channel) {
|
|
|
|
|
return channel.replace(/^@+/, '');
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Chat API Methods (WebSocket packets sent/received)
|
|
|
|
|
*/
|
|
|
|
|
|
2023-01-11 06:38:48 +00:00
|
|
|
|
sendMessage() {
|
|
|
|
|
if (!this.message) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.ws.connected) {
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.ChatClient("You are not connected to the server.");
|
2023-01-11 06:38:48 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 01:14:49 +00:00
|
|
|
|
// Spammy links.
|
|
|
|
|
if (this.message.toLowerCase().indexOf("onlyfans.com") > -1 ||
|
|
|
|
|
this.message.toLowerCase().indexOf("justfor.fans") > -1 ||
|
|
|
|
|
this.message.toLowerCase().indexOf("justforfans") > -1 ||
|
|
|
|
|
this.message.toLowerCase().match(/fans[^A-Za-z0-9]+dot/)) {
|
|
|
|
|
|
|
|
|
|
// If they do it twice, kick them from the room.
|
|
|
|
|
if (this.spamWarningCount >= 1) {
|
|
|
|
|
// Walk of shame.
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "message",
|
|
|
|
|
channel: "lobby",
|
2023-09-07 06:03:12 +00:00
|
|
|
|
message: "**(Message of Shame)** I have been naughty and posted spam in chat despite being warned, " +
|
2023-08-31 01:14:49 +00:00
|
|
|
|
"and I am now being kicked from the room in shame. ☹️",
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
this.ChatServer(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"It is <strong>not allowed</strong> to promote your Onlyfans (or similar) " +
|
|
|
|
|
"site on the chat room. You have been removed from the chat room, and this " +
|
2023-08-31 01:14:49 +00:00
|
|
|
|
"incident has been reported to the site admin.",
|
|
|
|
|
);
|
|
|
|
|
this.pushHistory({
|
|
|
|
|
channel: this.channel,
|
|
|
|
|
username: this.username,
|
|
|
|
|
message: "has been kicked from the room!",
|
|
|
|
|
action: "presence",
|
|
|
|
|
});
|
|
|
|
|
this.disconnect = true;
|
|
|
|
|
this.ws.connected = false;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.ws.conn.close();
|
|
|
|
|
}, 1000);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.spamWarningCount++;
|
|
|
|
|
|
|
|
|
|
this.ChatClient(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"Please <strong>do not</strong> send links to your Onlyfans (or similar sites) in the chat room. " +
|
|
|
|
|
"Those links are widely regarded to be spam and make a lot of people uncomfortable. " +
|
2023-08-31 01:14:49 +00:00
|
|
|
|
"If you violate this again, your account will be suspended.",
|
|
|
|
|
);
|
|
|
|
|
this.message = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-09 00:51:52 +00:00
|
|
|
|
// DEBUGGING: fake set the freeze indicator.
|
|
|
|
|
let match = this.message.match(/^\/freeze (.+?)$/i);
|
|
|
|
|
if (match) {
|
|
|
|
|
let username = match[1];
|
|
|
|
|
this.WebRTC.frozenStreamDetected[username] = true;
|
|
|
|
|
this.ChatClient(`DEBUG: Marked ${username} stream as frozen.`);
|
|
|
|
|
this.message = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 00:18:18 +00:00
|
|
|
|
// DEBUGGING: test whether the page thinks you're Apple Webkit.
|
|
|
|
|
if (this.message.toLowerCase().indexOf("/ipad") === 0) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (isAppleWebkit()) {
|
2023-09-01 00:18:18 +00:00
|
|
|
|
this.ChatClient("I have detected that you are probably an iPad or iPhone browser.");
|
|
|
|
|
} else {
|
|
|
|
|
this.ChatClient("I have detected that you <strong>are not</strong> an iPad or iPhone browser.");
|
|
|
|
|
}
|
|
|
|
|
this.message = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 21:33:09 +00:00
|
|
|
|
// console.debug("Send message: %s", this.message);
|
2023-01-11 06:38:48 +00:00
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "message",
|
2023-02-05 08:53:50 +00:00
|
|
|
|
channel: this.channel,
|
2023-01-11 06:38:48 +00:00
|
|
|
|
message: this.message,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
this.message = "";
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-10 07:03:06 +00:00
|
|
|
|
sendTypingNotification() {
|
|
|
|
|
// TODO
|
|
|
|
|
},
|
|
|
|
|
|
2023-07-01 03:00:21 +00:00
|
|
|
|
// Emoji reactions
|
|
|
|
|
sendReact(message, emoji) {
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: 'react',
|
|
|
|
|
msgID: message.msgID,
|
|
|
|
|
message: emoji,
|
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
onReact(msg) {
|
|
|
|
|
// Search all channels for this message ID and append the reaction.
|
|
|
|
|
let msgID = msg.msgID,
|
|
|
|
|
who = msg.username,
|
|
|
|
|
emoji = msg.message;
|
|
|
|
|
|
|
|
|
|
if (this.messageReactions[msgID] == undefined) {
|
|
|
|
|
this.messageReactions[msgID] = {};
|
|
|
|
|
}
|
|
|
|
|
if (this.messageReactions[msgID][emoji] == undefined) {
|
|
|
|
|
this.messageReactions[msgID][emoji] = [];
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-01 18:39:08 +00:00
|
|
|
|
// if they double sent the same reaction, it counts as a removal
|
|
|
|
|
let unreact = false;
|
|
|
|
|
for (let i = 0; i < this.messageReactions[msgID][emoji].length; i++) {
|
|
|
|
|
let reactor = this.messageReactions[msgID][emoji][i];
|
|
|
|
|
if (reactor === who) {
|
|
|
|
|
this.messageReactions[msgID][emoji].splice(i, 1);
|
|
|
|
|
unreact = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if this emoji reaction is empty, clean it up
|
|
|
|
|
if (unreact) {
|
|
|
|
|
if (this.messageReactions[msgID][emoji].length === 0) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.messageReactions[msgID][emoji]);
|
2023-07-01 18:39:08 +00:00
|
|
|
|
}
|
|
|
|
|
return;
|
2023-07-01 03:00:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.messageReactions[msgID][emoji].push(who);
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Sync the current user state (such as video broadcasting status) to
|
|
|
|
|
// the backend, which will reload everybody's Who List.
|
|
|
|
|
sendMe() {
|
2023-08-29 00:49:50 +00:00
|
|
|
|
if (!this.ws.connected) return;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "me",
|
2023-07-01 01:41:06 +00:00
|
|
|
|
video: this.myVideoFlag,
|
2023-03-28 04:13:04 +00:00
|
|
|
|
status: this.status,
|
2023-08-29 00:49:50 +00:00
|
|
|
|
dnd: this.prefs.closeDMs,
|
2023-01-27 04:34:58 +00:00
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
onMe(msg) {
|
|
|
|
|
// We have had settings pushed to us by the server, such as a change
|
|
|
|
|
// in our choice of username.
|
|
|
|
|
if (this.username != msg.username) {
|
|
|
|
|
this.ChatServer(`Your username has been changed to ${msg.username}.`);
|
2023-01-27 06:54:02 +00:00
|
|
|
|
this.username = msg.username;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 06:46:39 +00:00
|
|
|
|
// The server can set our webcam NSFW flag.
|
2023-07-01 01:41:06 +00:00
|
|
|
|
let myNSFW = this.webcam.nsfw;
|
|
|
|
|
let theirNSFW = (msg.video & this.VideoFlag.NSFW) > 0;
|
|
|
|
|
if (myNSFW != theirNSFW) {
|
|
|
|
|
this.webcam.nsfw = theirNSFW;
|
2023-02-11 06:46:39 +00:00
|
|
|
|
}
|
2023-07-30 17:32:08 +00:00
|
|
|
|
|
|
|
|
|
// Note: Me events only come when we join the server or a moderator has
|
|
|
|
|
// flagged our video. This is as good of an "on connected" handler as we
|
|
|
|
|
// get, so push over our cached blocklist from the website now.
|
|
|
|
|
this.bulkMuteUsers();
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// WhoList updates.
|
|
|
|
|
onWho(msg) {
|
|
|
|
|
this.whoList = msg.whoList;
|
2023-02-06 01:42:09 +00:00
|
|
|
|
this.whoMap = {};
|
2023-02-05 08:53:50 +00:00
|
|
|
|
|
2023-03-29 01:12:49 +00:00
|
|
|
|
if (this.whoList == undefined) {
|
|
|
|
|
this.whoList = [];
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// If we had a camera open with any of these and they have gone
|
|
|
|
|
// off camera, close our side of the connection.
|
|
|
|
|
for (let row of this.whoList) {
|
2023-02-06 01:42:09 +00:00
|
|
|
|
this.whoMap[row.username] = row;
|
2023-02-05 08:53:50 +00:00
|
|
|
|
if (this.WebRTC.streams[row.username] != undefined &&
|
2023-07-01 01:41:06 +00:00
|
|
|
|
!(row.video & this.VideoFlag.Active)) {
|
2023-02-06 23:02:23 +00:00
|
|
|
|
this.closeVideo(row.username, "offerer");
|
2023-02-05 08:53:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-06 04:26:00 +00:00
|
|
|
|
|
2023-08-12 01:42:06 +00:00
|
|
|
|
// Hang up on mutual cameras, if they changed their setting while we
|
|
|
|
|
// are already watching them.
|
|
|
|
|
this.unMutualVideo();
|
|
|
|
|
|
2023-02-06 04:26:00 +00:00
|
|
|
|
// Has the back-end server forgotten we are on video? This can
|
|
|
|
|
// happen if we disconnect/reconnect while we were streaming.
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if (this.webcam.active && !(this.whoMap[this.username]?.video & this.VideoFlag.Active)) {
|
2023-02-06 04:26:00 +00:00
|
|
|
|
this.sendMe();
|
|
|
|
|
}
|
2023-01-27 04:34:58 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-03-23 03:21:04 +00:00
|
|
|
|
// Mute or unmute a user.
|
|
|
|
|
muteUser(username) {
|
2023-06-15 03:45:54 +00:00
|
|
|
|
username = this.normalizeUsername(username);
|
2023-03-23 03:21:04 +00:00
|
|
|
|
let mute = this.muted[username] == undefined;
|
2023-08-10 03:49:41 +00:00
|
|
|
|
|
|
|
|
|
// If the user is muted because they were blocked on your main website (CachedBlocklist),
|
|
|
|
|
// do not allow a temporary unmute in chat: make them live with their choice.
|
|
|
|
|
if (this.config.CachedBlocklist.length > 0) {
|
|
|
|
|
for (let user of this.config.CachedBlocklist) {
|
|
|
|
|
if (user === username) {
|
|
|
|
|
this.ChatClient(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
`You can not unmute <strong>${username}</strong> because you have blocked them on the main website. ` +
|
2023-08-10 03:49:41 +00:00
|
|
|
|
`To unmute them, you will need to unblock them on the website and then reload the chat room.`
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 03:21:04 +00:00
|
|
|
|
if (mute) {
|
2023-07-01 18:39:08 +00:00
|
|
|
|
if (!window.confirm(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
`Do you want to mute ${username}? If muted, you will no longer see their ` +
|
|
|
|
|
`chat messages or any DMs they send you going forward. Also, ${username} will ` +
|
2023-07-01 18:39:08 +00:00
|
|
|
|
`not be able to see whether your webcam is active until you unmute them.`
|
|
|
|
|
)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-03-23 03:21:04 +00:00
|
|
|
|
this.muted[username] = true;
|
|
|
|
|
} else {
|
2023-07-30 18:25:44 +00:00
|
|
|
|
if (!window.confirm(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
`Do you want to remove your mute on ${username}? If you un-mute them, you ` +
|
|
|
|
|
`will be able to see their chat messages or DMs going forward, but most importantly, ` +
|
|
|
|
|
`they may be able to watch your webcam now if you are broadcasting!\n\n` +
|
|
|
|
|
`Note: currently you can only re-mute them the next time you see one of their ` +
|
|
|
|
|
`chat messages, or you can only boot them off your cam after they have already ` +
|
|
|
|
|
`opened it. If you are concerned about this, click Cancel and do not remove ` +
|
2023-07-30 18:25:44 +00:00
|
|
|
|
`the mute on ${username}.`
|
|
|
|
|
)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-03-23 03:21:04 +00:00
|
|
|
|
delete this.muted[username];
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 04:06:57 +00:00
|
|
|
|
// Hang up videos both ways.
|
|
|
|
|
this.closeVideo(username);
|
|
|
|
|
|
2023-03-23 03:21:04 +00:00
|
|
|
|
this.sendMute(username, mute);
|
|
|
|
|
if (mute) {
|
|
|
|
|
this.ChatClient(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
`You have muted <strong>${username}</strong> and will no longer see their chat messages, ` +
|
2023-03-23 03:21:04 +00:00
|
|
|
|
`and they will not see whether your webcam is active. You may unmute them via the Who Is Online list.`);
|
|
|
|
|
} else {
|
|
|
|
|
this.ChatClient(
|
|
|
|
|
`You have unmuted <strong>${username}</strong> and can see their chat messages from now on.`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
sendMute(username, mute) {
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: mute ? "mute" : "unmute",
|
|
|
|
|
username: username,
|
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
isMutedUser(username) {
|
2023-06-15 03:45:54 +00:00
|
|
|
|
return this.muted[this.normalizeUsername(username)] != undefined;
|
2023-03-23 03:21:04 +00:00
|
|
|
|
},
|
2023-07-30 17:32:08 +00:00
|
|
|
|
bulkMuteUsers() {
|
|
|
|
|
// On page load, if the website sent you a CachedBlocklist, mute all
|
|
|
|
|
// of these users in bulk when the server connects.
|
|
|
|
|
// this.ChatClient("BulkMuteUsers: sending our blocklist " + this.config.CachedBlocklist);
|
|
|
|
|
|
|
|
|
|
if (this.config.CachedBlocklist.length === 0) {
|
|
|
|
|
return; // nothing to do
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the client side mute.
|
|
|
|
|
let blocklist = this.config.CachedBlocklist;
|
|
|
|
|
for (let username of blocklist) {
|
|
|
|
|
this.muted[username] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send the username list to the server.
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "blocklist",
|
|
|
|
|
usernames: blocklist,
|
|
|
|
|
}))
|
|
|
|
|
},
|
2023-03-23 03:21:04 +00:00
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// Send a video request to access a user's camera.
|
|
|
|
|
sendOpen(username) {
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "open",
|
|
|
|
|
username: username,
|
|
|
|
|
}));
|
|
|
|
|
},
|
2023-03-23 03:21:04 +00:00
|
|
|
|
sendBoot(username) {
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "boot",
|
|
|
|
|
username: username,
|
|
|
|
|
}));
|
|
|
|
|
},
|
2023-01-27 06:54:02 +00:00
|
|
|
|
onOpen(msg) {
|
|
|
|
|
// Response for the opener to begin WebRTC connection.
|
|
|
|
|
this.startWebRTC(msg.username, true);
|
|
|
|
|
},
|
|
|
|
|
onRing(msg) {
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// Request from a viewer to see our broadcast.
|
2023-01-27 06:54:02 +00:00
|
|
|
|
this.startWebRTC(msg.username, false);
|
|
|
|
|
},
|
2023-02-05 05:00:01 +00:00
|
|
|
|
onUserExited(msg) {
|
|
|
|
|
// A user has logged off the server. Clean up any WebRTC connections.
|
2023-02-05 08:53:50 +00:00
|
|
|
|
this.closeVideo(msg.username);
|
2023-02-05 05:00:01 +00:00
|
|
|
|
},
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Handle messages sent in chat.
|
|
|
|
|
onMessage(msg) {
|
2023-02-10 07:03:06 +00:00
|
|
|
|
// Play sound effects if this is not the active channel or the window is not focused.
|
2023-02-06 21:27:29 +00:00
|
|
|
|
if (msg.channel.indexOf("@") === 0) {
|
2023-02-10 07:03:06 +00:00
|
|
|
|
if (msg.channel !== this.channel || !this.windowFocused) {
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// If we are ignoring unsolicited DMs, don't play the sound effect here.
|
|
|
|
|
if (this.prefs.closeDMs && this.channels[msg.channel] == undefined) {
|
|
|
|
|
console.log("Unsolicited DM received");
|
|
|
|
|
} else {
|
|
|
|
|
this.playSound("DM");
|
|
|
|
|
}
|
2023-02-06 21:27:29 +00:00
|
|
|
|
}
|
2023-02-10 07:03:06 +00:00
|
|
|
|
} else if (msg.channel !== this.channel || !this.windowFocused) {
|
2023-02-06 21:27:29 +00:00
|
|
|
|
this.playSound("Chat");
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.pushHistory({
|
2023-02-05 08:53:50 +00:00
|
|
|
|
channel: msg.channel,
|
2023-01-27 04:34:58 +00:00
|
|
|
|
username: msg.username,
|
|
|
|
|
message: msg.message,
|
2023-06-24 20:08:15 +00:00
|
|
|
|
messageID: msg.msgID,
|
2023-01-27 04:34:58 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2023-06-24 20:08:15 +00:00
|
|
|
|
// A user deletes their message for everybody
|
|
|
|
|
onTakeback(msg) {
|
|
|
|
|
// Search all channels for this message ID and remove it.
|
|
|
|
|
for (let channel of Object.keys(this.channels)) {
|
|
|
|
|
for (let i = 0; i < this.channels[channel].history.length; i++) {
|
|
|
|
|
let cmp = this.channels[channel].history[i];
|
|
|
|
|
if (cmp.msgID === msg.msgID) {
|
|
|
|
|
this.channels[channel].history.splice(i, 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.error("Got a takeback for msgID %d but did not find it!", msg.msgID);
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-06 01:42:09 +00:00
|
|
|
|
// User logged in or out.
|
|
|
|
|
onPresence(msg) {
|
|
|
|
|
// TODO: make a dedicated leave event
|
2023-08-29 05:46:40 +00:00
|
|
|
|
let isLeave = false,
|
|
|
|
|
isJoin = false;
|
2023-02-06 01:42:09 +00:00
|
|
|
|
if (msg.message.indexOf("has exited the room!") > -1) {
|
|
|
|
|
// Clean up data about this user.
|
|
|
|
|
this.onUserExited(msg);
|
2023-02-06 21:27:29 +00:00
|
|
|
|
this.playSound("Leave");
|
2023-06-12 03:33:26 +00:00
|
|
|
|
isLeave = true;
|
2023-08-29 05:46:40 +00:00
|
|
|
|
} else if (msg.message.indexOf("has joined the room!") > -1) {
|
2023-02-06 21:27:29 +00:00
|
|
|
|
this.playSound("Enter");
|
2023-08-29 05:46:40 +00:00
|
|
|
|
isJoin = true;
|
2023-02-06 01:42:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// Push it to the history of all public channels (depending on user preference).
|
2023-08-30 02:57:12 +00:00
|
|
|
|
if ((isJoin && this.prefs.joinMessages) || (isLeave && this.prefs.exitMessages)
|
|
|
|
|
|| (!isJoin && !isLeave)) {
|
2023-06-12 03:33:26 +00:00
|
|
|
|
for (let channel of this.config.channels) {
|
|
|
|
|
this.pushHistory({
|
|
|
|
|
channel: channel.ID,
|
|
|
|
|
action: msg.action,
|
|
|
|
|
username: msg.username,
|
|
|
|
|
message: msg.message,
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-02-06 21:27:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-12 03:33:26 +00:00
|
|
|
|
// Push also to any DM channels for this user (leave events do push to DM thread for visibility).
|
2023-02-06 21:27:29 +00:00
|
|
|
|
let channel = "@" + msg.username;
|
|
|
|
|
if (this.channels[channel] != undefined) {
|
|
|
|
|
this.pushHistory({
|
|
|
|
|
channel: channel,
|
|
|
|
|
action: msg.action,
|
|
|
|
|
username: msg.username,
|
|
|
|
|
message: msg.message,
|
2023-02-06 01:42:09 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-11 06:38:48 +00:00
|
|
|
|
// Dial the WebSocket connection.
|
|
|
|
|
dial() {
|
2023-02-09 04:01:06 +00:00
|
|
|
|
this.ChatClient("Establishing connection to server...");
|
|
|
|
|
|
2023-02-05 05:00:01 +00:00
|
|
|
|
const proto = location.protocol === 'https:' ? 'wss' : 'ws';
|
|
|
|
|
const conn = new WebSocket(`${proto}://${location.host}/ws`);
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
|
|
|
|
conn.addEventListener("close", ev => {
|
2023-02-06 01:42:09 +00:00
|
|
|
|
// Lost connection to server - scrub who list.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
this.onWho({ whoList: [] });
|
2023-03-23 03:21:04 +00:00
|
|
|
|
this.muted = {};
|
2023-02-06 01:42:09 +00:00
|
|
|
|
|
2023-01-11 06:38:48 +00:00
|
|
|
|
this.ws.connected = false;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.ChatClient(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`);
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
2023-02-20 05:36:36 +00:00
|
|
|
|
this.disconnectCount++;
|
|
|
|
|
if (this.disconnectCount > this.disconnectLimit) {
|
2023-09-01 00:18:18 +00:00
|
|
|
|
this.ChatClient(`It seems there's a problem connecting to the server. Please try some other time.`);
|
2023-02-20 05:36:36 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 06:46:39 +00:00
|
|
|
|
if (!this.disconnect) {
|
|
|
|
|
if (ev.code !== 1001) {
|
|
|
|
|
this.ChatClient("Reconnecting in 5s");
|
|
|
|
|
setTimeout(this.dial, 5000);
|
|
|
|
|
}
|
2023-01-11 06:38:48 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
conn.addEventListener("open", ev => {
|
|
|
|
|
this.ws.connected = true;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.ChatClient("Websocket connected!");
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
|
|
|
|
// Tell the server our username.
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "login",
|
|
|
|
|
username: this.username,
|
2023-02-06 01:42:09 +00:00
|
|
|
|
jwt: this.jwt.token,
|
2023-08-29 00:49:50 +00:00
|
|
|
|
dnd: this.prefs.closeDMs,
|
2023-01-11 06:38:48 +00:00
|
|
|
|
}));
|
2023-08-29 00:49:50 +00:00
|
|
|
|
|
|
|
|
|
// Focus the message entry box.
|
|
|
|
|
window.requestAnimationFrame(() => {
|
|
|
|
|
this.messageBox.focus();
|
|
|
|
|
});
|
2023-01-11 06:38:48 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
conn.addEventListener("message", ev => {
|
|
|
|
|
if (typeof ev.data !== "string") {
|
|
|
|
|
console.error("unexpected message type", typeof ev.data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let msg = JSON.parse(ev.data);
|
2023-02-06 21:27:29 +00:00
|
|
|
|
try {
|
|
|
|
|
// Cast timestamp to date.
|
|
|
|
|
msg.at = new Date(msg.at);
|
2023-09-07 06:03:12 +00:00
|
|
|
|
} catch (e) {
|
2023-02-06 21:27:29 +00:00
|
|
|
|
console.error("Parsing timestamp '%s' on msg: %s", msg.at, e);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
switch (msg.action) {
|
|
|
|
|
case "who":
|
2023-02-05 08:53:50 +00:00
|
|
|
|
this.onWho(msg);
|
2023-01-27 04:34:58 +00:00
|
|
|
|
break;
|
|
|
|
|
case "me":
|
|
|
|
|
this.onMe(msg);
|
|
|
|
|
break;
|
|
|
|
|
case "message":
|
|
|
|
|
this.onMessage(msg);
|
|
|
|
|
break;
|
2023-06-24 20:08:15 +00:00
|
|
|
|
case "takeback":
|
|
|
|
|
this.onTakeback(msg);
|
|
|
|
|
break;
|
2023-07-01 03:00:21 +00:00
|
|
|
|
case "react":
|
|
|
|
|
this.onReact(msg);
|
|
|
|
|
break;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
case "presence":
|
2023-02-06 01:42:09 +00:00
|
|
|
|
this.onPresence(msg);
|
2023-01-27 04:34:58 +00:00
|
|
|
|
break;
|
2023-01-27 06:54:02 +00:00
|
|
|
|
case "ring":
|
|
|
|
|
this.onRing(msg);
|
|
|
|
|
break;
|
|
|
|
|
case "open":
|
|
|
|
|
this.onOpen(msg);
|
|
|
|
|
break;
|
|
|
|
|
case "candidate":
|
|
|
|
|
this.onCandidate(msg);
|
|
|
|
|
break;
|
|
|
|
|
case "sdp":
|
|
|
|
|
this.onSDP(msg);
|
|
|
|
|
break;
|
2023-02-06 04:26:00 +00:00
|
|
|
|
case "watch":
|
|
|
|
|
this.onWatch(msg);
|
|
|
|
|
break;
|
|
|
|
|
case "unwatch":
|
|
|
|
|
this.onUnwatch(msg);
|
|
|
|
|
break;
|
2023-01-27 06:54:02 +00:00
|
|
|
|
case "error":
|
|
|
|
|
this.pushHistory({
|
2023-02-06 01:42:09 +00:00
|
|
|
|
channel: msg.channel,
|
2023-01-27 06:54:02 +00:00
|
|
|
|
username: msg.username || 'Internal Server Error',
|
|
|
|
|
message: msg.message,
|
2023-02-06 01:42:09 +00:00
|
|
|
|
isChatServer: true,
|
2023-01-27 06:54:02 +00:00
|
|
|
|
});
|
2023-02-06 21:27:29 +00:00
|
|
|
|
break;
|
2023-02-11 06:46:39 +00:00
|
|
|
|
case "disconnect":
|
|
|
|
|
this.disconnect = true;
|
|
|
|
|
break;
|
2023-02-06 21:27:29 +00:00
|
|
|
|
case "ping":
|
2023-04-20 02:55:39 +00:00
|
|
|
|
// New JWT token?
|
|
|
|
|
if (msg.jwt) {
|
|
|
|
|
this.jwt.token = msg.jwt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset disconnect retry counter: if we were on long enough to get
|
|
|
|
|
// a ping, we're well connected and can reconnect no matter how many
|
|
|
|
|
// times the chat server is rebooted.
|
|
|
|
|
this.disconnectCount = 0;
|
2023-02-06 21:27:29 +00:00
|
|
|
|
break;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
default:
|
|
|
|
|
console.error("Unexpected action: %s", JSON.stringify(msg));
|
|
|
|
|
}
|
2023-01-11 06:38:48 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.ws.conn = conn;
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* WebRTC concerns.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Start WebRTC with the other username.
|
|
|
|
|
startWebRTC(username, isOfferer) {
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// this.ChatClient(`Begin WebRTC with ${username}.`);
|
2023-01-27 06:54:02 +00:00
|
|
|
|
let pc = new RTCPeerConnection(configuration);
|
2023-02-06 23:02:23 +00:00
|
|
|
|
|
|
|
|
|
// Store uni-directional PeerConnections:
|
|
|
|
|
// - If we are reading video from the other (offerer)
|
|
|
|
|
// - If we are sending video to the other (answerer)
|
|
|
|
|
if (this.WebRTC.pc[username] == undefined) {
|
|
|
|
|
this.WebRTC.pc[username] = {};
|
|
|
|
|
}
|
|
|
|
|
if (isOfferer) {
|
|
|
|
|
this.WebRTC.pc[username].offerer = pc;
|
|
|
|
|
} else {
|
|
|
|
|
this.WebRTC.pc[username].answerer = pc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Keep a pointer to the current channel being established (for candidate/SDP).
|
|
|
|
|
this.WebRTC.pc[username].connecting = pc;
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
2023-02-05 05:00:01 +00:00
|
|
|
|
// Create a data channel so we have something to connect over even if
|
|
|
|
|
// the local user is not broadcasting their own camera.
|
2023-08-30 00:32:20 +00:00
|
|
|
|
// TODO: adding a dummy data channel might allow iPad to open single directional video
|
2023-02-05 05:00:01 +00:00
|
|
|
|
let dataChannel = pc.createDataChannel("data");
|
|
|
|
|
dataChannel.addEventListener("open", event => {
|
|
|
|
|
// beginTransmission(dataChannel);
|
|
|
|
|
})
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// 'onicecandidate' notifies us whenever an ICE agent needs to deliver a
|
|
|
|
|
// message to the other peer through the signaling server.
|
|
|
|
|
pc.onicecandidate = event => {
|
|
|
|
|
if (event.candidate) {
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "candidate",
|
|
|
|
|
username: username,
|
2023-02-25 01:42:38 +00:00
|
|
|
|
candidate: JSON.stringify(event.candidate),
|
2023-01-27 06:54:02 +00:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// If the user is offerer let the 'negotiationneeded' event create the offer.
|
|
|
|
|
if (isOfferer) {
|
|
|
|
|
pc.onnegotiationneeded = () => {
|
|
|
|
|
pc.createOffer().then(this.localDescCreated(pc, username)).catch(this.ChatClient);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// When a remote stream arrives.
|
|
|
|
|
pc.ontrack = event => {
|
|
|
|
|
const stream = event.streams[0];
|
|
|
|
|
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// We've received a video! If we had an "open camera spinner timeout",
|
|
|
|
|
// clear it before it expires.
|
|
|
|
|
if (this.WebRTC.openTimeouts[username] != undefined) {
|
|
|
|
|
clearTimeout(this.WebRTC.openTimeouts[username]);
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.WebRTC.openTimeouts[username]);
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// Do we already have it?
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// this.ChatClient(`Received a video stream from ${username}.`);
|
2023-01-27 06:54:02 +00:00
|
|
|
|
if (this.WebRTC.streams[username] == undefined ||
|
|
|
|
|
this.WebRTC.streams[username].id !== stream.id) {
|
|
|
|
|
this.WebRTC.streams[username] = stream;
|
|
|
|
|
}
|
2023-02-05 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
window.requestAnimationFrame(() => {
|
|
|
|
|
let $ref = document.getElementById(`videofeed-${username}`);
|
|
|
|
|
$ref.srcObject = stream;
|
|
|
|
|
});
|
2023-02-06 04:26:00 +00:00
|
|
|
|
|
|
|
|
|
// Inform them they are being watched.
|
|
|
|
|
this.sendWatch(username, true);
|
2023-08-09 00:51:52 +00:00
|
|
|
|
|
|
|
|
|
// Set a mute video handler to detect freezes.
|
|
|
|
|
stream.getVideoTracks().forEach(videoTrack => {
|
|
|
|
|
let freezeDetected = () => {
|
|
|
|
|
console.log("FREEZE DETECTED:", username);
|
2023-08-11 03:01:38 +00:00
|
|
|
|
// Wait some seconds to see if the stream has recovered on its own
|
2023-08-09 00:51:52 +00:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// Flag it as likely frozen.
|
|
|
|
|
if (videoTrack.muted) {
|
|
|
|
|
this.WebRTC.frozenStreamDetected[username] = true;
|
|
|
|
|
}
|
2023-08-11 03:01:38 +00:00
|
|
|
|
}, 7500); // 7.5s
|
2023-08-09 00:51:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
console.log("Apply onmute handler for", username);
|
|
|
|
|
videoTrack.onmute = freezeDetected;
|
|
|
|
|
|
|
|
|
|
// Double check for frozen streams on an interval.
|
|
|
|
|
this.WebRTC.frozenStreamInterval[username] = setInterval(() => {
|
|
|
|
|
if (videoTrack.muted) freezeDetected();
|
|
|
|
|
}, 3000);
|
|
|
|
|
})
|
2023-01-27 06:54:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-09-01 00:18:18 +00:00
|
|
|
|
// ANSWERER: add our video to the connection so that the offerer (the one who
|
|
|
|
|
// clicked on our video icon to watch us) can receive it.
|
2023-02-05 08:53:50 +00:00
|
|
|
|
if (!isOfferer && this.webcam.active) {
|
2023-02-05 05:00:01 +00:00
|
|
|
|
let stream = this.webcam.stream;
|
|
|
|
|
stream.getTracks().forEach(track => {
|
|
|
|
|
pc.addTrack(track, stream)
|
|
|
|
|
});
|
2023-01-27 06:54:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 00:18:18 +00:00
|
|
|
|
// OFFERER: If we were already broadcasting our own video, and the answerer
|
|
|
|
|
// has the "auto-open your video" setting enabled, attach our video to the initial
|
|
|
|
|
// offer right now.
|
|
|
|
|
//
|
|
|
|
|
// NOTE: this will force open our video on the answerer's side, and this workflow
|
|
|
|
|
// is also the only way that iPads/iPhones/Safari browsers can make a call
|
|
|
|
|
// (two-way video is the only option for them; send-only/receive-only channels seem
|
|
|
|
|
// not to work in Safari).
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if (isOfferer && (this.whoMap[username].video & this.VideoFlag.MutualOpen) && this.webcam.active) {
|
2023-04-01 02:46:42 +00:00
|
|
|
|
let stream = this.webcam.stream;
|
|
|
|
|
stream.getTracks().forEach(track => {
|
|
|
|
|
pc.addTrack(track, stream)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// If we are the offerer, begin the connection.
|
|
|
|
|
if (isOfferer) {
|
2023-02-05 08:53:50 +00:00
|
|
|
|
pc.createOffer({
|
|
|
|
|
offerToReceiveVideo: true,
|
|
|
|
|
offerToReceiveAudio: true,
|
|
|
|
|
}).then(this.localDescCreated(pc, username)).catch(this.ChatClient);
|
2023-01-27 06:54:02 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Common handler function for
|
|
|
|
|
localDescCreated(pc, username) {
|
|
|
|
|
return (desc) => {
|
2023-08-30 00:32:20 +00:00
|
|
|
|
pc.setLocalDescription(desc).then(() => {
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "sdp",
|
|
|
|
|
username: username,
|
|
|
|
|
description: JSON.stringify(pc.localDescription),
|
|
|
|
|
}));
|
|
|
|
|
}).catch(e => {
|
2023-09-02 00:11:17 +00:00
|
|
|
|
console.error(`Error sending WebRTC negotiation message (SDP): ${e}`);
|
2023-08-30 00:32:20 +00:00
|
|
|
|
});
|
2023-01-27 06:54:02 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Handle inbound WebRTC signaling messages proxied by the websocket.
|
|
|
|
|
onCandidate(msg) {
|
2023-02-06 23:02:23 +00:00
|
|
|
|
if (this.WebRTC.pc[msg.username] == undefined || !this.WebRTC.pc[msg.username].connecting) {
|
2023-02-05 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2023-02-06 23:02:23 +00:00
|
|
|
|
let pc = this.WebRTC.pc[msg.username].connecting;
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
2023-02-25 01:42:38 +00:00
|
|
|
|
// XX: WebRTC candidate/SDP messages JSON stringify their inner payload so that the
|
|
|
|
|
// Go back-end server won't re-order their json keys (Safari on Mac OS is very sensitive
|
|
|
|
|
// to the keys being re-ordered during the handshake, in ways that NO OTHER BROWSER cares
|
|
|
|
|
// about at all). Re-parse the JSON stringified object here.
|
|
|
|
|
let candidate = JSON.parse(msg.candidate);
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// Add the new ICE candidate.
|
2023-08-30 00:32:20 +00:00
|
|
|
|
pc.addIceCandidate(candidate).catch(e => {
|
|
|
|
|
this.ChatClient(`addIceCandidate: ${e}`);
|
|
|
|
|
});
|
2023-01-27 06:54:02 +00:00
|
|
|
|
},
|
|
|
|
|
onSDP(msg) {
|
2023-02-06 23:02:23 +00:00
|
|
|
|
if (this.WebRTC.pc[msg.username] == undefined || !this.WebRTC.pc[msg.username].connecting) {
|
2023-02-05 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2023-02-06 23:02:23 +00:00
|
|
|
|
let pc = this.WebRTC.pc[msg.username].connecting;
|
2023-02-25 01:42:38 +00:00
|
|
|
|
|
|
|
|
|
// XX: WebRTC candidate/SDP messages JSON stringify their inner payload so that the
|
|
|
|
|
// Go back-end server won't re-order their json keys (Safari on Mac OS is very sensitive
|
|
|
|
|
// to the keys being re-ordered during the handshake, in ways that NO OTHER BROWSER cares
|
|
|
|
|
// about at all). Re-parse the JSON stringified object here.
|
|
|
|
|
let message = JSON.parse(msg.description);
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
|
|
|
|
// Add the new ICE candidate.
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// this.ChatClient(`Received a Remote Description from ${msg.username}: ${JSON.stringify(msg.description)}.`);
|
2023-02-05 05:00:01 +00:00
|
|
|
|
pc.setRemoteDescription(new RTCSessionDescription(message), () => {
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// When receiving an offer let's answer it.
|
|
|
|
|
if (pc.remoteDescription.type === 'offer') {
|
|
|
|
|
pc.createAnswer().then(this.localDescCreated(pc, msg.username)).catch(this.ChatClient);
|
|
|
|
|
}
|
|
|
|
|
}, console.error);
|
|
|
|
|
},
|
2023-02-06 04:26:00 +00:00
|
|
|
|
onWatch(msg) {
|
|
|
|
|
// The user has our video feed open now.
|
2023-08-05 02:24:42 +00:00
|
|
|
|
if (this.isBootedAdmin(msg.username)) return;
|
2023-08-29 00:49:50 +00:00
|
|
|
|
|
|
|
|
|
// Notify in chat if this was the first watch (viewer may send multiple per each track they received)
|
|
|
|
|
if (this.prefs.watchNotif && this.webcam.watching[msg.username] != true) {
|
|
|
|
|
this.ChatServer(
|
|
|
|
|
`<strong>${msg.username}</strong> is now watching your camera.`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 04:26:00 +00:00
|
|
|
|
this.webcam.watching[msg.username] = true;
|
2023-08-29 05:46:40 +00:00
|
|
|
|
this.playSound("Watch");
|
2023-02-06 04:26:00 +00:00
|
|
|
|
},
|
|
|
|
|
onUnwatch(msg) {
|
|
|
|
|
// The user has closed our video feed.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.webcam.watching[msg.username]);
|
2023-08-29 05:46:40 +00:00
|
|
|
|
this.playSound("Unwatch");
|
2023-02-06 04:26:00 +00:00
|
|
|
|
},
|
|
|
|
|
sendWatch(username, watching) {
|
|
|
|
|
// Send the watch or unwatch message to backend.
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: watching ? "watch" : "unwatch",
|
|
|
|
|
username: username,
|
|
|
|
|
}));
|
|
|
|
|
},
|
2023-07-23 01:30:45 +00:00
|
|
|
|
isWatchingMe(username) {
|
|
|
|
|
// Return whether the user is watching your camera
|
|
|
|
|
return this.webcam.watching[username] === true;
|
|
|
|
|
},
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Front-end web app concerns.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-02-06 21:27:29 +00:00
|
|
|
|
// Settings modal.
|
|
|
|
|
showSettings() {
|
|
|
|
|
this.settingsModal.visible = true;
|
|
|
|
|
},
|
|
|
|
|
hideSettings() {
|
|
|
|
|
this.settingsModal.visible = false;
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Set active chat room.
|
|
|
|
|
setChannel(channel) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
this.channel = typeof (channel) === "string" ? channel : channel.ID;
|
2023-06-24 18:12:02 +00:00
|
|
|
|
this.scrollHistory(this.channel, true);
|
2023-02-05 08:53:50 +00:00
|
|
|
|
this.channels[this.channel].unread = 0;
|
2023-02-06 01:42:09 +00:00
|
|
|
|
|
|
|
|
|
// Responsive CSS: switch back to chat panel upon selecting a channel.
|
|
|
|
|
this.openChatPanel();
|
2023-02-12 00:02:48 +00:00
|
|
|
|
|
|
|
|
|
// Edit hyperlinks to open in a new window.
|
|
|
|
|
this.makeLinksExternal();
|
2023-08-29 00:49:50 +00:00
|
|
|
|
|
|
|
|
|
// Focus the message entry box.
|
|
|
|
|
this.messageBox.focus();
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
|
|
|
|
hasUnread(channel) {
|
|
|
|
|
if (this.channels[channel] == undefined) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return this.channels[channel].unread;
|
|
|
|
|
},
|
2023-07-18 03:38:07 +00:00
|
|
|
|
hasAnyUnread() {
|
|
|
|
|
// Returns total unread count (for mobile responsive view to show in the left drawer button)
|
|
|
|
|
let count = 0;
|
|
|
|
|
for (let channel of Object.keys(this.channels)) {
|
|
|
|
|
count += this.channels[channel].unread;
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
},
|
|
|
|
|
anyUnreadDMs() {
|
|
|
|
|
// Returns true if any unread messages are DM threads
|
|
|
|
|
for (let channel of Object.keys(this.channels)) {
|
|
|
|
|
if (channel.indexOf("@") === 0 && this.channels[channel].unread > 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2023-02-05 08:53:50 +00:00
|
|
|
|
openDMs(user) {
|
|
|
|
|
let channel = "@" + user.username;
|
|
|
|
|
this.initHistory(channel);
|
|
|
|
|
this.setChannel(channel);
|
2023-02-06 01:42:09 +00:00
|
|
|
|
|
|
|
|
|
// Responsive CSS: switch back to chat panel upon opening a DM.
|
|
|
|
|
this.openChatPanel();
|
|
|
|
|
},
|
|
|
|
|
openProfile(user) {
|
|
|
|
|
let url = this.profileURLForUsername(user.username);
|
|
|
|
|
if (url) {
|
|
|
|
|
window.open(url);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
avatarURL(user) {
|
|
|
|
|
// Resolve the avatar URL of this user.
|
|
|
|
|
if (user.avatar.match(/^https?:/i)) {
|
|
|
|
|
return user.avatar;
|
|
|
|
|
} else if (user.avatar.indexOf("/") === 0) {
|
|
|
|
|
return this.config.website.replace(/\/+$/, "") + user.avatar;
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
},
|
2023-06-13 01:16:27 +00:00
|
|
|
|
isUsernameOnline(username) {
|
|
|
|
|
return this.whoMap[username] != undefined;
|
|
|
|
|
},
|
2023-02-06 01:42:09 +00:00
|
|
|
|
avatarForUsername(username) {
|
|
|
|
|
if (this.whoMap[username] != undefined && this.whoMap[username].avatar) {
|
|
|
|
|
return this.avatarURL(this.whoMap[username]);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
profileURLForUsername(username) {
|
|
|
|
|
if (!username) return;
|
|
|
|
|
username = username.replace(/^@/, "");
|
|
|
|
|
if (this.whoMap[username] != undefined && this.whoMap[username].profileURL) {
|
|
|
|
|
let url = this.whoMap[username].profileURL;
|
|
|
|
|
if (url.match(/^https?:/i)) {
|
|
|
|
|
return url;
|
|
|
|
|
} else if (url.indexOf("/") === 0) {
|
|
|
|
|
// Subdirectory relative to our WebsiteURL
|
|
|
|
|
return this.config.website.replace(/\/+$/, "") + url;
|
|
|
|
|
} else {
|
|
|
|
|
this.ChatClient("Didn't know how to open profile URL: " + url);
|
|
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
2023-04-19 05:18:12 +00:00
|
|
|
|
nicknameForUsername(username) {
|
|
|
|
|
if (!username) return;
|
|
|
|
|
username = username.replace(/^@/, "");
|
|
|
|
|
if (this.whoMap[username] != undefined && this.whoMap[username].profileURL) {
|
|
|
|
|
let nick = this.whoMap[username].nickname;
|
|
|
|
|
if (nick) {
|
|
|
|
|
return nick;
|
|
|
|
|
}
|
2023-06-12 03:33:26 +00:00
|
|
|
|
} else if (this.whoMap[username] == undefined && username !== 'ChatServer' && username !== 'ChatClient') {
|
|
|
|
|
// User is not even logged in! Add this note to their name
|
|
|
|
|
username += " (offline)";
|
2023-04-19 05:18:12 +00:00
|
|
|
|
}
|
|
|
|
|
return username;
|
|
|
|
|
},
|
2023-08-29 00:49:50 +00:00
|
|
|
|
isUsernameDND(username) {
|
|
|
|
|
if (!username) return false;
|
|
|
|
|
return this.whoMap[username] != undefined && this.whoMap[username].dnd;
|
|
|
|
|
},
|
2023-08-09 00:51:52 +00:00
|
|
|
|
isUsernameCamNSFW(username) {
|
|
|
|
|
// returns true if the username is broadcasting and NSFW, false otherwise.
|
|
|
|
|
// (used for the color coding of their nickname on their video box - so assumed they are broadcasting)
|
|
|
|
|
if (this.whoMap[username] != undefined && this.whoMap[username].video & this.VideoFlag.NSFW) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2023-02-05 08:53:50 +00:00
|
|
|
|
leaveDM() {
|
|
|
|
|
// Validate we're in a DM currently.
|
|
|
|
|
if (this.channel.indexOf("@") !== 0) return;
|
|
|
|
|
|
|
|
|
|
if (!window.confirm(
|
|
|
|
|
"Do you want to close this chat thread? Your conversation history will " +
|
|
|
|
|
"be forgotten on your computer, but your chat partner may still have " +
|
|
|
|
|
"your chat thread open on their end."
|
|
|
|
|
)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let channel = this.channel;
|
|
|
|
|
this.setChannel(this.config.channels[0].ID);
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.channels[channel]);
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-24 20:08:15 +00:00
|
|
|
|
/* Take back messages (for everyone) or remove locally */
|
|
|
|
|
takeback(msg) {
|
|
|
|
|
if (!window.confirm(
|
|
|
|
|
"Do you want to take this message back? Doing so will remove this message from everybody's view in the chat room."
|
|
|
|
|
)) return;
|
|
|
|
|
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "takeback",
|
|
|
|
|
msgID: msg.msgID,
|
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
removeMessage(msg) {
|
|
|
|
|
if (!window.confirm(
|
|
|
|
|
"Do you want to remove this message from your view? This will delete the message only for you, but others in this chat thread may still see it."
|
|
|
|
|
)) return;
|
|
|
|
|
|
|
|
|
|
this.onTakeback({
|
|
|
|
|
msgID: msg.msgID,
|
2023-09-07 06:03:12 +00:00
|
|
|
|
});
|
2023-06-24 20:08:15 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-07-01 03:00:21 +00:00
|
|
|
|
/* message reaction emojis */
|
|
|
|
|
hasReactions(msg) {
|
|
|
|
|
return this.messageReactions[msg.msgID] != undefined;
|
|
|
|
|
},
|
|
|
|
|
getReactions(msg) {
|
|
|
|
|
if (!this.hasReactions(msg)) return [];
|
|
|
|
|
return this.messageReactions[msg.msgID];
|
|
|
|
|
},
|
2023-07-01 18:39:08 +00:00
|
|
|
|
iReacted(msg, emoji) {
|
|
|
|
|
// test whether the current user has reacted
|
|
|
|
|
if (this.messageReactions[msg.msgID] != undefined && this.messageReactions[msg.msgID][emoji] != undefined) {
|
|
|
|
|
for (let reactor of this.messageReactions[msg.msgID][emoji]) {
|
|
|
|
|
if (reactor === this.username) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2023-07-01 03:00:21 +00:00
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
activeChannels() {
|
|
|
|
|
// List of current channels, unread indicators etc.
|
|
|
|
|
let result = [];
|
|
|
|
|
for (let channel of this.config.channels) {
|
2023-09-03 19:48:21 +00:00
|
|
|
|
// VIP room we can't see?
|
|
|
|
|
if (channel.VIP && !this.isVIP) continue;
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
let data = {
|
|
|
|
|
ID: channel.ID,
|
|
|
|
|
Name: channel.Name,
|
|
|
|
|
};
|
|
|
|
|
if (this.channels[channel] != undefined) {
|
|
|
|
|
data.Unread = this.channels[channel].unread;
|
|
|
|
|
data.Updated = this.channels[channel].updated;
|
|
|
|
|
}
|
|
|
|
|
result.push(data);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Start broadcasting my webcam.
|
2023-07-09 19:33:02 +00:00
|
|
|
|
// - force=true to skip the NSFW modal prompt (this param is passed by the button in that modal)
|
|
|
|
|
// - changeCamera=true to re-negotiate WebRTC connections with a new camera device (invoked by the Settings modal)
|
2023-09-07 06:03:12 +00:00
|
|
|
|
startVideo({ force = false, changeCamera = false }) {
|
2023-01-27 04:34:58 +00:00
|
|
|
|
if (this.webcam.busy) return;
|
|
|
|
|
|
2023-08-18 02:15:26 +00:00
|
|
|
|
// Before they go on cam the first time, ATTEMPT to get their device names.
|
|
|
|
|
// - If they had never granted permission, we won't get the names of
|
|
|
|
|
// the devices and no big deal.
|
|
|
|
|
// - If they had given permission before, we can present a nicer experience
|
|
|
|
|
// for them and enumerate their devices before they go on originally.
|
2023-08-18 02:36:33 +00:00
|
|
|
|
if (!changeCamera && !force) {
|
2023-08-18 02:15:26 +00:00
|
|
|
|
// Initial broadcast: did they select device IDs?
|
|
|
|
|
this.getDevices();
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 06:46:39 +00:00
|
|
|
|
// If we are running in PermitNSFW mode, show the user the modal.
|
|
|
|
|
if (this.config.permitNSFW && !force) {
|
|
|
|
|
this.nsfwModalCast.visible = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-09 19:33:02 +00:00
|
|
|
|
let mediaParams = {
|
2023-01-27 04:34:58 +00:00
|
|
|
|
audio: true,
|
2023-07-09 19:33:02 +00:00
|
|
|
|
video: {
|
2023-08-29 00:49:50 +00:00
|
|
|
|
width: { max: 640 },
|
|
|
|
|
height: { max: 480 },
|
2023-07-09 19:33:02 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-18 02:15:26 +00:00
|
|
|
|
// Name the specific devices chosen by the user.
|
|
|
|
|
if (this.webcam.videoDeviceID) {
|
2023-07-09 19:33:02 +00:00
|
|
|
|
mediaParams.video.deviceId = { exact: this.webcam.videoDeviceID };
|
2023-08-18 02:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
if (this.webcam.audioDeviceID) {
|
2023-07-09 19:33:02 +00:00
|
|
|
|
mediaParams.audio = {
|
|
|
|
|
deviceId: { exact: this.webcam.audioDeviceID },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.webcam.busy = true;
|
|
|
|
|
navigator.mediaDevices.getUserMedia(mediaParams).then(stream => {
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.webcam.active = true;
|
|
|
|
|
this.webcam.elem.srcObject = stream;
|
|
|
|
|
this.webcam.stream = stream;
|
|
|
|
|
|
2023-04-01 03:25:53 +00:00
|
|
|
|
// Save our mutuality prefs.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
LocalStorage.set('videoMutual', this.webcam.mutual);
|
|
|
|
|
LocalStorage.set('videoMutualOpen', this.webcam.mutualOpen);
|
|
|
|
|
LocalStorage.set('videoAutoMute', this.webcam.autoMute);
|
|
|
|
|
LocalStorage.set('videoVipOnly', this.webcam.vipOnly);
|
2023-08-12 01:56:22 +00:00
|
|
|
|
|
|
|
|
|
// Auto-mute our camera? Two use cases:
|
|
|
|
|
// 1. The user marked their cam as muted but then changed video device,
|
|
|
|
|
// so we set the mute to match their preference as shown on their UI.
|
|
|
|
|
// 2. The user opted to auto-mute their camera from the get to on their
|
|
|
|
|
// NSFW broadcast modal popup.
|
|
|
|
|
if (this.webcam.muted || this.webcam.autoMute) {
|
|
|
|
|
// Mute their audio tracks.
|
|
|
|
|
this.webcam.stream.getAudioTracks().forEach(track => {
|
|
|
|
|
track.enabled = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Set their front-end mute toggle to match (in case of autoMute).
|
|
|
|
|
this.webcam.muted = true;
|
|
|
|
|
}
|
2023-04-01 03:25:53 +00:00
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Tell backend the camera is ready.
|
|
|
|
|
this.sendMe();
|
2023-04-19 05:18:12 +00:00
|
|
|
|
|
|
|
|
|
// Record the selected device IDs.
|
|
|
|
|
this.webcam.videoDeviceID = stream.getVideoTracks()[0].getSettings().deviceId;
|
|
|
|
|
this.webcam.audioDeviceID = stream.getAudioTracks()[0].getSettings().deviceId;
|
|
|
|
|
|
|
|
|
|
// Collect video and audio devices to let the user change them in their settings.
|
2023-08-19 01:54:45 +00:00
|
|
|
|
this.getDevices().then(() => {
|
|
|
|
|
// Store their names on localStorage in case we can reselect them by name
|
|
|
|
|
// on the user's next visit.
|
|
|
|
|
this.storePreferredDeviceNames();
|
|
|
|
|
});
|
2023-07-09 19:33:02 +00:00
|
|
|
|
|
|
|
|
|
// If we have changed devices, reconnect everybody's WebRTC channels for your existing watchers.
|
|
|
|
|
if (changeCamera) {
|
|
|
|
|
this.updateWebRTCStreams();
|
|
|
|
|
}
|
2023-01-27 04:34:58 +00:00
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.ChatClient(`Webcam error: ${err}`);
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.webcam.busy = false;
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-04-19 05:18:12 +00:00
|
|
|
|
getDevices() {
|
|
|
|
|
// Collect video and audio devices.
|
|
|
|
|
if (!navigator.mediaDevices?.enumerateDevices) {
|
|
|
|
|
console.log("enumerateDevices() not supported.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-18 01:45:43 +00:00
|
|
|
|
this.webcam.gettingDevices = true;
|
|
|
|
|
|
2023-08-19 01:54:45 +00:00
|
|
|
|
return navigator.mediaDevices.enumerateDevices().then(devices => {
|
2023-04-19 05:18:12 +00:00
|
|
|
|
this.webcam.videoDevices = [];
|
|
|
|
|
this.webcam.audioDevices = [];
|
|
|
|
|
devices.forEach(device => {
|
2023-08-18 02:15:26 +00:00
|
|
|
|
// If we can't get the device label, disregard it.
|
|
|
|
|
// It can happen if the user has not yet granted permission.
|
2023-08-18 02:36:33 +00:00
|
|
|
|
if (!device.label) {
|
|
|
|
|
return;
|
|
|
|
|
};
|
2023-08-18 02:15:26 +00:00
|
|
|
|
|
2023-04-19 05:18:12 +00:00
|
|
|
|
if (device.kind === 'videoinput') {
|
2023-07-09 19:33:02 +00:00
|
|
|
|
// console.log(`Video device ${device.deviceId} ${device.label}`);
|
2023-04-19 05:18:12 +00:00
|
|
|
|
this.webcam.videoDevices.push({
|
|
|
|
|
id: device.deviceId,
|
|
|
|
|
label: device.label,
|
|
|
|
|
});
|
|
|
|
|
} else if (device.kind === 'audioinput') {
|
2023-07-09 19:33:02 +00:00
|
|
|
|
// console.log(`Audio device ${device.deviceId} ${device.label}`);
|
2023-04-19 05:18:12 +00:00
|
|
|
|
this.webcam.audioDevices.push({
|
|
|
|
|
id: device.deviceId,
|
|
|
|
|
label: device.label,
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-08-19 01:54:45 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// If we don't have the user's current active device IDs (e.g., they have
|
|
|
|
|
// not yet started their video the first time), see if we can pre-select
|
|
|
|
|
// by their preferred device names.
|
|
|
|
|
if (!this.webcam.videoDeviceID && this.webcam.preferredDeviceNames.video) {
|
|
|
|
|
for (let dev of this.webcam.videoDevices) {
|
|
|
|
|
if (dev.label === this.webcam.preferredDeviceNames.video) {
|
|
|
|
|
this.webcam.videoDeviceID = dev.id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!this.webcam.audioDeviceID && this.webcam.preferredDeviceNames.audio) {
|
|
|
|
|
for (let dev of this.webcam.audioDevices) {
|
|
|
|
|
if (dev.label === this.webcam.preferredDeviceNames.audio) {
|
|
|
|
|
this.webcam.audioDeviceID = dev.id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-19 05:18:12 +00:00
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.ChatClient(`Error listing your cameras and microphones: ${err.name}: ${err.message}`);
|
2023-08-18 01:45:43 +00:00
|
|
|
|
}).finally(() => {
|
|
|
|
|
// In the settings modal, let the spinner spin for a moment.
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.webcam.gettingDevices = false;
|
|
|
|
|
}, 500);
|
2023-04-19 05:18:12 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
2023-08-19 01:54:45 +00:00
|
|
|
|
storePreferredDeviceNames() {
|
|
|
|
|
// This function looks up the names of the user's selected video/audio device.
|
|
|
|
|
// When they come back later, IF we are able to enumerate devices before they
|
|
|
|
|
// go on for the first time, we might pre-select their last device by name.
|
|
|
|
|
// NOTE: on iOS apparently device IDs shuffle every single time so only names
|
|
|
|
|
// may be reliable!
|
|
|
|
|
if (this.webcam.videoDeviceID) {
|
|
|
|
|
for (let dev of this.webcam.videoDevices) {
|
|
|
|
|
if (dev.id === this.webcam.videoDeviceID && dev.label) {
|
|
|
|
|
this.webcam.preferredDeviceNames.video = dev.label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.webcam.audioDeviceID) {
|
|
|
|
|
for (let dev of this.webcam.audioDevices) {
|
|
|
|
|
if (dev.id === this.webcam.audioDeviceID && dev.label) {
|
|
|
|
|
this.webcam.preferredDeviceNames.audio = dev.label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Put them on localStorage.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
LocalStorage.set('preferredDeviceNames', this.webcam.preferredDeviceNames);
|
2023-08-19 01:54:45 +00:00
|
|
|
|
},
|
2023-01-27 04:34:58 +00:00
|
|
|
|
|
2023-07-09 19:33:02 +00:00
|
|
|
|
// Replace your video/audio streams for your watchers (on camera changes)
|
|
|
|
|
updateWebRTCStreams() {
|
|
|
|
|
console.log("Re-negotiating video and audio channels to your watchers.");
|
|
|
|
|
for (let username of Object.keys(this.WebRTC.pc)) {
|
|
|
|
|
let pc = this.WebRTC.pc[username];
|
|
|
|
|
if (pc.answerer != undefined) {
|
|
|
|
|
let oldTracks = pc.answerer.getSenders();
|
|
|
|
|
let newTracks = this.webcam.stream.getTracks();
|
|
|
|
|
|
|
|
|
|
// Remove and replace the tracks.
|
|
|
|
|
for (let old of oldTracks) {
|
|
|
|
|
if (old.track.kind === 'audio') {
|
|
|
|
|
for (let replace of newTracks) {
|
|
|
|
|
if (replace.kind === 'audio') {
|
|
|
|
|
old.replaceTrack(replace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (old.track.kind === 'video') {
|
|
|
|
|
for (let replace of newTracks) {
|
|
|
|
|
if (replace.kind === 'video') {
|
|
|
|
|
old.replaceTrack(replace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
// Begin connecting to someone else's webcam.
|
2023-08-09 00:51:52 +00:00
|
|
|
|
openVideoByUsername(username, force) {
|
|
|
|
|
if (this.whoMap[username] != undefined) {
|
|
|
|
|
this.openVideo(this.whoMap[username], force);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.ChatClient("Couldn't open video by username: not found.");
|
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
setSkipNSFWModal() {
|
|
|
|
|
// Set the "don't show again" on NSFW modal.
|
|
|
|
|
LocalStorage.set("skip-nsfw-modal", true);
|
|
|
|
|
},
|
2023-02-11 06:46:39 +00:00
|
|
|
|
openVideo(user, force) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
// Close the NSFW warning modal if it was open.
|
|
|
|
|
this.nsfwModalView.visible = false;
|
|
|
|
|
|
2023-01-27 06:54:02 +00:00
|
|
|
|
if (user.username === this.username) {
|
|
|
|
|
this.ChatClient("You can already see your own webcam.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 04:06:57 +00:00
|
|
|
|
// If we have muted the target, we shouldn't view their video.
|
|
|
|
|
if (this.isMutedUser(user.username)) {
|
|
|
|
|
this.ChatClient(`You have muted <strong>${user.username}</strong> and so should not see their camera.`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 06:46:39 +00:00
|
|
|
|
// Is the target user NSFW? Go thru the modal.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
let dontShowAgain = LocalStorage.get("skip-nsfw-modal") === true;
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if ((user.video & this.VideoFlag.NSFW) && !dontShowAgain && !force) {
|
2023-02-11 06:46:39 +00:00
|
|
|
|
this.nsfwModalView.user = user;
|
|
|
|
|
this.nsfwModalView.visible = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-09 00:55:22 +00:00
|
|
|
|
// Debounce so we don't spam too much for the same user.
|
|
|
|
|
if (this.WebRTC.debounceOpens[user.username]) return;
|
|
|
|
|
this.WebRTC.debounceOpens[user.username] = true;
|
|
|
|
|
setTimeout(() => {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.WebRTC.debounceOpens[user.username]);
|
2023-08-09 00:55:22 +00:00
|
|
|
|
}, 5000);
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Camera is already open? Then disconnect the connection.
|
2023-02-06 23:02:23 +00:00
|
|
|
|
if (this.WebRTC.pc[user.username] != undefined && this.WebRTC.pc[user.username].offerer != undefined) {
|
|
|
|
|
this.closeVideo(user.username, "offerer");
|
2023-02-05 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 02:46:42 +00:00
|
|
|
|
// If this user requests mutual viewership...
|
2023-09-03 19:36:15 +00:00
|
|
|
|
if (this.isVideoNotAllowed(user)) {
|
2023-04-01 02:46:42 +00:00
|
|
|
|
this.ChatClient(
|
|
|
|
|
`<strong>${user.username}</strong> has requested that you should share your own camera too before opening theirs.`
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// Set a timeout: the video icon becomes a spinner and we wait a while
|
|
|
|
|
// to see if the connection went thru. This gives the user feedback and we
|
|
|
|
|
// can avoid a spammy 'ChatClient' notification message.
|
|
|
|
|
if (this.WebRTC.openTimeouts[user.username] != undefined) {
|
|
|
|
|
clearTimeout(this.WebRTC.openTimeouts[user.username]);
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.WebRTC.openTimeouts[user.username]);
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
this.WebRTC.openTimeouts[user.username] = setTimeout(() => {
|
2023-09-01 00:18:18 +00:00
|
|
|
|
// It timed out. If they are on an iPad, offer additional hints on
|
|
|
|
|
// how to have better luck connecting their cameras.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (isAppleWebkit()) {
|
2023-09-01 00:18:18 +00:00
|
|
|
|
this.ChatClient(
|
|
|
|
|
`There was an error opening <strong>${user.username}</strong>'s camera.<br><br>` +
|
|
|
|
|
"<strong>Advice:</strong> You appear to be on an iPad-style browser. Webcam sharing " +
|
2023-09-07 06:03:12 +00:00
|
|
|
|
"may be limited and only work if:<br>A) You are sharing your own camera first, and<br>B) " +
|
2023-09-01 00:18:18 +00:00
|
|
|
|
"The person you view has the setting to auto-open your camera in return.<br>Best of luck!",
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
this.ChatClient(
|
|
|
|
|
`There was an error opening <strong>${user.username}</strong>'s camera.`,
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.WebRTC.openTimeouts[user.username]);
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
|
|
// Send the ChatServer 'open' command.
|
2023-01-27 06:54:02 +00:00
|
|
|
|
this.sendOpen(user.username);
|
2023-02-06 04:26:00 +00:00
|
|
|
|
|
|
|
|
|
// Responsive CSS -> go to chat panel to see the camera
|
|
|
|
|
this.openChatPanel();
|
2023-01-27 06:54:02 +00:00
|
|
|
|
},
|
2023-02-06 23:02:23 +00:00
|
|
|
|
closeVideo(username, name) {
|
2023-08-09 02:09:49 +00:00
|
|
|
|
// Clean up any lingering camera freeze states.
|
|
|
|
|
delete (this.WebRTC.frozenStreamDetected[username]);
|
|
|
|
|
if (this.WebRTC.frozenStreamInterval[username]) {
|
|
|
|
|
clearInterval(this.WebRTC.frozenStreamInterval);
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.WebRTC.frozenStreamInterval[username]);
|
2023-08-09 02:09:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 23:02:23 +00:00
|
|
|
|
if (name === "offerer") {
|
|
|
|
|
// We are closing another user's video stream.
|
|
|
|
|
delete (this.WebRTC.streams[username]);
|
2023-07-01 01:41:06 +00:00
|
|
|
|
delete (this.WebRTC.muted[username]);
|
|
|
|
|
delete (this.WebRTC.poppedOut[username]);
|
2023-02-06 23:02:23 +00:00
|
|
|
|
if (this.WebRTC.pc[username] != undefined && this.WebRTC.pc[username].offerer != undefined) {
|
|
|
|
|
this.WebRTC.pc[username].offerer.close();
|
|
|
|
|
delete (this.WebRTC.pc[username]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Inform backend we have closed it.
|
|
|
|
|
this.sendWatch(username, false);
|
|
|
|
|
return;
|
|
|
|
|
} else if (name === "answerer") {
|
|
|
|
|
// We have turned off our camera, kick off viewers.
|
|
|
|
|
if (this.WebRTC.pc[username] != undefined && this.WebRTC.pc[username].answerer != undefined) {
|
|
|
|
|
this.WebRTC.pc[username].answerer.close();
|
|
|
|
|
delete (this.WebRTC.pc[username]);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// A user has logged off the server. Clean up any WebRTC connections.
|
|
|
|
|
delete (this.WebRTC.streams[username]);
|
2023-02-06 04:26:00 +00:00
|
|
|
|
delete (this.webcam.watching[username]);
|
2023-02-05 08:53:50 +00:00
|
|
|
|
if (this.WebRTC.pc[username] != undefined) {
|
2023-02-06 23:02:23 +00:00
|
|
|
|
if (this.WebRTC.pc[username].offerer) {
|
|
|
|
|
this.WebRTC.pc[username].offerer.close();
|
|
|
|
|
}
|
|
|
|
|
if (this.WebRTC.pc[username].answerer) {
|
|
|
|
|
this.WebRTC.pc[username].answerer.close();
|
|
|
|
|
}
|
2023-02-05 08:53:50 +00:00
|
|
|
|
delete (this.WebRTC.pc[username]);
|
2023-07-01 01:41:06 +00:00
|
|
|
|
delete (this.WebRTC.muted[username]);
|
|
|
|
|
delete (this.WebRTC.poppedOut[username]);
|
2023-02-05 08:53:50 +00:00
|
|
|
|
}
|
2023-02-06 04:26:00 +00:00
|
|
|
|
|
2023-08-09 00:51:52 +00:00
|
|
|
|
// Clean up any lingering camera freeze states.
|
|
|
|
|
delete (this.WebRTC.frozenStreamDetected[username]);
|
|
|
|
|
if (this.WebRTC.frozenStreamInterval[username]) {
|
|
|
|
|
clearInterval(this.WebRTC.frozenStreamInterval);
|
2023-09-07 06:03:12 +00:00
|
|
|
|
delete (this.WebRTC.frozenStreamInterval[username]);
|
2023-08-09 00:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 04:26:00 +00:00
|
|
|
|
// Inform backend we have closed it.
|
|
|
|
|
this.sendWatch(username, false);
|
|
|
|
|
},
|
2023-04-01 02:46:42 +00:00
|
|
|
|
unMutualVideo() {
|
|
|
|
|
// If we had our camera on to watch a video of someone who wants mutual cameras,
|
|
|
|
|
// and then we turn ours off: we should unfollow the ones with mutual video.
|
2023-08-12 01:58:05 +00:00
|
|
|
|
if (this.webcam.active) return;
|
2023-04-01 02:46:42 +00:00
|
|
|
|
for (let row of this.whoList) {
|
|
|
|
|
let username = row.username;
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if ((row.video & this.VideoFlag.MutualRequired) && this.WebRTC.pc[username] != undefined) {
|
2023-04-01 02:46:42 +00:00
|
|
|
|
this.closeVideo(username);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-07-01 01:41:06 +00:00
|
|
|
|
webcamIconClass(user) {
|
|
|
|
|
// Return the icon to show on a video button.
|
|
|
|
|
// - Usually a video icon
|
|
|
|
|
// - May be a crossed-out video if isVideoNotAllowed
|
|
|
|
|
// - Or an eyeball for cameras already opened
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// - Or a spinner if we are actively trying to open the video
|
2023-09-01 00:18:18 +00:00
|
|
|
|
|
|
|
|
|
// Current user sees their own self camera always.
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if (user.username === this.username && this.webcam.active) {
|
2023-09-01 00:18:18 +00:00
|
|
|
|
return 'fa-eye';
|
2023-07-01 01:41:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// In spinner mode? (Trying to open the video)
|
|
|
|
|
if (this.WebRTC.openTimeouts[user.username] != undefined) {
|
|
|
|
|
return 'fa-spinner fa-spin';
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-01 01:41:06 +00:00
|
|
|
|
// Already opened?
|
|
|
|
|
if (this.WebRTC.pc[user.username] != undefined && this.WebRTC.streams[user.username] != undefined) {
|
|
|
|
|
return 'fa-eye';
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 00:18:18 +00:00
|
|
|
|
// iPad test: they will have very limited luck opening videos unless
|
|
|
|
|
// A) the iPad camera is already on, and
|
|
|
|
|
// B) the person they want to watch has mutual auto-open enabled.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
if (isAppleWebkit()) {
|
2023-09-01 00:18:18 +00:00
|
|
|
|
if (!this.webcam.active) {
|
|
|
|
|
return 'fa-video-slash'; // can not open any cam w/o local video on
|
|
|
|
|
}
|
|
|
|
|
if (!(this.whoMap[user.username].video & this.VideoFlag.MutualOpen)) {
|
|
|
|
|
// the user must have mutual auto-open on: the iPad has to offer
|
|
|
|
|
// their video which will force open their cam on the other side,
|
|
|
|
|
// and this is only if the user expects it.
|
|
|
|
|
return 'fa-video-slash';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-01 01:41:06 +00:00
|
|
|
|
if (this.isVideoNotAllowed(user)) return 'fa-video-slash';
|
|
|
|
|
return 'fa-video';
|
|
|
|
|
},
|
2023-06-15 04:06:57 +00:00
|
|
|
|
isVideoNotAllowed(user) {
|
|
|
|
|
// Returns whether the video button to open a user's cam will be not allowed (crossed out)
|
|
|
|
|
|
|
|
|
|
// Mutual video sharing is required on this camera, and ours is not active
|
2023-09-03 19:36:15 +00:00
|
|
|
|
if ((user.video & this.VideoFlag.Active) && (user.video & this.VideoFlag.MutualRequired)) {
|
|
|
|
|
// A nuance to the mutual video required: if we DO have our cam on, but ours is VIP only, and the
|
|
|
|
|
// user we want to watch can't see that our cam is on, then honor their wishes.
|
|
|
|
|
if (this.webcam.active && this.isVIP && this.webcam.vipOnly && this.whoMap[user.username] != undefined && !this.whoMap[user.username].vip) {
|
|
|
|
|
// Our cam is active, but the non-VIP user won't see it on, so they won't expect
|
|
|
|
|
// us to be able to open their camera.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.webcam.active) {
|
|
|
|
|
// Our cam is not broadcasting, but they requested it should be: not allowed.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-06-15 04:06:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We have muted them and it wouldn't be appropriate to still watch their video but not get their messages.
|
|
|
|
|
if (this.isMutedUser(user.username)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2023-02-06 04:26:00 +00:00
|
|
|
|
|
2023-08-13 06:09:46 +00:00
|
|
|
|
// Show who watches our video.
|
|
|
|
|
showViewers() {
|
|
|
|
|
// TODO: for now, ChatClient is our bro.
|
|
|
|
|
let users = Object.keys(this.webcam.watching);
|
|
|
|
|
if (users.length === 0) {
|
|
|
|
|
this.ChatClient("There is currently nobody viewing your camera.");
|
|
|
|
|
} else {
|
|
|
|
|
this.ChatClient("Your current webcam viewers are:<br><br>" + users.join(", "));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Also focus the Watching list.
|
|
|
|
|
this.whoTab = 'watching';
|
|
|
|
|
|
|
|
|
|
// TODO: if mobile, show the panel - this width matches
|
|
|
|
|
// the media query in chat.css
|
|
|
|
|
if (screen.width < 1024) {
|
|
|
|
|
this.openWhoPanel();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Boot someone off your video.
|
2023-03-23 03:21:04 +00:00
|
|
|
|
bootUser(username) {
|
|
|
|
|
if (!window.confirm(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
`Kick ${username} off your camera? This will also prevent them ` +
|
|
|
|
|
`from seeing that your camera is active for the remainder of your ` +
|
2023-03-23 03:21:04 +00:00
|
|
|
|
`chat session.`)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.sendBoot(username);
|
2023-08-05 02:24:42 +00:00
|
|
|
|
this.WebRTC.booted[username] = true;
|
2023-03-23 03:21:04 +00:00
|
|
|
|
|
|
|
|
|
// Close the WebRTC peer connection.
|
|
|
|
|
if (this.WebRTC.pc[username] != undefined) {
|
|
|
|
|
this.closeVideo(username, "answerer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ChatClient(
|
2023-09-07 06:03:12 +00:00
|
|
|
|
`You have booted ${username} off your camera. They will no longer be able ` +
|
|
|
|
|
`to connect to your camera, or even see that your camera is active at all -- ` +
|
|
|
|
|
`to them it appears as though you had turned yours off.<br><br>This will be ` +
|
2023-03-23 03:21:04 +00:00
|
|
|
|
`in place for the remainder of your current chat session.`
|
|
|
|
|
);
|
2023-02-05 08:53:50 +00:00
|
|
|
|
},
|
2023-08-05 02:24:42 +00:00
|
|
|
|
isBootedAdmin(username) {
|
|
|
|
|
return (this.WebRTC.booted[username] === true || this.muted[username] === true) &&
|
|
|
|
|
this.whoMap[username] != undefined &&
|
|
|
|
|
this.whoMap[username].op;
|
|
|
|
|
},
|
2023-01-27 06:54:02 +00:00
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Stop broadcasting.
|
|
|
|
|
stopVideo() {
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Close all WebRTC sessions.
|
|
|
|
|
for (username of Object.keys(this.WebRTC.pc)) {
|
2023-02-06 23:02:23 +00:00
|
|
|
|
this.closeVideo(username, "answerer");
|
2023-02-05 08:53:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 02:46:42 +00:00
|
|
|
|
// Hang up on mutual cameras.
|
|
|
|
|
this.unMutualVideo();
|
|
|
|
|
|
2023-07-08 19:08:46 +00:00
|
|
|
|
// Close the local camera devices completely.
|
|
|
|
|
this.webcam.stream.getTracks().forEach(track => {
|
|
|
|
|
track.stop();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Reset all front-end state.
|
|
|
|
|
this.webcam.elem.srcObject = null;
|
|
|
|
|
this.webcam.stream = null;
|
|
|
|
|
this.webcam.active = false;
|
|
|
|
|
this.webcam.muted = false;
|
|
|
|
|
this.whoTab = "online";
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Tell backend our camera state.
|
|
|
|
|
this.sendMe();
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-06 04:26:00 +00:00
|
|
|
|
// Mute my microphone if broadcasting.
|
|
|
|
|
muteMe() {
|
|
|
|
|
this.webcam.muted = !this.webcam.muted;
|
|
|
|
|
this.webcam.stream.getAudioTracks().forEach(track => {
|
|
|
|
|
track.enabled = !this.webcam.muted;
|
|
|
|
|
});
|
2023-07-01 01:41:06 +00:00
|
|
|
|
|
|
|
|
|
// Communicate our local mute to others.
|
|
|
|
|
this.sendMe();
|
|
|
|
|
},
|
|
|
|
|
isSourceMuted(username) {
|
|
|
|
|
// See if the webcam broadcaster muted their mic at the source
|
|
|
|
|
if (this.whoMap[username] != undefined && this.whoMap[username].video & this.VideoFlag.Muted) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2023-02-06 04:26:00 +00:00
|
|
|
|
},
|
|
|
|
|
isMuted(username) {
|
|
|
|
|
return this.WebRTC.muted[username] === true;
|
|
|
|
|
},
|
|
|
|
|
muteVideo(username) {
|
|
|
|
|
this.WebRTC.muted[username] = !this.isMuted(username);
|
|
|
|
|
|
|
|
|
|
// Find the <video> tag to mute it.
|
|
|
|
|
let $ref = document.getElementById(`videofeed-${username}`);
|
|
|
|
|
if ($ref) {
|
|
|
|
|
$ref.muted = this.WebRTC.muted[username];
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2023-04-20 05:00:31 +00:00
|
|
|
|
// Pop out a user's video.
|
|
|
|
|
popoutVideo(username) {
|
|
|
|
|
this.WebRTC.poppedOut[username] = !this.WebRTC.poppedOut[username];
|
|
|
|
|
|
|
|
|
|
// If not popped out, reset CSS positioning.
|
|
|
|
|
window.requestAnimationFrame(this.makeDraggableVideos);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Outside of Vue, attach draggable video scripts to DOM.
|
|
|
|
|
makeDraggableVideos() {
|
|
|
|
|
let $panel = document.querySelector("#video-feeds");
|
|
|
|
|
|
|
|
|
|
interact('.popped-in').unset();
|
|
|
|
|
|
|
|
|
|
// Give popped out videos to the root of the DOM so they can
|
|
|
|
|
// be dragged anywhere on the page.
|
|
|
|
|
window.requestAnimationFrame(() => {
|
|
|
|
|
document.querySelectorAll('.popped-out').forEach(node => {
|
|
|
|
|
// $panel.removeChild(node);
|
|
|
|
|
document.body.appendChild(node);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('.popped-in').forEach(node => {
|
|
|
|
|
// document.body.removeChild(node);
|
|
|
|
|
$panel.appendChild(node);
|
|
|
|
|
node.style.top = null;
|
|
|
|
|
node.style.left = null;
|
|
|
|
|
node.setAttribute('data-x', 0);
|
|
|
|
|
node.setAttribute('data-y', 0);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interact('.popped-out').draggable({
|
|
|
|
|
// enable inertial throwing
|
|
|
|
|
inertia: true,
|
|
|
|
|
// keep the element within the area of it's parent
|
|
|
|
|
modifiers: [
|
2023-09-07 06:03:12 +00:00
|
|
|
|
interact.modifiers.restrictRect({
|
|
|
|
|
restriction: 'parent',
|
|
|
|
|
endOnly: true
|
|
|
|
|
})
|
2023-04-20 05:00:31 +00:00
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
listeners: {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
// call this function on every dragmove event
|
|
|
|
|
move(event) {
|
|
|
|
|
let target = event.target;
|
|
|
|
|
let x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
|
|
|
|
|
let y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy
|
|
|
|
|
|
|
|
|
|
target.style.top = `${y}px`;
|
|
|
|
|
target.style.left = `${x}px`;
|
|
|
|
|
|
|
|
|
|
target.setAttribute('data-x', x);
|
|
|
|
|
target.setAttribute('data-y', y);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// call this function on every dragend event
|
|
|
|
|
end(event) {
|
|
|
|
|
console.log(
|
|
|
|
|
'moved a distance of ' +
|
|
|
|
|
(Math.sqrt(Math.pow(event.pageX - event.x0, 2) +
|
2023-04-20 05:00:31 +00:00
|
|
|
|
Math.pow(event.pageY - event.y0, 2) | 0))
|
2023-09-07 06:03:12 +00:00
|
|
|
|
.toFixed(2) + 'px')
|
|
|
|
|
}
|
2023-04-20 05:00:31 +00:00
|
|
|
|
}
|
|
|
|
|
}).resizable({
|
|
|
|
|
edges: { left: true, right: true, bottom: true, right: true },
|
|
|
|
|
listeners: {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
move(event) {
|
|
|
|
|
var target = event.target
|
|
|
|
|
var x = (parseFloat(target.getAttribute('data-x')) || 0)
|
|
|
|
|
var y = (parseFloat(target.getAttribute('data-y')) || 0)
|
2023-04-20 05:00:31 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
// update the element's style
|
|
|
|
|
target.style.width = event.rect.width + 'px'
|
|
|
|
|
target.style.height = event.rect.height + 'px'
|
2023-04-20 05:00:31 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
// translate when resizing from top or left edges
|
|
|
|
|
x += event.deltaRect.left
|
|
|
|
|
y += event.deltaRect.top
|
2023-04-20 05:00:31 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
target.style.top = `${y}px`;
|
|
|
|
|
target.style.left = `${x}px`;
|
2023-04-20 05:00:31 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
target.setAttribute('data-x', x)
|
|
|
|
|
target.setAttribute('data-y', y)
|
2023-04-20 05:00:31 +00:00
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
},
|
|
|
|
|
modifiers: [
|
2023-04-20 05:00:31 +00:00
|
|
|
|
// keep the edges inside the parent
|
|
|
|
|
interact.modifiers.restrictEdges({
|
2023-09-07 06:03:12 +00:00
|
|
|
|
outer: 'parent'
|
2023-04-20 05:00:31 +00:00
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
// minimum size
|
|
|
|
|
interact.modifiers.restrictSize({
|
2023-09-07 06:03:12 +00:00
|
|
|
|
min: { width: 100, height: 50 }
|
2023-04-20 05:00:31 +00:00
|
|
|
|
})
|
2023-09-07 06:03:12 +00:00
|
|
|
|
],
|
2023-04-20 05:00:31 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
inertia: true
|
2023-04-20 05:00:31 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
initHistory(channel) {
|
|
|
|
|
if (this.channels[channel] == undefined) {
|
|
|
|
|
this.channels[channel] = {
|
|
|
|
|
history: [],
|
|
|
|
|
updated: Date.now(),
|
|
|
|
|
unread: 0,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-24 20:08:15 +00:00
|
|
|
|
pushHistory({ channel, username, message, action = "message", isChatServer, isChatClient, messageID }) {
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Default channel = your current channel.
|
|
|
|
|
if (!channel) {
|
|
|
|
|
channel = this.channel;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 05:46:40 +00:00
|
|
|
|
// Are we ignoring DMs?
|
|
|
|
|
if (this.prefs.closeDMs && channel.indexOf('@') === 0) {
|
|
|
|
|
// Don't allow an (incoming) DM to initialize a new chat room for us.
|
2023-08-29 00:56:43 +00:00
|
|
|
|
// Unless the user is an operator.
|
|
|
|
|
let isSenderOp = this.whoMap[username] != undefined && this.whoMap[username].op;
|
|
|
|
|
if (username !== this.username && this.channels[channel] == undefined && !isSenderOp) return;
|
2023-08-29 05:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Initialize this channel's history?
|
|
|
|
|
this.initHistory(channel);
|
|
|
|
|
|
2023-08-15 02:59:35 +00:00
|
|
|
|
// Image handling per the user's preference.
|
|
|
|
|
if (message.indexOf("<img") > -1) {
|
|
|
|
|
if (this.imageDisplaySetting === "hide") {
|
|
|
|
|
return;
|
|
|
|
|
} else if (this.imageDisplaySetting === "collapse") {
|
|
|
|
|
// Put a collapser link.
|
|
|
|
|
let collapseID = `collapse-${messageID}`;
|
|
|
|
|
message = `
|
|
|
|
|
<a href="#" id="img-show-${collapseID}"
|
|
|
|
|
class="button is-outlined is-small is-info"
|
|
|
|
|
onclick="document.querySelector('#img-${collapseID}').style.display = 'block';
|
|
|
|
|
document.querySelector('#img-show-${collapseID}').style.display = 'none';
|
|
|
|
|
return false">
|
|
|
|
|
<i class="fa fa-image mr-1"></i>
|
|
|
|
|
Image attachment - click to expand
|
|
|
|
|
</a>
|
|
|
|
|
<div id="img-${collapseID}" style="display: none">${message}</div>`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Append the message.
|
2023-07-23 01:30:45 +00:00
|
|
|
|
this.channels[channel].updated = new Date().getTime();
|
2023-02-05 08:53:50 +00:00
|
|
|
|
this.channels[channel].history.push({
|
2023-01-27 04:34:58 +00:00
|
|
|
|
action: action,
|
2023-08-13 04:35:41 +00:00
|
|
|
|
channel: channel,
|
2023-01-11 06:38:48 +00:00
|
|
|
|
username: username,
|
|
|
|
|
message: message,
|
2023-06-24 20:08:15 +00:00
|
|
|
|
msgID: messageID,
|
2023-02-10 07:03:06 +00:00
|
|
|
|
at: new Date(),
|
2023-01-27 04:34:58 +00:00
|
|
|
|
isChatServer,
|
|
|
|
|
isChatClient,
|
2023-01-11 06:38:48 +00:00
|
|
|
|
});
|
2023-07-23 01:30:45 +00:00
|
|
|
|
|
|
|
|
|
// Trim the history per the scrollback buffer.
|
|
|
|
|
if (this.scrollback > 0 && this.channels[channel].history.length > this.scrollback) {
|
|
|
|
|
this.channels[channel].history = this.channels[channel].history.slice(
|
|
|
|
|
-this.scrollback,
|
2023-09-07 06:03:12 +00:00
|
|
|
|
this.channels[channel].history.length + 1,
|
2023-07-23 01:30:45 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-24 18:12:02 +00:00
|
|
|
|
this.scrollHistory(channel);
|
2023-02-05 08:53:50 +00:00
|
|
|
|
|
|
|
|
|
// Mark unread notifiers if this is not our channel.
|
|
|
|
|
if (this.channel !== channel) {
|
2023-02-06 01:42:09 +00:00
|
|
|
|
// Don't notify about presence broadcasts.
|
2023-03-17 02:02:59 +00:00
|
|
|
|
if (action !== "presence" && !isChatServer) {
|
2023-02-06 01:42:09 +00:00
|
|
|
|
this.channels[channel].unread++;
|
|
|
|
|
}
|
2023-02-05 08:53:50 +00:00
|
|
|
|
}
|
2023-02-12 00:02:48 +00:00
|
|
|
|
|
|
|
|
|
// Edit hyperlinks to open in a new window.
|
|
|
|
|
this.makeLinksExternal();
|
2023-01-27 04:34:58 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-24 18:12:02 +00:00
|
|
|
|
scrollHistory(channel, force) {
|
|
|
|
|
if (!this.autoscroll && !force) return;
|
2023-03-25 04:56:40 +00:00
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
window.requestAnimationFrame(() => {
|
2023-06-24 18:12:02 +00:00
|
|
|
|
// Only scroll if it's the current channel.
|
|
|
|
|
if (channel !== this.channel) return;
|
|
|
|
|
|
2023-09-07 00:15:02 +00:00
|
|
|
|
if (this.historyScrollbox === null) return;
|
2023-01-27 04:34:58 +00:00
|
|
|
|
this.historyScrollbox.scroll({
|
|
|
|
|
top: this.historyScrollbox.scrollHeight,
|
|
|
|
|
behavior: 'smooth',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-05 08:53:50 +00:00
|
|
|
|
// Responsive CSS controls for mobile. Notes for maintenance:
|
|
|
|
|
// - The chat.css has responsive CSS to hide the left/right panels
|
|
|
|
|
// and set the grid-template-columns for devices < 1024px width
|
|
|
|
|
// - These functions override w/ style tags to force the drawer to
|
|
|
|
|
// be visible and change the grid-template-columns.
|
|
|
|
|
// - On window resize (e.g. device rotation) or when closing one
|
|
|
|
|
// of the side drawers, we reset our CSS overrides to default so
|
|
|
|
|
// the main chat window reappears.
|
|
|
|
|
openChannelsPanel() {
|
|
|
|
|
// Open the left drawer
|
|
|
|
|
let $container = this.responsive.nodes.$container,
|
|
|
|
|
$drawer = this.responsive.nodes.$left;
|
|
|
|
|
|
|
|
|
|
$container.style.gridTemplateColumns = "1fr 0 0";
|
|
|
|
|
$drawer.style.display = "block";
|
|
|
|
|
},
|
|
|
|
|
openWhoPanel() {
|
|
|
|
|
// Open the right drawer
|
|
|
|
|
let $container = this.responsive.nodes.$container,
|
|
|
|
|
$drawer = this.responsive.nodes.$right;
|
|
|
|
|
|
|
|
|
|
$container.style.gridTemplateColumns = "0 0 1fr";
|
|
|
|
|
$drawer.style.display = "block";
|
|
|
|
|
},
|
|
|
|
|
openChatPanel() {
|
|
|
|
|
this.resetResponsiveCSS();
|
|
|
|
|
},
|
|
|
|
|
resetResponsiveCSS() {
|
|
|
|
|
let $container = this.responsive.nodes.$container,
|
|
|
|
|
$left = this.responsive.nodes.$left,
|
|
|
|
|
$right = this.responsive.nodes.$right;
|
|
|
|
|
|
|
|
|
|
$left.style.removeProperty("display");
|
|
|
|
|
$right.style.removeProperty("display");
|
|
|
|
|
$container.style.removeProperty("grid-template-columns");
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-27 04:34:58 +00:00
|
|
|
|
// Send a chat message as ChatServer
|
|
|
|
|
ChatServer(message) {
|
|
|
|
|
this.pushHistory({
|
|
|
|
|
username: "ChatServer",
|
|
|
|
|
message: message,
|
|
|
|
|
isChatServer: true,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
ChatClient(message) {
|
|
|
|
|
this.pushHistory({
|
|
|
|
|
username: "ChatClient",
|
|
|
|
|
message: message,
|
|
|
|
|
isChatClient: true,
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-02-06 21:27:29 +00:00
|
|
|
|
|
|
|
|
|
// Format a datetime nicely for chat timestamp.
|
|
|
|
|
prettyDate(date) {
|
2023-08-13 04:35:41 +00:00
|
|
|
|
if (date == undefined) return '';
|
2023-02-06 21:27:29 +00:00
|
|
|
|
let hours = date.getHours(),
|
|
|
|
|
minutes = String(date.getMinutes()).padStart(2, '0'),
|
|
|
|
|
ampm = hours >= 11 ? "pm" : "am";
|
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
let hour = hours % 12 || 12;
|
2023-04-19 05:34:45 +00:00
|
|
|
|
return `${(hour)}:${minutes} ${ampm}`;
|
2023-02-06 21:27:29 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-08-06 02:38:04 +00:00
|
|
|
|
// CSS classes for the profile button (color coded genders)
|
|
|
|
|
profileButtonClass(user) {
|
2023-09-03 19:08:23 +00:00
|
|
|
|
// VIP background.
|
|
|
|
|
let result = "";
|
|
|
|
|
if (user.vip) {
|
|
|
|
|
result = "has-background-vip ";
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-06 02:38:04 +00:00
|
|
|
|
let gender = (user.gender || "").toLowerCase();
|
|
|
|
|
if (gender.indexOf("m") === 0) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
return result + "has-text-gender-male";
|
2023-08-06 02:38:04 +00:00
|
|
|
|
} else if (gender.indexOf("f") === 0) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
return result + "has-text-gender-female";
|
2023-08-06 02:38:04 +00:00
|
|
|
|
} else if (gender.length > 0) {
|
2023-09-07 06:03:12 +00:00
|
|
|
|
return result + "has-text-gender-other";
|
2023-08-06 02:38:04 +00:00
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
},
|
|
|
|
|
|
2023-03-22 04:29:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* Image sharing in chat
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// The image upload button handler.
|
|
|
|
|
uploadFile() {
|
|
|
|
|
let input = document.createElement('input');
|
|
|
|
|
input.type = 'file';
|
|
|
|
|
input.accept = 'image/*';
|
|
|
|
|
input.onchange = e => {
|
|
|
|
|
let file = e.target.files[0];
|
|
|
|
|
if (file.size > FileUploadMaxSize) {
|
|
|
|
|
this.ChatClient(`Please share an image smaller than ${FileUploadMaxSize / 1024 / 1024} MB in size!`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ChatClient(`<em>Uploading file to chat: ${file.name} - ${file.size} bytes, ${file.type} format.</em>`);
|
|
|
|
|
|
|
|
|
|
// Get image file data.
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
let rawData = new ArrayBuffer();
|
|
|
|
|
reader.onload = e => {
|
|
|
|
|
rawData = e.target.result;
|
|
|
|
|
|
|
|
|
|
let fileByteArray = [],
|
|
|
|
|
u8array = new Uint8Array(rawData);
|
|
|
|
|
for (let i = 0; i < u8array.length; i++) {
|
|
|
|
|
fileByteArray.push(u8array[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let msg = JSON.stringify({
|
|
|
|
|
action: "file",
|
|
|
|
|
channel: this.channel,
|
|
|
|
|
message: file.name,
|
|
|
|
|
bytes: fileByteArray, //btoa(fileByteArray),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Send it to the chat server.
|
|
|
|
|
this.ws.conn.send(msg);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reader.readAsArrayBuffer(file);
|
|
|
|
|
};
|
|
|
|
|
input.click();
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-06 21:27:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* Sound effect concerns.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
setupSounds() {
|
2023-06-12 02:21:06 +00:00
|
|
|
|
// Note: setupSounds had to be called on a page gesture (mouse click) before browsers
|
|
|
|
|
// allow it to set up the AudioContext. If we've successfully set one up before, exit
|
|
|
|
|
// this function immediately.
|
|
|
|
|
if (this.config.sounds.audioContext) {
|
2023-06-12 03:33:26 +00:00
|
|
|
|
if (this.config.sounds.audioContext.state === 'suspended') {
|
|
|
|
|
this.config.sounds.audioContext.resume();
|
|
|
|
|
}
|
2023-06-12 02:21:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-09 05:23:08 +00:00
|
|
|
|
try {
|
|
|
|
|
if (AudioContext) {
|
|
|
|
|
this.config.sounds.audioContext = new AudioContext();
|
|
|
|
|
} else {
|
|
|
|
|
this.config.sounds.audioContext = window.AudioContext || window.webkitAudioContext;
|
|
|
|
|
}
|
2023-09-07 06:03:12 +00:00
|
|
|
|
} catch { }
|
2023-02-09 05:23:08 +00:00
|
|
|
|
|
2023-02-06 21:27:29 +00:00
|
|
|
|
if (!this.config.sounds.audioContext) {
|
|
|
|
|
console.error("Couldn't set up AudioContext! No sound effects will be supported.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create <audio> elements for all the sounds.
|
|
|
|
|
for (let effect of this.config.sounds.available) {
|
|
|
|
|
if (!effect.filename) continue; // 'Quiet' has no audio
|
|
|
|
|
|
|
|
|
|
let elem = document.createElement("audio");
|
|
|
|
|
elem.autoplay = false;
|
|
|
|
|
elem.src = `/static/sfx/${effect.filename}`;
|
|
|
|
|
document.body.appendChild(elem);
|
|
|
|
|
|
|
|
|
|
let track = this.config.sounds.audioContext.createMediaElementSource(elem);
|
|
|
|
|
track.connect(this.config.sounds.audioContext.destination);
|
|
|
|
|
this.config.sounds.audioTracks[effect.name] = elem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Apply the user's saved preferences if any.
|
|
|
|
|
for (let setting of Object.keys(this.config.sounds.settings)) {
|
|
|
|
|
if (localStorage[`sound:${setting}`] != undefined) {
|
|
|
|
|
this.config.sounds.settings[setting] = localStorage[`sound:${setting}`];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
playSound(event) {
|
2023-09-02 00:11:17 +00:00
|
|
|
|
// Muting all SFX?
|
|
|
|
|
if (this.prefs.muteSounds) return;
|
2023-02-06 21:27:29 +00:00
|
|
|
|
let filename = this.config.sounds.settings[event];
|
|
|
|
|
// Do we have an audio track?
|
|
|
|
|
if (this.config.sounds.audioTracks[filename] != undefined) {
|
|
|
|
|
let track = this.config.sounds.audioTracks[filename];
|
|
|
|
|
track.play();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setSoundPref(event) {
|
|
|
|
|
this.playSound(event);
|
|
|
|
|
|
|
|
|
|
// Store the user's setting in localStorage.
|
|
|
|
|
localStorage[`sound:${event}`] = this.config.sounds.settings[event];
|
|
|
|
|
},
|
2023-02-12 00:02:48 +00:00
|
|
|
|
|
2023-03-28 04:13:04 +00:00
|
|
|
|
// Make all links in chat open in new windows
|
2023-02-12 00:02:48 +00:00
|
|
|
|
makeLinksExternal() {
|
|
|
|
|
window.requestAnimationFrame(() => {
|
|
|
|
|
let $history = document.querySelector("#chatHistory");
|
2023-09-07 00:15:02 +00:00
|
|
|
|
if ($history === null) return;
|
|
|
|
|
|
2023-02-12 00:02:48 +00:00
|
|
|
|
// Make all <a> links appearing in chat into external links.
|
|
|
|
|
($history.querySelectorAll("a") || []).forEach(node => {
|
|
|
|
|
let href = node.attributes.href,
|
|
|
|
|
target = node.attributes.target;
|
|
|
|
|
if (href == undefined || target != undefined) return;
|
|
|
|
|
node.target = "_blank";
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-03-28 04:13:04 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Idle Detection methods
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
setupIdleDetection() {
|
|
|
|
|
window.addEventListener("keypress", this.deidle);
|
|
|
|
|
window.addEventListener("mousemove", this.deidle);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Common "de-idle" event handler
|
|
|
|
|
deidle(e) {
|
|
|
|
|
if (this.status === "idle") {
|
|
|
|
|
this.status = "online";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.idleTimeout !== null) {
|
|
|
|
|
clearTimeout(this.idleTimeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.idleTimeout = setTimeout(this.goIdle, 1000 * this.idleThreshold);
|
|
|
|
|
},
|
|
|
|
|
goIdle() {
|
|
|
|
|
// only if we aren't already set on away
|
|
|
|
|
if (this.status === "online") {
|
|
|
|
|
this.status = "idle";
|
|
|
|
|
}
|
2023-08-13 04:35:41 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Webhook methods
|
|
|
|
|
*/
|
|
|
|
|
isWebhookEnabled(name) {
|
|
|
|
|
for (let webhook of this.config.webhookURLs) {
|
|
|
|
|
if (webhook.Name === name && webhook.Enabled) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reportMessage(message) {
|
|
|
|
|
// User is reporting a message on chat.
|
|
|
|
|
if (message.reported) {
|
|
|
|
|
if (!window.confirm("You have already reported this message. Do you want to report it again?")) return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
// Clone the user object.
|
|
|
|
|
let user = {
|
|
|
|
|
avatar: this.avatarForUsername(message.username),
|
|
|
|
|
nickname: this.nicknameForUsername(message.username),
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-13 04:35:41 +00:00
|
|
|
|
// Clone the message.
|
|
|
|
|
let clone = Object.assign({}, message);
|
|
|
|
|
|
|
|
|
|
// Sub out attached images.
|
|
|
|
|
clone.message = clone.message.replace(/<img .+?>/g, "[inline image]");
|
|
|
|
|
|
|
|
|
|
this.reportModal.message = clone;
|
2023-09-07 06:03:12 +00:00
|
|
|
|
this.reportModal.user = user;
|
2023-08-13 04:35:41 +00:00
|
|
|
|
this.reportModal.origMessage = message;
|
|
|
|
|
this.reportModal.visible = true;
|
|
|
|
|
},
|
2023-09-07 06:03:12 +00:00
|
|
|
|
doReport({ classification, comment }) {
|
2023-08-13 04:35:41 +00:00
|
|
|
|
// Submit the queued up report.
|
|
|
|
|
if (this.reportModal.busy) return;
|
|
|
|
|
this.reportModal.busy = true;
|
|
|
|
|
|
|
|
|
|
let msg = this.reportModal.message;
|
|
|
|
|
|
|
|
|
|
this.ws.conn.send(JSON.stringify({
|
|
|
|
|
action: "report",
|
|
|
|
|
channel: msg.channel,
|
|
|
|
|
username: msg.username,
|
2023-09-07 06:03:12 +00:00
|
|
|
|
timestamp: "" + msg.at,
|
|
|
|
|
reason: classification,
|
2023-08-13 04:35:41 +00:00
|
|
|
|
message: msg.message,
|
2023-09-07 06:03:12 +00:00
|
|
|
|
comment: comment,
|
2023-08-13 04:35:41 +00:00
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
this.reportModal.busy = false;
|
|
|
|
|
this.reportModal.visible = false;
|
|
|
|
|
|
|
|
|
|
// Set the "reported" flag.
|
|
|
|
|
this.reportModal.origMessage.reported = true;
|
|
|
|
|
},
|
2023-01-11 06:38:48 +00:00
|
|
|
|
}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<!-- Sign In modal -->
|
|
|
|
|
<LoginModal :visible="loginModal.visible" @sign-in="signIn"></LoginModal>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<!-- Settings modal -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="modal" :class="{ 'is-active': settingsModal.visible }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<div class="modal-background"></div>
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<header class="card-header has-background-info">
|
|
|
|
|
<p class="card-header-title has-text-light">Chat Settings</p>
|
|
|
|
|
</header>
|
|
|
|
|
<div class="card-content">
|
|
|
|
|
|
|
|
|
|
<!-- Tab bar for the settings -->
|
|
|
|
|
<div class="tabs">
|
|
|
|
|
<ul>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li :class="{ 'is-active': settingsModal.tab === 'prefs' }">
|
|
|
|
|
<a href="#" @click.prevent="settingsModal.tab = 'prefs'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Display
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li :class="{ 'is-active': settingsModal.tab === 'sounds' }">
|
|
|
|
|
<a href="#" @click.prevent="settingsModal.tab = 'sounds'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Sounds
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li :class="{ 'is-active': settingsModal.tab === 'webcam' }">
|
|
|
|
|
<a href="#" @click.prevent="settingsModal.tab = 'webcam'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Camera
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li :class="{ 'is-active': settingsModal.tab === 'misc' }">
|
|
|
|
|
<a href="#" @click.prevent="settingsModal.tab = 'misc'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Misc
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Display preferences -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div v-if="settingsModal.tab === 'prefs'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<div class="field is-horizontal">
|
|
|
|
|
<div class="field-label is-normal">
|
|
|
|
|
<label class="label">Video size</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="field-body">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="control">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="webcam.videoScale">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in webcam.videoScaleOptions" v-bind:key="s[0]"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:value="s[0]">
|
|
|
|
|
{{ s[1] }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field is-horizontal">
|
|
|
|
|
<div class="field-label is-normal">
|
|
|
|
|
<label class="label">Text size</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="field-body">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="control">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="fontSizeClass">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.fontSizeClasses" v-bind:key="s[0]" :value="s[0]">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ s[1] }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field is-horizontal">
|
|
|
|
|
<div class="field-label is-normal">
|
|
|
|
|
<label class="label">Images</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="field-body">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="control">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="imageDisplaySetting">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.imageDisplaySettings" v-bind:key="s[0]"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:value="s[0]">
|
|
|
|
|
{{ s[1] }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label class="label">Scrollback buffer</label>
|
|
|
|
|
<div class="control">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="number" class="input" v-model="scrollback" min="0" inputmode="numeric">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
<p class="help">
|
|
|
|
|
How many chat history messages to keep at once (per channel/DM thread).
|
|
|
|
|
Older messages will be removed so your web browser doesn't run low on memory.
|
|
|
|
|
A value of zero (0) will mean "unlimited" and the chat history is never trimmed.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Sound settings -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div v-else-if="settingsModal.tab === 'sounds'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<div class="mb-4">
|
|
|
|
|
<label class="checkbox">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="prefs.muteSounds" :value="true">
|
|
|
|
|
Mute all sound effects
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<div class="column is-2 pr-1">
|
|
|
|
|
<label class="label is-size-7">DM chat</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="config.sounds.settings.DM" @change="setSoundPref('DM')">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.sounds.available" v-bind:key="s.name" :value="s.name">
|
|
|
|
|
{{ s.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column is-2 pr-1">
|
|
|
|
|
<label class="label is-size-7">Public chat</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="config.sounds.settings.Chat" @change="setSoundPref('Chat')">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.sounds.available" v-bind:key="s.name" :value="s.name">
|
|
|
|
|
{{ s.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<div class="column is-2 pr-1">
|
|
|
|
|
<label class="label is-size-7">Room enter</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="config.sounds.settings.Enter" @change="setSoundPref('Enter')">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.sounds.available" v-bind:key="s.name" :value="s.name">
|
|
|
|
|
{{ s.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column is-2 pr-1">
|
|
|
|
|
<label class="label is-size-7">Room leave</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="config.sounds.settings.Leave" @change="setSoundPref('Leave')">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.sounds.available" v-bind:key="s.name" :value="s.name">
|
|
|
|
|
{{ s.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<div class="column is-2 pr-1">
|
|
|
|
|
<label class="label is-size-7">Watched</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="config.sounds.settings.Watch" @change="setSoundPref('Watch')">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.sounds.available" v-bind:key="s.name" :value="s.name">
|
|
|
|
|
{{ s.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column is-2 pr-1">
|
|
|
|
|
<label class="label is-size-7">Unwatched</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="config.sounds.settings.Unwatch" @change="setSoundPref('Unwatch')">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="s in config.sounds.available" v-bind:key="s.name" :value="s.name">
|
|
|
|
|
{{ s.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Webcam preferences -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div v-if="settingsModal.tab === 'webcam'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<h3 class="subtitle mb-2">
|
|
|
|
|
Camera Settings
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
<p class="block mb-1 is-size-7">
|
|
|
|
|
The settings on this tab will be relevant only when you are already
|
|
|
|
|
broadcasting your camera. They allow you to modify your broadcast settings
|
|
|
|
|
while you are already live (for example, to change your mutual camera
|
|
|
|
|
preference or select another audio/video device to broadcast from).
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p class="block mb-1" v-if="config.permitNSFW">
|
|
|
|
|
<label class="label">Explicit</label>
|
|
|
|
|
</p>
|
|
|
|
|
<div class="field" v-if="config.permitNSFW">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<label class="checkbox" :class="{ 'cursor-notallowed': !webcam.active }">
|
|
|
|
|
<input type="checkbox" v-model="webcam.nsfw" :disabled="!webcam.active">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Mark my camera as featuring explicit content
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p class="block mb-1">
|
|
|
|
|
<label class="label">Mutual webcam options</label>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div class="field mb-1">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<label class="checkbox" :class="{ 'cursor-notallowed': !webcam.active }">
|
|
|
|
|
<input type="checkbox" v-model="webcam.mutual" :disabled="!webcam.active">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
People must be sharing their own camera before they can open mine
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field mb-1">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<label class="checkbox" :class="{ 'cursor-notallowed': !webcam.active }">
|
|
|
|
|
<input type="checkbox" v-model="webcam.mutualOpen" :disabled="!webcam.active">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
When someone opens my camera, I also open their camera automatically
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field" v-if="isVIP">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<label class="checkbox" :class="{ 'cursor-notallowed': !webcam.active }">
|
|
|
|
|
<input type="checkbox" v-model="webcam.vipOnly" :disabled="!webcam.active">
|
|
|
|
|
Only <span v-html="config.VIP.Branding"></span> <sup class="is-size-7"
|
|
|
|
|
:class="config.VIP.Icon"></sup>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
members can see that my camera is broadcasting
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h3 class="subtitle mb-2" v-if="webcam.videoDevices.length > 0 || webcam.audioDevices.length > 0">
|
|
|
|
|
Webcam Devices
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-primary is-small is-outlined ml-2" @click="getDevices()"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Refresh list of devices">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<i class="fa fa-arrows-rotate" :class="{ 'fa-spin': webcam.gettingDevices }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</i>
|
|
|
|
|
</button>
|
|
|
|
|
</h3>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="columns is-mobile"
|
|
|
|
|
v-if="webcam.videoDevices.length > 0 || webcam.audioDevices.length > 0">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
|
<label class="label">Video source</label>
|
|
|
|
|
<div class="select is-fullwidth">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<select v-model="webcam.videoDeviceID"
|
|
|
|
|
@change="startVideo({ changeCamera: true, force: true })">
|
|
|
|
|
<option v-for="(d, i) in webcam.videoDevices" :value="d.id">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ d.label || `Camera ${i}` }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
|
<label class="label">Audio source</label>
|
|
|
|
|
<div class="select is-fullwidth">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<select v-model="webcam.audioDeviceID"
|
|
|
|
|
@change="startVideo({ changeCamera: true, force: true })">
|
|
|
|
|
<option v-for="(d, i) in webcam.audioDevices" :value="d.id">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ d.label || `Microphone ${i}` }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Misc preferences -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div v-if="settingsModal.tab === 'misc'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<div class="field">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<label class="label">Presence messages <small>('has joined the room')</small> in public
|
|
|
|
|
channels</label>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<div class="columns is-mobile mb-0">
|
|
|
|
|
<div class="column py-1">
|
|
|
|
|
<label class="checkbox" title="Show 'has joined the room' messages in public channels">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="prefs.joinMessages" :value="true">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Join room
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column py-1">
|
|
|
|
|
<label class="checkbox" title="Show 'has exited the room' messages in public channels">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="prefs.exitMessages" :value="true">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Exit room
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label class="label mb-0">Server notification messages</label>
|
|
|
|
|
<label class="checkbox" title="Show 'has joined the room' messages in public channels">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="prefs.watchNotif" :value="true">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Notify when somebody opens my camera
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label class="label mb-0">Direct Messages</label>
|
|
|
|
|
<label class="checkbox">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="prefs.closeDMs" :value="true">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Ignore unsolicited DMs from others
|
|
|
|
|
</label>
|
|
|
|
|
<p class="help">
|
|
|
|
|
If you check this box, other chatters may not initiate DMs with you: their messages
|
|
|
|
|
will be (silently) ignored. You may still initiate DM chats with others, unless they
|
|
|
|
|
also have closed their DMs with this setting.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<footer class="card-footer">
|
|
|
|
|
<div class="card-footer-item">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-primary" @click="hideSettings()">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Close
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</footer>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- NSFW Modal: before user activates their webcam -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="modal" :class="{ 'is-active': nsfwModalCast.visible }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<div class="modal-background"></div>
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<header class="card-header has-background-info">
|
|
|
|
|
<p class="card-header-title has-text-light">Broadcast my webcam</p>
|
|
|
|
|
</header>
|
|
|
|
|
<div class="card-content">
|
|
|
|
|
<p class="block mb-1">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
You can turn on your webcam and enable others in the room to connect to yours.
|
|
|
|
|
The controls to <i class="fa fa-stop has-text-danger"></i> stop and <i
|
|
|
|
|
class="fa fa-microphone-slash has-text-danger"></i> mute audio
|
|
|
|
|
will be at the top of the page.
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label class="checkbox">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="webcam.autoMute">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Start with my microphone on mute by default
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p class="block mb-1">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
If your camera will be featuring "<abbr title="Not Safe For Work">Explicit</abbr>" or sexual
|
|
|
|
|
content, please
|
|
|
|
|
mark it as such by clicking on the "<small><i class="fa fa-fire mr-1 has-text-danger"></i>
|
|
|
|
|
Explicit</small>"
|
|
|
|
|
button at the top of the page, or check the box below to start with it enabled.
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label class="checkbox">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="webcam.nsfw">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Check this box if your webcam will <em>definitely</em> be Explicit. 😈
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p class="block mb-1">
|
|
|
|
|
<label class="label">Mutual webcam options:</label>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div class="field mb-1">
|
|
|
|
|
<label class="checkbox">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="webcam.mutual">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
People must be sharing their own camera before they can open mine
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label class="checkbox">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="webcam.mutualOpen">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
When someone opens my camera, I also open their camera automatically
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field" v-if="isVIP">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<label class="checkbox" :class="{ 'cursor-notallowed': !webcam.active }">
|
|
|
|
|
<input type="checkbox" v-model="webcam.vipOnly">
|
|
|
|
|
Only <span v-html="config.VIP.Branding"></span> <sup class="is-size-7"
|
|
|
|
|
:class="config.VIP.Icon"></sup>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
members can see that my camera is broadcasting
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Device Pickers: just in case the user had granted video permission in the past,
|
|
|
|
|
and we are able to enumerate their device names, we can show them here before they
|
|
|
|
|
go on this time.-->
|
|
|
|
|
<div class="columns is-mobile" v-if="webcam.videoDevices.length > 0 || webcam.audioDevices.length > 0">
|
|
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
|
<label class="label">Video source</label>
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="webcam.videoDeviceID">
|
|
|
|
|
<option :value="null" disabled selected>Select default camera</option>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="(d, i) in webcam.videoDevices" :value="d.id">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ d.label || `Camera ${i}` }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
|
<label class="label">Audio source</label>
|
|
|
|
|
<div class="select is-fullwidth">
|
|
|
|
|
<select v-model="webcam.audioDeviceID">
|
|
|
|
|
<option :value="null" disabled selected>Select default microphone</option>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option v-for="(d, i) in webcam.audioDevices" :value="d.id">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ d.label || `Microphone ${i}` }}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="control has-text-centered">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-link mr-4"
|
|
|
|
|
@click="startVideo({ force: true }); nsfwModalCast.visible = false">Start webcam</button>
|
|
|
|
|
<button type="button" class="button" @click="nsfwModalCast.visible = false">Cancel</button>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- NSFW Modal: before user views a NSFW camera the first time -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<ExplicitOpenModal :visible="nsfwModalView.visible"
|
|
|
|
|
:user="nsfwModalView.user"
|
|
|
|
|
@accept="openVideo(nsfwModalView.user, true)"
|
|
|
|
|
@cancel="nsfwModalView.visible=false"
|
|
|
|
|
@dont-show-again="setSkipNSFWModal()"></ExplicitOpenModal>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<!-- Report Modal -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<ReportModal :visible="reportModal.visible"
|
|
|
|
|
:busy="reportModal.busy"
|
|
|
|
|
:user="reportModal.user"
|
|
|
|
|
:message="reportModal.message"
|
|
|
|
|
@accept="doReport"
|
|
|
|
|
@cancel="reportModal.visible=false"></ReportModal>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<div class="chat-container">
|
|
|
|
|
|
|
|
|
|
<!-- Top header panel -->
|
|
|
|
|
<header class="chat-header">
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<div class="column is-narrow pr-1">
|
|
|
|
|
<strong class="is-6"><span v-html="config.branding"></span></strong>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column px-1">
|
|
|
|
|
<!-- Stop/Start video buttons -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active" class="button is-small is-danger px-1" @click="stopVideo()">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-stop mr-2"></i>
|
|
|
|
|
Stop
|
|
|
|
|
</button>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-else class="button is-small is-success px-1" @click="startVideo({})"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:disabled="webcam.busy">
|
|
|
|
|
<i class="fa fa-video mr-2"></i>
|
|
|
|
|
Share webcam
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Mute/Unmute my mic buttons (if streaming)-->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active && !webcam.muted" class="button is-small is-success ml-1 px-1"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="muteMe()">
|
|
|
|
|
<i class="fa fa-microphone mr-2"></i>
|
|
|
|
|
Mute
|
|
|
|
|
</button>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active && webcam.muted" class="button is-small is-danger ml-1 px-1"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="muteMe()">
|
|
|
|
|
<i class="fa fa-microphone-slash mr-2"></i>
|
|
|
|
|
Unmute
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Watchers button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active" class="button is-small is-info is-outlined ml-1 px-1"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="showViewers()">
|
|
|
|
|
<i class="fa fa-eye mr-2"></i>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
{{ Object.keys(webcam.watching).length }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- NSFW toggle button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active && config.permitNSFW" class="button is-small px-1 ml-1"
|
|
|
|
|
:class="{
|
|
|
|
|
'is-outlined is-dark': !webcam.nsfw,
|
|
|
|
|
'is-danger': webcam.nsfw
|
|
|
|
|
}" @click.prevent="webcam.nsfw = !webcam.nsfw; sendMe()"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Toggle the NSFW setting for your camera broadcast">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<i class="fa fa-fire mr-1" :class="{ 'has-text-danger': !webcam.nsfw }"></i> Explicit
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column is-narrow pl-1">
|
|
|
|
|
<a href="/about" target="_blank" class="button is-small is-link px-2">
|
|
|
|
|
<i class="fa fa-info-circle"></i>
|
|
|
|
|
</a>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-small is-light ml-1 px-2" @click="showSettings()"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Chat Settings">
|
|
|
|
|
<i class="fa fa-gear"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<!-- Left Column: Channels & DMs -->
|
|
|
|
|
<div class="left-column">
|
|
|
|
|
<div class="card grid-card">
|
|
|
|
|
<header class="card-header has-background-success-dark">
|
|
|
|
|
<div class="columns is-mobile card-header-title has-text-light">
|
|
|
|
|
<div class="column is-narrow mobile-only">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-success px-2" @click="openChatPanel">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-arrow-left"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">Channels</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
<div class="card-content">
|
|
|
|
|
<aside class="menu">
|
|
|
|
|
<p class="menu-label">
|
|
|
|
|
Chat Rooms
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<ul class="menu-list">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li v-for="c in activeChannels()" v-bind:key="c.ID">
|
|
|
|
|
<a :href="'#' + c.ID" @click.prevent="setChannel(c)" :class="{ 'is-active': c.ID == channel }">
|
|
|
|
|
{{ c.Name }}
|
|
|
|
|
<span v-if="hasUnread(c.ID)" class="tag is-success">
|
|
|
|
|
{{ hasUnread(c.ID) }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<p class="menu-label">
|
|
|
|
|
Private Messages
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<ul class="menu-list">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li v-for="c in activeDMs" v-bind:key="c.channel">
|
|
|
|
|
<a :href="'#' + c.channel" @click.prevent="setChannel(c.channel)"
|
|
|
|
|
:class="{ 'is-active': c.channel == channel }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<!-- Avatar URL if available (copied from Who List) -->
|
|
|
|
|
<div class="column is-narrow pr-0" style="position: relative">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<img v-if="avatarForUsername(normalizeUsername(c.channel))"
|
|
|
|
|
:src="avatarForUsername(normalizeUsername(c.channel))" width="24"
|
|
|
|
|
height="24" alt="">
|
|
|
|
|
<img v-else src="/static/img/shy.png" width="24" height="24">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
{{ c.name }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<span v-if="hasUnread(c.channel)" class="tag is-danger">
|
|
|
|
|
{{ hasUnread(c.channel) }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Middle Column: Chat Room/History -->
|
|
|
|
|
<div class="chat-column">
|
|
|
|
|
|
|
|
|
|
<div class="card grid-card">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<header class="card-header" :class="{ 'has-background-private': isDM, 'has-background-link': !isDM }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<div class="columns is-mobile card-header-title has-text-light">
|
|
|
|
|
<div class="column is-narrow mobile-only pr-0">
|
|
|
|
|
<!-- Responsive mobile button to pan to Left Column -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-success px-2" @click="openChannelsPanel">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i v-if="isDM" class="fa fa-arrow-left"></i>
|
|
|
|
|
<i v-else class="fa fa-comments"></i>
|
|
|
|
|
|
|
|
|
|
<!-- Indicator badge for unread messages -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<span v-if="hasAnyUnread() > 0" class="tag ml-1" :class="{ 'is-danger': anyUnreadDMs() }">
|
|
|
|
|
{{ hasAnyUnread() }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
{{ channelName }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div class="column is-narrow">
|
|
|
|
|
<!-- If a DM thread and the user has a profile URL -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="channel.indexOf('@') === 0 && profileURLForUsername(channel)"
|
|
|
|
|
class="button is-small is-outlined is-light mr-1" @click="openProfile({ username: channel })">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-user"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- DMs: Leave convo button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="channel.indexOf('@') === 0"
|
|
|
|
|
class="float-right button is-small is-warning is-outlined" @click="leaveDM()">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Who List button, only shown on public channel view -->
|
|
|
|
|
<div v-if="!isDM" class="column is-narrow mobile-only">
|
|
|
|
|
<!-- Responsive mobile button to pan to Right Column -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-success px-2" @click="openWhoPanel">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-user-group"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div id="video-feeds" class="video-feeds" :class="webcam.videoScale"
|
|
|
|
|
v-show="webcam.active || Object.keys(WebRTC.streams).length > 0">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<!-- Video Feeds-->
|
|
|
|
|
|
|
|
|
|
<!-- My video -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="feed" v-show="webcam.active" :class="{
|
|
|
|
|
'popped-out': WebRTC.poppedOut[username],
|
|
|
|
|
'popped-in': !WebRTC.poppedOut[username]
|
|
|
|
|
}">
|
|
|
|
|
<video class="feed" id="localVideo" autoplay muted>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</video>
|
|
|
|
|
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="caption" :class="{
|
|
|
|
|
'has-text-camera-blue': !webcam.nsfw,
|
|
|
|
|
'has-text-camera-red': webcam.nsfw
|
|
|
|
|
}">
|
|
|
|
|
<i class="fa fa-microphone-slash mr-1 has-text-grey" v-if="webcam.muted"></i>
|
|
|
|
|
{{ username }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="controls">
|
|
|
|
|
<!-- MY Mute button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active && !webcam.muted"
|
|
|
|
|
class="button is-small is-success is-outlined ml-1 px-2" @click="muteMe()">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-microphone"></i>
|
|
|
|
|
</button>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="webcam.active && webcam.muted"
|
|
|
|
|
class="button is-small is-danger ml-1 px-2" @click="muteMe()">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-microphone-slash"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Pop-out MY video -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-small is-light is-outlined p-2 ml-2" title="Pop out"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="popoutVideo(username)">
|
|
|
|
|
<i class="fa fa-up-right-from-square"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Others' videos -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="feed" v-for="(stream, username) in WebRTC.streams" v-bind:key="username" :class="{
|
|
|
|
|
'popped-out': WebRTC.poppedOut[username],
|
|
|
|
|
'popped-in': !WebRTC.poppedOut[username]
|
|
|
|
|
}">
|
|
|
|
|
<video class="feed" :id="'videofeed-' + username" autoplay>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</video>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="caption" :class="{
|
|
|
|
|
'has-text-camera-blue': !isUsernameCamNSFW(username),
|
|
|
|
|
'has-text-camera-red': isUsernameCamNSFW(username)
|
|
|
|
|
}">
|
|
|
|
|
<i class="fa fa-microphone-slash mr-1 has-text-grey" v-if="isSourceMuted(username)"></i>
|
|
|
|
|
{{ username }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-people-arrows ml-1 has-text-grey is-size-7"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
:title="username + ' is watching your camera too'" v-if="isWatchingMe(username)"></i>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<!-- Frozen stream detection -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<a class="fa fa-mountain ml-1" href="#" v-if="WebRTC.frozenStreamDetected[username]"
|
|
|
|
|
style="color: #00FFFF" @click.prevent="openVideoByUsername(username, true)"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Frozen video detected!"></a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="close">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<a href="#" class="has-text-danger" title="Close video"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click.prevent="closeVideo(username, 'offerer')">
|
|
|
|
|
<i class="fa fa-close"></i>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="controls">
|
|
|
|
|
<!-- Mute button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="isMuted(username)" class="button is-small is-danger p-2"
|
|
|
|
|
title="Unmute this video" @click="muteVideo(username)">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-volume-xmark"></i>
|
|
|
|
|
</button>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-else class="button is-small is-success is-outlined p-2"
|
|
|
|
|
title="Mute this video" @click="muteVideo(username)">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-volume-high"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Pop-out -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-small is-light is-outlined p-2 ml-2" title="Pop out"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="popoutVideo(username)">
|
|
|
|
|
<i class="fa fa-up-right-from-square"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Debugging - copy a lot of these to simulate more videos -->
|
|
|
|
|
|
|
|
|
|
<!-- <div class="feed">
|
|
|
|
|
hi
|
|
|
|
|
</div>
|
|
|
|
|
<div class="feed">
|
|
|
|
|
hi
|
|
|
|
|
</div>
|
|
|
|
|
<div class="feed">
|
|
|
|
|
hi
|
|
|
|
|
</div>
|
|
|
|
|
<div class="feed">
|
|
|
|
|
hi
|
|
|
|
|
</div> -->
|
|
|
|
|
|
|
|
|
|
</div>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="card-content" id="chatHistory" :class="{ 'has-background-dm': isDM }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<div class="autoscroll-field tag">
|
|
|
|
|
<label class="checkbox is-size-6" title="Automatically scroll when new chat messages come in.">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="checkbox" v-model="autoscroll" :value="true">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Auto-scroll
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div :class="fontSizeClass">
|
|
|
|
|
|
|
|
|
|
<!-- Disclaimer at the top of DMs -->
|
|
|
|
|
<!-- TODO: make this disclaimer configurable for other sites to modify -->
|
|
|
|
|
<div class="notification is-warning is-light" v-if="isDM">
|
|
|
|
|
<i class="fa fa-info-circle mr-1"></i>
|
|
|
|
|
<strong>Reminder:</strong> please conduct yourself honorably in Direct Messages.
|
2023-09-07 06:03:12 +00:00
|
|
|
|
Please refer to <span v-html="config.branding"></span>'s Privacy Policy or Terms of Service with
|
|
|
|
|
regard to DMs.
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- No history? -->
|
|
|
|
|
<div v-if="chatHistory.length === 0">
|
|
|
|
|
<em v-if="isDM">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
Starting a direct message chat with {{ channel }}. Type a message and say hello!
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</em>
|
|
|
|
|
<em v-else>
|
|
|
|
|
There are no messages in this channel yet.
|
|
|
|
|
</em>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-for="(msg, i) in chatHistory" v-bind:key="i">
|
|
|
|
|
<!-- Enter chat presence messages draw as a short banner -->
|
|
|
|
|
<div v-if="msg.action === 'presence'" class="notification is-success is-light py-1 px-3 mb-2">
|
|
|
|
|
|
|
|
|
|
<!-- Tiny avatar next to name and action buttons -->
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<div class="column is-narrow pr-0 pt-4">
|
|
|
|
|
<figure class="image is-16x16">
|
|
|
|
|
<img v-if="avatarForUsername(msg.username)"
|
|
|
|
|
:src="avatarForUsername(msg.username)">
|
|
|
|
|
<img v-else src="/static/img/shy.png">
|
|
|
|
|
</figure>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<strong>{{ nicknameForUsername(msg.username) }}</strong>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<small v-if="isUsernameOnline(msg.username)"
|
|
|
|
|
class="ml-1">(@{{ msg.username }})</small>
|
|
|
|
|
{{ msg.message }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Normal chat message: full size card w/ avatar -->
|
|
|
|
|
<div v-else class="box mb-2 px-4 pt-3 pb-1 position-relative">
|
|
|
|
|
<div class="media mb-0">
|
|
|
|
|
<div class="media-left">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<a :href="profileURLForUsername(msg.username)"
|
|
|
|
|
@click.prevent="openProfile({ username: msg.username })"
|
|
|
|
|
:class="{ 'cursor-default': !profileURLForUsername(msg.username) }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<figure class="image is-48x48">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<img v-if="msg.isChatServer" src="/static/img/server.png">
|
|
|
|
|
<img v-else-if="msg.isChatClient" src="/static/img/client.png">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<img v-else-if="avatarForUsername(msg.username)"
|
|
|
|
|
:src="avatarForUsername(msg.username)">
|
|
|
|
|
<img v-else src="/static/img/shy.png">
|
|
|
|
|
</figure>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="media-content">
|
|
|
|
|
<div class="columns is-mobile pb-0">
|
|
|
|
|
<div class="column is-narrow pb-0">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<strong :class="{
|
|
|
|
|
'has-text-success is-dark': msg.isChatServer,
|
|
|
|
|
'has-text-warning is-dark': msg.isAdmin,
|
|
|
|
|
'has-text-danger': msg.isChatClient
|
|
|
|
|
}">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<!-- User nickname/display name -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
{{ nicknameForUsername(msg.username) }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</strong>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column has-text-right pb-0">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<small class="has-text-grey is-size-7" :title="msg.at">{{ prettyDate(msg.at)
|
|
|
|
|
}}</small>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- User @username below it which may link to a profile URL if JWT -->
|
|
|
|
|
<div class="columns is-mobile pt-0" v-if="(msg.isChatClient || msg.isChatServer)">
|
|
|
|
|
<div class="column is-narrow pt-0">
|
|
|
|
|
<small v-if="!(msg.isChatClient || msg.isChatServer)">
|
|
|
|
|
<a v-if="profileURLForUsername(msg.username)"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
:href="profileURLForUsername(msg.username)" target="_blank"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
class="has-text-grey">
|
|
|
|
|
@{{ msg.username }}
|
|
|
|
|
</a>
|
|
|
|
|
<span v-else class="has-text-grey">@{{ msg.username }}</span>
|
|
|
|
|
</small>
|
|
|
|
|
<small v-else class="has-text-grey">internal</small>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="columns is-mobile pt-0">
|
|
|
|
|
<div class="column is-narrow pt-0">
|
|
|
|
|
<small v-if="!(msg.isChatClient || msg.isChatServer)">
|
|
|
|
|
<a v-if="profileURLForUsername(msg.username)"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
:href="profileURLForUsername(msg.username)" target="_blank"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
class="has-text-grey">
|
|
|
|
|
@{{ msg.username }}
|
|
|
|
|
</a>
|
|
|
|
|
<span v-else class="has-text-grey">@{{ msg.username }}</span>
|
|
|
|
|
</small>
|
|
|
|
|
<small v-else class="has-text-grey">internal</small>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="column is-narrow pl-1 pt-0">
|
|
|
|
|
<!-- DMs button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="!(msg.username === username || isDM)"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
class="button is-grey is-outlined is-small px-2"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
@click="openDMs({ username: msg.username })"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:title="isUsernameDND(msg.username) ? 'This person is not accepting new DMs' : 'Open a Direct Message (DM) thread'"
|
|
|
|
|
:disabled="isUsernameDND(msg.username)">
|
|
|
|
|
<i class="fa fa-comment"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Mute button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="!(msg.username === username)"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
class="button is-grey is-outlined is-small px-2 ml-1"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
@click="muteUser(msg.username)" title="Mute user">
|
|
|
|
|
<i class="fa fa-comment-slash" :class="{
|
|
|
|
|
'has-text-success': isMutedUser(msg.username),
|
|
|
|
|
'has-text-danger': !isMutedUser(msg.username)
|
|
|
|
|
}"></i>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Owner or admin: take back the message -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="msg.username === username || isOp"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
class="button is-grey is-outlined is-small px-2 ml-1"
|
|
|
|
|
title="Take back this message (delete it for everybody)"
|
|
|
|
|
@click="takeback(msg)">
|
|
|
|
|
<i class="fa fa-rotate-left has-text-danger"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Everyone else: can hide it locally -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="msg.username !== username"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
class="button is-grey is-outlined is-small px-2 ml-1"
|
|
|
|
|
title="Hide this message (delete it only for your view)"
|
|
|
|
|
@click="removeMessage(msg)">
|
|
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Report & Emoji buttons -->
|
|
|
|
|
<div v-if="msg.msgID" class="emoji-button columns is-mobile is-gapless mb-0">
|
|
|
|
|
<!-- Report message button -->
|
|
|
|
|
<div class="column" v-if="isWebhookEnabled('report') && msg.username !== username">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button class="button is-small is-outlined mr-1" :class="{
|
|
|
|
|
'is-danger': !msg.reported,
|
|
|
|
|
'has-text-grey': msg.reported
|
|
|
|
|
}" title="Report this message"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="reportMessage(msg)">
|
|
|
|
|
<i class="fa fa-flag"></i>
|
|
|
|
|
<i class="fa fa-check ml-1" v-if="msg.reported"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Emoji reactions menu -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="column dropdown is-right" :class="{ 'is-up': i >= 2 }"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
onclick="this.classList.toggle('is-active')">
|
|
|
|
|
<div class="dropdown-trigger">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button class="button is-small px-2" aria-haspopup="true"
|
|
|
|
|
:aria-controls="`react-menu-${msg.msgID}`">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<span>
|
|
|
|
|
<i class="fa fa-heart has-text-grey"></i>
|
|
|
|
|
<i class="fa fa-plus has-text-grey pl-1"></i>
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="dropdown-menu" :id="`react-menu-${msg.msgID}`" role="menu">
|
|
|
|
|
<div class="dropdown-content p-0">
|
|
|
|
|
<!-- Iterate over reactions in rows of emojis-->
|
|
|
|
|
<div class="columns is-mobile ml-0 mb-2 mr-1"
|
|
|
|
|
v-for="row in config.reactions">
|
|
|
|
|
|
|
|
|
|
<!-- Loop over the icons -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="column p-0 is-narrow" v-for="i in row">
|
|
|
|
|
<button type="button" class="button px-2 mt-1 ml-1 mr-0 mb-1"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="sendReact(msg, i)">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
{{ i }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Message box -->
|
|
|
|
|
<div class="content pl-5 pb-3 pt-1 mb-5">
|
|
|
|
|
<em v-if="msg.action === 'presence'">{{ msg.message }}</em>
|
|
|
|
|
<div v-else v-html="msg.message"></div>
|
|
|
|
|
|
|
|
|
|
<!-- Reactions so far? -->
|
|
|
|
|
<div v-if="hasReactions(msg)" class="mt-1">
|
|
|
|
|
<span v-for="(users, emoji) in getReactions(msg)"
|
|
|
|
|
class="tag is-secondary mr-1 cursor-pointer"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
:class="{ 'is-success is-light': iReacted(msg, emoji), 'is-secondary': !iReacted(msg, emoji) }"
|
|
|
|
|
:title="emoji + ' by: ' + users.join(', ')" @click="sendReact(msg, emoji)">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ emoji }} <small class="ml-1">{{ users.length }}</small>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- If this is a DM with a muted user, offer to unmute. -->
|
|
|
|
|
<div v-if="isDM && isMutedUser(channel)" class="has-text-danger">
|
|
|
|
|
<i class="fa fa-comment-slash"></i>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<strong>{{ channel }}</strong> is currently <strong>muted</strong> so you have not been seeing their
|
|
|
|
|
recent
|
2023-09-07 00:15:02 +00:00
|
|
|
|
chat messages or DMs.
|
|
|
|
|
<a href="#" v-on:click.prevent="muteUser(channel)">Unmute them?</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Chat Footer Frame -->
|
|
|
|
|
<div class="chat-footer">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-content p-2">
|
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<div class="column pr-1 is-narrow" v-if="canUploadFile">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button" @click="uploadFile()"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Upload a picture to share in chat">
|
|
|
|
|
<i class="fa fa-image"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="column pr-1" :class="{ 'pl-1': canUploadFile }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<form @submit.prevent="sendMessage()">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<input type="text" class="input" id="messageBox" v-model="message"
|
|
|
|
|
placeholder="Write a message" @keydown="sendTypingNotification()" autocomplete="off"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:disabled="!ws.connected">
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column pl-1 is-narrow">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button" :disabled="message.length === 0"
|
|
|
|
|
title="Click to send your message" @click="sendMessage()">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-paper-plane"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Right Column: Who Is Online -->
|
|
|
|
|
<div class="right-column">
|
|
|
|
|
<div class="card grid-card">
|
|
|
|
|
<header class="card-header has-background-success-dark">
|
|
|
|
|
<div class="columns is-mobile card-header-title has-text-light">
|
|
|
|
|
<div class="column">Who Is Online</div>
|
|
|
|
|
<div class="column is-narrow mobile-only">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-success px-2" @click="openChatPanel">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-arrow-left"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
<div class="card-content p-2">
|
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile mb-0">
|
|
|
|
|
<div class="column is-one-quarter">
|
|
|
|
|
Status:
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-small is-fullwidth">
|
|
|
|
|
<select v-model="status">
|
|
|
|
|
<optgroup label="Status">
|
|
|
|
|
<option value="online">☀️ Active</option>
|
|
|
|
|
<option value="away">🕒 Away</option>
|
|
|
|
|
<option value="brb">⏰ Be right back</option>
|
|
|
|
|
<option value="lunch">🍴 Out to lunch</option>
|
|
|
|
|
<option value="call">📞 On the phone</option>
|
|
|
|
|
<option value="busy">💼 Working</option>
|
|
|
|
|
<option value="book">📖 Studying</option>
|
|
|
|
|
<option value="gaming">🎮 Gaming</option>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<option value="idle" v-show="status === 'idle'">🕒 Idle</option>
|
|
|
|
|
<option value="hidden" v-if="jwt.claims != undefined && jwt.claims.op">🕵️ Hidden
|
|
|
|
|
</option>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</optgroup>
|
|
|
|
|
<optgroup label="Mood">
|
|
|
|
|
<option value="chatty">🗨️ Chatty and sociable</option>
|
|
|
|
|
<option value="introverted">🥄 Introverted and quiet</option>
|
|
|
|
|
<option value="horny" v-if="config.permitNSFW">🔥 Horny</option>
|
|
|
|
|
<option value="exhibitionist" v-if="config.permitNSFW">👀 Watch me</option>
|
|
|
|
|
</optgroup>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="columns is-mobile mb-0">
|
|
|
|
|
<div class="column is-one-quarter">
|
|
|
|
|
Sort:
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column">
|
|
|
|
|
<div class="select is-small is-fullwidth">
|
|
|
|
|
<select v-model="whoSort">
|
|
|
|
|
<option value="a-z">Username (a-z)</option>
|
|
|
|
|
<option value="z-a">Username (z-a)</option>
|
|
|
|
|
<option value="login">Login Time</option>
|
|
|
|
|
<option value="broadcasting">Broadcasting</option>
|
|
|
|
|
<option value="nsfw" v-show="config.permitNSFW">Red cameras</option>
|
|
|
|
|
<option value="status">Status</option>
|
|
|
|
|
<option value="emoji">Emoji/country flag</option>
|
|
|
|
|
<option value="gender">Gender</option>
|
|
|
|
|
<option value="op">User level (operators)</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="tabs has-text-small">
|
|
|
|
|
<ul>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li :class="{ 'is-active': whoTab === 'online' }">
|
|
|
|
|
<a class="is-size-7" @click.prevent="whoTab = 'online'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
Online ({{ whoList.length }})
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<li v-if="webcam.active" :class="{ 'is-active': whoTab === 'watching' }">
|
|
|
|
|
<a class="is-size-7" @click.prevent="whoTab = 'watching'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-eye mr-2"></i>
|
|
|
|
|
Watching ({{ Object.keys(webcam.watching).length }})
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Who Is Online -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<ul class="menu-list" v-if="whoTab === 'online'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<li v-for="(u, i) in sortedWhoList" v-bind:key="i">
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<!-- Avatar URL if available -->
|
|
|
|
|
<div class="column is-narrow pr-0" style="position: relative">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<a :href="profileURLForUsername(u.username)"
|
|
|
|
|
@click.prevent="openProfile({ username: u.username })"
|
|
|
|
|
:class="{ 'cursor-default': !profileURLForUsername(u.username) }" class="p-0">
|
|
|
|
|
<img v-if="u.avatar" :src="avatarURL(u)" width="24" height="24" alt="">
|
|
|
|
|
<img v-else src="/static/img/shy.png" width="24" height="24">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
|
|
|
|
|
<!-- Away symbol -->
|
|
|
|
|
<div v-if="u.status !== 'online'" class="status-away-icon">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<i v-if="u.status === 'away'" class="fa fa-clock has-text-light"
|
|
|
|
|
title="Status: Away"></i>
|
|
|
|
|
<i v-else-if="u.status === 'lunch'" class="fa fa-utensils has-text-light"
|
|
|
|
|
title="Status: Out to lunch"></i>
|
|
|
|
|
<i v-else-if="u.status === 'call'" class="fa fa-phone-volume has-text-light"
|
|
|
|
|
title="Status: On the phone"></i>
|
|
|
|
|
<i v-else-if="u.status === 'brb'" class="fa fa-stopwatch-20 has-text-light"
|
|
|
|
|
title="Status: Be right back"></i>
|
|
|
|
|
<i v-else-if="u.status === 'busy'" class="fa fa-briefcase has-text-light"
|
|
|
|
|
title="Status: Working"></i>
|
|
|
|
|
<i v-else-if="u.status === 'book'" class="fa fa-book has-text-light"
|
|
|
|
|
title="Status: Studying"></i>
|
|
|
|
|
<i v-else-if="u.status === 'gaming'"
|
|
|
|
|
class="fa fa-gamepad who-status-wide-icon-2 has-text-light"
|
|
|
|
|
title="Status: Gaming"></i>
|
|
|
|
|
<i v-else-if="u.status === 'idle'" class="fa-regular fa-moon has-text-light"
|
|
|
|
|
title="Status: Idle"></i>
|
|
|
|
|
<i v-else-if="u.status === 'horny'" class="fa fa-fire has-text-light"
|
|
|
|
|
title="Status: Horny"></i>
|
|
|
|
|
<i v-else-if="u.status === 'chatty'" class="fa fa-comment has-text-light"
|
|
|
|
|
title="Status: Chatty and sociable"></i>
|
|
|
|
|
<i v-else-if="u.status === 'introverted'" class="fa fa-spoon has-text-light"
|
|
|
|
|
title="Status: Introverted and quiet"></i>
|
|
|
|
|
<i v-else-if="u.status === 'exhibitionist'"
|
|
|
|
|
class="fa-regular fa-eye who-status-wide-icon-1 has-text-light"
|
|
|
|
|
title="Status: Watch me"></i>
|
|
|
|
|
<i v-else class="fa fa-clock has-text-light" :title="'Status: ' + u.status"></i>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<div class="column pr-0 is-clipped" :class="{ 'pl-1': u.avatar }">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<strong class="truncate-text-line is-size-7">{{ u.username }}</strong>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<sup class="fa fa-peace has-text-warning-dark is-size-7 ml-1" v-if="u.op"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Operator"></sup>
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<sup class="is-size-7 ml-1" :class="config.VIP.Icon" v-else-if="u.vip"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:title="config.VIP.Name"></sup>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column is-narrow pl-0">
|
|
|
|
|
<!-- Emoji icon -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<span v-if="u.emoji" class="pr-1 cursor-default" :title="u.emoji">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
{{ u.emoji.split(" ")[0] }}
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<!-- Profile button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="u.profileURL" class="button is-small px-2 py-1"
|
|
|
|
|
:class="profileButtonClass(u)" @click="openProfile(u)"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:title="'Open profile page' + (u.gender ? ` (gender: ${u.gender})` : '') + (u.vip ? ` (${config.VIP.Name})` : '')">
|
|
|
|
|
<i class="fa fa-user"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Unmute User button (if muted) -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-if="isMutedUser(u.username)" class="button is-small px-2 py-1"
|
|
|
|
|
@click="muteUser(u.username)" title="This user is muted. Click to unmute them.">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<i class="fa fa-comment-slash has-text-danger"></i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- DM button (if not muted) -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" v-else class="button is-small px-2 py-1" @click="openDMs(u)"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
:disabled="u.username === username || (u.dnd && !isOp)"
|
|
|
|
|
:title="u.dnd ? 'This person is not accepting new DMs' : 'Send a Direct Message'">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<i class="fa" :class="{ 'fa-comment': !u.dnd, 'fa-comment-slash': u.dnd }"></i>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<!-- Video button -->
|
|
|
|
|
<button type="button" class="button is-small px-2 py-1"
|
2023-09-07 06:03:12 +00:00
|
|
|
|
:disabled="!(u.video & VideoFlag.Active)" :class="{
|
2023-09-07 00:15:02 +00:00
|
|
|
|
'is-danger is-outlined': (u.video & VideoFlag.Active) && (u.video & VideoFlag.NSFW),
|
|
|
|
|
'is-info is-outlined': (u.video & VideoFlag.Active) && !(u.video & VideoFlag.NSFW),
|
|
|
|
|
'cursor-notallowed': isVideoNotAllowed(u),
|
2023-09-07 06:03:12 +00:00
|
|
|
|
}" :title="`Open video stream` +
|
|
|
|
|
(u.video & VideoFlag.MutualRequired ? '; mutual video sharing required' : '') +
|
|
|
|
|
(u.video & VideoFlag.MutualOpen ? '; will auto-open your video' : '')"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@click="openVideo(u)">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<i class="fa" :class="webcamIconClass(u)"></i>
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<!-- Watching My Webcam -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<ul class="menu-list" v-if="whoTab === 'watching'">
|
2023-09-07 00:15:02 +00:00
|
|
|
|
<li v-for="username in Object.keys(webcam.watching)" v-bind:key="username">
|
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
|
<!-- Avatar URL if available -->
|
|
|
|
|
<div class="column is-narrow pr-0">
|
|
|
|
|
<i class="fa fa-eye"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="column pr-0">
|
2023-09-07 06:03:12 +00:00
|
|
|
|
{{ username }}
|
2023-09-07 00:15:02 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div class="column is-narrow pl-0">
|
|
|
|
|
<!-- Boot from cam button -->
|
2023-09-07 06:03:12 +00:00
|
|
|
|
<button type="button" class="button is-small px-2 py-1" @click="bootUser(username)"
|
2023-09-07 00:15:02 +00:00
|
|
|
|
title="Kick this person off your cam">
|
|
|
|
|
<i class="fa fa-user-xmark has-text-danger"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
/* header {
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logo {
|
|
|
|
|
display: block;
|
|
|
|
|
margin: 0 auto 2rem;
|
|
|
|
|
}
|
2023-01-11 06:38:48 +00:00
|
|
|
|
|
2023-09-07 00:15:02 +00:00
|
|
|
|
@media (min-width: 1024px) {
|
|
|
|
|
header {
|
|
|
|
|
display: flex;
|
|
|
|
|
place-items: center;
|
|
|
|
|
padding-right: calc(var(--section-gap) / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logo {
|
|
|
|
|
margin: 0 2rem 0 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header .wrapper {
|
|
|
|
|
display: flex;
|
|
|
|
|
place-items: flex-start;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
|
|
|
|
} */
|
|
|
|
|
</style>
|