-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
68 lines (51 loc) · 1.34 KB
/
script.js
File metadata and controls
68 lines (51 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function initFireBase(){
var config = {
apiKey: "AIzaSyCl_mlUCPiTR3Cwmu4be3DpWiab-V-mpkI",
authDomain: "avagenerator.firebaseapp.com",
databaseURL: "https://avagenerator.firebaseio.com",
projectId: "avagenerator",
storageBucket: "avagenerator.appspot.com",
messagingSenderId: "140289767041"
};
firebase.initializeApp(config);
}
function changeColor(t){
head.style.fill=t.value;
body.style.fill=t.value;
color = t.value;
}
function saveColor(t){
if(color){
firebase.database().ref('colors/').push({
hex: color
});
document.location.reload(true);
}
}
function loadColors(){
firebase.database().ref('colors/').once('value').then(function(snapshot) {
var data = snapshot.val();
for(var i in data){
for(var j in data[i]){
colors.push(data[i][j]);
console.log(colors);
}
}
displayColors();
});
}
function displayColors() {
var ul = document.getElementById("list");
for(var i=0;i<colors.length;i++){
var li = document.createElement("li");
li.appendChild(document.createTextNode(colors[i]));
ul.appendChild(li);
li.setAttribute("class", "avatar");
li.setAttribute("value",colors[i]);
li.style.backgroundColor=colors[i];
}
}
var colors = [];
var color;
initFireBase();
loadColors();