function toggle_visibility(e) { if(e.style.display == 'none') { e.style.display = 'block'; return e; } else { e.style.display = 'none'; return undefined; } } /* function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } */ var storage; var sidetoc; var toc; var menubar; var allItems; function popOutTOC(original_toc, p0) { var t = original_toc.cloneNode(true); t.id = "sidetoc"; var c = document.getElementsByClassName("contents")[0]; var left = c.style.marginLeft; c.style.marginLeft = "20.5em"; document.body.insertBefore(t,c); t.getElementsByClassName("toc_search")[0].getElementsByTagName("input")[0].onkeyup = toc_search; t.style.top = menubar.clientHeight; t.style.maxHeight = "none"; t.style.display = "block"; var p = t.getElementsByClassName("popoutlink")[0]; p.innerHTML = "close"; p.onclick = function() { t.parentNode.removeChild(t); c.style.marginLeft = left; p0.style.display = ""; sidetoc = null; allItems = toc.getElementsByTagName("ul")[0].getElementsByTagName("li"); storage.popToc = "no"; return false; } var x = document.createElement("div"); x.id = "toctitle"; x.innerHTML = "Table of contents"; t.insertBefore(x,p.nextSibling); p0.style.display = "none"; sidetoc = t; allItems = t.getElementsByTagName("ul")[0].getElementsByTagName("li"); resize_handler(); storage.popToc = "yes"; } function resize_handler() { var height = window.innerHeight - menubar.clientHeight - 20; if(sidetoc) sidetoc.style.height = height; if(toc) toc.style.maxHeight = height * 0.75; } function addInheritedMethods() { if(! /\/Classes\/[^\/]+/.test(window.location.pathname)) return; // skip this if not a class doc var doc = docmap["Classes/"+document.title]; if(!doc) return; if(doc.implementor) { var sups = docmap["Classes/"+doc.implementor].superclasses; } else { var sups = doc.superclasses; } if(!sups) return; var divs = [document.getElementById("inheritedclassmets"), document.getElementById("inheritedinstmets")]; for(var i=0;i"+m.slice(2)+""; if(m[1]=="*") { d[0].appendChild(li); } else if(m[1]=="-") { d[1].appendChild(li); } } } for(var j=0;j<2;j++) { var count = d[j].childElementCount; if(count) { var x = document.createElement("div"); var show = "► show"; var hide = "▼ hide"; x.className = "inheritedmets_class"; x.innerHTML = count+" methods from "+s.title+" "; divs[j].appendChild(x); (function(z) { var a = document.createElement("a"); a.className = "inheritedmets_toggle"; a.setAttribute("href","#"); a.innerHTML = show; a.onclick = function() { if(z.style.display == "none") { z.style.display = "block"; a.innerHTML = hide; } else { z.style.display = "none"; a.innerHTML = show; } return false; }; x.appendChild(a); })(d[j]); divs[j].appendChild(d[j]); } } } } function showAllSubclasses(a) { var e = document.getElementById("hiddensubclasses"); e.style.display = ""; a.style.display = "none"; } /* This key event handler selects the whole line when pressing shift/ctrl-enter with no selection. But the problem is that it does not update the selection sent to the client. This is probably because the WebView catches the key event before javascript does! A fix might be to expose a function to JS that evaluates selection, and call it here. Or can the WebView make sure that JS has responded to all key events before getting the selection? */ function selectLine() { var s = window.getSelection(); var r = s.getRangeAt(); function findleft(p) { var y, j; while(p) { if(p.nodeName == "BR") return [p,j]; if(p.childNodes.length>0) { for(var i=p.childNodes.length-1;i>=0;i--) { y = findleft(p.childNodes[i]); if(y) return y; } } p = p.previousSibling; } return null; }; function findright(p) { var y, j; while(p) { if(p.nodeName == "BR") return [p,j]; for(var i=0;i=0; i--) { var c = text.charAt(i); if(c == char) count--; else if(c == counterChar) count++; if( count < 1 ) break; } } else { for(i=0; i 0) { if( (i = chars.indexOf(text[pos-1])) != -1 ) return [chars[i], node, pos-1]; } else { n = node; do { n = advance(n, top, true); } while (n && !(text = n.nodeValue)); if(n && (len=text.length)) { if( (i = chars.indexOf(text[len-1])) != -1 ) return [chars[i], n, len-1]; } } return null; } if(!code_click_node) return; var top = ev.target; while( top && top.className.indexOf("lang-sc") == -1 ) top = top.parentNode; if(!top) return; var pos = code_click_pos; var node = code_click_node; code_click_node = null; var char; var startRes = findAdjacentChar(top, node, pos, "()"); if(startRes) { char = startRes[0]; node = startRes[1]; pos = startRes[2]; } else { return; } back = char == ")"; counterChar = back ? "(" : ")"; var count = 1, countRes; var rnode, rpos; // try same node var text = node.nodeValue; if( back) text = text.substring(0, pos); else text = text.substring(pos+1); countRes = countChars(counterChar, char, text, count, back); count = countRes[0]; if( count < 1 ) { rpos = countRes[1]; if(!back) rpos += pos + 1; rnode = node; } else { // try other nodes var n = advance(node, top, back); res = findChar(counterChar, char, top, n, back, count); if(res) { rnode = res[0]; rpos = res[1]; } } if(rnode) { if(back) { r2.setStart(rnode, rpos); r2.setEnd(node, pos+1); } else { r2.setStart(node, pos); r2.setEnd(rnode, rpos+1); } s.removeAllRanges(); s.addRange(r2); } } escape_regexp = function(str) { var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ return str.replace(specials, "\\$&"); } function toc_search(ev) { //TODO: on enter, go to first match var re = RegExp("^"+escape_regexp(ev.target.value),"i"); for(var i=0;i=0;i2--) { var e = allItems[i2]; if(e.className[3]