-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.min.js
1 lines (1 loc) · 6.89 KB
/
loader.min.js
1
!function(){var e="bodjo-page-loader",a=null,o=null;function n(e){var a=new Date(e);return a.toDateString().split(" ").slice(1).join(" ")+", "+t(a.getHours())+":"+t(a.getMinutes())}function t(e,a){return"string"!=typeof e&&(e=e.toString()),"number"!=typeof a&&(a=2),e.length>=a?e:"0".repeat(a-e.length)+e}window.loadBodjoPage=function(t,i,s){var d;function g(){r(a+"/pages/load?id="+t+(s.preview?"&preview":""),function(a,o){a?"ok"!=o.status?console.warn(e,"bad api response",o):l(o):console.warn(e,"bad http response: "+o.statusCode+": "+o.statusText)},s.cache)}function l(e){i.className.indexOf("bodjo-page")<0&&(i.className+=" bodjo-page"),i.innerHTML=(void 0===e.page?"":function(e,o,t){var i;o&&(i="u"+Math.round(9999999*Math.random()),setTimeout(function(){r(a+"/account/info?username="+e.author,function(e,a){var o=document.querySelector("#"+i);if(null!==o){if(e&&"ok"==a.status){var n=a.result[0];o.querySelector(".image").style.backgroundImage='url("'+n.image[64]+'")'}o.className="author"}},t)},1));return'<div class="signature"><a class="id" href="https://pages.bodjo.net/#'+e.id+'">'+e.id+"</a><br>"+(o?'<div class="author loading" id="'+i+'"><span class="image"></span><span class="name"><span class="username">'+e.author+'</span><br><span class="role">author</span></span></div><div class="info"><div class="date">published '+n(e["date-published"])+"</div>"+(e["date-edited"]>0?'<div class="date edited">edited '+n(e["date-edited"])+"</div>":"")+"</div>":"")+"</div>"}(e.page,s.signature,s.cache))+parseBodjoPage(void 0===e.page?e:e.page.content)}void 0===s&&(s={}),void 0===s.signature&&(s.signature=!0),void 0===s.cache&&(s.cache=!0),"string"==typeof i&&(i=document.querySelector(i)),null==o&&((o=document.createElement("style")).innerHTML='@import url(https://fonts.googleapis.com/css?family=Roboto+Mono:400,700|Source+Code+Pro:400,700&display=swap&subset=cyrillic);.bodjo-page{font-size:100%;font-family:"Source Code Pro","Roboto Mono",Consolas,monospace}.bodjo-page h1,.bodjo-page h2,.bodjo-page h3,.bodjo-page h4,.bodjo-page h5,.bodjo-page h6,.bodjo-page p{margin:0;display:inline-block}.bodjo-page pre.code{overflow:auto;background:rgba(0,0,0,.05);border-radius:2px;padding:5px;-moz-tab-size:4;-o-tab-size:4;tab-size:4;display:inline-block;font-size:130%;max-width:100%;box-sizing:border-box;word-break:break-all;white-space:normal}.bodjo-page span.code-small{background:rgba(0,0,0,.05);border-radius:2px;padding:2px;display:inline-block;font-size:90%}.bodjo-page div.question,.bodjo-page div.warning{box-sizing:border-box;display:inline-block;min-width:50%;position:relative;border-radius:2px;padding:5px;padding-right:25px}.bodjo-page div.question>span:nth-child(1),.bodjo-page div.warning>span:nth-child(1){position:absolute;top:0;right:0;width:27px;text-align:center;font-weight:700;font-size:150%}.bodjo-page div.warning{background-color:rgba(255,204,128,.5)}.bodjo-page div.warning>span:nth-child(1){color:rgba(127,102,64,1)}.bodjo-page div.question{background-color:rgba(144,202,249,.5)}.bodjo-page div.question>span:nth-child(1){color:rgba(72,101,123,1)}.bodjo-page img.right{margin:10px 0 10px 10px;float:right;max-width:50%}.bodjo-page img.left{margin:10px 10px 10px 0;float:left;max-width:50%}.bodjo-page img{max-width:100%}.bodjo-page ul{margin:0 0 0 5px}.bodjo-page .signature{font-size:110%;margin-bottom:2px}.bodjo-page .signature .id{display:inline-block;text-decoration:none;border-bottom:1px dashed rgba(0,0,0,0.15);color:rgba(0,0,0,0.5);font-size:75%}.bodjo-page .signature .id:hover{border-bottom:1px dotted rgba(0,0,0,0.5)}.bodjo-page .signature .id:active{font-weight:bold;color:#000;border-bottom:1px solid #000;}.bodjo-page .signature .date{font-style:italic;font-size:60%}.bodjo-page .signature .info{float:right;text-align:right;margin:5px 0}.bodjo-page .signature .author{min-width:100px;display:inline-block;padding:5px 0}.bodjo-page .signature .author span.image{width:25px;height:25px;display:inline-block;background-size:contain;box-shadow:0 1px 3px rgba(0,0,0,.2);border-radius:50%;margin-right:8px}.bodjo-page .signature .author>*{vertical-align:bottom;display:inline-block;line-height:50%}.bodjo-page .signature .author .name .username{margin:0}.bodjo-page .signature .author .name .role{opacity:.5;font-size:60%;margin:0}.bodjo-page .signature .author.loading span.image{background-color:rgba(0,0,0,.1);animation:loadingblink infinite ease-in-out 1s}@keyframes loadingblink{0%{background:rgba(0,0,0,.025)}50%{background:rgba(0,0,0,.075)}100%{background:rgba(0,0,0,.025)}}.bodjo-page video{max-width: 100%}',document.querySelector("head").appendChild(o)),s.raw?l(t):null==a?(d=g,r("https://bodjo.net/SERVER_HOST",function(o,n){o?(a=n,d()):console.warn(e,"failed to get server ip, bad http response: "+n.statusCode+": "+n.statusText)})):g()},window.parseBodjoPage=function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\</g,"<")).replace(/\>/g,">")).replace(/^\~{5}(?:\n|\r\n){0,1}/gm,"")).replace(/\`\`\`(?:\n|\r\n){0,1}((\n|[^`])+)\`\`\`/gm,function(e,a){return"<pre class='code'>"+a.replace(/\#/g,"#").replace(/\!/g,"!").replace(/\?/g,"?").replace(/\t/g," ").replace(/ /g," ")+"</pre>"})).replace(/\`([^`]+)\`/g,"<span class='code-small'>$1</span>")).replace(/^(\#{1,6}) (.+)$/gm,function(e,a,o){return"<h"+a.length+">"+o+"</h"+a.length+">"})).replace(/^(\?|\!) {0,1}\{(?:\n|\r\n){0,1}([^\}]+)(?:\n|\r\n){0,1}\}/gm,function(e,a,o){return'<div class="'+{"?":"question","!":"warning"}[a]+'"><span>'+a+"</span>"+o+"</div>"})).replace(/((?:^(?:[ \t]*)(?:\-|\d+\.|\w+\.) (?:[^\n\r]+)\n{0,1}){1,})/gm,function(e){return"<ul>"+e.replace(/^([ \t]*)(\-|\d+\.|\w+\.) (.+)(?:\n|\r\n){0,1}/gm,function(e,a,o,n){var t="",i=(a.match(/\t/g)||[]).length;return/^[ixv]+\.$/.test(o)?t="list-style: lower-roman;":/^[IXV]+\.$/.test(o)?t="list-style: upper-roman;":/^\d+\.$/.test(o)||/^\w+\.$/.test(o)?(t="list-style: none;",n=o+" "+n):i>=0&&(t="list-style: "+["disc","circle","square"][i%3]+";"),i>0&&(t+="margin-left: "+i+"em;"),"<li style='"+t+"'>"+n+"</li>"})+"</ul>"})).replace(/v\(([^\)]+)\)/g,"<video src='$1' muted loop autoplay></video>")).replace(/V\(([^\)]+)\)/g,"<video src='$1' controls></video>")).replace(/\!\[([^\]]*)\]\(([^\)]+)\)/g,"<img src='$2' alt='$1'></img>")).replace(/(?:\n|\r\n){0,1}\>\;\[([^\]]*)\]\(([^\)]+)\)(?:\n|\r\n){0,1}/g,"<img src='$2' class='right' alt='$1'></img>")).replace(/(?:\n|\r\n){0,1}\<\;\[([^\]]*)\]\(([^\)]+)\)(?:\n|\r\n){0,1}/g,"<img src='$2' class='left' alt='$1'></img>")).replace(/\[([^\]]*)\]\(([^\)]+)\)/g,"<a href='$2'>$1</a>")).replace(/__([^_]+)__/g,"<i>$1</i>")).replace(/\*\*([^\*]+)\*\*/g,"<b>$1</b>")).replace(/(?:\n|\r\n)/g,"<br>")};var i={};function r(e,a,o){if(0!=e.indexOf("http://")&&0!=e.indexOf("https://")&&(e="http://"+e),i[e]&&o)a.apply(null,i[e]);else{var n=new XMLHttpRequest;n.open("GET",e,!0),n.send(),n.onreadystatechange=function(){if(4===n.readyState)if(200==n.status){var o=n.responseText;try{o=JSON.parse(o)}catch(e){}i[e]=[!0,o],a(!0,o)}else i[e]=[!1,n],a(!1,n)}}}}();