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
4 changed files with 39 additions and 36 deletions
  1. 9
    3
      app.js
  2. 1
    2
      modules/UI/invite/Invite.js
  3. 1
    3
      modules/UI/reload_overlay/PageReloadOverlay.js
  4. 28
    28
      modules/URL/ConferenceUrl.js

+ 9
- 3
app.js View File

@@ -19,12 +19,12 @@ import 'aui-experimental-css';
19 19
 window.toastr = require("toastr");
20 20
 
21 21
 import URLProcessor from "./modules/config/URLProcessor";
22
-import ConferenceUrl from './modules/URL/ConferenceUrl';
23 22
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
24 23
 
25 24
 import UI from "./modules/UI/UI";
26 25
 import settings from "./modules/settings/Settings";
27 26
 import conference from './conference';
27
+import ConferenceUrl from './modules/URL/ConferenceUrl';
28 28
 import API from './modules/API/API';
29 29
 
30 30
 import UIEvents from './service/UI/UIEvents';
@@ -95,6 +95,12 @@ const APP = {
95 95
     UI,
96 96
     settings,
97 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 104
     connection: null,
99 105
     API,
100 106
     init () {
@@ -121,9 +127,9 @@ function setTokenData() {
121 127
 function init() {
122 128
     setTokenData();
123 129
     // Initialize the conference URL handler
124
-    ConferenceUrl.init(window.location);
130
+    APP.ConferenceUrl = new ConferenceUrl(window.location);
125 131
     // Clean up the URL displayed by the browser
126
-    replaceHistoryState(ConferenceUrl.getInviteUrl());
132
+    replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
127 133
     var isUIReady = APP.UI.start();
128 134
     if (isUIReady) {
129 135
         APP.conference.init({roomName: buildRoomName()}).then(function () {

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

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

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

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

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

@@ -1,24 +1,12 @@
1
+/* global console */
1 2
 
2 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 6
  * The modules stores information about the URL used to start the conference and
19 7
  * provides utility methods for dealing with conference URL and reloads.
20 8
  */
21
-export default {
9
+export default class ConferenceUrl {
22 10
     /**
23 11
      * Initializes the module.
24 12
      *
@@ -40,34 +28,46 @@ export default {
40 28
      * @param location.protocol the protocol part of the URL, would be 'https:'
41 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 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 52
      * Obtains the conference invite URL.
53 53
      * @return {string} the URL pointing o the conference which is mean to be
54 54
      * used to invite new participants.
55 55
      */
56 56
     getInviteUrl() {
57
-        return inviteURL;
58
-    },
57
+        return this.inviteURL;
58
+    }
59 59
     /**
60 60
      * Obtains full conference URL with all original parameters.
61 61
      * @return {string} the original URL used to open the current conference.
62 62
      */
63 63
     getOriginalUrl() {
64
-        return originalURL;
65
-    },
64
+        return this.originalURL;
65
+    }
66 66
     /**
67 67
      * Reloads the conference using original URL with all of the parameters.
68 68
      */
69 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