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 / 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-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 / 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 / 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 / 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 / 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 / index.html
Created January 21, 2020 03:24
JavaScript - Weight Converter App (HTML 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">
@potikanond
potikanond / index.html
Created January 21, 2020 03:29
JavaScript - Filterable List (HTML 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">
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
@potikanond
potikanond / score-card.js
Last active February 14, 2020 10:25
CPE Project Scorecard
$(document).ready(function(){
$("#myBtn").click(function(){
$("#myModal").modal();
});
$(".form-control").change(validateCell);
$("#btn-save").click(saveScores);
$("#copy-score").click(copyScores);
@potikanond
potikanond / Members.js
Last active February 4, 2020 05:27
Simple Node Tutorial
// 4 - Array of member objects
const members = [
{
id: 1,
name: 'John Doe',
email: '[email protected]',
status: 'active'
},
{
id: 2,