(function () { 'use strict'; const stylesheet = document.querySelector("#stylesheet"); const toggleStylesheetLightButton = document.querySelector("#light"); const toggleStylesheetDarkButton = document.querySelector("#dark"); const navMenu = document.querySelector("#nav-menu"); navMenu.offsetTop; const mainPage = document.querySelector("#main-div"); const topBar = document.querySelector("#top-bar"); const lightDarkWarning = document.querySelector("#light-dark-warning"); const abnormalLogo = document.querySelector("#logo"); const abnormalLogoStylesheet = document.querySelector("#logo-stylesheet"); const footerAbnormal = document.querySelector("#footer-fourth"); const introScreen = document.querySelector("[data-intro-screen]"); const stylesheetSelector = document.createElement("div"); const previousStylesheet = document.createElement("div"); const menuButton = document.querySelector("#menu-button-open-close"); const navMobile = document.querySelector("#mobile-nav-menu"); const menuBar = document.querySelector("#mobile-menu-bar"); const pageName = document.querySelector("#page-name"); /*change prefix from "./" for test page inside the issue's folder to "./issues-number/" for root index file */ const prefix = "./"; const articles = { "Book Review": [ { "title": "Book Review - JFK and the Unspeakable", "sub-title": "", "author": "James W. Douglass", "description":[ "Do you remember where you were when President Kennedy was killed? I do.", "I was in a cafe on a street in downtown Buenos Aires. It was a warm southern hemisphere spring day and I was waiting for a colleague who should have arrived a few minutes ago; but this being Argentina, where punctuality is a mere theoretical virtue, I was accustomed to waiting. There was a buzz of voices in the rear of the café that seemed to be creeping nearer and louder.", "Suddenly Osvaldo rushed in. He didn't stop to even say Buenos Días. “Did you hear that Kennedy has been shot?” he blurted out.", "“Kennedy?” I repeated stupidly.", ], "imgUrl": `${prefix}jfk-assassination-2.png`, "link": `${prefix}jfk-review.html`, "poem": false, "mainImg": false, }, { "title": "Beyond Belief", "sub-title": "", "author": "Elaine Pagels", "description":[ "Elaine Pagels, professor of religion at Princeton University, became famous – well, at least well known – with the publication of her book, The Gnostic Gospels, in 1979. She has written several other books as well on the history of Christianity, establishing her as the foremost popular scholar in the field.", "Beyond Belief, published in 2003 by Random House, is a sort of sequel to The Gnostic Gospels, in that it incorporates the new scholarship that has come to light since that book was published. Since Ms. Pagels’ infant son was diagnosed with fatal pulmonary hypertension, her pursuit of knowledge about who Jesus really was has become a question of personal urgency for her. This need is reflected in the text and transforms the book into much more than a scholarly treatise for the curious. She wants to know what Christ meant to his followers before doctrine and dogmas, in other words, before Christianity was re-invented by the Roman Catholic Church.", ], "imgUrl": `${prefix}thomas-apostle.jpg`, "link": `${prefix}pagels-beyond-belief.html`, "poem": false, "mainImg": false, }, ], "Fiction": [ { "title": "“We are the lucky ones…”", "sub-title": "(Bilingual)", "author": "Z", "description":[ "When I moved with my family to the country from Buenos Aires 14 years ago, we lived in an old house, once the core building of an estancia. There were ten acres of what was once farmland, but had turned into what my son, ten years old at the time, rather romantically and with his flair for exaggeration called a jungle. After a few days of snooping around in the “jungle” with his dog, he found a rusty old lunch pail. It had no lock on it, but it was rusted tightly shut, so he brought it to me to open, which I did with the help of a chisel and hammer. Instead of a rotted chicken leg, we found a…what should I call it? An essay, or simply an unfinished manuscript. Translated into English, it reads as follows.", "We were four or five men, all about the same age, in our early forties, except for Dr. Bernard Lievegoed, who was in his mid-sixties then, and Lex Bos, seven years older than I. We were of different nationalities – I remember a Swiss who lived in Sao Paulo, Brazil, a German who lived in Johannesburg, South Africa. The others were Europeans, if I remember correctly. And I, an Argentine who was about to escape from my own country to Spain. Lievegoed and Bos were Dutch and we were in the Dutch city of Zeist, at the headquarters of NPI – the Netherlands Pedagogic Institute.", ], "imgUrl": `${prefix}boy-and-dog.jpg`, "link": `${prefix}anthrobio.html`, "poem": false, "mainImg": false, }, { "title": "Blonde Noir", "sub-title": "", "author": "DC Diamondopolous", "description":[ "Kit Covington sat on the sofa in her Pacific Palisades mansion with a cigarette lodged in the side of her mouth. A cloud of smoke floated around her head. She adjusted the oxygen tube in her nose, then brushed ash from her dog Muffin’s champagne-colored curls. The miniature poodle dozing in Kit’s lap startled when the camera crew from The Great Morning Talk Show banged equipment into Kit’s antique furniture.", "“Watch it! You scratch anything, you’ll pay for the restoration.” Since her left lung had been removed, Kit’s husky voice had a rattle that lingered between words chaining them together like loose ball bearings.", "“Sorry,” the stocky, tattooed sound woman said.", "Kit wondered if the all-female crew was a set-up—some kind of knife-twisting in the gut. She’d been anxious about the interview and now regretted it.", ], "imgUrl": `${prefix}woman_kooning.webp`, "link": `${prefix}blonde-noir.html`, "poem": false, "mainImg": false, }, { "title": "They Call Me Jackie Robinson in Brazil", "sub-title": "", "author": "Frank Thomas Smith", "description":[ "It's Jackie Robinson Day! All the major league baseball team players have his number – 42 – on their backs. Well, why not? Jackie was not only one of the best baseball players who ever lived, he was, more importantly, the first African American (called Negro back then) to play in the Major Leagues, for the Brooklyn Dodgers. He took a lot of racist insults – not in Brooklyn, in the South – which he knew he would, but never blew his top. It's not a national holiday yet, but somehow better.", "As I watched the ceremony honoring his memory on TV, another personal memory came to mind: why they call me Jackie Robinson in Brazil.", ], "imgUrl": `${prefix}jackie-42.jpg`, "link": `${prefix}fts-jackie-robinson-brasil.html`, "poem": false, "mainImg": false, }, { "title": "Saint Death", "sub-title": "(Bilingual)", "author": "Frank Thomas Smith", "description":[ "I had a pounding hangover when I woke up well past noon in a strange bed. A bottle of mineral water and an empty glass stood on the night table and clean towels had been placed on the dresser. I got up slowly, drank two glasses of water, opened the shutters and looked out the window. The bright sky that met the flat grassy earth at the horizon assaulted my aching eyes. After a shower and two aspirins that I found in the bathroom medicine cabinet, I eased myself downstairs to where the Prietos were having lunch in the dining room. Both were in their early sixties, Señora Prieto perhaps a few years younger. She tinkled a small bell and an obese Indian woman entered silently from the kitchen. I gladly accepted Señora Prieto’s suggestion of breakfast of café con leche, toast and marmalade. The servant waddled back to the kitchen.", "“Our son Pedro did not give us any details concerning your problem and we would not dream of asking you,” Señora Prieto said. “We can only offer you our hospitality and hope that your stay here will provide the tranquility you seek.” She was very polite and obviously sincere, but her smile seemed forced. My colleague Pedro Prieto had insisted that I go to the Chaco and spend some time on his parent’s estancia when, according to him, I was on the point of cracking up over a woman. It’s true that I was in pretty bad shape, drinking too much and all that, but…no point in getting ahead of myself.", ], "imgUrl": `${prefix}san-la-muerte-1.jpg`, "link": `${prefix}fts-saint-death.html`, "poem": false, "mainImg": false, }, { "title": "Love In The Life Of Spies", "sub-title": "", "author": "Frank Thomas Smith", "description":[ "That night I went to the Gilded Cage with a purpose and was dressed accordingly: blue sports jacket, slacks, loafers without socks, white shirt open to the third button. I arrived early and found a stool at the semi-circular bar, put a fiver on the bar for effect, ordered a Millers High Life, lit a cigarette, and looked around. The bar-stools were almost all occupied – by men. Soon they'd be three deep, it being Friday night. The piano was set back in an alcove to the left-rear of the bar. It also had bar-stools around it so you could drink there and look at the player with one elbow on the piano. Two young couples were perched on the stools, the men in suits and ties and the giggly women showing a lot of leg. The men were probably asshole officers from Fort Ord, I figured. The piano player was playing As Time Goes By, probably requested by one of the girls. That kind of girl always requested that kind of song because they liked to think of themselves as Ingrid Bergman - romantic and teary - without realizing that it wasn't a song you could request, it had to hit you out of the blue. I lit another cigarette and nursed my beer.", ], "imgUrl": `${prefix}love-life-cover.jpg`, "link": `${prefix}love-life-5.html`, "poem": false, "mainImg": false, }, ], "Social Science": [ { "title": "Favela Children - Chapter 6 & 7", "sub-title": "", "author": "Ute Creamer", "description":[ "Once upon a time there was a coral-colored serpent and a little black girl. She lived in the middle of a dense jungle. The trees grew so high and the undergrowth was so thick that the way had to be hacked out with a bush-knife, after which the jungle closed in again. The strength of the sun and the sap of the earth were so strong that every trampled blade of grass and every cut-off branch grew back almost immediately. Wild animals, tigers, serpents, armadillos, monkeys and parrots inhabited the jungle; crocodiles lounged lazily in a wide muddy stream that wandered slowly to the sea.", "Talinha, the black child, lived in this jungle. Her other had died at her birth. As the angel descended to carry her mother to heaven, she spread her wings over the new-born child, which made her invisible to human eyes. Even her father could no longer see his daughter. Sad because he lost his wife and daughter on the same day, he left his house and the jungle for good in order to live in a place where there were more people. Talinha, small and defenseless against the threatening jungle, stayed behind.", ], "imgUrl": `${prefix}favela-cover.jpg`, "link": `${prefix}favela-children-6-7.html`, "poem": false, "mainImg": false, }, { "title": "The Peace Speech", "sub-title": "", "author": "President John F. Kennedy", "description":[ "Washington, D.C. June 10, 1963", "President Anderson, members of the faculty, board of trustees, distinguished guests, my old colleague, Senator Bob Byrd, who has earned his degree through many years of attending night law school, while I am earning mine in the next 30 minutes, distinguished guests, ladies and gentlemen :", "It is with great pride that I participate in this ceremony of the American University, sponsored by the Methodist Church, founded by Bishop John Fletcher Hurst, and first opened by President Woodrow Wilson in 1914. This is a young and growing university, but it has already fulfilled Bishop Hurst’s enlightened hope for the study of history and public affairs in a city devoted to the making of history and the conduct of the public’s business. By sponsoring this institution of higher learning for all who wish to learn, whatever their color or their creed, the Methodists of this area and the Nation deserve the Nation’s thanks, and I commend all those who are today graduating.", ], "imgUrl": `${prefix}kennedy-dallas.jpg`, "link": `${prefix}kennedy-peace.html`, "poem": false, "mainImg": false, }, ], "Current Events": [ { "title": "“The Greatest Fighting Force in Human History”", "sub-title": "", "author": "William J. Astore", "description":[ "In his message to the troops prior to the July 4th weekend, Secretary of Defense Lloyd Austin offered high praise indeed. “We have the greatest fighting force in human history,” he tweeted, connecting that claim to the U.S. having patriots of all colors, creeds, and backgrounds “who bravely volunteer to defend our country and our values.”", "As a retired Air Force lieutenant colonel from a working-class background who volunteered to serve more than four decades ago, who am I to argue with Austin? Shouldn’t I just bask in the glow of his praise for today’s troops, reflecting on my own honorable service near the end of what now must be thought of as the First Cold War?", "Yet I confess to having doubts. I’ve heard it all before. The hype. The hyperbole. I still remember how, soon after the 9/11 attacks, President George W. Bush boasted that this country had “the greatest force for human liberation the world has ever known.” I also remember how, in a pep talk given to U.S. troops in Afghanistan in 2010, President Barack Obama declared them “the finest fighting force that the world has ever known.” And yet, 15 years ago at TomDispatch, I was already wondering when Americans had first become so proud of, and insistent upon, declaring our military the world’s absolute best, a force beyond compare, and what that meant for a republic that once had viewed large standing armies and constant warfare as anathemas to freedom.", ], "imgUrl": `${prefix}bush_mission_accomplished.jpg`, "link": `${prefix}astore-greatest-fighting-force.html`, "poem": false, "mainImg": false, }, { "title": "The Profiteers of Armageddon", "sub-title": "", "author": "William D. Hartung", "description":[ "Unless you’ve been hiding under a rock for the past few months, you’re undoubtedly aware that award-winning director Christopher Nolan has released a new film about Robert Oppenheimer, known as the “father of the atomic bomb” for leading the group of scientists who created that deadly weapon as part of America’s World War II-era Manhattan Project. The film has earned widespread attention, with large numbers of people participating in what’s already become known as “Barbieheimer” by seeing Greta Gerwig’s hit film Barbie and Nolan’s three-hour-long Oppenheimer on the same day.", "Nolan’s film is a distinctive pop cultural phenomenon because it deals with the American use of nuclear weapons, a genuine rarity since ABC’s 1983 airing of The Day After about the consequences of nuclear war. (An earlier exception was Stanley Kubrick’s Dr. Strangelove, his satirical portrayal of the insanity of the Cold War nuclear arms race.)", ], "imgUrl": `${prefix}oppenheimer-sensation.png`, "link": `${prefix}hartwig-profiteering.html`, "poem": false, "mainImg": false, }, { "title": "DEADLY IMMUNITY", "sub-title": "", "author": "Robert F. Kennedy Jr.", "description":[ "In June 2000, a group of top government scientists and health officials gathered for a meeting at the isolated Simpsonwood conference center in Norcross, Ga. Convened by the Centers for Disease Control and Prevention, the meeting was held at this Methodist retreat center, nestled in wooded farmland next to the Chattahoochee River, to ensure complete secrecy. The agency had issued no public announcement of the session -- only private invitations to 52 attendees. There were high-level officials from the CDC and the Food and Drug Administration, the top vaccine specialist from the World Health Organization in Geneva, and representatives of every major vaccine manufacturer, including GlaxoSmithKline, Merck, Wyeth and Aventis Pasteur. All of the scientific data under discussion, CDC officials repeatedly reminded the participants, was strictly \"embargoed.\" There would be no making photocopies of documents, no taking papers with them when they left.", ], "imgUrl": `${prefix}rfkjr.jpg`, "link": `${prefix}kennedy-deadly-immunity.html`, "poem": false, "mainImg": false, }, { "title": "AI Versus AI", "sub-title": "", "author": "Michael Klare", "description":[ "A world in which machines governed by artificial intelligence (AI) systematically replace human beings in most business, industrial, and professional functions is horrifying to imagine. After all, as prominent computer scientists have been warning us, AI-governed systems are prone to critical errors and inexplicable “hallucinations,” resulting in potentially catastrophic outcomes. But there’s an even more dangerous scenario imaginable from the proliferation of super-intelligent machines: the possibility that those nonhuman entities could end up fighting one another, obliterating all human life in the process.", "The notion that super-intelligent computers might run amok and slaughter humans has, of course, long been a staple of popular culture. In the prophetic 1983 film “WarGames,” a supercomputer known as WOPR (for War Operation Plan Response and, not surprisingly, pronounced “whopper”) nearly provokes a catastrophic nuclear war between the United States and the Soviet Union before being disabled by a teenage hacker (played by Matthew Broderick). The “Terminator” movie franchise, beginning with the original 1984 film, similarly envisioned a self-aware supercomputer called “Skynet” that, like WOPR, was designed to control U.S. nuclear weapons but chooses instead to wipe out humanity, viewing us as a threat to its existence.", ], "imgUrl": `${prefix}ai-vs-ai.jpeg`, "link": `${prefix}klare-ai-ai.html`, "poem": false, "mainImg": false, }, ], "Children's Corner": [ { "title": "The Mystery of the Headless Ghost", "sub-title": "", "author": "Nicolás Gawain Smith", "description":[ "This story is my dog Duque's fault. If Duque hadn't found those footprints...But it would be better to start at the beginning.", "It was a Monday and I was on my way to school. That day was very good in school. The English teacher was absent so we had almost an hour extra for recreation break. When I got home Duque wasn't there. I looked inside and outside, on the back porch and the front patio. Then I went out on the street to look for him. Finally I found him in the abandoned house next door barking at something. I called him but he didn't come. I whistled and he didn't come. I rolled on the floor and he didn't come. How strange, I thought. Whenever I roll on the floor he comes running and jumps on top of me. I went back home and asked my dad to let me put a leash on Duque. My dad doesn't like to put a leash on him. I went back to the abandoned house where I finally got the leash on him and brought him home.", ], "imgUrl": `${prefix}headless.webp`, "link": `${prefix}headless-ghost.html`, "poem": false, "mainImg": false, }, ], }; const articlesKeys = Object.keys(articles); // Uncheck all other hidden checkboxes when one is checked // colapses nav-menu dropdowns when a new one is expanded function createNavMenu(navMenuElement) { function createMenuLinks() { articlesKeys.forEach(category => { // create dropdown menu if there is more than one article in category if (articles[category].length === 1) { if (!articles[category][0]["title"]) return const div = document.createElement("div"); const p = document.createElement("p"); const title = articles[category][0]["title"] .toLowerCase() .replace(/[^a-zA-Z0-9]/g, ""); p.className = "nav-menu-links"; p.innerText = category; p.dataset.title = title; div.appendChild(p); navMenuElement.appendChild(div); } else if (articles[category].length > 1) { const content = document .querySelector("[data-dropdown-template]") .content.cloneNode(true); const hiddenInput = content.querySelector("[data-hidden-input]"); const label = content.querySelector("[data-label]"); const title = content.querySelector("[data-title]"); const list = content.querySelector("[data-list]"); hiddenInput.id = `${category}-input`; label.htmlFor = hiddenInput.id; title.innerHTML = `${category} ▼`; articles[category].forEach(article => { const li = document.createElement("li"); const title = article["title"] .replace(/[^a-zA-Z0-9]/g, "") .toLowerCase(); li.className = "nav-menu-links"; li.id = article["title"]; li.innerText = `${article.title} - ${article.author}`; li.dataset.title = title; list.appendChild(li); }); navMenuElement.appendChild(content); } }); const createSingleLink = (title, id) => { const div = document.createElement("div"); const p = document.createElement("p"); p.className = "nav-menu-links"; p.innerText = title; p.dataset.title = id; div.appendChild(p); navMenuElement.appendChild(div); }; createSingleLink("Other Sections", "pic-nav-menu"); createSingleLink("Subscribe", "subscribe"); } createMenuLinks(); //event listeners const navmenuLinkArray = Array.from( navMenuElement.querySelectorAll(".nav-menu-links") ); const scrollToTarget = target => { const headerOffset = 120; const elementPositon = target.getBoundingClientRect().top; const offsetPosition = elementPositon + window.pageYOffset - headerOffset; window.scrollTo({ top: offsetPosition, behavior: "smooth", }); }; navmenuLinkArray.forEach(link => { link.addEventListener("click", () => { let article = document.querySelector(`#${link.dataset.title}`); scrollToTarget(article); if (menuBar.dataset.opened === "true") { menuBar.dataset.opened = "false"; } }); }); const navChekboxes = Array.from(document.querySelectorAll(".nav-hidden-inputs")); navChekboxes.forEach(input => { input.addEventListener("change", () => { navChekboxes.forEach(element => { console.log("hi"); if (element === input) return element.checked = false; }); }); }); } function checkAndReduce() { const title = mainPage.querySelector("h2"); if (title.innerText.length > 20) { title.style.fontSize = "2.5em"; } } function appendPicNavMenu() { const picNavDiv = document .querySelector("[data-pic-nav]") .content.cloneNode(true); const nav = picNavDiv.querySelector("nav"); nav.id = "pic-nav-menu"; const subscribeDiv = document .querySelector("[data-subscribe-div]") .content.cloneNode(true); const subscribe = subscribeDiv.querySelector("div"); subscribe.id = "subscribe"; const firstChild = document.querySelector("#main-div").lastElementChild; const navDiv = document.createElement("div"); navDiv.appendChild(picNavDiv); navDiv.appendChild(subscribe); firstChild.insertAdjacentElement("afterend", navDiv); } function createArticlePeek(object) { const keys = Object.keys(object); keys.forEach(key => { if (keys.indexOf(key) !== 0) { const categoryTitle = document.createElement("h1"); categoryTitle.innerText = key; categoryTitle.className = "category-title"; mainPage.appendChild(categoryTitle); } object[key].forEach(article => { const articleDiv = document .querySelector("[data-article-template]") .content.cloneNode(true); const articleInnerDiv = articleDiv.querySelector("article"); const titleElement = articleDiv.querySelector("h2"); const author = articleDiv.querySelector("h1"); const subTitle = articleDiv.querySelector("h3"); const description = articleDiv.querySelector("[data-article-description]"); const img = articleDiv.querySelector("[data-article-img]"); const linkContainer = articleDiv.querySelector("[data-link-container]"); const link = articleDiv.querySelector("[data-article-link]"); articleInnerDiv.id = article["title"] .toLowerCase() .replace(/[^a-zA-Z0-9]/g, ""); titleElement.innerHTML = article["title"]; author.innerHTML = article["author"]; if (article["sub-title"] && article["sub-title"].length !== 0) { subTitle.innerText = article["sub-title"]; } img.src = article["imgUrl"]; linkContainer.style.display = "flex"; linkContainer.style.width = "100%"; linkContainer.style.justifyContent = "center"; link.href = article["link"]; link.style.fontSize = "130%"; link.style.fontWeight = "500"; // Special Atributes for "Featured Art" if (article["mainImg"]) { titleElement.style.marginBottom = "1em"; link.style.display = "none"; img.style.maxWidth = "80%"; img.style.maxHeight = "100%"; img.style.marginLeft = "auto"; img.style.marginRight = "auto"; img.style.marginBottom = "1em"; img.style.float = "none"; img.insertAdjacentElement("afterend", author); } // if its a poem, make the div and link float (so the text doesn't go under the img) if (article["poem"]) { description.style.float = "left"; link.style.clear = "left"; link.style.float = "right"; } let i = 1; const className = article["title"] .replace(/[^a-zA-Z0-9]/g, "") .toLowerCase(); description.id = `${className}-paragraphs-div`; link.id = `${className}-main-link`; article["description"].forEach(descriptionParagraph => { const paragraph = document.createElement("p"); paragraph.innerHTML = descriptionParagraph; paragraph.className = `${className}-paragraph-${i}`; description.appendChild(paragraph); i++; }); mainPage.appendChild(articleDiv); checkAndReduce(); }); }); appendPicNavMenu(); } function mobilePortrait() { if (previousStylesheet.dataset.stylesheet == "mobile") return pageName.innerHTML = "Menu"; //create elements in mobile-navbar createNavMenu(navMobile); //get modify input and label "for" in mobile nav const navMobileInputs = Array.from(navMobile.querySelectorAll("input")); const navMobileLabels = Array.from(navMobile.querySelectorAll("label")); navMobileInputs.forEach(input => { input.id += "-mobile"; }); navMobileLabels.forEach(label => { label.htmlFor += "-mobile"; }); //append elements topBar.appendChild(navMobile); //create observer functions let observerMobileMenu = new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.type == "attributes") { if (menuBar.dataset.opened == "true") { navMobile.classList.add("open"); menuButton.classList.add("close"); } else { navMobile.classList.remove("open"); menuButton.classList.remove("close"); } } }); }); //create menu open button - three lines for (let i = 0; i < 3; i++) { const menuButtonLine = document.createElement("div"); menuButtonLine.className = "menu-button-line"; menuButton.appendChild(menuButtonLine); } //give new class to desktop menu navMobile.className = "nav-menu menu-mobile desktop-hide"; //observe for changes observerMobileMenu.observe(menuBar, { attributes: true, }); //menu button listener menuButton.addEventListener("click", () => { if (menuBar.dataset.opened === "false") { menuBar.dataset.opened = "true"; } else { menuBar.dataset.opened = "false"; } }); previousStylesheet.dataset.stylesheet = "mobile"; // musicLinks.innerHTML = "Words and Music" } //scroll to top on refresh window.onbeforeunload = function () { window.scrollTo(0, 0); }; //create elements for data-attributes // function to set data atributes acording to screen width function setStylesheetDataAttr() { if (screen.width <= 650) { if (stylesheetSelector.dataset.stylesheet == "mobile") return stylesheetSelector.dataset.stylesheet = "mobile"; } else if (screen.width >= 651 && screen.width < 1200) { if (stylesheetSelector.dataset.stylesheet == "medium") return stylesheetSelector.dataset.stylesheet = "medium"; } else { if (stylesheetSelector.dataset.stylesheet == "desktop") return stylesheetSelector.dataset.stylesheet = "desktop"; } } //execute on rezise window.addEventListener("resize", () => { setStylesheetDataAttr(); }); //ovserve changes on data-attributes and execute functions let observerStylesheetAttr = new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.type == "attributes") { if (stylesheetSelector.dataset.stylesheet === "mobile") { mobilePortrait(); } } }); }); observerStylesheetAttr.observe(stylesheetSelector, { attributes: true, }); //onload functions window.addEventListener("load", () => { setStylesheetDataAttr(); mainPage.offsetTop; introScreen.classList.add("fade-out"); setTimeout(() => { introScreen.style.display = "none"; document.querySelector("html").style.overflowY = "visible"; lightDarkWarning.classList.remove("desktop-hide", "mobile-hide"); }, 1000); //local storage - if exists change theme if (!localStorage.getItem("style")) return lightDarkWarning.style.display = "none"; const lightOrDark = localStorage.getItem("style"); if (lightOrDark === "dark") { stylesheet.href = `${prefix}css/dark.css`; } if (screen.width <= 650) { mobilePortrait(); } }); //remove light-and-dark warning onclick lightDarkWarning.addEventListener("click", () => { lightDarkWarning.style.display = "none"; }); // Toggle Stylesheets toggleStylesheetLightButton.addEventListener("click", () => { stylesheet.href = `${prefix}css/light.css`; localStorage.setItem("style", "light"); }); toggleStylesheetDarkButton.addEventListener("click", () => { stylesheet.href = `${prefix}css/dark.css`; localStorage.setItem("style", "dark"); }); // Sticky navbar const stickyFunc = () => { const limit = mainPage.offsetTop; const navCol = document.querySelector("#sticky-div "); if (window.pageYOffset + 50 >= limit) { navCol.classList.add("fixed-nav-col"); } else { navCol.classList.remove("fixed-nav-col"); } }; //observer function, scroll-in abnormal logo when footer is 50% visible let notFirstTime = 0; const observer = new IntersectionObserver( entries => { if (entries[0].isIntersecting === true) { if (notFirstTime > 0) return abnormalLogoStylesheet.href = `${prefix}css/logo2.css`; abnormalLogo.classList.add("logo-animation"); notFirstTime++; } }, { threshold: [0.5] } ); observer.observe(footerAbnormal); createNavMenu(navMenu); createArticlePeek(articles); window.onscroll = () => { stickyFunc(); }; })();