forked from michalbe/tv-series
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·139 lines (131 loc) · 3.57 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="data/build/data/series.js"></script>
<script src="data/build/data/proposals.js"></script>
<script src="tools/wiki_client.js"></script>
<script src="tools/render.js"></script>
<title>tv-series</title>
<link rel="stylesheet" href="style/style.css">
</head>
<body>
<a href="https://github.com/michalbe/tv-series"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png" alt="Fork me on GitHub"></a>
<table id="series">
<tbody>
<tr>
<th colspan=5 style="text-align:center">
My List
</th>
</tr>
<tr>
<th>
Cover
</th>
<th>
Title
</th>
<th>
Episodes
</th>
<th>
Episode Length
</th>
<th>
Total Length
</th>
<th id="egg">
Still watching?
</th>
</tr>
</tbody>
</table>
<table id="to-consider">
<tbody>
<tr>
<th colspan=5 style="text-align:center">
Shows to consider
</th>
</tr>
<tr>
<th>
Cover
</th>
<th>
Title
</th>
<th>
Episodes
</th>
<th>
Episode Length
</th>
<th class="totallength">
Total Length
</th>
<th class="stillWatching">
Ongoing?
</th>
<th id="egg2">
Votes
</th>
</tr>
</tbody>
</table>
<script>
Renderer(series, document.getElementById('series'));
Renderer(toConsider, document.getElementById('to-consider'));
</script>
<script>
var removeWp = function(){
var elements = document.getElementsByClassName('wp');
while (elements.length) {
document.body.removeChild(elements[0]);
}
};
var generateWallpaper = function(evt){
var parent = evt.target.parentNode.parentNode.parentNode;
var series = parent.querySelectorAll('.cover');
var x = 6;
var y = 3;
var sizeX = 1200;
var sizeY = 800;
var topPos = 0;
var leftPos = 0;
var totalCovers = x*y;
var result = 0;
var generated = [];
while (result < totalCovers) {
var id = ~~(Math.random()*series.length);
while (generated.indexOf(id) > -1) {
id = ~~(Math.random()*series.length);
}
generated.push(id);
var show = series[id];
if (show.style.backgroundImage) {
result++;
var el = document.createElement('div');
el.classList.add('wp');
el.style.backgroundImage = show.style.backgroundImage;
el.style.width = sizeX/x + 'px';
el.style.height = sizeY/y + 'px';
el.style.backgroundSize = 'cover';
el.style.position = 'absolute';
el.style.top = topPos + 'px';
el.style.left = leftPos + 'px';
el.addEventListener('click', removeWp);
document.body.appendChild(el);
if (result%x === 0) {
topPos += sizeY/y;
leftPos = 0;
} else {
leftPos += sizeX/x;
}
}
}
};
document.getElementById('egg').addEventListener('click', generateWallpaper);
document.getElementById('egg2').addEventListener('click', generateWallpaper);
</script>
</body>
</html>