-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
468 lines (463 loc) · 16.6 KB
/
index.js
File metadata and controls
468 lines (463 loc) · 16.6 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
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
//////////////////////////////
// Begin configuation.
// URL string is empty for Test because gallery information
// is located in VIVIZ["catalogs"]["Test"]
var VIVIZ = {}
VIVIZ["config"] =
{
"catalogs": {
"Test": {"URL": ""},
"User": {"URL": ""},
"ViRBO": {"URL": "catalogs/virbo.json"},
"Solar": {"URL": "catalogs/solar.json"}
},
"defaultCatalog": "Test",
"defaultGallery": "",
"defaultMode": "gallery",
"defaultFirstImage": 1,
"showThumbstrip": true,
"showCatalog": true,
"showDropdowns": true,
"showControls": true,
"showAboutText": true,
"showAttributes": true,
"showFileName": true,
"thumbWidth": 0.25,
"thumbHeight": 0.25,
"fullWidth": 1.0,
"fullHeight": 1.0,
"useAutoAttributes": true,
"lazyLoadMax": 6,
"frameRate": 500,
"play": false,
"port": 8002,
"debug": true,
"proxyServer": "http://localhost:8002/proxy?url="
}
// Note: In general it is best to use $ instead of % in configuation except in
// the scripts. This is because sprintf=demo-%04d.png is decoded to demo-d.png,
// so you must use demo-$04d.png. In scripts where sprintf and strftime are used,
// the % must be used.
VIVIZ["catalogs"] = {};
VIVIZ["catalogs"]["Test"] =
[
{
"id": "SOHO/Sunspots",
"title": "Sunspot measurements from SOHO",
"aboutlink": "http://sohowww.nascom.nasa.gov/sunspots/",
"strftime": "$Y$m$d.jpg",
"fulldir": "http://sohowww.nascom.nasa.gov/data/synoptic/sunspots_earth/sunspots_1024_",
"thumbdir": "http://sohowww.nascom.nasa.gov/data/synoptic/sunspots_earth/sunspots_512_",
"thumbWidth": 256,
"start": "2006-01-20",
"stop": "P0D"
},
{
"id": "ACE/Multi/a",
"title": "ACE/Multi",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbdir": "http://virbo.org/images/pngwalk/ACE/Multi/thumbs400/"
},
{
"id": "ACE/Multi/b",
"title": "ACE/Multi/a w/ no thumbdir",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/"
},
{
"id": "ACE/Multi/c",
"title": "ACE/Multi/b w/ no thumbdir & thumbWidth=0.1",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbWidth": 0.1
},
{
"id": "ACE/Multi/d",
"title": "ACE/Multi/c w/ no thumbdir & thumbWidth=100",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbWidth": 100
},
{
"id": "ACE/Multi/e",
"title": "ACE/Multi/d w/ dir, no thumbdir & thumbWidth=0.1.",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"dir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbWidth": 0.1
},
{
"id": "ACE/Multi/f",
"title": "ACE/Multi/e w/ dir, no thumbdir & thumbWidth=100.",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"dir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbWidth": 100
},
{
"id": "ACE/Multi/g",
"title": "ACE/Multi/f thumbdir is relative path.",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbdir": "../thumbs400/"
},
{
"id": "ACE/Multi/h",
"title": "ACE/Multi/g with start number and regexp.",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbdir": "../thumbs400/",
"defaultFirstImage": 10
},
{
"id": "ACE/Multi/i",
"title": "ACE/Multi/h with start number and regexp.",
"aboutlink": "http://virbo.org/gallery#ACE",
"strftime": "product_$Y$m$d.png",
"start": "1998-01-01",
"stop": "2012-04-30",
"fulldir": "http://virbo.org/images/pngwalk/ACE/Multi/fulls/",
"thumbdir": "../thumbs400/",
"defaultRegExp": "2000",
"defaultFirstImage": 10
},
{
"id": "Demo/01",
"title": "sprintf",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"sprintf": "demo-$04d.png",
"start": 1,
"stop": 4
},
{
"id": "Demo/02",
"title": "strftime",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"strftime": "demo-$Y.png",
"start": 2001,
"stop": 2004
},
{
"id": "Demo/03",
"title": "fullscript as function",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullscript": function() {files = [];for (i = 0; i < 4; i++) {files[i] = ['demo-' + sprintf('%04d',i+1) + '.png']};return files}
},
{
"id": "Demo/04",
"title": "fullscript as string",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullscript": "function() {files = [];for (i = 0; i < 4; i++) {files[i] = ['demo-' + sprintf('%04d',i+1) + '.png']};return files}"
},
{
"id": "Demo/05a",
"title": "fullfiles as array with array elements of file information",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullfiles": [["demo-2001.png"],["demo-2002.png"],["demo-2003.png"],["demo-2004.png"]]
},
{
"id": "Demo/05b",
"title": "Same as Demo/05a but with attribute for each image",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullfiles": [["demo-2001.png",1],["demo-2002.png",2],["demo-2003.png",3],["demo-2004.png",4]]
},
{
"id": "Demo/05c",
"title": "Same as Demo/05b but with attribute names",
"fulldir": "images/full/",
"thumbdir": "images/thumb/",
"attributes": ["Filename","Age"],
"fullfiles": [["demo-2001.png",1],["demo-2002.png",2],["demo-2003.png",3],["demo-2004.png",4]]
},
{
"id": "Demo/05d",
"title": "Same as Demo/05c but with attribute filters",
"fulldir": "images/full/",
"thumbdir": "images/thumb/",
"attributes": ["Filename","Age"],
"filters": [[{}],[{"name": "All", "value": "Age >= 0"}, {"name": "Age > 1", "value": "Age > 1.0"}]],
"fullfiles": [["demo-2001.png",1],["demo-2002.png",2],["demo-2003.png",3],["demo-2004.png",4]]
},
{
"id": "Demo/05e",
"title": "Same as Demo/05d but with defaultFirstImage",
"fulldir": "images/full/",
"thumbdir": "images/thumb/",
"defaultFirstImage": 2,
"attributes": ["Filename","Age"],
"filters": [[{}],[{"name": "Age > 1", "value": "Age > 1.0"}]],
"fullfiles": [["demo-2001.png",1],["demo-2002.png",2],["demo-2003.png",3],["demo-2004.png",4]]
},
{
"id": "Demo/06a",
"title": "fullfiles as string with file information separated by newlines",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullfiles": "demo-2001.png\ndemo-2002.png\ndemo-2003.png\ndemo-2004.png"
},
{
"id": "Demo/06b",
"title": "fullfiles as string with relative path to text file. (Requires web server or full application installation.)",
"fulldir": "images/full/",
"fullfiles": "catalogs/lists/demo-filelist.txt"
},
{
"id": "Demo/06d",
"title": "fullfiles as string with relative path to JavaScript file. (Requires web server or full application installation.)",
"fulldir": "images/full/",
"fullfiles": "catalogs/lists/demo-filelist.json"
},
{
"id": "Demo/06e",
"title": "fullfiles as localhost URL to text file. (Requires full application install)",
"aboutlink": "http://viviz.org/",
"fulldir": "images/full/",
"fullfiles": "http://localhost:"+VIVIZ["config"]["port"]+"/catalogs/lists/demo-filelist.txt"
},
{
"id": "Demo/06f",
"title": "fullfiles as localhost URL to file with JavaScript array. (Requires full application install)",
"fulldir": "images/full/",
"fullfiles": "http://localhost:"+VIVIZ["config"]["port"]+"/catalogs/lists/demo-filelist.json"
},
{
"id": "Demo/06g",
"title": "fullfiles as remote URL to text file. (Requires full application install.)",
"fulldir": "images/full/",
"fullfiles": "https://raw.githubusercontent.com/rweigel/viviz/master/catalogs/lists/demo-filelist.txt"
},
{
"id": "Demo/07a",
"title": "fullfiles as remote URL to file with JavaScript array. (Requires full application install.)",
"fulldir": "images/full/",
"fullfiles": "https://raw.githubusercontent.com/rweigel/viviz/master/catalogs/lists/demo-filelist.json"
},
{
"id": "Demo/07b",
"title": "fullfiles as remote URL to service that returns a JavaScript array. (Requires full application install.)",
"fulldir": "images/time/full/",
"fullfiles": "http://localhost:9002/?url=http://localhost:8002/images/time/full/"
},
{
"id": "Demo/07c",
"title": "fullfiles as remote URL to service that returns a JavaScript array. (Requires full application install.)",
"fulldir": "images/full/",
"fullfiles": "http://localhost:9002/?url=http://localhost:8002/images/full/%26filepattern=demo-"
},
{
"id": "Demo/08a",
"title": "No dir given; images must be in same directory as index.htm",
"strftime": "demo-$Y.png",
"start": 2001,
"stop": 2002
},
{
"id": "Demo/08b",
"title": "Same as previous demo but gallery specified as hash.",
"id":"strftime=demo-$Y.png&start=2001&stop=2002"
},
{
"id": "Demo/08c",
"title": "Same as previous demo but gallery specified as hash with first image bad.",
"id":"strftime=demo-$Y.png&start=2000&stop=2002"
},
{
"id": "Demo/09d",
"title": "No dir given; images must be in same directory as index.htm",
"strftime": "demo-$Y.png",
"start": 2001,
"stop": 2002,
"fullfiles": ""
},
{
"id": "Demo/09e",
"title": "First image is 404.",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullfiles": [["xdemo-2001.png"],["demo-2002.png"],["demo-2003.png"],["demo-2004.png"]]
},
{
"id": "Demo/09f",
"title": "Demo/15 with attributes and filters.",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"attributes": ["Filename","Age"],
"filters": [[{}],[{"name": "Age > 1", "value": "Age > 1.0"}]],
"fullfiles": [["xdemo-2001.png",1],["demo-2002.png",2],["demo-2003.png",3],["demo-2004.png",4]]
},
{
"id": "Demo/09g",
"title": "First two images are 404.",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullfiles": [["xdemo-2001.png"],["xdemo-2002.png"],["demo-2003.png"],["demo-2004.png"]]
},
{
"id": "Demo/09h",
"title": "All images are 404.",
"fulldir":"images/full/",
"thumbdir":"images/thumb/",
"fullfiles": [["xdemo-2001.png"],["xdemo-2002.png"],["xdemo-2003.png"],["xdemo-2004.png"]]
},
{
"id": "dir=http://sohowww.nascom.nasa.gov/data/synoptic/sunspots_earth/&strftime=sunspots_512_$Y$m$d.jpg&start=2006-01-20&stop=P0D",
"title": "Example in documentation."
},
{
"id": "dir=http://sohowww.nascom.nasa.gov/data/synoptic/sunspots_earth/&strftime=sunspots_512_$Y$m$d.jpg&start=2006-01-20&stop=P0D",
"title": "Example in documentation. Should be error because % is used instead of $."
},
{
"id": "dir=images/full/&strftime=demo-$Y.png&start=2001&stop=2004",
"title": "Example in documentation."
},
{
"id": "dir=images/full/&strftime=demo-$Y.png&start=2001&stop=2004",
"title": "Example in documentation"
},
{
"id": "fulldir=images/full/&thumbdir=images/thumb/&strftime=demo-$Y.png&start=2001&stop=2004",
"title": "Example in documentation."
},
{
"id": "fulldir=http://virbo.org/images/pngwalk/ACE/Multi/fulls/&strftime=product_$Y$m$d.png&start=1998-01-01&stop=1998-01-04",
"title": "ID specified as URL in index.js."
},
{
"id": "dir=http://virbo.org/images/pngwalk/ACE/Multi/fulls/&strftime=product_$Y$m$d.png&start=1998-01-01&stop=1998-01-04",
"title": "ID specified as URL in index.js."
},
{
"id": "dir=http://virbo.org/images/pngwalk/ACE/Multi/fulls/&strftime=product_$Y$m$d.png&start=1998-01-01&stop=1998-01-04&thumbWidth=0.1",
"title": "ID specified as URL in index.js."
},
{
"id": "scalar",
"title": "Long URLs",
"strftime": "time.min=$Y-$m-$dT00:00:00.000Z&time.max=$Y-$m-$dT23:59:59.999Z",
"start": "1970-01-02",
"stop": "2016-12-30",
"fulldir": "http://hapi-server.org/plot?server=http://hapi-server.org/servers/TestData/hapi&id=dataset1¶meters=scalar&usecache=true&format=png&",
"thumbdir": "http://hapi-server.org/plot?server=http://hapi-server.org/servers/TestData/hapi&id=dataset1¶meters=scalar&usecache=true&format=png&dpi=72&"
},
{
"id": "dir=http%3A%2F%2Flocalhost%3A8004%2F%3Fcatalog%3DIMAGE%2FPT1M%26dataset%3DABK%26parameters%3DX%26return%3Dimage%26format%3Dpng%26type%3Dtimeseries%26style%3D0%26image.width%3D800%26image.height%3D200&strftime=%26start%3D-P1D%26stop%3D%24Y-%24m-%24d&start=2014-09-01&stop=2014-09-30",
"title": "ID specified as URL with encoded values in index.js (28 images)."
},
{
"id": "dir=http%3A%2F%2Flocalhost%3A8004%2F%3Fcatalog%3DIMAGE%2FPT1M%26dataset%3DABK%26parameters%3DX%26return%3Dimage%26format%3Dpng%26type%3Dtimeseries%26style%3D0%26image.width%3D800%26image.height%3D200&strftime=%26start%3D-P1D%26stop%3D%24Y-%24m-%24d&start=2010-09-27&stop=2014-09-30",
"title": "ID specified as URL with encoded values in index.js (1000+ images)."
},
{
"id": "INVALID/ID",
"title": "Invalid ID. Error message is wrong because of use of configuration URL in gallery configuration. URL is assumed to be gallery configuration. Append x to id in address bar to see proper error message."
},
{
"id": "dir=http://emfisis.physics.uiowa.edu/pngwalk/RBSP-A/HFR-WFR_L2/&strftime=product_$Y$m$d.png&start=20151226&stop=20151228",
"title": "ID specified as URL in index.js."
},
{
"id": "Demo/99a",
"title": "Should always fail. Response is 404.",
"fulldir": "images/full/",
"fullfiles": "http://mag.gmu.edu/demo-filelist.txt"
},
{
"id": "Demo/99b",
"title": "Should always fail. Response is 404.",
"fulldir": "images/full/",
"fullfiles": "http://mag.gmu.edu/demo-filelist.json"
},
{
"id": "Demo/99c",
"title": "Should always fail. Site returns html instead of 404.",
"fulldir": "images/full/",
"fullfiles": "http://viviz.org/demo-filelist.txt"
},
{
"id": "Demo/99d",
"title": "fullfiles as remote URL to file with JavaScript array. (Requires full application install.)",
"title": "Should always fail. Site returns html instead of 404.",
"fullfiles": "http://viviz.org/demo-filelist.json"
}
]
// End configuration.
//////////////////////////////
// To allow server-side use of this file.
if (typeof(location) !== "undefined") { // Browser
if (location.hostname === "localhost") {
//console.log("---index.js: hostname is localhost. Using test catalog.")
VIVIZ["config"]["defaultCatalog"] = "Test";
}
if (location.hostname === "viviz.org") {
//console.log("index.js: hostname is localhost. Using test catalog.")
VIVIZ["config"]["defaultCatalog"] = "Test";
}
if (location.hostname === "virbo.org") {
//console.log("index.js: hostname is virbo.org. Using ViRBO catalog.")
VIVIZ["config"]["defaultCatalog"] = "ViRBO";
}
//if (location.href.indexOf("file:") != 0) {
if (0) {
var nr = 0;
var l = VIVIZ["catalogs"]["Test"].length;
for (var j = 0; j < l; j++) {
var fullfiles = VIVIZ["catalogs"]["Test"][j-nr].fullfiles;
if (typeof(fullfiles) === "string") {
if (fullfiles.match(/^http/)) {
console.log("Removing " + VIVIZ["catalogs"]["Test"][j-nr]["id"])
VIVIZ["catalogs"]["Test"].splice(j-nr,1)
nr = nr+1
}
}
}
for (var j in VIVIZ["catalogs"]["Test"]) {
var fulldir = VIVIZ["catalogs"]["Test"][j].fulldir;
if (fulldir) {
if (fulldir.match(/^images/)) {
VIVIZ["catalogs"]["Test"][j].fulldir =
"http://viviz.org/" + fulldir
}
}
var thumbdir = VIVIZ["catalogs"]["Test"][j].thumbdir;
if (thumbdir) {
if (thumbdir.match(/^images/)) {
VIVIZ["catalogs"]["Test"][j].thumbdir =
"http://viviz.org/" + thumbdir
}
}
}
//console.log("index.js: href starts with file:. Using test catalog and modifying tests.")
//prepend images/full and images/thumb with http://viviz.org/
//remove ones that require full install.
}
}