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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright @ 2015 Atlassian Pty Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. var email = '';
  17. var displayName = '';
  18. var userId;
  19. var language = null;
  20. function supportsLocalStorage() {
  21. try {
  22. return 'localStorage' in window && window.localStorage !== null;
  23. } catch (e) {
  24. console.log("localstorage is not supported");
  25. return false;
  26. }
  27. }
  28. function generateUniqueId() {
  29. function _p8() {
  30. return (Math.random().toString(16) + "000000000").substr(2, 8);
  31. }
  32. return _p8() + _p8() + _p8() + _p8();
  33. }
  34. if (supportsLocalStorage()) {
  35. if (!window.localStorage.jitsiMeetId) {
  36. window.localStorage.jitsiMeetId = generateUniqueId();
  37. console.log("generated id", window.localStorage.jitsiMeetId);
  38. }
  39. userId = window.localStorage.jitsiMeetId || '';
  40. email = window.localStorage.email || '';
  41. displayName = window.localStorage.displayname || '';
  42. language = window.localStorage.language;
  43. } else {
  44. console.log("local storage is not supported");
  45. userId = generateUniqueId();
  46. }
  47. var Settings =
  48. {
  49. setDisplayName: function (newDisplayName) {
  50. displayName = newDisplayName;
  51. window.localStorage.displayname = displayName;
  52. return displayName;
  53. },
  54. setEmail: function (newEmail)
  55. {
  56. email = newEmail;
  57. window.localStorage.email = newEmail;
  58. return email;
  59. },
  60. getSettings: function () {
  61. return {
  62. email: email,
  63. displayName: displayName,
  64. uid: userId,
  65. language: language
  66. };
  67. },
  68. setLanguage: function (lang) {
  69. language = lang;
  70. window.localStorage.language = lang;
  71. }
  72. };
  73. module.exports = Settings;