59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
var email = '';
|
|
var displayName = '';
|
|
var userId;
|
|
|
|
|
|
function supportsLocalStorage() {
|
|
try {
|
|
return 'localStorage' in window && window.localStorage !== null;
|
|
} catch (e) {
|
|
console.log("localstorage is not supported");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
function generateUniqueId() {
|
|
function _p8() {
|
|
return (Math.random().toString(16)+"000000000").substr(2,8);
|
|
}
|
|
return _p8() + _p8() + _p8() + _p8();
|
|
}
|
|
|
|
if(supportsLocalStorage()) {
|
|
if(!window.localStorage.jitsiMeetId) {
|
|
window.localStorage.jitsiMeetId = generateUniqueId();
|
|
console.log("generated id", window.localStorage.jitsiMeetId);
|
|
}
|
|
userId = window.localStorage.jitsiMeetId || '';
|
|
email = window.localStorage.email || '';
|
|
displayName = window.localStorage.displayname || '';
|
|
} else {
|
|
console.log("local storage is not supported");
|
|
userId = generateUniqueId();
|
|
}
|
|
|
|
var Settings =
|
|
{
|
|
setDisplayName: function (newDisplayName) {
|
|
displayName = newDisplayName;
|
|
window.localStorage.displayname = displayName;
|
|
return displayName;
|
|
},
|
|
setEmail: function(newEmail)
|
|
{
|
|
email = newEmail;
|
|
window.localStorage.email = newEmail;
|
|
return email;
|
|
},
|
|
getSettings: function () {
|
|
return {
|
|
email: email,
|
|
displayName: displayName,
|
|
uid: userId
|
|
};
|
|
}
|
|
};
|
|
|
|
module.exports = Settings;
|