| 1234567891011121314151617181920 |
- function g(a){this.id=a.id;this.name=a.name}function h(a,b){this.id=a.id;this.name=a.name;this.b=parseFloat(a.last_read);this.a={};if(a.members)for(var c=0,d=a.members.length;c<d;c++){var f=l(b,a.members[c]);this.a[f.id]=f;f.f[this.id]=this}}function m(a,b){var c=[];this.id=b.id;this.a={};for(var d=0,f=b.members.length;d<f;d++){var e=l(a,b.members[d]);this.a[b.members[d]]=e;e.f[this.id]=this;c.push(e.name)}this.name=c.join(", ");this.b=parseFloat(b.last_read)}
- function n(a,b){this.id=b.id;this.c=a;this.b=parseFloat(b.last_read)}function r(a){this.id=a.id;this.name=a.name;this.status=a.status;this.b={B:a.profile.image_24,C:a.profile.image_32,l:a.profile.image_48,s:a.profile.image_72,A:a.profile.image_192,F:a.profile.image_512};this.f={};this.a=null}function v(a){this.id=a.id;this.name=a.name;this.b={D:a.icons.image_36,l:a.icons.image_48,s:a.icons.image_72};this.f={};this.a=null}
- function w(){this.i=null;this.f={};this.b={};this.g={};this.a={};this.c=null;this.h={}}function l(a,b){return a.a[b]||a.h[b]||null}function x(a,b){return a.f[b]||a.g[b]||a.b[b]||null}"undefined"!==typeof module&&(module.o.u=w);function z(a){this.c=a.user;this.b=parseFloat(a.ts);this.a=a}function A(a,b,c){this.id="string"===typeof a?a:a.id;this.a=[];this.b=b;c&&B(this,c)}function B(a,b){var c=0;b.forEach(function(a){c=Math.max(this.push(a),c)}.bind(a))}A.prototype.push=function(a){for(var b=parseFloat(a.ts),c=0,d=this.a.length;c<d;c++)if(this.a[c].b===b)return b;for(this.a.push(new z(a));this.a.length>this.b;)this.a.shift();return b};"undefined"!==typeof module&&(module.o.w=A);var C=null;
- function D(){var a=document.createDocumentFragment(),b=E.a.c?Object.keys(E.a.c.f):[];b.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:(E.a.f[a]||E.a.b[a]).name.localeCompare((E.a.f[b]||E.a.b[b]).name)});b.forEach(function(b){b=E.a.f[b]||E.a.b[b];var c=document.createElement("li");c.id=b.id;"D"===b.id[0]?c.className="slack-context-room slack-ims":"G"===b.id[0]?c.className="slack-context-room slack-group":"C"===b.id[0]&&(c.className="slack-context-room slack-channel");c.textContent=b.name;c&&a.appendChild(c)});
- b=E.a.a?Object.keys(E.a.a):[];b.sort(function(a,b){return E.a.a[a].name.localeCompare(E.a.a[b].name)});b.forEach(function(b){b=E.a.a[b].a;var c=document.createElement("li");c.id=b.id;c.className="slack-context-room";c.textContent=b.c.name;c&&a.appendChild(c)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a)}function F(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network")}
- function G(){if(C){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){C=null;G()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(H("reply_"+I.id,C))}else document.body.classList.remove("replyingTo")}
- function H(a,b){var c=document.createElement("div"),d=document.createElement("div"),f=document.createElement("div"),e=document.createElement("div"),k=document.createElement("img"),p=document.createElement("span"),q=document.createElement("ul"),t=document.createElement("li"),u=b.a.user?E.a.a[b.a.user]:E.a.h[b.a.bot_id];c.id=a+"_"+b.b;c.className="slackmsg-item";d.className="slackmsg-ts";f.className="slackmsg-msg";e.className="slackmsg-author";k.className="slackmsg-author-img";p.className="slackmsg-author-name";
- q.className="slackmsg-hover";t.className="slackmsg-hover-reply";d.textContent=(new Date(1E3*b.b)).toLocaleTimeString();var y=b.a.text||"",y=y.replace(RegExp("<([@#]?)([^>]*)>","g"),function(a,b,c){a=c.split("|");"@"===b?(a[1]?"@"!==a[1][0]&&(a[1]="@"+a[1]):(c=l(E.a,a[0]),a[1]=c?"@"+c.name:"Unknown member"),a[0]="#"+a[0],a[2]="slackmsg-link slackmsg-link-user"):"#"===b?(a[1]?"#"!==a[1][0]&&(a[1]="#"+a[1]):(c=x(E.a,a[0]),a[1]=c?"#"+c.name:"Unknown channel"),a[0]="#"+a[0],a[2]="slackmsg-link slackmsg-link-chan"):
- (a[1]||(a[1]=a[0]),a[2]="slackmsg-link");return'<a href="'+a[0]+'" class="'+a[2]+'"'+(b?"":' target="_blank"')+">"+a[1]+"</a>"});f.innerHTML=y;p.textContent=u?u.name:b.a.username||"?";u||b.a.username||(f.textContent=b.a.subtype||JSON.stringify(b.a));k.src=u?u.b.l:"";e.appendChild(k);e.appendChild(p);q.appendChild(t);c.appendChild(e);c.appendChild(f);c.appendChild(d);c.appendChild(q);return c}
- function J(){var a=0,b=0,c,d;for(d in K)K.hasOwnProperty(d)&&(a+=K[d].m,b+=K[d].j);b&&(c="(!"+b);a&&(c=(c?c+" - ":"(")+a);c=c?c+(") "+E.a.i.name):E.a.i.name;document.title=c}function L(){var a=document.createDocumentFragment(),b=I.id;document.getElementById("chatWindow").textContent="";E.b[b]&&E.b[b].a.forEach(function(c){a.appendChild(H(b,c))});var c=document.getElementById("chatWindow");c.appendChild(a);c.scrollTop=c.scrollHeight-c.clientHeight}
- function M(a){for(;a.target!==a.currentTarget&&a.target;){if(a.target.classList.contains("slack-context-room")){if((a=E.a.f[a.target.id]||E.a.g[a.target.id]||E.a.b[a.target.id])&&a!==I){I&&document.getElementById(I.id).classList.remove("selected");document.getElementById(a.id).classList.add("selected");document.body.classList.remove("no-room-selected");I=a;a=void 0;var b=I.name||(I.c?I.c.name:void 0);if(!b){b=[];for(a in I.a)b.push(I.a[a].name);b=b.join(", ")}document.getElementById("currentRoomTitle").textContent=
- b;L();N();document.getElementById("fileUploadContainer").classList.add("hidden");O();C&&(C=null,G());I.b&&!E.b[I.id]&&(a=new XMLHttpRequest,a.open("GET","api/hist?room="+I.id,!0),a.send(null))}break}a.target=a.target.parentElement}}
- function P(a){for(var b=a.target;b!==a.currentTarget&&b&&!b.classList.contains("slackmsg-hover");){if(b.classList.contains("slackmsg-hover-reply")){a:{for(b=b||a.target;b!==a.currentTarget&&b;){if(b.classList.contains("slackmsg-item")){a=b.id;break a}b=b.parentElement}a=void 0}if(a){a=parseFloat(a.split("_")[1]);for(var b=E.b[I.id].a,c=0,d=b.length;c<d&&b[c].b<=a;c++)if(b[c].b===a){C!==b[c]&&(C=b[c],G());break}}break}b=b.parentElement}}function N(){document.getElementById("msgInput").focus()}
- document.addEventListener("DOMContentLoaded",function(){document.getElementById("chatList").addEventListener("click",M);document.getElementById("chatWindow").addEventListener("click",P);document.getElementById("fileUploadCancel").addEventListener("click",function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value="";return!1});document.getElementById("fileUploadForm").addEventListener("submit",
- function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),Q(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1});document.getElementById("attachFile").addEventListener("click",function(a){a.preventDefault();
- I&&document.getElementById("fileUploadContainer").classList.remove("hidden");return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");if(I&&a.value){var b=I,c=C,d=new XMLHttpRequest,f="api/msg?room="+b.id+"&text="+encodeURIComponent(a.value);if(c){var e=l(E.a,c.c),k="Message";"C"===b.id[0]?k="Channel message":"D"===b.id[0]?k="Direct message":"G"===b.id[0]&&(k="Group message");f+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.a.text||
- "",author_name:"<@"+e.id+"|"+e.name+">",author_icon:e.b.l,text:c.a.text||"",footer:k,ts:c.b}]))}d.open("POST",f,!0);d.send(null);a.value="";C&&(C=null,G())}N();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;I&&O();N()});window.hasFocus=!0;R()});var E,K={};function S(a,b){if(a&&(a!==I||!window.hasFocus)){var c=new RegExp("<@"+E.a.c.id),d=!1;K[a.id]||(K[a.id]={j:0,m:0});b.forEach(function(b){"message"===b.type&&("D"===a.id[0]||b.text.match(c)?(K[a.id].j++,d=!0):K[a.id].m++)});J();document.getElementById(a.id).classList.add("unread");d&&document.getElementById(a.id).classList.add("unreadHi")}}function O(){var a=I;K[a.id]&&(K[a.id]={j:0,m:0},J());a=document.getElementById(a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}
- E=new function(){this.c=0;this.a=new w;this.b={}};var T=0,I=null;function U(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var c=null,d=2===Math.floor(b.status/100);if(d){T&&(T=0,F(!0));c=b.response;try{c=JSON.parse(c)}catch(f){c=null}}else T?(T+=Math.floor((T||5)/2),T=Math.min(60,T)):(T=5,F(!1));a(d,c)}else T&&(T=0,F(!0)),U(a)};b.open("GET","api?v="+E.c,!0);b.send(null)}
- function V(a,b){if(a){if(b){var c=E;b.v&&(c.c=b.v);if(b["static"]){for(var d=c.a,f=b["static"],e=0,k=f.bots.length;e<k;e++)d.h[f.bots[e].id]=new v(f.bots[e]);e=0;for(k=f.users.length;e<k;e++)d.a[f.users[e].id]=new r(f.users[e]);e=0;for(k=f.ims.length;e<k;e++){var p=l(d,f.ims[e].user);p&&(p.a=new n(p,f.ims[e]),d.g[p.a.id]=p.a)}e=0;for(k=f.channels.length;e<k;e++)d.f[f.channels[e].id]=new h(f.channels[e],d);e=0;for(k=f.groups.length;e<k;e++)d.b[f.groups[e].id]=new m(d,f.groups[e]);d.i=new g(f.team);
- d.c=l(d,f.self.id);D()}if(b.live){for(var q in b.live)(d=c.b[q])?B(d,b.live[q]):c.b[q]=new A(q,250,b.live[q]);for(var t in b.live)S(x(c.a,t),b.live[t]),I&&b.live[I.id]&&L()}}R()}else setTimeout(R,1E3*T)}function R(){U(V)}function Q(a,b,c){var d=I;new FileReader;var f=new FormData,e=new XMLHttpRequest;f.append("file",b);f.append("filename",a);e.onreadystatechange=function(){4===e.readyState&&(204===e.status?c(null):c(e.statusText))};e.open("POST","api/file?room="+d.id);e.send(f)};
|