forked from External/greenlight
* Fixed issue with recording length and sort * Made js run on any page with a table element on it * Scrutinizer fix
This commit is contained in:
committed by
Jesus Federico
parent
95a98f6574
commit
4d648534f7
@ -121,7 +121,7 @@ $(document).on('turbolinks:load', function(){
|
||||
submit_update_request({
|
||||
setting: "rename_header",
|
||||
room_name: element.find('#user-text').text(),
|
||||
});
|
||||
}, element.data('path'));
|
||||
}
|
||||
else if(element.is('#recording-title')){
|
||||
submit_update_request({
|
||||
@ -129,27 +129,15 @@ $(document).on('turbolinks:load', function(){
|
||||
record_id: element.data('recordid'),
|
||||
record_name: element.find('text').text(),
|
||||
room_uid: element.data('room-uid'),
|
||||
});
|
||||
}, element.data('path'));
|
||||
}
|
||||
}
|
||||
|
||||
// Helper for submitting ajax requests
|
||||
var submit_update_request = function(data){
|
||||
var update_path = window.location.pathname
|
||||
|
||||
if ('room_uid' in data) {
|
||||
update_path = $("body").data('relative-root')
|
||||
|
||||
if (!update_path.endsWith("/")) {
|
||||
update_path += "/"
|
||||
}
|
||||
|
||||
update_path += data.room_uid
|
||||
}
|
||||
|
||||
var submit_update_request = function(data, path){
|
||||
// Send ajax request for update
|
||||
$.ajax({
|
||||
url: update_path,
|
||||
url: path,
|
||||
type: "PATCH",
|
||||
data: data,
|
||||
});
|
||||
|
@ -15,16 +15,14 @@
|
||||
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$(document).on('turbolinks:load', function(){
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
|
||||
if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update"){
|
||||
// Check if there is a table on this page
|
||||
if ($("table").length) {
|
||||
|
||||
// Choose active header
|
||||
// (Name, Length or Users)
|
||||
$('th').each(function(){
|
||||
if($(this).data("header")){
|
||||
$(this).on('click', function(){
|
||||
$(this).on('click', function(){
|
||||
set_active_header($(this).data("header"));
|
||||
sort_by($(this).data("header"), $(this).data('order'));
|
||||
});
|
||||
@ -80,8 +78,14 @@ $(document).on('turbolinks:load', function(){
|
||||
// Generalized function for sorting recordings
|
||||
var sort_recordings = function(recording_list_tbody, order, recording_id){
|
||||
recording_list_tbody.find('tr').sort(function(a, b){
|
||||
var a_val = $.trim($(a).find(recording_id).text());
|
||||
var b_val = $.trim($(b).find(recording_id).text());
|
||||
var a_val, b_val;
|
||||
if (recording_id == "#recording-length") {
|
||||
a_val = $.trim($(a).find(recording_id).data("full-length"));
|
||||
b_val = $.trim($(b).find(recording_id).data("full-length"));
|
||||
} else {
|
||||
a_val = $.trim($(a).find(recording_id).text());
|
||||
b_val = $.trim($(b).find(recording_id).text());
|
||||
}
|
||||
|
||||
if(order === "asc"){
|
||||
return a_val.localeCompare(b_val);
|
||||
@ -89,6 +93,8 @@ $(document).on('turbolinks:load', function(){
|
||||
else if(order === "desc"){
|
||||
return b_val.localeCompare(a_val);
|
||||
}
|
||||
|
||||
|
||||
}).appendTo(recording_list_tbody);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user