From 2f10203d85d71edde15c648fd44490024b5abf22 Mon Sep 17 00:00:00 2001 From: Zachary Chai Date: Tue, 22 Nov 2016 18:16:34 -0500 Subject: [PATCH] generate url with ports --- app/assets/javascripts/landing.js | 15 +++------------ app/assets/javascripts/meeting.coffee | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index 335b510b..fad81029 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -19,6 +19,7 @@ $('.center-panel-wrapper').on ('click', '.meeting-join', function (event) { var name = $('.meeting-user-name').val(); Meeting.getInstance().setName(name); + Meeting.getInstance().setURL(Meeting.buildMeetingURL()); var jqxhr = Meeting.getInstance().getJoinMeetingResponse(); jqxhr.done(function(data) { @@ -136,21 +137,11 @@ e.preventDefault(); var newId = Math.trunc(Math.random() * 1000000000); $(".page-wrapper.meetings").data('id', newId); - var link = window.location.protocol + - '//' + - window.location.hostname + - '/meetings/' + - newId; - $('.meeting-url').val(link); + $('.meeting-url').val(Meeting.buildMeetingURL()); }); if (meetingId = $(".page-wrapper.meetings").data('id')) { - var link = window.location.protocol + - '//' + - window.location.hostname + - '/meetings/' + - meetingId; - $('.meeting-url').val(link) + $('.meeting-url').val(Meeting.getInstance().getURL()); } else { $('.generate-link').click(); } diff --git a/app/assets/javascripts/meeting.coffee b/app/assets/javascripts/meeting.coffee index 7adbd82b..22ff3c51 100644 --- a/app/assets/javascripts/meeting.coffee +++ b/app/assets/javascripts/meeting.coffee @@ -10,7 +10,7 @@ class @Meeting if _meetingInstance return _meetingInstance id = $(".page-wrapper").data('id') - url = @buildURL(id) + url = @buildMeetingURL() name = $('.meeting-user-name').val() _meetingInstance = new Meeting(id, url, name) return _meetingInstance @@ -18,16 +18,17 @@ class @Meeting @clear: -> _meetingInstance = null - @buildURL: (id) -> + @buildMeetingURL: (id) -> if (resource = location.pathname.split('/')[1]) != 'rooms' resource = 'meetings' - return location.protocol + - '//' + - location.hostname + - '/' + - resource + - '/' + - id; + id ||= $(".page-wrapper").data('id') + return @buildFullDomainURL() + '/' + resource + '/' + id + + @buildFullDomainURL: -> + url = location.protocol + '//' + location.hostname + if location.port + url.concat ':' + location.port + return url # Sends the end meeting request # Returns a response object