2 lines
15 KiB
JavaScript
2 lines
15 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 s(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function a(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){return document.createElement(t)}function d(t){return document.createTextNode(t)}function f(){return d(" ")}function p(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}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 g;function b(t){g=t}const y=[],v=[],$=[],w=[],x=Promise.resolve();let k=!1;function J(t){$.push(t)}let _=!1;const A=new Set;function C(){if(!_){_=!0;do{for(let t=0;t<y.length;t+=1){const e=y[t];b(e),j(e.$$)}for(y.length=0;v.length;)v.pop()();for(let t=0;t<$.length;t+=1){const e=$[t];A.has(e)||(A.add(e),e())}$.length=0}while(y.length);for(;w.length;)w.pop()();k=!1,_=!1,A.clear()}}function j(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 L=new Set;function S(t,e){t&&t.i&&(L.delete(t),t.i(e))}function M(t,e,n,o){if(t&&t.o){if(L.has(t))return;L.add(t),(void 0).c.push(()=>{L.delete(t),o&&(n&&t.d(1),o())}),t.o(e)}}function N(t){t&&t.c()}function O(t,n,s){const{fragment:a,on_mount:c,on_destroy:l,after_update:i}=t.$$;a&&a.m(n,s),J(()=>{const n=c.map(e).filter(r);l?l.push(...n):o(n),t.$$.on_mount=[]}),i.forEach(J)}function R(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 T(t,e){-1===t.$$.dirty[0]&&(y.push(t),k||(k=!0,x.then(C)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function E(e,r,s,a,c,l,u=[-1]){const d=g;b(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=s?s(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&&T(e,t)),n}):[],p.update(),h=!0,o(p.before_update),p.fragment=!!a&&a(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&&S(e.$$.fragment),O(e,r.target,r.anchor),C()}b(d)}class D{$destroy(){R(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 H(e,n=t){let o;const r=[];function a(t){if(s(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:a,update:function(t){a(t(e))},subscribe:function(s,c=t){const l=[s,c];return r.push(l),1===r.length&&(o=n(a)||t),s(e),()=>{const t=r.indexOf(l);-1!==t&&r.splice(t,1),0===r.length&&(o(),o=null)}}}}var P=function t(e){function n(t){return function(e,n){return s(e,Object.assign({method:t},n))}}function o(t){return function(e,n,o){return s(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,s={};if(t)for(o in t)s[n?o.toLowerCase():o]=t[o];for(o in e){var a=n?o.toLowerCase():o;"headers"===a&&(n=!0),s[a]=o in s?r(s[a],e[o],n):e[o]}return s}return e}function s(t,n){"string"!=typeof t&&(t=(n=t).url);var o=r(e,n||{}),s=o.data;if(o.transformRequest)for(var a=0;a<o.transformRequest.length;a++){var c=o.transformRequest[a](s,o.headers);void 0!==c&&(s=c)}var l={};if(s&&"object"==typeof s&&(s=JSON.stringify(s),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:s,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||{},s.request=s,s.get=n("get"),s.delete=n("delete"),s.options=n("options"),s.post=o("post"),s.put=o("put"),s.patch=o("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}();let z=location.port?":"+location.port:"",F=`${location.protocol}//${location.hostname}${z}`;const I={jobs:F.concat("/jobs"),apply:F.concat("/apply"),readall:F.concat("/readall"),kill:F.concat("/kill"),upvote:F.concat("/vote/up"),downvote:F.concat("/vote/down")},V=H([]),W=H({}),B={getJobList(){P.get(I.jobs).then(t=>{const e=JSON.parse(t.data);V.set(e)}).catch(t=>{console.error("getJobList",t)})},loadJobDetail(t){if(console.log("loadJobDetail: "+t),t){const e=`${I.jobs}/${t}`;P.get(e).then(t=>{const e=JSON.parse(t.data);W.set(e)}).catch(t=>{console.error("loadJobDetail",t)})}},async touchJob(t){if(console.log("touchJob: "+t),t){const e=`${I.jobs}/${t}`;await P.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("touchJob",t)}),V.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=Date.now()/1e3;if(t){console.log("Applying..");const n=`${I.apply}/${t}`;await P.put(n).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("appliedJob",t)});const o=parseInt(t,10);V.update(t=>(t.map(t=>{if(t._id===o)return t.a=e,t}),t)),W.update(t=>(t.a=e,t))}},async markAllRead(){console.log(">> markAllRead");const t=""+I.readall;await P.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=`${I.kill}/${t}`;P.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("killword",t)})},upVote(t){console.log(">> upvote:"+t);const e=`${I.upvote}/${t}`;P.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("upvote",t)})},downVote(t){console.log(">> downvote:"+t);const e=`${I.downvote}/${t}`;P.put(e).then(t=>{200!==t.status&&console.error(t)}).catch(t=>{console.error("downvote",t)})}};function U(t,e,n){const o=t.slice();return o[4]=e[n],o[6]=n,o}function G(t){let e,n,o,r,s,a,g,b,y,v,$,w,x,k,J,_,A=t[4].title+"",C=t[4].site+"",j=Q(t[4].company)+"",L=t[4].postdate+"";return{c(){e=u("tr"),n=u("td"),o=d(A),r=f(),s=u("td"),a=d(C),g=f(),b=u("td"),y=d(j),v=f(),$=u("td"),w=d(L),x=f(),h(n,"class","noOverflow svelte-1u7sr1d"),h(e,"class",k="dataRow "+X(t[4])+" "+Y(t[4])+" svelte-1u7sr1d"),h(e,"data-id",J=t[4]._id)},m(i,u,d){var f;l(i,e,u),c(e,n),c(n,o),c(e,r),c(e,s),c(s,a),c(e,g),c(e,b),c(b,y),c(e,v),c(e,$),c($,w),c(e,x),d&&_(),_=p(e,"click",(f=t[1],function(t){return t.stopPropagation(),f.call(this,t)}))},p(t,n){1&n&&A!==(A=t[4].title+"")&&m(o,A),1&n&&C!==(C=t[4].site+"")&&m(a,C),1&n&&j!==(j=Q(t[4].company)+"")&&m(y,j),1&n&&L!==(L=t[4].postdate+"")&&m(w,L),1&n&&k!==(k="dataRow "+X(t[4])+" "+Y(t[4])+" svelte-1u7sr1d")&&h(e,"class",k),1&n&&J!==(J=t[4]._id)&&h(e,"data-id",J)},d(t){t&&i(e),_()}}}function K(e){let n,o,r,s,a,d=e[0],p=[];for(let t=0;t<d.length;t+=1)p[t]=G(U(e,d,t));return{c(){n=u("div"),o=u("table"),r=u("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>',s=f(),a=u("tbody");for(let t=0;t<p.length;t+=1)p[t].c();h(o,"class",""),h(n,"class","lister svelte-1u7sr1d")},m(t,e){l(t,n,e),c(n,o),c(o,r),c(o,s),c(o,a);for(let t=0;t<p.length;t+=1)p[t].m(a,null)},p(t,[e]){if(3&e){let n;for(d=t[0],n=0;n<d.length;n+=1){const o=U(t,d,n);p[n]?p[n].p(o,e):(p[n]=G(o),p[n].c(),p[n].m(a,null))}for(;n<p.length;n+=1)p[n].d(1);p.length=d.length}},i:t,o:t,d(t){t&&i(n),function(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}(p,t)}}}function Q(t){return t.length<=40?t:t.slice(0,40)+"…"}function X(t){return 0!==t.read?"read":""}function Y(t){return 0!==t.applied?"applied":""}function Z(t,e,n){let o;return a(t,V,t=>n(0,o=t)),[o,function(t){console.log("clickevent",t);const e=t.target.parentElement.dataset.id;B.loadJobDetail(e),B.touchJob(e)}]}class tt extends D{constructor(t){super(),E(this,t,Z,K,s,{})}}function et(e){let n;return{c(){n=u("div"),h(n,"class","detail svelte-66pry7")},m(t,e){l(t,n,e)},p:t,d(t){t&&i(n)}}}function nt(t){let e,n,o,r,s,a,p,g,b,y,v,$,w,x,k,J,_,A,C,j,L,S,M,N,O,R,T,E,D,q,H,P,z,F,I,V,W,B,U,G,K=t[2].title+"",Q=t[2].company+"",X=t[2].location+"",Y=t[2].salary+"",Z=t[2].postdate+"",tt=t[2].site+"",et=t[2].summary+"";let nt=void 0,st=nt&&nt(t);function at(t,e){return t[2].applied?ot:rt}let ct=at(t),lt=ct(t);return{c(){e=u("div"),n=u("div"),o=u("div"),r=u("div"),s=d(K),a=f(),st&&st.c(),p=f(),g=u("div"),b=u("div"),y=d("Company: "),v=u("span"),$=d(Q),w=f(),x=u("div"),k=d("Location: "),J=u("span"),_=d(X),A=f(),C=u("div"),j=d("Applied:\n "),lt.c(),L=f(),S=u("div"),M=u("div"),N=d("Salary: "),O=u("span"),R=d(Y),T=f(),E=u("div"),D=d("Scraped: "),q=u("span"),H=d(Z),P=f(),z=u("div"),F=d("Site: "),I=u("a"),V=d(tt),U=f(),G=u("blockquote"),h(r,"class","col-12 text-primary lead"),h(o,"class","row svelte-66pry7"),h(v,"class","text-primary"),h(b,"class","col-1-3rd"),h(J,"class","text-primary"),h(x,"class","col-1-3rd"),h(C,"class","col-1-3rd"),h(g,"class","row svelte-66pry7"),h(O,"class","text-primary"),h(M,"class","col-1-3rd"),h(q,"class","text-primary"),h(E,"class","col-1-3rd"),h(I,"href",W=t[2].url),h(I,"class","text-capitalize"),h(I,"target","_blank"),h(z,"class","col-1-3rd"),h(S,"class","row svelte-66pry7"),h(n,"class",B="detailHead bg-light "+(t[1]?"applied":"")+" svelte-66pry7"),h(G,"class","padx--2 svelte-66pry7"),h(e,"class","detail svelte-66pry7")},m(t,i){l(t,e,i),c(e,n),c(n,o),c(o,r),c(r,s),c(o,a),st&&st.m(o,null),c(n,p),c(n,g),c(g,b),c(b,y),c(b,v),c(v,$),c(g,w),c(g,x),c(x,k),c(x,J),c(J,_),c(g,A),c(g,C),c(C,j),lt.m(C,null),c(n,L),c(n,S),c(S,M),c(M,N),c(M,O),c(O,R),c(S,T),c(S,E),c(E,D),c(E,q),c(q,H),c(S,P),c(S,z),c(z,F),c(z,I),c(I,V),c(e,U),c(e,G),G.innerHTML=et},p(t,e){4&e&&K!==(K=t[2].title+"")&&m(s,K),4&e&&Q!==(Q=t[2].company+"")&&m($,Q),4&e&&X!==(X=t[2].location+"")&&m(_,X),ct===(ct=at(t))&<?lt.p(t,e):(lt.d(1),lt=ct(t),lt&&(lt.c(),lt.m(C,null))),4&e&&Y!==(Y=t[2].salary+"")&&m(R,Y),4&e&&Z!==(Z=t[2].postdate+"")&&m(H,Z),4&e&&tt!==(tt=t[2].site+"")&&m(V,tt),4&e&&W!==(W=t[2].url)&&h(I,"href",W),2&e&&B!==(B="detailHead bg-light "+(t[1]?"applied":"")+" svelte-66pry7")&&h(n,"class",B),4&e&&et!==(et=t[2].summary+"")&&(G.innerHTML=et)},d(t){t&&i(e),st&&st.d(),lt.d()}}}function ot(e){let n;return{c(){n=d("Applied!")},m(t,e){l(t,n,e)},p:t,d(t){t&&i(n)}}}function rt(e){let n,o;return{c(){n=u("button"),n.textContent="Applied",h(n,"class","btn btn-sm btn-primary")},m(t,r,s){l(t,n,r),s&&o(),o=p(n,"click",e[3])},p:t,d(t){t&&i(n),o()}}}function st(e){let n;function o(t,e){return t[0]?nt:et}let r=o(e),s=r(e);return{c(){s.c(),n=d("")},m(t,e){s.m(t,e),l(t,n,e)},p(t,[e]){r===(r=o(t))&&s?s.p(t,e):(s.d(1),s=r(t),s&&(s.c(),s.m(n.parentNode,n)))},i:t,o:t,d(t){s.d(t),t&&i(n)}}}function at(t){for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function ct(t,e,n){let o;a(t,W,t=>n(2,o=t));let r=!1,s=!1;return W.subscribe(t=>{n(0,r=!at(t)),console.log("JobDetails.subscribe",t)}),t.$$.update=()=>{4&t.$$.dirty&&(at(o)||(console.log("jobdetails.data:",o),console.log("Applied:",o.applied),n(1,s="number"==typeof o.applied&&0!==o.applied)))},[r,s,o,function(){B.appliedJob(o._id)}]}class lt extends D{constructor(t){super(),E(this,t,ct,st,s,{})}}function it(e){let n,o,r,s,a,d,m;return{c(){n=u("header"),o=u("section"),r=u("span"),r.textContent=""+ut,s=f(),a=u("section"),d=u("button"),d.textContent="Mark All Read",h(r,"class","text-bold navbar-brand mx-1 text-uppercase"),h(o,"class","navbar-section"),h(d,"class","btn btn-sm btn-primary"),h(a,"class","navbar-section text-right"),h(n,"class","navbar bg-primary")},m(t,i,u){l(t,n,i),c(n,o),c(o,r),c(n,s),c(n,a),c(a,d),u&&m(),m=p(d,"click",e[0])},p:t,i:t,o:t,d(t){t&&i(n),m()}}}let ut="Jobs";function dt(t){return[function(){B.markAllRead()}]}class ft extends D{constructor(t){super(),E(this,t,dt,it,s,{})}}function pt(e){let n,o,r,s,a;const d=new ft({}),p=new tt({}),m=new lt({});return{c(){N(d.$$.fragment),n=f(),o=u("div"),r=u("div"),N(p.$$.fragment),s=f(),N(m.$$.fragment),h(r,"class","col-12"),h(o,"class","container fullWidth")},m(t,e){O(d,t,e),l(t,n,e),l(t,o,e),c(o,r),O(p,r,null),c(r,s),O(m,r,null),a=!0},p:t,i(t){a||(S(d.$$.fragment,t),S(p.$$.fragment,t),S(m.$$.fragment,t),a=!0)},o(t){M(d.$$.fragment,t),M(p.$$.fragment,t),M(m.$$.fragment,t),a=!1},d(t){R(d,t),t&&i(n),t&&i(o),R(p),R(m)}}}var ht=1e3,mt=6e4,gt=60*mt,bt=24*gt,yt=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*bt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*gt;case"minutes":case"minute":case"mins":case"min":case"m":return n*mt;case"seconds":case"second":case"secs":case"sec":case"s":return n*ht;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>=bt)return vt(t,e,bt,"day");if(e>=gt)return vt(t,e,gt,"hour");if(e>=mt)return vt(t,e,mt,"minute");if(e>=ht)return vt(t,e,ht,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=bt)return Math.round(t/bt)+"d";if(e>=gt)return Math.round(t/gt)+"h";if(e>=mt)return Math.round(t/mt)+"m";if(e>=ht)return Math.round(t/ht)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function vt(t,e,n,o){var r=e>=1.5*n;return Math.round(t/n)+" "+o+(r?"s":"")}let $t=0;const wt=new class extends D{constructor(t){super(),E(this,t,null,pt,s,{})}}({target:document.body});return function t(){B.getJobList();const e=yt("15m");console.log("Next:",e),$t=setTimeout(()=>{t()},e)}(),wt}();
|