Skip to content

Commit

Permalink
[js-format] applied automatic formatting to js assets (#315)
Browse files Browse the repository at this point in the history
* [js-format] applied cleanup formatting to js assets

* [js-format] applied cleanup formatting to js assets
  • Loading branch information
jfederico authored May 9, 2024
1 parent 5d12848 commit 1f45387
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 145 deletions.
6 changes: 3 additions & 3 deletions app/javascript/channels/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.

window.Cable = require("@rails/actioncable")
window.App = {}
App.cable = Cable.createConsumer()
window.Cable = require("@rails/actioncable");
window.App = {};
App.cable = Cable.createConsumer();
4 changes: 2 additions & 2 deletions app/javascript/channels/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load all the channels within this directory and all subdirectories.
// Channel files must be named *_channel.js.

const channels = require.context('.', true, /_channel\.js$/)
channels.keys().forEach(channels)
const channels = require.context('.', true, /_channel\.js$/);
channels.keys().forEach(channels);
44 changes: 22 additions & 22 deletions app/javascript/packs/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/

$(document).on('turbolinks:load', function(){
$('#copy-icon-group').on('click', function() {
$(document).on('turbolinks:load', function () {
$('#copy-icon-group').on('click', function () {
let useSharedCodeCheckbox = $('#use_shared_code_checkbox');
let inputField = $('#shared_code_field');

Expand All @@ -36,7 +36,7 @@ $(document).on('turbolinks:load', function(){
let copiedText = $('#copied-text');
copiedText.css('display', 'inline');

setTimeout(function() {
setTimeout(function () {
checkIcon.css('display', 'none');
copyIcon.css('display', 'inline-block');
copiedText.css('display', 'none');
Expand All @@ -62,23 +62,23 @@ $(document).on('turbolinks:load', function(){

handleUseSharedCodeCheckbox();

$('#allModerators_checkbox').on('click', function() {
$('#allModerators_checkbox').on('click', function () {
var all_mod_checked = $('#allModerators_checkbox').prop("checked");
if (all_mod_checked){
if (all_mod_checked) {
$('#waitForModerator_checkbox').prop("checked", false);
}
})

$('#waitForModerator_checkbox').on('click', function() {
$('#waitForModerator_checkbox').on('click', function () {
var wait_mod_checked = $('#waitForModerator_checkbox').prop("checked");
if (wait_mod_checked){
if (wait_mod_checked) {
$('#allModerators_checkbox').prop("checked", false);
}
})

function check_record_status(){
function check_record_status() {
var record_checked = $('#record_checkbox').prop("checked");
if (!record_checked){
if (!record_checked) {
$('#allowStartStopRecording_checkbox').prop("checked", false);
$('#allowStartStopRecording_checkbox').prop("disabled", true);
$('#autoStartRecording_checkbox').prop("checked", false);
Expand All @@ -91,33 +91,33 @@ $(document).on('turbolinks:load', function(){

check_record_status(); // check status every time page is loaded

$('#record_checkbox').on('click', function() {
$('#record_checkbox').on('click', function () {
check_record_status();
})

// If shared room is selected, allow the code field to be editable
$('#use_shared_code_checkbox').on('click', function() {
$('#use_shared_code_checkbox').on('click', function () {
var use_shared_code_checked = $('#use_shared_code_checkbox').prop("checked");
if (use_shared_code_checked){
if (use_shared_code_checked) {
$('#shared_code_field').prop("disabled", false);
$('#shared_code_field').val('');
} else {
$('#shared_code_field').prop("disabled", true);
console.log("code_val: = ",$('#room_code_value').val() )
console.log("code_val: = ", $('#room_code_value').val())
$('#shared_code_field').val($('#room_code_value').val());
}
})

function checkSharedCodeCheckboxStatus() {
var sharedcode_checked = $('#use_shared_code_checkbox').prop("checked");
if (!sharedcode_checked){
$('#shared_code_field').prop("disabled", true);
} else {
$('#shared_code_field').prop("disabled", false);
}
}
function checkSharedCodeCheckboxStatus() {
var sharedcode_checked = $('#use_shared_code_checkbox').prop("checked");
if (!sharedcode_checked) {
$('#shared_code_field').prop("disabled", true);
} else {
$('#shared_code_field').prop("disabled", false);
}
}

checkSharedCodeCheckboxStatus();
checkSharedCodeCheckboxStatus();


});
42 changes: 21 additions & 21 deletions app/javascript/packs/meetingInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@

import '../channels/consumer'

$(document).on('turbolinks:load', function(){
$(document).on('turbolinks:load', function () {

var controller = $("body").data('controller');
var action = $("body").data('action');
var chosenRoomId = $("#body").data("chosenroomid");
if (!(controller == "rooms" && action == "meeting_join")){
var chosenRoomId = $("#body").data("chosenroomid");

if (!(controller == "rooms" && action == "meeting_join")) {
App.meetingInfo = App.cable.subscriptions.create({
channel: "MeetingInfoChannel",
room_id: chosenRoomId
}, {
connected: function() {
console.log("Connected to meeting info channel");
channel: "MeetingInfoChannel",
room_id: chosenRoomId
}, {
connected: function () {
console.log("Connected to meeting info channel for [" + chosenRoomId + "]");
},
disconnected: function() {
disconnected: function () {
console.log("Disconnected from meeting info channel");
},
received: function(data) {
received: function (data) {
console.log("Received data from meeting info channel. data: " + JSON.stringify(data));
if (data.meeting_in_progress == true){
if (data.meeting_in_progress == true) {
startTime = data.elapsed_time
start_elapsed_time();
display_participant_count(data.participant_count);
show_elems();
show_elems();
}
if (data.action == "end"){
hide_elements();
if (data.action == "end") {
hide_elements();
}
}
});
Expand All @@ -53,20 +53,20 @@ $(document).on('turbolinks:load', function(){

var startTime = 0;

var show_elems = function(){
var show_elems = function () {
$('#end-meeting-btn').show();
$('#meeting-info-msg').show();
$('#wait-for-mod-msg').hide();
}

var hide_elements = function(){
var hide_elements = function () {
$('#end-meeting-btn').hide();
$('#meeting-info-msg').hide();
$('#wait-for-mod-msg').hide();
}

var display_participant_count = function(participantCount){
if (participantCount == 1){
var display_participant_count = function (participantCount) {
if (participantCount == 1) {
var pplprson = "person";
} else {
var pplprson = "people";
Expand All @@ -75,7 +75,7 @@ var display_participant_count = function(participantCount){
document.getElementById('ppl-or-person-elem').innerHTML = pplprson;
}

var start_elapsed_time = function(){
var start_elapsed_time = function () {
var diff = new Date() - new Date(startTime); // the elapsed time in ms

var secs = Math.floor((diff / 1000) % 60);
Expand All @@ -86,7 +86,7 @@ var start_elapsed_time = function(){
secs = addZeroMaybe(secs);
hrs = addZeroMaybe(hrs);

document.getElementById('elapsed-time-elem').innerHTML = hrs + ":" + mins + ":" + secs;
document.getElementById('elapsed-time-elem').innerHTML = hrs + ":" + mins + ":" + secs;

setTimeout(start_elapsed_time, 500);
}
Expand Down
46 changes: 23 additions & 23 deletions app/javascript/packs/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/

function func(){
function func() {
var controller = $("body").data('controller');
var action = $("body").data('action');

if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update"){
if (controller == "rooms" && action == "show" || controller == "rooms" && action == "update") {

// Set a recording row rename event
var configure_recording_row = function(recording_text, recording_text_id){
var configure_recording_row = function (recording_text, recording_text_id) {

function register_recording_text_event(e){
function register_recording_text_event(e) {
// Remove current window events
$(window).off('mousedown keydown');

Expand All @@ -34,56 +34,56 @@ function func(){
let $input = $('<input type="text"/>').val($el.text().trim()).attr('id', $el.attr('id')).attr('class', $el.attr('class'));
$el.replaceWith($input);

var save = function(){
var save = function () {
let $text = $('<text/>').text($input.val()).attr('class', $input.attr('class'));
$input.replaceWith($text);
submit_rename_request(recording_text);
};

$input.on('blur keyup', function(e) {
if (e.type === 'blur' || e.keyCode === 13) { // keycode is depreciated by still recognized by browsers, it's alt (.key) doesnt work in firefox
$input.on('blur keyup', function (e) {
if (e.type === 'blur' || e.keyCode === 13) { // keycode is depreciated by still recognized by browsers, it's alt (.key) doesnt work in firefox
save();
this.focus();
}
});

// Register the events for being able to exit the input box.
register_window_event(recording_text, recording_text_id, '#edit-record', 'edit-recordid');
}

recording_text.find('a').on('click focusout', function(e){
recording_text.find('a').on('click focusout', function (e) {
register_recording_text_event(e);
});

recording_text.find('#recording-title-text').on('focusout', function(e){
recording_text.find('#recording-title-text').on('focusout', function (e) {
$(window).off('mousedown keydown');
submit_rename_request(recording_text);
});

recording_text.find('#recording-description-text').on('focusout', function(e){
recording_text.find('#recording-description-text').on('focusout', function (e) {
$(window).off('mousedown keydown');
submit_rename_request(recording_text);
});
}

// Register window event to submit new name
// upon click or upon pressing the enter key
var register_window_event = function(element, textfield_id, edit_button_id, edit_button_data){
$(window).on('mousedown keydown', function(clickEvent){
var register_window_event = function (element, textfield_id, edit_button_id, edit_button_data) {
$(window).on('mousedown keydown', function (clickEvent) {

// Return if the text is clicked
if(clickEvent.type == "mousedown" && clickEvent.target.id == textfield_id){
if (clickEvent.type == "mousedown" && clickEvent.target.id == textfield_id) {
return;
}

// Return if the edit icon is clicked
if(clickEvent.type == "mousedown" && $(clickEvent.target).is(edit_button_id) &&
$(clickEvent.target).data(edit_button_data) === element.find(edit_button_id).data(edit_button_data)){
if (clickEvent.type == "mousedown" && $(clickEvent.target).is(edit_button_id) &&
$(clickEvent.target).data(edit_button_data) === element.find(edit_button_id).data(edit_button_data)) {
return;
}

// Check if event is keydown and enter key is not pressed
if(clickEvent.type == "keydown" && clickEvent.which !== 13){
if (clickEvent.type == "keydown" && clickEvent.which !== 13) {
return;
}

Expand All @@ -95,16 +95,16 @@ function func(){
}

// Apply ajax request depending on the element that triggered the event
var submit_rename_request = function(element){
if(element.is('#recording-title')){
var submit_rename_request = function (element) {
if (element.is('#recording-title')) {
submit_update_request({
setting: "rename_recording",
record_id: element.data('recordid'),
record_name: element.find('text').text(),
launch_nonce: element.data('launch-nonce'),
});
}
else if(element.is('#recording-description')){
else if (element.is('#recording-description')) {
submit_update_request({
setting: "describe_recording",
record_id: element.data('recordid'),
Expand All @@ -115,20 +115,20 @@ function func(){
}

// Helper for submitting ajax requests
var submit_update_request = function(data){
var submit_update_request = function (data) {
// Send ajax request for update
$.ajax({
url: window.location.pathname + '/recording/' + data['record_id'] + '/update?launch_nonce=' + data['launch_nonce'],
type: "POST",
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
beforeSend: function (xhr) { xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')) },
data: data,
});
}

var recording_rows = $('#recording-table').find('tr');

// Configure renaming for recording rows
recording_rows.each(function(){
recording_rows.each(function () {
var recording_title = $(this).find('#recording-title');
var recording_description = $(this).find('#recording-description');
configure_recording_row(recording_title, 'recording-title-text');
Expand Down
Loading

0 comments on commit 1f45387

Please sign in to comment.