Giter VIP home page Giter VIP logo

levelupjosh-dev / js.land Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 20.51 MB

Js.Land will provide tools, knowledge and access to anyone pursuing their dreams of being a better developer. JsLand is my attempt to find a way to share the lessons, articles, and knowledge I have gathered over the years and still do to this day. As well as a way to connect with the greater community of developers.

Home Page: https://js.land/

License: MIT License

JavaScript 51.70% CSS 48.30%
css deno denodeploy html html5 javascript js nodejs

js.land's People

Stargazers

 avatar

Watchers

 avatar

Forkers

the-jsland

js.land's Issues

Content Gird JS

(async function ContentGrid() {
  const contentCards = document.querySelectorAll(`.content-grid .card`);
  contentCards.forEach((element) => {
    element.addEventListener("click", async function (event) {
      event.preventDefault();
      const urlFragments = event.currentTarget.closest("a").href.split("/");
      const contentId = urlFragments[4];
      const requestPath = `${urlFragments[4]}`;
      const response = fetch(requestPath, {
        method: "GET",
        credentials: "same-origin",
        headers: {
          "Content-Type": "application/json",
        },
      }).then((response) => {
        response.json().then((body) => {
          const content = JSON.parse(body);
          const contentGrid = document.querySelector(`.content-grid`);
          const contentContainer = document.querySelector(`.content-container`);
          contentGrid.style.display = "none";
          contentContainer.innerHTML = content.body;
        });
      });
    });
  });

  const contentContainer = document.querySelector(`.content-container`);
  const contentGrid = document.querySelector(`.content-grid`);
  const contentClose = document.querySelector(`.content-close`);
  const contentObserver = new MutationObserver(function (mutations) {
    if (mutations[0].addedNodes.length > 0) {
      let mutationEvent = new Event("content-loaded");
      mutationEvent.data = mutations;
      console.log(`content-loaded`);
      window.dispatchEvent(mutationEvent);
    }
  });

  contentObserver.observe(contentContainer, {
    childList: true,
    characterDataOldValue: true,
  });

  window.addEventListener("content-loaded", function (event) {
    const eventData = event.data[0] || null;
    const contentClose = eventData.target.querySelector(".content-close");
    console.log(eventData);
    contentClose.addEventListener("click", function (event) {
      event.preventDefault();
      contentGrid.style.display = "block";
      contentContainer.innerHTML = "";
    });
  });
})();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.