Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
color picker
  • Loading branch information
bpd01001 committed Feb 5, 2020
1 parent e0c6927 commit 5fb14b0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
41 changes: 41 additions & 0 deletions week-3/color-picker.html
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Color Picker</title>
</head>
<body>

<form >

<input type="color" name="bg" id="bg">
</form>


<script>
let picker = document.getElementById('bg');
let body = document.querySelector('body');
let keyName = "bgColor";
let bgColor = window.localStorage.getItem(keyName) || '#ffffff';

picker.addEventListener('change', function(event) {
let hex = this.value;
console.log(hex);
setBg(hex);
window.localStorage.setItem(keyName, hex);

})

function setBg(color){
body.style.backgroundColor = color;
picker.value = color;
}

setBg(bgColor);


</script>
</body>
</html>
32 changes: 31 additions & 1 deletion week-3/firestore.html
Expand Up @@ -36,8 +36,38 @@

</ul>


<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-firestore.js"></script>
<script>

// Initialize Cloud Firestore through Firebase
firebase.initializeApp({
apiKey: "AIzaSyBi03NBONZ2ncp4PSvjbAplWm6pC5XnjTw",
authDomain: "dmd-4470.firebaseapp.com",
databaseURL: "https://dmd-4470.firebaseio.com",
projectId: "dmd-4470",
storageBucket: "dmd-4470.appspot.com",
messagingSenderId: "159373794744",
appId: "1:159373794744:web:ca93db7d63c296b472834d"
});
var db = firebase.firestore();


var docRef = db.collection("shopping-lists").doc("mnTUo37Vem1NO2n7CptX");

docRef.get().then(function (doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
// doc.data() will be undefined in this case
console.log("No such document!");
}
}).catch(function (error) {
console.log("Error getting document:", error);
});



const addBtn = document.getElementById('add');
const inputBox = document.getElementById('item');
const list = document.getElementById('shopping-list');
Expand Down

0 comments on commit 5fb14b0

Please sign in to comment.