From a2bd232c815256649dbfc860752500d7f35350e4 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 4 Feb 2024 21:19:26 +0000 Subject: [PATCH 1/2] Restyled by clang-format --- public/butter.js | 231 +++++++++++++++++++++++------------------------ 1 file changed, 114 insertions(+), 117 deletions(-) diff --git a/public/butter.js b/public/butter.js index c8140bd..6d06def 100644 --- a/public/butter.js +++ b/public/butter.js @@ -1,126 +1,123 @@ // butter.js -(function (root) { - var Butter = function () { - var self = this; - - this.defaults = { - wrapperId: "butter", - wrapperDamper: 0.07, - cancelOnTouch: false, - }; - - this.validateOptions = function (ops) { - for (var prop in ops) { - if (self.defaults.hasOwnProperty(prop)) { - Object.defineProperty(self.defaults, prop, { - value: Object.getOwnPropertyDescriptor(ops, prop).value, - }); - } - } - }; - // ???? What is this for ???? - // this.wrapperDamper; - // this.wrapperId; - // this.cancelOnTouch; - // this.wrapper; - this.wrapperOffset = 0; - // this.animateId; - this.resizing = false; - this.active = false; - // this.wrapperHeight; - // this.bodyHeight; +(function(root) { +var Butter = function() { + var self = this; + + this.defaults = { + wrapperId : "butter", + wrapperDamper : 0.07, + cancelOnTouch : false, }; - Butter.prototype = { - init: function (options) { - if (options) { - this.validateOptions(options); - } - - this.active = true; - this.resizing = false; - this.wrapperDamper = this.defaults.wrapperDamper; - this.wrapperId = this.defaults.wrapperId; - this.cancelOnTouch = this.defaults.cancelOnTouch; - - this.wrapper = document.getElementById(this.wrapperId); - this.wrapper.style.position = "fixed"; - this.wrapper.style.width = "100%"; - - this.wrapperHeight = this.wrapper.clientHeight; - document.body.style.height = this.wrapperHeight + "px"; - - window.addEventListener("resize", this.resize.bind(this)); - if (this.cancelOnTouch) { - window.addEventListener("touchstart", this.cancel.bind(this)); + this.validateOptions = function(ops) { + for (var prop in ops) { + if (self.defaults.hasOwnProperty(prop)) { + Object.defineProperty(self.defaults, prop, { + value : Object.getOwnPropertyDescriptor(ops, prop).value, + }); } - this.wrapperOffset = 0.0; - this.animateId = window.requestAnimationFrame(this.animate.bind(this)); - - // window.addEventListener('load', this.resize.bind(this)); - }, - - wrapperUpdate: function () { - var scrollY = - document.scrollingElement !== undefined - ? document.scrollingElement.scrollTop - : document.documentElement.scrollTop || 0.0; - this.wrapperOffset += (scrollY - this.wrapperOffset) * this.wrapperDamper; - this.wrapper.style.transform = + } + }; + // ???? What is this for ???? + // this.wrapperDamper; + // this.wrapperId; + // this.cancelOnTouch; + // this.wrapper; + this.wrapperOffset = 0; + // this.animateId; + this.resizing = false; + this.active = false; + // this.wrapperHeight; + // this.bodyHeight; +}; + +Butter.prototype = { + init : function(options) { + if (options) { + this.validateOptions(options); + } + + this.active = true; + this.resizing = false; + this.wrapperDamper = this.defaults.wrapperDamper; + this.wrapperId = this.defaults.wrapperId; + this.cancelOnTouch = this.defaults.cancelOnTouch; + + this.wrapper = document.getElementById(this.wrapperId); + this.wrapper.style.position = "fixed"; + this.wrapper.style.width = "100%"; + + this.wrapperHeight = this.wrapper.clientHeight; + document.body.style.height = this.wrapperHeight + "px"; + + window.addEventListener("resize", this.resize.bind(this)); + if (this.cancelOnTouch) { + window.addEventListener("touchstart", this.cancel.bind(this)); + } + this.wrapperOffset = 0.0; + this.animateId = window.requestAnimationFrame(this.animate.bind(this)); + + // window.addEventListener('load', this.resize.bind(this)); + }, + + wrapperUpdate : function() { + var scrollY = document.scrollingElement !== undefined + ? document.scrollingElement.scrollTop + : document.documentElement.scrollTop || 0.0; + this.wrapperOffset += (scrollY - this.wrapperOffset) * this.wrapperDamper; + this.wrapper.style.transform = "translate3d(0," + -this.wrapperOffset.toFixed(2) + "px, 0)"; - }, + }, - checkResize: function () { - if (this.wrapperHeight !== this.wrapper.clientHeight) { - this.resize(); - } - }, - - resize: function () { - var self = this; - if (!self.resizing) { - self.resizing = true; - window.cancelAnimationFrame(self.animateId); - window.setTimeout(function () { - self.wrapperHeight = self.wrapper.clientHeight; - if ( - parseInt(document.body.style.height) !== - parseInt(self.wrapperHeight) - ) { - document.body.style.height = self.wrapperHeight + "px"; - } - self.animateId = window.requestAnimationFrame( - self.animate.bind(self), - ); - self.resizing = false; - }, 150); - } - }, - - animate: function () { - this.checkResize(); - this.wrapperUpdate(); - this.animateId = window.requestAnimationFrame(this.animate.bind(this)); - }, - - cancel: function () { - if (this.active) { - window.cancelAnimationFrame(this.animateId); - - window.removeEventListener("resize", this.resize); - window.removeEventListener("touchstart", this.cancel); - this.wrapper.removeAttribute("style"); - document.body.removeAttribute("style"); - - this.active = false; - this.wrapper = ""; - this.wrapperOffset = 0; - this.resizing = true; - this.animateId = ""; - } - }, - }; + checkResize : function() { + if (this.wrapperHeight !== this.wrapper.clientHeight) { + this.resize(); + } + }, - root.butter = new Butter(); + resize : function() { + var self = this; + if (!self.resizing) { + self.resizing = true; + window.cancelAnimationFrame(self.animateId); + window.setTimeout(function() { + self.wrapperHeight = self.wrapper.clientHeight; + if (parseInt(document.body.style.height) !== + parseInt(self.wrapperHeight)) { + document.body.style.height = self.wrapperHeight + "px"; + } + self.animateId = window.requestAnimationFrame( + self.animate.bind(self), + ); + self.resizing = false; + }, 150); + } + }, + + animate : function() { + this.checkResize(); + this.wrapperUpdate(); + this.animateId = window.requestAnimationFrame(this.animate.bind(this)); + }, + + cancel : function() { + if (this.active) { + window.cancelAnimationFrame(this.animateId); + + window.removeEventListener("resize", this.resize); + window.removeEventListener("touchstart", this.cancel); + this.wrapper.removeAttribute("style"); + document.body.removeAttribute("style"); + + this.active = false; + this.wrapper = ""; + this.wrapperOffset = 0; + this.resizing = true; + this.animateId = ""; + } + }, +}; + +root.butter = new Butter(); })(this); From e775e5e28d2f210b6b6d607441ca71a905993111 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 4 Feb 2024 21:19:31 +0000 Subject: [PATCH 2/2] Restyled by prettier --- public/butter.js | 231 +++++++++++++------------ src/components/NonPage/Initiatives.jsx | 102 ++++++----- 2 files changed, 171 insertions(+), 162 deletions(-) diff --git a/public/butter.js b/public/butter.js index 6d06def..c8140bd 100644 --- a/public/butter.js +++ b/public/butter.js @@ -1,123 +1,126 @@ // butter.js -(function(root) { -var Butter = function() { - var self = this; - - this.defaults = { - wrapperId : "butter", - wrapperDamper : 0.07, - cancelOnTouch : false, - }; +(function (root) { + var Butter = function () { + var self = this; - this.validateOptions = function(ops) { - for (var prop in ops) { - if (self.defaults.hasOwnProperty(prop)) { - Object.defineProperty(self.defaults, prop, { - value : Object.getOwnPropertyDescriptor(ops, prop).value, - }); + this.defaults = { + wrapperId: "butter", + wrapperDamper: 0.07, + cancelOnTouch: false, + }; + + this.validateOptions = function (ops) { + for (var prop in ops) { + if (self.defaults.hasOwnProperty(prop)) { + Object.defineProperty(self.defaults, prop, { + value: Object.getOwnPropertyDescriptor(ops, prop).value, + }); + } } - } - }; - // ???? What is this for ???? - // this.wrapperDamper; - // this.wrapperId; - // this.cancelOnTouch; - // this.wrapper; - this.wrapperOffset = 0; - // this.animateId; - this.resizing = false; - this.active = false; - // this.wrapperHeight; - // this.bodyHeight; -}; - -Butter.prototype = { - init : function(options) { - if (options) { - this.validateOptions(options); - } - - this.active = true; + }; + // ???? What is this for ???? + // this.wrapperDamper; + // this.wrapperId; + // this.cancelOnTouch; + // this.wrapper; + this.wrapperOffset = 0; + // this.animateId; this.resizing = false; - this.wrapperDamper = this.defaults.wrapperDamper; - this.wrapperId = this.defaults.wrapperId; - this.cancelOnTouch = this.defaults.cancelOnTouch; - - this.wrapper = document.getElementById(this.wrapperId); - this.wrapper.style.position = "fixed"; - this.wrapper.style.width = "100%"; - - this.wrapperHeight = this.wrapper.clientHeight; - document.body.style.height = this.wrapperHeight + "px"; - - window.addEventListener("resize", this.resize.bind(this)); - if (this.cancelOnTouch) { - window.addEventListener("touchstart", this.cancel.bind(this)); - } - this.wrapperOffset = 0.0; - this.animateId = window.requestAnimationFrame(this.animate.bind(this)); - - // window.addEventListener('load', this.resize.bind(this)); - }, - - wrapperUpdate : function() { - var scrollY = document.scrollingElement !== undefined - ? document.scrollingElement.scrollTop - : document.documentElement.scrollTop || 0.0; - this.wrapperOffset += (scrollY - this.wrapperOffset) * this.wrapperDamper; - this.wrapper.style.transform = - "translate3d(0," + -this.wrapperOffset.toFixed(2) + "px, 0)"; - }, + this.active = false; + // this.wrapperHeight; + // this.bodyHeight; + }; - checkResize : function() { - if (this.wrapperHeight !== this.wrapper.clientHeight) { - this.resize(); - } - }, + Butter.prototype = { + init: function (options) { + if (options) { + this.validateOptions(options); + } - resize : function() { - var self = this; - if (!self.resizing) { - self.resizing = true; - window.cancelAnimationFrame(self.animateId); - window.setTimeout(function() { - self.wrapperHeight = self.wrapper.clientHeight; - if (parseInt(document.body.style.height) !== - parseInt(self.wrapperHeight)) { - document.body.style.height = self.wrapperHeight + "px"; - } - self.animateId = window.requestAnimationFrame( + this.active = true; + this.resizing = false; + this.wrapperDamper = this.defaults.wrapperDamper; + this.wrapperId = this.defaults.wrapperId; + this.cancelOnTouch = this.defaults.cancelOnTouch; + + this.wrapper = document.getElementById(this.wrapperId); + this.wrapper.style.position = "fixed"; + this.wrapper.style.width = "100%"; + + this.wrapperHeight = this.wrapper.clientHeight; + document.body.style.height = this.wrapperHeight + "px"; + + window.addEventListener("resize", this.resize.bind(this)); + if (this.cancelOnTouch) { + window.addEventListener("touchstart", this.cancel.bind(this)); + } + this.wrapperOffset = 0.0; + this.animateId = window.requestAnimationFrame(this.animate.bind(this)); + + // window.addEventListener('load', this.resize.bind(this)); + }, + + wrapperUpdate: function () { + var scrollY = + document.scrollingElement !== undefined + ? document.scrollingElement.scrollTop + : document.documentElement.scrollTop || 0.0; + this.wrapperOffset += (scrollY - this.wrapperOffset) * this.wrapperDamper; + this.wrapper.style.transform = + "translate3d(0," + -this.wrapperOffset.toFixed(2) + "px, 0)"; + }, + + checkResize: function () { + if (this.wrapperHeight !== this.wrapper.clientHeight) { + this.resize(); + } + }, + + resize: function () { + var self = this; + if (!self.resizing) { + self.resizing = true; + window.cancelAnimationFrame(self.animateId); + window.setTimeout(function () { + self.wrapperHeight = self.wrapper.clientHeight; + if ( + parseInt(document.body.style.height) !== + parseInt(self.wrapperHeight) + ) { + document.body.style.height = self.wrapperHeight + "px"; + } + self.animateId = window.requestAnimationFrame( self.animate.bind(self), - ); - self.resizing = false; - }, 150); - } - }, - - animate : function() { - this.checkResize(); - this.wrapperUpdate(); - this.animateId = window.requestAnimationFrame(this.animate.bind(this)); - }, - - cancel : function() { - if (this.active) { - window.cancelAnimationFrame(this.animateId); - - window.removeEventListener("resize", this.resize); - window.removeEventListener("touchstart", this.cancel); - this.wrapper.removeAttribute("style"); - document.body.removeAttribute("style"); - - this.active = false; - this.wrapper = ""; - this.wrapperOffset = 0; - this.resizing = true; - this.animateId = ""; - } - }, -}; - -root.butter = new Butter(); + ); + self.resizing = false; + }, 150); + } + }, + + animate: function () { + this.checkResize(); + this.wrapperUpdate(); + this.animateId = window.requestAnimationFrame(this.animate.bind(this)); + }, + + cancel: function () { + if (this.active) { + window.cancelAnimationFrame(this.animateId); + + window.removeEventListener("resize", this.resize); + window.removeEventListener("touchstart", this.cancel); + this.wrapper.removeAttribute("style"); + document.body.removeAttribute("style"); + + this.active = false; + this.wrapper = ""; + this.wrapperOffset = 0; + this.resizing = true; + this.animateId = ""; + } + }, + }; + + root.butter = new Butter(); })(this); diff --git a/src/components/NonPage/Initiatives.jsx b/src/components/NonPage/Initiatives.jsx index 002abf6..ee2d138 100644 --- a/src/components/NonPage/Initiatives.jsx +++ b/src/components/NonPage/Initiatives.jsx @@ -3,53 +3,59 @@ import Papa from "papaparse"; import "./Initiatives.css"; export default function AllInitiatives(props) { - const [initiativesData, setEventsInfo] = useState([]); - const [showMore, setShowMore] = useState([]); - console.log(props.dayInfo); - useEffect(() => { - const fetchSheetsData = async () => { - try { - const ID = "1yB7zzw0I3hUjLwgKZXMpBioQ9FNkTg2bp3skTwtatHk"; - const sheet_name = "Announcements"; - const response = await fetch(`https://docs.google.com/spreadsheets/d/${ID}/gviz/tq?tqx=out:csv&sheet=${sheet_name}`); - const text = await response.text(); - const parsedData = Papa.parse(text, { header: true }).data.reverse(); - setEventsInfo(parsedData); - setShowMore(Array(parsedData.length).fill(false)); - } catch (err) { - console.log(err); - } - }; - fetchSheetsData(); - }, []); - + const [initiativesData, setEventsInfo] = useState([]); + const [showMore, setShowMore] = useState([]); + console.log(props.dayInfo); + useEffect(() => { + const fetchSheetsData = async () => { + try { + const ID = "1yB7zzw0I3hUjLwgKZXMpBioQ9FNkTg2bp3skTwtatHk"; + const sheet_name = "Announcements"; + const response = await fetch( + `https://docs.google.com/spreadsheets/d/${ID}/gviz/tq?tqx=out:csv&sheet=${sheet_name}`, + ); + const text = await response.text(); + const parsedData = Papa.parse(text, { header: true }).data.reverse(); + setEventsInfo(parsedData); + setShowMore(Array(parsedData.length).fill(false)); + } catch (err) { + console.log(err); + } + }; + fetchSheetsData(); + }, []); - const handleShowMoreToggle = (index) => { - setShowMore((prevShowMore) => { - const newShowMore = [...prevShowMore]; - newShowMore[index] = !newShowMore[index]; - return newShowMore; - }); - } + const handleShowMoreToggle = (index) => { + setShowMore((prevShowMore) => { + const newShowMore = [...prevShowMore]; + newShowMore[index] = !newShowMore[index]; + return newShowMore; + }); + }; - return ( -
-
- {initiativesData.map((initiative, index) => ( -
-

{initiative.Date}

-

{initiative.Title}

-

- {showMore[index] ? initiative.Text : initiative.Text.substring(0, 100)} -

- {showMore[index] ? - : null - } -
- ))} -
-
- ); - } \ No newline at end of file + return ( +
+
+ {initiativesData.map((initiative, index) => ( +
+

{initiative.Date}

+

{initiative.Title}

+

+ {showMore[index] + ? initiative.Text + : initiative.Text.substring(0, 100)} +

+ {showMore[index] ? ( + + ) : null} +
+ ))} +
+
+ ); +}