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> | |
Hex Color Generator | |
</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="style.css" /> |
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 getColor() { | |
return '#' + Math.random().toString(16).slice(2, 8); | |
} |
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 setBackground() { | |
var bgColor = getColor(); | |
document.body.style.background = bgColor; | |
} | |
setBackground() |
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.body.onkeyup = function(e){ | |
if(e.keyCode == 32){ | |
setBackground(); | |
} | |
} |
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
// generator function | |
function getColor() { | |
return '#' + Math.random().toString(16).slice(2, 8); | |
} | |
// sets background color style | |
function setBackground() { | |
var bgColor = getColor(); | |
document.body.style.background = bgColor; | |
} | |
// runs function on click |
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
body { | |
transition: all .5s ease; | |
} |
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> | |
<head> | |
<title>Text Editor</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="style.css"/> | |
</head> | |
<div id="heading" contenteditable="true"></div> | |
<div id="content" contenteditable="true"></div> |
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 { | |
font-family: 'Helevetica', sans-serif; | |
} | |
body { | |
color: #333; | |
font-weight: 100; | |
max-width: 50em; | |
margin: 0 auto; | |
} |
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.getElementById('heading').innerHTML = localStorage['title'] || 'Just Write'; // default text | |
document.getElementById('content').innerHTML = localStorage['text'] || 'This text is automatically saved every second :) '; // default text | |
setInterval(function() { // fuction that is saving the innerHTML of the div | |
localStorage['title'] = document.getElementById('heading').innerHTML; // heading div | |
localStorage['text'] = document.getElementById('content').innerHTML; // content div | |
}, 1000); |
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> | |
<head> | |
<title>Clock</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="style.css" /> | |
</head> | |
<body> |
OlderNewer