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
var docElm = document.documentElement; | |
if (docElm.requestFullscreen) { | |
docElm.requestFullscreen(); | |
} | |
else if (docElm.mozRequestFullScreen) { | |
docElm.mozRequestFullScreen(); | |
} | |
else if (docElm.webkitRequestFullScreen) { | |
docElm.webkitRequestFullScreen(); | |
} |
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
if (document.exitFullscreen) { | |
document.exitFullscreen(); | |
} | |
else if (document.mozCancelFullScreen) { | |
document.mozCancelFullScreen(); | |
} | |
else if (document.webkitCancelFullScreen) { | |
document.webkitCancelFullScreen(); | |
} | |
else if (document.msExitFullscreen) { |
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
document.addEventListener("fullscreenchange", function () { | |
fullscreenState.innerHTML = (document.fullscreen)? "" : "not "; | |
}, false); | |
document.addEventListener("mozfullscreenchange", function () { | |
fullscreenState.innerHTML = (document.mozFullScreen)? "" : "not "; | |
}, false); | |
document.addEventListener("webkitfullscreenchange", function () { | |
fullscreenState.innerHTML = (document.webkitIsFullScreen)? "" : "not "; |
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
html:-moz-full-screen { | |
background: red; | |
} | |
html:-webkit-full-screen { | |
background: red; | |
} | |
html:-ms-fullscreen { | |
background: red; |
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
var date = new Date(); | |
console.log(date); | |
var dateAsString = JSON.stringify(date); | |
console.log(dateAsString); | |
var dateAsObj = new Date(JSON.parse(dateAsString)); | |
console.log(dateAsObj); |
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
var cast = { | |
"Adm. Adama" : "Edward James Olmos", | |
"President Roslin" : "Mary McDonnell", | |
"Captain Adama" : "Jamie Bamber", | |
"Gaius Baltar" : "James Callis", | |
"Number Six" : "Tricia Helfer", | |
"Kara Thrace" : " Katee Sackhoff" | |
}; | |
// Stores the JavaScript object as a string |
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
// Get a reference to the image element | |
var elephant = document.getElementById("elephant"); | |
// Take action when the image has loaded | |
elephant.addEventListener("load", function () { | |
var imgCanvas = document.createElement("canvas"), | |
imgContext = imgCanvas.getContext("2d"); | |
// Make sure canvas is as big as the picture | |
imgCanvas.width = elephant.width; |
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
<figure> | |
<img id="elephant" src="about:blank" alt="A close up of an elephant"> | |
<noscript> | |
<img src="elephant.png" alt="A close up of an elephant"> | |
</noscript> | |
<figcaption>A mighty big elephant, and mighty close too!</figcaption> | |
</figure> |
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
// localStorage with image | |
var storageFiles = JSON.parse(localStorage.getItem("storageFiles")) || {}, | |
elephant = document.getElementById("elephant"), | |
storageFilesDate = storageFiles.date, | |
date = new Date(), | |
todaysDate = (date.getMonth() + 1).toString() + date.getDate().toString(); | |
// Compare date and create localStorage if it's not existing/too old | |
if (typeof storageFilesDate === "undefined" || storageFilesDate < todaysDate) { | |
// Take action when the image has loaded |
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
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob | |
var rhinoStorage = localStorage.getItem("rhino"), | |
rhino = document.getElementById("rhino"); | |
if (rhinoStorage) { | |
// Reuse existing Data URL from localStorage | |
rhino.setAttribute("src", rhinoStorage); | |
} | |
else { | |
// Create XHR, Blob and FileReader objects | |
var xhr = new XMLHttpRequest(), |
OlderNewer