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":
60 case "SplObjectStorage":
71 return "<br> <em>";
91 if (-1 !== (i
= s
.indexOf("::"))) {
93 if (!mdref
.is_constant(t
) && !mdref
.is_variable(t
)) {
95 return "<a href=\"" + s
.replace(/::|\\/g, "/") + "\">";
98 if (-1 !== (j = s.indexOf("\\")) && s.substr(j+1,1) !== "n
") {
99 return "<a href
=\"" + s.replace(/\\/g, "/").replace(/::|$/, "#") + "\">";
102 switch (s.toLowerCase()) {
105 if (!mdref.is_variable(s)) {
112 return "<span
class=\"var\">";
116 if (mdref.is_constant(s)) {
117 return "<span
class=\"constant
\">";
120 wrap: function wrap(n, nn) {
124 $n.text().split(/([^a-zA-Z0-9_\\\$:]+)/).forEach(function(v) {
127 if ((t = mdref.type(v, nn))) {
128 a.push($(t).text(v));
129 } else if (a.length && a[a.length-1].nodeName === "#text
") {
130 /* if we already have a text node and the next is also gonna be a text
131 * node, then join them, becuase chrome v30+ or something eats whitespace
132 * for breakfast, lunch and dinner!
134 a[a.length-1].textContent += v;
136 a.push(document.createTextNode(v));
141 walk: function walk(i, e) {
142 // mdref.log("walk
", i, e);
144 $.each($.makeArray(e.childNodes), function(i, n) {
145 switch (n.nodeName) {
154 mdref.wrap(n, e.nodeName);
162 blink: function blink(c) {
165 $c.fadeOut("fast
").queue(function(next) {
166 this.style.color = "red
";
168 }).fadeIn("fast
").fadeOut("slow
").queue(function(next) {
169 this.style.color = "";
173 hashchange: function hashchange() {
174 if (location.hash.length > 1) {
175 var hash = location.hash.substring(1);
176 var name = mdref.is_variable(hash) ? ".var" : ".constant
";
177 var scrolled = false;
179 $(name).each(hash.substring(hash.length-1) === "_
" ? function(i, c) {
180 if (c.textContent.substring(0, hash.length) === hash) {
182 $(window).scrollTop($(c).offset().top - 100);
188 if (c.textContent === hash) {
189 $(window).scrollTop($(c).offset().top - 100);
198 $("h1
,h2
,h3
,h4
,h5
,h6
,p
,li
,code
").each(mdref.walk);
199 $(window).on("hashchange
", mdref.hashchange);