function SlackTeam(teamData){this.id=teamData["id"];this.name=teamData["name"];this.domain=teamData["domain"];this.callApp=teamData["prefs"]["calling_app_id"];this.callAppName=teamData["prefs"]["calling_app_name"];this.fileUploadPermission=teamData["prefs"]["disable_file_uploads"];this.fileEditPermission=teamData["prefs"]["disable_file_editing"];this.fileDeletePermission=teamData["prefs"]["disable_file_deleting"];this.icons={image_34:teamData["icon"]["image_34"],image_44:teamData["icon"]["image_44"], image_68:teamData["icon"]["image_68"],image_88:teamData["icon"]["image_88"],image_102:teamData["icon"]["image_102"],image_132:teamData["icon"]["image_132"],image_230:teamData["icon"]["image_230"],image_default:teamData["icon"]["image_default"]}} function SlackChan(chanData,slackData){this.id=chanData["id"];this.name=chanData["name"];this.created=chanData["created"];this.creator=slackData.getMember(chanData["creator"]);this.archived=chanData["is_archived"];this.isMember=chanData["is_member"];this.lastRead=parseFloat(chanData["last_read"]);this.members={};if(chanData["members"])for(var i=0,nbMembers=chanData["members"].length;iknownVersion?this.buildStatic():undefined};(function(){if(typeof module!=="undefined")module.exports.SlackData=SlackData})();function SlackMessage(e,ts){this.userId=e["user"];this.id=e["ts"];this.ts=ts||parseFloat(e["ts"]);this.type=e["type"];this.subtype=e["subtype"];this.raw=e;this.starred=!!e["is_starred"];this.pinned=false;this.reactions={};var _this=this;e["reactions"]&&e["reactions"].forEach(function(r){_this.reactions[r["name"]]=[];r["users"].forEach(function(userId){_this.reactions[r["name"]].push(userId)})})} function SlackHistory(room,keepMessages,evts){this.id=typeof room==="string"?room:room.id;this.messages=[];this.v=0;this.keepMessages=keepMessages;if(evts)this.pushAll(evts)}SlackMessage.prototype.toStatic=function(){return this.raw};SlackMessage.prototype.addReaction=function(reaction,userId){if(!this.reactions[reaction])this.reactions[reaction]=[];this.reactions[reaction].push(userId)}; SlackMessage.prototype.removeReaction=function(reaction,userId){if(this.reactions[reaction])if(this.reactions[reaction].length===1)delete this.reactions[reaction];else this.reactions[reaction]=this.reactions[reaction].filter(function(i){return i!==userId})};SlackMessage.prototype.hasReactionForUser=function(reaction,userId){if(this.reactions[reaction])return this.reactions[reaction].indexOf(userId)!==-1;return false}; SlackHistory.prototype.pushAll=function(evts){var result=0;evts.forEach(function(e){result=Math.max(this.push(e),result)}.bind(this));this.resort();return result}; SlackHistory.prototype.push=function(ev){var ts=parseFloat(ev["ts"]);for(var i=0,nbMsg=this.messages.length;ithis.keepMessages)this.messages.shift();if(ev["type"]==="reaction_added")this.addReaction(ev["reaction"],ev["user"],parseFloat(ev["item"]["ts"]));else if(ev["type"]==="reaction_removed")this.removeReaction(ev["reaction"],ev["user"],parseFloat(ev["item"]["ts"]));return ts}; SlackHistory.prototype.addReaction=function(reaction,userId,ts){var msg=this.getMessage(ts);if(msg)msg.addReaction(reaction,userId)};SlackHistory.prototype.removeReaction=function(reaction,userId,ts){var msg=this.getMessage(ts);if(msg)msg.removeReaction(reaction,userId)};SlackHistory.prototype.getMessage=function(ts){for(var i=0,nbMessages=this.messages.length;i=this.messages[i].ts;i++)if(this.messages[i].ts===ts)return this.messages[i];return null}; SlackHistory.prototype.getMessageById=function(id){for(var i=0,nbMessages=this.messages.length;i=0&&this.messages[i].ts>knownVersion;i--)result.push(this.messages[i].toStatic());return result};SlackHistory.prototype.resort=function(){this.messages.sort(function(a,b){return a.ts-b.ts})}; (function(){if(typeof module!=="undefined")module.exports.SlackHistory=SlackHistory})();var lang={},locale;function initLang(lg){if(!lg){for(var i=0,nbLang=navigator.languages.length;i]*)>","g"),function(matched,type,entity){var sub=entity.split("|");if(type==="@"){if(!sub[1]){var user=SLACK.context.getMember(sub[0]);sub[1]=user?"@"+user.name:locale.unknownMember}else if("@"!== sub[1][0])sub[1]="@"+sub[1];sub[0]="#"+sub[0];sub[2]=R.klass.msg.link+" "+R.klass.msg.linkuser}else if(type==="#"){if(!sub[1]){var chan=SLACK.context.getChannel(sub[0]);sub[1]=chan?"#"+chan.name:locale.unknownChannel}else if("#"!==sub[1][0])sub[1]="#"+sub[1];sub[0]="#"+sub[0];sub[2]=R.klass.msg.link+" "+R.klass.msg.linkchan}else if(sub[0].indexOf("://")!==-1){if(!sub[1])sub[1]=sub[0];sub[2]=R.klass.msg.link}else return matched;return'"+sub[1]+""});msgContent=formatEmojis(msgContent);var msgLength=msgContent.length;var checkEnd=function(str,pos,c){while(str[pos]){if(str[pos]!=" "&&str[pos]!=c&&str[pos+1]==c)return true;pos++}return false},appendMod=function(mods){if(!Object.keys(currentMods).length)return"";return''};while(i");i--;continue}if(!currentMods[R.klass.msg.style.bold]&&c==="*"&&msgContent[i+1]&&checkEnd(msgContent,i,c)){if(Object.keys(currentMods).length)_msgContent+="";currentMods[R.klass.msg.style.bold]=true;_msgContent+=appendMod(currentMods)}else if(!currentMods[R.klass.msg.style.strike]&&c==="~"&&msgContent[i+1]&&checkEnd(msgContent,i,c)){if(Object.keys(currentMods).length)_msgContent+="";currentMods[R.klass.msg.style.strike]= true;_msgContent+=appendMod(currentMods)}else if(!currentMods[R.klass.msg.style.code]&&c==="`"&&msgContent[i+1]&&checkEnd(msgContent,i,c)){if(Object.keys(currentMods).length)_msgContent+="";currentMods[R.klass.msg.style.code]=true;_msgContent+=appendMod(currentMods)}else if(!currentMods[R.klass.msg.style.italic]&&c==="_"&&msgContent[i+1]&&checkEnd(msgContent,i,c)){if(Object.keys(currentMods).length)_msgContent+="";currentMods[R.klass.msg.style.italic]=true;_msgContent+=appendMod(currentMods)}else{var finalFound= false;_msgContent+=c;do{if(currentMods[R.klass.msg.style.bold]&&c!=="*"&&msgContent[i+1]==="*"){delete currentMods[R.klass.msg.style.bold];finalFound=true}else if(currentMods[R.klass.msg.style.strike]&&c!=="~"&&msgContent[i+1]==="~"){delete currentMods[R.klass.msg.style.strike];finalFound=true}else if(currentMods[R.klass.msg.style.code]&&c!=="`"&&msgContent[i+1]==="`"){delete currentMods[R.klass.msg.style.code];finalFound=true}else if(currentMods[R.klass.msg.style.italic]&&c!=="_"&&msgContent[i+1]=== "_"){delete currentMods[R.klass.msg.style.italic];finalFound=true}else break;c=msgContent[++i]}while(i"+appendMod(currentMods)}}if(currentMods)_msgContent+="";if(quote)msgContents[msgContentIndex]=''+_msgContent+"";else msgContents[msgContentIndex]=_msgContent}return msgContents.join("
")} function createAttachmentDom(channelId,msg,attachment){var rootDom=document.createElement("li"),attachmentBlock=document.createElement("div"),pretext=document.createElement("div"),titleBlock=document.createElement("a"),authorBlock=document.createElement("div"),authorImg=document.createElement("img"),authorName=document.createElement("a"),textBlock=document.createElement("div"),textDom=document.createElement("div"),thumbImgDom=document.createElement("img"),imgDom=document.createElement("img"),footerBlock= document.createElement("div"),footerIcon=document.createElement("img"),footerText=document.createElement("span"),footerTs=document.createElement("span");rootDom.className=R.klass.msg.attachment.container;var color="#e3e4e6";if(attachment["color"])if(attachment["color"][0]==="#")color=attachment["color"][0];else if(attachment["color"]==="good")color="#2fa44f";else if(attachment["color"]==="warning")color="#de9e31";else if(attachment["color"]==="danger")color="#d50200";attachmentBlock.style.borderColor= color;pretext.className=R.klass.msg.attachment.pretext;if(attachment["pretext"])pretext.innerHTML=formatSlackText(attachment["pretext"]);else pretext.classList.add(R.klass.hidden);titleBlock.target="_blank";if(attachment["title"]){titleBlock.innerHTML=formatSlackText(attachment["title"]);if(attachment["title_link"])titleBlock.href=attachment["title_link"];titleBlock.className=R.klass.msg.attachment.title}else titleBlock.className=R.klass.hidden+" "+R.klass.msg.attachment.title;authorName.target="_blank"; authorBlock.className=R.klass.msg.author;if(attachment["author_name"]){authorName.innerHTML=formatSlackText(attachment["author_name"]);authorName.href=attachment["author_link"]||"";authorName.className=R.klass.msg.authorname;authorImg.className=R.klass.msg.authorAvatar;if(attachment["author_icon"])authorImg.src=attachment["author_icon"];else authorImg.classList.add(R.klass.hidden)}else authorBlock.classList.add(R.klass.hidden);textDom.innerHTML=formatSlackText(attachment["text"]||"");textDom.klassName= R.klass.msg.attachment.text;thumbImgDom.className=R.klass.msg.attachment.thumbImg;if(attachment["thumb_url"])thumbImgDom.src=attachment["thumb_url"];else thumbImgDom.classList.add(R.klass.hidden);imgDom.className=R.klass.msg.attachment.img;if(attachment["image_url"])imgDom.src=attachment["image_url"];else imgDom.classList.add(R.klass.hidden);footerBlock.className=R.klass.msg.attachment.footer;footerText.className=R.klass.msg.attachment.footerText;footerIcon.className=R.klass.msg.attachment.footerIcon; if(attachment["footer"]){footerText.innerHTML=formatSlackText(attachment["footer"]);if(attachment["footer_icon"])footerIcon.src=attachment["footer_icon"];else footerIcon.classList.add(R.klass.hidden)}else{footerIcon.classList.add(R.klass.hidden);footerText.classList.add(R.klass.hidden)}footerTs.className=R.klass.msg.ts;if(attachment["ts"])footerTs.innerHTML=formatDate(attachment["ts"]);else footerTs.classList.add(R.klass.hidden);authorBlock.appendChild(authorImg);authorBlock.appendChild(authorName); textBlock.appendChild(textDom);textBlock.appendChild(thumbImgDom);footerBlock.appendChild(footerIcon);footerBlock.appendChild(footerText);footerBlock.appendChild(footerTs);attachmentBlock.appendChild(titleBlock);attachmentBlock.appendChild(authorBlock);attachmentBlock.appendChild(textBlock);attachmentBlock.appendChild(imgDom);attachmentBlock.appendChild(footerBlock);rootDom.appendChild(pretext);rootDom.appendChild(attachmentBlock);return rootDom} function doCreateMeMessageDom(channelId,msg,skipAttachment){var dom=doCreateMessageDom(channelId,msg,skipAttachment);dom.classList.add(R.klass.msg.meMessage);return dom}function createMessageDom(channelId,msg,skipAttachment){if(msg.subtype==="me_message")return doCreateMeMessageDom(channelId,msg,skipAttachment);return doCreateMessageDom(channelId,msg,skipAttachment)} function setFavicon(unreadhi,unread){if(!unreadhi&&!unread)document.getElementById(R.id.favicon).href="favicon_ok.png";else document.getElementById(R.id.favicon).href="favicon.png?h="+unreadhi+"&m="+unread}function setNetErrorFavicon(){document.getElementById(R.id.favicon).href="favicon_err.png"} function updateTitle(){var hasUnread=0,hasHl=0,title="";if(NEXT_RETRY){title="!"+locale.netErrorShort+" - ";setNetErrorFavicon()}else{for(var i in UNREAD_CHANS)if(UNREAD_CHANS.hasOwnProperty(i)){hasUnread+=UNREAD_CHANS[i].unread;hasHl+=UNREAD_CHANS[i].hl}if(hasHl)title="(!"+hasHl+") - ";else if(hasUnread)title="("+hasUnread+") - ";setFavicon(hasHl,hasUnread)}title+=SLACK.context.team.name;document.title=title} function spawnNotification(){if(!("Notification"in window));else if(Notification.permission==="granted"){var now=Date.now();if(lastNotificationSpawn+NOTIFICATION_COOLDOWN","author_icon":sender.icons.image_48,"text":replyTo.raw["text"]|| "","footer":footer,"ts":replyTo.ts};url+="&attachments="+encodeURIComponent(JSON.stringify([attachment]))}xhr.open("POST",url,true);xhr.send(null)}function addReaction(channelId,msgId,reaction){var xhr=new XMLHttpRequest;var url="api/reaction?room="+channelId+"&msg="+msgId+"&reaction="+encodeURIComponent(reaction);xhr.open("POST",url,true);xhr.send(null)} function removeReaction(channelId,msgId,reaction){var xhr=new XMLHttpRequest;var url="api/reaction?room="+channelId+"&msg="+msgId+"&reaction="+encodeURIComponent(reaction);xhr.open("DELETE",url,true);xhr.send(null)};