forked from kokonior/HTML-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValentine's PopUp.html
82 lines (79 loc) · 2.46 KB
/
Valentine's PopUp.html
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
75
76
77
78
79
80
81
82
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<title>Happy Valentine's Day Max!</title>
<link rel="icon" type="image/jpg" href="favicon.jpg">
<style>
/* HELLO MAX! THIS IS MY CSS! */
body {
background-image: url('tandem_grey.png');
}
body::before {
content: url('tandem_grey.png') url('broken.png') url('clock.png') url('colors.png') url('theCertificate.png') url('thePerks.png');
display: none;
}
.certificate {
background: #fff;
background-image: url('theCertificate.png');
box-shadow: 0 0 5px #888;
}
.benefits {
background: #fff;
background-image: url('thePerks.png');
box-shadow: 0 0 5px #888;
}
.no {
background-image: url('broken.png');
}
.yes {
background-image: url('colors.png');
}
.maybe {
background-image: url('clock.png');
}
#image {
height: 517px;
width: 780px;
margin: 50px auto;
}
</style>
</head>
<body>
<script type="text/javascript">
/* ZOMG. FUNCTION! */
/* I ALSO LEARNED HOW TO DO A LOT OF THIS BY CHANGING .CSS INSTEAD OF ADDING/REMOVING CLASSES, WHICH I LEARNED IS BETTER. I ALSO LEARNED THAT I SHOULD MAKE VARS FOR BODY AND IMAGE SINCE I'M USING THEM MORE THAN ONCE! */
var beardedBoo = function() {
var body = $('body'),
image = $("#image");
body.removeClass("no").removeClass("maybe")
image.removeClass("benefits").removeClass("certificate")
var answer = prompt("Will you be my valentine? Yes, No, Maybe?").toLowerCase()
/* .toLowerCase IS BEST PRACTICE! IT'S ALSO OK IF YOU TYPE THE FIRST LETTER INSTEAD OF THE WORD! */
if (answer == "yes" || answer == 'y') {
body.addClass("yes")
image.addClass("certificate")
} else if (answer == "maybe" || answer == 'm') {
body.addClass("maybe")
/* I WANTED THE BG TO CHANGE BEFORE THE ALERT AND THE IMAGE AFTER THE PROMPT AND THE NEXT PROMPT AFTER THAT! I LEARNED THAT IF ALERT AD IMAGE ARE NOT IN THE setTimeout TOGETHER, IT DOES THEM AT THE SAME TIME. */
setTimeout(beardedBoo, 6000)
setTimeout(function() {
alert("Perhaps you are not aware of the many benefits")
image.addClass("benefits")
}, 200)
/* HEY!!! */
} else {
body.addClass("no")
setTimeout(function() {
alert("Say it isn't so. Please try again.")
beardedBoo()
}, 200)
}
}
setTimeout(beardedBoo, 300)
/* ALL THESE ALERTS/PROMPTS COULD GET ANNOYING, IT'S BEST TO JUST BE MY VALENTINE */
</script>
<div id="image"></div>
</body>
</html>