1
|
|
|
/** |
2
|
|
|
* JavaScript library for the bigbluebuttonbn module. |
3
|
|
|
* |
4
|
|
|
* @package mod |
5
|
|
|
* @subpackage bigbluebuttonbn |
6
|
|
|
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
7
|
|
|
* @copyright 2012-2016 Blindside Networks Inc. |
8
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
/** global: M */ |
12
|
|
|
/** global: Y */ |
13
|
|
|
/** global: bigbluebuttonbn */ |
14
|
|
|
|
15
|
|
|
M.mod_bigbluebuttonbn = M.mod_bigbluebuttonbn || {}; |
16
|
|
|
|
17
|
|
|
var bigbluebuttonbn_ds; |
18
|
|
|
var bigbluebuttonbn_ping; |
19
|
|
|
var bigbluebuttonbn_panel; |
20
|
|
|
|
21
|
|
|
M.mod_bigbluebuttonbn.datasource_init = function(Y) { |
22
|
|
|
bigbluebuttonbn_ds = new Y.DataSource.Get({ |
23
|
|
|
source: M.cfg.wwwroot + "/mod/bigbluebuttonbn/bbb_broker.php?" |
24
|
|
|
}); |
25
|
|
|
}; |
26
|
|
|
|
27
|
|
|
M.mod_bigbluebuttonbn.datatable_init = function() { |
28
|
|
|
/* global bigbluebuttonbn */ |
29
|
|
|
|
30
|
|
|
var options = { |
31
|
|
|
weekday: 'long', |
32
|
|
|
year: 'numeric', |
33
|
|
|
month: 'long', |
34
|
|
|
day: 'numeric' |
35
|
|
|
}; |
36
|
|
|
for (var i = 0; i < bigbluebuttonbn.data.length; i++) { |
37
|
|
|
var date = new Date(bigbluebuttonbn.data[i].date); |
38
|
|
|
bigbluebuttonbn.data[i].date = date.toLocaleDateString(bigbluebuttonbn.locale, options); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
YUI({ |
42
|
|
|
lang: bigbluebuttonbn.locale |
43
|
|
|
}).use('datatable', 'datatable-sort', 'datatable-paginator', 'datatype-number', function(Y) { |
44
|
|
|
var table = new Y.DataTable({ |
45
|
|
|
width: "1075px", |
46
|
|
|
columns: bigbluebuttonbn.columns, |
47
|
|
|
data: bigbluebuttonbn.data, |
48
|
|
|
rowsPerPage: 10, |
49
|
|
|
paginatorLocation: ['header', 'footer'] |
50
|
|
|
}).render('#bigbluebuttonbn_yui_table'); |
51
|
|
|
return table; |
52
|
|
|
}); |
53
|
|
|
}; |
54
|
|
|
|
55
|
|
|
M.mod_bigbluebuttonbn.import_view_init = function(Y) { |
56
|
|
|
/* global bigbluebuttonbn */ |
57
|
|
|
|
58
|
|
|
// Init general datasource. |
59
|
|
|
M.mod_bigbluebuttonbn.datasource_init(Y); |
60
|
|
|
|
61
|
|
|
// Init event listener for course selector. |
62
|
|
|
Y.one('#menuimport_recording_links_select').on('change', function() { |
63
|
|
|
var endpoint = '/mod/bigbluebuttonbn/import_view.php'; |
64
|
|
|
var qs = '?bn=' + bigbluebuttonbn.bn + '&tc=' + this.get('value'); |
65
|
|
|
Y.config.win.location = M.cfg.wwwroot + endpoint + qs; |
66
|
|
|
}); |
67
|
|
|
}; |
68
|
|
|
|
69
|
|
|
M.mod_bigbluebuttonbn.view_init = function(Y) { |
70
|
|
|
/* global bigbluebuttonbn */ |
71
|
|
|
|
72
|
|
|
// Init general datasource. |
73
|
|
|
M.mod_bigbluebuttonbn.datasource_init(Y); |
74
|
|
|
|
75
|
|
|
if (bigbluebuttonbn.profile_features.includes('all') || bigbluebuttonbn.profile_features.includes('showroom')) { |
76
|
|
|
|
77
|
|
|
if (bigbluebuttonbn.activity === 'open') { |
78
|
|
|
// Create the main modal form. |
79
|
|
|
bigbluebuttonbn_panel = new Y.Panel({ |
80
|
|
|
srcNode: '#panelContent', |
81
|
|
|
headerContent: bigbluebuttonbn.locales.modal_title, |
82
|
|
|
width: 250, |
83
|
|
|
zIndex: 5, |
84
|
|
|
centered: true, |
85
|
|
|
modal: true, |
86
|
|
|
visible: false, |
87
|
|
|
render: true, |
88
|
|
|
plugins: [Y.Plugin.Drag] |
89
|
|
|
}); |
90
|
|
|
|
91
|
|
|
// Define the apply function - this will be called when 'Apply' is pressed in the modal form. |
92
|
|
|
bigbluebuttonbn_panel.addButton({ |
93
|
|
|
value: bigbluebuttonbn.locales.modal_button, |
94
|
|
|
section: Y.WidgetStdMod.FOOTER, |
95
|
|
|
action: function(e) { |
96
|
|
|
e.preventDefault(); |
97
|
|
|
bigbluebuttonbn_panel.hide(); |
98
|
|
|
|
99
|
|
|
var joinField = Y.one('#meeting_join_url'); |
100
|
|
|
var messageField = Y.one('#meeting_message'); |
101
|
|
|
var nameField = Y.one('#recording_name'); |
102
|
|
|
var descriptionField = Y.one('#recording_description'); |
103
|
|
|
var tagsField = Y.one('#recording_tags'); |
104
|
|
|
|
105
|
|
|
// Gatter the fields thay will be passed as metaparameters to the bbb server. |
106
|
|
|
var name = nameField.get('value').replace(/</g, "<").replace(/>/g, ">"); |
107
|
|
|
var description = descriptionField.get('value').replace(/</g, "<").replace(/>/g, ">"); |
108
|
|
|
var tags = tagsField.get('value').replace(/</g, "<").replace(/>/g, ">"); |
109
|
|
|
|
110
|
|
|
// Prepare the new join_url. |
111
|
|
|
var join_url = joinField.get('value') + '&name=' + name + '&description=' + description + '&tags=' + tags; |
112
|
|
|
|
113
|
|
|
// Executes the join. |
114
|
|
|
M.mod_bigbluebuttonbn.broker_executeJoin(join_url, messageField.get('value')); |
115
|
|
|
|
116
|
|
|
// Clean values in case the for is used again. |
117
|
|
|
nameField.set('value', ''); |
118
|
|
|
descriptionField.set('value', ''); |
119
|
|
|
tagsField.set('value', ''); |
120
|
|
|
joinField.set('value', ''); |
121
|
|
|
messageField.set('value', ''); |
122
|
|
|
} |
123
|
|
|
}); |
124
|
|
|
|
125
|
|
|
M.mod_bigbluebuttonbn.view_update(); |
126
|
|
|
} else { |
127
|
|
|
if (bigbluebuttonbn.activity === 'ended') { |
128
|
|
|
Y.DOM.addHTML(Y.one('#status_bar'), M.mod_bigbluebuttonbn.view_init_status_bar( |
129
|
|
|
bigbluebuttonbn.locales.conference_ended |
130
|
|
|
)); |
131
|
|
|
} else { |
132
|
|
|
Y.DOM.addHTML(Y.one('#status_bar'), M.mod_bigbluebuttonbn.view_init_status_bar( |
133
|
|
|
[bigbluebuttonbn.locales.conference_ended, bigbluebuttonbn.opening, bigbluebuttonbn.closing] |
134
|
|
|
)); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
if (bigbluebuttonbn.recordings_html === false && |
140
|
|
|
(bigbluebuttonbn.profile_features.includes('all') || bigbluebuttonbn.profile_features.includes('showrecordings'))) { |
141
|
|
|
M.mod_bigbluebuttonbn.datatable_init(Y); |
142
|
|
|
} |
143
|
|
|
}; |
144
|
|
|
|
145
|
|
|
M.mod_bigbluebuttonbn.view_update = function() { |
146
|
|
|
/* global bigbluebuttonbn */ |
147
|
|
|
|
148
|
|
|
var status_bar = Y.one('#status_bar'); |
149
|
|
|
var control_panel = Y.one('#control_panel'); |
150
|
|
|
var join_button = Y.one('#join_button'); |
151
|
|
|
var end_button = Y.one('#end_button'); |
152
|
|
|
|
153
|
|
|
bigbluebuttonbn_ds.sendRequest({ |
154
|
|
|
request: 'action=meeting_info&id=' + bigbluebuttonbn.meetingid + '&bigbluebuttonbn=' + bigbluebuttonbn.bigbluebuttonbnid, |
155
|
|
|
callback: { |
156
|
|
|
success: function(e) { |
157
|
|
|
Y.DOM.addHTML(status_bar, M.mod_bigbluebuttonbn.view_init_status_bar(e.data.status.message)); |
158
|
|
|
Y.DOM.addHTML(control_panel, M.mod_bigbluebuttonbn.view_init_control_panel(e.data)); |
159
|
|
|
if (typeof e.data.status.can_join != 'undefined') { |
160
|
|
|
Y.DOM.addHTML(join_button, M.mod_bigbluebuttonbn.view_init_join_button(e.data.status)); |
161
|
|
|
} |
162
|
|
|
if (typeof e.data.status.can_end != 'undefined' && e.data.status.can_end) { |
163
|
|
|
Y.DOM.addHTML(end_button, M.mod_bigbluebuttonbn.view_init_end_button(e.data.status)); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
}); |
168
|
|
|
}; |
169
|
|
|
|
170
|
|
|
M.mod_bigbluebuttonbn.view_clean = function() { |
171
|
|
|
M.mod_bigbluebuttonbn.view_clean_status_bar(); |
172
|
|
|
M.mod_bigbluebuttonbn.view_clean_control_panel(); |
173
|
|
|
M.mod_bigbluebuttonbn.view_clean_join_button(); |
174
|
|
|
M.mod_bigbluebuttonbn.view_clean_end_button(); |
175
|
|
|
}; |
176
|
|
|
|
177
|
|
|
M.mod_bigbluebuttonbn.view_remote_update = function(delay) { |
178
|
|
|
setTimeout(function() { |
179
|
|
|
M.mod_bigbluebuttonbn.view_clean(); |
180
|
|
|
M.mod_bigbluebuttonbn.view_update(); |
181
|
|
|
}, delay); |
182
|
|
|
}; |
183
|
|
|
|
184
|
|
|
M.mod_bigbluebuttonbn.view_init_status_bar = function(status_message) { |
185
|
|
|
var status_bar_span = Y.DOM.create('<span>'); |
186
|
|
|
|
187
|
|
|
if (status_message.constructor === Array) { |
188
|
|
|
for (var message in status_message) { |
189
|
|
|
if (!status_message.hasOwnProperty(message)) { |
190
|
|
|
continue; // Skip keys from the prototype. |
191
|
|
|
} |
192
|
|
|
var status_bar_span_span = Y.DOM.create('<span>'); |
193
|
|
|
Y.DOM.setAttribute(status_bar_span_span, 'id', 'status_bar_span_span'); |
194
|
|
|
Y.DOM.setText(status_bar_span_span, status_message[message]); |
195
|
|
|
Y.DOM.addHTML(status_bar_span, status_bar_span_span); |
196
|
|
|
Y.DOM.addHTML(status_bar_span, Y.DOM.create('<br>')); |
197
|
|
|
} |
198
|
|
|
} else { |
199
|
|
|
Y.DOM.setAttribute(status_bar_span, 'id', 'status_bar_span'); |
200
|
|
|
Y.DOM.setText(status_bar_span, status_message); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
return (status_bar_span); |
204
|
|
|
}; |
205
|
|
|
|
206
|
|
|
M.mod_bigbluebuttonbn.view_init_control_panel = function(data) { |
207
|
|
|
var control_panel_div = Y.DOM.create('<div>'); |
208
|
|
|
|
209
|
|
|
Y.DOM.setAttribute(control_panel_div, 'id', 'control_panel_div'); |
210
|
|
|
var control_panel_div_html = ''; |
211
|
|
|
if (data.running) { |
212
|
|
|
control_panel_div_html += M.mod_bigbluebuttonbn.view_msg_started_at(data.info.startTime) + ' '; |
213
|
|
|
control_panel_div_html += M.mod_bigbluebuttonbn.view_msg_attendees_in(data.info.moderatorCount, |
214
|
|
|
data.info.participantCount); |
215
|
|
|
} |
216
|
|
|
Y.DOM.addHTML(control_panel_div, control_panel_div_html); |
217
|
|
|
|
218
|
|
|
return (control_panel_div); |
219
|
|
|
}; |
220
|
|
|
|
221
|
|
|
M.mod_bigbluebuttonbn.view_msg_started_at = function(startTime) { |
222
|
|
|
/* global bigbluebuttonbn */ |
223
|
|
|
|
224
|
|
|
var start_timestamp = (parseInt(startTime) - parseInt(startTime) % 1000); |
225
|
|
|
var date = new Date(start_timestamp); |
226
|
|
|
var hours = date.getHours(); |
227
|
|
|
var minutes = date.getMinutes(); |
228
|
|
|
|
229
|
|
|
return bigbluebuttonbn.locales.started_at + ' <b>' + hours + ':' + (minutes < 10 ? '0' : '') + minutes + '</b>.'; |
230
|
|
|
}; |
231
|
|
|
|
232
|
|
|
M.mod_bigbluebuttonbn.view_msg_users_joined = function(participantCount) { |
233
|
|
|
/* global bigbluebuttonbn */ |
234
|
|
|
|
235
|
|
|
var participants = parseInt(participantCount); |
236
|
|
|
var msg_users_joined = '<b>' + participants + '</b> '; |
237
|
|
|
if (participants == 1) { |
238
|
|
|
msg_users_joined += bigbluebuttonbn.locales.user + ' ' + bigbluebuttonbn.locales.has_joined + '.'; |
239
|
|
|
} else { |
240
|
|
|
msg_users_joined += bigbluebuttonbn.locales.users + ' ' + bigbluebuttonbn.locales.have_joined + '.'; |
241
|
|
|
} |
242
|
|
|
return msg_users_joined; |
243
|
|
|
}; |
244
|
|
|
|
245
|
|
|
M.mod_bigbluebuttonbn.view_msg_attendees_in = function(moderators, participants) { |
246
|
|
|
/* global bigbluebuttonbn */ |
247
|
|
|
|
248
|
|
|
if (typeof moderators == 'undefined' && typeof participants == 'undefined') { |
249
|
|
|
return bigbluebuttonbn.locales.session_no_users + '.'; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
var viewers = participants - moderators; |
253
|
|
|
|
254
|
|
|
if (participants == 1) { |
255
|
|
|
if (viewers > 0) { |
256
|
|
|
return bigbluebuttonbn.locales.session_has_user + ' <b>1</b> ' + bigbluebuttonbn.locales.viewer + '.'; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
return bigbluebuttonbn.locales.session_has_user + ' <b>1</b> ' + bigbluebuttonbn.locales.moderator + '.'; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
var msg = bigbluebuttonbn.locales.session_has_users; |
263
|
|
|
|
264
|
|
|
var msg_moderators = bigbluebuttonbn.locales.moderators; |
265
|
|
|
if (moderators == 1) { |
266
|
|
|
msg_moderators = bigbluebuttonbn.locales.moderator; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
var msg_viewers = bigbluebuttonbn.locales.viewers; |
270
|
|
|
if (moderators == 1) { |
271
|
|
|
msg_viewers = bigbluebuttonbn.locales.viewer; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
return msg + ' <b>' + moderators + '</b> ' + msg_moderators + ' and <b>' + viewers + '</b> ' + msg_viewers + '.'; |
275
|
|
|
}; |
276
|
|
|
|
277
|
|
|
M.mod_bigbluebuttonbn.view_init_join_button = function(status) { |
278
|
|
|
var join_button_input = Y.DOM.create('<input>'); |
279
|
|
|
|
280
|
|
|
Y.DOM.setAttribute(join_button_input, 'id', 'join_button_input'); |
281
|
|
|
Y.DOM.setAttribute(join_button_input, 'type', 'button'); |
282
|
|
|
Y.DOM.setAttribute(join_button_input, 'value', status.join_button_text); |
283
|
|
|
|
284
|
|
|
if (status.can_join) { |
285
|
|
|
var input_html = 'M.mod_bigbluebuttonbn.broker_joinNow(\''; |
286
|
|
|
input_html += status.join_url + '\', \'' + bigbluebuttonbn.locales.in_progress; |
287
|
|
|
input_html += '\', ' + status.can_tag + ');'; |
288
|
|
|
Y.DOM.setAttribute(join_button_input, 'onclick', input_html); |
289
|
|
|
} else { |
290
|
|
|
Y.DOM.setAttribute(join_button_input, 'disabled', true); |
291
|
|
|
M.mod_bigbluebuttonbn.broker_waitModerator(status.join_url); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
return join_button_input; |
295
|
|
|
}; |
296
|
|
|
|
297
|
|
|
M.mod_bigbluebuttonbn.view_init_end_button = function(status) { |
298
|
|
|
var end_button_input = Y.DOM.create('<input>'); |
299
|
|
|
|
300
|
|
|
Y.DOM.setAttribute(end_button_input, 'id', 'end_button_input'); |
301
|
|
|
Y.DOM.setAttribute(end_button_input, 'type', 'button'); |
302
|
|
|
Y.DOM.setAttribute(end_button_input, 'value', status.end_button_text); |
303
|
|
|
if (status.can_end) { |
304
|
|
|
Y.DOM.setAttribute(end_button_input, 'onclick', 'M.mod_bigbluebuttonbn.broker_endMeeting();'); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return end_button_input; |
308
|
|
|
}; |
309
|
|
|
|
310
|
|
|
|
311
|
|
|
M.mod_bigbluebuttonbn.view_clean_status_bar = function() { |
312
|
|
|
Y.one('#status_bar_span').remove(); |
313
|
|
|
}; |
314
|
|
|
|
315
|
|
|
M.mod_bigbluebuttonbn.view_clean_control_panel = function() { |
316
|
|
|
Y.one('#control_panel_div').remove(); |
317
|
|
|
}; |
318
|
|
|
|
319
|
|
|
M.mod_bigbluebuttonbn.view_clean_join_button = function() { |
320
|
|
|
Y.one('#join_button').setContent(''); |
321
|
|
|
}; |
322
|
|
|
|
323
|
|
|
M.mod_bigbluebuttonbn.view_hide_join_button = function() { |
324
|
|
|
Y.DOM.setStyle(Y.one('#join_button'), 'visibility', 'hidden'); |
325
|
|
|
}; |
326
|
|
|
|
327
|
|
|
M.mod_bigbluebuttonbn.view_show_join_button = function() { |
328
|
|
|
Y.DOM.setStyle(Y.one('#join_button'), 'visibility', 'shown'); |
329
|
|
|
}; |
330
|
|
|
|
331
|
|
|
M.mod_bigbluebuttonbn.view_clean_end_button = function() { |
332
|
|
|
Y.one('#end_button').setContent(''); |
333
|
|
|
}; |
334
|
|
|
|
335
|
|
|
M.mod_bigbluebuttonbn.view_hide_end_button = function() { |
336
|
|
|
Y.DOM.setStyle(Y.one('#end_button'), 'visibility', 'hidden'); |
337
|
|
|
}; |
338
|
|
|
|
339
|
|
|
M.mod_bigbluebuttonbn.view_show_end_button = function() { |
340
|
|
|
Y.DOM.setStyle(Y.one('#end_button'), 'visibility', 'shown'); |
341
|
|
|
}; |
342
|
|
|
|
343
|
|
|
M.mod_bigbluebuttonbn.view_windowClose = function() { |
344
|
|
|
window.onunload = function() { |
345
|
|
|
/* global: opener */ |
346
|
|
|
opener.M.mod_bigbluebuttonbn.view_remote_update(5000); |
347
|
|
|
}; |
348
|
|
|
window.close(); |
349
|
|
|
}; |
350
|
|
|
|
351
|
|
|
M.mod_bigbluebuttonbn.broker_waitModerator = function() { |
352
|
|
|
/* global bigbluebuttonbn */ |
353
|
|
|
|
354
|
|
|
// Show the spinning wheel. |
355
|
|
|
var status_bar_span = Y.one('#status_bar_span'); |
356
|
|
|
// Create a img element. |
357
|
|
|
var spinning_wheel = Y.DOM.create('<img>'); |
358
|
|
|
Y.DOM.setAttribute(spinning_wheel, 'id', 'spinning_wheel'); |
359
|
|
|
Y.DOM.setAttribute(spinning_wheel, 'src', 'pix/processing16.gif'); |
360
|
|
|
// Add the spinning wheel. |
361
|
|
|
Y.DOM.addHTML(status_bar_span, ' '); |
362
|
|
|
Y.DOM.addHTML(status_bar_span, spinning_wheel); |
363
|
|
|
|
364
|
|
|
// Start the ping. |
365
|
|
|
bigbluebuttonbn_ping = bigbluebuttonbn_ds.setInterval(bigbluebuttonbn.ping_interval, { |
366
|
|
|
request: "action=meeting_info&id=" + bigbluebuttonbn.meetingid + "&bigbluebuttonbn=" + bigbluebuttonbn.bigbluebuttonbnid, |
367
|
|
|
callback: { |
368
|
|
|
success: function(e) { |
369
|
|
|
if (e.data.running) { |
370
|
|
|
clearInterval(bigbluebuttonbn_ping); |
371
|
|
|
M.mod_bigbluebuttonbn.view_clean(); |
372
|
|
|
M.mod_bigbluebuttonbn.view_update(); |
373
|
|
|
} |
374
|
|
|
}, |
375
|
|
|
failure: function() { |
376
|
|
|
clearInterval(bigbluebuttonbn_ping); |
377
|
|
|
} |
378
|
|
|
} |
379
|
|
|
}); |
380
|
|
|
}; |
381
|
|
|
|
382
|
|
|
M.mod_bigbluebuttonbn.broker_joinNow = function(join_url, status_message, can_tag) { |
383
|
|
|
/* global bigbluebuttonbn */ |
384
|
|
|
var qs = ''; |
385
|
|
|
|
386
|
|
|
if (can_tag) { |
387
|
|
|
Y.one('#panelContent').removeClass('hidden'); |
388
|
|
|
qs += 'action=meeting_info'; |
389
|
|
|
qs += '&id=' + bigbluebuttonbn.meetingid; |
390
|
|
|
qs += '&bigbluebuttonbn=' + bigbluebuttonbn.bigbluebuttonbnid; |
391
|
|
|
bigbluebuttonbn_ds.sendRequest({ |
392
|
|
|
request: qs, |
393
|
|
|
callback: { |
394
|
|
|
success: function(e) { |
395
|
|
|
if (e.data.running) { |
396
|
|
|
M.mod_bigbluebuttonbn.broker_executeJoin(join_url, e.data.status.message); |
397
|
|
|
} else { |
398
|
|
|
Y.one('#meeting_join_url').set('value', join_url); |
399
|
|
|
Y.one('#meeting_message').set('value', e.data.status.message); |
400
|
|
|
|
401
|
|
|
YUI({ |
402
|
|
|
lang: bigbluebuttonbn.locale |
403
|
|
|
}).use('panel', function() { |
404
|
|
|
bigbluebuttonbn_panel.show(); |
405
|
|
|
}); |
406
|
|
|
} |
407
|
|
|
} |
408
|
|
|
} |
409
|
|
|
}); |
410
|
|
|
|
411
|
|
|
} else { |
412
|
|
|
M.mod_bigbluebuttonbn.broker_executeJoin(join_url); |
413
|
|
|
} |
414
|
|
|
}; |
415
|
|
|
|
416
|
|
|
M.mod_bigbluebuttonbn.broker_executeJoin = function(join_url) { |
417
|
|
|
window.open(join_url); |
418
|
|
|
// Update view. |
419
|
|
|
setTimeout(function() { |
420
|
|
|
M.mod_bigbluebuttonbn.view_clean(); |
421
|
|
|
M.mod_bigbluebuttonbn.view_update(); |
422
|
|
|
}, 15000); |
423
|
|
|
}; |
424
|
|
|
|
425
|
|
|
M.mod_bigbluebuttonbn.broker_actionVerification = function(action, recordingid, meetingid, callback) { |
426
|
|
|
/* global bigbluebuttonbn */ |
427
|
|
|
|
428
|
|
|
var is_imported_link = Y.one('#playbacks-' + recordingid).get('dataset').imported === 'true'; |
429
|
|
|
var data = { |
430
|
|
|
'id': recordingid |
431
|
|
|
}; |
432
|
|
|
var confirm; |
433
|
|
|
|
434
|
|
|
if (!is_imported_link && (action === 'unpublish' || action === 'delete')) { |
435
|
|
|
bigbluebuttonbn_ds.sendRequest({ |
436
|
|
|
request: 'action=recording_links&id=' + recordingid, |
437
|
|
|
callback: { |
438
|
|
|
success: function(e) { |
439
|
|
|
if (e.data.status) { |
440
|
|
|
data.links = e.data.links; |
441
|
|
|
if (e.data.links === 0) { |
442
|
|
|
data.confirmed = true; |
443
|
|
|
} else { |
444
|
|
|
var confirmation_warning = bigbluebuttonbn.locales[action + "_confirmation_warning_p"]; |
445
|
|
|
if (e.data.links == 1) { |
446
|
|
|
confirmation_warning = bigbluebuttonbn.locales[action + "_confirmation_warning_s"]; |
447
|
|
|
} |
448
|
|
|
confirmation_warning = confirmation_warning.replace("{$a}", e.data.links) + '. '; |
449
|
|
|
var recording_type = bigbluebuttonbn.locales.recording; |
450
|
|
|
if (is_imported_link) { |
451
|
|
|
recording_type = bigbluebuttonbn.locales.recording_link; |
452
|
|
|
} |
453
|
|
|
var confirmation = bigbluebuttonbn.locales[action + "_confirmation"].replace("{$a}", recording_type); |
454
|
|
|
|
455
|
|
|
// Create the confirmation dialogue. |
456
|
|
|
confirm = new M.core.confirm({ |
457
|
|
|
modal: true, |
458
|
|
|
centered: true, |
459
|
|
|
question: confirmation_warning + '\n\n' + confirmation |
460
|
|
|
}); |
461
|
|
|
|
462
|
|
|
// If it is confirmed. |
463
|
|
|
confirm.on('complete-yes', function(data, callback) { |
464
|
|
|
data.confirmed = true; |
465
|
|
|
callback(data); |
466
|
|
|
}, this); |
467
|
|
|
} |
468
|
|
|
} else { |
469
|
|
|
data.error = 'Big failiure'; |
470
|
|
|
} |
471
|
|
|
callback(data); |
472
|
|
|
}, |
473
|
|
|
failure: function(e) { |
474
|
|
|
data.error = e.error.message; |
475
|
|
|
callback(data); |
476
|
|
|
} |
477
|
|
|
} |
478
|
|
|
}); |
479
|
|
|
} else if (action === 'import') { |
480
|
|
|
// Create the confirmation dialogue. |
481
|
|
|
confirm = new M.core.confirm({ |
482
|
|
|
modal: true, |
483
|
|
|
centered: true, |
484
|
|
|
question: bigbluebuttonbn.locales.import_confirmation |
485
|
|
|
}); |
486
|
|
|
|
487
|
|
|
// If it is confirmed. |
488
|
|
|
confirm.on('complete-yes', function(data, callback) { |
489
|
|
|
data.confirmed = true; |
490
|
|
|
callback(data); |
491
|
|
|
}, this); |
492
|
|
|
} else { |
493
|
|
|
data.confirmed = true; |
494
|
|
|
callback(data); |
495
|
|
|
} |
496
|
|
|
}; |
497
|
|
|
|
498
|
|
|
M.mod_bigbluebuttonbn.broker_manageRecording = function(action, recordingid, meetingid) { |
499
|
|
|
/* global bigbluebuttonbn */ |
500
|
|
|
|
501
|
|
|
// Before sending the request, let's process a verification. |
502
|
|
|
M.mod_bigbluebuttonbn.broker_actionVerification(action, recordingid, meetingid, function(data) { |
503
|
|
|
if (data.confirmed) { |
504
|
|
|
bigbluebuttonbn_ds.sendRequest({ |
505
|
|
|
request: "action=recording_" + action + "&id=" + recordingid, |
506
|
|
|
callback: { |
507
|
|
|
success: function(e) { |
508
|
|
|
if (action == 'delete') { |
509
|
|
|
Y.one('#recording-td-' + recordingid).remove(); |
510
|
|
|
|
511
|
|
|
} else if (action == 'import') { |
512
|
|
|
Y.one('#recording-td-' + recordingid).remove(); |
513
|
|
|
|
514
|
|
|
} else if (action == 'publish' || action == 'unpublish') { |
515
|
|
|
if (e.data.status == 'true') { |
516
|
|
|
var ping_data = { |
517
|
|
|
action: action, |
518
|
|
|
meetingid: meetingid, |
519
|
|
|
recordingid: recordingid |
520
|
|
|
}; |
521
|
|
|
// Start pooling until the action has been executed. |
522
|
|
|
bigbluebuttonbn_ping = bigbluebuttonbn_ds.setInterval( |
523
|
|
|
bigbluebuttonbn.ping_interval, |
524
|
|
|
M.mod_bigbluebuttonbn.broker_pingRecordingObject(ping_data) |
525
|
|
|
); |
526
|
|
|
} else { |
527
|
|
|
var alert = new M.core.alert({ |
528
|
|
|
message: e.data.message |
529
|
|
|
}); |
530
|
|
|
alert.show(); |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
} |
534
|
|
|
} |
535
|
|
|
}); |
536
|
|
|
} |
537
|
|
|
}); |
538
|
|
|
}; |
539
|
|
|
|
540
|
|
|
M.mod_bigbluebuttonbn.broker_pingRecordingObject = function(data) { |
541
|
|
|
|
542
|
|
|
var btn_action = Y.one('#recording-btn-' + data.action + '-' + data.recordingid); |
543
|
|
|
var btn_action_src_current = btn_action.getAttribute('src'); |
544
|
|
|
var btn_action_src_url = btn_action_src_current.substring(0, btn_action_src_current.length - 4); |
545
|
|
|
btn_action.setAttribute('src', M.cfg.wwwroot + "/mod/bigbluebuttonbn/pix/processing16.gif"); |
546
|
|
|
if (data.action == 'publish') { |
547
|
|
|
btn_action.setAttribute('alt', bigbluebuttonbn.locales.publishing); |
548
|
|
|
btn_action.setAttribute('title', bigbluebuttonbn.locales.publishing); |
549
|
|
|
} else { |
550
|
|
|
btn_action.setAttribute('alt', bigbluebuttonbn.locales.unpublishing); |
551
|
|
|
btn_action.setAttribute('title', bigbluebuttonbn.locales.unpublishing); |
552
|
|
|
} |
553
|
|
|
var link_action = Y.one('#recording-link-' + data.action + '-' + data.recordingid); |
554
|
|
|
var link_action_current_onclick = link_action.getAttribute('onclick'); |
555
|
|
|
link_action.setAttribute('onclick', ''); |
556
|
|
|
|
557
|
|
|
return { |
558
|
|
|
request: "action=recording_info&id=" + data.recordingid + "&idx=" + data.meetingid, |
559
|
|
|
callback: { |
560
|
|
|
success: function(e) { |
561
|
|
|
if (e.data.status !== 'true') { |
562
|
|
|
clearInterval(bigbluebuttonbn_ping); |
563
|
|
|
return; |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
if (data.action === 'publish' && e.data.published === 'true') { |
567
|
|
|
clearInterval(bigbluebuttonbn_ping); |
568
|
|
|
btn_action.setAttribute('id', 'recording-btn-unpublish-' + data.recordingid); |
569
|
|
|
link_action.setAttribute('id', 'recording-link-unpublish-' + data.recordingid); |
570
|
|
|
btn_action.setAttribute('src', btn_action_src_url + 'hide'); |
571
|
|
|
btn_action.setAttribute('alt', bigbluebuttonbn.locales.unpublish); |
572
|
|
|
btn_action.setAttribute('title', bigbluebuttonbn.locales.unpublish); |
573
|
|
|
link_action.setAttribute('onclick', link_action_current_onclick.replace('publish', 'unpublish')); |
574
|
|
|
Y.one('#playbacks-' + data.recordingid).show(); |
575
|
|
|
return; |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
if (data.action === 'unpublish' && e.data.published === 'false') { |
579
|
|
|
clearInterval(bigbluebuttonbn_ping); |
580
|
|
|
btn_action.setAttribute('id', 'recording-btn-publish-' + data.recordingid); |
581
|
|
|
link_action.setAttribute('id', 'recording-link-publish-' + data.recordingid); |
582
|
|
|
btn_action.setAttribute('src', btn_action_src_url + 'show'); |
583
|
|
|
btn_action.setAttribute('alt', bigbluebuttonbn.locales.publish); |
584
|
|
|
btn_action.setAttribute('title', bigbluebuttonbn.locales.publish); |
585
|
|
|
link_action.setAttribute('onclick', link_action_current_onclick.replace('unpublish', 'publish')); |
586
|
|
|
Y.one('#playbacks-' + data.recordingid).hide(); |
587
|
|
|
} |
588
|
|
|
}, |
589
|
|
|
failure: function() { |
590
|
|
|
clearInterval(bigbluebuttonbn_ping); |
591
|
|
|
} |
592
|
|
|
} |
593
|
|
|
}; |
594
|
|
|
}; |
595
|
|
|
|
596
|
|
|
M.mod_bigbluebuttonbn.broker_endMeeting = function() { |
597
|
|
|
/* global bigbluebuttonbn */ |
598
|
|
|
var qs = 'action=meeting_end&id=' + bigbluebuttonbn.meetingid; |
599
|
|
|
qs += '&bigbluebuttonbn=' + bigbluebuttonbn.bigbluebuttonbnid; |
600
|
|
|
bigbluebuttonbn_ds.sendRequest({ |
601
|
|
|
request: qs, |
602
|
|
|
callback: { |
603
|
|
|
success: function(e) { |
604
|
|
|
if (e.data.status) { |
605
|
|
|
M.mod_bigbluebuttonbn.view_clean_control_panel(); |
606
|
|
|
M.mod_bigbluebuttonbn.view_hide_join_button(); |
607
|
|
|
M.mod_bigbluebuttonbn.view_hide_end_button(); |
608
|
|
|
location.reload(); |
609
|
|
|
} |
610
|
|
|
} |
611
|
|
|
} |
612
|
|
|
}); |
613
|
|
|
}; |
614
|
|
|
|