-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute-scoreboard.chunk.d42c9.js
1 lines (1 loc) · 13 KB
/
route-scoreboard.chunk.d42c9.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{"FrX+":function(e,t,n){"use strict";function r(e){return Object(o.h)(l.a,{...e,glyph:"clock",viewBox:"0 0 24 24"})}n.d(t,"a",(function(){return r}));var o=n("sL3o"),i=n("ziER"),a=n.n(i),c=n("5JeM"),s=n.n(c),l=n("VXtC");const u=new a.a({id:"clock",use:"clock-usage",viewBox:"0 0 24 24",content:'<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff" id="clock"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" /><path d="M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z" /></symbol>'});s.a.add(u)},JXlG:function(e,t,n){"use strict";(function(e){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var c=n("sL3o"),s=n("+mXV"),l=n("C+Gs"),u=n("obyI"),f=n("Xjb4"),d=function(e){var t=e.minX;return(e.time-t)/(e.maxX-t)*e.width},p=function(e){var t=parseInt(e.slice(-12),16)+1;return"rgba(186, "+89*t%128+", "+53*t%128+", 0.8)"},b=Object(f.b)((function(t){var n=t.points,r=t.onTooltipIn,o=t.onMouseMove,i=t.onMouseOut,s=t.name,l=t.currentScore,u=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}(t,["points","onTooltipIn","onMouseMove","onMouseOut","name","currentScore"]);return e(c.Fragment,null,e("polyline",a({},u,{points:n,"stroke-width":2,"stroke-linecap":"round",fill:"transparent","pointer-events":"none"})),e("polyline",{"stroke-width":12,points:n,"stroke-linecap":"round",fill:"transparent","pointer-events":"stroke",onMouseOver:r(s+" - "+l+" points"),onMouseMove:o,onMouseOut:i}))}));t.a=Object(l.a)({root:{marginBottom:"20px",background:"#222","& .frame__body":{padding:"20px"}},tooltip:{position:"fixed",pointerEvents:"none",background:"#fff",color:"#222",padding:"5px 10px",borderRadius:"5px",margin:"5px",top:"0",left:"0"}},(function(t){var n=t.graphData,r=t.classes,i=Object(s.i)(null),a=Object(s.j)(window.innerWidth),l=a[0],f=a[1],v=Object(s.a)((function(){null!==i.current&&f(i.current.getBoundingClientRect().width)}),[]),m=Object(s.j)({x:0,y:0,content:""}),g=m[0],h=m[1];Object(s.f)((function(){v()}),[v]),Object(s.d)((function(){function e(){v()}return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[v]);var O=Object(s.g)((function(){if(!n||0===n.length)return{polylines:[],labels:[]};var e=u.a.startTime,t=Math.min(Date.now(),u.a.endTime),r=0;n.graph.forEach((function(e){e.points.forEach((function(e){e.score>r&&(r=e.score)}))}));var o=function(e){var t=e.minX,n=e.maxX,r=e.width,o=[],i=864e5*Math.ceil((n-t)/r*200/864e5),a=new Date(t).setHours(0,0,0,0);a%i!=0&&(a+=i);for(var c=a;c<=n;c+=i)o.push({label:new Date(c).toLocaleDateString(),x:d({minX:t,maxX:n,time:c,width:r})});return o}({minX:e,maxX:t,width:l});return{polylines:n.graph.map((function(n){return function(e){var t=e.id,n=e.name,r=e.currentScore,o=e.maxX,i=e.minX,a=e.maxY,c=e.width,s=e.points.map((function(e){return d({minX:i,maxX:o,time:e.time,width:c})+" "+400*(1-e.score/a)}));return{color:p(t),name:n,currentScore:r,points:s.join(",")}}({points:n.points,id:n.id,name:n.name,currentScore:n.points[0].score,maxX:t,minX:e,maxY:r,width:l})})),labels:o}}),[n,l]),y=O.polylines,j=O.labels,w=Object(s.a)((function(e){return function(){h((function(t){return o(o({},t),{},{content:e})}))}}),[]),k=Object(s.a)((function(e){h((function(t){return o(o({},t),{},{x:e.clientX,y:e.clientY})}))}),[]),x=Object(s.a)((function(){h((function(e){return o(o({},e),{},{content:""})}))}),[]);return null===n?null:e("div",{class:"frame "+r.root},e("div",{class:"frame__body"},e("svg",{ref:i,viewBox:"-22 -2 "+(l+4+20)+" 444"},e(c.Fragment,null,y.map((function(t,n){return e(b,{key:n,stroke:t.color,points:t.points,name:t.name,currentScore:t.currentScore,onMouseMove:k,onMouseOut:x,onTooltipIn:w})}))),e(c.Fragment,null,j.map((function(t,n){return e("text",{x:t.x,y:440,key:n,fill:"#fff"},t.label)}))),e("line",{x1:-20,y1:420,x2:l,y2:420,stroke:"var(--cirrus-bg)","stroke-linecap":"round","stroke-width":2}),e("line",{x1:-20,y1:"0",x2:-20,y2:420,stroke:"var(--cirrus-bg)","stroke-linecap":"round","stroke-width":2}))),g.content&&e("div",{class:r.tooltip,style:{transform:"translate("+g.x+"px, "+g.y+"px)"}},g.content))}))}).call(this,n("sL3o").h)},VXtC:function(e,t,n){"use strict";(function(e){function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(t){var n=t.glyph,o=t.viewBox,i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}(t,["glyph","viewBox"]);return e("svg",r({},i,{viewBox:o,xmlns:"http://www.w3.org/2000/svg"}),e("use",{xlinkHref:"#"+n}))}n.d(t,"a",(function(){return o}))}).call(this,n("sL3o").h)},WX8x:function(e,t,n){"use strict";(function(e){function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(t){var n=t.onClick,o=t.disabled,a=t.selected,c=t.children,s=t.tabindex,l=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}(t,["onClick","disabled","selected","children","tabindex"]),u=l.class||"";delete l.class;var f=Object(i.a)((function(e){e.preventDefault(),n()}),[n]);return e("div",r({class:"pagination-item short "+u+(a?" selected":"")},l),e("a",{disabled:o,href:n&&"#",onClick:f,tabindex:s},c))}var i=n("+mXV"),a=n("sL3o"),c=n("C+Gs"),s=Object(c.a)({noHover:{backgroundColor:"transparent !important"},ellipses:{paddingLeft:"0.1em !important",paddingRight:"0.1em !important"}},(function(t){var n=t.classes,r=Object(i.a)((function(e){return e.target.blur()}),[]);return e("div",{class:"pagination-item short "+n.noHover},e("a",{class:"ellipses "+n.ellipses,tabindex:"-1",onFocus:r},"…"))}));t.a=function(t){var n=t.page,r=t.setPage,c=t.numVisiblePages;c=c||9;var l=Math.ceil(t.totalItems/t.pageSize),u=Object(i.g)((function(){var e,t;l<=c?(e=1,t=l):(e=n-Math.ceil((c-1)/2),t=n+Math.floor((c-1)/2),e<1?(e=1,t=c):t>l&&(t=l,e=l-c+1),e>1&&(e+=2),t<l&&(t-=2));for(var r=[],o=e;o<=t;o++)r.push(o);return{pages:r,startPage:e,endPage:t}}),[l,n,c]),f=u.pages,d=u.startPage,p=u.endPage,b=Object(i.g)((function(){for(var e=[],t=function(t){e.push((function(){return r(t)}))},n=1;n<=l;n++)t(n);return e}),[r,l]);return e("div",{class:"pagination u-center"},e(o,{disabled:1===n,key:"<",onClick:b[n-1-1]},"<"),d>1&&e(a.Fragment,null,e(o,{key:1,onClick:b[0]},"1"),e(s,{key:".<"})),f.map((function(t){return e(o,{selected:t===n,key:t,onClick:b[t-1]},t)})),p<l&&e(a.Fragment,null,e(s,{key:".>"}),e(o,{key:l,onClick:b[l-1]},l)),e(o,{disabled:n===l,key:">",onClick:b[n+1-1]},">"))}}).call(this,n("sL3o").h)},"YM+X":function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return o}));var r=function(e){return new Promise((function(t,n){var r,o;return r=e.division,o=e.offset,Promise.resolve(fetch("/json/leaderboard/"+(null!=r?r:"all")+"/now-"+(void 0===o?0:o)+".json")).then((function(e){try{return t(e.json())}catch(e){return n(e)}}),n)}))},o=function(e){return new Promise((function(t,n){var r;return r=e.division,Promise.resolve(fetch("/json/leaderboard/"+(null!=r?r:"all")+"/graph.json")).then((function(e){try{return t(e.json())}catch(e){return n(e)}}),n)}))}},obyI:function(e,t){"use strict";var n=JSON.parse(document.head.querySelector("meta[name=rctf-config]").content);t.a=n},pEbl:function(e,t,n){"use strict";(function(e){var r=n("C+Gs"),o=n("FrX+"),i=n("obyI"),a=Object(r.a)({card:{background:"#222",padding:"30px !important",flexDirection:"column"},icon:{width:"60px"}},(function(t){var n=t.classes;return e("div",{class:"row"},e("div",{class:"card u-center col-6 "+n.card},e("div",{class:n.icon},e(o.a,null)),e("h4",null,i.a.ctfName," has not started yet.")))}));t.a=a}).call(this,n("sL3o").h)},uRlC:function(e,t,n){"use strict";n.r(t),function(e){function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=n("+mXV"),s=n("obyI"),l=n("C+Gs"),u=n("WX8x"),f=n("JXlG"),d=n("pEbl"),p=n("YM+X"),b=0,v=1,m=2,g=Object(l.a)({frame:{paddingBottom:"1.5em",paddingTop:"2.125em",background:"#222","& .frame__subtitle":{color:"#fff"},"& button, & select, & option":{background:"#111",color:"#fff"}},tableFrame:{paddingTop:"1.5em"},selected:{backgroundColor:"rgba(216,216,216,.07)","&:hover":{backgroundColor:"rgba(216,216,216,.20) !important"}},table:{tableLayout:"fixed","& tbody td":{overflow:"hidden",whiteSpace:"nowrap"}}},(function(t){var n=t.classes,o=Object(c.g)((function(){var e=JSON.parse(localStorage.getItem("scoreboardPageState")||"{}"),t=new URLSearchParams(location.search),n={};if(t.has("page")){var r=parseInt(t.get("page"));isNaN(r)||(n.page=r)}return t.has("division")&&(n.division=t.get("division")),i(i({},e),n)}),[]),a=Object(c.j)([]),l=a[0],g=a[1],h=Object(c.j)(null),O=h[0],y=h[1],j=Object(c.j)(o.division||"all"),w=j[0],k=j[1],x=Object(c.j)(o.page||1),P=x[0],S=x[1],X=Object(c.j)(0),M=X[0],C=X[1],D=Object(c.j)(b),L=D[0],I=D[1],E=Object(c.j)(b),_=E[0],F=E[1],B=Object(c.a)((function(e){k(e),S(1)}),[k,S]);Object(c.d)((function(){localStorage.setItem("scoreboardPageState",JSON.stringify({pageSize:100,division:w}))}),[100,w]),Object(c.d)((function(){1===P&&""===location.search||history.replaceState({},"","?page="+P+"&division="+encodeURIComponent(w))}),[100,w,P]);var z=Object(c.a)((function(e){return B(e.target.value)}),[B]);return Object(c.d)((function(){document.title="Scoreboard | "+s.a.ctfName}),[]),Object(c.d)((function(){new Promise((function(e,t){var n,r,o,a;return n="all"===w?void 0:w,Promise.resolve(Object(p.b)({division:n,offset:100*(P-1),limit:100})).then((function(n){try{return a=(r=n).data,I("badNotStarted"===(o=r.kind)?v:m),"goodLeaderboard"!==o||(g(a.leaderboard.map((function(e,t){return i(i({},e),{},{rank:t+1+100*(P-1)})}))),C(a.total)),e()}catch(e){return t(e)}}),t)}))}),[w,P,100]),Object(c.d)((function(){new Promise((function(e,t){var n,r,o,i;return n="all"===w?void 0:w,Promise.resolve(Object(p.a)({division:n})).then((function(n){try{return i=(r=n).data,F("badNotStarted"===(o=r.kind)?v:m),"goodLeaderboard"!==o||y(i),e()}catch(e){return t(e)}}),t)}))}),[w]),L===b||_===b?null:L===v||_===v?e(d.a,null):e("div",{class:"row u-center",style:"align-items: initial !important"},e("div",{class:"col-12 u-center"},e("div",{class:"col-8"},e(f.a,{graphData:O}))),e("div",{class:"col-3"},e("div",{class:"frame "+n.frame},e("div",{class:"frame__body"},e("div",{class:"frame__subtitle"},"Filter by division"),e("div",{class:"input-control"},e("select",{required:!0,class:"select",name:"division",value:w,onChange:z},e("option",{value:"all",selected:!0},"All"),Object.entries(s.a.divisions).map((function(t){var n=t[0];return e("option",{key:n,value:n},t[1])}))))))),e("div",{class:"col-6"},e("div",{class:"frame "+n.frame+" "+n.tableFrame},e("div",{class:"frame__body"},e("table",{class:"table small "+n.table},e("thead",null,e("tr",null,e("th",{style:"width: 3.5em"},"#"),e("th",null,"Team"),e("th",{style:"width: 5em"},"Points"))),e("tbody",null,l.map((function(t){var n=t.id,r=t.name,o=t.score;return e("tr",{key:n},e("td",null,t.rank),e("td",null,e("a",{href:"/profile/"+n},r)),e("td",null,o))}))))),M>100&&e(u.a,r({totalItems:M,pageSize:100,page:P,setPage:S},{numVisiblePages:9})))))}));t.default=g}.call(this,n("sL3o").h)}}]);