This repository was archived by the owner on Dec 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
executable file
·329 lines (275 loc) · 13.6 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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<!DOCTYPE html>
<html>
<head>
<title>XJourney</title>
</head>
<style>
@font-face {
font-family: 'MyriadSetPro-UltraLight';
src: url('media/MyriadSetPro-UltraLight.ttf');
}
::-webkit-input-placeholder {
font-size: 14px;
text-align:center;
}
.osx {
float: left; clear: both;
margin: 0 10px 19px 0;
}
/* CSS for Buttons */
.osx, .osx:hover {
color: #000; text-decoration: none; text-shadow: 0 1px rgba(255,255,255,.2);
font: 400 13px/19px "Helvetica Neue", Arial, sans-serif;
-webkit-tap-highlight-color: transparent;
padding: 0 12px;
border: 1px solid;
border-top-color: #9d9d9d; border-bottom-color: #939393;
border-left-color: #949494; border-right-color: #949494;
-webkit-border-radius: 4px; box-shadow: 0 1px rgba(0,0,0,0.1);
-moz-border-radius: 4px; -moz-box-shadow: 0 1px rgba(0,0,0,0.1);
border-radius: 4px; -webkit-box-shadow: 0 1px rgba(0,0,0,0.1);
-webkit-appearance: none;
background: #ffffff; /* Old browsers */
background: -webkit-gradient(linear, left top, left bottom,
/* Chrome, */ color-stop( 0%, #ffffff),
/* Safari4+ */ color-stop(25%, #ffffff),
color-stop( 30%, #fcfcfc),
color-stop(35%, #f9f9f9),
color-stop(40%, #f7f7f7),
color-stop(45%, #f5f5f5),
color-stop( 50%, #f2f2f2),
color-stop(50%, #ececec),
color-stop(80%, #ededed),
color-stop(95%, #efefef),
color-stop(100%, #f2f2f2));
background: -webkit-linear-gradient(top, #ffffff 0%, #ffffff 25%, #fcfcfc 30%, #f9f9f9 35%,
/* Chrome10+, */ #f7f7f7 40%, #f5f5f5 45%, #f2f2f2 50%, #ececec 50%,
/* Safari5.1+ */ #ededed 80%, #efefef 95%, #f2f2f2 100%);
background: -moz-linear-gradient(top, #ffffff 0%, #ffffff 25%, #fcfcfc 30%, #f9f9f9 35%,
/* FF3.6+ */ #f7f7f7 40%, #f5f5f5 45%, #f2f2f2 50%, #ececec 50%,
#ededed 80%, #efefef 95%, #f2f2f2 100%);
background: -o-linear-gradient(top, #ffffff 0%, #ffffff 25%, #fcfcfc 30%, #f9f9f9 35%,
/* Opera 11.10+ */ #f7f7f7 40%, #f5f5f5 45%, #f2f2f2 50%, #ececec 50%,
#ededed 80%, #efefef 95%, #f2f2f2 100%);
background: -ms-linear-gradient(top, #ffffff 0%, #ffffff 25%, #fcfcfc 30%, #f9f9f9 35%,
/* IE10+ */ #f7f7f7 40%, #f5f5f5 45%, #f2f2f2 50%, #ececec 50%,
#ededed 80%, #efefef 95%, #f2f2f2 100%);
background: linear-gradient(top, #ffffff 0%, #ffffff 25%, #fcfcfc 30%, #f9f9f9 35%,
/* W3C */ #f7f7f7 40%, #f5f5f5 45%, #f2f2f2 50%, #ececec 50%,
#ededed 80%, #efefef 95%, #f2f2f2 100%);
filter: progid:DXImageTransform.Microsoft.gradient(
/* IE6-9 */ startColorstr='#ffffff', endColorstr='#f2f2f2',GradientType=0 );
cursor: default; -webkit-user-select: none;
-moz-user-select: none; user-select: none;
}
.osx:active, .osx.primary, .osx.primary:hover {
background: #bcd6ef; /* Old browsers */
background: -webkit-gradient(linear, left top, left bottom,
/* Chrome, */ color-stop( 0%, #bcd6ef),
/* Safari4+ */ color-stop( 5%, #a3c1ef),
color-stop( 10%, #98b8e9),
color-stop(15%, #91b3e9),
color-stop(20%, #8ab1e9),
color-stop(25%, #8ab2ea),
color-stop( 30%, #83abe8),
color-stop(35%, #7cabe9),
color-stop(40%, #73a6e8),
color-stop(45%, #6ca4e9),
color-stop( 50%, #67a1e9),
color-stop(50%, #4693ea),
color-stop(70%, #579eec),
color-stop(75%, #64a7ee),
color-stop( 80%, #6eaeee),
color-stop(85%, #7db6ef),
color-stop(90%, #88bfef),
olor-stop(95%, #97caef),
color-stop(100%, #abd4ef));
background: -webkit-linear-gradient(top, #bcd6ef 0%, #a3c1ef 5%, #98b8e9 10%, #91b3e9 15%,
/* Chrome10+, */ #8ab1e9 20%, #8ab2ea 25%, #83abe8 30%, #7cabe9 35%,
/* Safari5.1+ */ #73a6e8 40%, #6ca4e9 45%, #67a1e9 50%, #4693ea 50%,
#579eec 70%, #64a7ee 75%, #6eaeee 80%, #7db6ef 85%,
#88bfef 90%, #97caef 95%, #abd4ef 100%);
background: -moz-linear-gradient(top, #bcd6ef 0%, #a3c1ef 5%, #98b8e9 10%, #91b3e9 15%,
/* FF3.6+ */ #8ab1e9 20%, #8ab2ea 25%, #83abe8 30%, #7cabe9 35%,
#73a6e8 40%, #6ca4e9 45%, #67a1e9 50%, #4693ea 50%,
#579eec 70%, #64a7ee 75%, #6eaeee 80%, #7db6ef 85%,
#88bfef 90%, #97caef 95%, #abd4ef 100%);
background: -o-linear-gradient(top, #bcd6ef 0%, #a3c1ef 5%, #98b8e9 10%, #91b3e9 15%,
/* Opera 11.10+ */ #8ab1e9 20%, #8ab2ea 25%, #83abe8 30%, #7cabe9 35%,
#73a6e8 40%, #6ca4e9 45%, #67a1e9 50%, #4693ea 50%,
#579eec 70%, #64a7ee 75%, #6eaeee 80%, #7db6ef 85%,
#88bfef 90%, #97caef 95%, #abd4ef 100%);
background: -ms-linear-gradient(top, #bcd6ef 0%, #a3c1ef 5%, #98b8e9 10%, #91b3e9 15%,
/* IE10+ */ #8ab1e9 20%, #8ab2ea 25%, #83abe8 30%, #7cabe9 35%,
#73a6e8 40%, #6ca4e9 45%, #67a1e9 50%, #4693ea 50%,
#579eec 70%, #64a7ee 75%, #6eaeee 80%, #7db6ef 85%,
#88bfef 90%, #97caef 95%, #abd4ef 100%);
background: linear-gradient(top, #bcd6ef 0%, #a3c1ef 5%, #98b8e9 10%, #91b3e9 15%,
/* W3C */ #8ab1e9 20%, #8ab2ea 25%, #83abe8 30%, #7cabe9 35%,
#73a6e8 40%, #6ca4e9 45%, #67a1e9 50%, #4693ea 50%,
#579eec 70%, #64a7ee 75%, #6eaeee 80%, #7db6ef 85%,
#88bfef 90%, #97caef 95%, #abd4ef 100%);
filter: progid:DXImageTransform.Microsoft.gradient(
/* IE6-9 */ startColorstr='#bcd6ef', endColorstr='#abd4ef',GradientType=0 );
border-top-color: #5158ab; border-bottom-color: #464872;
border-left-color: #4b4d8c; border-right-color: #4b4d8c;
}
.osx.primary, .osx.primary:hover {
-webkit-animation: pulsate 730ms infinite alternate ease-in-out;
-moz-animation: pulsate 730ms infinite alternate ease-in-out;
animation: pulsate 730ms infinite alternate ease-in-out;
}
.osx.primary:active {
animation: none;
-moz-animation: none;
-webkit-animation: none;
}
@-webkit-keyframes pulsate {
0% { -webkit-box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 2px #d2f7ff; box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 2px #d2f7ff; }
100% { -webkit-box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 0px #a0c1ed; box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 0px #a0c1ed; }
}
@-moz-keyframes pulsate {
0% { -moz-box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 2px #d2f7ff; box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 2px #d2f7ff; }
100% { -moz-box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 0px #a0c1ed; box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 0px #a0c1ed; }
}
@keyframes pulsate {
0% { box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 2px #d2f7ff; }
100% { box-shadow: 0 1px rgba(0,0,0,0.1), inset 0 0 19px 0px #a0c1ed; }
}
.osx:focus {
-webkit-box-shadow: 0 1px rgba(0,0,0,0.1), 0 0 4px hsl(204, 100%, 88%);
-moz-box-shadow: 0 1px rgba(0,0,0,0.1), 0 0 4px hsl(204, 100%, 88%);
box-shadow: 0 1px rgba(0,0,0,0.1), 0 0 4px hsl(204, 100%, 88%);
border-color: hsl(204, 68%, 58%);
}
.osx.round {
-webkit-border-radius: 9999px;
-moz-border-radius: 9999px;
border-radius: 9999px;
padding: 0 10px;
}
.osx.single{
padding: 0 6px;
}
.osx b, .osx strong {
font-weight: 500;
}
#holder { -webkit-border-radius:30px; background-color:white; border: 10px dashed #ccc; width: 300px; height: 150px; margin: 20px auto;}
#holder.hover { border: 10px dashed #333; }
</style>
<script src="js/jquery-2.1.1.min"></script>
<script>
var locItemCreator = require('./js/locItemGenerator.js');
var plist = require('plist');
var fs = require('fs');
var gui = require('nw.gui');
var Base64 = require('./js/base64.js').Base64;
var replaceWithReal = "integer";
var realReplacement = "real";
var mb = new gui.Menu({type:"menubar"});
mb.createMacBuiltin("XJourney");
gui.Window.get().menu = mb;
//Placeholder values
var LocDelBehaviorPlaceholder = 88888888;
var LocRepBehaviorPlaceholder = 99999999;
var locationsDataPlaceholder = "REPLACE_LOCATIONS";
var DOMLocationDataPlaceholder = "<string>" + locationsDataPlaceholder + "</string>";
//Settings - need to be strings so floating point is not truncated
var LocationDeliveryBehavior = "0.0";
var LocationRepeatBehavior = "2";
var plistBase = {
"Locations": [locationsDataPlaceholder],
"Options":{
"LocationDeliveryBehavior":LocDelBehaviorPlaceholder,
"LocationRepeatBehavior":LocRepBehaviorPlaceholder
}
};
//Helper method to replace all occurences of a string
function replaceAll(find, replace, str) {
return str.replace(new RegExp(find, 'g'), replace);
}
//1st pass creates location plist base
function performFirstPassReplacements() {
//Create base plist
var out = plist.build(plistBase);
//1st pass ensures values are 'real' as is required in Plist
out = replaceAll(replaceWithReal,realReplacement,out);
//Ensure real floating values are in 'LocationDeliveryBehavior'
var oldLocDel = "<" + realReplacement + ">" + LocDelBehaviorPlaceholder + "</" + realReplacement + ">";
var newLocDel = "<" + realReplacement + ">" + LocationDeliveryBehavior + "</" + realReplacement + ">";
out = out.replace(oldLocDel,newLocDel);
//Ensure real floating values are in 'LocationRepeatBehavior'
var oldLocRep = "<" + realReplacement + ">" + LocRepBehaviorPlaceholder + "</" + realReplacement + ">";
var newLocRep = "<" + realReplacement + ">" + LocationRepeatBehavior + "</" + realReplacement + ">";
out = out.replace(oldLocRep,newLocRep);
return out;
}
//format latitude,longitude,course
//Generates the plist (primary 'do it' method)
function generatePlist(inputCSVItems) {
var pList = performFirstPassReplacements();
var pulseList = "";
for (var i = 0; i < inputCSVItems.length; i = i+10)
{
//Skip CSV header
if(inputCSVItems[i].toLowerCase().indexOf("alt") > -1)
{
continue;
}
// 21, 50.853394, -1.289268, 302, 10, 30, 6.26, 1412578717.1, 1, 3,
// Altitude, Latitude, Longitude, Course, HorizontalAccuracy,Lifespan, Speed, Timestamp, Type, VerticalAccuracy, fs,Base64)
var newPulse = locItemCreator.generateLocationPulse(inputCSVItems[i],inputCSVItems[i+1],inputCSVItems[i+2],inputCSVItems[i+3],inputCSVItems[i+4],inputCSVItems[i+5],inputCSVItems[i+6],inputCSVItems[i+7],inputCSVItems[i+8],inputCSVItems[i+9],fs,Base64);
pulseList = pulseList + "\n" + newPulse;
}
pList = pList.replace(DOMLocationDataPlaceholder,pulseList);
return pList;
}
function createPlistFile(inputCSV) {
//remove possible comma using regex
inputCSV = inputCSV.replace(/(^,)|(,$)/g, "");
var locCSVItems = inputCSV.split(',');
if(locCSVItems.length < 10)
{
alert("No input data");
return;
}
if(locCSVItems.length % 10 != 0)
{
alert("Bad input data (Incorrect number of values)");
return;
}
var newPlist = generatePlist(locCSVItems);
fs.writeFile("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreLocation.framework/Support/SimulationScenarios/XJourney.plist", newPlist, function(err) {
if(err)
{
alert("Error saving journey: make sure xcode.app is in your 'Applications' directory. If you downloaded your copy of Xcode from the appstore, you need to give 'everyone' read/write permissions to directory '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreLocation.framework/Support/SimulationScenarios/'");
}
else
{
alert("Journey added successfully, reset iOS Simulator then look for 'XJourney' under 'Location'.");
}
});
}
</script>
<body style="text-align:center;background-color:#2C96F2;background-image: url('media/bg.png');">
<h1 style="font-family:MyriadSetPro-UltraLight;-webkit-user-select:none;cursor:default;">XJourney</h1>
<div id="holder"><div style="cursor:default;-webkit-user-select:none;font-family:MyriadSetPro-UltraLight;position:relative;margin-top:60px;text-align:center">Drop CSV Here</div></div>
<script>
// prevent default behavior from changing page on dropped file
window.ondragover = function(e) { e.preventDefault(); return false };
window.ondrop = function(e) { e.preventDefault(); return false };
var holder = document.getElementById('holder');
holder.ondragover = function () { this.className = 'hover'; return false; };
holder.ondragend = function () { this.className = ''; return false; };
holder.ondrop = function (e) {
e.preventDefault();
for (var i = 0; i < e.dataTransfer.files.length; ++i)
{
var locFile = fs.readFileSync(e.dataTransfer.files[i].path, "utf8");
createPlistFile(locFile);
}
return false;
};
</script>
</body>
</html>