|
45 | 45 | anchors.add(selector);
|
46 | 46 | </script>
|
47 | 47 | <script>
|
| 48 | +if (typeof String.prototype.endsWith !== "function") { |
| 49 | + String.prototype.endsWith = function(suffix) { |
| 50 | + return this.indexOf(suffix, this.length - suffix.length) !== -1; |
| 51 | + }; |
| 52 | +} |
| 53 | + |
| 54 | +// Triggered when changing the version from select box.. |
48 | 55 | function changeVersion() {
|
49 | 56 | var e = document.getElementById("version");
|
50 | 57 | var strVersion = e.options[e.selectedIndex].value;
|
51 | 58 | window.location = "{{ site.url }}/" + strVersion + "/";
|
52 | 59 | }
|
| 60 | + |
| 61 | +// Update the URL if the version is not specified.. |
| 62 | +var links = document.links; |
| 63 | + |
| 64 | +for(var i = 0; i < links.length; i++) { |
| 65 | + var link = links[i].href; |
| 66 | + |
| 67 | + // Make sure the link is not external and targets a document in the documentation.. |
| 68 | + if (link.indexOf("{{ site.url }}") === 0 && link.endsWith(".html")) { |
| 69 | + var url = link.substring(0, link.lastIndexOf("/") + 1); |
| 70 | + var file = link.split("/").pop(); |
| 71 | + var parts = url.split("/"); |
| 72 | + |
| 73 | + // No version specified in the URL.. |
| 74 | + if (/^v(\d+\.)?(\d+\.)?(\*|\d+)$/.test(parts[parts.length-2]) === false) { |
| 75 | + var e = document.getElementById("version"); |
| 76 | + var strUser = e.options[e.selectedIndex].value; |
| 77 | + links[i].href = url + strUser + "/" + file; |
| 78 | + } |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +// Some random quotes that appears in the bottom of the page.. |
53 | 83 | var quotes = [
|
54 | 84 | "The best thing about a boolean is even if you are wrong, you are only off by a bit.",
|
55 | 85 | "There are two ways to write error-free programs; only the third one works.",
|
|
0 commit comments