Skip to content

Commit 95fd4d4

Browse files
committed
pass data from querystring
1 parent 315df96 commit 95fd4d4

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

docs/index.html

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,15 @@
88
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cerulean/bootstrap.min.css" rel="stylesheet" integrity="sha384-zF4BRsG/fLiTGfR9QL82DrilZxrwgY/+du4p/c7J72zZj+FLYq4zY00RylP9ZjiT" crossorigin="anonymous">
99
<script src="https://d3js.org/d3.v4.min.js"></script>
1010
<style type="text/css">
11-
12-
/** {
13-
padding: 0;
14-
margin: 0;
15-
border-width: 0;
16-
}*/
17-
1811
.links line {
1912
stroke-opacity: 0.6;
2013
stroke-width: 1px;
2114
fill: none;
2215
}
23-
2416
.nodes circle {
2517
stroke: #333;
2618
stroke-width: 1.5px;
2719
}
28-
body {
29-
/*background-color: green;*/
30-
}
31-
32-
/*html, body, svg {
33-
width: 100%;
34-
height: 100%;
35-
}*/
3620
</style>
3721
</head>
3822

@@ -371,14 +355,31 @@ <h4 class="modal-title">Data URL</h4>
371355
})
372356
}
373357

358+
function getQueryVariable(variable){
359+
var query = window.location.search.substring(1);
360+
var vars = query.split("&");
361+
for (var i=0;i<vars.length;i++) {
362+
var pair = vars[i].split("=");
363+
if(pair[0] == variable){return pair[1];}
364+
}
365+
return "";
366+
}
367+
374368
// new data from url
375369
d3.select("#url-load").on("click", loadURL);
376370
function loadURL(){
377371
var url = document.getElementById("url-data").value;
372+
history.pushState('', 'CertGraph', "?data="+url);
378373
newGraph(url);
379374
};
380375

381-
newGraph("https://gist.githubusercontent.com/lanrat/8187d01793bf3e578d76495182654206/raw/c49741b5206d81935febdf563452cc4346381e52/eff.json");
376+
377+
// load initial graph data
378+
var dataURL = getQueryVariable("data");
379+
if (dataURL == "") {
380+
dataURL = "https://gist.githubusercontent.com/lanrat/8187d01793bf3e578d76495182654206/raw/c49741b5206d81935febdf563452cc4346381e52/eff.json";
381+
}
382+
newGraph(dataURL);
382383
</script>
383384

384385
</body>

0 commit comments

Comments
 (0)