-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
149 lines (134 loc) · 6.41 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
140
141
142
143
144
145
146
147
148
149
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JQVMap - World Map</title>
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link href="map/jqvmap/jqvmap.css" media="screen" rel="stylesheet" type="text/css" />
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="map/jqvmap/jquery.vmap.js" type="text/javascript"></script>
<script src="map/jqvmap/maps/jquery.vmap.world.js" type="text/javascript"></script>
<script src="map/jqvmap/data/jquery.vmap.sampledata.js" type="text/javascript"></script>
<script type="text/javascript" src="js/query.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
var home = 1
var country_list = {};
var home_country;
var homeCountryColor = '#f0802a';
var visitedCountryColor = '#6fb86e';
var nonVisitedCountryColor = '#006491';
var mockup_results = '{"score": 129, "description": "You are a not very awesome traveller.", "highscores": {"Alexander Hemberg": 14, "Lars Lowe Sjosund": 16}}';
jQuery('#vmap').vectorMap({
map: 'world_en',
backgroundColor: '#FFFFFF',
color: '#ffffff',
hoverOpacity: 0.7,
selectedColor: '#FF0000',
enableZoom: false,
showTooltip: true,
values: sample_data,
scaleColors: ['#C8EEFF', '#006491'],
normalizeFunction: 'polynomial',
onRegionClick: function(event, code, region)
{
var country = {};
if (country_list[code] == true && !home) {
country_list[code] = false;
country[code] = nonVisitedCountryColor;
}
else if (code == home_country) {
// TODO Fix fulkod
$('.top').html("Where are you from?");
home = 1;
country[code] = nonVisitedCountryColor;
home_country = "";
}
else {
if (home) {
country[code] = homeCountryColor;
home = 0;
home_country = code;
country_list[code] = false;
if (code == 'mx'){
$('.top').html("You so sleepy. Choose visited place!");
} else {
$('.top').html("You're from " + region + ", Choose visited place!");
}
}
else {
country[code] = visitedCountryColor;
country_list[code] = true;
}
}
//alert(Object.keys(country_list));
jQuery('#vmap').vectorMap('set','colors', country);
}
});
function get_results() {
results = jQuery.parseJSON(mockup_results)
return results;
}
function display_results(result) {
$("#score").text(result.score);
$("#description").text(result.description);
var highscores = "<table>";
$.each(result.highscores, function(key, value) {
$("#result").add("#testblock");
highscores = highscores.concat("<tr><td>");
highscores = highscores.concat(key);
highscores = highscores.concat("</td><td>");
highscores = highscores.concat(value);
highscores = highscores.concat("</td></tr>");
});
highscores = highscores.concat("</table>")
$("#highscores").text(highscores);
}
$("#fade_box").click(function() {
$("#fade_box").fadeOut(350);
$("#blur_box").css("filter", "blur(0px)");
$("#blur_box").css("-o-filter", "blur(0px)");
$("#blur_box").css("-ms-filter", "blur(0px)");
$("#blur_box").css("-moz-filter", "blur(0px)");
$("#blur_box").css("-webkit-filter", "blur(0px)");
});
$("#submit").click(function(event){
var json = JSON.stringify({countries:"afsf", b:"3r14"});
$.post( "http://localhost:5000/score", json)
.done(function( data ) {
alert( "Data Loaded: " + data );
});
event.preventDefault();
$("#result").show();
$("#submit").hide();
var dest=$("#vmap").height();
display_results(get_results());
$('html,body').animate({scrollTop:dest}, 1000,'swing');
});
});
</script>
</head>
<body>
<div id="fade_box">
<div id="instructions">Choose your home country. <br> Then select where you've been.</div>
</div>
<div id ="blur_box">
<div id="vmap" style="width: 60%; height: 600px; margin-left: auto; margin-right: auto;"></div>
<div id="space-invader"></div>
<div id="center">
<!--<form method="POST" action="http://localhost:5000/score"><input type="hidden" name="countries" value='countryvar'>-->
<input type="submit" id="submit" value="Done">
</form>
</div>
<div id="result">
<div id="res_box">
<div id="score"></div>
<div id="description"></div>
<div id="highscores"></div>
</div>
</div>
</div>
<!--<h1 id="instructions">First, click your home country, then all counties that you've visited.</h1>-->
</body>
</html>