Skip to content

Instantly share code, notes, and snippets.

<!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" />
@shamdasani
shamdasani / app.js
Last active October 17, 2016 01:10
function hex color
function getColor() {
return '#' + Math.random().toString(16).slice(2, 8);
}
@shamdasani
shamdasani / app.js
Last active October 17, 2016 01:12
setbackground function
function setBackground() {
var bgColor = getColor();
document.body.style.background = bgColor;
}
setBackground()
@shamdasani
shamdasani / app.js
Created October 17, 2016 01:24
spacebar-color
document.body.onkeyup = function(e){
if(e.keyCode == 32){
setBackground();
}
}
// 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
body {
transition: all .5s ease;
}
@shamdasani
shamdasani / index.html
Created October 24, 2016 00:03
text editor
<!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>
html {
font-family: 'Helevetica', sans-serif;
}
body {
color: #333;
font-weight: 100;
max-width: 50em;
margin: 0 auto;
}
@shamdasani
shamdasani / app.js
Last active November 5, 2016 18:34
1 text editor
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);
@shamdasani
shamdasani / index.html
Created November 5, 2016 19:49
clock html
<!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>