Skip to content

Commit

Permalink
Add otomad links
Browse files Browse the repository at this point in the history
  • Loading branch information
otomad committed Jan 9, 2024
1 parent 1d78866 commit e510f15
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions otomad/link/OtomadHelper.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
var links = {
"latest": "https://github.com/otomad/OtomadHelper/releases/latest",
"latest/v4": "https://github.com/otomad/OtomadHelper/releases/latest",
"datamosh": "https://github.com/otomad/OtomadHelper/releases/tag/v1.0-datamosh",
"documentation/v4": "https://docs.google.com/document/d/1PEkh0_WFDLUAYGD-YzIDNXUQiAKqogEvpuRQhfqz9ng",
};
</script>
<script src="index.js"></script>
23 changes: 23 additions & 0 deletions otomad/link/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var hash = location.hash.replace(/^#/, "");
var searchParams = (function () {
var search = location.search;
var paramArray = search.slice(search.indexOf("?") + 1).split("&");
var params = {};
for (var i = 0; i < paramArray.length; i++) {
var pair = paramArray[i].split("=");
params[pair[0]] = decodeURIComponent(pair[1]);
}
return params;
})();

if (typeof links === "undefined" || !links[hash])
location.href = "about:blank";
else {
var link = links[hash];
link = link.replace(/{{(.*?)}}/g, function (_, param) {
var pair = param.split("="), key = pair[0], def = pair[1] || "";
var searchParam = searchParams[key];
return searchParam || def;
});
location.href = link;
}
7 changes: 7 additions & 0 deletions otomad/link/om_midi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
var links = {
"latest": "https://github.com/otomad/om_midi/releases/latest",
"latest/v3": "https://github.com/otomad/om_midi/releases/latest"
};
</script>
<script src="index.js"></script>

0 comments on commit e510f15

Please sign in to comment.