2015-01-07 14:54:03 +00:00
|
|
|
var email = '';
|
|
|
|
var displayName = '';
|
|
|
|
var userId;
|
2015-02-24 10:49:46 +00:00
|
|
|
var language = null;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
function supportsLocalStorage() {
|
|
|
|
try {
|
|
|
|
return 'localStorage' in window && window.localStorage !== null;
|
|
|
|
} catch (e) {
|
|
|
|
console.log("localstorage is not supported");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function generateUniqueId() {
|
|
|
|
function _p8() {
|
2015-02-13 09:38:37 +00:00
|
|
|
return (Math.random().toString(16) + "000000000").substr(2, 8);
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
return _p8() + _p8() + _p8() + _p8();
|
|
|
|
}
|
|
|
|
|
2015-02-13 09:38:37 +00:00
|
|
|
if (supportsLocalStorage()) {
|
|
|
|
if (!window.localStorage.jitsiMeetId) {
|
2015-01-07 14:54:03 +00:00
|
|
|
window.localStorage.jitsiMeetId = generateUniqueId();
|
|
|
|
console.log("generated id", window.localStorage.jitsiMeetId);
|
|
|
|
}
|
|
|
|
userId = window.localStorage.jitsiMeetId || '';
|
|
|
|
email = window.localStorage.email || '';
|
|
|
|
displayName = window.localStorage.displayname || '';
|
2015-02-24 10:49:46 +00:00
|
|
|
language = window.localStorage.language;
|
2015-01-07 14:54:03 +00:00
|
|
|
} else {
|
|
|
|
console.log("local storage is not supported");
|
|
|
|
userId = generateUniqueId();
|
|
|
|
}
|
|
|
|
|
2015-07-28 18:22:11 +00:00
|
|
|
var Settings = {
|
2015-01-07 14:54:03 +00:00
|
|
|
setDisplayName: function (newDisplayName) {
|
|
|
|
displayName = newDisplayName;
|
|
|
|
window.localStorage.displayname = displayName;
|
|
|
|
return displayName;
|
|
|
|
},
|
2015-07-28 18:22:11 +00:00
|
|
|
setEmail: function (newEmail) {
|
2015-01-07 14:54:03 +00:00
|
|
|
email = newEmail;
|
|
|
|
window.localStorage.email = newEmail;
|
|
|
|
return email;
|
|
|
|
},
|
|
|
|
getSettings: function () {
|
|
|
|
return {
|
|
|
|
email: email,
|
|
|
|
displayName: displayName,
|
2015-02-24 10:49:46 +00:00
|
|
|
uid: userId,
|
|
|
|
language: language
|
2015-01-07 14:54:03 +00:00
|
|
|
};
|
2015-02-24 10:49:46 +00:00
|
|
|
},
|
|
|
|
setLanguage: function (lang) {
|
|
|
|
language = lang;
|
|
|
|
window.localStorage.language = lang;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Settings;
|