Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed Feb 21, 2012
0 parents commit fbb7835
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
19 changes: 19 additions & 0 deletions index.html
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/libs/documentup.js"></script>
<script>
DocumentUp.document({
repo: "fnichol/chef-rvm",
twitter: "fnichol",
afterRender: function() {
$('#sections a').html(function(index, heading) {
return heading.replace(/^&lt;.*\/a&gt; /, '');
});
}
});
</script>
</head>
<body></body>
</html>
31 changes: 31 additions & 0 deletions js/libs/documentup.js
@@ -0,0 +1,31 @@
this.DocumentUp = {};

DocumentUp.document = function (opts) {
var repo;
if ("string" === typeof opts) {
repo = opts;
opts = null;
} else {
repo = opts.repo;
delete opts.repo;
}

window.callback = function (resp) {
if (resp.status === 200) {
document.open();
document.write(resp.html);
document.close();
if (opts && opts.afterRender && typeof opts.afterRender === "function")
opts.afterRender()
}
}

var script = document.createElement('script');
script.src = 'http://documentup.com/'+repo
if (opts)
script.src += "?config="+encodeURIComponent(JSON.stringify(opts))+'&callback=callback';
else
script.src += "?callback=callback";

document.getElementsByTagName('head')[0].appendChild(script);
}

0 comments on commit fbb7835

Please sign in to comment.