Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.js « js « static - github.com/jacobsun/edidor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9ae3ab1bcb5a928b16b1f79f3cfaff653e18afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){},function(e,t,n){(function(t){var n="Expected a function",o=NaN,i="[object Symbol]",r=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,d=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt,c="object"==typeof t&&t&&t.Object===Object&&t,s="object"==typeof self&&self&&self.Object===Object&&self,f=c||s||Function("return this")(),m=Object.prototype.toString,p=Math.max,h=Math.min,g=function(){return f.Date.now()};function w(e,t,o){var i,r,a,d,u,l,c=0,s=!1,f=!1,m=!0;if("function"!=typeof e)throw new TypeError(n);function w(t){var n=i,o=r;return i=r=void 0,c=t,d=e.apply(o,n)}function v(e){var n=e-l;return void 0===l||n>=t||n<0||f&&e-c>=a}function x(){var e=g();if(v(e))return k(e);u=setTimeout(x,function(e){var n=t-(e-l);return f?h(n,a-(e-c)):n}(e))}function k(e){return u=void 0,m&&i?w(e):(i=r=void 0,d)}function M(){var e=g(),n=v(e);if(i=arguments,r=this,l=e,n){if(void 0===u)return function(e){return c=e,u=setTimeout(x,t),s?w(e):d}(l);if(f)return u=setTimeout(x,t),w(l)}return void 0===u&&(u=setTimeout(x,t)),d}return t=b(t)||0,y(o)&&(s=!!o.leading,a=(f="maxWait"in o)?p(b(o.maxWait)||0,t):a,m="trailing"in o?!!o.trailing:m),M.cancel=function(){void 0!==u&&clearTimeout(u),c=0,i=l=r=u=void 0},M.flush=function(){return void 0===u?d:k(g())},M}function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&m.call(e)==i}(e))return o;if(y(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=y(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var n=d.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):a.test(e)?o:+e}e.exports=function(e,t,o){var i=!0,r=!0;if("function"!=typeof e)throw new TypeError(n);return y(o)&&(i="leading"in o?!!o.leading:i,r="trailing"in o?!!o.trailing:r),w(e,t,{leading:i,maxWait:t,trailing:r})}}).call(this,n(2))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);n(0);const o=n(1);function i(e,t=document.body){return"string"==typeof t&&(t=document.querySelector(t)),t.querySelector(e)}function r(e,t={},...n){const o=document.createElement(e);return Object.keys(t).forEach(e=>{o.setAttribute(e,t[e])}),n.forEach(e=>{"string"==typeof e&&(e=document.createTextNode(e)),o.appendChild(e)}),o}function a(e,t){return"string"==typeof e&&(e=i(e)),e.classList.remove(t),e}function d(e,t){return"string"==typeof e&&(e=i(e)),e.classList.add(t),e}function u(e,t){return"string"==typeof e&&(e=i(e)),e.classList.contains(t)}function l(e,t){"string"==typeof e&&(e=i(e)),Object.keys(t).forEach(n=>{e.style[n]=t[n]})}function c(e,t,n=0,r=document.body,a={}){"string"==typeof r&&(r=i(r)),n>0?r.addEventListener(e,o(t,n),a):r.addEventListener(e,t,a)}const s={};function f(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e))+e}function m(e){return e.duration?Math.min(function(e){const[t]=window.performance.getEntriesByName(e);return t?window.performance.now()-t.startTime:(window.performance.mark(e),0)}(e.id)/e.duration,1):1}s.get=(e=>window.localStorage.getItem(e)),s.set=((e,t)=>{null==t?t="":"string"!=typeof t&&(t=JSON.stringify(t)),window.localStorage.setItem(e,t)});const p={darkCode:["c","f","6","9"],lightCode:["a","b","c","d","e","f"],textCode:["1a2a3a","2a3a4a","3a4a5a","4a5a6a","5a6a7a","6a7a8a","7a8a9a"],grayCode:["aaa","bbb","ccc","ddd"],lightGrayCode:["e2e2e2","e7e7e7","ececec"],deepGrayCode:["222","333","444"],dark:()=>{let e="";for(let t=0;3!==t;t++){let t=p.darkCode[f(0,p.darkCode.length)];e+=t+t}return"#"+e},light:()=>{let e="";for(let t=0;6!==t;t++)e+=p.lightCode[f(0,p.lightCode.length)];return"#"+e},gray:()=>{let e=f(0,p.grayCode.length);return"#"+p.grayCode[e]},lightGray:()=>{let e=f(0,p.lightGrayCode.length);return"#"+p.lightGrayCode[e]},deepGray:()=>{let e=f(0,p.deepGrayCode.length);return"#"+p.deepGrayCode[e]},text:(e=0,t=7)=>{let n=f(e,t);return"#"+p.textCode[n]}};p.deepText=p.text.bind(p,0,2),p.mediumText=p.text.bind(p,2,5),p.lightText=p.text.bind(p,5,6);var h=function(e,...t){return function(){let n=e.slice();return t.forEach((e,t)=>{n[t]+=p[e]()}),n.join("").replace(/\s{2}/gm," ")}}`
  .wild-mode code {
    background: ${"lightGray"}
  }
  .wild-mode .main .article-tags a {
      background: ${"light"};
  }
  .wild-mode .local-info {
      background: ${"light"};
  }
  body.wild-mode,
  .wild-mode .main {
      background: ${"light"};
  }
  .wild-mode th,
  .wild-mode td {
      border-bottom: 1px solid ${"dark"};
  }
  .wild-mode hr {
      border: 1px solid ${"dark"};
  }
  .wild-mode .pagination {
      background: ${"dark"};
  }
  .wild-mode .sidebar {
      background: ${"dark"};
  }
  .wild-mode .header,
  .wild-mode .footer,
  .wild-mode .header .sub-menu li:hover,
  .wild-mode .sidebar a:hover,
  .wild-mode .logo-link,
  .wild-mode .top, .wild-mode .bottom {
      background: ${"dark"};
  }
  .wild-mode .header .menu>li:hover,
  .wild-mode .footer a:hover {
      background: ${"light"};
  }
  .wild-mode .header ul ul {
      box-shadow: 0 0.1em 0.2em 0 ${"dark"};
  }
  .wild-mode .header ul ul,
  .wild-mode .pagination a:hover {
      background: ${"dark"};
  }
  .wild-mode .article-meta,
  .wild-mode .item-meta,
  .wild-mode .footnotes,
  .wild-mode .count,
  .wild-mode .taxonomy-key {
      color: ${"mediumText"};
  }
  .wild-mode .main .article-tags a,
  .wild-mode .local-info,
  .wild-mode .main,
  .wild-mode .main a,
  .wild-mode .terms-list a,
  .wild-mode blockquote.twitter-tweet,
  .wild-mode .sidebar a,
  .wild-mode .taxonomy-key,
  .wild-mode .main .title a,
  .wild-mode .header a,
  .wild-mode .footer a,
  .wild-mode .footer time,
  .wild-mode .pagination a,
  .wild-mode .header .sub-menu a {
      color: ${"deepGray"};
  }
  .wild-mode .icon,
  .wild-mode .footer .icon {
      background: ${"deepGray"};
  }
  `;function g(e){const t={last:!1,resizing:!1,resizable:!1};function n(t,n=4){return Math.abs(t-e.pane.getBoundingClientRect().right)<=n}function o(n){t.resizing=!1;let o=e.pane.getBoundingClientRect();!function(e){if(e<=10)return;s.set("sidebar_width",e)}(o.right-o.left)}c("mousedown",e=>{t.resizable&&(t.resizing=!0)},0),c("mouseup",o,0),c("keydown",e=>{e.ctrlKey&&66===e.keyCode&&y()},0),c("touchstart",e=>{t.resizing=n(e.touches[0].clientX,10)}),c("touchend",o),function(e,t,n=document.body){c("mousemove",t=>{e({clientX:t.clientX,clientY:t.clientY,type:t.type})},t,n,{passive:!0}),c("touchmove",t=>{e({clientX:t.touches[0].clientX,clientY:t.touches[0].clientY,type:t.type})},t,n,{passive:!0})}(function(o){t.resizable=n(o.clientX),t.resizing?function(t){let n=t-e.paneLeft;n<=10?d(e.pane,"hide"):w(n)}(o.clientX):"mousemove"===o.type&&o.clientX>10&&t.last!==t.resizable&&(t.resizable?l(document.body,{cursor:"ew-resize"}):l(document.body,{cursor:"auto"}),t.last=t.resizable)},50,i(".middle"))}function w(e,t="px"){l(i(".sidebar"),{width:e+"px"}),l(i(".main"),{marginLeft:e+"px"})}function y(e,t){return u(e.pane,"hide")?(a(e.pane,"hide"),s.set("is_sidebar_hide","0")):(d(e.pane,"hide"),s.set("is_sidebar_hide","1")),t.preventDefault(),t.stopPropagation(),!1}const b=e=>{u(document.body,e)||d(function(e,t){return"string"==typeof e&&(e=i(e)),e.className="",e}(document.body),e),s.set("mode",e)};function v(e,t){c("click",e=>{a(".dialog","show")},0,".close-dialog"),c("click",e=>{const n=i("#theme-name").value.trim();n?/^[a-zA-Z\s-]+$/.test(n)?"light"!==n&&"dark"!==n&&"wild"!==n?(t.loading(),function(e){let t=function(e){let t=s.get("wild_style"),n=e.replace(/\s/g,"-");return t=t.replace(/wild-mode/g,`${n}-mode`),function(e,t){return`/*\nHugo Edidor theme wild mode exported.\nhomepage: https://github.com/jacobsun/edidor\nUsage:\n1. Throw me to your site root folder/static/css directory, you can rename me to whatever you like.\n2. Copy the code below to your config file.\n\n--------\n[[menu.main]]\nparent = "Theme"\nidentifier = "${e}"\nname = "${t}"\nurl = "#"\nweight = 30\n--------\n\n3. Change the field 'name' and 'weight' to whatever you like. Leave others alone, and don't add your custom field, hugo doesn't support that, though I really hope so :/.\n*/`}(n,e)+t}(e);!function(e,t){const n=r("a",{href:"data:text/plain;charset=utf-8,"+encodeURIComponent(t),download:e,style:{display:"none"}});document.body.appendChild(n),n.click(),document.body.removeChild(n)}(e+".css",t)}(n),a(".dialog","show"),t.loaded()):window.alert("Mess up builtin themes."):window.alert("Only English letters, space, hyphens are allowed."):window.alert("Name is required.")},0,".export")}(function e(t){function n(e){return Math.pow(e,t)}return t=+t,n.exponent=e,n})(3),function e(t){function n(e){return 1-Math.pow(1-e,t)}return t=+t,n.exponent=e,n}(3),function e(t){function n(e){return((e*=2)<=1?Math.pow(e,t):2-Math.pow(2-e,t))/2}return t=+t,n.exponent=e,n}(3),Math.PI;(function e(t){function n(e){return e*e*((t+1)*e-t)}return t=+t,n.overshoot=e,n})(1.70158),function e(t){function n(e){return--e*e*((t+1)*e+t)+1}return t=+t,n.overshoot=e,n}(1.70158),function e(t){function n(e){return((e*=2)<1?e*e*((t+1)*e-t):(e-=2)*e*((t+1)*e+t)+2)/2}return t=+t,n.overshoot=e,n}(1.70158);var x=2*Math.PI,k=(function e(t,n){var o=Math.asin(1/(t=Math.max(1,t)))*(n/=x);function i(e){return t*Math.pow(2,10*--e)*Math.sin((o-e)/n)}return i.amplitude=function(t){return e(t,n*x)},i.period=function(n){return e(t,n)},i}(1,.3),function e(t,n){var o=Math.asin(1/(t=Math.max(1,t)))*(n/=x);function i(e){return 1-t*Math.pow(2,-10*(e=+e))*Math.sin((e+o)/n)}return i.amplitude=function(t){return e(t,n*x)},i.period=function(n){return e(t,n)},i}(1,.3));(function e(t,n){var o=Math.asin(1/(t=Math.max(1,t)))*(n/=x);function i(e){return((e=2*e-1)<0?t*Math.pow(2,10*e)*Math.sin((o-e)/n):2-t*Math.pow(2,-10*e)*Math.sin((o+e)/n))/2}return i.amplitude=function(t){return e(t,n*x)},i.period=function(n){return e(t,n)},i})(1,.3);const M=function(){let e=i(".top"),t=i(".bottom"),n=document.documentElement.clientHeight/2,o=n+100,r=!1,a=!1,d=!1,u=!1;const l=(e,t,n,o=(()=>{}))=>{const i=()=>{let n=Math.min(e(m(r)),1);n<1?(t(n),window.requestAnimationFrame(i)):(window.performance.clearMarks(r.id),t(n),o())},r={duration:n,id:window.requestAnimationFrame(i)}};function c(i){l(k,i=>{e.style.top=-i*o+"px",t.style.top=i*o+n+"px"},1e3,()=>{d=!1,a=!1,u=!1,r=!1})}return{loading:()=>{r||(r=!0,function(i){l(k,i=>{e.style.top=-(1-i)*o+"px",t.style.top=(1-i)*o+n+"px"},1e3,i)}(()=>{a=!0,u&&c()}))},loaded:()=>{r&&(d||(d=!0,a?c():u=!0))}}}();c("DOMContentLoaded",e=>{M.loading();const t={};t.pane=i(".sidebar"),t.main=i(".main"),t.paneLeft=t.pane.getBoundingClientRect().left,function(e,t){let n=s.get("mode");if(n&&b(n),"wild-mode"===n){let e=r("style",{class:"wild-ele"},s.get("wild_style"));document.body.appendChild(e)}t.loaded()}(0,M),function(e){w(s.get("sidebar_width")),"1"===s.get("is_sidebar_hide")?d(e.pane,"hide"):a(e.pane,"hide")}(t),function(e){c("click",y.bind(null,e),0,".toggle-sidebar")}(t),function(e,t){c("click",e=>{if(e.preventDefault(),e.stopPropagation(),"theme-switcher-button"===e.target.id)return;if(u(e.target,"export-wild"))return d(".dialog","show"),void i("#theme-name").focus();let n=e.target.dataset.theme;if(n){if(t.loading(),b(n+"-mode"),"wild"===n){const e=i(".wild-ele"),t=h();e?e.innerText=t:document.body.appendChild(r("style",{class:"wild-ele"},t)),s.set("wild_style",t)}t.loaded()}else console.error('Theme name not found, probably missing an "Identifier" field in Config file.')},0,"#theme-switcher")}(0,M),g(t),v(0,M)},0,document)}]);