forked from StephHerdz/TTX-Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSON Track2.html
More file actions
167 lines (141 loc) · 3.67 KB
/
Copy pathJSON Track2.html
File metadata and controls
167 lines (141 loc) · 3.67 KB
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
<!doctypehtml>
<html>
<head>
<title>TTX</title>
<META HTTP-EQUIV="refresh" CONTENT="15">
<A HREF="javascript:history.go(0)"> </A>
<style>
html, body {
width: 100%;
height: 100%;
background-color: #c7c7c7;
}
#track1 {
position: relative;
top: 50px;
left:15px;
}
#track2 {
position: relative;
top: 120px;
left:15px;
}
#track3 {
position: relative;
top: 190px;
left:15px;
}
.track {
height:50px;
width:110px;
border-radius: 15%;
border-width: 10px;
border-style: solid;
font-size: 15px;
}
.button {
height:50px;
width:70px;
border-radius: 30%;
border-width: 10px;
border-style: solid;
font-size: 15px;
}
</style>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script>
//declare global variables
var thegame;
thegame = new mygame;
//create your object
function mygame(){
this.tracks = [];
//an object method to say something
this.sayhello = function (){
console.log ('hello world');
};
this.addtrack = function (jsonTrack){
var newtrack = new track();
jQuery.extend(newtrack, jsonTrack);
this.tracks.push(newtrack);
newtrack.show();
};
}
function track(){
var trackid;
var trackname;
var initialleft;
var initialtop;
var yardid;
this.debug = function (){
console.log ('my id is: ' + this.trackid);
};
this.show = function () {
var track = $("#track");
track.append('<div><button data-role="button" data-inline="true" data-mini="true" data-theme="b">'+this.trackname+'</button></div>').trigger('create');
//("<img id='"+this.cssid+"' src='"+this.imgsrc+"'/>");
this.element = $("#" + this.cssid);
//this.element.css({display: 'block', position:'absolute',left:this.initialleft,top:this.initialtop });
};
this.move=function(dx,dy){
this.element.animate({ "left": "+=" +dx+ "px", "top": "+=" +dy+ "px" }, "slow" );
};
}
$(document).ready (function(){
var server = new ajaxServiceLayer();
var tracksFromJSON = server.gettracks();
for (i=0;i<tracksFromJSON.length;i++){
thegame.addtrack(tracksFromJSON[i]);
}
});
function ajaxServiceLayer(){
this.gettrack = function(){
//name the return value
var retval;
/*
$.get("getball.aspx")
.done(function(data){
retval = JSON.parse(data);
});
*/
//fake the server for now
//http://www.w3schools.com/json/json_syntax.asp
retval = JSON.parse('{"trackid":"1","trackname":"j1","yardid":"1","initialleft":400,"initialtop":100}');
return retval;
};
this.gettracks = function(){
//name the return value
var retval;
/*
$.get("getballs.aspx")
.done(function(data){
retval = JSON.parse(data);
});
*/
//fake the server for now
//http://www.w3schools.com/json/json_syntax.asp
retval = JSON.parse('[{"trackid":"1","trackname":"j1","yardid":"1"},{"trackid":"2","trackname":"j2","yardid":"1"}, {"trackid":"3","trackname":"j3","yardid":"1"},{"trackid":"4","trackname":"j4","yardid":"1"}]');
return retval;
};
}
</script>
</head>
<body bgcolor="#fcaf00">
<div id="header">
<div id="navbar">
<ul>
<li><a href="load.html">home</a></li>
<li><a href="ttx.html">Login</a></li>
<li><a href="track.html">Map</a></li>
<li><a href="4th page.html">text</a></li>
</ul>
</div>
<img src="images/Logo.png"alt="TTX Logo" height="100px"width="150px">
<form>
<input type="text" placeholder="Search..." required>
<input type="button" value="Search">
</form>
<br><h1 align="center">Facilty Name</h1></br>
<div id="track"> </div>
</body>
</html>