generate url with ports

This commit is contained in:
Zachary Chai 2016-11-22 18:16:34 -05:00
parent e8cf988604
commit 2f10203d85
2 changed files with 13 additions and 21 deletions

View File

@ -19,6 +19,7 @@
$('.center-panel-wrapper').on ('click', '.meeting-join', function (event) { $('.center-panel-wrapper').on ('click', '.meeting-join', function (event) {
var name = $('.meeting-user-name').val(); var name = $('.meeting-user-name').val();
Meeting.getInstance().setName(name); Meeting.getInstance().setName(name);
Meeting.getInstance().setURL(Meeting.buildMeetingURL());
var jqxhr = Meeting.getInstance().getJoinMeetingResponse(); var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
jqxhr.done(function(data) { jqxhr.done(function(data) {
@ -136,21 +137,11 @@
e.preventDefault(); e.preventDefault();
var newId = Math.trunc(Math.random() * 1000000000); var newId = Math.trunc(Math.random() * 1000000000);
$(".page-wrapper.meetings").data('id', newId); $(".page-wrapper.meetings").data('id', newId);
var link = window.location.protocol + $('.meeting-url').val(Meeting.buildMeetingURL());
'//' +
window.location.hostname +
'/meetings/' +
newId;
$('.meeting-url').val(link);
}); });
if (meetingId = $(".page-wrapper.meetings").data('id')) { if (meetingId = $(".page-wrapper.meetings").data('id')) {
var link = window.location.protocol + $('.meeting-url').val(Meeting.getInstance().getURL());
'//' +
window.location.hostname +
'/meetings/' +
meetingId;
$('.meeting-url').val(link)
} else { } else {
$('.generate-link').click(); $('.generate-link').click();
} }

View File

@ -10,7 +10,7 @@ class @Meeting
if _meetingInstance if _meetingInstance
return _meetingInstance return _meetingInstance
id = $(".page-wrapper").data('id') id = $(".page-wrapper").data('id')
url = @buildURL(id) url = @buildMeetingURL()
name = $('.meeting-user-name').val() name = $('.meeting-user-name').val()
_meetingInstance = new Meeting(id, url, name) _meetingInstance = new Meeting(id, url, name)
return _meetingInstance return _meetingInstance
@ -18,16 +18,17 @@ class @Meeting
@clear: -> @clear: ->
_meetingInstance = null _meetingInstance = null
@buildURL: (id) -> @buildMeetingURL: (id) ->
if (resource = location.pathname.split('/')[1]) != 'rooms' if (resource = location.pathname.split('/')[1]) != 'rooms'
resource = 'meetings' resource = 'meetings'
return location.protocol + id ||= $(".page-wrapper").data('id')
'//' + return @buildFullDomainURL() + '/' + resource + '/' + id
location.hostname +
'/' + @buildFullDomainURL: ->
resource + url = location.protocol + '//' + location.hostname
'/' + if location.port
id; url.concat ':' + location.port
return url
# Sends the end meeting request # Sends the end meeting request
# Returns a response object # Returns a response object