jobscraper/server/dist/build/bundle.js
2020-09-10 19:42:17 +01:00

2 lines
16 KiB
JavaScript

var app=function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function r(t){return"function"==typeof t}function a(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function s(e,n,o){e.$$.on_destroy.push(function(e,...n){if(null==e)return t;const o=e.subscribe(...n);return o.unsubscribe?()=>o.unsubscribe():o}(n,o))}function c(t,e){t.appendChild(e)}function l(t,e,n){t.insertBefore(e,n||null)}function i(t){t.parentNode.removeChild(t)}function u(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function d(t){return document.createElement(t)}function f(t){return document.createTextNode(t)}function p(){return f(" ")}function h(){return f("")}function m(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function g(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function b(t,e){e=""+e,t.data!==e&&(t.data=e)}let v;function y(t){v=t}const $=[],w=[],k=[],x=[],J=Promise.resolve();let _=!1;function j(t){k.push(t)}let C=!1;const A=new Set;function L(){if(!C){C=!0;do{for(let t=0;t<$.length;t+=1){const e=$[t];y(e),T(e.$$)}for($.length=0;w.length;)w.pop()();for(let t=0;t<k.length;t+=1){const e=k[t];A.has(e)||(A.add(e),e())}k.length=0}while($.length);for(;x.length;)x.pop()();_=!1,C=!1,A.clear()}}function T(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}const M=new Set;function O(t,e){t&&t.i&&(M.delete(t),t.i(e))}function S(t,e,n,o){if(t&&t.o){if(M.has(t))return;M.add(t),(void 0).c.push(()=>{M.delete(t),o&&(n&&t.d(1),o())}),t.o(e)}}function N(t){t&&t.c()}function R(t,n,a){const{fragment:s,on_mount:c,on_destroy:l,after_update:i}=t.$$;s&&s.m(n,a),j(()=>{const n=c.map(e).filter(r);l?l.push(...n):o(n),t.$$.on_mount=[]}),i.forEach(j)}function D(t,e){const n=t.$$;null!==n.fragment&&(o(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]&&($.push(t),_||(_=!0,J.then(L)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function H(e,r,a,s,c,l,u=[-1]){const d=v;y(e);const f=r.props||{},p=e.$$={fragment:null,ctx:null,props:l,update:t,not_equal:c,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:[]),callbacks:n(),dirty:u};let h=!1;if(p.ctx=a?a(e,f,(t,n,...o)=>{const r=o.length?o[0]:n;return p.ctx&&c(p.ctx[t],p.ctx[t]=r)&&(p.bound[t]&&p.bound[t](r),h&&E(e,t)),n}):[],p.update(),h=!0,o(p.before_update),p.fragment=!!s&&s(p.ctx),r.target){if(r.hydrate){const t=function(t){return Array.from(t.childNodes)}(r.target);p.fragment&&p.fragment.l(t),t.forEach(i)}else p.fragment&&p.fragment.c();r.intro&&O(e.$$.fragment),R(e,r.target,r.anchor),L()}y(d)}class P{$destroy(){D(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(){}}const q=[];function z(e,n=t){let o;const r=[];function s(t){if(a(e,t)&&(e=t,o)){const t=!q.length;for(let t=0;t<r.length;t+=1){const n=r[t];n[1](),q.push(n,e)}if(t){for(let t=0;t<q.length;t+=2)q[t][0](q[t+1]);q.length=0}}}return{set:s,update:function(t){s(t(e))},subscribe:function(a,c=t){const l=[a,c];return r.push(l),1===r.length&&(o=n(s)||t),a(e),()=>{const t=r.indexOf(l);-1!==t&&r.splice(t,1),0===r.length&&(o(),o=null)}}}}var F=function t(e){function n(t){return function(e,n){return a(e,Object.assign({method:t},n))}}function o(t){return function(e,n,o){return a(e,Object.assign({method:t,data:n},o))}}function r(t,e,n){if(Array.isArray(t))return t.concat(e);if(e&&"object"==typeof e){var o,a={};if(t)for(o in t)a[n?o.toLowerCase():o]=t[o];for(o in e){var s=n?o.toLowerCase():o;"headers"===s&&(n=!0),a[s]=o in a?r(a[s],e[o],n):e[o]}return a}return e}function a(t,n){"string"!=typeof t&&(t=(n=t).url);var o=r(e,n||{}),a=o.data;if(o.transformRequest)for(var s=0;s<o.transformRequest.length;s++){var c=o.transformRequest[s](a,o.headers);void 0!==c&&(a=c)}var l={};if(a&&"object"==typeof a&&(a=JSON.stringify(a),l["Content-Type"]="application/json"),o.xsrfCookieName)for(var i=document.cookie.split(/ *[;=] */),u=0;u<i.length;u+=2)if(i[u]==o.xsrfCookieName){l[o.xsrfHeaderName]=decodeURIComponent(i[u+1]);break}o.auth&&(l.Authorization=o.auth);var d={};return d.config=n,fetch(t,{method:o.method,body:a,headers:r(o.headers,l,!0)}).then((function(t){var e;for(e in t)"function"!=typeof t[e]&&(d[e]=t[e]);return(o.validateStatus?o.validateStatus(t.status):t.ok)?("stream"===o.responseType?Promise.resolve(t.body):t[o.responseType||"text"]()).then((function(t){return d.data=t,d})):Promise.reject(t)}))}return e=e||{},a.request=a,a.get=n("get"),a.delete=n("delete"),a.options=n("options"),a.post=o("post"),a.put=o("put"),a.patch=o("patch"),a.all=Promise.all,a.spread=function(t){return function(e){return t.apply(this,e)}},a.CancelToken=self.AbortController||Object,a.create=t,a}();const V=`${location.protocol}//${location.hostname}`,W={jobs:V.concat("/v2/jobs"),apply:V.concat("/v2/apply"),readall:V.concat("/v2/readall"),kill:V.concat("/kill"),upvote:V.concat("/vote/up"),downvote:V.concat("/vote/down")},B=z([]),I=z({}),U={getJobList(){F.get(W.jobs).then(t=>{const e=JSON.parse(t.data);B.set(e)}).catch(t=>{console.error("getJobList",t)})},loadJobDetail(t){if(console.log("loadJobDetail: "+t),t){const e=`${W.jobs}/${t}`;F.get(e).then(t=>{const e=JSON.parse(t.data);I.set(e)}).catch(t=>{console.error("loadJobDetail",t)})}},async touchJob(t){if(console.log("touchJob: "+t),t){const e=`${W.jobs}/${t}`;await F.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("touchJob",t)}),B.update(e=>(e.map(e=>{if(e._id===t)return e.read=(new Date).getTime(),e}),e))}},async appliedJob(t){console.log("touchJob: "+t);const e=(new Date).getTime();if(t){console.log("Applying..");const n=`${W.apply}/${t}`;await F.put(n).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("appliedJob",t)});const o=t;B.update(t=>(t.map(t=>{if(t._id===o)return t.applied=e,t}),t)),I.update(t=>(t.data.applied=e,t))}},async markAllRead(){console.log(">> markAllRead");const t=""+W.readall;await F.put(t).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("markAllRead",t)}),this.getJobList()},killWord(t){console.log(">> killword:"+t);const e=`${W.kill}/${t}`;F.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("killword",t)})},upVote(t){console.log(">> upvote:"+t);const e=`${W.upvote}/${t}`;F.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("upvote",t)})},downVote(t){console.log(">> downvote:"+t);const e=`${W.downvote}/${t}`;F.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("downvote",t)})}};function G(t,e,n){const o=t.slice();return o[4]=e[n],o[6]=n,o}function K(t){let e,n,o,r,a,s,u,h,v,y,$,w,k,x,J,_,j=t[4].title+"",C=t[4].site+"",A=X(t[4].company)+"",L=tt(t[4].timestamp)+"";return{c(){e=d("tr"),n=d("td"),o=f(j),r=p(),a=d("td"),s=f(C),u=p(),h=d("td"),v=f(A),y=p(),$=d("td"),w=f(L),k=p(),g(n,"class","noOverflow svelte-hvjw8w"),g(e,"class",x="dataRow "+Y(t[4])+" "+Z(t[4])+" svelte-hvjw8w"),g(e,"data-id",J=t[4]._id)},m(i,d,f){var p;l(i,e,d),c(e,n),c(n,o),c(e,r),c(e,a),c(a,s),c(e,u),c(e,h),c(h,v),c(e,y),c(e,$),c($,w),c(e,k),f&&_(),_=m(e,"click",(p=t[1],function(t){return t.stopPropagation(),p.call(this,t)}))},p(t,n){1&n&&j!==(j=t[4].title+"")&&b(o,j),1&n&&C!==(C=t[4].site+"")&&b(s,C),1&n&&A!==(A=X(t[4].company)+"")&&b(v,A),1&n&&L!==(L=tt(t[4].timestamp)+"")&&b(w,L),1&n&&x!==(x="dataRow "+Y(t[4])+" "+Z(t[4])+" svelte-hvjw8w")&&g(e,"class",x),1&n&&J!==(J=t[4]._id)&&g(e,"data-id",J)},d(t){t&&i(e),_()}}}function Q(e){let n,o,r,a,s,f=e[0],h=[];for(let t=0;t<f.length;t+=1)h[t]=K(G(e,f,t));return{c(){n=d("div"),o=d("table"),r=d("thead"),r.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>',a=p(),s=d("tbody");for(let t=0;t<h.length;t+=1)h[t].c();g(o,"class",""),g(n,"class","lister svelte-hvjw8w")},m(t,e){l(t,n,e),c(n,o),c(o,r),c(o,a),c(o,s);for(let t=0;t<h.length;t+=1)h[t].m(s,null)},p(t,[e]){if(3&e){let n;for(f=t[0],n=0;n<f.length;n+=1){const o=G(t,f,n);h[n]?h[n].p(o,e):(h[n]=K(o),h[n].c(),h[n].m(s,null))}for(;n<h.length;n+=1)h[n].d(1);h.length=f.length}},i:t,o:t,d(t){t&&i(n),u(h,t)}}}function X(t){return t.length<=40?t:t.slice(0,40)+"…"}function Y(t){return 0!==t.read?"read":""}function Z(t){return 0!==t.applied?"applied":""}function tt(t){return new Date(t).toLocaleString()}function et(t,e,n){let o;return s(t,B,t=>n(0,o=t)),[o,function(t){const e=t.target.parentElement.dataset.id;U.loadJobDetail(e),U.touchJob(e)}]}class nt extends P{constructor(t){super(),H(this,t,et,Q,a,{})}}function ot(t,e,n){const o=t.slice();return o[8]=e[n],o[10]=n,o}function rt(t){let e,n,o,r,a,s,h,m,v,y,$,w,k,x,J,_,j,C,A,L,T,M,O,S,N,R,D,E,H,P,q,z,F,V,W,B,I,U,G,K,Q,X,Y=t[3].title+"",Z=t[3].company+"",tt=t[3].location+"",et=t[3].salary+"",nt=t[3].date+"",rt=t[3].site+"",it=t[3].summary+"";function ut(t,e){return 1===t[2]?st:2===t[2]?at:void 0}let dt=ut(t),pt=dt&&dt(t);function ht(t,e){return t[1]?ct:lt}let mt=ht(t),gt=mt(t),bt=t[3].data.autoclass.words,vt=[];for(let e=0;e<bt.length;e+=1)vt[e]=ft(ot(t,bt,e));return{c(){e=d("div"),n=d("div"),o=d("div"),r=d("div"),a=f(Y),s=p(),pt&&pt.c(),h=p(),m=d("div"),v=d("div"),y=f("Company: "),$=d("span"),w=f(Z),k=p(),x=d("div"),J=f("Location: "),_=d("span"),j=f(tt),C=p(),A=d("div"),L=f("Applied:\n "),gt.c(),T=p(),M=d("div"),O=d("div"),S=f("Salary: "),N=d("span"),R=p(),D=d("div"),E=f("Scraped: "),H=d("span"),P=f(nt),q=p(),z=d("div"),F=f("Site: "),V=d("a"),W=f(rt),I=p(),U=d("div"),G=d("div");for(let t=0;t<vt.length;t+=1)vt[t].c();Q=p(),X=d("blockquote"),g(r,"class","col-12 text-primary lead"),g(o,"class","row svelte-ewk0kd"),g($,"class","text-primary"),g(v,"class","col-1-3rd"),g(_,"class","text-primary"),g(x,"class","col-1-3rd"),g(A,"class","col-1-3rd"),g(m,"class","row svelte-ewk0kd"),g(N,"class","text-primary"),g(O,"class","col-1-3rd"),g(H,"class","text-primary"),g(D,"class","col-1-3rd"),g(V,"href",B=t[3].url),g(V,"class","text-capitalize"),g(V,"target","_blank"),g(z,"class","col-1-3rd"),g(M,"class","row svelte-ewk0kd"),g(G,"class","col-12"),g(U,"class","row svelte-ewk0kd"),g(n,"class",K="detailHead bg-light "+(t[1]?"applied":"")+" svelte-ewk0kd"),g(X,"class","container noscroll"),g(e,"class","detail svelte-ewk0kd")},m(t,i){l(t,e,i),c(e,n),c(n,o),c(o,r),c(r,a),c(o,s),pt&&pt.m(o,null),c(n,h),c(n,m),c(m,v),c(v,y),c(v,$),c($,w),c(m,k),c(m,x),c(x,J),c(x,_),c(_,j),c(m,C),c(m,A),c(A,L),gt.m(A,null),c(n,T),c(n,M),c(M,O),c(O,S),c(O,N),N.innerHTML=et,c(M,R),c(M,D),c(D,E),c(D,H),c(H,P),c(M,q),c(M,z),c(z,F),c(z,V),c(V,W),c(n,I),c(n,U),c(U,G);for(let t=0;t<vt.length;t+=1)vt[t].m(G,null);c(e,Q),c(e,X),X.innerHTML=it},p(t,e){if(8&e&&Y!==(Y=t[3].title+"")&&b(a,Y),dt!==(dt=ut(t))&&(pt&&pt.d(1),pt=dt&&dt(t),pt&&(pt.c(),pt.m(o,null))),8&e&&Z!==(Z=t[3].company+"")&&b(w,Z),8&e&&tt!==(tt=t[3].location+"")&&b(j,tt),mt===(mt=ht(t))&&gt?gt.p(t,e):(gt.d(1),gt=mt(t),gt&&(gt.c(),gt.m(A,null))),8&e&&et!==(et=t[3].salary+"")&&(N.innerHTML=et),8&e&&nt!==(nt=t[3].date+"")&&b(P,nt),8&e&&rt!==(rt=t[3].site+"")&&b(W,rt),8&e&&B!==(B=t[3].url)&&g(V,"href",B),8&e){let n;for(bt=t[3].data.autoclass.words,n=0;n<bt.length;n+=1){const o=ot(t,bt,n);vt[n]?vt[n].p(o,e):(vt[n]=ft(o),vt[n].c(),vt[n].m(G,null))}for(;n<vt.length;n+=1)vt[n].d(1);vt.length=bt.length}2&e&&K!==(K="detailHead bg-light "+(t[1]?"applied":"")+" svelte-ewk0kd")&&g(n,"class",K),8&e&&it!==(it=t[3].summary+"")&&(X.innerHTML=it)},d(t){t&&i(e),pt&&pt.d(),gt.d(),u(vt,t)}}}function at(t){let e;return{c(){e=d("span"),e.textContent="Permanent",g(e,"class","badge badge-danger")},m(t,n){l(t,e,n)},d(t){t&&i(e)}}}function st(t){let e;return{c(){e=d("span"),e.textContent="Contract",g(e,"class","badge badge-success")},m(t,n){l(t,e,n)},d(t){t&&i(e)}}}function ct(e){let n;return{c(){n=f("Applied!")},m(t,e){l(t,n,e)},p:t,d(t){t&&i(n)}}}function lt(e){let n,o;return{c(){n=d("button"),n.textContent="Applied",g(n,"class","btn btn-sm btn-primary")},m(t,r,a){l(t,n,r),a&&o(),o=m(n,"click",e[4])},p:t,d(t){t&&i(n),o()}}}function it(t){let e,n,o,a=t[8]+"";return{c(){e=d("span"),n=f(a),g(e,"class","badge badge-dark")},m(a,s,i){l(a,e,s),c(e,n),i&&o(),o=m(e,"click",(function(){r(mt(t[8]))&&mt(t[8]).apply(this,arguments)}))},p(e,o){t=e,8&o&&a!==(a=t[8]+"")&&b(n,a)},d(t){t&&i(e),o()}}}function ut(t){let e,n,o=t[8]+"";return{c(){e=d("span"),n=f(o),g(e,"class","badge badge-danger")},m(t,o){l(t,e,o),c(e,n)},p(t,e){8&e&&o!==(o=t[8]+"")&&b(n,o)},d(t){t&&i(e)}}}function dt(t){let e,n,o=t[8]+"";return{c(){e=d("span"),n=f(o),g(e,"class","badge badge-success")},m(t,o){l(t,e,o),c(e,n)},p(t,e){8&e&&o!==(o=t[8]+"")&&b(n,o)},d(t){t&&i(e)}}}function ft(t){let e,n,o;function r(t,o){return(null==e||8&o)&&(e=!(-1===t[3].data.autoclass.good.indexOf(t[8]))),e?dt:((null==n||8&o)&&(n=!(-1===t[3].data.autoclass.bad.indexOf(t[8]))),n?ut:it)}let a=r(t,-1),s=a(t);return{c(){s.c(),o=h()},m(t,e){s.m(t,e),l(t,o,e)},p(t,e){a===(a=r(t,e))&&s?s.p(t,e):(s.d(1),s=a(t),s&&(s.c(),s.m(o.parentNode,o)))},d(t){s.d(t),t&&i(o)}}}function pt(e){let n,o=e[0]&&rt(e);return{c(){o&&o.c(),n=h()},m(t,e){o&&o.m(t,e),l(t,n,e)},p(t,[e]){t[0]?o?o.p(t,e):(o=rt(t),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:t,o:t,d(t){o&&o.d(t),t&&i(n)}}}function ht(t){for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function mt(t){console.log(">>kill",t)}function gt(t,e,n){let o;s(t,I,t=>n(3,o=t));let r=!1,a=!1,c=0;return I.subscribe(t=>{n(0,r=!ht(t))}),t.$$.update=()=>{8&t.$$.dirty&&(ht(o)||(n(1,a="number"==typeof o.data.applied&&0!==o.data.applied),n(2,c=o.data.jobtype)))},[r,a,c,o,function(){U.appliedJob(o._id)}]}class bt extends P{constructor(t){super(),H(this,t,gt,pt,a,{})}}function vt(e){let n,o,r,a,s,u,f;return{c(){n=d("header"),o=d("section"),r=d("span"),r.textContent=""+yt,a=p(),s=d("section"),u=d("button"),u.textContent="Mark All Read",g(r,"class","text-bold navbar-brand mx-1 text-uppercase"),g(o,"class","navbar-section"),g(u,"class","btn btn-sm btn-primary"),g(s,"class","navbar-section text-right"),g(n,"class","navbar bg-primary")},m(t,i,d){l(t,n,i),c(n,o),c(o,r),c(n,a),c(n,s),c(s,u),d&&f(),f=m(u,"click",e[0])},p:t,i:t,o:t,d(t){t&&i(n),f()}}}let yt="Jobs";function $t(t){return[function(){U.markAllRead()}]}class wt extends P{constructor(t){super(),H(this,t,$t,vt,a,{})}}function kt(e){let n,o,r,a,s;const u=new wt({}),f=new nt({}),h=new bt({});return{c(){N(u.$$.fragment),n=p(),o=d("div"),r=d("div"),N(f.$$.fragment),a=p(),N(h.$$.fragment),g(r,"class","col-12"),g(o,"class","container fullWidth noscroll")},m(t,e){R(u,t,e),l(t,n,e),l(t,o,e),c(o,r),R(f,r,null),c(r,a),R(h,r,null),s=!0},p:t,i(t){s||(O(u.$$.fragment,t),O(f.$$.fragment,t),O(h.$$.fragment,t),s=!0)},o(t){S(u.$$.fragment,t),S(f.$$.fragment,t),S(h.$$.fragment,t),s=!1},d(t){D(u,t),t&&i(n),t&&i(o),D(f),D(h)}}}var xt=1e3,Jt=6e4,_t=60*Jt,jt=24*_t,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*jt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*_t;case"minutes":case"minute":case"mins":case"min":case"m":return n*Jt;case"seconds":case"second":case"secs":case"sec":case"s":return n*xt;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>=jt)return At(t,e,jt,"day");if(e>=_t)return At(t,e,_t,"hour");if(e>=Jt)return At(t,e,Jt,"minute");if(e>=xt)return At(t,e,xt,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=jt)return Math.round(t/jt)+"d";if(e>=_t)return Math.round(t/_t)+"h";if(e>=Jt)return Math.round(t/Jt)+"m";if(e>=xt)return Math.round(t/xt)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function At(t,e,n,o){var r=e>=1.5*n;return Math.round(t/n)+" "+o+(r?"s":"")}let Lt=0;const Tt=new class extends P{constructor(t){super(),H(this,t,null,kt,a,{})}}({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),Lt=setTimeout(()=>{t()},e)}(),Tt}();