diff --git a/appinfo/info.xml b/appinfo/info.xml index f081dd92..29df281b 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ JavaScript XMPP Chat Facebook-like chat Facebook-like chat with end-to-end encrypted conversation, video calls, multi-user rooms, XMPP and internal server backend. - 3.2.0-beta.3 + 3.2.0 agpl Klaus Herberth Tobia De Koninck diff --git a/build/appinfo/info.xml b/build/appinfo/info.xml index f081dd92..29df281b 100644 --- a/build/appinfo/info.xml +++ b/build/appinfo/info.xml @@ -5,7 +5,7 @@ JavaScript XMPP Chat Facebook-like chat Facebook-like chat with end-to-end encrypted conversation, video calls, multi-user rooms, XMPP and internal server backend. - 3.2.0-beta.3 + 3.2.0 agpl Klaus Herberth Tobia De Koninck diff --git a/build/css/jsxc.oc.css b/build/css/jsxc.oc.css index 3b637124..3de6e7a5 100644 --- a/build/css/jsxc.oc.css +++ b/build/css/jsxc.oc.css @@ -1,5 +1,5 @@ /*! - * ojsxc v3.2.0-beta.3 - 2017-05-02 + * ojsxc v3.2.0 - 2017-05-17 * * Copyright (c) 2017 Klaus Herberth
* Released under the MIT license @@ -7,7 +7,7 @@ * Please see http://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.2.0-beta.3 + * @version 3.2.0 * @license MIT */ @@ -2799,7 +2799,7 @@ fieldset[disabled] #jsxc_webrtc .checkbox label { width: 14px; height: 100%; position: absolute; - left: -14px !important; + right: 100%; top: 0; z-index: 110; background-color: transparent; @@ -4443,6 +4443,9 @@ div.jsxc_video { top: 45px; z-index: 1500; } +#jsxc_toggleRoster { + width: 8px; } + #jsxc_windowList, #jsxc_windowListSB { z-index: 1500; } diff --git a/build/js/eof.js b/build/js/eof.js index 0b07b8bc..5705f673 100644 --- a/build/js/eof.js +++ b/build/js/eof.js @@ -1,5 +1,5 @@ /*! - * ojsxc v3.2.0-beta.3 - 2017-05-02 + * ojsxc v3.2.0 - 2017-05-17 * * Copyright (c) 2017 Klaus Herberth
* Released under the MIT license @@ -7,7 +7,7 @@ * Please see http://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.2.0-beta.3 + * @version 3.2.0 * @license MIT */ diff --git a/build/js/jsxc/css/jsxc.css b/build/js/jsxc/css/jsxc.css index c440bbd2..e27ec567 100644 --- a/build/js/jsxc/css/jsxc.css +++ b/build/js/jsxc/css/jsxc.css @@ -2552,7 +2552,7 @@ fieldset[disabled] width: 14px; height: 100%; position: absolute; - left: -14px !important; + right: 100%; top: 0; z-index: 110; background-color: transparent; diff --git a/build/js/jsxc/jsxc.js b/build/js/jsxc/jsxc.js index a358e38e..6023a66c 100644 --- a/build/js/jsxc/jsxc.js +++ b/build/js/jsxc/jsxc.js @@ -1,5 +1,5 @@ /*! - * jsxc v3.2.0-beta.2 - 2017-04-28 + * jsxc v3.2.0 - 2017-05-17 * * Copyright (c) 2017 Klaus Herberth
* Released under the MIT license @@ -7,7 +7,7 @@ * Please see http://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.2.0-beta.2 + * @version 3.2.0 * @license MIT */ @@ -25,7 +25,7 @@ var jsxc = null, RTC = null, RTCPeerconnection = null; */ jsxc = { /** Version of jsxc */ - version: '3.2.0-beta.2', + version: '3.2.0', /** True if i'm the master */ master: false, @@ -3670,6 +3670,8 @@ jsxc.gui = { $('[data-bid="' + bid + '"]').each(function() { var el = $(this); + el.attr('data-status', pres); + if (!el.hasClass('jsxc_statusIndicator')) { el = el.find('.jsxc_statusIndicator'); } @@ -3801,7 +3803,11 @@ jsxc.gui = { element.off('click').click(function(ev) { ev.stopPropagation(); - jsxc.gui.queryActions[action].call(jsxc, jid, params); + if (jsxc.xmpp.conn && jsxc.xmpp.conn.connected) { + jsxc.gui.queryActions[action].call(jsxc, jid, params); + } else { + jsxc.gui.showNotification($.t('no_connection'), $.t('You_have_to_go_online_')); + } return false; }); diff --git a/build/js/jsxc/jsxc.min.js b/build/js/jsxc/jsxc.min.js index c191094c..cae9afce 100644 --- a/build/js/jsxc/jsxc.min.js +++ b/build/js/jsxc/jsxc.min.js @@ -1,5 +1,5 @@ /*! - * jsxc v3.2.0-beta.2 - 2017-04-28 + * jsxc v3.2.0 - 2017-05-17 * * Copyright (c) 2017 Klaus Herberth
* Released under the MIT license @@ -7,14 +7,14 @@ * Please see http://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.2.0-beta.2 + * @version 3.2.0 * @license MIT */ -var jsxc=null,RTC=null,RTCPeerconnection=null;!function($){"use strict";jsxc={version:"3.2.0-beta.2",master:!1,role_allocation:!1,to:[],toBusy:null,toNotification:null,toNotificationDelay:500,keepaliveInterval:null,restoreCompleted:!1,triggeredFromBox:!1,triggeredFromElement:!1,triggeredFromLogout:!1,ls:[],storageNotConform:null,toSNC:null,bid:null,currentState:null,currentUIState:null,CONST:{NOTIFICATION_DEFAULT:"default",NOTIFICATION_GRANTED:"granted",NOTIFICATION_DENIED:"denied",STATUS:["offline","dnd","xa","away","chat","online"],SOUNDS:{MSG:"incomingMessage.wav",CALL:"Rotary-Phone6.mp3",NOTICE:"Ping1.mp3"},REGEX:{JID:new RegExp("\\b[^\"&'\\/:<>@\\s]+@[\\w-_.]+\\b","ig"),URL:new RegExp(/(https?:\/\/|www\.)[^\s<>'"]+/gi)},NS:{CARBONS:"urn:xmpp:carbons:2",FORWARD:"urn:xmpp:forward:0",HINTS:"urn:xmpp:hints"},HIDDEN:"hidden",SHOWN:"shown",STATE:{INITIATING:0,PREVCONFOUND:1,SUSPEND:2,TRYTOINTERCEPT:3,INTERCEPTED:4,ESTABLISHING:5,READY:6},UISTATE:{INITIATING:0,READY:1}},getFormattedTime:function(unixtime){var msgDate=new Date(parseInt(unixtime)),day=("0"+msgDate.getDate()).slice(-2),month=("0"+(msgDate.getMonth()+1)).slice(-2),year=msgDate.getFullYear(),hours=("0"+msgDate.getHours()).slice(-2),minutes=("0"+msgDate.getMinutes()).slice(-2),dateNow=new Date,date="function"==typeof msgDate.toLocaleDateString?msgDate.toLocaleDateString():day+"."+month+"."+year,time="function"==typeof msgDate.toLocaleTimeString?msgDate.toLocaleTimeString():hours+":"+minutes;return dateNow.setHours(0,0,0,0),msgDate.setHours(0,0,0,0),dateNow.getTime()!==msgDate.getTime()?date+" "+time:time},debug:function(msg,data,level){if(level&&(msg="["+level+"] "+msg),data){!0===jsxc.storage.getItem("debug")&&console.log(msg,data);var d;try{d=$("").prepend($(data).clone()).html()}catch(err){try{d=JSON.stringify(data)}catch(err2){d="see js console"}}jsxc.log=jsxc.log+"$ "+msg+": "+d+"\n"}else console.log(msg),jsxc.log=jsxc.log+"$ "+msg+"\n"},warn:function(msg,data){jsxc.debug(msg,data,"WARN")},error:function(msg,data){jsxc.debug(msg,data,"ERROR")},log:"",init:function(options){if(jsxc.changeState(jsxc.CONST.STATE.INITIATING),options&&options.loginForm&&"boolean"==typeof options.loginForm.attachIfFound&&!options.loginForm.ifFound&&(options.loginForm.ifFound=options.loginForm.attachIfFound?"attach":"pause"),options&&$.extend(!0,jsxc.options,options),!jsxc.storage.hasSupport())return void jsxc.error("Browser doesn't support localStorage. JSXC will be disabled.");jsxc.options.get=function(key){if(jsxc.bid){var local=jsxc.storage.getUserItem("options")||{};return void 0!==local[key]?local[key]:jsxc.options[key]}return jsxc.options[key]},jsxc.options.set=function(key,value){jsxc.storage.updateItem("options",key,value,!0)},jsxc.storageNotConform=jsxc.storage.getItem("storageNotConform"),null===jsxc.storageNotConform&&(jsxc.storageNotConform=2);var lang;lang=null!==jsxc.storage.getItem("lang")?jsxc.storage.getItem("lang"):jsxc.options.autoLang&&navigator.languages&&navigator.languages.length>0?navigator.languages[0].substr(0,2):jsxc.options.autoLang&&navigator.language?navigator.language.substr(0,2):jsxc.options.defaultLang,window.i18next.init({lng:lang,fallbackLng:"en",resources:I18next,debug:!0===jsxc.storage.getItem("debug"),interpolation:{prefix:"__",suffix:"__"}},function(){window.jqueryI18next.init(window.i18next,$,{tName:"t",i18nName:"i18next",handleName:"localize"})}),!0===jsxc.storage.getItem("debug")&&(jsxc.options.otr.debug=!0),window.addEventListener("storage",jsxc.storage.onStorage,!1),$(document).on("attached.jsxc",jsxc.registerLogout);var isStorageAttachParameters=jsxc.storage.getItem("rid")&&jsxc.storage.getItem("sid")&&jsxc.storage.getItem("jid"),isOptionsAttachParameters=jsxc.options.xmpp.rid&&jsxc.options.xmpp.sid&&jsxc.options.xmpp.jid,isForceLoginForm=jsxc.options.loginForm&&"force"===jsxc.options.loginForm.ifFound&&jsxc.isLoginForm();if(!isStorageAttachParameters&&!isOptionsAttachParameters||isForceLoginForm){if(jsxc.storage.removeItem("rid"),jsxc.storage.removeItem("sid"),!jsxc.isLoginForm())return jsxc.changeState(jsxc.CONST.STATE.SUSPEND),void(jsxc.options.displayRosterMinimized()&&(jsxc.storage.setUserItem("roster","hidden"),jsxc.gui.roster.init(),jsxc.gui.roster.noConnection()));jsxc.changeState(jsxc.CONST.STATE.TRYTOINTERCEPT),"function"==typeof jsxc.options.formFound&&jsxc.options.formFound.call();var form=jsxc.options.loginForm.form=$(jsxc.options.loginForm.form),events=form.data("events")||{submit:[]},submits=[];$.each(events.submit,function(index,val){submits.push(val.handler)}),form.data("submits",submits),form.off("submit"),form.submit(function(ev){return ev.preventDefault(),jsxc.prepareLogin(function(settings){if(!1!==settings){var enabled=settings.loginForm&&settings.loginForm.enable||settings.xmpp&&settings.xmpp.onlogin;if(enabled="true"===enabled||!0===enabled)return jsxc.options.loginForm.triggered=!0,void jsxc.xmpp.login(jsxc.options.xmpp.jid,jsxc.options.xmpp.password)}jsxc.submitLoginForm()}),!1}),jsxc.changeState(jsxc.CONST.STATE.INTERCEPTED)}else(!jsxc.isLoginForm()||jsxc.options.loginForm&&"attach"===jsxc.options.loginForm.ifFound)&&(jsxc.changeState(jsxc.CONST.STATE.PREVCONFOUND),void 0===jsxc.storage.getItem("alive")?jsxc.onMaster():jsxc.checkMaster())},start:function(){var args=arguments;return jsxc.role_allocation&&!jsxc.master?(jsxc.debug("There is an other master tab"),!1):jsxc.xmpp.conn&&jsxc.xmpp.connected?(jsxc.debug("We are already connected"),!1):(3===args.length&&$(document).one("attached.jsxc",function(){jsxc.xmpp.onRidChange(jsxc.xmpp.conn._proto.rid),jsxc.onMaster()}),void jsxc.checkMaster(function(){jsxc.xmpp.login.apply(this,args)}))},registerLogout:function(){if(null!==jsxc.options.logoutElement&&$(jsxc.options.logoutElement).length>0){var logout=function(ev){ev.stopPropagation(),ev.preventDefault(),jsxc.options.logoutElement=$(this),jsxc.triggeredFromLogout=!0,jsxc.xmpp.logout()};jsxc.options.logoutElement=$(jsxc.options.logoutElement),jsxc.options.logoutElement.off("click",null,logout).one("click",logout)}},isLoginForm:function(){return jsxc.options.loginForm.form&&jsxc.el_exists(jsxc.options.loginForm.form)&&jsxc.el_exists(jsxc.options.loginForm.jid)&&jsxc.el_exists(jsxc.options.loginForm.pass)},prepareLogin:function(username,password,cb){"function"==typeof username&&(cb=username,username=null),username=username||$(jsxc.options.loginForm.jid).val(),password=password||$(jsxc.options.loginForm.pass).val(),jsxc.triggeredFromBox||"dialog"!==jsxc.options.loginForm.onConnecting&&void 0!==jsxc.options.loginForm.onConnecting||jsxc.gui.showWaitAlert($.t("Logging_in"));var settings;"function"==typeof jsxc.options.loadSettings?void 0!==(settings=jsxc.options.loadSettings.call(this,username,password,function(s){jsxc._prepareLogin(username,password,cb,s)}))&&jsxc._prepareLogin(username,password,cb,settings):jsxc._prepareLogin(username,password,cb)},_prepareLogin:function(username,password,cb,loadedSettings){if(!1===loadedSettings)return jsxc.warn("No settings provided"),void cb(!1);var settings=$.extend(!0,{},jsxc.options);loadedSettings?settings=$.extend(!0,settings,loadedSettings):loadedSettings={},"string"==typeof settings.xmpp.username&&(username=settings.xmpp.username),"string"==typeof settings.xmpp.password&&(password=settings.xmpp.password);var jid,resource=settings.xmpp.resource?"/"+settings.xmpp.resource:"",domain=settings.xmpp.domain;jid=username.match(/@(.*)$/)?username.match(/\/(.*)$/)?username:username+resource:username+"@"+domain+resource,"function"==typeof jsxc.options.loginForm.preJid&&(jid=jsxc.options.loginForm.preJid(jid)),jsxc.bid=jsxc.jidToBid(jid),settings.xmpp.username=jid.split("@")[0],settings.xmpp.domain=jid.split("@")[1].split("/")[0],settings.xmpp.resource=jid.split("@")[1].split("/")[1]||"",loadedSettings.xmpp||(loadedSettings.xmpp={}),$.each(loadedSettings,function(key){var old=jsxc.options.get(key),val=settings[key];val=$.extend(!0,old,val),jsxc.options.set(key,val)}),jsxc.options.xmpp.jid=jid,jsxc.options.xmpp.password=password,cb(settings)},onSlave:function(){jsxc.debug("I am the slave."),jsxc.role_allocation=!0,jsxc.bid=jsxc.jidToBid(jsxc.storage.getItem("jid")),jsxc.gui.init(),$("#jsxc_roster").removeClass("jsxc_noConnection"),jsxc.registerLogout(),jsxc.gui.avatar.update($("#jsxc_roster > .jsxc_bottom"),jsxc.jidToBid(jsxc.storage.getItem("jid")),"own"),jsxc.gui.restore()},onMaster:function(){jsxc.debug("I am master."),jsxc.master=!0,jsxc.storage.setItem("alive",0),jsxc.storage.setItem("alive_busy",0),jsxc.startKeepAlive(),jsxc.role_allocation=!0,jsxc.xmpp.login()},checkMaster:function(cb){jsxc.debug("check master"),cb=cb&&"function"==typeof cb?cb:jsxc.onMaster,void 0===jsxc.storage.getItem("alive")?cb.call():(jsxc.to.push(window.setTimeout(cb,1e3)),jsxc.keepAlive("slave"))},masterActions:function(){if(jsxc.xmpp.conn&&jsxc.xmpp.conn.authenticated){var noti=jsxc.storage.getUserItem("notification");noti="number"==typeof noti?noti:2,jsxc.options.notification&¬i>0&&jsxc.notification.hasSupport()?jsxc.notification.hasPermission()?jsxc.notification.init():jsxc.notification.prepareRequest():jsxc.options.notification=!1,jsxc.options.get("otr").enable&&jsxc.otr.createDSA(),jsxc.gui.avatar.update($("#jsxc_roster > .jsxc_bottom"),jsxc.jidToBid(jsxc.storage.getItem("jid")),"own")}},startKeepAlive:function(){jsxc.keepaliveInterval=window.setInterval(jsxc.keepAlive,jsxc.options.timeout-1e3)},keepAlive:function(role){var next=parseInt(jsxc.storage.getItem("alive"))+1;role=role||"master",jsxc.storage.setItem("alive",next+":"+role)},keepBusyAlive:function(){jsxc.toBusy&&window.clearTimeout(jsxc.toBusy),jsxc.keepaliveInterval&&window.clearInterval(jsxc.keepaliveInterval),jsxc.storage.ink("alive_busy"),jsxc.toBusy=window.setTimeout(jsxc.startKeepAlive,jsxc.options.busyTimeout-1e3)},random:function(max){return Math.floor(Math.random()*max)},el_exists:function(selector){return $(selector).length>0},jidToCid:function(jid){return jsxc.warn("jsxc.jidToCid is deprecated!"),Strophe.getBareJidFromJid(jid).replace("@","-").replace(/\./g,"-").toLowerCase()},jidToBid:function(jid){return Strophe.unescapeNode(Strophe.getBareJidFromJid(jid).toLowerCase())},restoreRoster:function(){var buddies=jsxc.storage.getUserItem("buddylist");if(!buddies||0===buddies.length)return jsxc.debug("No saved buddylist."),void jsxc.gui.roster.empty();$.each(buddies,function(index,value){jsxc.gui.roster.add(value)}),jsxc.gui.roster.loaded=!0,$(document).trigger("cloaded.roster.jsxc")},restoreWindows:function(){var windows=jsxc.storage.getUserItem("windowlist");null!==windows&&$.each(windows,function(index,bid){var win=jsxc.storage.getUserItem("window",bid);if(!win)return jsxc.debug("Associated window-element is missing: "+bid),!0;jsxc.gui.window.init(bid),win.minimize?jsxc.gui.window.hide(bid):jsxc.gui.window.show(bid),jsxc.gui.window.setText(bid,win.text)})},submitLoginForm:function(){var form=$(jsxc.options.loginForm.form).off("submit"),submits=form.data("submits")||[];$.each(submits,function(index,val){form.submit(val)}),form.find("#submit").length>0?form.find("#submit").click():form.get(0)&&"function"==typeof form.get(0).submit?form.submit():form.find('[type="submit"]').length>0?form.find('[type="submit"]').click():jsxc.warn("Could not submit login form.")},escapeHTML:function(text){return text=text.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),text.replace(/&/g,"&").replace(//g,">")},removeHTML:function(text){return $("").html(text).text()},switchEvents:function(obj){var ns=Math.random().toString(36).substr(2,12),self=this;return $.each(obj,function(key,val){$(document).one(key+"."+ns,function(){$(document).off("."+ns),val.apply(self,arguments)})}),ns},isHidden:function(){var hidden=!1;return void 0!==document.hidden?hidden=document.hidden:void 0!==document.webkitHidden?hidden=document.webkitHidden:void 0!==document.mozHidden?hidden=document.mozHidden:void 0!==document.msHidden&&(hidden=document.msHidden),hidden&&jsxc.master?jsxc.storage.ink("hidden",0):hidden||jsxc.master||jsxc.storage.ink("hidden"),hidden},hasFocus:function(){var focus=!0;return"function"==typeof document.hasFocus&&(focus=document.hasFocus()),!focus&&jsxc.master?jsxc.storage.ink("focus",0):focus&&!jsxc.master&&jsxc.storage.ink("focus"),focus},exec:function(fnName,fnParams){var i,fnList=fnName.split("."),fn=jsxc[fnList[0]];for(i=1;i",data)}),jsxc.xmpp.conn.nextValidRid=jsxc.xmpp.onRidChange;var callback=function(status,condition){switch(jsxc.debug(Object.getOwnPropertyNames(Strophe.Status)[status]+": "+condition),status){case Strophe.Status.CONNECTING:$(document).trigger("connecting.jsxc");break;case Strophe.Status.CONNECTED:jsxc.bid=jsxc.jidToBid(jsxc.xmpp.conn.jid.toLowerCase()),$(document).trigger("connected.jsxc");break;case Strophe.Status.ATTACHED:$(document).trigger("attached.jsxc");break;case Strophe.Status.DISCONNECTED:$(document).trigger("disconnected.jsxc");break;case Strophe.Status.CONNFAIL:$(document).trigger("connfail.jsxc");break;case Strophe.Status.AUTHFAIL:$(document).trigger("authfail.jsxc")}};jsxc.xmpp.conn.caps&&(jsxc.xmpp.conn.caps.node="http://jsxc.org/"),jsxc.changeState(jsxc.CONST.STATE.ESTABLISHING),sid&&rid?(jsxc.debug("Try to attach"),jsxc.debug("SID: "+sid),jsxc.xmpp.conn.attach(jid,sid,rid,callback)):(jsxc.debug("New connection"),jsxc.xmpp.conn.caps&&jsxc.xmpp.conn._addSysHandler(function(stanza){var from=jsxc.xmpp.conn.domain,c=stanza.querySelector("c"),ver=c.getAttribute("ver"),node=c.getAttribute("node"),_jidNodeIndex=JSON.parse(localStorage.getItem("strophe.caps._jidNodeIndex"))||{};jsxc.xmpp.conn.caps._jidVerIndex[from]=ver,_jidNodeIndex[from]=node,localStorage.setItem("strophe.caps._jidVerIndex",JSON.stringify(jsxc.xmpp.conn.caps._jidVerIndex)),localStorage.setItem("strophe.caps._jidNodeIndex",JSON.stringify(_jidNodeIndex))},Strophe.NS.CAPS),jsxc.xmpp.conn.connect(jid,password||jsxc.options.xmpp.password,callback))},logout:function(complete){if(jsxc.triggeredFromElement="boolean"!=typeof complete||complete,!jsxc.master)return jsxc.storage.removeItem("sid"),!0;if(jsxc.storage.removeUserItem("windowlist"),jsxc.storage.removeUserItem("unreadMsg"),$("body").click(),!jsxc.xmpp.conn||!jsxc.xmpp.conn.authenticated)return!0;$.each(jsxc.storage.getUserItem("otrlist")||{},function(i,val){jsxc.otr.create(val)});var numOtr=Object.keys(jsxc.otr.objects||{}).length+1,disReady=function(){--numOtr<=0&&(jsxc.xmpp.conn.flush(),setTimeout(function(){jsxc.xmpp.conn.disconnect()},600))};return $.each(jsxc.otr.objects||{},function(key,obj){obj.msgstate===OTR.CONST.MSGSTATE_ENCRYPTED?obj.endOtr.call(obj,function(){obj.init.call(obj),jsxc.otr.backup(key),disReady()}):disReady()}),disReady(),!1},connected:function(){jsxc.xmpp.conn.pause(),jsxc.xmpp.initNewConnection(),jsxc.xmpp.saveSessionParameter();var rosterVerSupport=$(jsxc.xmpp.conn.features).find('[xmlns="urn:xmpp:features:rosterver"]').length>0;if(jsxc.storage.setUserItem("rosterVerSupport",rosterVerSupport),jsxc.options.loginForm.triggered)switch(jsxc.options.loginForm.onConnected||"submit"){case"submit":return void jsxc.submitLoginForm();case!1:return}jsxc.gui.dialog.close(),jsxc.xmpp.conn.resume(),jsxc.onMaster(),jsxc.changeState(jsxc.CONST.STATE.READY),$(document).trigger("attached.jsxc")},attached:function(){$("#jsxc_roster").removeClass("jsxc_noConnection"),Strophe.addNamespace("VERSION","jabber:iq:version"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onRosterChanged,"jabber:iq:roster","iq","set"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onChatMessage,null,"message","chat"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onErrorMessage,null,"message","error"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onHeadlineMessage,null,"message","headline"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onReceived,null,"message"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onPresence,null,"presence"),jsxc.xmpp.conn.addHandler(jsxc.xmpp.onVersionRequest,Strophe.NS.VERSION,"iq","get"),jsxc.gui.init();var caps=jsxc.xmpp.conn.caps,domain=jsxc.xmpp.conn.domain;if(caps){var conditionalEnable=function(){};if(jsxc.options.get("carbons").enable&&(conditionalEnable=function(){jsxc.xmpp.conn.caps.hasFeatureByJid(domain,jsxc.CONST.NS.CARBONS)&&jsxc.xmpp.carbons.enable()},$(document).on("caps.strophe",function onCaps(ev,from){from===domain&&(conditionalEnable(),$(document).off("caps.strophe",onCaps))})),void 0===caps._knownCapabilities[caps._jidVerIndex[domain]]){var _jidNodeIndex=JSON.parse(localStorage.getItem("strophe.caps._jidNodeIndex"))||{};jsxc.debug("Request server capabilities"),caps._requestCapabilities(jsxc.xmpp.conn.domain,_jidNodeIndex[domain],caps._jidVerIndex[domain])}else conditionalEnable()}if(jsxc.storage.getUserItem("rosterLoaded")!==jsxc.xmpp.conn._proto.sid){$(document).one("cloaded.roster.jsxc",jsxc.xmpp.sendPres),$("#jsxc_roster > p:first").remove();var queryAttr={xmlns:"jabber:iq:roster"};jsxc.storage.getUserItem("rosterVerSupport")&&(queryAttr.ver=jsxc.storage.getUserItem("rosterVer")||"");var iq=$iq({type:"get"}).c("query",queryAttr);jsxc.xmpp.conn.sendIQ(iq,jsxc.xmpp.onRoster)}else jsxc.xmpp.sendPres(),jsxc.restoreCompleted||jsxc.gui.restore();jsxc.xmpp.saveSessionParameter(),jsxc.masterActions(),jsxc.changeState(jsxc.CONST.STATE.READY)},saveSessionParameter:function(){var nomJid=Strophe.getBareJidFromJid(jsxc.xmpp.conn.jid).toLowerCase()+"/"+Strophe.getResourceFromJid(jsxc.xmpp.conn.jid);jsxc.storage.setItem("sid",jsxc.xmpp.conn._proto.sid),jsxc.storage.setItem("jid",nomJid)},initNewConnection:function(){jsxc.storage.removeUserItem("windowlist"),jsxc.storage.removeUserItem("own"),jsxc.storage.removeUserItem("avatar","own"),jsxc.storage.removeUserItem("otrlist"),jsxc.storage.removeUserItem("unreadMsg"),jsxc.storage.removeUserItem("features"),jsxc.storage.removeUserElement("options","RTCPeerConfig")},sendPres:function(){jsxc.xmpp.conn.disco&&(jsxc.xmpp.conn.disco.addIdentity("client","web","JSXC"),jsxc.xmpp.conn.disco.addFeature(Strophe.NS.DISCO_INFO),jsxc.xmpp.conn.disco.addFeature(Strophe.NS.RECEIPTS),jsxc.xmpp.conn.disco.addFeature(Strophe.NS.VERSION));var pres=$pres();jsxc.xmpp.conn.caps&&pres.c("c",jsxc.xmpp.conn.caps.generateCapsAttrs()).up();var presState=jsxc.storage.getUserItem("presence")||"online";"online"!==presState&&pres.c("show").t(presState).up();var priority=jsxc.options.get("priority");if(priority&&void 0!==priority[presState]&&0!==parseInt(priority[presState])&&pres.c("priority").t(priority[presState]).up(),jsxc.debug("Send presence",pres.toString()),jsxc.xmpp.conn.send(pres),jsxc.storage.getUserItem("features"))$(document).trigger("features.jsxc");else{jsxc.xmpp.conn.flush();var barJid=Strophe.getBareJidFromJid(jsxc.xmpp.conn.jid);jsxc.xmpp.conn.disco.info(barJid,void 0,function(stanza){var features=$(stanza).find("feature").map(function(){return $(this).attr("var")});jsxc.storage.setUserItem("features",features.toArray()),$(document).trigger("features.jsxc")})}},disconnected:function(){jsxc.debug("disconnected"),jsxc.storage.removeItem("jid"),jsxc.storage.removeItem("sid"),jsxc.storage.removeItem("rid"),jsxc.storage.removeItem("hidden"),jsxc.storage.removeUserItem("avatar","own"),jsxc.storage.removeUserItem("otrlist"),jsxc.storage.removeUserItem("features"),$(document).off("connected.jsxc",jsxc.xmpp.connected),$(document).off("attached.jsxc",jsxc.xmpp.attached),$(document).off("disconnected.jsxc",jsxc.xmpp.disconnected),$(document).off("connfail.jsxc",jsxc.xmpp.onConnfail),$(document).off("authfail.jsxc",jsxc.xmpp.onAuthFail),jsxc.xmpp.conn=null,$("#jsxc_windowList").remove(),jsxc.triggeredFromElement?($(document).trigger("toggle.roster.jsxc",["hidden",0]),jsxc.gui.roster.ready=!1,$("#jsxc_roster").remove(),jsxc.triggeredFromLogout&&(window.location=jsxc.options.logoutElement.attr("href"))):jsxc.gui.roster.noConnection(),window.clearInterval(jsxc.keepaliveInterval),jsxc.role_allocation=!1,jsxc.master=!1,jsxc.storage.removeItem("alive"),jsxc.changeState(jsxc.CONST.STATE.SUSPEND)},onConnfail:function(ev,condition){jsxc.debug("XMPP connection failed: "+condition),jsxc.options.loginForm.triggered&&jsxc.submitLoginForm()},onAuthFail:function(){if(jsxc.options.loginForm.triggered)switch(jsxc.options.loginForm.onAuthFail||"ask"){case"ask":jsxc.gui.showAuthFail();break;case"submit":jsxc.submitLoginForm();break;case"quiet":case!1:return}},onRoster:function(iq){if(jsxc.debug("Load roster",iq),jsxc.storage.setUserItem("rosterLoaded",jsxc.xmpp.conn._proto.sid),0===$(iq).find("query").length)return jsxc.debug("Use cached roster"),void jsxc.restoreRoster();var buddies=[];$(iq).find("item").each(function(){var jid=$(this).attr("jid"),name=$(this).attr("name")||jid,bid=jsxc.jidToBid(jid),sub=$(this).attr("subscription");buddies.push(bid),jsxc.storage.removeUserItem("res",bid),jsxc.storage.saveBuddy(bid,{jid:jid,name:name,status:0,sub:sub,res:[],rnd:Math.random()}),jsxc.gui.roster.add(bid)}),0===buddies.length&&jsxc.gui.roster.empty(),jsxc.storage.setUserItem("buddylist",buddies),$(iq).find("query").attr("ver")&&jsxc.storage.setUserItem("rosterVer",$(iq).find("query").attr("ver")),jsxc.xmpp.bookmarks.load(),jsxc.gui.roster.loaded=!0,jsxc.debug("Roster loaded"),$(document).trigger("cloaded.roster.jsxc"),jsxc.changeUIState(jsxc.CONST.UISTATE.READY)},onRosterChanged:function(iq){var iqSender=$(iq).attr("from"),ownBareJid=Strophe.getBareJidFromJid(jsxc.xmpp.conn.jid);return!(!iqSender||iqSender===ownBareJid)||(jsxc.debug("onRosterChanged",iq),$(iq).find("item").each(function(){var jid=$(this).attr("jid"),name=$(this).attr("name")||jid,bid=jsxc.jidToBid(jid),sub=$(this).attr("subscription");if("remove"===sub)jsxc.gui.roster.purge(bid);else{var bl=jsxc.storage.getUserItem("buddylist");bl.indexOf(bid)<0&&(bl.push(bid),jsxc.storage.setUserItem("buddylist",bl));"updated"===jsxc.storage.saveBuddy(bid,{jid:jid,name:name,sub:sub})?(jsxc.gui.update(bid),jsxc.gui.roster.reorder(bid)):jsxc.gui.roster.add(bid)}if("from"===sub||"both"===sub){var notice,notices=jsxc.storage.getUserItem("notices"),noticeKey=null;for(noticeKey in notices)notice=notices[noticeKey],"gui.showApproveDialog"===notice.fnName&¬ice.fnParams[0]===jid&&(jsxc.debug("Remove notice with key "+noticeKey),jsxc.notice.remove(noticeKey))}}),$(iq).find("query").attr("ver")&&jsxc.storage.setUserItem("rosterVer",$(iq).find("query").attr("ver")),jsxc.storage.getUserItem("buddylist")&&0!==jsxc.storage.getUserItem("buddylist").length?$("#jsxc_roster > p:first").remove():jsxc.gui.roster.empty(),!0)},onPresence:function(presence){jsxc.debug("onPresence",presence);var ptype=$(presence).attr("type"),from=$(presence).attr("from"),jid=Strophe.getBareJidFromJid(from).toLowerCase(),r=Strophe.getResourceFromJid(from),bid=jsxc.jidToBid(jid),data=jsxc.storage.getUserItem("buddy",bid)||{},res=jsxc.storage.getUserItem("res",bid)||{},status=null,xVCard=$(presence).find('x[xmlns="vcard-temp:x:update"]');if(jid===Strophe.getBareJidFromJid(jsxc.storage.getItem("jid")))return!0;if("error"===ptype){$(document).trigger("error.presence.jsxc",[from,presence]);var error=$(presence).find("error");return jsxc.error("[XMPP] "+error.attr("code")+" "+error.find(">:first-child").prop("tagName")),!0}if("subscribe"===ptype){return jsxc.storage.getUserItem("buddylist").indexOf(bid)>-1?(jsxc.debug("Auto approve contact request, because he is already in our contact list."),jsxc.xmpp.resFriendReq(jid,!0),"to"!==data.sub&&jsxc.xmpp.addBuddy(jid,data.name),!0):(jsxc.storage.setUserItem("friendReq",{jid:jid,approve:-1}),jsxc.notice.add({msg:$.t("Friendship_request"),description:$.t("from")+" "+jid,type:"contact"},"gui.showApproveDialog",[jid]),!0)}if("unavailable"===ptype||"unsubscribed"===ptype)status=jsxc.CONST.STATUS.indexOf("offline");else{var show=$(presence).find("show").text();status=""===show?jsxc.CONST.STATUS.indexOf("online"):jsxc.CONST.STATUS.indexOf(show)}0===status?delete res[r]:r&&(res[r]=status);var maxVal=[],max=0,prop=null;for(prop in res)res.hasOwnProperty(prop)&&max<=res[prop]&&(max!==res[prop]&&(maxVal=[],max=res[prop]),maxVal.push(prop));if(0===data.status&&max>0&&jsxc.notification.notify({title:data.name,msg:$.t("has_come_online"),source:bid}),"groupchat"!==data.type&&(data.status=max),data.res=maxVal,data.jid=jid,xVCard.length>0&&"groupchat"!==data.type){var photo=xVCard.find("photo");photo.length>0&&photo.text()!==data.avatar&&(jsxc.storage.removeUserItem("avatar",data.avatar),data.avatar=photo.text())}return jsxc.gui.window.get(bid).length>0&&jsxc.gui.window.get(bid).data("jid",jid),jsxc.storage.setUserItem("buddy",bid,data),jsxc.storage.setUserItem("res",bid,res),jsxc.debug("Presence ("+from+"): "+jsxc.CONST.STATUS[status]),jsxc.gui.update(bid),jsxc.gui.roster.reorder(bid),$(document).trigger("presence.jsxc",[from,status,presence]),!0},onChatMessage:function(stanza){var message,carbon,forwarded=$(stanza).find('forwarded[xmlns="'+jsxc.CONST.NS.FORWARD+'"]'),originalSender=$(stanza).attr("from");if(forwarded.length>0){if(message=forwarded.find("> message"),forwarded=!0,carbon=$(stanza).find('> [xmlns="'+jsxc.CONST.NS.CARBONS+'"]'),0===carbon.length)carbon=!1;else if(originalSender!==Strophe.getBareJidFromJid(jsxc.xmpp.conn.jid))return!0;jsxc.debug("Incoming forwarded message",message)}else message=stanza,forwarded=!1,carbon=!1,jsxc.debug("Incoming message",message);var body=$(message).find("body:first").text(),htmlBody=$(message).find('body[xmlns="'+Strophe.NS.XHTML+'"]');if(!body||body.match(/\?OTR/i)&&forwarded)return!0;var bid,type=$(message).attr("type"),from=$(message).attr("from"),mid=$(message).attr("id"),delay=$(message).find('delay[xmlns="urn:xmpp:delay"]'),stamp=delay.length>0?new Date(delay.attr("stamp")):new Date;if(stamp=stamp.getTime(),carbon){var direction="sent"===carbon.prop("tagName")?jsxc.Message.OUT:jsxc.Message.IN;return bid=jsxc.jidToBid("out"===direction?$(message).attr("to"):from),jsxc.gui.window.postMessage({bid:bid,direction:direction,msg:body,encrypted:!1,forwarded:forwarded,stamp:stamp}),!0}forwarded&&(body=from+" "+$.t("to")+" "+$(stanza).attr("to")+'"'+body+'"',from=$(stanza).attr("from"));var jid=Strophe.getBareJidFromJid(from);bid=jsxc.jidToBid(jid);var data=jsxc.storage.getUserItem("buddy",bid),request=$(message).find("request[xmlns='urn:xmpp:receipts']");if(null===data){0===(jsxc.storage.getUserItem("chat",bid)||[]).length&&jsxc.notice.add({msg:$.t("Unknown_sender"),description:$.t("You_received_a_message_from_an_unknown_sender_")+" ("+bid+")."},"gui.showUnknownSender",[bid]);var msg=jsxc.removeHTML(body);msg=jsxc.escapeHTML(msg);return new jsxc.Message({bid:bid,msg:msg,direction:jsxc.Message.IN,encrypted:!1,forwarded:forwarded,stamp:stamp}).save(),!0}var win=jsxc.gui.window.init(bid);"chat"===type&&(win.data("jid",from),jsxc.storage.updateUserItem("buddy",bid,{jid:from})),$(document).trigger("message.jsxc",[from,body]),jsxc.master&&!jsxc.otr.objects[bid]&&jsxc.otr.create(bid),forwarded||null===mid||!request.length||null===data||"both"!==data.sub&&"from"!==data.sub||"chat"!==type||jsxc.xmpp.conn.send($msg({to:from}).c("received",{xmlns:"urn:xmpp:receipts",id:mid}));var attachment;if(1===htmlBody.length){var httpUploadElement=htmlBody.find("a[data-type][data-name][data-size]");1===httpUploadElement.length&&(attachment={type:httpUploadElement.attr("data-type"),name:httpUploadElement.attr("data-name"),size:httpUploadElement.attr("data-size")},httpUploadElement.attr("data-thumbnail")&&httpUploadElement.attr("data-thumbnail").match(/^\s*data:[a-z]+\/[a-z0-9-+.*]+;base64,[a-z0-9=+\/]+$/i)&&(attachment.thumbnail=httpUploadElement.attr("data-thumbnail")),httpUploadElement.attr("href")&&httpUploadElement.attr("href").match(/^https:\/\//)&&(attachment.data=httpUploadElement.attr("href"),body=null),attachment.type.match(/^[a-z]+\/[a-z0-9-+.*]+$/i)&&attachment.name.match(/^[\s\w.,-]+$/i)&&attachment.size.match(/^\d+$/i)||(attachment=void 0,jsxc.warn("Invalid file type, name or size.")))}return jsxc.otr.objects.hasOwnProperty(bid)&&body?jsxc.otr.objects[bid].receiveMsg(body,{_uid:mid,foo:"bar",stamp:stamp,forwarded:forwarded,attachment:attachment}):jsxc.gui.window.postMessage({_uid:mid,bid:bid,direction:jsxc.Message.IN,msg:body,encrypted:!1,forwarded:forwarded,stamp:stamp,attachment:attachment}),!0},onErrorMessage:function(message){var bid=jsxc.jidToBid($(message).attr("from"));return 0===jsxc.gui.window.get(bid).length||!$(message).attr("id")||($(message).find("item-not-found").length>0?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_item-not-found")}):$(message).find("forbidden").length>0?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_forbidden")}):$(message).find("not-acceptable").length>0?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_not-acceptable")}):$(message).find("remote-server-not-found").length>0?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_remote-server-not-found")}):$(message).find("service-unavailable").length>0?0===$(message).find('[xmlns="'+Strophe.NS.CHATSTATES+'"]').length&&jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_resource-unavailable")}):jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send")}),jsxc.debug("error message for "+bid,$(message).find("error")[0]),!0)},onHeadlineMessage:function(stanza){stanza=$(stanza);var from=stanza.attr("from"),domain=Strophe.getDomainFromJid(from);if(domain!==from){if(!jsxc.storage.getUserItem("buddy",jsxc.jidToBid(from)))return!0}else if(domain!==Strophe.getDomainFromJid(jsxc.xmpp.conn.jid))return!0;var subject=stanza.find("subject:first").text()||$.t("Notification"),body=stanza.find("body:first").text();return jsxc.notice.add({msg:subject,description:body,type:domain===from?"announcement":null},"gui.showNotification",[subject,body,from]),!0},onVersionRequest:function(stanza){stanza=$(stanza);var from=stanza.attr("from"),id=stanza.attr("id"),iq=$iq({type:"result",to:from,id:id}).c("query",{ -xmlns:Strophe.NS.VERSION}).c("name").t("JSXC").up().c("version").t(jsxc.version);return jsxc.xmpp.conn.sendIQ(iq),!0},onRidChange:function(rid){jsxc.storage.setItem("rid",rid)},resFriendReq:function(from,approve){jsxc.master?(jsxc.xmpp.conn.send($pres({to:from,type:approve?"subscribed":"unsubscribed"})),jsxc.storage.removeUserItem("friendReq"),jsxc.gui.dialog.close()):jsxc.storage.updateUserItem("friendReq","approve",approve)},addBuddy:function(username,alias){var bid=jsxc.jidToBid(username);if(jsxc.master){var iq=$iq({type:"set"}).c("query",{xmlns:"jabber:iq:roster"}).c("item",{jid:username,name:alias||""});jsxc.xmpp.conn.sendIQ(iq),jsxc.xmpp.conn.send($pres({to:username,type:"subscribe"})),jsxc.storage.removeUserItem("add",bid)}else jsxc.storage.setUserItem("add",bid,{username:username,alias:alias||null})},removeBuddy:function(jid){var bid=jsxc.jidToBid(jid),iq=$iq({type:"set"}).c("query",{xmlns:"jabber:iq:roster"}).c("item",{jid:Strophe.getBareJidFromJid(jid),subscription:"remove"});jsxc.xmpp.conn.sendIQ(iq),jsxc.gui.roster.purge(bid)},onReceived:function(stanza){var received=$(stanza).find("received[xmlns='urn:xmpp:receipts']");if(received.length){var receivedId=received.attr("id");new jsxc.Message(receivedId).received()}return!0},sendMessage:function(message){var bid=message.bid,msg=message.htmlMsg,mucRoomNames=jsxc.xmpp.conn.muc&&jsxc.xmpp.conn.muc.roomNames?jsxc.xmpp.conn.muc.roomNames:[],isMucBid=mucRoomNames.indexOf(bid)>=0;jsxc.otr.objects.hasOwnProperty(bid)&&!isMucBid?jsxc.otr.objects[bid].sendMsg(msg,message):jsxc.xmpp._sendMessage(jsxc.gui.window.get(bid).data("jid"),msg,message)},_sendMessage:function(jid,msg,message){var data=jsxc.storage.getUserItem("buddy",jsxc.jidToBid(jid))||{},isBar=Strophe.getBareJidFromJid(jid)===jid,type=data.type||"chat";message=message||{};var xmlMsg=$msg({to:jid,type:type,id:message._uid});if(message.type===jsxc.Message.HTML){xmlMsg.c("html",{xmlns:Strophe.NS.XHTML_IM});var body=Strophe.xmlElement("body",{xmlns:Strophe.NS.XHTML});body.innerHTML=msg,xmlMsg.node.appendChild(body)}else xmlMsg.c("body").t(msg);jsxc.xmpp.carbons.enabled&&msg.match(/^\?OTR/)&&xmlMsg.up().c("private",{xmlns:jsxc.CONST.NS.CARBONS}),msg.match(/^\?OTR/)&&xmlMsg.up().c("no-permanent-store",{xmlns:jsxc.CONST.NS.HINTS}),"chat"===type&&(isBar||jsxc.xmpp.conn.caps.hasFeatureByJid(jid,Strophe.NS.RECEIPTS))&&xmlMsg.up().c("request",{xmlns:"urn:xmpp:receipts"}),jsxc.xmpp.conn.chatstates&&!jsxc.xmpp.chatState.isDisabled()&&xmlMsg.up().c("active",{xmlns:Strophe.NS.CHATSTATES}),jsxc.xmpp.conn.send(xmlMsg)},loadVcard:function(bid,cb,error_cb){jsxc.master?jsxc.xmpp.conn.vcard.get(cb,bid,error_cb):(jsxc.storage.setUserItem("vcard",bid,"request:"+(new Date).getTime()),$(document).one("loaded.vcard.jsxc",function(ev,result){result&&"success"===result.state?cb($(result.data).get(0)):error_cb()}))},getCapabilitiesByJid:function(jid){if(jsxc.xmpp.conn)return jsxc.xmpp.conn.caps.getCapabilitiesByJid(jid);var jidVerIndex=JSON.parse(localStorage.getItem("strophe.caps._jidVerIndex"))||{},knownCapabilities=JSON.parse(localStorage.getItem("strophe.caps._knownCapabilities"))||{};return jidVerIndex[jid]?knownCapabilities[jidVerIndex[jid]]:null},hasFeatureByJid:function(jid,feature,cb){var conn=jsxc.xmpp.conn;if(cb=cb||function(){},!feature)return!1;$.isArray(feature)||(feature=$.makeArray(feature));var check=function(knownCapabilities){if(!knownCapabilities)return null;var i;for(i=0;i:-( >:( >:-( >:(","angry"],[":-) :)","slight_smile"],[":-D :D","grin"],[":-( :(","disappointed"],[";-) ;)","wink"],[":-P :P","stuck_out_tongue"],["=-O","astonished"],[":kiss: :-*","kissing_heart"],["8-) :cool:","sunglasses"],[":-X :X","zipper_mouth"],[":yes:","thumbsup"],[":no:","thumbsdown"],[":beer:","beer"],[":coffee:","coffee"],[":devil:","smiling_imp"],[":kiss: :kissing:","kissing"],["@->-- @->--","rose"],[":music:","musical_note"],[":love:","heart_eyes"],[":heart:","heart"],[":brokenheart:","broken_heart"],[":zzz:","zzz"],[":wait:","hand_splayed"]],favicon:null,regShortNames:null,emoticonList:{core:{":klaus:":["klaus"],":jabber:":["jabber"],":xmpp:":["xmpp"],":jsxc:":["jsxc"],":owncloud:":["owncloud"],":nextcloud:":["nextcloud"]},emojione:emojione.emojioneList},queryActions:{message:function(jid,params){var bid=jsxc.jidToBid(jid);jsxc.storage.getUserItem("buddy",bid)||jsxc.storage.saveBuddy(bid,{jid:jid,name:bid,status:0,sub:"none",res:[],rnd:Math.random()});var win=jsxc.gui.window.open(bid);params&&"string"==typeof params.body&&win.find(".jsxc_textinput").val(params.body)},remove:function(jid){jsxc.gui.showRemoveDialog(jsxc.jidToBid(jid))},subscribe:function(jid,params){jsxc.gui.showContactDialog(jid),params&&(params.name,!0)&&$("#jsxc_alias").val(params.name)},vcard:function(jid){jsxc.gui.showVcard(jid)},join:function(jid,params){var password=params&¶ms.password?params.password:null;jsxc.muc.showJoinChat(jid,password)}},init:function(){if(!($("#jsxc_windowList").length>0)){jsxc.changeUIState(jsxc.CONST.UISTATE.INITIATING),jsxc.gui.regShortNames=new RegExp(emojione.regShortNames.source+"|("+Object.keys(jsxc.gui.emoticonList.core).join("|")+")","gi"),$("body").append($(jsxc.gui.template.get("windowList"))),$(window).resize(jsxc.gui.updateWindowListSB),$("#jsxc_windowList").resize(jsxc.gui.updateWindowListSB),$("#jsxc_windowListSB .jsxc_scrollLeft").click(function(){jsxc.gui.scrollWindowListBy(-200)}),$("#jsxc_windowListSB .jsxc_scrollRight").click(function(){jsxc.gui.scrollWindowListBy(200)}),$("#jsxc_windowList").on("wheel",function(ev){$("#jsxc_windowList").data("isOver")&&jsxc.gui.scrollWindowListBy(ev.originalEvent.wheelDelta>0?200:-200)}),jsxc.gui.tooltip("#jsxc_windowList");var fo=jsxc.options.get("favicon");fo&&fo.enable&&(jsxc.gui.favicon=new Favico({animation:"pop",bgColor:fo.bgColor,textColor:fo.textColor}),jsxc.gui.favicon.badge(jsxc.storage.getUserItem("unreadMsg")||0)),jsxc.el_exists("#jsxc_roster")||jsxc.gui.roster.init(),$.each(jsxc.gui.emotions,function(i,val){var reg=val[0].replace(/(\/|\||\*|\.|\+|\?|\^|\$|\(|\)|\[|\]|\{|\})/g,"\\$1");reg="("+reg.split(" ").join("|")+")",jsxc.gui.emotions[i][2]=new RegExp(reg,"g")}),jsxc.gui.windowTemplate=$(jsxc.gui.template.get("chatWindow")),jsxc.gui.buddyTemplate=$(jsxc.gui.template.get("rosterBuddy"))}},tooltip:function(selector){$(selector).tooltip({show:{delay:600},content:function(){return $(this).attr("title").replace(/\n/g,"
")}})},update:function(bid){var data=jsxc.storage.getUserItem("buddy",bid);if(!data)return void jsxc.debug("No data for "+bid);var ri=jsxc.gui.roster.getItem(bid),we=jsxc.gui.window.get(bid),ue=ri.add(we),spot=$('.jsxc_spot[data-bid="'+bid+'"]');switch(ri.data(data),jsxc.gui.updatePresence(bid,jsxc.CONST.STATUS[data.status]),ue.find(".jsxc_name:first").add(spot).text(data.name).attr("title",$.t("is_",{status:$.t(jsxc.CONST.STATUS[data.status])})),data.msgstate){case 0:we.find(".jsxc_transfer").removeClass("jsxc_enc jsxc_fin").attr("title",$.t("your_connection_is_unencrypted")),we.find(".jsxc_settings .jsxc_verification").addClass("jsxc_disabled"),we.find(".jsxc_settings .jsxc_transfer").text($.t("start_private"));break;case 1:we.find(".jsxc_transfer").addClass("jsxc_enc").attr("title",$.t("your_connection_is_encrypted")),we.find(".jsxc_settings .jsxc_verification").removeClass("jsxc_disabled"),we.find(".jsxc_settings .jsxc_transfer").text($.t("close_private"));break;case 2:we.find(".jsxc_settings .jsxc_verification").addClass("jsxc_disabled"),we.find(".jsxc_transfer").removeClass("jsxc_enc").addClass("jsxc_fin").attr("title",$.t("your_buddy_closed_the_private_connection")),we.find(".jsxc_settings .jsxc_transfer").text($.t("close_private"))}data.trust?we.find(".jsxc_transfer").addClass("jsxc_trust").attr("title",$.t("your_buddy_is_verificated")):we.find(".jsxc_transfer").removeClass("jsxc_trust"),data.sub&&"both"!==data.sub?ue.addClass("jsxc_oneway"):ue.removeClass("jsxc_oneway");var info=Strophe.getBareJidFromJid(data.jid)+"\n";info+=$.t("Subscription")+": "+$.t(data.sub)+"\n",info+=$.t("Status")+": "+$.t(jsxc.CONST.STATUS[data.status]),ri.find(".jsxc_name").attr("title",info),jsxc.gui.avatar.update(ri.add(we.find(".jsxc_bar")),data.jid,data.avatar),$(document).trigger("update.gui.jsxc",[bid])},updateWindowListSB:function(){$("#jsxc_windowList>ul").width()>$("#jsxc_windowList").width()?$("#jsxc_windowListSB > div").removeClass("jsxc_disabled"):($("#jsxc_windowListSB > div").addClass("jsxc_disabled"),$("#jsxc_windowList>ul").css("right","0px"))},scrollWindowListBy:function(offset){var scrollWidth=$("#jsxc_windowList>ul").width(),width=$("#jsxc_windowList").width(),el=$("#jsxc_windowList>ul"),right=parseInt(el.css("right"))-offset,padding=$("#jsxc_windowListSB").width();scrollWidth0&&(right=0),right0?void setTimeout(function(){jsxc.gui.showVerification(bid)},3e3):jsxc.storage.getUserItem("buddy",bid).msgstate!==OTR.CONST.MSGSTATE_ENCRYPTED?void jsxc.warn("Connection not encrypted"):(jsxc.gui.dialog.open(jsxc.gui.template.get("authenticationDialog",bid),{name:"smp"}),$("#jsxc_dialog > div:gt(0)").hide(),$("#jsxc_dialog > div:eq(0) button").click(function(){$(this).siblings().removeClass("active"),$(this).addClass("active"),$(this).get(0).blur(),$("#jsxc_dialog > div:gt(0)").hide(),$("#jsxc_dialog > div:eq("+($(this).index()+1)+")").show().find("input:first").focus()}),$("#jsxc_dialog > div:eq(1) .jsxc_submit").click(function(){jsxc.master&&(jsxc.otr.objects[bid].trust=!0),jsxc.storage.updateUserItem("buddy",bid,"trust",!0),jsxc.gui.dialog.close("smp"),jsxc.storage.updateUserItem("buddy",bid,"trust",!0),jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("conversation_is_now_verified")}),jsxc.gui.update(bid)}),$("#jsxc_dialog > div:eq(2) .jsxc_submit").click(function(){var div=$("#jsxc_dialog > div:eq(2)"),sec=div.find("#jsxc_secret2").val(),quest=div.find("#jsxc_quest").val();if(""===sec||""===quest)return void div.find('input[value=""]').addClass("jsxc_invalid").keyup(function(){$(this).val().match(/.*/)&&$(this).removeClass("jsxc_invalid")});jsxc.master?jsxc.otr.sendSmpReq(bid,sec,quest):jsxc.storage.setUserItem("smp",bid,{sec:sec,quest:quest}),jsxc.gui.dialog.close("smp"),jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("authentication_query_sent")})}),void $("#jsxc_dialog > div:eq(3) .jsxc_submit").click(function(){var div=$("#jsxc_dialog > div:eq(3)"),sec=div.find("#jsxc_secret").val();if(""===sec)return void div.find("#jsxc_secret").addClass("jsxc_invalid").keyup(function(){$(this).val().match(/.*/)&&$(this).removeClass("jsxc_invalid")});jsxc.master?jsxc.otr.sendSmpReq(bid,sec):jsxc.storage.setUserItem("smp",bid,{sec:sec,quest:null}),jsxc.gui.dialog.close("smp"),jsxc.gui.window.postMessage({bid:bid,direction:"sys",msg:$.t("authentication_query_sent")})}))},showApproveDialog:function(from){jsxc.gui.dialog.open(jsxc.gui.template.get("approveDialog"),{noClose:!0}),$("#jsxc_dialog .jsxc_their_jid").text(Strophe.getBareJidFromJid(from)),$("#jsxc_dialog .jsxc_deny").click(function(ev){ev.stopPropagation(),jsxc.xmpp.resFriendReq(from,!1),jsxc.gui.dialog.close()}),$("#jsxc_dialog .jsxc_approve").click(function(ev){ev.stopPropagation();var data=jsxc.storage.getUserItem("buddy",jsxc.jidToBid(from));jsxc.xmpp.resFriendReq(from,!0),data&&"from"!==data.sub||jsxc.gui.showContactDialog(from)})},showContactDialog:function(username){jsxc.gui.dialog.open(jsxc.gui.template.get("contactDialog")),username&&$("#jsxc_username").val(username),$("#jsxc_username").keyup(function(){if("function"==typeof jsxc.options.getUsers){var val=$(this).val();$("#jsxc_userlist").empty(),""!==val&&jsxc.options.getUsers.call(this,val,function(list){$("#jsxc_userlist").empty(),$.each(list||{},function(uid,displayname){var option=$("