You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.5 KiB
130 lines
4.5 KiB
3 months ago
|
<!doctype html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
<title>My Learning Website</title>
|
||
|
<link href="/styles/styles.css" rel="stylesheet" type="text/css">
|
||
|
<link href="/webdevelopment/styles/styles.css" rel="stylesheet" type="text/css">
|
||
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||
|
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||
|
<!--[if lt IE 9]>
|
||
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||
|
<![endif]-->
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<h1 class="courselink">JavaScript Essential Training</h1>
|
||
|
<h2 class="lecturer">LinkedIn Learning : Morten Rand-Hendriksen</h2>
|
||
|
<h1 class="episodetitle">Code Samples</h1>
|
||
|
|
||
|
<article>
|
||
|
<h2 class="sectiontitle">Code Sample 1</h2>
|
||
|
<p>This is the code example for 05_02 in the exercise files. </p>
|
||
|
<h2 class="sectiontitle">The HTML Document</h2>
|
||
|
<pre class="codesample">
|
||
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8" />
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
|
<title>BackpackPacker</title>
|
||
|
<link
|
||
|
href="https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&family=Work+Sans:wght@100..900&display=swap"
|
||
|
rel="stylesheet"
|
||
|
/>
|
||
|
<link
|
||
|
rel="stylesheet"
|
||
|
href="../assets/style.css"
|
||
|
type="text/css"
|
||
|
media="all"
|
||
|
/>
|
||
|
<script type="module" src="Backpack.js"></script>
|
||
|
<script type="module" src="script.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<header class="siteheader">
|
||
|
<div class="site-title">BackpackPacker</div>
|
||
|
<div class="site-description">All backpack packing, all the time.</div>
|
||
|
</header>
|
||
|
<main class="maincontent"></main>
|
||
|
<footer class="sitefooter">
|
||
|
<p>
|
||
|
Demo project for JavaScript Essential Training, a LinkedIn Learning
|
||
|
course.
|
||
|
</p>
|
||
|
</footer>
|
||
|
</body>
|
||
|
</html></pre>
|
||
|
<p>The only difference between these two HTML files is that in the second version, there is no HTML in the body.</p>
|
||
|
<h2 class="sectiontitle">The JavaScript file</h2>
|
||
|
<pre class="codesample">
|
||
|
/**
|
||
|
* Traverse the DOM tree using querySelector() and querySelectorAll()
|
||
|
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector
|
||
|
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll
|
||
|
*/
|
||
|
|
||
|
import Backpack from "./Backpack.js";
|
||
|
|
||
|
const everydayPack = new Backpack(
|
||
|
"Everyday Backpack",
|
||
|
30,
|
||
|
"grey",
|
||
|
15,
|
||
|
26,
|
||
|
26,
|
||
|
false,
|
||
|
"December 5, 2018 15:00:00 PST",
|
||
|
"../assets/images/everyday.svg"
|
||
|
);
|
||
|
|
||
|
const main = document.querySelector(".maincontent");
|
||
|
|
||
|
const content = `
|
||
|
<article class="backpack" id="everyday">
|
||
|
<figure class="backpack__image">
|
||
|
<img src=${everydayPack.image} alt="" />
|
||
|
</figure>
|
||
|
<h1 class="backpack__name">${everydayPack.name}</h1>
|
||
|
<ul class="backpack__features">
|
||
|
<li class="backpack__volume">Volume:<span> ${
|
||
|
everydayPack.volume
|
||
|
}l</span></li>
|
||
|
<li class="backpack__color">Color:<span> ${everydayPack.color}</span></li>
|
||
|
<li class="backpack__age">Age:<span> ${everydayPack.backpackAge()} days old</span></li>
|
||
|
<li class="backpack__pockets">Number of pockets:<span> ${
|
||
|
everydayPack.pocketNum
|
||
|
}</span></li>
|
||
|
<li class="backpack__strap">Left strap length:<span> ${
|
||
|
everydayPack.strapLength.left
|
||
|
} inches</span></li>
|
||
|
<li class="backpack__strap">Right strap length:<span> ${
|
||
|
everydayPack.strapLength.right
|
||
|
} inches</span></li>
|
||
|
<li class="backpack__lid">Lid status:<span> ${
|
||
|
everydayPack.lidOpen
|
||
|
}</span></li>
|
||
|
</ul>
|
||
|
</article>
|
||
|
`;
|
||
|
|
||
|
main.innerHTML = content;</pre>
|
||
|
</article>
|
||
|
|
||
|
<div class="btngroup">
|
||
|
<button class="button" onclick="window.location.href='javascriptessentialtraining2021.html'">
|
||
|
Course Contents
|
||
|
</button>
|
||
|
<button class="button" onclick="window.location.href='/webdevelopment/webdevelopment.html'">
|
||
|
Web Development Page
|
||
|
</button>
|
||
|
<button class="button" onclick="window.location.href='/index.html'">
|
||
|
Home
|
||
|
</button>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|