From f7adb67e3e4db424e5374e62ba2e7fb697adbfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Fri, 11 Dec 2020 17:53:33 +0100 Subject: [PATCH 1/5] ES6 conversion --- animations.js | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/animations.js b/animations.js index c1e138b..82f5d68 100644 --- a/animations.js +++ b/animations.js @@ -11,7 +11,7 @@ $(".column").on('click', function() { } - var bounding_box = $(this).get(0).getBoundingClientRect(); + const bounding_box = $(this).get(0).getBoundingClientRect(); $(this).css({ top: bounding_box.top + 'px', left: bounding_box.left -20+ 'px' }); /* Set container to fixed position. Add animation */ @@ -23,7 +23,7 @@ $(".column").on('click', function() { $('
').insertAfter(this); /* To animate the container from full-screen to normal, we need dynamic keyframes */ - var styles = ''; + let styles = ''; styles = '@keyframes outlightbox {'; styles += '0% {'; styles += 'height: 100%;'; @@ -68,15 +68,15 @@ $(".close").on('click', function(e) { try{ - var oldstream = getById('previewWebcam').srcObject; + const oldstream = getById('previewWebcam').srcObject; if (oldstream){ log("old stream found"); - oldstream.getTracks().forEach(function(track) { - track.stop(); - oldstream.removeTrack(track); - log("stopping old track"); - }); + oldstream.getTracks().forEach((track) => { + track.stop(); + oldstream.removeTrack(track); + log("stopping old track"); + }); } activatedPreview=false; } catch (e){ @@ -107,35 +107,35 @@ else if(e.originalEvent.animationName == 'outlightbox') { }); -$('#audioSource').on('mousedown touchend focusin focusout', function(e) { - var state = $('#multiselect-trigger').data('state') || 0; - if( state == 0 ) { - ////open the dropdown - $('#multiselect-trigger').data('state', '1').addClass('open').removeClass('closed'); - $('#multiselect-trigger').find('.chevron').removeClass('bottom'); - $('#multiselect-trigger').parent().find('.multiselect-contents').show(); - $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; - } - // e.preventDefault(); -}); +$('#audioSource').on('mousedown touchend focusin focusout', (_e) => { + const state = $('#multiselect-trigger').data('state') || 0; + if (state == 0) { + ////open the dropdown + $('#multiselect-trigger').data('state', '1').addClass('open').removeClass('closed'); + $('#multiselect-trigger').find('.chevron').removeClass('bottom'); + $('#multiselect-trigger').parent().find('.multiselect-contents').show(); + $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; + $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + } + // e.preventDefault(); + }); -$('#audioSource3').on('mousedown touchend focusin focusout', function(e) { - var state = $('#multiselect-trigger3').attr('data-state') || 0; - if( state == 0 ) { - ////open the dropdown - $('#multiselect-trigger3').attr('data-state', '1').addClass('open').removeClass('closed'); - $('#multiselect-trigger3').find('.chevron').removeClass('bottom'); - $('#multiselect-trigger3').parent().find('.multiselect-contents').show(); - $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; - } - // e.preventDefault(); -}); +$('#audioSource3').on('mousedown touchend focusin focusout', (_e) => { + const state = $('#multiselect-trigger3').attr('data-state') || 0; + if (state == 0) { + ////open the dropdown + $('#multiselect-trigger3').attr('data-state', '1').addClass('open').removeClass('closed'); + $('#multiselect-trigger3').find('.chevron').removeClass('bottom'); + $('#multiselect-trigger3').parent().find('.multiselect-contents').show(); + $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; + $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + } + // e.preventDefault(); + }); // multiselect dropdowns $('#multiselect-trigger').on('mousedown touchend focusin focusout', function(e) { - var state = $(this).data('state') || 0; + const state = $(this).data('state') || 0; if( state == 0 ) { // open the dropdown $(this).data('state', '1').addClass('open').removeClass('closed'); @@ -154,7 +154,7 @@ $('#multiselect-trigger').on('mousedown touchend focusin focusout', function(e) }); // multiselect dropdowns $('#multiselect-trigger3').on('mousedown touchend focusin focusout', function(e) { - var state = $(this).attr('data-state') || 0; + const state = $(this).attr('data-state') || 0; if( state == 0 ) { // open the dropdown From b25632188abfb0548387a82f1b67d6088d8cdf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Fri, 11 Dec 2020 17:53:42 +0100 Subject: [PATCH 2/5] Template string --- animations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/animations.js b/animations.js index 82f5d68..58e919f 100644 --- a/animations.js +++ b/animations.js @@ -59,8 +59,8 @@ $(".close").on('click', function(e) { $("body").css('overflow', 'auto'); - var bounding_box = $(this).parent().get(0).getBoundingClientRect(); - $(this).parent().css({ top: bounding_box.top + 'px', left: bounding_box.left + 'px' }); + const bounding_box = $(this).parent().get(0).getBoundingClientRect(); + $(this).parent().css({ top: `${bounding_box.top}px`, left: `${bounding_box.left}px` }); /* Show animation */ $(this).parent().addClass('out-animation'); From 26288e685a9e17126cc9be1edddf97060254e953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Fri, 11 Dec 2020 17:54:17 +0100 Subject: [PATCH 3/5] Rename e to er due to IE8 overwriting it Nobody will use OBS.ninja in IE8 but who knows... --- animations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/animations.js b/animations.js index 58e919f..b95e708 100644 --- a/animations.js +++ b/animations.js @@ -79,8 +79,8 @@ $(".close").on('click', function(e) { }); } activatedPreview=false; - } catch (e){ - errorlog(e); + } catch (er){ + errorlog(er); } log("Cleaned up Video"); e.stopPropagation(); From 78b7b9cba98ff010cf81df7082b6fe53de245b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Fri, 11 Dec 2020 17:54:38 +0100 Subject: [PATCH 4/5] Format animations.js --- animations.js | 253 +++++++++++++++++++++++++------------------------- 1 file changed, 126 insertions(+), 127 deletions(-) diff --git a/animations.js b/animations.js index b95e708..22027fd 100644 --- a/animations.js +++ b/animations.js @@ -1,179 +1,178 @@ - /* We need to create dynamic keyframes to show the animation from full-screen to normal. So we create a stylesheet in which we can insert CSS keyframe rules */ $("body").append(''); /* Click on the container */ -$(".column").on('click', function() { - /* The position of the container will be set to fixed, so set the top & left properties of the container */ +$(".column").on('click', function () { + /* The position of the container will be set to fixed, so set the top & left properties of the container */ - if ( $(this).hasClass( "skip-animation" )){ - return; - } - + if ($(this).hasClass("skip-animation")) { + return; + } - const bounding_box = $(this).get(0).getBoundingClientRect(); - $(this).css({ top: bounding_box.top + 'px', left: bounding_box.left -20+ 'px' }); - /* Set container to fixed position. Add animation */ - $(this).addClass('in-animation').removeClass('pointer'); + const bounding_box = $(this).get(0).getBoundingClientRect(); + $(this).css({ + top: bounding_box.top + 'px', + left: bounding_box.left - 20 + 'px' + }); - /* An empty container has to be added in place of the lightbox container so that the elements below don't come up + /* Set container to fixed position. Add animation */ + $(this).addClass('in-animation').removeClass('pointer'); + + /* An empty container has to be added in place of the lightbox container so that the elements below don't come up Dimensions of this empty container is the same as the original container */ - $("#empty-container").remove(); - $('
').insertAfter(this); + $("#empty-container").remove(); + $('
').insertAfter(this); - /* To animate the container from full-screen to normal, we need dynamic keyframes */ - let styles = ''; - styles = '@keyframes outlightbox {'; - styles += '0% {'; - styles += 'height: 100%;'; - styles += 'width: 100%;'; - styles += 'top: 0px;'; - styles += 'left: 0px;'; - styles += '}'; - styles += '50% {'; - styles += 'height: 220px;'; - styles += 'top: ' + bounding_box.y + 'px;'; - styles += '}'; - styles += '100% {'; - styles += 'height: 220px;'; - styles += 'width: '+bounding_box.width+'px;'; - styles += 'top: ' + bounding_box.y + 'px;'; - styles += 'left: ' + bounding_box.x + 'px;'; - styles += '}'; - styles += '}'; + /* To animate the container from full-screen to normal, we need dynamic keyframes */ + let styles = ''; + styles = '@keyframes outlightbox {'; + styles += '0% {'; + styles += 'height: 100%;'; + styles += 'width: 100%;'; + styles += 'top: 0px;'; + styles += 'left: 0px;'; + styles += '}'; + styles += '50% {'; + styles += 'height: 220px;'; + styles += 'top: ' + bounding_box.y + 'px;'; + styles += '}'; + styles += '100% {'; + styles += 'height: 220px;'; + styles += 'width: ' + bounding_box.width + 'px;'; + styles += 'top: ' + bounding_box.y + 'px;'; + styles += 'left: ' + bounding_box.x + 'px;'; + styles += '}'; + styles += '}'; - /* Add keyframe to CSS */ - $("#lightbox-animations").empty(); - $("#lightbox-animations").get(0).sheet.insertRule(styles, 0); + /* Add keyframe to CSS */ + $("#lightbox-animations").empty(); + $("#lightbox-animations").get(0).sheet.insertRule(styles, 0); - /* Hide the window scrollbar */ - $("body").css('overflow', 'hidden'); + /* Hide the window scrollbar */ + $("body").css('overflow', 'hidden'); }); /* Click on close button when full-screen */ -$(".close").on('click', function(e) { - $(this).hide(); - $(".container-inner").hide(); - - $("body").css('overflow', 'auto'); +$(".close").on('click', function (e) { + $(this).hide(); + $(".container-inner").hide(); - const bounding_box = $(this).parent().get(0).getBoundingClientRect(); - $(this).parent().css({ top: `${bounding_box.top}px`, left: `${bounding_box.left}px` }); + $("body").css('overflow', 'auto'); - /* Show animation */ - $(this).parent().addClass('out-animation'); + const bounding_box = $(this).parent().get(0).getBoundingClientRect(); + $(this).parent().css({top: `${ + bounding_box.top + }px`, left: `${ + bounding_box.left + }px`}); + + /* Show animation */ + $(this).parent().addClass('out-animation'); - try{ - - const oldstream = getById('previewWebcam').srcObject; - - if (oldstream){ - log("old stream found"); - oldstream.getTracks().forEach((track) => { - track.stop(); - oldstream.removeTrack(track); - log("stopping old track"); - }); - } - activatedPreview=false; - } catch (er){ - errorlog(er); - } - log("Cleaned up Video"); - e.stopPropagation(); + try { + + const oldstream = getById('previewWebcam').srcObject; + + if (oldstream) { + log("old stream found"); + oldstream.getTracks().forEach((track) => { + track.stop(); + oldstream.removeTrack(track); + log("stopping old track"); + }); + } + activatedPreview = false; + } catch (er) { + errorlog(er); + } + log("Cleaned up Video"); + e.stopPropagation(); }); /* On animationend : from normal to full screen & full screen to normal */ -$(".column").on('animationend', function(e) { -/* On animation end from normal to full-screen */ -if(e.originalEvent.animationName == 'inlightbox') { - $(this).children(".close").show(); - $(this).children(".container-inner").show(); -} -/* On animation end from full-screen to normal */ -else if(e.originalEvent.animationName == 'outlightbox') { - /* Remove fixed positioning, remove animation rules */ - $(this).removeClass('in-animation').removeClass('out-animation').removeClass('columnfade').addClass('pointer'); - - /* Remove the empty container that was earlier added */ - $("#empty-container").remove(); +$(".column").on('animationend', function (e) { + /* On animation end from normal to full-screen */ + if (e.originalEvent.animationName == 'inlightbox') { + $(this).children(".close").show(); + $(this).children(".container-inner").show(); + } + /* On animation end from full-screen to normal */ else if (e.originalEvent.animationName == 'outlightbox') { + /* Remove fixed positioning, remove animation rules */ + $(this).removeClass('in-animation').removeClass('out-animation').removeClass('columnfade').addClass('pointer'); - /* Delete the dynamic keyframe rule that was earlier created */ - $("#lightbox-animations").get(0).sheet.deleteRule(0); -} + /* Remove the empty container that was earlier added */ + $("#empty-container").remove(); + + /* Delete the dynamic keyframe rule that was earlier created */ + $("#lightbox-animations").get(0).sheet.deleteRule(0); + } }); $('#audioSource').on('mousedown touchend focusin focusout', (_e) => { - const state = $('#multiselect-trigger').data('state') || 0; - if (state == 0) { - ////open the dropdown - $('#multiselect-trigger').data('state', '1').addClass('open').removeClass('closed'); - $('#multiselect-trigger').find('.chevron').removeClass('bottom'); - $('#multiselect-trigger').parent().find('.multiselect-contents').show(); - $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; - } - // e.preventDefault(); - }); + const state = $('#multiselect-trigger').data('state') || 0; + if (state == 0) { + // //open the dropdown + $('#multiselect-trigger').data('state', '1').addClass('open').removeClass('closed'); + $('#multiselect-trigger').find('.chevron').removeClass('bottom'); + $('#multiselect-trigger').parent().find('.multiselect-contents').show(); + $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; + $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + } + // e.preventDefault(); +}); $('#audioSource3').on('mousedown touchend focusin focusout', (_e) => { - const state = $('#multiselect-trigger3').attr('data-state') || 0; - if (state == 0) { - ////open the dropdown - $('#multiselect-trigger3').attr('data-state', '1').addClass('open').removeClass('closed'); - $('#multiselect-trigger3').find('.chevron').removeClass('bottom'); - $('#multiselect-trigger3').parent().find('.multiselect-contents').show(); - $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; - } - // e.preventDefault(); - }); - + const state = $('#multiselect-trigger3').attr('data-state') || 0; + if (state == 0) { + // //open the dropdown + $('#multiselect-trigger3').attr('data-state', '1').addClass('open').removeClass('closed'); + $('#multiselect-trigger3').find('.chevron').removeClass('bottom'); + $('#multiselect-trigger3').parent().find('.multiselect-contents').show(); + $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; + $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + } + // e.preventDefault(); +}); + // multiselect dropdowns -$('#multiselect-trigger').on('mousedown touchend focusin focusout', function(e) { +$('#multiselect-trigger').on('mousedown touchend focusin focusout', function (e) { const state = $(this).data('state') || 0; - if( state == 0 ) { + if (state == 0) { // open the dropdown $(this).data('state', '1').addClass('open').removeClass('closed'); $(this).find('.chevron').removeClass('bottom'); $(this).parent().find('.multiselect-contents').show(); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; } else { // close the dropdown $(this).data('state', '0').addClass('closed').removeClass('open'); $(this).find('.chevron').addClass('bottom'); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide();; - } - e.preventDefault(); + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide();; + } e.preventDefault(); }); // multiselect dropdowns -$('#multiselect-trigger3').on('mousedown touchend focusin focusout', function(e) { +$('#multiselect-trigger3').on('mousedown touchend focusin focusout', function (e) { const state = $(this).attr('data-state') || 0; - - if( state == 0 ) { + + if (state == 0) { // open the dropdown - errorlog("STATE: "+state); + errorlog("STATE: " + state); $(this).attr('data-state', '1').addClass('open').removeClass('closed'); $(this).find('.chevron').removeClass('bottom'); $(this).parent().find('.multiselect-contents').show(); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; } else { // close the dropdown $(this).attr('data-state', '0').addClass('closed').removeClass('open'); $(this).find('.chevron').addClass('bottom'); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide();; - } - e.preventDefault(); + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide();; + } e.preventDefault(); }); - - - - From 4f8d2c2d385c0bed50b3f0ae27ba56b19b875395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Fri, 11 Dec 2020 17:55:33 +0100 Subject: [PATCH 5/5] Remove extra semicolons --- animations.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/animations.js b/animations.js index 22027fd..cfcfe2b 100644 --- a/animations.js +++ b/animations.js @@ -119,8 +119,8 @@ $('#audioSource').on('mousedown touchend focusin focusout', (_e) => { $('#multiselect-trigger').data('state', '1').addClass('open').removeClass('closed'); $('#multiselect-trigger').find('.chevron').removeClass('bottom'); $('#multiselect-trigger').parent().find('.multiselect-contents').show(); - $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show(); + $('#multiselect-trigger').parent().find('.multiselect-contents').find('input[type="checkbox"]').show(); } // e.preventDefault(); }); @@ -132,8 +132,8 @@ $('#audioSource3').on('mousedown touchend focusin focusout', (_e) => { $('#multiselect-trigger3').attr('data-state', '1').addClass('open').removeClass('closed'); $('#multiselect-trigger3').find('.chevron').removeClass('bottom'); $('#multiselect-trigger3').parent().find('.multiselect-contents').show(); - $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show(); + $('#multiselect-trigger3').parent().find('.multiselect-contents').find('input[type="checkbox"]').show(); } // e.preventDefault(); }); @@ -146,14 +146,14 @@ $('#multiselect-trigger').on('mousedown touchend focusin focusout', function (e) $(this).data('state', '1').addClass('open').removeClass('closed'); $(this).find('.chevron').removeClass('bottom'); $(this).parent().find('.multiselect-contents').show(); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show(); + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show(); } else { // close the dropdown $(this).data('state', '0').addClass('closed').removeClass('open'); $(this).find('.chevron').addClass('bottom'); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide(); + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide(); } e.preventDefault(); }); // multiselect dropdowns @@ -166,13 +166,13 @@ $('#multiselect-trigger3').on('mousedown touchend focusin focusout', function (e $(this).attr('data-state', '1').addClass('open').removeClass('closed'); $(this).find('.chevron').removeClass('bottom'); $(this).parent().find('.multiselect-contents').show(); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').parent().show(); + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').show(); } else { // close the dropdown $(this).attr('data-state', '0').addClass('closed').removeClass('open'); $(this).find('.chevron').addClass('bottom'); - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide();; - $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide();; + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').not(":checked").parent().hide(); + $(this).parent().find('.multiselect-contents').find('input[type="checkbox"]').hide(); } e.preventDefault(); });