[mirotalksfu] - allow name storage per room

هذا الالتزام موجود في:
Laurent Goussard
2022-08-30 23:52:13 +02:00
الأصل f436bbe182
التزام 472900976e

عرض الملف

@@ -393,6 +393,11 @@ function whoAreYou() {
return;
}
let default_name = window.localStorage.peer_name ? window.localStorage.peer_name : '';
if (getCookie(room_id + "_name")) {
default_name = getCookie(room_id + "_name");
}
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: false,
@@ -401,7 +406,7 @@ function whoAreYou() {
imageUrl: image.username,
input: 'text',
inputPlaceholder: 'Enter your name',
inputValue: window.localStorage.peer_name ? window.localStorage.peer_name : '',
inputValue: default_name,
html: `<br />
<div style="overflow: hidden;">
<button id="initAudioButton" class="fas fa-microphone" onclick="handleAudio(event)"></button>
@@ -417,12 +422,15 @@ function whoAreYou() {
},
inputValidator: (name) => {
if (!name) return 'Please enter your name';
if (!getCookie(room_id + "_name")) {
window.localStorage.peer_name = name;
}
setCookie(room_id + "_name", name, 30);
peer_name = name;
},
}).then(() => {
getPeerInfo();
joinRoom(peer_name, room_id);
window.localStorage.peer_name = peer_name;
});
if (!DetectRTC.isMobileDevice) {
@@ -1256,6 +1264,24 @@ function openURL(url, blank = false) {
blank ? window.open(url, '_blank') : (window.location.href = url);
}
function setCookie(name, value, expDays) {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + "; " + expires + "; path=/";
}
function getCookie(cName) {
const name = cName + "=";
const cDecoded = decodeURIComponent(document.cookie);
const cArr = cDecoded .split('; ');
let res;
cArr.forEach(val => {
if (val.indexOf(name) === 0) res = val.substring(name.length);
})
return res;
}
// ####################################################
// HANDLE WHITEBOARD
// ####################################################