2 lines
12 KiB
JavaScript
2 lines
12 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 J=!1;const k=new Set;function j(){if(!J){J=!0;do{for(let t=0;t<y.length;t+=1){const e=y[t];g(e),C(e.$$)}for(y.length=0;b.length;)b.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];k.has(e)||(k.add(e),e())}v.length=0}while(y.length);for(;$.length;)$.pop()();w=!1,J=!1,k.clear()}}function C(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 L=new Set;function S(t,e){t&&t.i&&(L.delete(t),t.i(e))}function T(t,e,n,r){if(t&&t.o){if(L.has(t))return;L.add(t),(void 0).c.push(()=>{L.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function M(t){t&&t.c()}function N(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 E(t,e){-1===t.$$.dirty[0]&&(y.push(t),w||(w=!0,x.then(j)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function A(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&&E(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&&S(e.$$.fragment),N(e,o.target,o.anchor),j()}g(f)}class D{$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 q(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 D{constructor(t){super(),A(this,t,null,q,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 I={jobs:`${location.protocol}//${location.hostname}:3000`.concat("/jobs")},F=R([]),B=R({}),U={getJobList(){z.get(I.jobs).then(t=>{const e=JSON.parse(t.data);F.set(e)}).catch(t=>{console.error("getJobList",t)})},loadJobDetail(t){if(console.log("loadJobDetail: "+t),t){const e=`${I.jobs}/${t}`;z.get(e).then(t=>{const e=JSON.parse(t.data);B.set(e)}).catch(t=>{console.error("loadJobDetail",t)})}},async touchJob(t){if(console.log("touchJob: "+t),t){const e=`${I.jobs}/${t}`;await z.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("touchJob",t)});const n=parseInt(t,10);F.update(t=>(t.map(t=>{if(t._id===n)return t.d=(new Date).getTime(),t}),t))}}};function G(t,e,n){const r=t.slice();return r[4]=e[n],r[6]=n,r}function K(t){let e,n,r,o,s,a,p,g,y,b,v,$,x,w,_,J,k=t[4].title+"",j=t[4].site+"",C=V(t[4].company)+"",L=t[4].date+"";return{c(){e=l("tr"),n=l("td"),r=f(k),o=d(),s=l("td"),a=f(j),p=d(),g=l("td"),y=f(C),b=d(),v=l("td"),$=f(L),x=d(),h(e,"class",w="dataRow "+(t[4].d?"read":"")+" svelte-1mc68rt"),h(e,"data-id",_=t[4]._id)},m(u,l,f){var d;i(u,e,l),c(e,n),c(n,r),c(e,o),c(e,s),c(s,a),c(e,p),c(e,g),c(g,y),c(e,b),c(e,v),c(v,$),c(e,x),f&&J(),J=function(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}(e,"click",(d=t[1],function(t){return t.stopPropagation(),d.call(this,t)}))},p(t,n){1&n&&k!==(k=t[4].title+"")&&m(r,k),1&n&&j!==(j=t[4].site+"")&&m(a,j),1&n&&C!==(C=V(t[4].company)+"")&&m(y,C),1&n&&L!==(L=t[4].date+"")&&m($,L),1&n&&w!==(w="dataRow "+(t[4].d?"read":"")+" svelte-1mc68rt")&&h(e,"class",w),1&n&&_!==(_=t[4]._id)&&h(e,"data-id",_)},d(t){t&&u(e),J()}}}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-1mc68rt")},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;return a(t,F,t=>n(0,r=t)),[r,function(t){const e=t.target.parentElement.dataset.id;U.loadJobDetail(e),U.touchJob(e)}]}class X extends D{constructor(t){super(),A(this,t,W,Q,s,{})}}function Y(t){let e,n,r,o,s,a,p,g,y,b,v,$,x,w,_,J,k,j,C,L,S,T,M,N,O,E,A,D,q,H,P,R,z,I,F,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"),J=f(G),k=d(),j=l("div"),C=l("div"),L=f("Salary: "),S=l("span"),T=f(K),M=d(),N=l("div"),O=f("Scraped: "),E=l("span"),A=f(Q),D=d(),q=l("div"),H=f("Site: "),P=l("a"),R=f(V),I=d(),F=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(S,"class","text-primary"),h(C,"class","col-1-3rd"),h(E,"class","text-primary"),h(N,"class","col-1-3rd"),h(P,"href",z=t[1].url),h(P,"class","text-capitalize"),h(P,"target","_blank"),h(q,"class","col-1-3rd"),h(j,"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(_,J),c(n,k),c(n,j),c(j,C),c(C,L),c(C,S),c(S,T),c(j,M),c(j,N),c(N,O),c(N,E),c(E,A),c(j,D),c(j,q),c(q,H),c(q,P),c(P,R),c(e,I),c(e,F),F.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(J,G),2&e&&K!==(K=t[1].salary+"")&&m(T,K),2&e&&Q!==(Q=t[1].date+"")&&m(A,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+"")&&(F.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 D{constructor(t){super(),A(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"),M(p.$$.fragment),s=d(),a=l("div"),M(g.$$.fragment),f=d(),M(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),N(p,o,null),c(r,s),c(r,a),N(g,a,null),c(a,f),N(y,a,null),m=!0},p:t,i(t){m||(S(p.$$.fragment,t),S(g.$$.fragment,t),S(y.$$.fragment,t),m=!0)},o(t){T(p.$$.fragment,t),T(g.$$.fragment,t),T(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 D{constructor(t){super(),A(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}();
|