Skip to content

Instantly share code, notes, and snippets.

View jasontwuk's full-sized avatar

Jason Liao jasontwuk

View GitHub Profile
@jasontwuk
jasontwuk / runWithDebugger.js
Created June 15, 2019 16:14
Watch and Code - Beasts 2. Improving runWithDebugger
function runWithDebugger(callback, array){
debugger;
// when has second argument
if(arguments.length > 1){
// when second argument's type is array
if(Array.isArray(array)){
callback.apply(null, array);
// when second argument's type is not array
@jasontwuk
jasontwuk / libraryWithDependencySystem.js
Created June 17, 2019 06:46
Watch and Code - Beasts 4. librarySystem with dependencies
(function(){
// build a storage for libraries
var libraryStorage = {};
function librarySystem(libraryName, dependencyArray, callback){
// when has dependencyArray and callback
if(arguments.length > 1){
// when has dependency
if(dependencyArray.length > 0){
// save the content of dependency in an array
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch14-exercise-Build A Table</title>
</head>
<body>
<h1>Mountains</h1>
<div id="mountains"></div>
<script>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch14-exercise-Element By Tag Name</title>
</head>
<body>
<h1>Heading with a <span>span</span> element.</h1>
<p>A paragraph with <span>one</span>, <span>two</span> spans.</p>
<script>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch14-exercise-The Cat's Hat</title>
<style>body { min-height: 200px }</style>
</head>
<body>
<img src="img/cat.png" id="cat" style="position: absolute">
<img src="img/hat.png" id="hat" style="position: absolute">
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch15-exercise-Balloon</title>
</head>
<body>
<p id="myP">🎈</p>
<script>
let balloon = document.getElementById("myP");
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch15-exercise-Mouse Trail</title>
<style>
.trail { /* className for the trail elements */
position: absolute;
height: 6px;
width: 6px;
border-radius: 3px;
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch15-exercise-Tabs</title>
</head>
<body>
<tab-panel>
<div data-tabname="one">Tab one</div>
<div data-tabname="two">Tab two</div>
<div data-tabname="three">Tab three</div>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch16-exercise-GameOver</title>
<script src="levels.js"></script>
<!-- <link rel="stylesheet" href="css/game.css"> -->
<style>
.background { background: rgb(52, 166, 251);
table-layout: fixed;
border-spacing: 0; }
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ch16-exercise-PausingTheGame</title>
<script src="levels.js"></script>
<!-- <link rel="stylesheet" href="css/game.css"> -->
<style>
.background { background: rgb(52, 166, 251);
table-layout: fixed;
border-spacing: 0; }