Skip to content

Commit

Permalink
Select engine in querystring (#18)
Browse files Browse the repository at this point in the history
* initial commit

* Added pull from remote url and from querystring

* Should resolve #15. Check querystring for 'engine' and act accordingly.

* Remove debugging logging

Co-authored-by: Daniel Lim <orcas@octalorca.me>
Co-authored-by: Dreampuf <soddyque@gmail.com>
  • Loading branch information
3 people authored Aug 6, 2020
1 parent 935e1ea commit 15d82b6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,29 @@
rawEl.addEventListener("change", renderGraph);
share.addEventListener("click", copyShareURL);

// Since apparently HTMLCollection does not implement the oh so convenient array functions
HTMLOptionsCollection.prototype.indexOf = function(name) {
for (let i = 0; i < this.length; i++) {
if (this[i].value == name) {
return i;
}
}

return -1;
};

/* come from sharing */
const params = new URLSearchParams(location.search.substring(1));
if (params.has('engine')) {
const engine = params.get('engine');
const index = engineEl.options.indexOf(engine);
if (index > -1) { // if index exists
engineEl.selectedIndex = index;
} else {
show_error({ message: `invalid engine ${engine} selected` });
}
}

if (params.has('raw')) {
editor.getSession().setValue(params.get('raw'));
renderGraph();
Expand Down

0 comments on commit 15d82b6

Please sign in to comment.