-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolourcombo.html
More file actions
74 lines (64 loc) · 2.39 KB
/
Copy pathcolourcombo.html
File metadata and controls
74 lines (64 loc) · 2.39 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
69
70
71
72
73
74
<html>
<body><br><br><br><br>
<div id="id" style=""></div>
<!--<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>-->
<script src="https://www.gstatic.com/firebasejs/5.7.2/firebase.js"></script>
<script>
var redBod=Math.floor(Math.random()*255);
var greenBod=Math.floor(Math.random()*255);
var blueBod=Math.floor(Math.random()*255);
var redDiv=Math.floor(Math.random()*255);
var greenDiv=Math.floor(Math.random()*255);
var blueDiv=Math.floor(Math.random()*255);
document.getElementById("id").style.backgroundColor="rgb("+redDiv+","+greenDiv+","+blueDiv+")";
document.getElementById("id").style.height="30%";
document.getElementById("id").style.width="30%";
document.getElementById("id").style.margin="auto";
document.getElementById("id").style.borderRadius="23px";
document.body.style.backgroundColor="rgb("+redBod+","+greenBod+","+blueBod+")"
var ultimateQuestion;
function q(){
ultimateQuestion=prompt("do you think this is a good colour combination?(1/0)");
}
setTimeout(q,2000);
var config = {
apiKey: "AIzaSyCTfmsiPdffvQchUrnDwDv9m8SUSEzo1qU",
authDomain: "machine-f60e6.firebaseapp.com",
databaseURL: "https://machine-f60e6.firebaseio.com",
projectId: "machine-f60e6",
storageBucket: "machine-f60e6.appspot.com",
messagingSenderId: "829526108897"
};
firebase.initializeApp(config);
database = firebase.database();
var gamedatabase = database.ref("colourCombo");
function sendData(){
//getting data starts here
// Make an object with data in it
var data = {
redDiv:redDiv,
greenDiv:greenDiv,
blueDiv:blueDiv,
redBod:redBod,
greenBod:greenBod,
blueBod:blueBod,
question:ultimateQuestion
};
console.log("saving data");
console.log(data);
let color = gamedatabase.push(data, finished);
console.log("Firebase generated key: " + color.key);
// Reload the data for the page
function finished(err) {
if (err) {
console.error("ooops, something went wrong.");
console.error(err);
} else {
console.log('Data saved successfully');
}
}
}
setTimeout(sendData,4000);
</script> <br><br><br><br><br>
</body>
</html>