You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Settings.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. function supportsLocalStorage() {
  2. try {
  3. return 'localStorage' in window && window.localStorage !== null;
  4. } catch (e) {
  5. console.log("localstorage is not supported");
  6. return false;
  7. }
  8. }
  9. function generateUniqueId() {
  10. function _p8() {
  11. return (Math.random().toString(16) + "000000000").substr(2, 8);
  12. }
  13. return _p8() + _p8() + _p8() + _p8();
  14. }
  15. function Settings(conferenceID) {
  16. this.email = '';
  17. this.displayName = '';
  18. this.userId;
  19. this.language = null;
  20. this.confSettings = null;
  21. if (supportsLocalStorage()) {
  22. if(!window.localStorage.jitsiConferences)
  23. window.localStorage.jitsiConferences = {}
  24. if (!window.localStorage.jitsiConferences[conferenceID]) {
  25. window.localStorage.jitsiConferences[conferenceID] = {}
  26. }
  27. this.confSettings = window.localStorage.jitsiConferences[conferenceID];
  28. if(!this.confSettings.jitsiMeetId) {
  29. this.confSettings.jitsiMeetId = generateUniqueId();
  30. console.log("generated id",
  31. this.confSettings.jitsiMeetId);
  32. }
  33. this.userId = this.confSettings.jitsiMeetId || '';
  34. this.email = this.confSettings.email || '';
  35. this.displayName = this.confSettings.displayname || '';
  36. this.language = this.confSettings.language;
  37. } else {
  38. console.log("local storage is not supported");
  39. this.userId = generateUniqueId();
  40. }
  41. }
  42. Settings.prototype.setDisplayName = function (newDisplayName) {
  43. this.displayName = newDisplayName;
  44. if(this.confSettings != null)
  45. this.confSettings.displayname = displayName;
  46. return this.displayName;
  47. },
  48. Settings.prototype.setEmail = function (newEmail) {
  49. this.email = newEmail;
  50. if(this.confSettings != null)
  51. this.confSettings.email = newEmail;
  52. return this.email;
  53. },
  54. Settings.prototype.getSettings = function () {
  55. return {
  56. email: this.email,
  57. displayName: this.displayName,
  58. uid: this.userId,
  59. language: this.language
  60. };
  61. },
  62. Settings.prototype.setLanguage = function (lang) {
  63. this.language = lang;
  64. if(this.confSettings != null)
  65. this.confSettings.language = lang;
  66. }
  67. module.exports = Settings;