/
index.html
72 lines (69 loc) · 2.09 KB
/
index.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
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<style>
.beer {
position: absolute;
bottom: 0;
left: 0;
height: 400px;
width: 100%;
background: #FAC937;
}
</style>
</head>
<body>
<h1>Hello this is beermarklet</h1>
<script src="jquery.min.js"></script>
<script>
(function() {
// Todo: Make it jqueryless
var beer = document.createDocumentFragment(),
body = document.getElementsByTagName("body")[0];
function randomize(up, bot) {
return Math.floor((Math.random()*up)+bot);
}
// This holds the number of circles
var foam = Math.floor(window.innerWidth/2) - 100,
foamNode = [],
foamSize = 50,
i = 0;
var glass = document.createElement("div"),
glassCss = {
"position":"absolute",
"bottom" : "0",
"left":"0",
"height":"400px",
"width":"100%",
"background":"#FAC937"
}
for (var prop in glassCss) {
glass.style[prop] = glassCss[prop];
}
for (i; i <= foam; i++) {
foamNode[i] = document.createElement("div");
foamNode[i].style.width = foamSize + "px";
foamNode[i].style.height = foamSize + "px";
foamNode[i].style.background = "white";
foamNode[i].style.borderRadius = foamSize / 2 + "px";
foamNode[i].style.position = "absolute";
foamNode[i].style.top = randomize(15, 0) + "px";
foamNode[i].style.left = Math.floor(foamSize * ( i / 2) ) + "px";
glass.appendChild(foamNode[i]);
}
// Append to the DOM
beer.appendChild(glass);
console.log(glass);
body.appendChild(beer);
})();
</script>
</body>
</html>