You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
glowing-bear/min.js

3 lines
54 KiB

!function(){"use strict";var e=angular.module("localStorage",[]);e.factory("$store",["$parse",function(e){var t="undefined"==typeof window.localStorage?void 0:window.localStorage,n=!("undefined"==typeof t||"undefined"==typeof window.JSON);n||console.log("Warning: localStorage is not supported");var i={parseValue:function(e){var t;try{t=JSON.parse(e),void 0===t&&(t=e),"true"===t&&(t=!0),"false"===t&&(t=!1),parseFloat(t)!=t||angular.isObject(t)||(t=parseFloat(t))}catch(n){t=e}return t}},r={set:function(e,r){n||console.log("Local Storage not supported");var o=JSON.stringify(r);return t.setItem(e,o),i.parseValue(o)},get:function(e){if(!n)return null;var r=t.getItem(e);return i.parseValue(r)},remove:function(e){return n?(t.removeItem(e),!0):!1},enumerateKeys:function(){for(var e=[],n=0,i=t.length;i>n;++n)e.push(t.key(n));return e},bind:function(t,n,i){return void 0===i&&(i=""),(void 0===r.get(n)||null===r.get(n))&&r.set(n,i),e(n).assign(t,r.get(n)),t.$watch(n,function(e){r.set(n,e)},!0),r.get(n)}};return r}])}(),function(e){"use strict";!function(){var t=function(){this._types={chr:this._getChar,int:this._getInt,str:this._getString,inf:this._getInfo,hda:this._getHdata,ptr:this._getPointer,lon:this._getStrNumber,tim:this._getTime,buf:this._getString,arr:this._getArray,htb:this._getHashTable,inl:function(){this._warnUnimplemented("infolist")}},this._typesStr={chr:this._strDirect,str:this._strDirect,int:this._strToString,tim:this._strToString,ptr:this._strDirect}};t._weeChatColorsNames=["default","black","darkgray","red","lightred","green","lightgreen","brown","yellow","blue","lightblue","magenta","lightmagenta","cyan","lightcyan","gray","white"],t._colorsOptionsNames=["separator","chat","chat_time","chat_time_delimiters","chat_prefix_error","chat_prefix_network","chat_prefix_action","chat_prefix_join","chat_prefix_quit","chat_prefix_more","chat_prefix_suffix","chat_buffer","chat_server","chat_channel","chat_nick","chat_nick_self","chat_nick_other","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","chat_host","chat_delimiters","chat_highlight","chat_read_marker","chat_text_found","chat_value","chat_prefix_buffer","chat_tags","chat_inactive_window","chat_inactive_buffer","chat_prefix_buffer_inactive_buffer","chat_nick_offline","chat_nick_offline_highlight","chat_nick_prefix","chat_nick_suffix","emphasis","chat_day_change"],t._getDefaultColor=function(){return{type:"weechat",name:"default"}},t._getDefaultAttributes=function(){return{name:null,override:{bold:!1,reverse:!1,italic:!1,underline:!1}}},t._getDefaultStyle=function(){return{fgColor:t._getDefaultColor(),bgColor:t._getDefaultColor(),attrs:t._getDefaultAttributes()}},t._cloneColor=function(e){var t={};for(var n in e)t[n]=e[n];return t},t._cloneAttrs=function(e){var t={};t.name=e.name,t.override={};for(var n in e.override)t.override[n]=e.override[n];return t},t._attrNameFromChar=function(e){var t={"*":"b","!":"r","/":"i",_:"u","":"b","":"r","":"i","":"u"};return e in t?t[e]:null},t._attrsFromStr=function(e){for(var n=t._getDefaultAttributes(),i=0;i<e.length;++i){var r=e.charAt(i);if("|"===r)return null;var o=t._attrNameFromChar(r);null!==o&&(n.override[o]=!0)}return n},t._getColorObj=function(e){if(2===e.length){var n=parseInt(e);return n>16?t._getDefaultColor():{type:"weechat",name:t._weeChatColorsNames[n]}}var i=e.substring(1);return{type:"ext",name:parseInt(i).toString()}},t._getStyle=function(e){var n=[{regex:/^(\d{2})/,fn:function(e){var n={},i=parseInt(e[1]);if(i>43)return{fgColor:null,bgColor:null,attrs:null};var r=t._colorsOptionsNames[i];return n.fgColor={type:"option",name:r},n.bgColor=t._cloneColor(n.fgColor),n.attrs={name:r,override:{}},n}},{regex:/^@(\d{5})/,fn:function(e){return{fgColor:null,bgColor:null,attrs:null}}},{regex:/^F(?:([*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))/,fn:function(e){var n={bgColor:null};return e[2]?(n.attrs=t._attrsFromStr(e[1]),n.fgColor=t._getColorObj(e[2])):(n.attrs=t._attrsFromStr(e[3]),n.fgColor=t._getColorObj(e[4])),n}},{regex:/^B(\d{2}|@\d{5})/,fn:function(e){return{fgColor:null,bgColor:t._getColorObj(e[1]),attrs:null}}},{regex:/^\*(?:([\x01\x02\x03\x04*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5})),(\d{2}|@\d{5})/,fn:function(e){var n={};return e[2]?(n.attrs=t._attrsFromStr(e[1]),n.fgColor=t._getColorObj(e[2])):(n.attrs=t._attrsFromStr(e[3]),n.fgColor=t._getColorObj(e[4])),n.bgColor=t._getColorObj(e[5]),n}},{regex:/^\*([\x01\x02\x03\x04*!\/_|]*)(\d{2}|@\d{5})/,fn:function(e){return{fgColor:t._getColorObj(e[2]),bgColor:null,attrs:t._attrsFromStr(e[1])}}},{regex:/^E/,fn:function(e){var n={};return n.fgColor={type:"option",name:"emphasis"},n.bgColor=t._cloneColor(n.fgColor),n.attrs={name:"emphasis",override:{}},n}}],i={fgColor:null,bgColor:null,attrs:null,text:e};return n.some(function(t){var n=e.match(t.regex);return n?(i=t.fn(n),i.text=e.substring(n[0].length),!0):!1}),i},t.rawText2Rich=function(e){var n=e.split(/(\x19|\x1a|\x1b|\x1c)/);if(1===n.length)return[{attrs:t._getDefaultAttributes(),fgColor:t._getDefaultColor(),bgColor:t._getDefaultColor(),text:n[0]}];var i=t._getDefaultColor(),r=t._getDefaultColor(),o=t._getDefaultAttributes(),a=null,c=!0;return n.map(function(e){if(0===e.length)return null;var n=e.charCodeAt(0),s=e.charAt(0);if(n>=25&&28>=n)return 28===n&&(i=t._getDefaultColor(),r=t._getDefaultColor(),25!==a&&(o=t._getDefaultAttributes())),a=n,null;var u=e;if(25===a){var l=t._getStyle(e);null!==l.fgColor&&(i=l.fgColor),null!==l.bgColor&&(r=l.bgColor),null!==l.attrs&&(o=l.attrs),u=l.text}else if(26===a||27===a){var f=26===a;if("|"!==s){var d=t._attrNameFromChar(s);d&&(o.override[d]=f,u=e.substring(1))}}if(a=null,0===u.length)return null;if(c&&null===o.name){var m=!0;for(var h in o.override)if(o.override[h]){m=!1;break}m?o.override={}:c=!1}return{fgColor:t._cloneColor(i),bgColor:t._cloneColor(r),attrs:t._cloneAttrs(o),text:u}}).filter(function(e){return null!==e})},t._uia2s=function(e){if(!e.length||0===e[0])return"";try{var t=String.fromCharCode.apply(null,e),n=decodeURIComponent(escape(t));return n}catch(t){for(var i="",r=0,o=e.length;o>r;r++)i+=e[r]<128?String.fromCharCode(e[r]):"?";return i}},t._mergeParams=function(e,t){for(var n in t)e[n]=t[n];return e},t._formatCmd=function(e,t,n){var i,r;return i=null!==e?"("+e+") ":"",i+=t,n.unshift(i),r=n.join(" "),r+="\n",r.replace(/[\r\n]+$/g,"").split("\n"),r},t.formatInit=function(e){var n={password:null,compression:"zlib"},i=[],r=[];return e=t._mergeParams(n,e),i.push("compression="+e.compression),null!==e.password&&i.push("password="+e.password),r.push(i.join(",")),t._formatCmd(null,"init",r)},t.formatHdata=function(e){var n={id:null,keys:null},i=[];return e=t._mergeParams(n,e),i.push(e.path),null!==e.keys&&i.push(e.keys.join(",")),t._formatCmd(e.id,"hdata",i)},t.formatInfo=function(e){var n={id:null},i=[];return e=t._mergeParams(n,e),i.push(e.name),t._formatCmd(e.id,"info",i)},t.formatNicklist=function(e){var n={id:null,buffer:null},i=[];return e=t._mergeParams(n,e),null!==e.buffer&&i.push(e.buffer),t._formatCmd(e.id,"nicklist",i)},t.formatInput=function(e){var n={id:null},i=[];return e=t._mergeParams(n,e),i.push(e.buffer),i.push(e.data),t._formatCmd(e.id,"input",i)},t._formatSyncDesync=function(e,n){var i={id:null,buffers:null,options:null},r=[];return n=t._mergeParams(i,n),null!==n.buffers&&(r.push(n.buffers.join(",")),null!==n.options&&r.push(n.options.join(","))),t._formatCmd(n.id,e,r)},t.formatSync=function(e){return t._formatSyncDesync("sync",e)},t.formatDesync=function(e){return t._formatSyncDesync("desync",e)},t.formatTest=function(e){var n={id:null},i=[];return e=t._mergeParams(n,e),t._formatCmd(e.id,"test",i)},t.formatQuit=function(){return t._formatCmd(null,"quit",[])},t.formatPing=function(e){var n={id:null,args:null},i=[];return e=t._mergeParams(n,e),null!==e.args&&i.push(e.args.join(" ")),t._formatCmd(e.id,"ping",i)},t.prototype={_warnUnimplemented:function(e){console.log("Warning: "+e+" message parsing is not implemented")},_getType:function(){var e=this._getSlice(3);return e?t._uia2s(new Uint8Array(e)):null},_runType:function(e){var t=this._types[e],n=t.bind(this);return n()},_getStrNumber:function(){var e=this._getByte(),n=this._getSlice(e);return t._uia2s(new Uint8Array(n))},_strDirect:function(e){return e},_strToString:function(e){return e.toString()},_objToString:function(e,t){var n=this._typesStr[t],i=n.bind(this);return i(e)},_getInfo:function(){var e={};return e.key=this._getString(),e.value=this._getString(),e},_getHdata:function(){function e(){var e={};e.pointers=t.map(function(e){return i._getPointer()}),a.forEach(function(t){e[t[0]]=i._runType(t[1])}),r.push(e)}var t,n,i=this,r=[],o=this._getString(),a=this._getString().split(",");t=o.split("/"),n=this._getInt(),a=a.map(function(e){return e.split(":")});for(var c=0;n>c;c++)e();return r},_getPointer:function(){return this._getStrNumber()},_getTime:function(){var e=this._getStrNumber();return new Date(1e3*parseInt(e,10))},_getInt:function(){var e=new Uint8Array(this._getSlice(4));return(255&e[0])<<24|(255&e[1])<<16|(255&e[2])<<8|255&e[3]},_getByte:function(){var e=new Uint8Array(this._getSlice(1));return e[0]},_getChar:function(){return this._getByte()},_getString:function(){var e=this._getInt();if(e>0){var n=this._getSlice(e),i=new Uint8Array(n);return t._uia2s(i)}return""},_getHeader:function(){var e=this._getInt(),t=this._getByte();return{length:e,compression:t}},_getId:function(){return this._getString()},_getObject:function(){var e=this,t=this._getType();return t?{type:t,content:e._runType(t)}:void 0},_getHashTable:function(){var e,t,n,i=this,r={};e=this._getType(),t=this._getType(),n=this._getInt();for(var o=0;n>o;++o){var a=i._runType(e),c=i._objToString(a,e),s=i._runType(t);r[c]=s}return r},_getArray:function(){var e,t,n,i=this;e=this._getType(),t=this._getInt(),n=[];for(var r=0;t>r;r++)n.push(i._runType(e));return n},_getSlice:function(e){if(this.dataAt+e>this._data.byteLength)return null;var t=this._data.slice(this._dataAt,this._dataAt+e);return this._dataAt+=e,t},_setData:function(e){this._data=e},setId:function(e,t){return"("+e+") "+t},parse:function(e,t){var n=this;this._setData(e),this._dataAt=0;var i=this._getHeader();if(i.compression){var r=new Uint8Array(e,5),o=new Zlib.Inflate(r),a=o.decompress();this._setData(a.buffer),this._dataAt=0}for(var c=this._getId(),s=[],u=this._getObject();u;)s.push(u),u=n._getObject();var l={header:i,id:c,objects:s};return l}},e.Protocol=t}()}("undefined"==typeof exports?this.weeChat={}:exports),function(){"use strict";var e=angular.module("IrcUtils",[]);e.service("IrcUtils",[function(){var e=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},t=function(e){var t=_(e).sortBy(function(e){return-e.spokeAt});return t=_(t).pluck("name")},n=function(e,t){var n=null;return t.some(function(t){return 0===t.toLowerCase().search(e.toLowerCase())?(n=t,!0):!1}),n},i=function(t,n,i){for(var r=[],o=null,a=t.toLowerCase(),c=n.toLowerCase(),s=0;s<i.length;++s){var u=i[s].toLowerCase();0===u.search(e(a))&&(r.push(i[s]),c===u&&(o=r.length-1))}return null===o||0===r.length?n:(++o,o===r.length&&(o=0),r[o])},r=function(r,o,a,c,s){var u=null!==a;null===s&&(s=":");var l=t(c),f=r.substring(0,o),d=r.substring(o),m={text:r,caretPos:o,foundNick:null,iterCandidate:null},h=f.match(new RegExp("^([a-zA-Z0-9_\\\\\\[\\]{}^`|-]+)"+s+" $")),g=null;return h?u?(g=i(a,h[1],l),f=g+s+" ",{text:f+d,caretPos:f.length,foundNick:g,iterCandidate:a}):m:(h=f.match(/^([a-zA-Z0-9_\\\[\]{}^`|-]+)$/))?(g=n(e(h[1]),l),null===g?m:(f=g+s+" "," "===d[0]&&(d=d.substring(1)),{text:f+d,caretPos:f.length,foundNick:g,iterCandidate:h[1]})):(h=f.match(/^(.* )([a-zA-Z0-9_\\\[\]{}^`|-]+) $/))?u?(g=i(a,h[2],l),f=h[1]+g+" ",{text:f+d,caretPos:f.length,foundNick:g,iterCandidate:a}):m:(h=f.match(/^(.* )([a-zA-Z0-9_\\\[\]{}^`|-]+)$/),h?(g=n(h[2],l),null===g?m:(f=h[1]+g+" "," "===d[0]&&(d=d.substring(1)),{text:f+d,caretPos:f.length,foundNick:g,iterCandidate:h[2]})):m)};return{completeNick:r}}])}(),function(){"use strict";var e=angular.module("weechat",["ngRoute","localStorage","weechatModels","plugins","IrcUtils","ngSanitize","ngWebsockets","ngTouch"],["$compileProvider",function(t){e.compileProvider=t}]);e.config(["$compileProvider",function(e){"undefined"==typeof it&&"undefined"==typeof describe&&e.debugInfoEnabled(!1)}]),e.controller("WeechatCtrl",["$rootScope","$scope","$store","$timeout","$log","models","connection","notifications","utils","settings",function(t,n,i,r,o,a,c,s,u,l){window.openBuffer=function(e){n.openBuffer(e),n.$apply()},n.command="",n.themes=["dark","light"],l.setDefaults({theme:"dark",host:"localhost",port:9001,ssl:"https:"===window.location.protocol,savepassword:!1,autoconnect:!1,nonicklist:u.isMobileUi(),noembed:!0,onlyUnread:!1,hotlistsync:!0,orderbyserver:!0,useFavico:!0,showtimestamp:!0,showtimestampSeconds:!1,fontsize:"14px",fontfamily:u.isMobileUi()?"sans-serif":"Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace",readlineBindings:!1,enableJSEmoji:u.isMobileUi()?!1:!0,enableMathjax:!1}),n.settings=l,t.countWatchers=function(){for(var e,n=[t],i=0;n.length>0;)e=n.pop(),e.$$watchers&&(i+=e.$$watchers.length),e.$$childHead&&n.push(e.$$childHead),e.$$nextSibling&&n.push(e.$$nextSibling);o.debug(i)},n.isinstalled=function(){return void 0===navigator.mozApps?!1:void(navigator.mozApps.getSelf().onsuccess=function(e){var t=e.target.result;return t?!0:!1})}(),function(){"undefined"!=typeof document.hidden?(n.documentHidden="hidden",n.documentVisibilityChange="visibilitychange"):"undefined"!=typeof document.webkitHidden?(n.documentHidden="webkitHidden",n.documentVisibilityChange="webkitvisibilitychange"):"undefined"!=typeof document.mozHidden?(n.documentHidden="mozHidden",n.documentVisibilityChange="mozvisibilitychange"):"undefined"!=typeof document.msHidden&&(n.documentHidden="msHidden",n.documentVisibilityChange="msvisibilitychange")}(),function(){window.location.search.substring(1).split("&").forEach(function(e){var n=e.split("=");"debug"===n[0]&&-1!=["true","1"].indexOf(n[1])&&(t.debugMode=!0)}),t.debugMode&&!e.compileProvider.debugInfoEnabled()&&angular.reloadWithDebugInfo()}(),t.isWindowFocused=function(){if("undefined"==typeof n.documentHidden)return!0;var e=document[n.documentHidden];return!e},"undefined"!=typeof n.documentVisibilityChange&&document.addEventListener(n.documentVisibilityChange,function(){if(!document[n.documentHidden]){var e=a.getActiveBuffer();null!==e&&(e.unread=0,e.notification=0,t.$emit("notificationChanged")),t.$apply()}},!1),t.$on("activeBufferChanged",function(e,i){var o=a.getActiveBuffer(),f=o.lines.length-i+5,d=o.lines.length-(2*n.lines_per_screen+10),m=Math.min(f,d);if(m>0&&(o.lines.splice(0,m),o.requestedLines-=m,o.lastSeen-=m,o.allLinesFetched=!1),n.bufferlines=o.lines,n.nicklist=o.nicklist,o.nicklistRequested()?n.showNicklist=n.updateShowNicklist():c.requestNicklist(o.fullName,function(){n.showNicklist=n.updateShowNicklist(),t.scrollWithBuffer(!0)}),o.requestedLines<n.lines_per_screen){var h=n.lines_per_screen+10;i>h&&(h=Math.min(4*h,i)),n.fetchMoreLines(h).then(function(){r(function(){var e=document.getElementById("bufferlines"),n=e.scrollHeight,i=function(){if(e){var r=e.scrollHeight;r!==n&&(t.updateBufferBottom(t.bufferBottom),n=r),setTimeout(i,500)}};t.updateBufferBottom(!0),t.scrollWithBuffer(!0),e.onscroll=_.debounce(function(){t.updateBufferBottom()},80),setTimeout(i,500)})})}s.updateTitle(o),n.notifications=s.unreadCount("notification"),n.unread=s.unreadCount("unread"),r(function(){t.scrollWithBuffer(!0)}),n.search="",u.isMobileUi()||setTimeout(function(){document.getElementById("sendMessage").focus()},0),l.hotlistsync&&o.fullName&&c.sendHotlistClear()}),t.favico=new Favico({animation:"none"}),n.notifications=s.unreadCount("notification"),n.unread=s.unreadCount("unread"),t.$on("notificationChanged",function(){s.updateTitle(),n.notifications=s.unreadCount("notification"),n.unread=s.unreadCount("unread"),l.useFavico&&t.favico&&s.updateFavico()}),t.$on("relayDisconnect",function(){t.pageTitle="",t.notificationStatus="",s.cancelAll(),a.reinitialize(),t.$emit("notificationChanged"),n.connectbutton="Connect"}),n.connectbutton="Connect",n.getBuffers=a.getBuffers.bind(a),n.bufferlines={},n.nicklist={},n.activeBuffer=a.getActiveBuffer,t.connected=!1,t.waseverconnected=!1,t.userdisconnect=!1,t.reconnecting=!1,t.models=a,t.iterCandidate=null,l.savepassword?(n.$watch("password",function(){l.password=n.password}),l.addCallback("password",function(e){n.password=e}),n.password=l.password):l.password="",l.addCallback("savepassword",function(e){l.savepassword&&(l.setDefaults({password:n.password}),l.password=n.password)}),t.wasMobileUi=!1,u.isMobileUi()&&(t.wasMobileUi=!0),l.fontfamily||(u.isMobileUi()?l.fontfamily="sans-serif":l.fontfamily="Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace"),n.isSidebarVisible=function(){return"visible"===document.getElementById("content").getAttribute("sidebar-state")},n.showSidebar=function(){document.getElementById("sidebar").setAttribute("data-state","visible"),document.getElementById("content").setAttribute("sidebar-state","visible"),u.isMobileUi()&&_.each(document.getElementsByTagName("textarea"),function(e){r(function(){e.blur()})})},t.hideSidebar=function(){u.isMobileUi()&&(document.getElementById("sidebar").setAttribute("data-state","hidden"),document.getElementById("content").setAttribute("sidebar-state","hidden"))},l.addCallback("autoconnect",function(e){!e||t.connected||t.sslError||t.securityError||t.errorMessage||n.connect()}),n.toggleSidebar=function(){u.isMobileUi()&&(n.isSidebarVisible()?n.hideSidebar():n.showSidebar())},n.openNick=function(){u.isMobileUi()&&l.nonicklist&&(l.nonicklist=!1)},n.closeNick=function(){u.isMobileUi()&&(l.nonicklist||(l.nonicklist=!0))},l.addCallback("orderbyserver",function(e){t.predicate=e?"serverSortKey":"number"}),l.addCallback("useFavico",function(e){t.connected&&(e?s.updateFavico():t.favico.reset())}),l.addCallback("enableMathjax",function(e){e&&!t.mathjax_init&&(t.mathjax_init=!0,function(){var e,t=document.getElementsByTagName("head")[0];e=document.createElement("script"),e.type="text/x-mathjax-config",e[window.opera?"innerHTML":"text"]="MathJax.Hub.Config({\n tex2jax: { inlineMath: [['$$','$$'], ['\\\\(','\\\\)']], displayMath: [['\\\\[','\\\\]']] },\n});",t.appendChild(e),e=document.createElement("script"),e.type="text/javascript",e.src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML",t.appendChild(e)}())}),l.addCallback("theme",function(e){var t=document.getElementById("themeCSS");t&&t.parentNode.removeChild(t),function(){var t=document.createElement("link");t.rel="stylesheet",t.href="css/themes/"+e+".css",t.media="screen",t.id="themeCSS",document.getElementsByTagName("head")[0].appendChild(t)}()}),l.addCallback("fontfamily",function(e){u.changeClassStyle("favorite-font","fontFamily",e)}),l.addCallback("fontsize",function(e){u.changeClassStyle("favorite-font","fontSize",e)}),n.setActiveBuffer=function(e,t){return u.isMobileUi()&&n.hideSidebar(),a.version[0]>=1&&c.sendHotlistClear(),a.setActiveBuffer(e,t)},n.openBuffer=function(e){var t=a.getActiveBuffer().fullName;if(t=t.substring(0,t.lastIndexOf(".")+1)+e,!n.setActiveBuffer(t,"fullName")){var i="join -noswitch";["#","&","+","!"].indexOf(e.charAt(0))<0&&(i="query",(1==a.version[0]&&a.version[1]>=2||a.version[1]>1)&&(i+=" -noswitch")),c.sendMessage("/"+i+" "+e)}},n.calculateNumLines=function(){for(var e=document.querySelectorAll(".bufferline"),t=0,i=0;0===t&&i<e.length;)t=e[i++].clientHeight;var r=document.querySelector("#bufferlines").clientHeight,o=Math.ceil(r/t+10);n.lines_per_screen=o},n.calculateNumLines(),window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame,window.addEventListener("resize",_.debounce(function(){if(t.connected&&(n.wasMobileUi&&!u.isMobileUi()&&n.showSidebar(),n.wasMobileUi=u.isMobileUi(),n.calculateNumLines(),t.bufferBottom)){var e=function(){t.updateBufferBottom(!0)};r(e,500),window.requestAnimationFrame(e)}},100)),t.loadingLines=!1,n.fetchMoreLines=function(e){return e||(e=n.lines_per_screen),c.fetchMoreLines(e)},t.updateBufferBottom=function(e){var n=document.getElementById("end-of-buffer"),i=document.getElementById("bufferlines");e&&n.scrollIntoView(),t.bufferBottom=n.offsetTop<=i.scrollTop+i.clientHeight},t.scrollWithBuffer=function(e,n){var i=document.getElementById("bufferlines"),o=i.scrollHeight-i.clientHeight,a=function(){var r=i.scrollTop;if((e||n)&&o>r||Math.abs(r-o)<3){var a=document.querySelector(".readmarker");if(e&&a)i.scrollTop=a.offsetTop-a.parentElement.scrollHeight+a.scrollHeight;else if(n)i.scrollTop=i.scrollHeight-i.clientHeight-o;else{var c=document.getElementById("end-of-buffer");c.scrollIntoView()}t.updateBufferBottom()}};r(a),window.requestAnimationFrame(a)},n.connect=function(){s.requestNotificationPermission(),t.sslError=!1,t.securityError=!1,t.errorMessage=!1,t.bufferBottom=!0,n.connectbutton="Connecting ...",c.connect(l.host,l.port,n.password,l.ssl)},n.disconnect=function(){n.connectbutton="Connect",c.disconnect()},n.reconnect=function(){var e=a.getActiveBuffer().id;c.attemptReconnect(e,3e3)},n.install=function(){if(void 0!==navigator.mozApps){var e=location.protocol+"//"+location.host+location.pathname.replace(/\/(index\.html)?$/,""),t=navigator.mozApps.install(e+"/manifest.webapp");t.onsuccess=function(){n.isinstalled=!0;var e=this.result;e.launch(),alert("Installation successful!")},t.onerror=function(){alert("Install failed, error: "+this.error.name)}}else alert("Sorry. Only supported in Firefox v26+")},n.showModal=function(e){document.getElementById(e).setAttribute("data-state","visible")},n.closeModal=function(e){function t(e,t){for(var n=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector;e;){if(n.call(e,t))return e;e=e.parentElement}}t(e.target,".gb-modal").setAttribute("data-state","hidden")},n.toggleAccordion=function(e){e.stopPropagation(),e.preventDefault();var t=e.target.parentNode.parentNode.parentNode;t.setAttribute("data-state","active"===t.getAttribute("data-state")?"collapsed":"active");var n=t.parentNode.children;for(var i in n){var r=n[i];1===r.nodeType&&r!==t&&r.setAttribute("data-state","collapsed")}},n.hasUnread=function(e){return n.search&&""!==n.search?!0:l.onlyUnread?a.getActiveBuffer()===e?!0:"core.weechat"===e.fullName||l.orderbyserver&&"server"===e.type?!0:(e.unread>0||e.notification>0)&&!e.hidden:!e.hidden},l.addCallback("nonicklist",function(){n.showNicklist=n.updateShowNicklist(),t.connected&&t.bufferBottom&&r(function(){t.updateBufferBottom(!0)},500)}),n.showNicklist=!1,n.updateShowNicklist=function(){var e=a.getActiveBuffer();return e?l.nonicklist?!1:e.isNicklistEmpty()?!1:!0:!1},t.switchToActivityBuffer=function(){var e,t,i=_.sortBy(n.getBuffers(),"number");for(e in i)if(t=i[e],t.notification>0)return void n.setActiveBuffer(t.id);for(e in i)if(t=i[e],t.unread>0)return void n.setActiveBuffer(t.id)},t.toggleNicklist=function(){l.nonicklist=!l.nonicklist},n.handleSearchBoxKey=function(e){var t=e.keyCode?e.keyCode:e.charCode;27===t?(e.preventDefault(),n.search=""):13===t&&(e.preventDefault(),n.filteredBuffers.length>0&&n.setActiveBuffer(n.filteredBuffers[0].id),n.search="")},window.onbeforeunload=function(e){null!==n.command&&""!==n.command?(e.preventDefault(),e.returnValue="Any unsent input will be lost. Are you sure that you want to quit?"):(t.connected&&n.disconnect(),n.favico.reset())},n.init=function(){if(window.location.hash){var e=atob(window.location.hash.substring(1));window.location.hash="";var i=e.split(":"),r=i[0],o=parseInt(i[1]),a=i[2],u=i.length>3;s.requestNotificationPermission(),t.sslError=!1,t.securityError=!1,t.errorMessage=!1,t.bufferBottom=!0,n.connectbutton="Connecting ...",c.connect(r,o,a,u)}}}]),e.config(["$routeProvider",function(e){e.when("/",{templateUrl:"index.html",controller:"WeechatCtrl"})}])}(),function(){"use strict";var e=angular.module("weechat");e.factory("settings",["$store","$rootScope",function(e,t){var n=this;this.callbacks={},this.cache={};var i=function(i){Object.defineProperty(n,i,{enumerable:!0,key:i,get:function(){return i in this.cache||(this.cache[i]=e.get(i)),this.cache[i]},set:function(r){this.cache[i]=r,e.set(i,r);for(var o=n.callbacks[i],a=0;void 0!==o&&a<o.length;a++)o[a](r);setTimeout(function(){t.$apply()},0)}})},r=e.enumerateKeys();for(var o in r){var a=r[o];i(a)}return this.addCallback=function(t,n,i){void 0===this.callbacks[t]?this.callbacks[t]=[n]:this.callbacks[t].push(n),setTimeout(function(){n(e.get(t))},0)},this.setDefaults=function(t){for(var n in t)null===e.get(n)&&(i(n),this[n]=t[n])},this}])}();var weechat=angular.module("weechat");weechat.factory("utils",function(){var e=function(e,t,n){_.each(document.getElementsByClassName(e),function(e){e.style[t]=n})},t=function(e,t){_.each(document.getElementsByClassName(e),function(e){return e.style[t]})},n=function(){var e=968;return document.body.clientWidth<e};return{changeClassStyle:e,getClassStyle:t,isMobileUi:n}});var weechat=angular.module("weechat");weechat.factory("notifications",["$rootScope","$log","models","settings",function(e,t,n,i){var r=[],o=function(){if(window.Notification&&Notification.requestPermission(function(e){t.info("Notification permission status: ",e),Notification.permission!==e&&(Notification.permission=e)}),void 0!==window.webkitNotifications){var e=window.webkitNotifications.checkPermission();0!==e&&(t.info("Notification permission status: ",0===e),window.webkitNotifications.requestPermission())}},a=function(e){e||(e="unread");var t=Object.keys(n.model.buffers),i=0;for(var r in t)i+=n.model.buffers[t[r]][e];return i},c=function(){var t=a("notification");t>0?e.notificationStatus="("+t+") ":e.notificationStatus="";var i=n.getActiveBuffer();i&&(e.pageTitle=i.shortName+" | "+i.rtitle)},s=function(){var t=a("notification");if(t>0)e.favico.badge(t,{bgColor:"#d00",textColor:"#fff"});else{var n=a("unread");0===n?e.favico.reset():e.favico.badge(n,{bgColor:"#5CB85C",textColor:"#ff0"})}},u=function(e,t){var o="",a="",c=e.notification;if(["#","&","+","!"].indexOf(e.shortName.charAt(0))<0)o=c>1?c.toString()+" private messages from ":"Private message from ",a=t.text;else{o=c>1?c.toString()+" highlights in ":"Highlight in ";for(var s="",u=0;u<t.prefix.length;u++)s+=t.prefix[u].text;a="<"+s+"> "+t.text}o+=e.shortName,o+=e.fullName.replace(/irc.([^\.]+)\..+/," ($1)");var l=new Notification(o,{body:a,icon:"assets/img/favicon.png"});l.id=r.length,r.push(l);var f=15e3;if(l.onshow=function(){setTimeout(function(){l.close()},f)},l.onclick=function(){n.setActiveBuffer(e.id),window.focus(),l.close()},l.onclose=function(){delete r[this.id]},i.soundnotification){var d="assets/audio/sonar",m='<audio autoplay="autoplay"><source src="'+d+'.ogg" type="audio/ogg" /><source src="'+d+'.mp3" type="audio/mpeg" /></audio>';document.getElementById("soundNotification").innerHTML=m}},l=function(){for(;r.length>0;){var e=r.pop();void 0!==e&&e.close()}};return{requestNotificationPermission:o,updateTitle:c,updateFavico:s,createHighlight:u,cancelAll:l,unreadCount:a}}]),function(){"use strict";var e=angular.module("weechat");e.filter("toArray",function(){return function(e,t){return e instanceof Object?t?Object.keys(e).map(function(t,n){return Object.defineProperties(e[t],{$key:{value:t},$idx:{value:n,configurable:!0}})}):Object.keys(e).map(function(t){return Object.defineProperty(e[t],"$key",{value:t})}):e}}),e.filter("irclinky",function(){return function(e){if(!e)return e;var t=/(^|[\s,.:;?!"'()+@-\~%])(#+[^\x00\x07\r\n\s,:]*[a-z][^\x00\x07\r\n\s,:]*)/gim,n='$1<a href="#" onclick="openBuffer(\'$2\');">$2</a>';return e.replace(t,n)}}),e.filter("inlinecolour",function(){return function(e){if(!e)return e;var t=/(^|[^&])(\#[0-9a-f]{6};?)(?!\w)/gim,n=/(.?)(rgba?\((?:\s*\d+\s*,){2}\s*\d+\s*(?:,\s*[\d.]+\s*)?\);?)/gim,i='$1$2 <div class="colourbox" style="background-color:$2"></div>';return e=e.replace(t,i),e=e.replace(n,i)}}),e.filter("DOMfilter",["$filter","$sce",function(e,t){return function(n,i){if(!n||!i)return n;var r=function(e){var t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","&":"&amp;","/":"&#x2F;"};return e.replace(/[<>"'&\/]/g,function(e){return t[e]})},o=arguments.length>2?arguments[2]:null,a=arguments.length>3?arguments[3]:null,c=e(i),s=document.createElement("div");s.innerHTML=n;var u=function(e){if(3===e.nodeType){var t=r(e.nodeValue),n=c(t,o,a);if(n!==t){var i=document.createElement("span");i.innerHTML=n;var s=e.parentNode,l=e.nextSibling;return s.removeChild(e),l?s.insertBefore(i,l):s.appendChild(i),i}}if(void 0!==e&&null!==e)for(e=e.firstChild;e;){var f=u(e);e=(f?f:e).nextSibling}};return u(s),t.trustAsHtml(s.innerHTML)}}]),e.filter("getBufferQuickKeys",function(){return function(e,t){return t?(void 0!==t.search&&t.search.length||t.onlyUnread?e.forEach(function(e,t){e.$quickKey=10>t?(t+1)%10:""}):_.map(e,function(e,t){return[e.number,e.$idx,t]}).sort(function(e,t){return e[0]-t[0]||e[1]-t[1]}).forEach(function(t,n){e[t[2]].$quickKey=10>n?(n+1)%10:""}),e):e}}),e.filter("emojify",function(){return function(e,t){return t===!0&&void 0!==window.emojione?emojione.unicodeToImage(e):e}}),e.filter("mathjax",function(){return function(e,t,n){if(!n||"undefined"==typeof MathJax)return e;if(-1!=e.indexOf("$$")||-1!=e.indexOf("\\[")||-1!=e.indexOf("\\(")){var i=document.querySelector(t);MathJax.Hub.Queue(["Typeset",MathJax.Hub,i])}return e}}),e.filter("prefixlimit",function(){return function(e,t){return isNaN(t)?e:0>=t?"":e&&e.length>t?(e=e.substring(0,t),e+"+"):e}})}(),function(){"use strict";var e=angular.module("weechat");e.factory("handlers",["$rootScope","$log","models","plugins","notifications",function(e,t,n,i,r){var o=function(e){var t=e.objects[0].content,i=t.value;n.version=i.split(".").map(function(e){return parseInt(e)})},a=function(e){var t=e.objects[0].content[0],i=t.pointers[0];n.closeBuffer(i)},c=function(t,o){var a=new n.BufferLine(t),c=n.getBuffer(a.buffer);c.requestedLines++,a.displayed&&(a=i.PluginManager.contentForMessage(a),c.addLine(a),o&&c.lastSeen++,c.active&&!o&&e.scrollWithBuffer(),o||c.active&&e.isWindowFocused()||(c.notify>1&&_.contains(a.tags,"notify_message")&&!_.contains(a.tags,"notify_none")&&(c.unread++,e.$emit("notificationChanged")),(0!==c.notify&&a.highlight||_.contains(a.tags,"notify_private"))&&(c.notification++,r.createHighlight(c,a),e.$emit("notificationChanged"))))},s=function(e){for(var t=e.objects[0].content,i=0;i<t.length;i++){var r=t[i].pointers[0],o=n.getBuffer(r);void 0!==o?u(o,t[i]):(o=new n.Buffer(t[i]),n.addBuffer(o),0===i&&n.setActiveBuffer(o.id))}},u=function(e,t){t.pointers[0]===e.id&&(e.shortName=t.short_name,e.trimmedName=e.shortName.replace(/^[#&+]/,""),e.title=t.title,e.number=t.number,e.hidden=t.hidden,e.notification=0,e.unread=0,e.lastSeen=-1,void 0!==t.local_variables.type&&(e.type=t.local_variables.type,e.indent=["channel","private"].indexOf(e.type)>=0),void 0!==t.notify&&(e.notify=t.notify))},l=function(e){e.objects[0].content.forEach(function(e){c(e,!1)})},f=function(e){var t=e.objects[0].content[0],i=new n.Buffer(t);n.addBuffer(i)},d=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i);r.fullName=t.full_name,r.title=n.parseRichText(t.title),r.number=t.number,r.rtitle="";for(var o=0;o<r.title.length;++o)r.rtitle+=r.title[o].text},m=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i);r.fullName=t.full_name,r.shortName=t.short_name,r.trimmedName=t.short_name.replace(/^[#&+]/,"")||(t.short_name?" ":null),r.prefix=["#","&","+"].indexOf(t.short_name.charAt(0))>=0?t.short_name.charAt(0):"";var o=n.outgoingQueries.indexOf(r.shortName);o>=0&&(n.outgoingQueries.splice(o,1),n.setActiveBuffer(r.id))},h=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i);r.hidden=!0},g=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i);r.hidden=!1},p=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i),o=t.local_variables;
void 0!==r&&void 0!==o&&(r.type=o.type,r.indent=["channel","private"].indexOf(o.type)>=0)},v=function(e,t){var n=e.objects[0].content.reverse();void 0===t&&(t=!0),n.forEach(function(e){c(e,t)})},b=function(e){if(0!==e.objects.length){var t=e.objects[0].content;t.forEach(function(e){var t=n.getBuffer(e.buffer);t.unread+=e.count[1],t.notification+=e.count[2],t.notification+=e.count[3];var i=_.reduce(e.count,function(e,t){return e+t},0);t.lastSeen=t.lines.length-1-i})}},y=function(e){var t=e.objects[0].content,i="root";t.forEach(function(e){var t=n.getBuffer(e.pointers[0]);if(1===e.group){var r=new n.NickGroup(e);i=r.name,t.nicklist[i]=r}else{var o=new n.Nick(e);t.addNick(i,o)}})},w=function(e){var t,i=e.objects[0].content;i.forEach(function(e){var i=n.getBuffer(e.pointers[0]),r=e._diff;if(1===e.group){if(t=e.name,void 0===t){var o=new n.NickGroup(e);i.nicklist[t]=o,t=o.name}}else{var a=new n.Nick(e);43===r?i.addNick(t,a):45===r?i.delNick(t,a):42===r&&i.updateNick(t,a)}})},C={_buffer_closing:a,_buffer_line_added:l,_buffer_localvar_added:p,_buffer_localvar_removed:p,_buffer_localvar_changed:p,_buffer_opened:f,_buffer_title_changed:d,_buffer_renamed:m,_buffer_hidden:h,_buffer_unhidden:g,_nicklist:y,_nicklist_diff:w};e.$on("onMessage",function(e,n){_.has(C,n.id)?C[n.id](n):t.debug("Unhandled event received: "+n.id)});var k=function(e){_.has(C,e.id)&&C[e.id](e)};return{handleVersionInfo:o,handleEvent:k,handleLineInfo:v,handleHotlistInfo:b,handleNicklist:y,handleBufferInfo:s}}])}(),function(){"use strict";var e=angular.module("weechat");e.factory("connection",["$rootScope","$log","handlers","models","ngWebsockets",function(e,t,n,i,r){var o,a=new weeChat.Protocol,c=[],s=function(i,o,s,u,f,d,m){c=[i,o,s,u,f];var h=u?"wss":"ws";-1!==i.indexOf(":")&&(i="["+i+"]");var g=h+"://"+i+":"+o+"/weechat";t.debug("Connecting to URL: ",g);var p=function(){var i=function(e){return r.send(weeChat.Protocol.formatInit({password:e,compression:f?"off":"zlib"})),r.send(weeChat.Protocol.formatInfo({name:"version"}))},o=function(){return r.send(weeChat.Protocol.formatHdata({path:"hotlist:gui_hotlist(*)",keys:[]}))},a=function(){return r.send(weeChat.Protocol.formatHdata({path:"buffer:gui_buffers(*)",keys:["local_variables,notify,number,full_name,short_name,title,hidden"]}))},c=function(){return r.send(weeChat.Protocol.formatSync({}))};i(s).then(function(i){n.handleVersionInfo(i),a().then(function(e){n.handleBufferInfo(e)}),o().then(function(e){n.handleHotlistInfo(e),d&&d()}),c(),t.info("Connected to relay"),e.connected=!0},function(){e.waseverconnected||(e.passwordError=!0)})},v=function(){e.waseverconnected=!0},b=function(n){t.info("Disconnected from relay"),e.userdisconnect||!e.waseverconnected?(y(n),e.userdisconnect=!1):l(n)},y=function(t){u&&t&&1006===t.code&&"undefined"!=typeof e.lastError&&Date.now()-e.lastError<1e3&&(e.sslError=!0,e.$apply())},_=function(n){t.error("Relay error",n),e.lastError=Date.now(),"error"===n.type&&1!==this.readyState&&(r.failCallbacks("error"),e.errorMessage=!0)};try{r.connect(g,a,{binaryType:"arraybuffer",onopen:p,onclose:b,onmessage:v,onerror:_})}catch(n){t.debug("Websocket caught DOMException:",n),e.lastError=Date.now(),e.errorMessage=!0,e.securityError=!0,e.$emit("relayDisconnect"),m&&m()}},u=function(n,r){t.info("Attempting to reconnect...");var a=c;s(a[0],a[1],a[2],a[3],a[4],function(){e.reconnecting=!1,i.setActiveBuffer(n),t.info("Sucessfully reconnected to relay")},function(){r>=6e5?(t.info("Failed to reconnect, giving up"),handleClose()):(t.info("Failed to reconnect, scheduling next attempt in",r/1e3,"seconds"),void 0!==o&&clearTimeout(o),o=setTimeout(function(){u(n,1.5*r)},r))})},l=function(n){if(c.length<5)return void t.error("Cannot reconnect, connection information is missing");i.reinitialize(),e.reconnecting=!0,e.$apply();var r=i.getActiveBuffer().id,a=3e3;o=setTimeout(function(){u(r,a)},a)},f=function(){t.info("Disconnecting from relay"),e.userdisconnect=!0,r.send(weeChat.Protocol.formatQuit());setTimeout(function(){r.disconnect(),r.failCallbacks("disconnection"),e.connected=!1,e.$emit("relayDisconnect"),e.$apply()})},d=function(e){r.send(weeChat.Protocol.formatInput({buffer:i.getActiveBufferReference(),data:e}))},m=function(e){r.send(weeChat.Protocol.formatInput({buffer:"core.weechat",data:e}))},h=function(){i.version[0]>=1?(d("/buffer set hotlist -1"),d("/input set_unread_current_buffer")):m("/buffer "+i.getActiveBuffer().fullName)},g=function(e,t){e=e||null,r.send(weeChat.Protocol.formatNicklist({buffer:e})).then(function(e){n.handleNicklist(e),void 0!==t&&t()})},p=function(o){t.debug("Fetching ",o," lines");var a=i.getActiveBuffer();return void 0===o&&(o=0),o=Math.max(o,2*a.requestedLines),e.loadingLines=!0,r.send(weeChat.Protocol.formatHdata({path:"buffer:0x"+a.id+"/own_lines/last_line(-"+o+")/data",keys:[]})).then(function(t){var i=a.lines.length,r=a.lastSeen>=0;a.lines.length=0,a.requestedLines=0;var c=t.objects[0].content.length;n.handleLineInfo(t,!0),a.lastSeen-=i,o>c&&(a.allLinesFetched=!0),e.loadingLines=!1;var s=!r&&a.lastSeen>=0;e.scrollWithBuffer(s,!0)})};return{connect:s,disconnect:f,sendMessage:d,sendCoreCommand:m,sendHotlistClear:h,fetchMoreLines:p,requestNicklist:g,attemptReconnect:u}}])}(),function(){"use strict";var e=angular.module("weechat");e.directive("inputBar",function(){return{templateUrl:"directives/input.html",scope:{inputId:"@inputId",command:"=command"},controller:["$rootScope","$scope","$element","$log","connection","models","IrcUtils","settings",function(e,t,n,i,r,o,a,c){t.inputChanged=function(){t.command=emojione.shortnameToUnicode(t.command)},t.getInputNode=function(){return document.querySelector("textarea#"+t.inputId)},t.hideSidebar=function(){e.hideSidebar()},t.completeNick=function(){var e=t.getInputNode(),n=e.selectionStart,i=o.getActiveBuffer(),r=t.command||"",c=a.completeNick(r,n,t.iterCandidate,i.getNicklistByTime(),":");t.iterCandidate=c.iterCandidate,t.command=c.text,setTimeout(function(){e.focus(),e.setSelectionRange(c.caretPos,c.caretPos)},0)},t.sendMessage=function(){var e=o.getActiveBuffer();if(void 0!==t.command&&""!==t.command){e.addToHistory(t.command),_.each(t.command.split(/\r?\n/),function(e){("/quit"!==e&&0!==e.indexOf("/quit ")||window.confirm("Are you sure you want to quit WeeChat? This will prevent you from connecting with Glowing Bear until you restart WeeChat on the command line!"))&&r.sendMessage(e)}),("/buffer clear"===t.command||"/c"===t.command)&&(i.debug("Clearing lines"),e.clear());var n=["/query","/join","/j","/q"],a=t.command.indexOf(" "),c=t.command.substr(0,a),s=n.indexOf(c);if(s>=0){var u=t.command.substring(a+1);o.outgoingQueries.push(u)}t.command=""}o.version[0]>=1&&r.sendHotlistClear(),t.getInputNode().focus()},e.addMention=function(e){var n=e[e.length-1].text,i=t.command||"",r=0===i.length;if(i.length>0){var a=i.trim();if(":"===a.charAt(a.length-1)){var c=a.lastIndexOf(" ")+1,s=a.slice(c,a.length-1),u=o.getActiveBuffer().getNicklistByTime();for(var l in u)if(u[l].name===s){i=i.slice(0,i.lastIndexOf(":"))+" ",r=!0;break}}" "!==i.charAt(i.length-1)&&(i+=" ")}i+=n,r&&(i+=": "),t.command=i,t.getInputNode().focus()},e.handleKeyPress=function(n){if(!e.connected)return!0;var i=t.getInputNode(),a=n.keyCode?n.keyCode:n.charCode,s=n.getModifierState?n.getModifierState("AltGraph"):!1;if(s)return!1;e.showQuickKeys=!1;var u=t.iterCandidate;if(t.iterCandidate=null,n.altKey&&!n.ctrlKey&&a>47&&58>a){48===a&&(a=58);var l,f=a-48-1;if((t.$parent.search.length||t.$parent.onlyUnread)&&t.$parent.filteredBuffers.length){var d=t.$parent.filteredBuffers[f];void 0!==d&&(l=[d.number,d.id])}else{var m=_.map(o.getBuffers(),function(e){return[e.number,e.id]}).sort(function(e,t){return e[0]-t[0]});l=m[f]}l&&(t.$parent.setActiveBuffer(l[1]),n.preventDefault())}if(9===a&&!n.altKey&&!n.ctrlKey)return n.preventDefault(),t.iterCandidate=u,t.completeNick(),!0;if(n.altKey&&!n.ctrlKey&&78===a)return n.preventDefault(),e.toggleNicklist(),!0;if(n.altKey&&(97===a||65===a))return n.preventDefault(),e.switchToActivityBuffer(),!0;if(n.altKey&&(76===a||108===a))return n.preventDefault(),i.focus(),i.setSelectionRange(t.command.length,t.command.length),!0;if(n.altKey&&(60===a||226===a)){var h=o.getPreviousBuffer();if(h)return o.setActiveBuffer(h.id),n.preventDefault(),!0}if(27===a){n.preventDefault();for(var g=document.querySelectorAll(".gb-modal"),p=0;p<g.length;p++)if("visible"===g[p].getAttribute("data-state"))return g[p].setAttribute("data-state","hidden"),!0;return"undefined"!=typeof t.lastEscape&&Date.now()-t.lastEscape<=500&&r.disconnect(),t.lastEscape=Date.now(),!0}if(n.altKey&&(103===a||71===a))return n.preventDefault(),t.$parent.isSidebarVisible()||t.$parent.showSidebar(),setTimeout(function(){document.getElementById("bufferFilter").focus()}),!0;var v;if("keydown"===n.type&&38===a&&document.activeElement===i)return v=i.selectionStart,-1!==t.command.slice(0,v).indexOf("\n")?!1:(t.command=o.getActiveBuffer().getHistoryUp(t.command),setTimeout(function(){t.command&&i.setSelectionRange(t.command.length,t.command.length)},0),!0);if("keydown"===n.type&&40===a&&document.activeElement===i)return v=i.selectionStart,-1!==t.command.slice(v).indexOf("\n")?!1:(t.command=o.getActiveBuffer().getHistoryDown(t.command),!0);if(13==a&&!n.shiftKey&&document.activeElement===i)return n.preventDefault(),t.sendMessage(),!0;var b,y,w=document.getElementById("bufferlines");if("keydown"===n.type&&33===a&&document.activeElement===i&&!n.ctrlKey&&!n.altKey&&!n.shiftKey){if(0===w.scrollTop)return e.loadingLines||t.$parent.fetchMoreLines(),!0;for(b=w.querySelectorAll("tr"),y=b.length-1;y>=0;y--)if(b[y].offsetTop-w.scrollTop<w.clientHeight/2){b[y].scrollIntoView(!1);break}return!0}if("keydown"===n.type&&34===a&&document.activeElement===i&&!n.ctrlKey&&!n.altKey&&!n.shiftKey){for(b=w.querySelectorAll("tr"),y=0;y<b.length;y++)if(b[y].offsetTop-w.scrollTop>w.clientHeight/2){b[y].scrollIntoView(!0);break}return!0}if(c.readlineBindings&&n.ctrlKey&&!n.altKey&&!n.shiftKey&&document.activeElement===i){if(v=i.selectionStart,65==a)i.setSelectionRange(0,0);else if(69==a)i.setSelectionRange(t.command.length,t.command.length);else if(85==a)t.command=t.command.slice(v),setTimeout(function(){i.setSelectionRange(0,0)});else if(75==a)t.command=t.command.slice(0,v),setTimeout(function(){i.setSelectionRange(t.command.length,t.command.length)});else{if(87!=a)return!1;var C=t.command.slice(0,v),k=C.lastIndexOf(" ")+1;t.command=t.command.slice(0,k)+t.command.slice(v,t.command.length),setTimeout(function(){i.setSelectionRange(k,k)})}return n.preventDefault(),!0}"keydown"!==n.type||18!==a||n.ctrlKey||n.shiftKey||(e.showQuickKeys=!0)},e.handleKeyRelease=function(t){return 18===t.keyCode?(void 0!==e.quickKeysTimer&&clearTimeout(e.quickKeysTimer),e.quickKeysTimer=setTimeout(function(){e.showQuickKeys&&(e.showQuickKeys=!1,e.$apply()),delete e.quickKeysTimer},1e3),!0):void 0}}]}})}(),function(){"use strict";var e=angular.module("weechat");e.directive("plugin",["$rootScope","settings",function(e,t){return{templateUrl:"directives/plugin.html",scope:{plugin:"=data"},controller:["$scope",function(n){n.displayedContent="",n.plugin.visible=!t.noembed&&!n.plugin.nsfw,n.plugin.className="embed_"+n.plugin.$$hashKey.replace(":","_"),n.plugin.getElement=function(){return document.querySelector("."+n.plugin.className)},n.hideContent=function(){n.plugin.visible=!1},n.showContent=function(t){var i=n.plugin.getElement();n.plugin.content instanceof Function?i&&""!==i.innerHTML||setTimeout(function(){n.plugin.content()}):n.displayedContent=n.plugin.content,n.plugin.visible=!0;var r;if(t){var o=e.bufferBottom;r=function(){e.updateBufferBottom(o)}}else r=function(){i&&void 0!==i.scrollIntoViewIfNeeded&&(i.scrollIntoViewIfNeeded(),e.updateBufferBottom())};setTimeout(r,500)},n.plugin.visible&&n.showContent(!0)}]}}])}(),function(){"use strict";var e=angular.module("ngWebsockets",[]);e.factory("ngWebsockets",["$rootScope","$q",function(e,t){var n=null,i=null,r={},o=0,a=function(e){for(var t in r)r[t].cb.reject(e)},c=function(){return o+=1,o>1e3&&(o=0),o},s=function(e){var t=u(e);return e=n.setId(t.id,e),i.send(e),t.promise},u=function(){var e=t.defer(),n=c();return r[n]={time:new Date,cb:e},e.id=n,e},l=function(e){var n=[];for(var i in e){var r=s(e[i]);n.push(r)}return t.all(n)},f=function(t){var i=n.parse(t.data);if(_.has(r,i.id)){var o=r[i.id];o.cb.resolve(i),delete r[i.id]}else e.$emit("onMessage",i);e.$apply()},d=function(e,t,r){i=new WebSocket(e),n=t;for(var o in r)i[o]=r[o];"onmessage"in r?i.onmessage=function(e){r.onmessage(e),f(e)}:i.onmessage=f},m=function(){i.close()};return{send:s,sendAll:l,connect:d,disconnect:m,failCallbacks:a}}])}(),function(){"use strict";var e=angular.module("weechatModels",[]);e.service("models",["$rootScope","$filter",function(e,t){function n(e,t){if(t in e&&e[t]&&e[t].length>0){var n=e[t];if(n.match(/^weechat/)){var i=n.match(/[a-zA-Z0-9_]+$/)[0];return["cof-"+i,"cob-"+i,"coa-"+i]}if(n.match(/^[a-zA-Z]+$/))return["cwf-"+n];if(n.match(/^[0-9]+$/))return["cef-"+n]}return["cwf-default"]}function i(e){return{name:n(e,"color"),prefix:n(e,"prefix_color")}}this.version=null,this.outgoingQueries=[];var r=function(e){var t=weeChat.Protocol.rawText2Rich(e),n={option:"cof-",weechat:"cwf-",ext:"cef-"},i={option:"cob-",weechat:"cwb-",ext:"ceb-"};return t.forEach(function(e){e.classes=[];var t=n[e.fgColor.type];e.classes.push(t+e.fgColor.name),t=i[e.bgColor.type],e.classes.push(t+e.bgColor.name),null!==e.attrs.name&&e.classes.push("coa-"+e.attrs.name);var r,o;for(r in e.attrs.override)o=e.attrs.override[r],o?e.classes.push("a-"+r):e.classes.push("a-no-"+r)}),t};this.parseRichText=r,this.Buffer=function(e){var t=e.full_name,n=e.short_name,i=e.hidden,o=n.replace(/^[#&+]/,"")||(n?" ":null),a=["#","&","+"].indexOf(n.charAt(0))>=0?n.charAt(0):"",c=r(e.title),s=e.number,u=e.pointers[0],l=3,f=[],d=0,m={},h=[],g=0,p=0,v=0,b=-1,y=t.replace(/^irc\.server\.(\w+)/,"irc.$1"),w=e.local_variables.type,C=["channel","private"].indexOf(w)>=0;void 0!==e.notify&&(l=e.notify);for(var k="",x=0;x<c.length;++x)k+=c[x].text;var B=function(e){f.push(e),$(e)},S=function(e,t){H()&&(t.spokeAt=Date.now(),m[e].nicks.push(t))},A=function(e,t){e=m[e],void 0!==e&&(e.nicks=_.filter(e.nicks,function(e){return e.name!==t.name}))},N=function(e,t){if(e=m[e],void 0!==e)for(var n in e.nicks)if(e.nicks[n].name===t.name){e.nicks[n]=t;break}},$=function(e){var t=e.prefix;if(0!==t.length){var n=t[t.length-1].text;if(" *"===n){var i=e.text.match(/^(.+)\s/);i&&(n=i[1])}else if(""===n||"=!="===n)return;_.each(m,function(e){_.each(e.nicks,function(e){e.name===n&&(e.spokeAt=Date.now())})})}},T=function(){var e=[];return _.each(m,function(t){_.each(t.nicks,function(t){e.push(t)})}),e.sort(function(e,t){return e.spokeAt<t.spokeAt}),e},M=function(e){var t="";return g!==h.length&&(t=h.pop()),h.push(e),g=h.length,t},I=function(e){if(g>=h.length&&h.push(e),0>=g||g>=h.length)return e;g--;var t=h[g];return t},E=function(e){return g===h.length?(void 0!==e&&""!==e&&(h.push(e),g++),""):0>g||g>h.length?e:(g++,h.length>0&&g==h.length-1?h.pop():h[g])},j=function(){for(var e in m)if("root"!==e)return!1;return!0},H=function(){return m.hasOwnProperty("root")},D=function(){for(;f.length>0;)f.pop();d=0};return{id:u,fullName:t,shortName:n,hidden:i,trimmedName:o,prefix:a,number:s,title:c,rtitle:k,lines:f,clear:D,requestedLines:d,addLine:B,lastSeen:b,unread:v,notification:p,notify:l,nicklist:m,addNick:S,delNick:A,updateNick:N,getNicklistByTime:T,serverSortKey:y,indent:C,type:w,history:h,addToHistory:M,getHistoryUp:I,getHistoryDown:E,isNicklistEmpty:j,nicklistRequested:H}},this.BufferLine=function(e){var n=e.buffer,i=e.date,o=t("date")(i,"HH:mm"),a=r(e.prefix),c=e.tags_array,s=e.displayed,u=e.highlight,l=r(e.message);u&&a.forEach(function(e){e.classes.push("highlight")});for(var f="",d=0;d<l.length;++d)f+=l[d].text;return{prefix:a,content:l,date:i,shortTime:o,buffer:n,tags:c,highlight:u,displayed:s,text:f}},this.Nick=function(e){var t=e.prefix,n=e.visible,r=e.name,o=i(e);return{prefix:t,visible:n,name:r,prefixClasses:o.prefix,nameClasses:o.name}},this.NickGroup=function(e){var t=e.name,n=e.visible,i=[];return{name:t,visible:n,nicks:i}};var o=null,a=null;this.model={buffers:{}},this.addBuffer=function(e){this.model.buffers[e.id]=e},this.getActiveBuffer=function(){return o},this.getActiveBufferReference=function(){return null!==this.version&&this.version[0]>=1?"0x"+o.id:o.fullName},this.getPreviousBuffer=function(){return a},this.setActiveBuffer=function(t,n){if(void 0===n&&(n="id"),a=this.getActiveBuffer(),o="id"===n?this.model.buffers[t]:_.find(this.model.buffers,function(e){return e[n]===t?e:void 0}),void 0===o)return o=a,!1;a&&(a.active=!1,a.lastSeen=a.lines.length-1);var i=o.unread+o.notification;return o.active=!0,o.unread=0,o.notification=0,e.$emit("activeBufferChanged",i),e.$emit("notificationChanged"),!0},this.getBuffers=function(){return this.model.buffers},this.reinitialize=function(){this.model.buffers={}},this.getBuffer=function(e){return this.model.buffers[e]},this.closeBuffer=function(e){var t=this.getBuffer(e);if(void 0!==t){if(t.active){var n=_.keys(this.model.buffers)[0];this.setActiveBuffer(n)}delete this.model.buffers[e]}}}])}(),function(){"use strict";var e=angular.module("plugins",[]),t=function(e,t){return{contentForMessage:t,exclusive:!1,name:e}},n=/(?:ftp|https?):\/\/\S*[^\s.;,(){}<>]/g,i=function(e,t){return{contentForMessage:function(e){for(var i=e.match(n),r=[],o=0;i&&o<i.length;o++){var a=t(i[o]);a&&r.push(a)}return r},exclusive:!1,name:e}};e.service("plugins",["userPlugins","$sce","$sanitize",function(e,t,n){var i=function(){var e=[],i=function(t){for(var n=0;n<t.length;n++)e.push(t[n])},r=new RegExp("nsfw","i"),o=function(i){i.metadata=[],i.text=n(i.text);for(var o=function(e,n,r){r&&(n+=" "+r),e instanceof Function||(e=t.trustAsHtml(e)),i.metadata.push({content:e,nsfw:c,name:n})},a=0;a<e.length;a++){var c=!1;i.text.match(r)&&(c=!0);var s=e[a].contentForMessage(i.text);if(s&&s!==[]){if(s instanceof Array)for(var u=s.length-1;u>=0;u--){var l=1==s.length?void 0:u+1;o(s[u],e[a].name,l)}else o(s,e[a].name);if(e[a].exclusive)break}}return i};return{registerPlugins:i,contentForMessage:o}};this.PluginManager=new i,this.PluginManager.registerPlugins(e.plugins)}]),e.factory("userPlugins",function(){var e=function(e,t){var n="jsonp_callback_"+Math.round(1e5*Math.random());window[n]=function(e){delete window[n],document.body.removeChild(i),t(e)};var i=document.createElement("script");i.src=e+(e.indexOf("?")>=0?"&":"?")+"callback="+n,document.body.appendChild(i)},n=new t("Spotify track",function(e){var t=[],n=function(e){for(var n=0;e&&n<e.length;n++){var i=e[n].substr(e[n].length-22,e[n].length);t.push('<iframe src="//embed.spotify.com/?uri=spotify:track:'+i+'" width="300" height="80" frameborder="0" allowtransparency="true"></iframe>')}};return n(e.match(/spotify:track:([a-zA-Z-0-9]{22})/g)),n(e.match(/open.spotify.com\/track\/([a-zA-Z-0-9]{22})/g)),t}),r=new i("YouTube video",function(e){var t=/(?:youtube.com|youtu.be)\/(?:v\/|embed\/|watch(?:\?v=|\/))?([a-zA-Z0-9-]+)/i,n=e.match(t);if(n){var i=n[1],r="https://www.youtube.com/embed/"+i+"?html5=1&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0";return'<iframe width="560" height="315" src="'+r+'" frameborder="0" allowfullscreen frameborder="0"></iframe>'}}),o=new t("Dailymotion video",function(e){var t=/dailymotion.com\/.*video\/([^_?# ]+)/,n=/dailymotion.com\/.*#video=([^_& ]+)/,i=/dai.ly\/([^_?# ]+)/,r=e.match(t)||e.match(n)||e.match(i);if(r){var o=r[1],a="https://www.dailymotion.com/embed/video/"+o+"?html&controls=html&startscreen=html&info=0&logo=0&related=0";return'<iframe frameborder="0" width="480" height="270" src="'+a+'"></iframe>'}return null}),a=new t("AlloCine video",function(e){var t=/allocine.fr\/videokast\/video-(\d+)/,n=/allocine.fr\/.*cmedia=(\d+)/,i=e.match(t)||e.match(n);if(i){var r=i[1],o="http://www.allocine.fr/_video/iblogvision.aspx?cmedia="+r;return'<iframe frameborder="0" width="480" height="270" src="'+o+'"></iframe>'}return null}),c=new i("image",function(e){return e.match(/\.(png|gif|jpg|jpeg)(:(small|medium|large))?\b/i)?(-1!=e.indexOf("^https?://fukung.net/v/")?e=e.replace(/.*\//,"http://media.fukung.net/imgs/"):e.match(/^http:\/\/(i\.)?imgur\.com\//i)?e=e.replace(/http:/,""):e.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\/[^?]+$/i)&&(e+="?dl=1"),'<a target="_blank" href="'+e+'"><img class="embed" src="'+e+'"></a>'):void 0}),s=new i("video",function(e){return e.match(/\.(mp4|webm|ogv)\b/i)?'<video class="embed" width="560"><source src="'+e+'"></source></video>':void 0}),u=new i("cloud music",function(e){return e.match(/^https?:\/\/soundcloud.com\//)?'<iframe width="100%" height="120" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url='+e+'&amp;color=ff6600&amp;auto_play=false&amp;show_artwork=true"></iframe>':e.match(/^https?:\/\/([a-z]+\.)?mixcloud.com\//)?'<iframe width="480" height="60" src="//www.mixcloud.com/widget/iframe/?feed='+e+'&mini=1&stylecolor=&hide_artwork=&embed_type=widget_standard&hide_tracklist=1&hide_cover=" frameborder="0"></iframe>':void 0}),l=new i("Google Map",function(e){return e.match(/^https?:\/\/maps\.google\./i)||e.match(/^https?:\/\/(?:[\w]+\.)?google\.[\w]+\/maps/i)?'<iframe width="450" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+e+'&output=embed"></iframe>':void 0}),f=new i("ascii cast",function(e){var t=/^https?:\/\/(?:www\.)?asciinema.org\/a\/(\d+)/i,n=e.match(t);if(n){var i=n[1];return function(){var e=this.getElement(),t=document.createElement("script");t.src="https://asciinema.org/a/"+i+".js",t.id="asciicast-"+i,t.async=!0,e.appendChild(t)}}}),d=new i("meteogram",function(e){var t=/^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/,n=e.match(t);if(n){var i=n[1],r=n[2],o=n[n.length-1].slice(0,-1);return e="http://www.yr.no/"+i+"/"+r+"avansert_meteogram.png","<img src='"+e+"' alt='Meteogram for "+o+"' />"}}),m=new i("Gist",function(t){var n=/^https:\/\/gist\.github.com\/[^.?]+/i,i=t.match(n);return i?(t=i[0]+".json",function(){var n=this.getElement();e(t,function(e){if(document.querySelectorAll('link[rel=stylesheet][href="'+e.stylesheet+'"]').length<1){var t='<link rel="stylesheet" href="'+e.stylesheet+'"></link>';document.getElementsByTagName("head")[0].innerHTML+=t}n.innerHTML='<div style="clear:both">'+e.div+"</div>"})}):void 0}),h=new i("Giphy",function(e){var t=/^https?:\/\/giphy.com\/gifs\/.*-(.*)\/?/i,n=e.match(t);if(n){var i="https://media.giphy.com/media/"+n[1]+"/giphy.gif";return'<a target="_blank" href="'+e+'"><img class="embed" src="'+i+'"></a>'}}),g=new i("Tweet",function(t){var n=/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i,i=t.match(n);return i?(t="https://api.twitter.com/1/statuses/oembed.json?id="+i[2],function(){var n=this.getElement();e(t,function(e){var t=e.html.indexOf("<script "),i=e.html.substr(0,t);i=i.replace('<blockquote class="twitter-tweet">','<blockquote class="twitter-tweet" data-dnt="true">'),n.innerHTML=i;var r=document.createElement("script");r.src="//platform.twitter.com/widgets.js",n.appendChild(r)})}):void 0}),p=new i("Vine",function(e){var t=/^https?:\/\/(www\.)?vine.co\/v\/([a-zA-Z0-9]+)(\/.*)?/i,n=e.match(t);if(n){var i=n[2],r="https://vine.co/v/"+i+"/embed/simple?audio=1";return'<iframe class="vine-embed" src="'+r+'" width="600" height="600" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>'}});return{plugins:[r,o,a,c,s,n,u,l,f,d,m,h,g,p]}})}();
//# sourceMappingURL=min.map