-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pro-src
committed
Jun 5, 2018
1 parent
e4eb98e
commit db4e0b6
Showing
3 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
<header id="docs-header"></header> | ||
|
||
<article class="docs-content" id="docs-content"></article> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/unfetch/dist/unfetch.umd.js"></script> | ||
|
||
<script> | ||
var header = document.getElementById('docs-header'); | ||
var content = document.getElementById('docs-content'); | ||
|
||
var params={}; | ||
window.location.search | ||
.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(s, k, v) { | ||
params[key] = decodeURIComponent(value); | ||
}); | ||
|
||
if (!params.repo) { | ||
window.alert('Error: url query is missing repo name'); | ||
} | ||
|
||
params.page = params.page || 'docs/README.md'; | ||
var url = 'https://cdn.jsdelivr.net/gh/xtermjs/' | ||
+ params.repo + '/' + params.page; | ||
|
||
if (!window.Promise) { | ||
window.Promise = ES6Promise; | ||
} | ||
if (!window.fetch) { | ||
window.fetch = unfetch; | ||
} | ||
|
||
fetch(url) | ||
.then(function (response) { | ||
return response.text(); | ||
}) | ||
.then(function (body) { | ||
content.innerHTML = marked(body); | ||
document.title = content.getElementsByTagName('h1')[0].innerHTML; | ||
header.innerHTML = '<h1><a href="' + location + '">' | ||
+ document.title | ||
+ '</a></h1>'; | ||
var anchors = content.getElementsByTagName('a'); | ||
for (var href, i = 0; i < anchors.length; i++) { | ||
anchors[i].addEventListener('click', onClick); | ||
} | ||
}) | ||
.catch(function (error) { | ||
content.innerHTML = '<p>Oops! There was a problem rendering the page.</p>' | ||
+ '<p>' + error.message + '</p>'; | ||
}); | ||
|
||
function onClick(event) { | ||
var href = event.target.getAttribute('href'); | ||
if (!/^(https?|#)/.test(href)) { | ||
// split on hash | ||
anchor.setAttribute('href', window.location.href.split(/[#?]/)[0] | ||
+ '?repo=' + params.repo + '&page=' + encodeURIComponent(href)); | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<ul class="docs-list"> | ||
{% for doc in site.docs %} | ||
{% if doc.category == include.category %} | ||
<li> | ||
<a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a> | ||
</li> | ||
{% endif %} | ||
{% if doc.category == include.category %} | ||
{% assign url = "{{ site.baseurl }}{{ doc.url }}" %} | ||
<li> | ||
{% unless include.category == "addons" %} | ||
<a href="{{ url }}">{{ doc.title }}</a> | ||
{% else %} | ||
<a href="{{ url }}?repo=xterm.js-addon-attach">Attach</a> | ||
<a href="{{ url }}?repo=xterm.js-addon-fit">Fit</a> | ||
<a href="{{ url }}?repo=xterm.js-addon-fullscreen">Fullscreen</a> | ||
<a href="{{ url }}?repo=xterm.js-addon-terminado">Terminado</a> | ||
<a href="{{ url }}?repo=xterm.js-addon-winptycompat">WinptyCompat</a> | ||
<a href="{{ url }}?repo=xterm.js-addon-zmodem">Zmodem</a> | ||
{% endif %} | ||
This comment has been minimized.
Sorry, something went wrong. |
||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FYI if you do a review comment (via the PR files tab) instead of commenting on the makes it a little easier as a reviewer (plus I get less notifications 😄)