2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
var app=function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function r(t){t.forEach(e)}function o(t){return"function"==typeof t}function s(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function a(e,n,r){e.$$.on_destroy.push(function(e,...n){if(null==e)return t;const r=e.subscribe(...n);return r.unsubscribe?()=>r.unsubscribe():r}(n,r))}function c(t,e){t.appendChild(e)}function i(t,e,n){t.insertBefore(e,n||null)}function u(t){t.parentNode.removeChild(t)}function l(t){return document.createElement(t)}function f(t){return document.createTextNode(t)}function d(){return f(" ")}function h(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function m(t,e){e=""+e,t.data!==e&&(t.data=e)}let p;function g(t){p=t}const y=[],b=[],v=[],$=[],x=Promise.resolve();let w=!1;function _(t){v.push(t)}let k=!1;const j=new Set;function C(){if(!k){k=!0;do{for(let t=0;t<y.length;t+=1){const e=y[t];g(e),L(e.$$)}for(y.length=0;b.length;)b.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];j.has(e)||(j.add(e),e())}v.length=0}while(y.length);for(;$.length;)$.pop()();w=!1,k=!1,j.clear()}}function L(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(_)}}const S=new Set;function J(t,e){t&&t.i&&(S.delete(t),t.i(e))}function M(t,e,n,r){if(t&&t.o){if(S.has(t))return;S.add(t),(void 0).c.push(()=>{S.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function N(t){t&&t.c()}function T(t,n,s){const{fragment:a,on_mount:c,on_destroy:i,after_update:u}=t.$$;a&&a.m(n,s),_(()=>{const n=c.map(e).filter(o);i?i.push(...n):r(n),t.$$.on_mount=[]}),u.forEach(_)}function O(t,e){const n=t.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function A(t,e){-1===t.$$.dirty[0]&&(y.push(t),w||(w=!0,x.then(C)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function E(e,o,s,a,c,i,l=[-1]){const f=p;g(e);const d=o.props||{},h=e.$$={fragment:null,ctx:null,props:i,update:t,not_equal:c,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(f?f.$$.context:[]),callbacks:n(),dirty:l};let m=!1;if(h.ctx=s?s(e,d,(t,n,...r)=>{const o=r.length?r[0]:n;return h.ctx&&c(h.ctx[t],h.ctx[t]=o)&&(h.bound[t]&&h.bound[t](o),m&&A(e,t)),n}):[],h.update(),m=!0,r(h.before_update),h.fragment=!!a&&a(h.ctx),o.target){if(o.hydrate){const t=function(t){return Array.from(t.childNodes)}(o.target);h.fragment&&h.fragment.l(t),t.forEach(u)}else h.fragment&&h.fragment.c();o.intro&&J(e.$$.fragment),T(e,o.target,o.anchor),C()}g(f)}class q{$destroy(){O(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}}function D(e){let n;return{c(){n=l("menu"),n.innerHTML="<h2>Jobs</h2> \n <hr> \n\n <button>Indeed</button>",h(n,"class","svelte-ssrzvc")},m(t,e){i(t,n,e)},p:t,i:t,o:t,d(t){t&&u(n)}}}class H extends q{constructor(t){super(),E(this,t,null,D,s,{})}}const P=[];function R(e,n=t){let r;const o=[];function a(t){if(s(e,t)&&(e=t,r)){const t=!P.length;for(let t=0;t<o.length;t+=1){const n=o[t];n[1](),P.push(n,e)}if(t){for(let t=0;t<P.length;t+=2)P[t][0](P[t+1]);P.length=0}}}return{set:a,update:function(t){a(t(e))},subscribe:function(s,c=t){const i=[s,c];return o.push(i),1===o.length&&(r=n(a)||t),s(e),()=>{const t=o.indexOf(i);-1!==t&&o.splice(t,1),0===o.length&&(r(),r=null)}}}}var z=function t(e){function n(t){return function(e,n){return s(e,Object.assign({method:t},n))}}function r(t){return function(e,n,r){return s(e,Object.assign({method:t,data:n},r))}}function o(t,e,n){if(Array.isArray(t))return t.concat(e);if(e&&"object"==typeof e){var r,s={};if(t)for(r in t)s[n?r.toLowerCase():r]=t[r];for(r in e){var a=n?r.toLowerCase():r;"headers"===a&&(n=!0),s[a]=r in s?o(s[a],e[r],n):e[r]}return s}return e}function s(t,n){"string"!=typeof t&&(t=(n=t).url);var r=o(e,n||{}),s=r.data;if(r.transformRequest)for(var a=0;a<r.transformRequest.length;a++){var c=r.transformRequest[a](s,r.headers);void 0!==c&&(s=c)}var i={};if(s&&"object"==typeof s&&(s=JSON.stringify(s),i["Content-Type"]="application/json"),r.xsrfCookieName)for(var u=document.cookie.split(/ *[;=] */),l=0;l<u.length;l+=2)if(u[l]==r.xsrfCookieName){i[r.xsrfHeaderName]=decodeURIComponent(u[l+1]);break}r.auth&&(i.Authorization=r.auth);var f={};return f.config=n,fetch(t,{method:r.method,body:s,headers:o(r.headers,i,!0)}).then((function(t){var e;for(e in t)"function"!=typeof t[e]&&(f[e]=t[e]);return(r.validateStatus?r.validateStatus(t.status):t.ok)?("stream"===r.responseType?Promise.resolve(t.body):t[r.responseType||"text"]()).then((function(t){return f.data=t,f})):Promise.reject(t)}))}return e=e||{},s.request=s,s.get=n("get"),s.delete=n("delete"),s.options=n("options"),s.post=r("post"),s.put=r("put"),s.patch=r("patch"),s.all=Promise.all,s.spread=function(t){return function(e){return t.apply(this,e)}},s.CancelToken=self.AbortController||Object,s.create=t,s}();const F={jobs:`${location.protocol}//${location.hostname}:3000`.concat("/jobs")},I=R([]),B=R({}),U={getJobList(){z.get(F.jobs).then(t=>{const e=JSON.parse(t.data);I.set(e)}).catch(t=>{console.error("getJobList",t)})},loadJobDetail(t){if(console.log("loadJobDetail: "+t),t){const e=`${F.jobs}/${t}`;z.get(e).then(t=>{const e=JSON.parse(t.data);B.set(e)}).catch(t=>{console.error("loadJobDetail",t)})}}};function G(t,e,n){const r=t.slice();return r[2]=e[n],r[4]=n,r}function K(t){let e,n,r,s,a,p,g,y,b,v,$,x,w,_,k=t[2].title+"",j=t[2].site+"",C=V(t[2].company)+"",L=t[2].date+"";return{c(){e=l("tr"),n=l("td"),r=f(k),s=d(),a=l("td"),p=f(j),g=d(),y=l("td"),b=f(C),v=d(),$=l("td"),x=f(L),w=d(),h(e,"class","dataRow")},m(u,l,f){var d,h,m,k;i(u,e,l),c(e,n),c(n,r),c(e,s),c(e,a),c(a,p),c(e,g),c(e,y),c(y,b),c(e,v),c(e,$),c($,x),c(e,w),f&&_(),h="click",m=function(){o(t[1](t[2]._id))&&t[1](t[2]._id).apply(this,arguments)},(d=e).addEventListener(h,m,k),_=()=>d.removeEventListener(h,m,k)},p(e,n){t=e,1&n&&k!==(k=t[2].title+"")&&m(r,k),1&n&&j!==(j=t[2].site+"")&&m(p,j),1&n&&C!==(C=V(t[2].company)+"")&&m(b,C),1&n&&L!==(L=t[2].date+"")&&m(x,L)},d(t){t&&u(e),_()}}}function Q(e){let n,r,o,s,a,f=e[0],m=[];for(let t=0;t<f.length;t+=1)m[t]=K(G(e,f,t));return{c(){n=l("div"),r=l("table"),o=l("thead"),o.innerHTML='<tr><th class="col-5">\n Title\n </th> \n <th class="col-2">\n Site\n </th> \n <th class="col-3">\n Company\n </th> \n <th class="col-2">\n Date\n </th></tr>',s=d(),a=l("tbody");for(let t=0;t<m.length;t+=1)m[t].c();h(r,"class",""),h(n,"class","lister svelte-1ndsoar")},m(t,e){i(t,n,e),c(n,r),c(r,o),c(r,s),c(r,a);for(let t=0;t<m.length;t+=1)m[t].m(a,null)},p(t,[e]){if(3&e){let n;for(f=t[0],n=0;n<f.length;n+=1){const r=G(t,f,n);m[n]?m[n].p(r,e):(m[n]=K(r),m[n].c(),m[n].m(a,null))}for(;n<m.length;n+=1)m[n].d(1);m.length=f.length}},i:t,o:t,d(t){t&&u(n),function(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}(m,t)}}}function V(t){return t.length<=40?t:t.slice(0,40)+"…"}function W(t,e,n){let r;a(t,I,t=>n(0,r=t));return[r,t=>{U.loadJobDetail(t)}]}class X extends q{constructor(t){super(),E(this,t,W,Q,s,{})}}function Y(t){let e,n,r,o,s,a,p,g,y,b,v,$,x,w,_,k,j,C,L,S,J,M,N,T,O,A,E,q,D,H,P,R,z,F,I,B=t[1].title+"",U=t[1].company+"",G=t[1].location+"",K=t[1].salary+"",Q=t[1].date+"",V=t[1].site+"",W=t[1].summary+"";return{c(){e=l("div"),n=l("div"),r=l("div"),o=l("div"),s=f(B),a=d(),p=l("div"),g=l("div"),y=f("Company: "),b=l("span"),v=f(U),$=d(),x=l("div"),w=f("Location: "),_=l("span"),k=f(G),j=d(),C=l("div"),L=l("div"),S=f("Salary: "),J=l("span"),M=f(K),N=d(),T=l("div"),O=f("Scraped: "),A=l("span"),E=f(Q),q=d(),D=l("div"),H=f("Site: "),P=l("a"),R=f(V),F=d(),I=l("blockquote"),h(o,"class","col-12 text-primary lead"),h(r,"class","row svelte-1rxym9d"),h(b,"class","text-primary"),h(g,"class","col-6"),h(_,"class","text-primary"),h(x,"class","col-6"),h(p,"class","row svelte-1rxym9d"),h(J,"class","text-primary"),h(L,"class","col-1-3rd"),h(A,"class","text-primary"),h(T,"class","col-1-3rd"),h(P,"href",z=t[1].url),h(P,"class","text-capitalize"),h(P,"target","_blank"),h(D,"class","col-1-3rd"),h(C,"class","row svelte-1rxym9d"),h(n,"class","detailHead bg-light svelte-1rxym9d"),h(e,"class","detail svelte-1rxym9d")},m(t,u){i(t,e,u),c(e,n),c(n,r),c(r,o),c(o,s),c(n,a),c(n,p),c(p,g),c(g,y),c(g,b),c(b,v),c(p,$),c(p,x),c(x,w),c(x,_),c(_,k),c(n,j),c(n,C),c(C,L),c(L,S),c(L,J),c(J,M),c(C,N),c(C,T),c(T,O),c(T,A),c(A,E),c(C,q),c(C,D),c(D,H),c(D,P),c(P,R),c(e,F),c(e,I),I.innerHTML=W},p(t,e){2&e&&B!==(B=t[1].title+"")&&m(s,B),2&e&&U!==(U=t[1].company+"")&&m(v,U),2&e&&G!==(G=t[1].location+"")&&m(k,G),2&e&&K!==(K=t[1].salary+"")&&m(M,K),2&e&&Q!==(Q=t[1].date+"")&&m(E,Q),2&e&&V!==(V=t[1].site+"")&&m(R,V),2&e&&z!==(z=t[1].url)&&h(P,"href",z),2&e&&W!==(W=t[1].summary+"")&&(I.innerHTML=W)},d(t){t&&u(e)}}}function Z(e){let n,r=e[0]&&Y(e);return{c(){r&&r.c(),n=f("")},m(t,e){r&&r.m(t,e),i(t,n,e)},p(t,[e]){t[0]?r?r.p(t,e):(r=Y(t),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:t,o:t,d(t){r&&r.d(t),t&&u(n)}}}function tt(t,e,n){let r;a(t,B,t=>n(1,r=t));let o=!1;return B.subscribe(t=>{n(0,o=!function(t){for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}(t))}),[o,r]}class et extends q{constructor(t){super(),E(this,t,tt,Z,s,{})}}function nt(e){let n,r,o,s,a,f,m;const p=new H({}),g=new X({}),y=new et({});return{c(){n=l("main"),r=l("div"),o=l("div"),N(p.$$.fragment),s=d(),a=l("div"),N(g.$$.fragment),f=d(),N(y.$$.fragment),h(o,"class","col-2"),h(a,"class","col-10"),h(r,"class","grid view")},m(t,e){i(t,n,e),c(n,r),c(r,o),T(p,o,null),c(r,s),c(r,a),T(g,a,null),c(a,f),T(y,a,null),m=!0},p:t,i(t){m||(J(p.$$.fragment,t),J(g.$$.fragment,t),J(y.$$.fragment,t),m=!0)},o(t){M(p.$$.fragment,t),M(g.$$.fragment,t),M(y.$$.fragment,t),m=!1},d(t){t&&u(n),O(p),O(g),O(y)}}}var rt=1e3,ot=6e4,st=60*ot,at=24*st,ct=function(t,e){e=e||{};var n=typeof t;if("string"===n&&t.length>0)return function(t){if((t=String(t)).length>100)return;var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return;var n=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*at;case"hours":case"hour":case"hrs":case"hr":case"h":return n*st;case"minutes":case"minute":case"mins":case"min":case"m":return n*ot;case"seconds":case"second":case"secs":case"sec":case"s":return n*rt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(t);if("number"===n&&isFinite(t))return e.long?function(t){var e=Math.abs(t);if(e>=at)return it(t,e,at,"day");if(e>=st)return it(t,e,st,"hour");if(e>=ot)return it(t,e,ot,"minute");if(e>=rt)return it(t,e,rt,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=at)return Math.round(t/at)+"d";if(e>=st)return Math.round(t/st)+"h";if(e>=ot)return Math.round(t/ot)+"m";if(e>=rt)return Math.round(t/rt)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function it(t,e,n,r){var o=e>=1.5*n;return Math.round(t/n)+" "+r+(o?"s":"")}let ut=0;const lt=new class extends q{constructor(t){super(),E(this,t,null,nt,s,{})}}({target:document.body});return function t(){U.getJobList();const e=function(t=0){return 36e5-(new Date).getTime()%36e5+t}()+ct("10m");console.log("Next:",e),ut=setTimeout(()=>{t()},e)}(),lt}();
|