Skip to content

Commit c4e0ba0

Browse files
authored
Merge pull request #21 from hapi-server/dev
Dev
2 parents ef93d00 + 0e0d7bc commit c4e0ba0

File tree

15 files changed

+1022
-709
lines changed

15 files changed

+1022
-709
lines changed

css/index.css

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ a {
2828
cursor: pointer;
2929
}
3030

31+
details {
32+
cursor: pointer;
33+
}
34+
3135
#options-details {
3236
margin-bottom: 5px;
3337
}
@@ -43,15 +47,18 @@ a {
4347
font-size: 80%;
4448
}
4549

46-
#loading, #timing, #xstatus {
50+
#timing, #xstatus {
4751
font-size: 90%;
4852
display: inline;
4953
}
5054

55+
#requests {
56+
font-size: 80%;
57+
overflow-x: scroll;
58+
}
59+
5160
#loadinfo {
52-
min-height: 1em;
53-
max-height: 2em;
54-
overflow-y: auto;
61+
overflow: scroll;
5562
}
5663

5764
a:link {

index.htm

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,33 @@
6969
<script type="text/javascript" src="js/checkboxes.js"></script>
7070
<script type="text/javascript" src="js/dropdowns.js"></script>
7171
<script type="text/javascript" src="js/examplelist.js"></script>
72+
<script type="text/javascript" src="js/hashchange.js"></script>
73+
<script type="text/javascript" src="js/get.js"></script>
74+
<script type="text/javascript" src="js/tooltips.js"></script>
75+
<script type="text/javascript" src="js/showText.js"></script>
76+
<script type="text/javascript" src="js/plot.js"></script>
77+
<script type="text/javascript" src="js/script.js"></script>
7278
<script type="text/javascript" src="js/index.js"></script>
7379

7480
<script>
7581
// Set PROXY_URL to false to not use proxy if AJAX request fails.
7682
let PROXY_URL = "proxy?url=";
7783

78-
// Will use server list at ./all.txt if found
84+
// Use server list at ./all.txt if found
7985
let SERVER_LIST = "all.txt";
8086

8187
// Show all servers if SERVER_LIST if ./all.txt not found
8288
let SERVER_LIST_FALLBACK =
8389
"https://raw.githubusercontent.com/hapi-server/servers/master/all_.txt";
90+
91+
let devNote = "";
92+
if (location.href.match("hapi-server.org/servers-dev")) {
93+
SERVER_LIST = "all-combined.txt";
94+
devNote = "Development server.<br>";
95+
}
96+
if (location.href.match("hapi-server.org/servers")) {
97+
SERVER_LIST = "all-combined.txt";
98+
}
8499

85100
let VERIFIER = '__VERIFIER__';
86101
let VERIFIER_EXTERNALLY_SET = true;
@@ -89,39 +104,37 @@
89104
if (VERIFIER.startsWith('__')) {
90105
VERIFIER_EXTERNALLY_SET = false;
91106
VERIFIER = "https://hapi-server.org/verify";
107+
if (location.href.match("//localhost")) {
108+
VERIFIER = "http://localhost:9999";
109+
}
92110
}
93111

94112
let PLOTSERVER = '__PLOTSERVER__';
95113
let PLOTSERVER_EXTERNALLY_SET = true;
96114
if (PLOTSERVER.startsWith('__')) {
97115
PLOTSERVER_EXTERNALLY_SET = false;
98116
PLOTSERVER = "https://hapi-server.org/plot";
99-
}
100-
101-
let URLWATCHER = 'https://hapi-server.org/urlwatcher/';
102-
103-
let devNote = "";
104-
if (location.href.match("hapi-server.org/servers-dev")) {
105-
SERVER_LIST = "all-combined.txt";
106-
devNote = "Development server.<br>";
107-
} else if (location.href.match("hapi-server.org/servers")) {
108-
SERVER_LIST = "all-combined.txt";
109-
} else if (location.href.match("//localhost") || location.host.match(/^[0-9]/)) {
110117
if (location.href.match("//localhost")) {
111-
SERVER_LIST = "all.txt";
112-
} else {
113-
SERVER_LIST = "all-combined.txt";
114-
}
115-
if (PLOTSERVER_EXTERNALLY_SET == false) {
116-
PLOTSERVER = "http://localhost:5000";
117-
}
118-
if (VERIFIER_EXTERNALLY_SET == false) {
119-
VERIFIER = "http://localhost:9999";
118+
PLOTSERVER = "http://localhost:5000";
120119
}
121120
}
122121

122+
//PLOTSERVER = "https://jfaden.net/AutoplotServlet/SimpleServlet";
123+
124+
OPTIONS = {
125+
"urlwatcher": "https://hapi-server.org/urlwatcher/",
126+
"serverList": SERVER_LIST,
127+
"serverListFallback": SERVER_LIST_FALLBACK,
128+
"plotserver": PLOTSERVER,
129+
"verifier": VERIFIER,
130+
"proxyURL": PROXY_URL,
131+
"devNote": devNote,
132+
"hapiplot": "https://hapi-server.org/plot/",
133+
"autoplot": "https://jfaden.net/AutoplotServlet/SimpleServlet"
134+
}
135+
123136
$(function() {
124-
main(); // DOM is loaded. Call main() in js/index.js.
137+
main(OPTIONS); // DOM is loaded. Call main() in js/index.js.
125138
})
126139
</script>
127140
</head>
@@ -131,7 +144,7 @@
131144
<div id="selections">
132145

133146
<details id="options-details">
134-
<summary><span class="link">Options</span></summary>
147+
<summary><span>Options</span></summary>
135148
<div id="optionscheckboxes">
136149
<div class="tooltip-right"
137150
title="When requesting data, show data in broswer instead of only providing a download link.">
@@ -188,7 +201,7 @@
188201

189202
<br>
190203

191-
<div class="tooltip-right" title="URL of server to use for plots">
204+
<div class="tooltip-right" title="Server to use for plots (<code>hapiplot</code>, <code>autoplot</code>, <code>hapiplot:https://..../</code>, <code>autoplot:https://..../</code>)">
192205
<b>Plotserver</b>
193206
<input id="plotserver" type="text" value="" style="width:100%">
194207
</div>
@@ -235,7 +248,7 @@
235248
<div id="xstatus"></div>
236249
<div id="loadinfo">
237250
<code id="timing"></code>
238-
<code id="loading"></code>
251+
<span id="requests"></span>
239252
</div>
240253

241254
<div id="overviewinfo">
@@ -325,6 +338,9 @@
325338
<a title="https://github.com/spedas/pyspedas"
326339
href="https://github.com/spedas/pyspedas">Python SPEDAS</a> /
327340

341+
<a title="https://nasa.github.io/Kamodo"
342+
href="https://nasa.github.io/Kamodo/">Python Kamodo</a> /
343+
328344
Wget
329345

330346
scripts that read and plot the selected parameter.

js/checkboxes.js

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
function checkboxes() {
1+
function checkboxes(OPTIONS) {
22

33
function savedefaults() {
44
var state = {};
55
var values = $('input[type="checkbox"]').map(function() {
66
state[this.id] = this.checked;
7-
})
7+
});
8+
state["plotserver"] = $('#plotserver').val();
89
localStorage.setItem("server-ui-defaults", JSON.stringify(state));
910
}
1011

@@ -17,32 +18,46 @@ function checkboxes() {
1718
showdata: true,
1819
showverifierlink: false,
1920
showtiming: false,
21+
showrequests: false,
2022
useimagecache: true,
2123
usedatacache: true,
2224
console: false,
23-
plotserver: "http://hapi-server.org/plot"
25+
plotserver: OPTIONS['plotserver']
2426
}
2527
}
2628

29+
$('#showdata').attr('checked', defaults['showdata']);
30+
if (defaults['showdata']) {$('#data').show()}
31+
$('#showdata').change(function() {
32+
savedefaults();
33+
if (this.checked) {
34+
output();
35+
} else {
36+
$('#data').remove();
37+
}
38+
});
39+
2740
$('#showrequests').attr('checked', defaults['showrequests']);
41+
if (defaults['showrequests']) {$('#requests').show()}
2842
$('#showrequests').change(function() {
2943
savedefaults();
3044
if (this.checked) {
31-
$('#loading').show();
45+
$('#requests').show();
3246
} else {
33-
$('#loading').hide();
47+
$('#requests').hide();
3448
}
35-
})
49+
});
3650

3751
$('#showtiming').attr('checked', defaults['showtiming']);
52+
if (defaults['showtiming']) {$('#timing').show();}
3853
$('#showtiming').change(function() {
3954
savedefaults();
4055
if (this.checked) {
4156
$('#timing').show();
4257
} else {
4358
$('#timing').hide();
4459
}
45-
})
60+
});
4661

4762
$('#showstatuslink').attr('checked', defaults['showstatuslink']);
4863
$('#showstatuslink').change(function() {
@@ -52,7 +67,7 @@ function checkboxes() {
5267
} else {
5368
$('#statuslink').hide();
5469
}
55-
})
70+
});
5671

5772
$('#showverifierlink').attr('checked', defaults['showverifierlink']);
5873
$('#showverifierlink').change(function() {
@@ -62,7 +77,7 @@ function checkboxes() {
6277
} else {
6378
$('#verifierlink').hide();
6479
}
65-
})
80+
});
6681

6782
$('#showtestdatalink').attr('checked', defaults['showtestdatalink']);
6883
$('#showtestdatalink').change(function() {
@@ -73,17 +88,7 @@ function checkboxes() {
7388
} else {
7489
$('#testdatalink').hide();
7590
}
76-
})
77-
78-
$('#showdata').attr('checked', defaults['showdata']);
79-
$('#showdata').change(function() {
80-
savedefaults();
81-
if (this.checked) {
82-
output();
83-
} else {
84-
$('#data').remove();
85-
}
86-
})
91+
});
8792

8893
$('#useimagecache').attr('checked', defaults['useimagecache']);
8994
$('#useimagecache').change(function() {
@@ -101,7 +106,7 @@ function checkboxes() {
101106
$("#image > img").attr('src',url)
102107
}
103108
}
104-
})
109+
});
105110

106111
$('#usedatacache').attr('checked', defaults['usedatacache']);
107112
$('#usedatacache').change(function() {
@@ -119,11 +124,25 @@ function checkboxes() {
119124
$("#image > img").attr('src',url)
120125
}
121126
}
122-
})
127+
});
123128

124129
$('#console').attr('checked', defaults['console']);
125130
$('#console').change(function() {
126131
savedefaults();
127132
});
128133

134+
$('#plotserver').val(defaults['plotserver']);
135+
$('#plotserver').change(function () {
136+
let qs = parseQueryString();
137+
if (qs["return"] && qs["return"] === "image" && qs["format"]) {
138+
log("plotserver changed. Triggering select event on #format drop-down.");
139+
$("#format").val("").data("autocomplete")._trigger("select",null,{item:""});
140+
$("#format").val(qs["format"]).data("autocomplete")._trigger("select",null,{item:qs["format"]});
141+
}
142+
qs['plotserver'] = $('#plotserver').val();
143+
$(window).hashchange.byurledit = false;
144+
location.hash = decodeURIComponent($.param(qs));
145+
savedefaults();
146+
});
147+
129148
}

js/dropdowns.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function dropdowns(ids, names, funs, tips, after, i) {
2828
.focus();
2929
});
3030
}
31-
31+
3232
function ac(i, list) {
3333

3434
$("#" + ids[i])
@@ -251,7 +251,7 @@ function dropdowns(ids, names, funs, tips, after, i) {
251251
}
252252

253253
log("dropdowns.ac.select(): New value is not same as old."
254-
+ " Clearing values in all drop-downs after " + id + ".");
254+
+ " Clearing values in all drop-downs after " + id + ".");
255255

256256
$("input[id='"+id+"']")
257257
.parent().parent()
@@ -261,7 +261,7 @@ function dropdowns(ids, names, funs, tips, after, i) {
261261
.attr('value','');
262262

263263
log("dropdowns.ac.select(): Getting drop-down "
264-
+ "values on all remaing drop-downs.");
264+
+ "values on all remaing drop-downs.");
265265

266266
qs = {};
267267
for (j = 0;j < i+1;j++) {
@@ -270,14 +270,14 @@ function dropdowns(ids, names, funs, tips, after, i) {
270270
}
271271
}
272272
log("dropdowns.ac.select(): Setting hash based on"
273-
+ " values on all remaing drop-downs.");
273+
+ " values on all remaing drop-downs.");
274274
location.hash = decodeURIComponent($.param(qs));
275275

276276
// Trigger onselect callback for dropdowns.
277277
var err;
278278
if (funs[i].onselect) {
279279
log("dropdowns.ac.select(): Triggering "
280-
+ "onselect callback for current drop-down.");
280+
+ "onselect callback for current drop-down.");
281281
var err = funs[i].onselect();
282282
}
283283

@@ -347,13 +347,7 @@ function dropdowns(ids, names, funs, tips, after, i) {
347347
return;
348348
}
349349

350-
if (!list) {
351-
log("dropdowns(): Drop-down has no values. Setting next drop-down.");
352-
dropdowns(ids, names, funs, tips, after, i+1);
353-
return;
354-
}
355-
356-
if (list.length == 0) {
350+
if (!list || list.length == 0) {
357351
log("dropdowns(): Drop-down has no values. Setting next drop-down.");
358352
dropdowns(ids, names, funs, tips, after, i+1);
359353
return;

0 commit comments

Comments
 (0)