Skip to content

Commit

Permalink
Added pull from url functionality (dreampuf#16)
Browse files Browse the repository at this point in the history
* initial commit

* Added pull from remote url and from querystring

Co-authored-by: Daniel Lim <[email protected]>
  • Loading branch information
UnicodingUnicorn and Daniel Lim authored Aug 3, 2020
1 parent b5cbd56 commit e06e5df
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,36 @@


/* come from sharing */
if (location.hash.length > 1) {
const params = new URLSearchParams(location.search.substring(1));
if (params.has('raw')) {
editor.getSession().setValue(params.get('raw'));
renderGraph();
} else if (params.has('compressed')) {
const compressed = params.get('compressed');
} else if (params.has('url')) {
const url = params.get('url');
let ok = false;
fetch(url)
.then(res => {
ok = res.ok;
return res.text();
})
.then(res => {
if (!ok) {
throw { message: res };
}

editor.getSession().setValue(res);
renderGraph();
}).catch(e => {
show_error(e);
});
} else if (location.hash.length > 1) {
editor.getSession().setValue(decodeURIComponent(location.hash.substring(1)));
}

/* Init */
if (editor.getValue()) {
} else if (editor.getValue()) { // Init
renderGraph();
}

})(document);
</script>
<script src="viz.js" type="text/javascript" charset="utf-8"></script>
Expand Down

0 comments on commit e06e5df

Please sign in to comment.