Created
October 19, 2012 04:53
-
-
Save jacktandrew/3916296 to your computer and use it in GitHub Desktop.
html5 Summary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var loadingPage = null; | |
$('nav a').click(function(e) { | |
e.preventDefault(); | |
$('nav a').removeClass('active'); | |
$(this).addClass('active'); | |
var page = $(this).data('page'); | |
$('.content').hide(); | |
if (loadingPage){ | |
loadingPage.abort(); | |
} | |
loadingPage = $.ajax({ | |
url: '/pages/' + page + '.html', | |
cache: false, | |
timeout: 8000, | |
beforeSend: function(){ | |
$('.error').hide(); | |
$('.loading').show(); | |
}, | |
complete: function(){ | |
$('.loading').hide(); | |
}, | |
success: function(data){ | |
$('.content').html(data).show(); | |
}, | |
error: function(){ | |
if (result.statusText != 'abort'){ | |
$('.error').show(); | |
} | |
} | |
}); | |
}); | |
$('.error a').click(function(e){ | |
e.preventDefault(); | |
loadPage($('nav a.active').data('page')) | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Dramatic Chipmunk</h3> | |
<video controls preload width=400px height=300px> | |
<source src="dramatic_chipmunk.ogv" type="video/ogg"> | |
<source src="dramatic_chipmunk.mp4" type="video/mpeg"> | |
You do not have HTML5 Video support. | |
</video> | |
<h3>Inconceivable</h3> | |
<audio controls> | |
<source src="thatword.ogg" type="audio/ogg"> | |
<source src="thatword.mp3" type="audio/mpeg"> | |
Your browser does not support the audio tag. | |
</audio> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function drawShape(){ | |
var canvas = document.getElementById('smiley'); | |
var ctx = canvas.getContext('2d'); | |
ctx.beginPath(); | |
ctx.arc(100,100,100,0,Math.PI*2,true); // Outer circle | |
ctx.moveTo(150,110); | |
ctx.arc(100,110,50,0,Math.PI,false); // Mouth | |
ctx.moveTo(70,65); | |
ctx.arc(60,65,10,0,Math.PI*2,true); // Left eye | |
ctx.moveTo(150,65); | |
ctx.arc(140,65,10,0,Math.PI*2,true); // Right eye | |
ctx.stroke(); | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function afterLoad(){ | |
var pegs = document.querySelectorAll('.peg_box div'); | |
[].forEach.call(pegs, function(peg) { | |
peg.addEventListener('dragstart', startDrag, false); | |
}); | |
var holes = document.querySelectorAll('.hole_box div'); | |
[].forEach.call(holes, function(hole) { | |
hole.addEventListener('dragenter', isDroppable, false); | |
hole.addEventListener('dragover', function(e){e.preventDefault();}, false); | |
hole.addEventListener('drop', dropped, false); | |
}); | |
}; | |
function startDrag(e) { | |
var html = e.target.outerHTML; | |
pegName = e.target.classList[0]; | |
e.dataTransfer.effectAllowed = "move"; | |
e.dataTransfer.setData('text/plain', html); | |
} | |
function isDroppable(e) { | |
e.preventDefault(); | |
if (e.target.classList[0] === pegName) { | |
isMatch = true; | |
} else { | |
isMatch = false; | |
}; | |
} | |
function dropped(e) { | |
e.preventDefault(); | |
if (isMatch === true) { | |
e.target.innerHTML = e.dataTransfer.getData('text/plain'); | |
var dropped = document.querySelector('.' + pegName); | |
document.querySelector('.peg_box').removeChild(dropped); | |
} | |
} | |
window.addEventListener('load', afterLoad, false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang=en> | |
<head> | |
<meta charset=utf-8> | |
<title>HTML5 Summary</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg width="300" height="300" xmlns="http://www.w3.org/2000/svg"> | |
<circle r="100" cy="100" cx="100" // Outer Circle | |
stroke-width="1" stroke="#000" fill="none"/> | |
<path d="M50 110 A 35 35, 1, 0, 0, 150 110" // Mouth | |
stroke-width="1" stroke="#000" fill="none" /> | |
<circle r="10" cy="65" cx="60" // Left Eye | |
stroke-width="1" stroke="#000" fill="none"/> | |
<circle r="10" cy="65" cx="140" // Right Eye | |
stroke-width="1" stroke="#000" fill="none"/> | |
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Dramatic Chipmunk</h3> | |
<video controls preload width=400px height=300px> | |
<source src="dramatic_chipmunk.ogv" type="video/ogg"> | |
<source src="dramatic_chipmunk.mp4" type="video/mpeg"> | |
You do not have HTML5 Video support. | |
</video> | |
<h3>Inconceivable</h3> | |
<audio controls> | |
<source src="thatword.ogg" type="audio/ogg"> | |
<source src="thatword.mp3" type="audio/mpeg"> | |
Your browser does not support the audio tag. | |
</audio> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Dramatic Chipmunk</h3> | |
<video controls preload width=400px height=300px> | |
<source src="dramatic_chipmunk.ogv" type="video/ogg"> | |
<source src="dramatic_chipmunk.mp4" type="video/mpeg"> | |
You do not have HTML5 Video support. | |
</video> | |
<h3>Inconceivable</h3> | |
<audio controls> | |
<source src="thatword.ogg" type="audio/ogg"> | |
<source src="thatword.mp3" type="audio/mpeg"> | |
Your browser does not support the audio tag. | |
</audio> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment