1
|
|
|
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. |
2
|
|
|
// |
3
|
|
|
// Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). |
4
|
|
|
// |
5
|
|
|
// This program is free software; you can redistribute it and/or modify it under the |
6
|
|
|
// terms of the GNU Lesser General Public License as published by the Free Software |
7
|
|
|
// Foundation; either version 3.0 of the License, or (at your option) any later |
8
|
|
|
// version. |
9
|
|
|
// |
10
|
|
|
// BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
11
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
12
|
|
|
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
13
|
|
|
// |
14
|
|
|
// You should have received a copy of the GNU Lesser General Public License along |
15
|
|
|
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. |
16
|
|
|
|
17
|
|
|
$(document).on('turbolinks:load', function(){ |
18
|
|
|
var controller = $("body").data('controller'); |
19
|
|
|
var action = $("body").data('action'); |
20
|
|
|
|
21
|
|
|
if ((controller == "admins" && action == "index") || |
22
|
|
|
(controller == "rooms" && action == "show") || |
23
|
|
|
(controller == "rooms" && action == "update") || |
24
|
|
|
(controller == "rooms" && action == "join") || |
25
|
|
|
(controller == "users" && action == "recordings")) { |
26
|
|
|
// Submit search if the user hits enter |
27
|
|
|
$("#search-input").keypress(function(key) { |
28
|
|
|
var keyPressed = key.which |
29
|
|
|
if (keyPressed == 13) { |
30
|
|
|
searchPage() |
31
|
|
|
} |
32
|
|
|
}) |
33
|
|
|
|
34
|
|
|
// Add listeners for sort |
35
|
|
|
$("th[data-order]").click(function(data){ |
36
|
|
|
var header_elem = $(data.target) |
37
|
|
|
var controller = $("body").data('controller'); |
38
|
|
|
var action = $("body").data('action'); |
39
|
|
|
|
40
|
|
|
if(header_elem.data('order') === 'asc'){ // asc |
41
|
|
|
header_elem.data('order', 'desc'); |
42
|
|
|
} |
43
|
|
|
else if(header_elem.data('order') === 'desc'){ // desc |
44
|
|
|
header_elem.data('order', 'none'); |
45
|
|
|
} |
46
|
|
|
else{ // none |
47
|
|
|
header_elem.data('order', 'asc'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
var search = $("#search-input").val(); |
51
|
|
|
|
52
|
|
|
if(controller === "rooms" && action === "show"){ |
53
|
|
|
window.location.replace(window.location.pathname + "?page=1&search=" + search + |
54
|
|
|
"&column=" + header_elem.data("header") + "&direction="+ header_elem.data('order') + |
55
|
|
|
"#recordings-table"); |
56
|
|
|
} |
57
|
|
|
else{ |
58
|
|
|
window.location.replace(window.location.pathname + "?page=1&search=" + search + |
59
|
|
|
"&column=" + header_elem.data("header") + "&direction="+ header_elem.data('order')); |
60
|
|
|
} |
61
|
|
|
}) |
62
|
|
|
|
63
|
|
|
if(controller === "rooms" && action === "show"){ |
64
|
|
|
$(".page-item > a").each(function(){ |
65
|
|
|
if(!$(this).attr('href').endsWith("#")){ |
66
|
|
|
$(this).attr('href', $(this).attr('href') + "#recordings-table") |
67
|
|
|
} |
68
|
|
|
}) |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
}) |
72
|
|
|
|
73
|
|
|
// Searches the user table for the given string |
74
|
|
|
function searchPage() { |
75
|
|
|
var search = $("#search-input").val(); |
76
|
|
|
|
77
|
|
|
var controller = $("body").data('controller'); |
78
|
|
|
var action = $("body").data('action'); |
79
|
|
|
|
80
|
|
|
if(controller === "rooms" && action === "show"){ |
81
|
|
|
window.location.replace(window.location.pathname + "?page=1&search=" + search + "#recordings-table"); |
82
|
|
|
} else{ |
83
|
|
|
window.location.replace(window.location.pathname + "?page=1&search=" + search); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
// Clears the search bar |
89
|
|
|
function clearSearch() { |
90
|
|
|
var controller = $("body").data('controller'); |
91
|
|
|
var action = $("body").data('action'); |
92
|
|
|
|
93
|
|
|
if(controller === "rooms" && action === "show"){ |
94
|
|
|
window.location.replace(window.location.pathname + "?page=1" + "#recordings-table"); |
95
|
|
|
} else{ |
96
|
|
|
window.location.replace(window.location.pathname + "?page=1"); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|