Merge branch 'kogakure:master' into git.m6w6.name
[m6w6/gitweb-theme] / custom.js
1
2 (function(d) {
3 /* load original gitweb.js */
4 var s = d.createElement("script");
5 s.type = "text/javascript";
6 s.src = "static/gitweb.js";
7 d.body.appendChild(s);
8
9 /* add separators between .page_nav links split by br */
10 [].slice.call(d.querySelectorAll(".page_nav a+br")).forEach(function(v) {
11 v.parentNode.replaceChild(d.createTextNode(" | "),v)
12 });
13
14 /* summary */
15 var q = {};
16 location.search.substring(1).split(";").forEach(function(p) {
17 var kv = p.split("=");
18 q[kv[0]]=kv[1];
19 });
20 if (q.p && (!q.a || q.a == "summary")) {
21 var x = new XMLHttpRequest();
22 x.onreadystatechange = function() {
23 if (x.readyState == XMLHttpRequest.DONE && x.status == 200) {
24 var target = d.querySelector(".projects_list");
25 if (target) {
26 var e = new DOMParser().parseFromString(x.response, "text/html");
27 [].slice.call(e.getElementsByTagName("a")).forEach(function(a) {
28 if (a.host == location.host) {
29 a.host = "github.com";
30 a.pathname = "/"+q.p+"/blob/master"+a.pathname;
31 }
32 });
33 target.parentNode.insertBefore(e.body.firstChild, target.nextSibling);
34 }
35 }
36 };
37 x.open("GET", "https://api.github.com/repos/"+q.p+"/readme", true);
38 x.setRequestHeader("Accept", "application/vnd.github.v3.html");
39 x.send();
40 }
41 })(document);