Browse Source

ref(ConferenceUrl): converts to class and binds instance to global APP

Converts ConferenceUrl to a class and binds an instance to the global
APP variable, as requested by HTerezov.
master
paweldomas 8 years ago
parent
commit
8f8b1385fa

+ 9
- 3
app.js View File

19
 window.toastr = require("toastr");
19
 window.toastr = require("toastr");
20
 
20
 
21
 import URLProcessor from "./modules/config/URLProcessor";
21
 import URLProcessor from "./modules/config/URLProcessor";
22
-import ConferenceUrl from './modules/URL/ConferenceUrl';
23
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
22
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
24
 
23
 
25
 import UI from "./modules/UI/UI";
24
 import UI from "./modules/UI/UI";
26
 import settings from "./modules/settings/Settings";
25
 import settings from "./modules/settings/Settings";
27
 import conference from './conference';
26
 import conference from './conference';
27
+import ConferenceUrl from './modules/URL/ConferenceUrl';
28
 import API from './modules/API/API';
28
 import API from './modules/API/API';
29
 
29
 
30
 import UIEvents from './service/UI/UIEvents';
30
 import UIEvents from './service/UI/UIEvents';
95
     UI,
95
     UI,
96
     settings,
96
     settings,
97
     conference,
97
     conference,
98
+    /**
99
+     * After the APP has been initialized provides utility methods for dealing
100
+     * with the conference room URL(address).
101
+     * @type ConferenceUrl
102
+     */
103
+    ConferenceUrl : null,
98
     connection: null,
104
     connection: null,
99
     API,
105
     API,
100
     init () {
106
     init () {
121
 function init() {
127
 function init() {
122
     setTokenData();
128
     setTokenData();
123
     // Initialize the conference URL handler
129
     // Initialize the conference URL handler
124
-    ConferenceUrl.init(window.location);
130
+    APP.ConferenceUrl = new ConferenceUrl(window.location);
125
     // Clean up the URL displayed by the browser
131
     // Clean up the URL displayed by the browser
126
-    replaceHistoryState(ConferenceUrl.getInviteUrl());
132
+    replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
127
     var isUIReady = APP.UI.start();
133
     var isUIReady = APP.UI.start();
128
     if (isUIReady) {
134
     if (isUIReady) {
129
         APP.conference.init({roomName: buildRoomName()}).then(function () {
135
         APP.conference.init({roomName: buildRoomName()}).then(function () {

+ 1
- 2
modules/UI/invite/Invite.js View File

3
 import InviteDialogView from './InviteDialogView';
3
 import InviteDialogView from './InviteDialogView';
4
 import createRoomLocker from './RoomLocker';
4
 import createRoomLocker from './RoomLocker';
5
 import UIEvents from  '../../../service/UI/UIEvents';
5
 import UIEvents from  '../../../service/UI/UIEvents';
6
-import ConferenceUrl from '../../URL/ConferenceUrl';
7
 
6
 
8
 const ConferenceEvents = JitsiMeetJS.events.conference;
7
 const ConferenceEvents = JitsiMeetJS.events.conference;
9
 
8
 
15
 class Invite {
14
 class Invite {
16
     constructor(conference) {
15
     constructor(conference) {
17
         this.conference = conference;
16
         this.conference = conference;
18
-        this.inviteUrl = ConferenceUrl.getInviteUrl();
17
+        this.inviteUrl = APP.ConferenceUrl.getInviteUrl();
19
         this.createRoomLocker(conference);
18
         this.createRoomLocker(conference);
20
         this.registerListeners();
19
         this.registerListeners();
21
     }
20
     }

+ 1
- 3
modules/UI/reload_overlay/PageReloadOverlay.js View File

1
 /* global $, APP, AJS */
1
 /* global $, APP, AJS */
2
 
2
 
3
-import ConferenceUrl from '../../URL/ConferenceUrl';
4
-
5
 let $overlay;
3
 let $overlay;
6
 
4
 
7
 /**
5
 /**
79
 
77
 
80
         if (timeLeft === 0) {
78
         if (timeLeft === 0) {
81
             window.clearInterval(intervalId);
79
             window.clearInterval(intervalId);
82
-            ConferenceUrl.reload();
80
+            APP.ConferenceUrl.reload();
83
         }
81
         }
84
     }, 1000);
82
     }, 1000);
85
 }
83
 }

+ 28
- 28
modules/URL/ConferenceUrl.js View File

1
+/* global console */
1
 
2
 
2
 import { redirect } from '../util/helpers';
3
 import { redirect } from '../util/helpers';
3
 
4
 
4
-/**
5
- * Stores the original conference room URL with all parameters.
6
- * @type {string}
7
- */
8
-let originalURL;
9
-
10
-/**
11
- * A simplified version of the conference URL stripped out of the parameters
12
- * which should be used for sending invites.
13
- * @type {string}
14
- */
15
-let inviteURL;
16
-
17
 /**
5
 /**
18
  * The modules stores information about the URL used to start the conference and
6
  * The modules stores information about the URL used to start the conference and
19
  * provides utility methods for dealing with conference URL and reloads.
7
  * provides utility methods for dealing with conference URL and reloads.
20
  */
8
  */
21
-export default {
9
+export default class ConferenceUrl {
22
     /**
10
     /**
23
      * Initializes the module.
11
      * Initializes the module.
24
      *
12
      *
40
      * @param location.protocol the protocol part of the URL, would be 'https:'
28
      * @param location.protocol the protocol part of the URL, would be 'https:'
41
      * from the sample URL.
29
      * from the sample URL.
42
      */
30
      */
43
-    init(location) {
44
-        originalURL = location.href;
45
-        // "https:" + "//" + "example.com:8888" + "/SomeConference1245"
46
-        inviteURL
31
+    constructor(location) {
32
+        /**
33
+         * Stores the original conference room URL with all parameters.
34
+         * Example:
35
+         * https://example.com:8888/SomeConference1245?jwt=a5sbc2#blablahash
36
+         * @type {string}
37
+         */
38
+        this.originalURL = location.href;
39
+        /**
40
+         * A simplified version of the conference URL stripped out of
41
+         * the parameters which should be used for sending invites.
42
+         * Example:
43
+         * https://example.com:8888/SomeConference1245
44
+         * @type {string}
45
+         */
46
+        this.inviteURL
47
             = location.protocol + "//" + location.host + location.pathname;
47
             = location.protocol + "//" + location.host + location.pathname;
48
-        console.info("Stored original conference URL: " + originalURL);
49
-        console.info("Conference URL for invites: " + inviteURL);
50
-    },
48
+        console.info("Stored original conference URL: " + this.originalURL);
49
+        console.info("Conference URL for invites: " + this.inviteURL);
50
+    }
51
     /**
51
     /**
52
      * Obtains the conference invite URL.
52
      * Obtains the conference invite URL.
53
      * @return {string} the URL pointing o the conference which is mean to be
53
      * @return {string} the URL pointing o the conference which is mean to be
54
      * used to invite new participants.
54
      * used to invite new participants.
55
      */
55
      */
56
     getInviteUrl() {
56
     getInviteUrl() {
57
-        return inviteURL;
58
-    },
57
+        return this.inviteURL;
58
+    }
59
     /**
59
     /**
60
      * Obtains full conference URL with all original parameters.
60
      * Obtains full conference URL with all original parameters.
61
      * @return {string} the original URL used to open the current conference.
61
      * @return {string} the original URL used to open the current conference.
62
      */
62
      */
63
     getOriginalUrl() {
63
     getOriginalUrl() {
64
-        return originalURL;
65
-    },
64
+        return this.originalURL;
65
+    }
66
     /**
66
     /**
67
      * Reloads the conference using original URL with all of the parameters.
67
      * Reloads the conference using original URL with all of the parameters.
68
      */
68
      */
69
     reload() {
69
     reload() {
70
-        console.info("Reloading the conference using URL: " + originalURL);
71
-        redirect(originalURL);
70
+        console.info("Reloading the conference using URL: " + this.originalURL);
71
+        redirect(this.originalURL);
72
     }
72
     }
73
-};
73
+}

Loading…
Cancel
Save