Skip to content

Instantly share code, notes, and snippets.

View banhaclong20's full-sized avatar

Tom Tran banhaclong20

View GitHub Profile
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
$('#siteForm').on('submit', function (e) {
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize()
}).done(function () {
$('#sideProof').hide('fast');
$('#rightContent').show('fast');
});
return false;
@banhaclong20
banhaclong20 / destructuring.js
Created September 21, 2017 22:33 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@banhaclong20
banhaclong20 / Vanilla JS Simple Cheatsheet
Last active December 6, 2017 22:21
Vanilla JS Simple Cheatsheet
/* Grab Children/Parent Node(s) */
var parent = document.getElementById('container');
var children = parent.childNodes;
var parentNode = children.parentNode;
/* Create New DOM Elements /*
var newH1 = document.createElement('h1');
var newPara = document.createElement('p');
@banhaclong20
banhaclong20 / Generate Unique Number in JavaScript
Created October 21, 2017 22:55
Generate Unique Number in JavaScript
function uniqueNumber() {
var date = Date.now();
if (date <= uniqueNumber.previous) {
date = ++uniqueNumber.previous;
} else {
uniqueNumber.previous = date;
}
return date;
@banhaclong20
banhaclong20 / Simple steps to add existing project to Github.
Last active October 26, 2017 18:36
Adding an existing project to GitHub using the command line
1. Create a new repository on GitHub.
2. In Terminal, change the current working directory to your local project.
git init
git add .
or:
git add --all
git commit -m 'First commit'
git remote add origin <remote repository URL>
@banhaclong20
banhaclong20 / createEvent-dispatchEvent and preventDefault
Created November 2, 2017 21:42
Create dispatchEvent Vanilla JS
// Markup
<input type="checkbox" id="checkbox"/><label for="checkbox">Checkbox</label>
Simulate click <input type="button" onclick="simulateClick();" value="Simulate click"/>
Add a click handler that calls preventDefault <input type="button" onclick="addHandler();" value="Add a click handler that calls preventDefault"/>
Remove the click handler that calls preventDefault <input type="button" onclick="removeHandler();" value="Remove the click handler that calls preventDefault"/>
// Script
var checkbox = document.querySelector('.checkbox')
@banhaclong20
banhaclong20 / Touch swipe detection in pure JavaScript
Created November 2, 2017 22:41
Touch swipe detection in pure JavaScript
<div id="swipezone">
Swipe me
</div>
// credit: http://www.javascriptkit.com/javatutors/touchevents2.shtml
function swipedetect(el, callback){
var touchsurface = el,
swipedir,
startX,
@banhaclong20
banhaclong20 / Combine Arrays with Spread Operator
Created December 6, 2017 23:05
Combine Arrays with Spread Operator
arr1.push(...arr2) // Adds arr2 items to end of array
arr1.unshift(...arr2) //Adds arr2 items to beginning of array
var arr1 = ['two', 'three'];
var arr2 = ['one', ...arr1, 'four', 'five'];
// ["one", "two", "three", "four", "five"]
@banhaclong20
banhaclong20 / Semantic HTML
Created December 17, 2017 22:38
Semantic HTML
//Some that you can use the project
// DATA LIST
<input list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">