5f0f34f0eb9da6a0e42524c1cb2a55f32970b267
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(/\\/g).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 switch (e.nodeName) {
158 var href = document.location.pathname;
159 var perm = $("<a
class=\"permalink
\" href
=\""+href+"#\">#</a
>");
160 if (e.nodeName === "H1
") {
163 perm.attr("href
", function(i, href) {
172 $.each($.makeArray(e.childNodes), function(i, n) {
173 switch (n.nodeName) {
182 mdref.wrap(n, e.nodeName);
190 blink: function blink(c) {
193 $c.fadeOut("fast
").queue(function(next) {
194 this.style.color = "red
";
196 }).fadeIn("fast
").fadeOut("slow
").queue(function(next) {
197 this.style.color = "";
201 hashchange: function hashchange() {
202 if (location.hash.length > 1) {
204 if ((e = document.getElementById(location.hash.substring(1)))) {
207 var hash = location.hash.substring(1);
208 var name = mdref.is_variable(hash) ? ".var" : ".constant
";
209 var scrolled = false;
211 $(name).each(hash.substring(hash.length-1) === "_
" ? function(i, c) {
212 if (c.textContent.substring(0, hash.length) === hash) {
214 $(window).scrollTop($(c).offset().top - 100);
220 if (c.textContent === hash) {
221 $(window).scrollTop($(c).offset().top - 100);
231 $("h1
,h2
,h3
,h4
,h5
,h6
,p
,li
,code
,td
").each(mdref.walk);
232 $(window).on("hashchange
", mdref.hashchange);
235 $("#disqus_activator
").on("click
", function() {
236 var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
237 dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
238 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
240 $.ajax("https
://disqus.com/api/3.0/threads/details.json?thread:ident="+(disqus_identifier||"index")+"&forum=mdref&api_key=VmhVG4z5jjtY8SCaMstOjfUuwniMv43Xy9FCU9YfEzhsrl95dNz1epykXSJn8jt9"). then(function(json) {
241 if (json
&& json
.response
) {
242 $("#disqus_activator span").text(json
.response
.posts
);
245 setTimeout(function() {
246 $("footer").addClass("hidden");