Giter Site home page Giter Site logo

piecioshka / warsawjs-workshop-41-gallery Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 4.0 18 KB

⛩️ WarsawJS Workshop #41 — JavaScript (Basic Level)

Home Page: https://piecioshka.github.io/warsawjs-workshop-41-gallery/

HTML 23.93% JavaScript 76.07%
warsawjs warsawjs-workshop warsawjs-workshop-41 javascript

warsawjs-workshop-41-gallery's Introduction

warsawjs-workshop-41-gallery

⛩️ WarsawJS Workshop #41 — JavaScript (Basic Level)

Preview 🎉

https://piecioshka.github.io/warsawjs-workshop-41-gallery

Links

What subjects can you learn after doing this project?

JavaScript
  • ✅ Variables (var, let, const)
  • ✅ Data Types (string, number, array)
  • ✅ Operators (++, ===, <)
  • ✅ Functions (Function Declaration, Method Shorthand Definition)
  • ✅ Arrays
  • ✅ Objects
  • ✅ Conditions (if)
  • ✅ Loops (for, forEach)
  • ✅ Error Handling (try...catch)
  • ⚠️ Falsy Values (false, 0, '', NaN, null, undefined)
  • ⚠️ JSON
  • ⚠️ BOM — Browser Object Model
  • ✅ Date
  • ⚠️ Math
  • ✅ Clocks (setTimeout, setInterval)
  • ✅ Comments
  • ✅ DOM Elements (ClassList API)

Step by step 👣

Display photos

  • EDIT: scripts/main.js
  • EDIT: index.html
    • Link a main.js file by script tag
  • EDIT: scripts/main.js
    • Create function main()
    • Create list of different URLs to photos
    • Create loop for
    • Create HTMLImageElement for each array item

Refactoring

  • EDIT: scripts/main.js
    • Create function renderPhoto()
      • With for loop content
    • Create function renderPhotos()
      • Use Array.prototype.forEach
    • Change structure of photos
      • Switch from URL to object with url property

Handle empty photos

  • EDIT: scripts/main.js
    • Create function displayMessage()
      • TALK: innerHTML, innerText, textContent
      • Use simple strategy with textContent
      • Use complex strategy with innerHTML with Bulma component
    • Create function displayEmptyGalleryMessage()
    • Add condition if an array is empty
    • Comment content of photos collection

Handler errors

  • EDIT: scripts/main.js
    • Add null as next element of photos
    • Add try...catch to catch Uncaught TypeError
      • Cannot read property 'url' of null

Loader

  • EDIT: images/loader.gif
  • EDIT: scripts/loader.js
    • Create object loader with functions: show(), hide()
  • EDIT: index.html
    • Link a loader.js file by script tag
  • EDIT: scripts/loader.js
    • Funkcja show()
      • Get reference to outlet container
      • Create HTMLElement
    • Funkcja hide()
      • Remove HTMLElement from DOM
  • EDIT: scripts/main.js
    • Invoke loader.show() and the beginning
    • Invoke loader.hide() before rendering use setTimeout

Display current time

  • EDIT: scripts/main.js
    • Create function displayCurrentTime()
    • Use setInterval() to render time on each second

Related

License

The MIT License @ 2020

warsawjs-workshop-41-gallery's People

Contributors

piecioshka avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.