-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflag.html
191 lines (166 loc) · 5.48 KB
/
flag.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Geography Genius</title>
<!-- CSS dependencies -->
<link rel="stylesheet" href="css/demo.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/demo-print.css" type="text/css" media="print">
<link rel="shortcut icon" href="world.ico" />
<link rel="stylesheet" type="text/css" href="dist/css/bootstrap.min.css">
<!-- World Map Code -->
<script src="js/raphael_2.0.2.js" type="text/javascript"></script>
<script src="js/world_1000.js" type="text/javascript"></script>
<!-- JS dependencies -->
<script src="js/jquery-1.11.3.min.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
<!-- bootbox code -->
<script src="bootbox.min.js"></script>
<script type="text/javascript">
var countries = [];
var flags = [];
var selected_country;
window.onload = function () {
$('img[id=flag_img0').hide().delay( 1000 ).fadeIn('slow');
$('img[id=flag_img1').hide().delay( 2000 ).fadeIn('slow');
$('img[id=flag_img2').hide().delay( 3000 ).fadeIn('slow');
$('img[id=flag_img3').hide().delay( 4000 ).fadeIn('slow');
$('img[id=flag_img4').hide().delay( 5000 ).fadeIn('slow');
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","xml/country_info.xml");
xmlhttp.send();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("country");
for (i=0;i<x.length;i++)
{
countries[i] = i;
}
for (i=0;i<5;i++)
{
flags[i] = countries[Math.floor(Math.random()*countries.length)];
}
for (i=0;i<5;i++)
{
name= x[flags[i]].getElementsByTagName("name")[0].childNodes[0].nodeValue;
flag = name.concat(".svg");
flag_id = "flag_img".concat(i);
document.getElementById(flag_id).src = "country_info/".concat(flag);
document.getElementById(flag_id).name = name;
}
}
};
current = null;
map = {};
m = {};
attr = {
fill: "#333",
stroke: "#888",
"stroke-width": .5,
"stroke-linejoin": "round"
};
width = document.getElementById('holder_1000').style.width;
height = document.getElementById('holder_1000').style.height * 0.99;
svgHeight = 400;
svgWidth = 1000;
R = Raphael("holder_1000", "100%", "100%");
R.setViewBox(0, 0, svgWidth, svgHeight, true);
render_map(R,map,attr);
for (var state in map) {
map[state].color = Raphael.getColor();
(function (st, state) {
st[0].style.cursor = "pointer";
st[0].onmouseover = function () {
current && map[current].animate({fill: "#333", stroke: "#666"}, 300);
st.animate({fill: st.color, stroke: "#ccc"}, 300);
var e = window.event;
var posX = e.pageX;
var posY = e.pageY;
if(posX>800)
posX-=300;
if(posY>400)
posY-=200;
t = R.text(posX, posY, state.replace(/_/g, " "));
t.scale(2,2);
R.safari();
current = state;
};
st[0].onmouseout = function () {
st.animate({fill: "#333", stroke: "#666"}, 300);
t.remove();
R.safari();
};
st[0].onclick = function () {
if(selected_country.match(state))
{
$('img[name='+selected_country+']').animate({
opacity: 0.25
});
$("img").css('box-shadow', "");
}
else
{
t.remove();
current && map[current].animate({fill: "#000", stroke: "#000"}, 300);
st.animate({fill: "#F00", stroke: "#000"}, 300);
var e = window.event;
var posX = e.pageX;
var posY = e.pageY;
if(posX>800)
posX-=300;
if(posY>400)
posY-=200;
t = R.text(posX, posY, "Wrong Selection");
t.scale(2,2);
R.safari();
current = state;
}
};
})(map[state], state);
}; // end forloop
};
function select_country(flag_info)
{
$("img").css('box-shadow', "");
selected_country = flag_info.name;
$(flag_info).css('box-shadow', "1px 1px 4px #000");
}
$( 'body' ).mouseover(function() {
$('body').animate({
opacity: 1
});
});
function instructions()
{
bootbox.alert("1. Select the Flag.<br><br>2. Click on selected flag's country in map.<br><br>3. Click on Reload to Play again.");
}
</script>
</head>
<body style="background: #333;">
<div id="holder_1000" style="position:relative;"></div>
<div style="width: 100%;" id="questions">
<div style="float: left;width: 150px;"><a href="index.html"><input type="button" value="Home" onclick="ff()" class="btn" style=" float: left;"></a>
<input type="button" id="Instructions" value="Instructions" class="btn" onclick="instructions()">
</div>
<div style="float: left;"><img id="flag_img0" alt="Flag" src="" width="200" name="" height="100" onclick="select_country(this);">
<img id="flag_img1" alt="Flag" src="" width="200" name="" height="100" onclick="select_country(this);">
<img id="flag_img2" alt="Flag" src="" width="200" name="" height="100" onclick="select_country(this);">
<img id="flag_img3" alt="Flag" src="" width="200" name="" height="100" onclick="select_country(this);">
<img id="flag_img4" alt="Flag" src="" width="200" name="" height="100" onclick="select_country(this);">
</div>
<div style="float: right;width: 150px;"><a href="flag.html"><input type="button" value="Reload" class="btn" style=" float: right;"></a>
<a href="continents.html"><input type="button" value="Take Quiz" class="btn" style=" float: right;"></a>
</div>
<br style="clear: left;" />
</div>
</body>
</html>