Skip to content
This repository
Browse code

Initial commit.

  • Loading branch information...
commit 4c71b73d4d4e02c2b48d8533736056e08b3bbd9f 0 parents
Fletcher Nichol authored May 31, 2012
19  index.html
... ...
@@ -0,0 +1,19 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+  <head>
  4
+    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  5
+    <script src="js/libs/documentup.js"></script>
  6
+    <script>
  7
+      DocumentUp.document({
  8
+        repo:         "fnichol/chef-rvm_passenger",
  9
+        twitter:      "fnichol",
  10
+        afterRender:  function() {
  11
+          $('#sections a').html(function(index, heading) {
  12
+            return heading.replace(/^&lt;.*\/a&gt; /, '');
  13
+          });
  14
+        }
  15
+      });
  16
+    </script>
  17
+  </head>
  18
+  <body></body>
  19
+</html>
31  js/libs/documentup.js
... ...
@@ -0,0 +1,31 @@
  1
+this.DocumentUp = {};
  2
+
  3
+DocumentUp.document = function (opts) {
  4
+  var repo;
  5
+  if ("string" === typeof opts) {
  6
+    repo = opts;
  7
+    opts = null;
  8
+  } else {
  9
+    repo = opts.repo;
  10
+    delete opts.repo;
  11
+  }
  12
+
  13
+  window.callback = function (resp) {
  14
+    if (resp.status === 200) {
  15
+      document.open();
  16
+      document.write(resp.html);
  17
+      document.close();
  18
+      if (opts && opts.afterRender && typeof opts.afterRender === "function")
  19
+        opts.afterRender()
  20
+    }
  21
+  }
  22
+
  23
+  var script = document.createElement('script');
  24
+  script.src = 'http://documentup.com/'+repo
  25
+  if (opts)
  26
+    script.src += "?config="+encodeURIComponent(JSON.stringify(opts))+'&callback=callback';
  27
+  else
  28
+    script.src += "?callback=callback";
  29
+
  30
+  document.getElementsByTagName('head')[0].appendChild(script);
  31
+}

0 notes on commit 4c71b73

Please sign in to comment.
Something went wrong with that request. Please try again.