Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

Settings.js 2.4KB

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