From 31f0e0a3e9aadc621f86fa0616db422f3eaf36b3 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 8 Jun 2017 10:43:06 -0400 Subject: [PATCH] clean active_meetings.js --- app/assets/javascripts/active_meetings.js | 81 ++++++++++++++--------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/app/assets/javascripts/active_meetings.js b/app/assets/javascripts/active_meetings.js index 0427d015..34df9a7f 100644 --- a/app/assets/javascripts/active_meetings.js +++ b/app/assets/javascripts/active_meetings.js @@ -1,35 +1,24 @@ -// Handles action cable events from bbb-webhooks and initial population of active meetings. +// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. +// +// Copyright (c) 2016 BigBlueButton Inc. and by respective authors (see below). +// +// This program is free software; you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation; either version 3.0 of the License, or (at your option) any later +// version. +// +// BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along +// with BigBlueButton; if not, see . + +// Handles live updating and initial population of the previous meetings and active meetings lists on +// the landing page using custom Actioncable events. MEETINGS = {} - -// Only need to register for logged in users. -if($('body').data('current-user')){ - App.messages = App.cable.subscriptions.create('RefreshMeetingsChannel', { - received: function(data) { - console.log('Recieved ' + data['method'] + ' action for ' + data['meeting'] + '.') - if(isPreviouslyJoined(data['meeting'])){ - if(data['method'] == 'create'){ - // Create an empty meeting. - MEETINGS[data['meeting']] = {'name': data['meeting'], - 'participants': 0, - 'moderators': 0} - - renderActiveMeeting(MEETINGS[data['meeting']]) - updatePreviousMeetings(); - } else if(data['method'] == 'destroy'){ - removeActiveMeeting(MEETINGS[data['meeting']]) - PreviousMeetings.append([data['meeting']]) - delete MEETINGS[data['meeting']] - } else if(data['method'] == 'join'){ - handleUser(data, 1) - updateMeetingText(MEETINGS[data['meeting']]) - } else if(data['method'] == 'leave'){ - handleUser(data, -1) - } - } - } - }); -} +LOADING_DELAY = 1250 // milliseconds. updatePreviousMeetings = function(){ $("ul.previously-joined li").each(function(idx, li) { @@ -128,4 +117,34 @@ joinMeeting = function(meeting_name){ } } -if($('body').data('current-user')){ console.log('Populating active meetings.'); setTimeout(initialPopulate, 1250); } +// Only need to register for logged in users. +if($('body').data('current-user')){ + App.messages = App.cable.subscriptions.create('RefreshMeetingsChannel', { + received: function(data) { + console.log('Recieved ' + data['method'] + ' action for ' + data['meeting'] + '.') + if(isPreviouslyJoined(data['meeting'])){ + if(data['method'] == 'create'){ + // Create an empty meeting. + MEETINGS[data['meeting']] = {'name': data['meeting'], + 'participants': 0, + 'moderators': 0} + + renderActiveMeeting(MEETINGS[data['meeting']]) + updatePreviousMeetings(); + } else if(data['method'] == 'destroy'){ + removeActiveMeeting(MEETINGS[data['meeting']]) + PreviousMeetings.append([data['meeting']]) + delete MEETINGS[data['meeting']] + } else if(data['method'] == 'join'){ + handleUser(data, 1) + updateMeetingText(MEETINGS[data['meeting']]) + } else if(data['method'] == 'leave'){ + handleUser(data, -1) + } + } + } + }); + + console.log('Populating active meetings.'); + setTimeout(initialPopulate, LOADING_DELAY); +}