From 9f342ec4455ad67f9960a152f28894dc22bd3490 Mon Sep 17 00:00:00 2001 From: sualko Date: Thu, 5 Jul 2018 15:36:31 +0200 Subject: [PATCH] build v3.4.1 --- appinfo/info.xml | 2 +- build/appinfo/application.php | 7 +- build/appinfo/info.xml | 2 +- build/css/jsxc.oc.css | 4 +- build/js/eof.js | 4 +- build/js/jsxc/css/jsxc.css | 39 +++++-- build/js/jsxc/jsxc.js | 158 ++++++++++++++------------ build/js/jsxc/jsxc.min.js | 2 +- build/js/jsxc/jsxc.min.js.map | 2 +- build/js/jsxc/lib/jsxc.dep.js | 4 +- build/js/jsxc/lib/jsxc.dep.min.js | 2 +- build/js/jsxc/lib/jsxc.dep.min.js.map | 2 +- build/js/jsxc/lib/translation.js | 2 +- build/js/ojsxc.js | 4 +- js/jsxc | 2 +- package.json | 2 +- 16 files changed, 139 insertions(+), 99 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index fc8d22ac..f89aed1c 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.4.0 + 3.4.1 agpl Klaus Herberth Tobia De Koninck diff --git a/build/appinfo/application.php b/build/appinfo/application.php index 7d11dc16..44cf35b9 100644 --- a/build/appinfo/application.php +++ b/build/appinfo/application.php @@ -363,7 +363,12 @@ public static function convertToRealUID($providedUid) { $backends = \OC::$server->getUserManager()->getBackends(); foreach ($backends as $backend) { - if ($backend->getBackendName() === $user->getBackendClassName()) { + if ($backend instanceof IUserBackend) { + $backendName = $backend->getBackendName(); + } else { + $backendName = get_class($backend); + } + if ($backendName === $user->getBackendClassName()) { if (method_exists($backend, 'loginName2UserName')) { $uid = $backend->loginName2UserName($providedUid); if ($uid !== false) { diff --git a/build/appinfo/info.xml b/build/appinfo/info.xml index fc8d22ac..f89aed1c 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.4.0 + 3.4.1 agpl Klaus Herberth Tobia De Koninck diff --git a/build/css/jsxc.oc.css b/build/css/jsxc.oc.css index 903fa16f..0a6488d0 100644 --- a/build/css/jsxc.oc.css +++ b/build/css/jsxc.oc.css @@ -1,5 +1,5 @@ /*! - * ojsxc v3.4.0 - 2018-05-23 + * ojsxc v3.4.1 - 2018-07-05 * * Copyright (c) 2018 Klaus Herberth
* Released under the MIT license @@ -7,7 +7,7 @@ * Please see http://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.4.0 + * @version 3.4.1 * @license MIT */ diff --git a/build/js/eof.js b/build/js/eof.js index 0b2a3ef2..c37963ed 100644 --- a/build/js/eof.js +++ b/build/js/eof.js @@ -1,5 +1,5 @@ /*! - * ojsxc v3.4.0 - 2018-05-23 + * ojsxc v3.4.1 - 2018-07-05 * * Copyright (c) 2018 Klaus Herberth
* Released under the MIT license @@ -7,7 +7,7 @@ * Please see http://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.4.0 + * @version 3.4.1 * @license MIT */ diff --git a/build/js/jsxc/css/jsxc.css b/build/js/jsxc/css/jsxc.css index bdbd1375..c095ad11 100644 --- a/build/js/jsxc/css/jsxc.css +++ b/build/js/jsxc/css/jsxc.css @@ -70,6 +70,7 @@ .mfp-arrow, .mfp-preloader, .mfp-counter { + -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } @@ -1113,6 +1114,7 @@ img.emojione { font-size: 14px; line-height: 1.428571429; border-radius: 4px; + -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } @@ -2712,9 +2714,10 @@ fieldset[disabled] line-height: 30px; float: left; cursor: pointer; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; } + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } #jsxc_windowListSB > div:hover { background-color: #b3b2b2; } #jsxc_windowListSB > .jsxc_disabled { @@ -2909,6 +2912,9 @@ fieldset[disabled] resize: none; transition: height 0.5s; font-size: 13px; } + .jsxc_window textarea::-webkit-input-placeholder { + color: #000; + opacity: 0.3; } .jsxc_window textarea::-moz-placeholder { color: #000; opacity: 0.3; } @@ -3518,15 +3524,17 @@ ul.jsxc_vCard { cursor: pointer; border: 1px solid transparent; border-radius: 4px; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; color: #fff; background-color: #5cb85c; border-color: #4cae4c; } .jsxc_oneway .jsxc_avatar { - filter: grayscale(100%); } + -webkit-filter: grayscale(100%); + filter: grayscale(100%); } img.jsxc_vCard { float: right; @@ -3558,9 +3566,10 @@ img.jsxc_vCard { white-space: nowrap; vertical-align: middle; cursor: pointer; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; background-image: none; border: 1px solid transparent; border-radius: 4px; @@ -3593,7 +3602,8 @@ img.jsxc_vCard { z-index: 110; margin: 8px 2px 5px 10px; right: 0; - filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); + -webkit-filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); + filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); padding: 4px 12px; padding-left: 5px; } .jsxc_menu:after { @@ -3927,6 +3937,11 @@ div:full-screen { div:full-screen.jsxc_localvideo { border: 1px solid #fff; } +div:-webkit-full-screen { + width: 100%; + height: 100%; + background-color: #000; } + div:-moz-full-screen { width: 100%; height: 100%; @@ -3941,6 +3956,8 @@ div:fullscreen { width: 100%; height: 100%; background-color: #000; } + div:-webkit-full-screen.jsxc_localvideo { + border: 1px solid #fff; } div:-moz-full-screen.jsxc_localvideo { border: 1px solid #fff; } div:-ms-fullscreen.jsxc_localvideo { diff --git a/build/js/jsxc/jsxc.js b/build/js/jsxc/jsxc.js index a7005573..441350f8 100644 --- a/build/js/jsxc/jsxc.js +++ b/build/js/jsxc/jsxc.js @@ -1,5 +1,5 @@ /*! - * jsxc v3.4.0 - 2018-05-23 + * jsxc v3.4.1 - 2018-07-05 * * Copyright (c) 2018 Klaus Herberth
* Released under the MIT license @@ -7,7 +7,7 @@ * Please see https://www.jsxc.org/ * * @author Klaus Herberth - * @version 3.4.0 + * @version 3.4.1 * @license MIT */ @@ -25,7 +25,7 @@ var jsxc = null, RTC = null, RTCPeerconnection = null; */ jsxc = { /** Version of jsxc */ - version: '3.4.0', + version: '3.4.1', /** True if i'm the master */ master: false, @@ -95,7 +95,7 @@ jsxc = { REGEX: { JID: new RegExp('\\b[^"&\'\\/:<>@\\s]+@[\\w-_.]+\\b', 'ig'), URL: new RegExp(/(https?:\/\/|www\.)[^\s<>'"]+/gi), - GEOURI: new RegExp(/geo:(\d+\.\d+),(\d+\.\d+)(,\d+\.\d+)?(;u=(\d+(\.\d+)?))?/), + GEOURI: new RegExp(/geo:(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)(?:,-?\d+(?:\.\d+)?)?(?:;crs=[\w-]+)?(?:;u=(\d+(?:\.\d+)?))?(?:;[\w-]+=(?:[\w-_.!~*'()]|%[\da-f][\da-f])+)*/) }, NS: { CARBONS: 'urn:xmpp:carbons:2', @@ -2167,71 +2167,10 @@ jsxc.xmpp = { })); } - var attachment; - if (htmlBody.length === 1) { - var httpUploadElement = htmlBody.find('a[data-type][data-name][data-size]'); - - if (httpUploadElement.length === 1) { - // deprecated syntax @since 3.2.1 - attachment = { - type: httpUploadElement.attr('data-type'), - name: httpUploadElement.attr('data-name'), - size: httpUploadElement.attr('data-size'), - }; - - if (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'); - } - - if (httpUploadElement.attr('href') && httpUploadElement.attr('href').match(/^https:\/\//)) { - attachment.data = httpUploadElement.attr('href'); - body = null; - } - - if (!attachment.type.match(/^[a-z]+\/[a-z0-9-+.*]+$/i) || !attachment.name.match(/^[\s\w.,-]+$/i) || !attachment.size.match(/^\d+$/i)) { - attachment = undefined; - - jsxc.warn('Invalid file type, name or size.'); - } - } else if (htmlBody.find('>a').length === 1) { - var linkElement = htmlBody.find('>a'); - var metaString = ''; - var thumbnail; - - if (linkElement.find('>img').length === 1) { - var imgElement = linkElement.find('>img'); - var src = imgElement.attr('src') || ''; - var altString = imgElement.attr('alt') || ''; - metaString = altString.replace(/^Preview:/, ''); - - if (src.match(/^\s*data:[a-z]+\/[a-z0-9-+.*]+;base64,[a-z0-9=+/]+$/i)) { - thumbnail = src; - } - } else { - metaString = linkElement.text(); - } - - var metaMatch = metaString.match(/^([a-z]+\/[a-z0-9-+.*]+)\|(\d+)\|([\s\w.,-]+)/); + var attachment = jsxc.xmpp.getAttachmentFromHtmlBody(htmlBody); - if (metaMatch) { - attachment = { - type: metaMatch[1], - size: metaMatch[2], - name: metaMatch[3], - }; - - if (thumbnail) { - attachment.thumbnail = thumbnail; - } - - if (linkElement.attr('href') && linkElement.attr('href').match(/^https?:\/\//)) { - attachment.data = linkElement.attr('href'); - body = null; - } - } else { - jsxc.warn('Invalid file type, name or size.'); - } - } + if (attachment) { + body = null; } if (jsxc.otr.objects.hasOwnProperty(bid) && body) { @@ -2376,6 +2315,77 @@ jsxc.xmpp = { jsxc.storage.setItem('rid', rid); }, + getAttachmentFromHtmlBody: function(htmlBody) { + if (htmlBody.length !== 1) { + return; + } + + var attachment; + var httpUploadElement = htmlBody.find('a[data-type][data-name][data-size]'); + + if (httpUploadElement.length === 1) { + // deprecated syntax @since 3.2.1 + attachment = { + type: httpUploadElement.attr('data-type'), + name: httpUploadElement.attr('data-name'), + size: httpUploadElement.attr('data-size'), + }; + + if (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'); + } + + if (httpUploadElement.attr('href') && httpUploadElement.attr('href').match(/^https:\/\//)) { + attachment.data = httpUploadElement.attr('href'); + } + + if (!attachment.type.match(/^[a-z]+\/[a-z0-9-+.*]+$/i) || !attachment.name.match(/^[\s\w.,-]+$/i) || !attachment.size.match(/^\d+$/i)) { + attachment = undefined; + + jsxc.warn('Invalid file type, name or size.'); + } + } else if (htmlBody.find('>a').length === 1) { + var linkElement = htmlBody.find('>a'); + var metaString = ''; + var thumbnail; + + if (linkElement.find('>img').length === 1) { + var imgElement = linkElement.find('>img'); + var src = imgElement.attr('src') || ''; + var altString = imgElement.attr('alt') || ''; + metaString = altString.replace(/^Preview:/, ''); + + if (src.match(/^\s*data:[a-z]+\/[a-z0-9-+.*]+;base64,[a-z0-9=+/]+$/i)) { + thumbnail = src; + } + } else { + metaString = linkElement.text(); + } + + var metaMatch = metaString.match(/^([a-z]+\/[a-z0-9-+.*]+)\|(\d+)\|([\s\w.,-]+)/); + + if (metaMatch) { + attachment = { + type: metaMatch[1], + size: metaMatch[2], + name: metaMatch[3], + }; + + if (thumbnail) { + attachment.thumbnail = thumbnail; + } + + if (linkElement.attr('href') && linkElement.attr('href').match(/^https?:\/\//)) { + attachment.data = linkElement.attr('href'); + } + } else { + jsxc.warn('Invalid file type, name or size.'); + } + } + + return attachment; + }, + /** * response to friendship request * @@ -4153,7 +4163,7 @@ jsxc.gui = { var matches = $(this).attr('href').match(jsxc.CONST.REGEX.GEOURI); var latitude = matches[1]; var longitude = matches[2]; - var accuracy = matches[5]; + var accuracy = matches[3]; var osmUrl = 'https://www.openstreetmap.org/?mlat=' + latitude + '&mlon=' + longitude + '#map=16/' + latitude + '/' + longitude; var label = 'OSM: ' + ddToDms(latitude, longitude); @@ -7992,6 +8002,7 @@ jsxc.muc = { } var from = $(message).attr('from'); + var htmlBodyElement = $(message).find('body[xmlns="' + Strophe.NS.XHTML + '"]').first(); var body = $(message).find('body:first').text(); var room = jsxc.jidToBid(from); var nickname = Strophe.unescapeNode(Strophe.getResourceFromJid(from)); @@ -8012,12 +8023,19 @@ jsxc.muc = { jsxc.gui.window.init(room); + var attachment = jsxc.xmpp.getAttachmentFromHtmlBody(htmlBodyElement); + + if (attachment) { + body = null; + } + jsxc.gui.window.postMessage({ bid: room, direction: jsxc.Message.IN, msg: body, stamp: stamp, - sender: sender + sender: sender, + attachment: attachment }); } diff --git a/build/js/jsxc/jsxc.min.js b/build/js/jsxc/jsxc.min.js index d1567d19..da9d209e 100644 --- a/build/js/jsxc/jsxc.min.js +++ b/build/js/jsxc/jsxc.min.js @@ -1,2 +1,2 @@ -var jsxc=null,RTC=null,RTCPeerconnection=null;!function($){"use strict";(jsxc={version:"3.4.0",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),GEOURI:new RegExp(/geo:(\d+\.\d+),(\d+\.\d+)(,\d+\.\d+)?(;u=(\d+(\.\d+)?))?/)},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){var d;!0===jsxc.storage.getItem("debug")&&console.log(msg,data);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.runMigrations(),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()){var lang;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),lang=null!==jsxc.storage.getItem("lang")?jsxc.storage.getItem("lang"):jsxc.options.autoLang&&navigator.languages&&0 .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&&0 .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 0<$(selector).length},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)}),0")).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;ii;){var message=new jsxc.Message(history[i]);if(message.direction!==jsxc.Message.SYS)return{text:message.msg,date:message.stamp};i++}},enableDebugMode:function(){jsxc.storage.setItem("debug",!0)},disableDebugMode:function(){jsxc.storage.setItem("debug",!1)},deleteAllData:function(){if(!jsxc.storage.getItem("debug"))return jsxc.warn("This action is only available in debug mode."),0;var prefix=jsxc.storage.PREFIX+jsxc.storage.SEP,prefixRegex=new RegExp("^"+prefix),keys=Object.keys(localStorage),count=0;return $.each(keys,function(index,key){prefixRegex.test(key)&&key!==prefix+"debug"&&(localStorage.removeItem(key),count++)}),count}}).xmpp={conn:null,login:function(){if(jsxc.xmpp.conn&&jsxc.xmpp.conn.authenticated)jsxc.debug("Connection already authenticated.");else{var jid=null,password=null,sid=null,rid=null;switch(arguments.length){case 2:jid=arguments[0],password=arguments[1];break;case 3:jid=arguments[0],sid=arguments[1],rid=arguments[2];break;default:sid=jsxc.storage.getItem("sid"),rid=jsxc.storage.getItem("rid"),null!==sid&&null!==rid?jid=jsxc.storage.getItem("jid"):(sid=jsxc.options.xmpp.sid||null,rid=jsxc.options.xmpp.rid||null,jid=jsxc.options.xmpp.jid)}if(jid){jsxc.bid||(jsxc.bid=jsxc.jidToBid(jid));var url=jsxc.options.get("xmpp").url;if(url){jsxc.xmpp.conn&&jsxc.xmpp.conn.connected||($(document).on("connected.jsxc",jsxc.xmpp.connected),$(document).on("attached.jsxc",jsxc.xmpp.attached),$(document).on("disconnected.jsxc",jsxc.xmpp.disconnected),$(document).on("connfail.jsxc",jsxc.xmpp.onConnfail),$(document).on("authfail.jsxc",jsxc.xmpp.onAuthFail),Strophe.addNamespace("RECEIPTS","urn:xmpp:receipts"),Strophe.addNamespace("VERSION","jabber:iq:version")),jsxc.xmpp.conn=new Strophe.Connection(url),!0===jsxc.storage.getItem("debug")&&(jsxc.xmpp.conn.xmlInput=function(data){console.log("<",data)},jsxc.xmpp.conn.xmlOutput=function(data){console.log(">",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",condition);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))}else jsxc.warn("xmpp.url required for login")}else jsxc.warn("Jid required for login")}},logout:function(complete){if(jsxc.storage.setUserItem("forcedLogout",!0),jsxc.triggeredFromElement="boolean"!=typeof complete||complete,!jsxc.master)return jsxc.storage.removeItem("sid"),!0;if(jsxc.storage.removeUserItem("windowlist"),jsxc.storage.removeUserItem("unreadMsg"),jsxc.gui.favicon&&jsxc.gui.favicon.badge(0),$("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=0<$(jsxc.xmpp.conn.features).find('[xmlns="urn:xmpp:features:rosterver"]').length;if(jsxc.storage.setUserItem("rosterVerSupport",rosterVerSupport),jsxc.storage.removeUserItem("forcedLogout"),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"),jsxc.storage.removeUserElement("options","httpUpload")},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("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.restoreCompleted=!1,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){jsxc.debug("Use cached roster");var buddylist=jsxc.storage.getUserItem("buddylist")||[];return $.each(buddylist,function(index,buddy){jsxc.storage.removeUserItem("res",buddy),jsxc.storage.updateUserItem("buddy",buddy,"status",0),jsxc.storage.updateUserItem("buddy",buddy,"res",[]),jsxc.storage.updateUserItem("buddy",buddy,"rnd",Math.random())}),void jsxc.restoreRoster()}var buddies=[];$(iq).find("item").each(function(){var jid=$(this).attr("jid");if(/^[^"&'\/:<>@\s]+@[\w-_.]+$/i.test(jid)){var 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)}else jsxc.warn(jid+" is no valid JID.")}),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),1!==$(iq).find("item").length?jsxc.warn("Roster pushes must contain only one item element"):($(iq).find("item").each(function(){var jid=$(this).attr("jid");if(/^[^"&'\/:<>@\s]+@[\w-_.]+$/i.test(jid)){var 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)"gui.showApproveDialog"===(notice=notices[noticeKey]).fnName&¬ice.fnParams[0]===jid&&(jsxc.debug("Remove notice with key "+noticeKey),jsxc.notice.remove(noticeKey))}}else jsxc.warn(jid+" is no valid JID.")}),$(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-1 message"),forwarded=!0,0===(carbon=$(stanza).find('> [xmlns="'+jsxc.CONST.NS.CARBONS+'"]')).length)carbon=!1;else if(originalSender!==Strophe.getBareJidFromJid(jsxc.xmpp.conn.jid))return!0;jsxc.debug("Incoming forwarded message",message)}else message=stanza,carbon=forwarded=!1,jsxc.debug("Incoming message",message);var htmlBody=$(message).find('body[xmlns="'+Strophe.NS.XHTML+'"]').first(),body=$(message).find(">body").first().text()||htmlBody.text();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=0a").length){var thumbnail,linkElement=htmlBody.find(">a"),metaString="";if(1===linkElement.find(">img").length){var imgElement=linkElement.find(">img"),src=imgElement.attr("src")||"";metaString=(imgElement.attr("alt")||"").replace(/^Preview:/,""),src.match(/^\s*data:[a-z]+\/[a-z0-9-+.*]+;base64,[a-z0-9=+/]+$/i)&&(thumbnail=src)}else metaString=linkElement.text();var metaMatch=metaString.match(/^([a-z]+\/[a-z0-9-+.*]+)\|(\d+)\|([\s\w.,-]+)/);metaMatch?(attachment={type:metaMatch[1],size:metaMatch[2],name:metaMatch[3]},thumbnail&&(attachment.thumbnail=thumbnail),linkElement.attr("href")&&linkElement.attr("href").match(/^https?:\/\//)&&(attachment.data=linkElement.attr("href"),body=null)):jsxc.warn("Invalid file type, name or size.")}}return jsxc.otr.objects.hasOwnProperty(bid)&&body?jsxc.otr.objects[bid].receiveMsg(body,{_uid:mid,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")&&(0<$(message).find("item-not-found").length?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_item-not-found")}):0<$(message).find("forbidden").length?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_forbidden")}):0<$(message).find("not-acceptable").length?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_not-acceptable")}):0<$(message).find("remote-server-not-found").length?jsxc.gui.window.postMessage({bid:bid,direction:jsxc.Message.SYS,msg:$.t("message_not_send_remote-server-not-found")}):0<$(message).find("service-unavailable").length?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){var from=(stanza=$(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){var from=(stanza=$(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.msg,isMucBid=0<=(jsxc.xmpp.conn.muc&&jsxc.xmpp.conn.muc.roomNames?jsxc.xmpp.conn.muc.roomNames:[]).indexOf(bid);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});message.type===jsxc.Message.HTML&&msg===message.msg&&message.htmlMsg?(xmlMsg.c("body").t(msg),xmlMsg.up().c("html",{xmlns:Strophe.NS.XHTML_IM}).c("body",{xmlns:Strophe.NS.XHTML}).h(message.htmlMsg).up()):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,1)&&$("#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(!(0<$("#jsxc_windowList").length)){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(0")}})},update:function(bid){var data=jsxc.storage.getUserItem("buddy",bid);if(data){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",bid+" "+$.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])}else jsxc.debug("No data for "+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();scrollWidth 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();""!==sec&&""!==quest?(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")})):div.find('input[value=""]').addClass("jsxc_invalid").keyup(function(){$(this).val().match(/.*/)&&$(this).removeClass("jsxc_invalid")})}),$("#jsxc_dialog > div:eq(3) .jsxc_submit").click(function(){var div=$("#jsxc_dialog > div:eq(3)"),sec=div.find("#jsxc_secret").val();""!==sec?(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")})):div.find("#jsxc_secret").addClass("jsxc_invalid").keyup(function(){$(this).val().match(/.*/)&&$(this).removeClass("jsxc_invalid")})})):jsxc.warn("Connection not encrypted")},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=$("").addClass("jsxc_spot"),href=$(this).attr("href").replace(/^ *(mailto|xmpp):/,"").trim();if(""!==href&&href!==Strophe.getBareJidFromJid(jsxc.storage.getItem("jid"))){var bid=jsxc.jidToBid(href),self=$(this),s=self.prev();s.hasClass("jsxc_spot")||(s=spot.clone().attr("data-bid",bid),self.before(s)),s.off("click"),jsxc.storage.getUserItem("buddy",bid)?(jsxc.gui.update(bid),s.click(function(){return jsxc.gui.window.open(bid),!1})):s.click(function(){return jsxc.gui.showContactDialog(href),!1})}})},detectGeoUri:function(container){function decimalToDms(deg){var d=Math.floor(deg),minfloat=60*(deg-d),m=Math.floor(minfloat),secfloat=60*(minfloat-m),s=Math.round(10*secfloat)/10;return 60===s&&(m++,s=0),60===m&&(d++,m=0),d+"°"+m+"'"+s+'"'}(container=$(container)).find('a[href^="geo:"]').each(function(){var matches=$(this).attr("href").match(jsxc.CONST.REGEX.GEOURI),latitude=matches[1],longitude=matches[2],accuracy=matches[5],osmUrl="https://www.openstreetmap.org/?mlat="+latitude+"&mlon="+longitude+"#map=16/"+latitude+"/"+longitude,label="OSM: "+function(latitude,longitude){return decimalToDms(latitude)+(0");return div.addClass("jsxc_emoticon"),div.css("background-image","url("+src+")"),div.attr("title",shortname),div.prop("outerHTML")});var obj=$("
"+str+"
");return 1===obj.find(".jsxc_emoticon").length&&0===obj.text().replace(/ /,"").length&&1===obj.find("*").length&&(obj.find(".jsxc_emoticon").addClass("jsxc_large"),str=obj.prop("outerHTML")),str},restore:function(){jsxc.restoreRoster(),jsxc.restoreWindows(),jsxc.restoreCompleted=!0,$(document).trigger("restoreCompleted.jsxc"),jsxc.changeUIState(jsxc.CONST.UISTATE.READY)}},jsxc.gui.roster={ready:!1,loaded:!1,init:function(){$(jsxc.options.rosterAppend+":first").append($(jsxc.gui.template.get("roster"))),jsxc.options.get("hideOffline")&&($("#jsxc_menu .jsxc_hideOffline").text($.t("Show_offline")),$("#jsxc_buddylist").addClass("jsxc_hideOffline")),$("#jsxc_menu .jsxc_settings").click(function(){jsxc.gui.showSettings()}),$("#jsxc_menu .jsxc_hideOffline").click(function(){var hideOffline=!jsxc.options.get("hideOffline");hideOffline?$("#jsxc_buddylist").addClass("jsxc_hideOffline"):$("#jsxc_buddylist").removeClass("jsxc_hideOffline"),$(this).text(hideOffline?$.t("Show_offline"):$.t("Hide_offline")),jsxc.options.set("hideOffline",hideOffline)}),jsxc.options.get("muteNotification")&&jsxc.notification.muteSound(),$("#jsxc_menu .jsxc_muteNotification").click(function(){"dnd"!==jsxc.storage.getUserItem("presence")&&(!jsxc.options.get("muteNotification")?jsxc.notification.muteSound():jsxc.notification.unmuteSound())}),$("#jsxc_roster .jsxc_addBuddy").click(function(){jsxc.gui.showContactDialog()}),$("#jsxc_roster .jsxc_onlineHelp").click(function(){window.open(jsxc.options.onlineHelp,"onlineHelp")}),$("#jsxc_roster .jsxc_about").click(function(){jsxc.gui.showAboutDialog()}),$("#jsxc_toggleRoster").click(function(){jsxc.gui.roster.toggle()}),$("#jsxc_presence li").click(function(){var pres=$(this).data("pres");"offline"===pres?jsxc.xmpp.logout(!1):jsxc.gui.changePresence(pres)}),$("#jsxc_buddylist").slimScroll({distance:"3px",height:$("#jsxc_roster").height()-31+"px",width:$("#jsxc_buddylist").width()+"px",color:"#fff",opacity:"0.5"}),$("#jsxc_roster > .jsxc_bottom > div").each(function(){jsxc.gui.toggleList.call($(this))});var rosterState=jsxc.storage.getUserItem("roster")||(jsxc.options.get("loginForm").startMinimized?"hidden":"shown");$("#jsxc_roster").addClass("jsxc_state_"+rosterState),$("#jsxc_windowList").addClass("jsxc_roster_"+rosterState);var pres=jsxc.storage.getUserItem("presence")||"online";$("#jsxc_presence > span").text($("#jsxc_presence .jsxc_"+pres).text()),jsxc.gui.updatePresence("own",pres),jsxc.gui.tooltip("#jsxc_roster"),jsxc.notice.load(),jsxc.gui.roster.ready=!0,$(document).trigger("ready.roster.jsxc",[rosterState]),$(document).trigger("ready-roster-jsxc",[rosterState])},add:function(bid){var data=jsxc.storage.getUserItem("buddy",bid),bud=jsxc.gui.buddyTemplate.clone().attr("data-bid",bid).attr("data-type",data.type||"chat");$("#jsxc_roster > p").remove(),jsxc.gui.roster.insert(bid,bud),bud.click(function(){jsxc.gui.window.open(bid)}),bud.find(".jsxc_msg").click(function(){return jsxc.gui.window.open(bid),!1}),bud.find(".jsxc_rename").click(function(){return jsxc.gui.roster.rename(bid),!1}),"groupchat"!==data.type&&bud.find(".jsxc_delete").click(function(){return jsxc.gui.showRemoveDialog(bid),!1});bud.find(".jsxc_more").click(function(){return bud.trigger("extra.jsxc"),$("body").click(),bud.find(".jsxc_menu").hasClass("jsxc_open")||(bud.find(".jsxc_menu").addClass("jsxc_open"),$("body").one("click",function(){bud.find(".jsxc_menu").removeClass("jsxc_open")})),!1}),bud.find(".jsxc_vcard").click(function(){return jsxc.gui.showVcard(data.jid),!1}),jsxc.gui.update(bid),$("#jsxc_buddylist").slimScroll({scrollTo:"0px"});for(var history=jsxc.storage.getUserItem("history",bid)||[],i=0;history.length>i;){var message=new jsxc.Message(history[i]);if(message.direction!==jsxc.Message.SYS){jsxc.gui.window.setLastMsg(bid,message.msg);break}i++}$(document).trigger("add.roster.jsxc",[bid,data,bud])},getItem:function(bid){return $("#jsxc_buddylist > li[data-bid='"+bid+"']")},insert:function(bid,li){var data=jsxc.storage.getUserItem("buddy",bid),listElements=$("#jsxc_buddylist > li"),insert=!1;data.name||(data.name=bid);var status="both"===data.sub?data.status:-1;listElements.each(function(){var thisStatus="both"===$(this).data("sub")?$(this).data("status"):-1;if($(this).data("name").toLowerCase()>data.name.toLowerCase()&&thisStatus===status||thisStatus');$("body").click(),options.hide(),name=name.replaceWith(input),input.val(name.text()),input.keypress(function(ev){13===ev.which&&(options.css("display",""),input.replaceWith(name),jsxc.gui.roster._rename(bid,$(this).val()),$("html").off("click"))}),input.click(function(){return!1}),$("html").one("click",function(){options.css("display",""),input.replaceWith(name),jsxc.gui.roster._rename(bid,input.val())})},_rename:function(bid,newname){if(jsxc.master){var d=jsxc.storage.getUserItem("buddy",bid)||{};if("chat"===d.type){var iq=$iq({type:"set"}).c("query",{xmlns:"jabber:iq:roster"}).c("item",{jid:Strophe.getBareJidFromJid(d.jid),name:newname});jsxc.xmpp.conn.sendIQ(iq)}else"groupchat"===d.type&&jsxc.xmpp.bookmarks.add(bid,newname,d.nickname,d.autojoin)}jsxc.storage.updateUserItem("buddy",bid,"name",newname),jsxc.gui.update(bid)},toggle:function(state){var duration,roster=$("#jsxc_roster"),wl=$("#jsxc_windowList");return state||(state=jsxc.storage.getUserItem("roster")===jsxc.CONST.HIDDEN?jsxc.CONST.SHOWN:jsxc.CONST.HIDDEN),"shown"===state&&jsxc.isExtraSmallDevice()&&jsxc.gui.window.hide(),jsxc.storage.setUserItem("roster",state),roster.removeClass("jsxc_state_hidden jsxc_state_shown").addClass("jsxc_state_"+state),wl.removeClass("jsxc_roster_hidden jsxc_roster_shown").addClass("jsxc_roster_"+state),duration=1e3*parseFloat(roster.css("transitionDuration")||0),setTimeout(function(){jsxc.gui.updateWindowListSB()},duration),$(document).trigger("toggle.roster.jsxc",[state,duration]),duration},noConnection:function(){$("#jsxc_roster").addClass("jsxc_noConnection"),$("#jsxc_buddylist").empty(),$("#jsxc_roster > p").remove(),$("

"+$.t("no_connection")+"

").append(" "+$.t("relogin")+"").click(function(){jsxc.storage.removeUserItem("forcedLogout"),jsxc.relogin()||jsxc.gui.showLoginBox()}).appendTo("#jsxc_roster")},empty:function(){var text=$("

"+$.t("Your_roster_is_empty_add_")+"

"),link=text.find("a");link.click(function(){jsxc.gui.showContactDialog()}),text.append(link),text.append("."),$("#jsxc_roster").prepend(text)}},jsxc.gui.dialog={open:function(data,o){var opt=$.extend({name:""},o),src=$('
').append(data);return $.magnificPopup.open({items:{src:src},type:"inline",modal:opt.noClose,callbacks:{beforeClose:function(){$(document).trigger("cleanup.dialog.jsxc")},afterClose:function(){$(document).trigger("close.dialog.jsxc")},open:function(){$("#jsxc_dialog .jsxc_close").click(function(ev){ev.preventDefault(),jsxc.gui.dialog.close()}),$("#jsxc_dialog form").each(function(){$(this).find("button[data-jsxc-loading-text]").each(function(){var btn=$(this);btn.on("btnloading.jsxc",function(){btn.prop("disabled")||(btn.prop("disabled",!0),btn.data("jsxc_value",btn.text()),btn.text(btn.attr("data-jsxc-loading-text")))}),btn.on("btnfinished.jsxc",function(){btn.prop("disabled")&&(btn.prop("disabled",!1),btn.text(btn.data("jsxc_value")))})})}),jsxc.gui.dialog.resize(),$(document).trigger("complete.dialog.jsxc")}}}),$("#jsxc_dialog")},close:function(name){jsxc.debug("close dialog"),"string"==typeof name&&0 ul"),data=jsxc.storage.getUserItem("buddy",bid);win.data("jid",data.jid);var textinputBlurTimeout;function resizeTextarea(){$(this).data("originalHeight")||$(this).data("originalHeight",$(this).outerHeight()),$(this).outerHeight()");li.append(jsxc.gui.shortnameToImage(":"+val[1]+":")),li.find("div").attr("title",ins),li.click(function(){win.find(".jsxc_textinput").val(win.find(".jsxc_textinput").val()+ins),win.find(".jsxc_textinput").focus()}),win.find(".jsxc_emoticons ul").prepend(li)}),jsxc.gui.toggleList.call(win.find(".jsxc_emoticons")),jsxc.gui.window.restoreChat(bid),jsxc.gui.update(bid),jsxc.gui.updateWindowListSB(),jsxc.master&&!jsxc.otr.objects[bid]?jsxc.otr.create(bid):jsxc.otr.enable(bid),$(document).trigger("init.window.jsxc",[win]),win},resize:function(win,ui,outer){var bid;if("object"==typeof win)bid=win.attr("data-bid");else{if("string"!=typeof win)return void jsxc.warn("jsxc.gui.window.resize has to be called either with bid or window object.");bid=win,win=jsxc.gui.window.get(bid)}win.attr("data-default-height")||win.attr("data-default-height",win.find(".ui-resizable").height()),win.attr("data-default-width")||win.attr("data-default-width",win.find(".ui-resizable").width());var outer_height_diff=outer?win.find(".jsxc_window").outerHeight()-win.find(".ui-resizable").height():0;ui=$.extend({size:{width:parseInt(win.attr("data-default-width")),height:parseInt(win.attr("data-default-height"))+outer_height_diff}},ui||{}),outer&&(ui.size.height-=outer_height_diff),win.find(".slimScrollDiv").css({width:ui.size.width,height:ui.size.height}),win.width(ui.size.width),win.find(".jsxc_textarea").slimScroll({height:ui.size.height}),$(document).trigger("resize.window.jsxc",[win,bid,ui.size])},fullsize:function(bid){var win=jsxc.gui.window.get(bid),size=jsxc.options.viewport.getSize();size.width-=10,size.height-=win.find(".jsxc_bar").outerHeight()+win.find(".jsxc_textinput").outerHeight(),jsxc.gui.window.resize(win,{size:size})},get:function(id){return $("li.jsxc_windowItem[data-bid='"+jsxc.jidToBid(id)+"']")},open:function(bid){var win=jsxc.gui.window.init(bid);return jsxc.gui.window.show(bid),jsxc.gui.window.highlight(bid),win},close:function(bid){0!==jsxc.gui.window.get(bid).length?(jsxc.storage.removeUserElement("windowlist",bid),jsxc.storage.removeUserItem("window",bid),jsxc.storage.getUserItem("buddylist").indexOf(bid)<0&&(jsxc.storage.removeUserItem("buddy",bid),jsxc.storage.removeUserItem("chat",bid)),jsxc.gui.window._close(bid)):jsxc.warn("Want to close a window, that is not open.")},_close:function(bid){jsxc.gui.window.get(bid).remove(),jsxc.gui.updateWindowListSB()},toggle:function(bid){var win=jsxc.gui.window.get(bid);0!==win.parents("#jsxc_windowList").length&&(win.hasClass("jsxc_min")?jsxc.gui.window.show(bid):jsxc.gui.window.hide(bid),jsxc.gui.updateWindowListSB())},show:function(bid){return jsxc.storage.updateUserItem("window",bid,"minimize",!1),jsxc.gui.window._show(bid)},_show:function(bid){var win=jsxc.gui.window.get(bid),duration=0;jsxc.isExtraSmallDevice()&&(0<=parseFloat($("#jsxc_roster").css("right"))&&(duration=jsxc.gui.roster.toggle()),jsxc.gui.window.hide(),jsxc.gui.window.fullsize(bid)),win.removeClass("jsxc_min").addClass("jsxc_normal"),win.find(".jsxc_window").css("bottom","0"),setTimeout(function(){var padding=$("#jsxc_windowListSB").width(),innerWidth=$("#jsxc_windowList>ul").width(),outerWidth=$("#jsxc_windowList").width()-padding;if(outerWidthul").css("right")),width=win.outerWidth(!0),right=innerWidth-win.position().left-width+offset,left=outerWidth-(innerWidth-win.position().left)-offset;left<0&&jsxc.gui.scrollWindowListBy(-1*left),right<0&&jsxc.gui.scrollWindowListBy(right)}},duration),jsxc.gui.window.scrollDown(bid),jsxc.restoreCompleted&&win.find(".jsxc_textinput").focus(),win.trigger("show.window.jsxc")},hide:function(bid){var hide=function(bid){jsxc.storage.updateUserItem("window",bid,"minimize",!0),jsxc.gui.window._hide(bid)};bid?hide(bid):$("#jsxc_windowList > ul > li").each(function(){var el=$(this);el.hasClass("jsxc_min")||hide(el.attr("data-bid"))})},_hide:function(bid){var win=jsxc.gui.window.get(bid);win.removeClass("jsxc_normal").addClass("jsxc_min"),win.find(".jsxc_window").css("bottom",-1*win.find(".jsxc_fade").height()),win.trigger("hidden.window.jsxc")},highlight:function(bid){var el=jsxc.gui.window.get(bid).find(" .jsxc_bar");el.is(":animated")||el.effect("highlight",{color:"orange"},2e3)},scrollDown:function(bid){var chat=jsxc.gui.window.get(bid).find(".jsxc_textarea");0!==chat.length&&chat.slimScroll({scrollTo:chat.get(0).scrollHeight+"px"})},postMessage:function(message){"object"!=typeof message||message instanceof jsxc.Message||(message=new jsxc.Message(message));var data=jsxc.storage.getUserItem("buddy",message.bid);!message.htmlMsg&&message.msg&&(message.htmlMsg=message.msg),void 0===message.msg&&(message.msg=""),message.msg=jsxc.removeHTML(message.msg),message.msg=jsxc.escapeHTML(message.msg),message.direction===jsxc.Message.OUT&&data.msgstate===OTR.CONST.MSGSTATE_FINISHED&&!0!==message.forwarded&&(message.direction=jsxc.Message.SYS,message.msg=$.t("your_message_wasnt_send_please_end_your_private_conversation")),message.direction===jsxc.Message.OUT&&data.msgstate===OTR.CONST.MSGSTATE_FINISHED&&(message.direction="sys",message.msg=$.t("unencrypted_message_received")+" "+message.msg),message.encrypted="boolean"==typeof message.encrypted?message.encrypted:data.msgstate===OTR.CONST.MSGSTATE_ENCRYPTED;try{message.save()}catch(err){jsxc.warn("Unable to save message.",err),message=new jsxc.Message({msg:"Unable to save that message. Please clear some chat histories.",direction:jsxc.Message.SYS})}return"in"!==message.direction||jsxc.gui.window.get(message.bid).find(".jsxc_textinput").is(":focus")||(jsxc.gui.unreadMsg(message.bid),$(document).trigger("postmessagein.jsxc",[message.bid,message.htmlMsg])),message.direction===jsxc.Message.OUT&&jsxc.master&&!0!==message.forwarded&&message.htmlMsg&&jsxc.xmpp.sendMessage(message),jsxc.gui.window._postMessage(message),"out"===message.direction&&"?"===message.msg&&!1!==jsxc.options.get("theAnswerToAnything")&&(void 0===jsxc.options.get("theAnswerToAnything")||100*Math.random()%42<1)&&(jsxc.options.set("theAnswerToAnything",!0),jsxc.gui.window.postMessage(new jsxc.Message({bid:message.bid,direction:jsxc.Message.SYS,msg:"42"}))),message},_postMessage:function(message,restore){var bid=message.bid,win=jsxc.gui.window.get(bid),msg=message.msg,direction=message.direction,uid=message._uid;win.find(".jsxc_textinput").is(":not(:focus)")&&direction===jsxc.Message.IN&&!restore&&jsxc.gui.window.highlight(bid),msg=(msg=(msg=msg.replace(jsxc.CONST.REGEX.URL,function(url){return''+url+""})).replace(new RegExp("(xmpp:)?("+jsxc.CONST.REGEX.JID.source+")(\\?[^\\s]+\\b)?","i"),function(match,protocol,jid,action){return"xmpp:"===protocol?("string"==typeof action&&(jid+=action),'xmpp:'+jid+""):'mailto:'+jid+""})).replace(jsxc.CONST.REGEX.GEOURI,function(uri){var a=$("");return a.attr("href",uri),a.attr("target","_blank"),a.text(uri),$("").append(a).html()}),$.each(jsxc.gui.emotions,function(i,val){msg=msg.replace(val[2],":"+val[1]+":")}),msg=(msg=jsxc.gui.shortnameToImage(msg)).replace(/(\r\n|\r|\n)/g,"
");var bidData=jsxc.storage.getUserItem("buddy",bid)||{};"in"===direction&&(msg=msg.replace(/^\/me /,''+jsxc.removeHTML(bidData.name||bid)+" ")),msg.match(/^\?OTR([:,|?]|[?v0-9x]+)/)&&(msg=''+$.t("Unreadable_OTR_message")+"");var msgDiv=$("
"),msgTsDiv=$("
");if(msgDiv.addClass("jsxc_chatmessage jsxc_"+direction),msgDiv.attr("id",uid.replace(/:/g,"-")),msgDiv.html("
"+msg+"
"),msgTsDiv.addClass("jsxc_timestamp"),msgTsDiv.text(jsxc.getFormattedTime(message.stamp)),message.isReceived()?msgDiv.addClass("jsxc_received"):msgDiv.removeClass("jsxc_received"),message.forwarded?msgDiv.addClass("jsxc_forwarded"):msgDiv.removeClass("jsxc_forwarded"),message.encrypted?msgDiv.addClass("jsxc_encrypted"):msgDiv.removeClass("jsxc_encrypted"),message.error?msgDiv.addClass("jsxc_error"):msgDiv.removeClass("jsxc_error"),msgDiv.attr("title",message.error),msgDiv.attr("data-error-msg",message.error),message.attachment&&message.attachment.name){var attachment=$("
");attachment.addClass("jsxc_attachment"),attachment.addClass("jsxc_"+message.attachment.type.replace(/\//,"-")),attachment.addClass("jsxc_"+message.attachment.type.replace(/^([^/]+)\/.*/,"$1")),!1===message.attachment.persistent&&attachment.addClass("jsxc_notPersistent"),message.attachment.data&&attachment.addClass("jsxc_data"),message.attachment.type.match(/^image\//)&&message.attachment.thumbnail?$('preview').attr("src",message.attachment.thumbnail).attr("title",message.attachment.name).appendTo(attachment):attachment.text(message.attachment.name),message.attachment.data&&((attachment=$("").append(attachment)).attr("href",message.attachment.data),attachment.attr("download",message.attachment.name),message.attachment.data===message.msg&&msgDiv.find("div").first().empty()),msgDiv.find("div").first().append(attachment)}"sys"===direction?jsxc.gui.window.get(bid).find(".jsxc_textarea").append('
'):void 0!==message.stamp&&msgDiv.append(msgTsDiv),"sys"!==direction&&jsxc.gui.window.setLastMsg(bid,msg);var currentMessageElement=jsxc.Message.getDOM(uid);if(0");if(avatarDiv.addClass("jsxc_avatar").prependTo(msgDiv),"string"==typeof message.sender.jid){msgDiv.attr("data-bid",jsxc.jidToBid(message.sender.jid));var data=jsxc.storage.getUserItem("buddy",jsxc.jidToBid(message.sender.jid))||{};jsxc.gui.avatar.update(msgDiv,jsxc.jidToBid(message.sender.jid),data.avatar),title=jsxc.jidToBid(message.sender.jid)}"string"==typeof message.sender.name&&(msgDiv.attr("data-name",message.sender.name),"string"!=typeof message.sender.jid&&jsxc.gui.avatarPlaceholder(avatarDiv,message.sender.name),""!==title&&(title="\n"+title),title=message.sender.name+title,msgTsDiv.text(msgTsDiv.text()+" "+message.sender.name)),avatarDiv.attr("title",jsxc.escapeHTML(title)),0"+$(this).text()+"")})},restoreChat:function(bid){var chat=jsxc.storage.getUserItem("chat",bid);if(chat){for(;null!==chat&&0"),span=div.find(".jsxc_timestamp span")),span.text(" "+Math.round(sent/size*100)+"%"),sent===size&&span.remove()},showOverlay:function(bid,content,allowClose){var win=jsxc.gui.window.get(bid);win.find(".jsxc_overlay .jsxc_body").empty().append(content),win.find(".jsxc_overlay .jsxc_close").off("click").click(function(){jsxc.gui.window.hideOverlay(bid)}),!0!==allowClose?win.find(".jsxc_overlay .jsxc_close").hide():win.find(".jsxc_overlay .jsxc_close").show(),win.addClass("jsxc_showOverlay")},hideOverlay:function(bid){jsxc.gui.window.get(bid).removeClass("jsxc_showOverlay")},selectResource:function(bid,text,cb,res){if(res=res||jsxc.storage.getUserItem("res",bid)||[],cb=cb||function(){},0"),list=$("