-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy path_preview.js
More file actions
35 lines (25 loc) · 759 Bytes
/
_preview.js
File metadata and controls
35 lines (25 loc) · 759 Bytes
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
(function(){
var file = document.location.search.replace(/\?/,'');
var link = document.createElement('a');
var listing = false;
// get directory listing if no URL provided
if (!file){
listing = true;
file = '/';
}
// let's ajax it in
var content = jQuery('<div>').load(file, function(res){
var self = $(this), ext = file.split(".");
if(ext[ext.length - 1] == "md")
self[0].innerHTML = marked.parse(res);
self.prependTo('#gc-content');
// muck with the content
if (!listing) return;
self.find('a[href]')
.filter('a[href$="/"]').closest('li').remove().end().end()
.attr('href', function(el, oldattr){
link.href = oldattr;
return location.pathname + '?' + link.pathname.replace(/\/docs\//,'');
});
});
}());