6 console
.log
.apply(console
, arguments
);
8 is_constant
: function is_constant(s
) {
9 s
= s
.replace(/v\d+(_\d+)?$/, "");
13 return s
.toUpperCase(s
) === s
;
15 is_variable
: function is_variable(s
) {
16 return s
.substring(0,1) === "$";
18 type
: function type(s
, nn
) {
20 // mdref.log("type", s);
22 if (!s
.match(/[a-zA-Z]/)) {
41 case "ErrorException":
42 case "RuntimeException":
43 case "UnexpectedValueException":
44 case "DomainException":
45 case "InvalidArgumentException":
46 case "BadMethodCallException":
53 case "IteratorAggregate":
57 case "RecursiveArrayIterator":
58 case "SeekableIterator":
61 case "SplObjectStorage":
62 case "JsonSerializable":
73 return "<br> <em>";
93 if (-1 !== (i
= s
.indexOf("::"))) {
95 if (!mdref
.is_constant(t
) && !mdref
.is_variable(t
)) {
97 return "<a href=\"" + s
.replace(/::|\\/g, "/") + "\">";
100 if (-1 !== (j = s.lastIndexOf("\\")) && s.substr(j+1,1) !== "n
") {
101 t = s.substring(j+1);
102 if (!mdref.is_constant(t) || s.match(/\\/).length <= 1) {
103 return "<a href
=\"" + s.replace(/\\/g, "/").replace(/::/, "#") + "\">";
105 return "<a href
=\"" + s.substring(0,j).replace(/\\/g, "/") + "#" + t + "\">";
108 switch (s.toLowerCase()) {
111 if (!mdref.is_variable(s)) {
118 return "<span
class=\"var\">";
122 if (mdref.is_constant(s)) {
123 return "<span
class=\"constant
\">";
126 wrap: function wrap(n, nn) {
130 $n.text().split(/([^a-zA-Z0-9_\\\$:]+)/).forEach(function(v) {
133 if ((t = mdref.type(v.replace(/:$/, ""), nn))) {
134 a.push($(t).text(v));
135 } else if (a.length && a[a.length-1].nodeName === "#text
") {
136 /* if we already have a text node and the next is also gonna be a text
137 * node, then join them, becuase chrome v30+ or something eats whitespace
138 * for breakfast, lunch and dinner!
140 a[a.length-1].textContent += v;
142 a.push(document.createTextNode(v));
147 walk: function walk(i, e) {
148 // mdref.log("walk
", i, e);
150 $.each($.makeArray(e.childNodes), function(i, n) {
151 switch (n.nodeName) {
160 mdref.wrap(n, e.nodeName);
168 blink: function blink(c) {
171 $c.fadeOut("fast
").queue(function(next) {
172 this.style.color = "red
";
174 }).fadeIn("fast
").fadeOut("slow
").queue(function(next) {
175 this.style.color = "";
179 hashchange: function hashchange() {
180 if (location.hash.length > 1) {
181 var hash = location.hash.substring(1);
182 var name = mdref.is_variable(hash) ? ".var" : ".constant
";
183 var scrolled = false;
185 $(name).each(hash.substring(hash.length-1) === "_
" ? function(i, c) {
186 if (c.textContent.substring(0, hash.length) === hash) {
188 $(window).scrollTop($(c).offset().top - 100);
194 if (c.textContent === hash) {
195 $(window).scrollTop($(c).offset().top - 100);
204 $("h1
,h2
,h3
,h4
,h5
,h6
,p
,li
,code
,td
").each(mdref.walk);
205 $(window).on("hashchange
", mdref.hashchange);