-
Notifications
You must be signed in to change notification settings - Fork 2
/
pokemon.html
164 lines (142 loc) · 4.84 KB
/
pokemon.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html>
<head>
<!-- Stylesheets -->
<link rel="stylesheet" href="pokemon.css" >
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/type.js"></script>
<script type="text/javascript" src="js/pokemon.js"></script>
<script type='text/javascript'>
function fillList(gen, type, id) {
//Build Pokemon Choose List
var chooseList = [];
if (type !== "All")
{
//Build the choose list for all pokemon of gen and type
for (i = 0; i < pokemon.length; i++){
if (pokemon[i].gen == gen)
for (t = 0; t < types.length; t++) {
if (types[t].name === type && pokemon[i].type === types[t].name) {
chooseList.push(pokemon[i]);
}
}
}
}
else
{
// Get all selected pokemon except the All category
var genList = $(".gen"+ gen + ":not('.All') > img");
//Build the choose list for the selected gen pokemon
for(g=0; g < genList.length; g++)
{
chooseList.push({
"img": genList[g].src,
"name": "" + genList[g].dataset.pokename + "" });
}
}
//Build ChooseDiv innerHTML
var maxCols = 3;
var colCount = 0;
var innerHTML = "";
for (p = 0; p < chooseList.length; p++) {
colCount++;
innerHTML += "<div class=\"btnChoose round\" onclick=\"setPicture('" + id + "','" + chooseList[p].img + "','" + chooseList[p].name + "');\"><img src=\"" + chooseList[p].img + "\">" + chooseList[p].name + "</div>";
if (colCount === maxCols)
{
innerHTML += "<br/>";
colCount = 0;
}
}
if (innerHTML === "")
{
innerHTML = "None";
}
else
{
innerHTML += "<div class=\"btnChoose round\" onclick=\"clearPicture('" + id + "');\"><img src=\"images/delete.png\">Remove</div>";
}
// Place the ChooseDiv in a dialog near the gen type cell
$(".pkmnselect").html(innerHTML).dialog({
title: getGenTitle(gen) + " - " + type,
width: 400,
position: { my: "left top", at: "right top", of: "#" + id }
});
}
function setPicture(id, imglink, pokename) {
document.getElementById(id).innerHTML = "<img data-pokename=\"" + pokename + "\" src=\"" + imglink + "\">";
$(".pkmnselect").dialog("close");
}
function clearPicture(id)
{
$("#" + id).html("");
$(".pkmnselect").dialog("close");
}
function getGenTitle(genNum)
{
var genTitle = "Gen ";
switch(genNum)
{
case 1: genTitle += "I"; break;
case 2: genTitle += "II"; break;
case 3: genTitle += "III"; break;
case 4: genTitle += "IV"; break;
case 5: genTitle += "V"; break;
case 6: genTitle += "VI"; break;
case 7: genTitle += "VII"; break;
}
return genTitle;
}
$(function() {
$('html').bind('click', function(e) {
if($('.pkmnselect').dialog('isOpen')
&& !$(e.target).is('.ui-dialog, button')
&& !$(e.target).is('.ui-dialog, img')
&& !$(e.target).closest('.ui-dialog').length)
{
jQuery('.pkmnselect').dialog('close');
}
});
});
</script>
</head>
<body>
<div class="title">FAV POKEMON OF EACH GEN AND TYPE MEME</div>
<div class="credit">
<div class="author"><span>CREATED BY ???</span></div>
<div class="templateAuthor"><span>TEMPLATE BY TARITOONS</span></div>
<div class="filledBy"><span>FILLED BY</span><span>.........................</span></div>
</div>
<script>
document.write("<table>");
document.write("<tr class=\"typeHeader\">");
document.write("<td class=\"typeHeader\"></td>");
for (t=0; t < types.length; t++) {
document.write("<td class=\"typeHeader\">");
document.write("<div class=\"typeHeader\">" + types[t].name + "</div>");
document.write("</td>");
}
document.write("</tr>");
for (g = 1; g <= 7; g++) {
document.write("<tr>");
document.write("<td class=\"genTitle\">");
document.write("<div class=\"rotate genTitle\">" + getGenTitle(g) + "</div>");
document.write("</td>");
for (t = 0; t < types.length; t++) {
document.write("<td>");
gen = "gen" + g;
id = gen + "type" + types[t].name;
document.write("<div class=\"round pkmnGenType " + types[t].name + "\"><button class=\"secret round " + gen + " " + types[t].name + "\" id=" + id + " onclick=\"fillList(" + g + ",'" + types[t].name + "','" + id + "');\" /></div>");
document.write("</td>");
}
document.write("</tr>");
}
document.write("</table>");
document.write("<div id=\"choosediv\">");
document.write("</div>");
</script>
<div class="pkmnselect"></div>
</body>
</html>