forked from jdegre/jdegre.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.html
47 lines (47 loc) · 1.36 KB
/
loader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<script>
urlParams = new URLSearchParams(location.search);
if (urlParams.has('repo')) repo = urlParams.get('repo');
else repo = 'jdegre/5GC_APIs';
if (urlParams.has('branch')) branch = urlParams.get('branch');
else {
branch = '';
ref = document.referrer;
console.log(ref);
id1 = ref.indexOf(repo);
if (id1 != -1) {
r = ref.substr(id1+repo.length);
if (r != '') {
id2 = r.indexOf('/tree/');
if (id2 != -1) {
id3 = r.indexOf('/', id2+7);
if (id3 == -1) branch = r.substr(id2+6);
else branch = r.substr(id2+6, id3-(id2+6));
}
else {
id4 = r.indexOf('/blob/');
if (id4 != -1) branch = r.substr(id4+6, r.indexOf('/README.md')-(id4+6));
else {
id5 = r.indexOf('/edit/');
if (id5 != -1) branch = r.substr(id5+6, r.indexOf('/README.md')-(id5+6));
}
}
}
}
if (branch == '') branch = 'master';
}
if (urlParams.has('yaml')) yaml = urlParams.get('yaml');
else yaml = '';
host = 'https://raw.githubusercontent.com/';
url = host + repo + '/' + branch + '/' + yaml;
console.log(url);
editor = 'https://jdegre.github.io/editor/';
console.log(editor);
loader = editor + '?url=' + url;
window.location.href = loader;
</script>