Skip to content

Instantly share code, notes, and snippets.

View potikanond's full-sized avatar

D. Potikanond potikanond

  • Computer Engineering, CMU
  • Thailand
View GitHub Profile
@potikanond
potikanond / index.html
Last active January 21, 2020 08:27
JavaScript Simple Form and DOM
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>JS Crash Course</title>
</head>
@potikanond
potikanond / es5-oop.js
Last active January 21, 2020 00:46
JavaScript OOP ES5 and ES6
// OOP <ES5-2016> - constructive function
function Person(firstName, lastName, dob) {
// properties
this.fname = firstName;
this.lname = lastName;
// this.dob = dob;
this.dob = (dob === undefined)? new Date(): new Date(dob);
// methods - listed as properties in the object (NOT in prototype)
/* this.getBirthYear = function () { return this.dob.getFullYear(); }
@potikanond
potikanond / validation.html
Created January 20, 2020 16:10
JavaScript simple form validation
<html>
<head>
<title>Form Validation</title>
</head>
<body>
<form action="" name="myForm" onsubmit="return(validate());">
<table cellspacing="2" cellpadding="2" border="1">
@potikanond
potikanond / guessing.html
Created January 14, 2020 06:40
HTML boilerplate or guessing game
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Number guessing game</title>
<style>
html {
font-family: sans-serif;
}
body {
@potikanond
potikanond / README-js-dom2.md
Last active January 14, 2020 06:10
JavaScript DOM Tutorial #2

JavaScript DOM Tutorial #2

A tutorial for advanced JavaScript DOM manipulation. We will use the Drum project to learn this section. Start by linking up the HTML with the CSS and JavaScript file.

Adding Event Listeners

In order to detect events on the page, we need to add event listener(s). We can create a function that will be called when a button is clicked.

// add a click event listener to the 1st button
@potikanond
potikanond / README-js-dom1.md
Last active October 31, 2023 20:59
JavaScript DOM Tutotrial #1

JavaScript DOM Tutorial #1

A tutorial from JavaScript DOM manipulation

Adding JavaScript to Website

Inline JavaScript

Add onload="..." action to the body element. The JS code inside will be executed when the page is loaded.

@potikanond
potikanond / README-js-crash.md
Last active January 14, 2020 06:25
JavaScript Tutorial 2020

JavaScript Crash Course

Use Console tab for single line instruction. Executing single instruction at a time.

// Warning
alert('Hello');

// Confirm?
let val = confirm("Do you want to continue ?");
@potikanond
potikanond / index.html
Last active January 14, 2020 06:50
Web1 - Simple Firefox Page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My test page</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
</head>
<body>
<h1>Mozilla is Cool!</h1>
@potikanond
potikanond / index.html
Last active January 21, 2020 12:47
JavaScript - Fetch API Tutorial (HTML, JSON)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- 9. add bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
@potikanond
potikanond / main.handlebars
Created April 21, 2019 04:13
Express Tutorial - "main" handlebars template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Members App</title>
</head>
<body>