From 95ff69ee9ad86506384efa6ee1faed2e7348fbae Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 18 Feb 2024 20:34:24 -0800 Subject: [PATCH] Run Prettier on some of our JS assets The motivation is that I'm about to change one of them to remove a reference to an old placeholder library, so I want that change to be clear! --- app/assets/javascripts/ajax_auth.js | 16 +- app/assets/javascripts/application.js | 4 +- .../javascripts/closet_hangers/index.js | 576 ++++++++++-------- .../javascripts/closet_hangers/petpage.js | 4 +- app/assets/javascripts/outfits/index.js | 5 +- app/assets/javascripts/pets/bulk.js | 178 +++--- 6 files changed, 443 insertions(+), 340 deletions(-) diff --git a/app/assets/javascripts/ajax_auth.js b/app/assets/javascripts/ajax_auth.js index f2a2d554..27f81bbb 100644 --- a/app/assets/javascripts/ajax_auth.js +++ b/app/assets/javascripts/ajax_auth.js @@ -1,20 +1,20 @@ (function () { var CSRFProtection; - var token = $('meta[name="csrf-token"]').attr('content'); + var token = $('meta[name="csrf-token"]').attr("content"); if (token) { - CSRFProtection = function(xhr, settings) { - var sendToken = ( - (typeof settings.useCSRFProtection === 'undefined') // default to true - || settings.useCSRFProtection); + CSRFProtection = function (xhr, settings) { + var sendToken = + typeof settings.useCSRFProtection === "undefined" || // default to true + settings.useCSRFProtection; if (sendToken) { - xhr.setRequestHeader('X-CSRF-Token', token); + xhr.setRequestHeader("X-CSRF-Token", token); } - } + }; } else { CSRFProtection = $.noop; } $.ajaxSetup({ - beforeSend: CSRFProtection + beforeSend: CSRFProtection, }); })(); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b8b1a698..07c1bbbc 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,3 +1,3 @@ -document.getElementById('locale').addEventListener('change', function() { - document.getElementById('locale-form').submit(); +document.getElementById("locale").addEventListener("change", function () { + document.getElementById("locale-form").submit(); }); diff --git a/app/assets/javascripts/closet_hangers/index.js b/app/assets/javascripts/closet_hangers/index.js index 02f81ae1..c2e65ca8 100644 --- a/app/assets/javascripts/closet_hangers/index.js +++ b/app/assets/javascripts/closet_hangers/index.js @@ -6,7 +6,7 @@ } function hangersInit() { - for(var i = 0; i < hangersInitCallbacks.length; i++) { + for (var i = 0; i < hangersInitCallbacks.length; i++) { hangersInitCallbacks[i](); } } @@ -19,33 +19,33 @@ var hangerGroups = []; - $('div.closet-hangers-group').each(function () { + $("div.closet-hangers-group").each(function () { var el = $(this); var lists = []; - el.find('div.closet-list').each(function () { + el.find("div.closet-list").each(function () { var el = $(this); - var id = el.attr('data-id'); - if(id) { + var id = el.attr("data-id"); + if (id) { lists[lists.length] = { id: parseInt(id, 10), - label: el.find('h4').text() - } + label: el.find("h4").text(), + }; } }); hangerGroups[hangerGroups.length] = { - label: el.find('h3').text(), + label: el.find("h3").text(), lists: lists, - owned: (el.attr('data-owned') == 'true') + owned: el.attr("data-owned") == "true", }; }); - $('div.closet-hangers-group span.toggle').live('click', function () { - $(this).closest('.closet-hangers-group').toggleClass('hidden'); + $("div.closet-hangers-group span.toggle").live("click", function () { + $(this).closest(".closet-hangers-group").toggleClass("hidden"); }); - var hangersElQuery = '#closet-hangers'; + var hangersElQuery = "#closet-hangers"; var hangersEl = $(hangersElQuery); /* @@ -54,8 +54,8 @@ */ - $('#toggle-compare').click(function () { - hangersEl.toggleClass('comparing'); + $("#toggle-compare").click(function () { + hangersEl.toggleClass("comparing"); }); /* @@ -65,7 +65,7 @@ */ var body = $(document.body).addClass("js"); - if(!body.hasClass("current-user")) return false; + if (!body.hasClass("current-user")) return false; // When we get hangers HTML, add the controls. We do this in JS rather than // in the HTML for caching, since otherwise the requests can take forever. @@ -81,11 +81,11 @@ $("#closet-hangers div.closet-hangers-group").each(function () { var groupEl = $(this); var owned = groupEl.data("owned"); - + groupEl.find("div.closet-list").each(function () { var listEl = $(this); var listId = listEl.data("id"); - + listEl.find("div.object").each(function () { var hangerEl = $(this); var hangerId = hangerEl.data("id"); @@ -94,32 +94,32 @@ // Ooh, this part is weird. We only want the name to be linked, so // lift everything else out. - var checkboxId = 'hanger-selected-' + hangerId; - var label = $('