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.
This commit is contained in:
paweldomas 2016-10-21 09:46:09 -05:00
parent d342f93547
commit 8f8b1385fa
4 changed files with 39 additions and 36 deletions

12
app.js
View File

@ -19,12 +19,12 @@ import 'aui-experimental-css';
window.toastr = require("toastr");
import URLProcessor from "./modules/config/URLProcessor";
import ConferenceUrl from './modules/URL/ConferenceUrl';
import RoomnameGenerator from './modules/util/RoomnameGenerator';
import UI from "./modules/UI/UI";
import settings from "./modules/settings/Settings";
import conference from './conference';
import ConferenceUrl from './modules/URL/ConferenceUrl';
import API from './modules/API/API';
import UIEvents from './service/UI/UIEvents';
@ -95,6 +95,12 @@ const APP = {
UI,
settings,
conference,
/**
* After the APP has been initialized provides utility methods for dealing
* with the conference room URL(address).
* @type ConferenceUrl
*/
ConferenceUrl : null,
connection: null,
API,
init () {
@ -121,9 +127,9 @@ function setTokenData() {
function init() {
setTokenData();
// Initialize the conference URL handler
ConferenceUrl.init(window.location);
APP.ConferenceUrl = new ConferenceUrl(window.location);
// Clean up the URL displayed by the browser
replaceHistoryState(ConferenceUrl.getInviteUrl());
replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
var isUIReady = APP.UI.start();
if (isUIReady) {
APP.conference.init({roomName: buildRoomName()}).then(function () {

View File

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

View File

@ -1,7 +1,5 @@
/* global $, APP, AJS */
import ConferenceUrl from '../../URL/ConferenceUrl';
let $overlay;
/**
@ -79,7 +77,7 @@ function start(timeoutSeconds) {
if (timeLeft === 0) {
window.clearInterval(intervalId);
ConferenceUrl.reload();
APP.ConferenceUrl.reload();
}
}, 1000);
}

View File

@ -1,24 +1,12 @@
/* global console */
import { redirect } from '../util/helpers';
/**
* Stores the original conference room URL with all parameters.
* @type {string}
*/
let originalURL;
/**
* A simplified version of the conference URL stripped out of the parameters
* which should be used for sending invites.
* @type {string}
*/
let inviteURL;
/**
* The modules stores information about the URL used to start the conference and
* provides utility methods for dealing with conference URL and reloads.
*/
export default {
export default class ConferenceUrl {
/**
* Initializes the module.
*
@ -40,34 +28,46 @@ export default {
* @param location.protocol the protocol part of the URL, would be 'https:'
* from the sample URL.
*/
init(location) {
originalURL = location.href;
// "https:" + "//" + "example.com:8888" + "/SomeConference1245"
inviteURL
constructor(location) {
/**
* Stores the original conference room URL with all parameters.
* Example:
* https://example.com:8888/SomeConference1245?jwt=a5sbc2#blablahash
* @type {string}
*/
this.originalURL = location.href;
/**
* A simplified version of the conference URL stripped out of
* the parameters which should be used for sending invites.
* Example:
* https://example.com:8888/SomeConference1245
* @type {string}
*/
this.inviteURL
= location.protocol + "//" + location.host + location.pathname;
console.info("Stored original conference URL: " + originalURL);
console.info("Conference URL for invites: " + inviteURL);
},
console.info("Stored original conference URL: " + this.originalURL);
console.info("Conference URL for invites: " + this.inviteURL);
}
/**
* Obtains the conference invite URL.
* @return {string} the URL pointing o the conference which is mean to be
* used to invite new participants.
*/
getInviteUrl() {
return inviteURL;
},
return this.inviteURL;
}
/**
* Obtains full conference URL with all original parameters.
* @return {string} the original URL used to open the current conference.
*/
getOriginalUrl() {
return originalURL;
},
return this.originalURL;
}
/**
* Reloads the conference using original URL with all of the parameters.
*/
reload() {
console.info("Reloading the conference using URL: " + originalURL);
redirect(originalURL);
console.info("Reloading the conference using URL: " + this.originalURL);
redirect(this.originalURL);
}
};
}