refactor meeting object naming

This commit is contained in:
Zachary Chai 2017-01-24 14:25:25 -05:00
parent e339dcd5b7
commit b30acae006
3 changed files with 20 additions and 20 deletions

View File

@ -41,8 +41,8 @@
// setup event handlers // setup event handlers
$('.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().setUserName(name);
Meeting.getInstance().setId($(".page-wrapper").data('id')); Meeting.getInstance().setMeetingId($(".page-wrapper").data('id'));
// a user name is set, join the user into the session // a user name is set, join the user into the session
if (name !== undefined && name !== null) { if (name !== undefined && name !== null) {
@ -159,7 +159,7 @@
$('.generate-link').click (function (e) { $('.generate-link').click (function (e) {
e.preventDefault(); e.preventDefault();
var newId = Math.trunc(Math.random() * 1000000000); var newId = Math.trunc(Math.random() * 1000000000);
Meeting.getInstance().setId(newId); Meeting.getInstance().setMeetingId(newId);
$(".page-wrapper.meetings").data('id', newId); $(".page-wrapper.meetings").data('id', newId);
$('.meeting-url').val(Meeting.getInstance().getURL()); $('.meeting-url').val(Meeting.getInstance().getURL());
}); });

View File

@ -19,7 +19,7 @@
_meetingInstance = null _meetingInstance = null
class @Meeting class @Meeting
constructor: (@id, @type, @name) -> constructor: (@meetingId, @type, @userName) ->
# Gets the current instance or creates a new one # Gets the current instance or creates a new one
@getInstance: -> @getInstance: ->
@ -56,28 +56,28 @@ class @Meeting
# Returns a response object # Returns a response object
# The response object contains the URL to join the meeting # The response object contains the URL to join the meeting
getJoinMeetingResponse: -> getJoinMeetingResponse: ->
return $.get @getURL() + "/join?name=" + @name, (data) => return $.get @getURL() + "/join?name=" + @userName, (data) =>
if data.messageKey == 'ok' && @type == 'meetings' if data.messageKey == 'ok' && @type == 'meetings'
# update name used to join meeting # update name used to join meeting
localStorage.setItem('lastJoinedName', @getName()) localStorage.setItem('lastJoinedName', @getUserName())
# update previously joined meetings on client # update previously joined meetings on client
try try
joinedMeetings = localStorage.getItem('joinedMeetings') || '' joinedMeetings = localStorage.getItem('joinedMeetings') || ''
joinedMeetings = joinedMeetings.split(',') joinedMeetings = joinedMeetings.split(',')
joinedMeetings = joinedMeetings.filter (item) => item != @id.toString() joinedMeetings = joinedMeetings.filter (item) => item != @meetingId.toString()
if joinedMeetings.length >= 5 if joinedMeetings.length >= 5
joinedMeetings.splice(0, 1) joinedMeetings.splice(0, 1)
joinedMeetings.push(@id) joinedMeetings.push(@meetingId)
localStorage.setItem('joinedMeetings', joinedMeetings.join(',')) localStorage.setItem('joinedMeetings', joinedMeetings.join(','))
catch err catch err
localStorage.setItem('joinedMeetings', @id) localStorage.setItem('joinedMeetings', @meetingId)
getId: -> getMeetingId: ->
return @id return @meetingId
setId: (id) -> setMeetingId: (id) ->
@id = id @meetingId = id
return this return this
getType: -> getType: ->
@ -88,13 +88,13 @@ class @Meeting
return this return this
getURL: -> getURL: ->
return Meeting.buildMeetingURL(@id, @type) return Meeting.buildMeetingURL(@meetingId, @type)
getName: -> getUserName: ->
return @name return @userName
setName: (name) -> setUserName: (name) ->
@name = name @userName = name
return this return this
getModJoined: -> getModJoined: ->

View File

@ -80,7 +80,7 @@ class @Recordings
targets: -1, targets: -1,
render: (data, type, row) -> render: (data, type, row) ->
if type == 'display' if type == 'display'
roomName = Meeting.getInstance().getId() roomName = Meeting.getInstance().getMeetingId()
recordingActions = $('.hidden-elements').find('.recording-actions') recordingActions = $('.hidden-elements').find('.recording-actions')
classes = ['recording-unpublished', 'recording-unlisted', 'recording-published'] classes = ['recording-unpublished', 'recording-unlisted', 'recording-published']
if row.published if row.published
@ -157,7 +157,7 @@ class @Recordings
# refresh the recordings from the server # refresh the recordings from the server
refresh: -> refresh: ->
table_api = this.table.api() table_api = this.table.api()
$.get "/rooms/"+Meeting.getInstance().getId()+"/recordings", (data) => $.get "/rooms/"+Meeting.getInstance().getMeetingId()+"/recordings", (data) =>
@setOwner(data.is_owner) @setOwner(data.is_owner)
if !@owner if !@owner
table_api.column(-1).visible(false) table_api.column(-1).visible(false)