This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Waits for an element satisfying selector to exist, then resolves promise with the element. | |
* Useful for resolving race conditions. | |
* | |
* @param selector | |
* @returns {Promise} | |
*/ | |
function elementReady(selector) { | |
return new Promise((resolve, reject) => { | |
let el = document.querySelector(selector); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How long you want the animation to take, in ms | |
const animationDuration = 2000; | |
// Calculate how long each ‘frame’ should last if we want to update the animation 60 times per second | |
const frameDuration = 1000 / 60; | |
// Use that to calculate how many frames we need to complete the animation | |
const totalFrames = Math.round( animationDuration / frameDuration ); | |
// An ease-out function that slows the count as it progresses | |
const easeOutQuad = t => t * ( 2 - t ); | |
// Variables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use("/", (req, res, next) => { | |
console.log("I am a middleaware") | |
next() | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
"scripts": { | |
"start": "nodemon index.js" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", function(event) { | |
console.log( 'Hello From Public' ); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: beige | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="css/styles.css"> | |
<script src="js/index.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
// path is a built in module in Node | |
// It Helps get the specific path to the files | |
const path = require('path') | |
// Add the Public Folder for Assets | |
app.use(express.static('public')) | |
app.listen( 3000, () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir public && cd public | |
# Create the sub folders | |
mkdir css js | |
# Create the style file | |
cd css && touch styles.css | |
# Create the script file | |
cd ../js && touch index.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
// path is a built in module in Node | |
// It Helps get the specific path to the files | |
const path = require('path') | |
app.listen( 3000, () => { | |
console.log('App listening on port 3000') | |
}) |