Create github source links

This commit is contained in:
Andreas Hocevar
2015-03-23 16:08:36 +01:00
parent c707c5e9db
commit 4862a8c897

View File

@@ -53,6 +53,21 @@ $(function () {
$(window).on('resize', _onResize);
_onResize();
// create source code links to github
var srcLinks = $('div.tag-source');
var masterSearch = window.location.href.match(/\/([^\/]*\/)apidoc\//);
if (masterSearch && masterSearch.length) {
var branch = masterSearch[1];
srcLinks.each(function(i, el) {
var textParts = el.innerHTML.trim().split(', ');
var link = 'https://github.com/openlayers/ol3/blob/' + branch +
textParts[0];
el.innerHTML = '<a href="' + link + '">' + textParts[0] + '</a>, ' +
'<a href="' + link + textParts[1].replace('line ', '#l') + '">' +
textParts[1] + '</a>';
});
}
// show/hide unstable items
var links = $('a[href^="ol."]');
var unstable = $('.unstable');