Skip to content

Commit 311aca6

Browse files
committed
Added support for differnt types of reference URLs
1 parent cc1f80e commit 311aca6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,37 @@
66
<title>DragonRuby Game Toolkit Tutorial</title>
77
<script>
88
function tutorialUrl() {
9+
// is there a querystring parameter
10+
// url looks like http://dragonruby.org/?tutorial=TUTORIAL_URL
911
var tutorialUrlMatches = window.location.href.match(/tutorial=(.*)/) || [""];
1012
var result = (tutorialUrlMatches[0] || "").replace("tutorial=", "").trim();
13+
14+
// nothing found? how about:
15+
// url looks like http://dragonruby.org/index.html#TUTORIAL_URL
16+
if (result.length == 0) {
17+
tutorialUrlMatches = window.location.href.match(/index\.html#(.*)/) || [""];
18+
result = (tutorialUrlMatches[0] || "").replace("index.html#", "").trim();
19+
}
20+
21+
// nothing found? how about:
22+
// url looks like http://dragonruby.org#TUTORIAL_URL
23+
if (result.length == 0) {
24+
tutorialUrlMatches = window.location.href.match(/\.org#(.*)/) || [""];
25+
result = (tutorialUrlMatches[0] || "").replace(".org#", "").trim();
26+
}
27+
28+
// nothing found? how about:
29+
// url looks like http://dragonruby.org/#TUTORIAL_URL
30+
if (result.length == 0) {
31+
tutorialUrlMatches = window.location.href.match(/\/#(.*)/) || [""];
32+
result = (tutorialUrlMatches[0] || "").replace("/#", "").trim();
33+
}
34+
1135
if (result.match(/gist\.github\.com/) && !result.match(/raw/)) {
1236
result = result + "/raw";
1337
result = result.replace("gist.github.com", "gist.githubusercontent.com");
1438
}
39+
1540
return result;
1641
}
1742

0 commit comments

Comments
 (0)