MATH201/public/js/main.min.2dd2f7073384163751...

70 lines
45 KiB
JavaScript
Raw Normal View History

2023-09-27 10:58:42 -06:00
(function(){var t=this;(function(){(function(){this.Turbolinks={supported:function(){return null!=window.history.pushState&&null!=window.requestAnimationFrame&&null!=window.addEventListener}(),visit:function(t,r){return e.controller.visit(t,r)},clearCache:function(){return e.controller.clearCache()},setProgressBarDelay:function(t){return e.controller.setProgressBarDelay(t)}}}).call(this)}).call(t);var e=t.Turbolinks;(function(){(function(){var t,r,n,o=[].slice;e.copyObject=function(t){var e,r,n;r={};for(e in t)n=t[e],r[e]=n;return r},e.closest=function(e,r){return t.call(e,r)},t=function(){var t,e;return t=document.documentElement,null!=(e=t.closest)?e:function(t){var e;for(e=this;e;){if(e.nodeType===Node.ELEMENT_NODE&&r.call(e,t))return e;e=e.parentNode}}}(),e.defer=function(t){return setTimeout(t,1)},e.throttle=function(t){var e;return e=null,function(){var r;return r=1<=arguments.length?o.call(arguments,0):[],null!=e?e:e=requestAnimationFrame(function(n){return function(){return e=null,t.apply(n,r)}}(this))}},e.dispatch=function(t,e){var r,o,i,s,a,u;return a=null!=e?e:{},u=a.target,r=a.cancelable,o=a.data,i=document.createEvent("Events"),i.initEvent(t,!0,r===!0),i.data=null!=o?o:{},i.cancelable&&!n&&(s=i.preventDefault,i.preventDefault=function(){return this.defaultPrevented||Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}}),s.call(this)}),(null!=u?u:document).dispatchEvent(i),i},n=function(){var t;return t=document.createEvent("Events"),t.initEvent("test",!0,!0),t.preventDefault(),t.defaultPrevented}(),e.match=function(t,e){return r.call(t,e)},r=function(){var t,e,r,n;return t=document.documentElement,null!=(e=null!=(r=null!=(n=t.matchesSelector)?n:t.webkitMatchesSelector)?r:t.msMatchesSelector)?e:t.mozMatchesSelector}(),e.uuid=function(){var t,e,r;for(r="",t=e=1;36>=e;t=++e)r+=9===t||14===t||19===t||24===t?"-":15===t?"4":20===t?(Math.floor(4*Math.random())+8).toString(16):Math.floor(15*Math.random()).toString(16);return r}}).call(this),function(){e.Location=function(){function t(t){var e,r;null==t&&(t=""),r=document.createElement("a"),r.href=t.toString(),this.absoluteURL=r.href,e=r.hash.length,2>e?this.requestURL=this.absoluteURL:(this.requestURL=this.absoluteURL.slice(0,-e),this.anchor=r.hash.slice(1))}var e,r,n,o;return t.wrap=function(t){return t instanceof this?t:new this(t)},t.prototype.getOrigin=function(){return this.absoluteURL.split("/",3).join("/")},t.prototype.getPath=function(){var t,e;return null!=(t=null!=(e=this.requestURL.match(/\/\/[^\/]*(\/[^?;]*)/))?e[1]:void 0)?t:"/"},t.prototype.getPathComponents=function(){return this.getPath().split("/").slice(1)},t.prototype.getLastPathComponent=function(){return this.getPathComponents().slice(-1)[0]},t.prototype.getExtension=function(){var t,e;return null!=(t=null!=(e=this.getLastPathComponent().match(/\.[^.]*$/))?e[0]:void 0)?t:""},t.prototype.isHTML=function(){return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/)},t.prototype.isPrefixedBy=function(t){var e;return e=r(t),this.isEqualTo(t)||o(this.absoluteURL,e)},t.prototype.isEqualTo=function(t){return this.absoluteURL===(null!=t?t.absoluteURL:void 0)},t.prototype.toCacheKey=function(){return this.requestURL},t.prototype.toJSON=function(){return this.absoluteURL},t.prototype.toString=function(){return this.absoluteURL},t.prototype.valueOf=function(){return this.absoluteURL},r=function(t){return e(t.getOrigin()+t.getPath())},e=function(t){return n(t,"/")?t:t+"/"},o=function(t,e){return t.slice(0,e.length)===e},n=function(t,e){return t.slice(-e.length)===e},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.HttpRequest=function(){function r(r,n,o){this.delegate=r,this.requestCanceled=t(this.requestCanceled,this),this.requestTimedOut=t(this.requestTimedOut,this),this.requestFailed=t(this.requestFailed,this),this.requestLoaded=t(this.requestLoaded,this),this.requestProgressed=t(this.requestProgressed,this),this.url=e.Location.wrap(n).requestURL,this.referrer=e.Location.wrap(o).absoluteURL,this.createXHR()}return r.NETWORK_FAILURE=
function imageMode(){const note_wrapper=document.getElementById('note-wrapper')
const images=note_wrapper.getElementsByTagName('img')
if(thumbnail_mode){var els=note_wrapper.getElementsByTagName('img')
for(var i=0,all=els.length;i<all;i++){els[i].classList.remove('thumbnail');}
thumbnail_mode=false}else{var els=note_wrapper.getElementsByTagName('img')
for(var i=0,all=els.length;i<all;i++){els[i].classList.add('thumbnail');}
thumbnail_mode=true}};loadIndex()
jQuery.fn.highlight=function(pat){function innerHighlight(node,pat){var skip=0;if(node.nodeType==3){var pos=node.data.toUpperCase().indexOf(pat);if(pos>=0){var spannode=document.createElement('span');spannode.className='highlighted';var middlebit=node.splitText(pos);var endbit=middlebit.splitText(pat.length);var middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceChild(spannode,middlebit);skip=1;}}else if(node.nodeType==1&&node.childNodes&&!/(script|style) /i.test(node.tagName)){for(var i=0;i<node.childNodes.length;++i){i+=innerHighlight(node.childNodes[i],pat);}}
return skip;}
return this.each(function(){innerHighlight(this,pat.toUpperCase());});};jQuery.fn.removeHighlight=function(){function newNormalize(node){for(var i=0,children=node.childNodes,nodeCount=children.length;i<nodeCount;i++){var child=children[i];if(child.nodeType==1){newNormalize(child);continue;}
if(child.nodeType!=3){continue;}
var next=child.nextSibling;if(next==null||next.nodeType!=3){continue;}
var combined_text=child.nodeValue+next.nodeValue;new_node=node.ownerDocument.createTextNode(combined_text);node.insertBefore(new_node,child);node.removeChild(child);node.removeChild(next);i--;nodeCount--;}}
return this.find("span.highlighted").each(function(){var thisParent=this.parentNode;thisParent.replaceChild(this.firstChild,this);newNormalize(thisParent);}).end();};$(function(){$('#search-input').bind('keyup change',function(ev){var searchTerm=$(this).val();$('body').removeHighlight();if(searchTerm){$('body').highlight(searchTerm);}});});var scrollTop=0
document.addEventListener("turbolinks:before-render",function(){var search_index=document.getElementById("search-results");var y=search_index.scrollTop;scrollTop=y})
document.addEventListener("turbolinks:render",function(){var search_index=document.getElementById("search-results");search_index.scrollTop=scrollTop})
document.addEventListener("turbolinks:load",function(){setNoteWrapperState()
const current=window.location.href
var els=document.getElementsByTagName("a");for(var i=0,l=els.length;i<l;i++){var el=els[i];if(el.href===current){el.classList.add("selected")}else{el.classList.remove("selected")}}})
function loadIndex(){fetchJSON(function(response){const notes=response;const search_results=document.getElementById('search-results');const tags=document.getElementById('tags');const current_note=window.location.href;notes.index.forEach(note=>{const title='<h4>'+note.title+'</h4>';const summary='<div>'+note.summary+'</div>';const permalink=note.permalink
var thumbnail=""
if(note.thumbnail===""){thumbnail=""}else{thumbnail='<img loading="lazy" src="'+note.thumbnail+'?nf_resize=fit&w=122&h=76"/><span style="display:none";>@attachments</span>'}
const tags='<span style="display:none">'+note.tags+'</span>'
var list_content;if(current_note===permalink){list_content='<a href="'+permalink+'" class="selected search-item" tabindex="0">'+title+summary+'</a>'}else{list_content='<a href="'+permalink+'" class="search-item" tabindex="0">'+title+summary+thumbnail+tags+'</a>'}
const child=document.createElement("li");child.innerHTML=list_content;search_results.append(child)});});}
function fetchJSON(callback){const requestURL='/index.json';const request=new XMLHttpRequest();request.open('GET',requestURL,true);request.responseType='json';request.onreadystatechange=function(){if(request.readyState===4&&request.status===200){callback(request.response);}};request.send(null);}
function focusTag(a){showNav()
performSearchWith(a.innerText)}
function performSearchWith(query){var filter,ul,li,a,i,txtValue;filter=query.toLowerCase();filter=filter.replace('/[.*+?^${}()|[\]\\]/g','\\$&');var re=new RegExp(filter,'g');ul=document.getElementById("search-results");li=ul.getElementsByTagName('li');for(i=0;i<li.length;i++){a=li[i].getElementsByTagName("a")[0];txtValue=a.textContent||a.innerText;if(txtValue.toLowerCase().indexOf(filter)>-1){li[i].style.display="block";}else{li[i].style.display="none";}}}
function performSearch(){var input,filter,ul,li,a,i,txtValue;input=document.getElementById('search-input');filter=input.value.toLowerCase();filter=filter.replace('/[.*+?^${}()|[\]\\]/g','\\$&');var re=new RegExp(filter,'g');ul=document.getElementById("search-results");li=ul.getElementsByTagName('li');for(i=0;i<li.length;i++){a=li[i].getElementsByTagName("a")[0];txtValue=a.textContent||a.innerText;if(txtValue.toLowerCase().indexOf(filter)>-1){li[i].style.display="block";}else{li[i].style.display="none";}}}
document.addEventListener('keydown',function(evt){if(evt.metaKey&&evt.which===75||evt.ctrlKey&&evt.which===75){document.getElementById("search-input").focus();handleNavVisibility()}
if(evt.key==="Escape"||evt.key==="Esc"|evt.keyCode===27){hideNav()}});var nav_is_visible=false;function handleNavVisibility(){if(!nav_is_visible){showNav();}else{hideNav()}}
function showNav(){document.getElementById("search").style.width="300px";document.getElementById("search").style.opacity=1;document.getElementById("search-header").style.opacity=1;document.getElementById("search-header").style.width="299px";pushNoteWrapper()
nav_is_visible=true;}
function hideNav(){document.getElementById("search").style.width="0";document.getElementById("search-header").style.width="0";document.getElementById("search").style.opacity=0;document.getElementById("search-header").style.opacity=0;document.getElementById("main").style.marginLeft="0";pullNoteWrapper()
nav_is_visible=false;}
function setNoteWrapperState(){if(nav_is_visible){pushNoteWrapper()}else{pullNoteWrapper()}}
function pushNoteWrapper(){document.getElementById("main").style.marginLeft="300px";}
function pullNoteWrapper(){document.getElementById("main").style.marginLeft="0";}
const hoverTime=300
const fetchers={}
const doc=document.implementation.createHTMLDocument('prefetch')
function fetchPage(url,success){const xhr=new XMLHttpRequest()
xhr.open('GET',url)
xhr.setRequestHeader('VND.PREFETCH','true')
xhr.setRequestHeader('Accept','text/html')
xhr.onreadystatechange=()=>{if(xhr.readyState!==XMLHttpRequest.DONE)return
if(xhr.status!==200)return
success(xhr.responseText)}
xhr.send()}
function prefetchTurbolink(url){fetchPage(url,responseText=>{doc.open()
doc.write(responseText)
doc.close()
const snapshot=Turbolinks.Snapshot.fromHTMLElement(doc.documentElement)
Turbolinks.controller.cache.put(url,snapshot)})}
function prefetch(url){if(prefetched(url))return
prefetchTurbolink(url)}
function prefetched(url){return location.href===url||Turbolinks.controller.cache.has(url)}
function prefetching(url){return!!fetchers[url]}
function cleanup(event){const element=event.target
clearTimeout(fetchers[element.href])
element.removeEventListener('mouseleave',cleanup)}
document.addEventListener('mouseover',event=>{if(!event.target.dataset.prefetch)return
const url=event.target.href
if(prefetched(url))return
if(prefetching(url))return
cleanup(event)
event.target.addEventListener('mouseleave',cleanup)
fetchers[url]=setTimeout(()=>prefetch(url),hoverTime)})