diff --git a/CHANGES.md b/CHANGES.md
index 4d3d9a36c..52e1d0572 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,6 @@
# Changelog
-## 4.0.3 (Unreleased)
+## 4.0.3 (2018-10-22)
- New translations: Arabic, Basque, Czech, French, German, Hungarian, Japanese, Norwegian Bokmål, Polish, Romanian, Spanish
- Bugfix. Converse continuously publishes an empty OMEMO devicelist for itself
diff --git a/COPYRIGHT b/COPYRIGHT
index fc71120ac..9cc586734 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -2,7 +2,7 @@
*
* An XMPP chat client that runs in the browser.
*
- * Version: 4.0.2
+ * Version: 4.0.3
*
* Copyright: JC Brand 2013-2018
* Except for 3rd party dependencies.
diff --git a/Makefile b/Makefile
index f1185f210..9b472d925 100644
--- a/Makefile
+++ b/Makefile
@@ -71,7 +71,7 @@ serve_bg: dev
########################################################################
## Translation machinery
-GETTEXT = xgettext --language="JavaScript" --keyword=__ --keyword=___ --from-code=UTF-8 --output=locale/converse.pot dist/converse-no-dependencies.js --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=4.0.2 -c
+GETTEXT = xgettext --language="JavaScript" --keyword=__ --keyword=___ --from-code=UTF-8 --output=locale/converse.pot dist/converse-no-dependencies.js --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=4.0.3 -c
.PHONY: pot
pot: dist/converse-no-dependencies-es2015.js
diff --git a/dist/converse-no-dependencies.js b/dist/converse-no-dependencies.js
index 2156fd2ad..535c51abf 100644
--- a/dist/converse-no-dependencies.js
+++ b/dist/converse-no-dependencies.js
@@ -26775,6 +26775,6226 @@ exports.default = vnode;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy8ucmVnaXN0cnkubnBtanMub3JnL2Jyb3dzZXItcGFjay82LjAuMi9ub2RlX21vZHVsZXMvYnJvd3Nlci1wYWNrL19wcmVsdWRlLmpzIiwiaHRtbGRvbWFwaS5qcyIsInRvdm5vZGUuanMiLCJ2bm9kZS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNqRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUMzQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbIihmdW5jdGlvbiBlKHQsbixyKXtmdW5jdGlvbiBzKG8sdSl7aWYoIW5bb10pe2lmKCF0W29dKXt2YXIgYT10eXBlb2YgcmVxdWlyZT09XCJmdW5jdGlvblwiJiZyZXF1aXJlO2lmKCF1JiZhKXJldHVybiBhKG8sITApO2lmKGkpcmV0dXJuIGkobywhMCk7dmFyIGY9bmV3IEVycm9yKFwiQ2Fubm90IGZpbmQgbW9kdWxlICdcIitvK1wiJ1wiKTt0aHJvdyBmLmNvZGU9XCJNT0RVTEVfTk9UX0ZPVU5EXCIsZn12YXIgbD1uW29dPXtleHBvcnRzOnt9fTt0W29dWzBdLmNhbGwobC5leHBvcnRzLGZ1bmN0aW9uKGUpe3ZhciBuPXRbb11bMV1bZV07cmV0dXJuIHMobj9uOmUpfSxsLGwuZXhwb3J0cyxlLHQsbixyKX1yZXR1cm4gbltvXS5leHBvcnRzfXZhciBpPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7Zm9yKHZhciBvPTA7bzxyLmxlbmd0aDtvKyspcyhyW29dKTtyZXR1cm4gc30pIiwiXCJ1c2Ugc3RyaWN0XCI7XG5PYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgXCJfX2VzTW9kdWxlXCIsIHsgdmFsdWU6IHRydWUgfSk7XG5mdW5jdGlvbiBjcmVhdGVFbGVtZW50KHRhZ05hbWUpIHtcbiAgICByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCh0YWdOYW1lKTtcbn1cbmZ1bmN0aW9uIGNyZWF0ZUVsZW1lbnROUyhuYW1lc3BhY2VVUkksIHF1YWxpZmllZE5hbWUpIHtcbiAgICByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKG5hbWVzcGFjZVVSSSwgcXVhbGlmaWVkTmFtZSk7XG59XG5mdW5jdGlvbiBjcmVhdGVUZXh0Tm9kZSh0ZXh0KSB7XG4gICAgcmV0dXJuIGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHRleHQpO1xufVxuZnVuY3Rpb24gY3JlYXRlQ29tbWVudCh0ZXh0KSB7XG4gICAgcmV0dXJuIGRvY3VtZW50LmNyZWF0ZUNvbW1lbnQodGV4dCk7XG59XG5mdW5jdGlvbiBpbnNlcnRCZWZvcmUocGFyZW50Tm9kZSwgbmV3Tm9kZSwgcmVmZXJlbmNlTm9kZSkge1xuICAgIHBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKG5ld05vZGUsIHJlZmVyZW5jZU5vZGUpO1xufVxuZnVuY3Rpb24gcmVtb3ZlQ2hpbGQobm9kZSwgY2hpbGQpIHtcbiAgICBub2RlLnJlbW92ZUNoaWxkKGNoaWxkKTtcbn1cbmZ1bmN0aW9uIGFwcGVuZENoaWxkKG5vZGUsIGNoaWxkKSB7XG4gICAgbm9kZS5hcHBlbmRDaGlsZChjaGlsZCk7XG59XG5mdW5jdGlvbiBwYXJlbnROb2RlKG5vZGUpIHtcbiAgICByZXR1cm4gbm9kZS5wYXJlbnROb2RlO1xufVxuZnVuY3Rpb24gbmV4dFNpYmxpbmcobm9kZSkge1xuICAgIHJldHVybiBub2RlLm5leHRTaWJsaW5nO1xufVxuZnVuY3Rpb24gdGFnTmFtZShlbG0pIHtcbiAgICByZXR1cm4gZWxtLnRhZ05hbWU7XG59XG5mdW5jdGlvbiBzZXRUZXh0Q29udGVudChub2RlLCB0ZXh0KSB7XG4gICAgbm9kZS50ZXh0Q29udGVudCA9IHRleHQ7XG59XG5mdW5jdGlvbiBnZXRUZXh0Q29udGVudChub2RlKSB7XG4gICAgcmV0dXJuIG5vZGUudGV4dENvbnRlbnQ7XG59XG5mdW5jdGlvbiBpc0VsZW1lbnQobm9kZSkge1xuICAgIHJldHVybiBub2RlLm5vZGVUeXBlID09PSAxO1xufVxuZnVuY3Rpb24gaXNUZXh0KG5vZGUpIHtcbiAgICByZXR1cm4gbm9kZS5ub2RlVHlwZSA9PT0gMztcbn1cbmZ1bmN0aW9uIGlzQ29tbWVudChub2RlKSB7XG4gICAgcmV0dXJuIG5vZGUubm9kZVR5cGUgPT09IDg7XG59XG5leHBvcnRzLmh0bWxEb21BcGkgPSB7XG4gICAgY3JlYXRlRWxlbWVudDogY3JlYXRlRWxlbWVudCxcbiAgICBjcmVhdGVFbGVtZW50TlM6IGNyZWF0ZUVsZW1lbnROUyxcbiAgICBjcmVhdGVUZXh0Tm9kZTogY3JlYXRlVGV4dE5vZGUsXG4gICAgY3JlYXRlQ29tbWVudDogY3JlYXRlQ29tbWVudCxcbiAgICBpbnNlcnRCZWZvcmU6IGluc2VydEJlZm9yZSxcbiAgICByZW1vdmVDaGlsZDogcmVtb3ZlQ2hpbGQsXG4gICAgYXBwZW5kQ2hpbGQ6IGFwcGVuZENoaWxkLFxuICAgIHBhcmVudE5vZGU6IHBhcmVudE5vZGUsXG4gICAgbmV4dFNpYmxpbmc6IG5leHRTaWJsaW5nLFxuICAgIHRhZ05hbWU6IHRhZ05hbWUsXG4gICAgc2V0VGV4dENvbnRlbnQ6IHNldFRleHRDb250ZW50LFxuICAgIGdldFRleHRDb250ZW50OiBnZXRUZXh0Q29udGVudCxcbiAgICBpc0VsZW1lbnQ6IGlzRWxlbWVudCxcbiAgICBpc1RleHQ6IGlzVGV4dCxcbiAgICBpc0NvbW1lbnQ6IGlzQ29tbWVudCxcbn07XG5leHBvcnRzLmRlZmF1bHQgPSBleHBvcnRzLmh0bWxEb21BcGk7XG4vLyMgc291cmNlTWFwcGluZ1VSTD1odG1sZG9tYXBpLmpzLm1hcCIsIlwidXNlIHN0cmljdFwiO1xuT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsIFwiX19lc01vZHVsZVwiLCB7IHZhbHVlOiB0cnVlIH0pO1xudmFyIHZub2RlXzEgPSByZXF1aXJlKFwiLi92bm9kZVwiKTtcbnZhciBodG1sZG9tYXBpXzEgPSByZXF1aXJlKFwiLi9odG1sZG9tYXBpXCIpO1xuZnVuY3Rpb24gdG9WTm9kZShub2RlLCBkb21BcGkpIHtcbiAgICB2YXIgYXBpID0gZG9tQXBpICE9PSB1bmRlZmluZWQgPyBkb21BcGkgOiBodG1sZG9tYXBpXzEuZGVmYXVsdDtcbiAgICB2YXIgdGV4dDtcbiAgICBpZiAoYXBpLmlzRWxlbWVudChub2RlKSkge1xuICAgICAgICB2YXIgaWQgPSBub2RlLmlkID8gJyMnICsgbm9kZS5pZCA6ICcnO1xuICAgICAgICB2YXIgY24gPSBub2RlLmdldEF0dHJpYnV0ZSgnY2xhc3MnKTtcbiAgICAgICAgdmFyIGMgPSBjbiA/ICcuJyArIGNuLnNwbGl0KCcgJykuam9pbignLicpIDogJyc7XG4gICAgICAgIHZhciBzZWwgPSBhcGkudGFnTmFtZShub2RlKS50b0xvd2VyQ2FzZSgpICsgaWQgKyBjO1xuICAgICAgICB2YXIgYXR0cnMgPSB7fTtcbiAgICAgICAgdmFyIGNoaWxkcmVuID0gW107XG4gICAgICAgIHZhciBuYW1lXzE7XG4gICAgICAgIHZhciBpID0gdm9pZCAwLCBuID0gdm9pZCAwO1xuICAgICAgICB2YXIgZWxtQXR0cnMgPSBub2RlLmF0dHJpYnV0ZXM7XG4gICAgICAgIHZhciBlbG1DaGlsZHJlbiA9IG5vZGUuY2hpbGROb2RlcztcbiAgICAgICAgZm9yIChpID0gMCwgbiA9IGVsbUF0dHJzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbmFtZV8xID0gZWxtQXR0cnNbaV0ubm9kZU5hbWU7XG4gICAgICAgICAgICBpZiAobmFtZV8xICE9PSAnaWQnICYmIG5hbWVfMSAhPT0gJ2NsYXNzJykge1xuICAgICAgICAgICAgICAgIGF0dHJzW25hbWVfMV0gPSBlbG1BdHRyc1tpXS5ub2RlVmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChpID0gMCwgbiA9IGVsbUNoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY2hpbGRyZW4ucHVzaCh0b1ZOb2RlKGVsbUNoaWxkcmVuW2ldKSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHZub2RlXzEuZGVmYXVsdChzZWwsIHsgYXR0cnM6IGF0dHJzIH0sIGNoaWxkcmVuLCB1bmRlZmluZWQsIG5vZGUpO1xuICAgIH1cbiAgICBlbHNlIGlmIChhcGkuaXNUZXh0KG5vZGUpKSB7XG4gICAgICAgIHRleHQgPSBhcGkuZ2V0VGV4dENvbnRlbnQobm9kZSk7XG4gICAgICAgIHJldHVybiB2bm9kZV8xLmRlZmF1bHQodW5kZWZpbmVkLCB1bmRlZmluZWQsIHVuZGVmaW5lZCwgdGV4dCwgbm9kZSk7XG4gICAgfVxuICAgIGVsc2UgaWYgKGFwaS5pc0NvbW1lbnQobm9kZSkpIHtcbiAgICAgICAgdGV4dCA9IGFwaS5nZXRUZXh0Q29udGVudChub2RlKTtcbiAgICAgICAgcmV0dXJuIHZub2RlXzEuZGVmYXVsdCgnIScsIHt9LCBbXSwgdGV4dCwgbm9kZSk7XG4gICAgfVxuICAgIGVsc2Uge1xuICAgICAgICByZXR1cm4gdm5vZGVfMS5kZWZhdWx0KCcnLCB7fSwgW10sIHVuZGVmaW5lZCwgdW5kZWZpbmVkKTtcbiAgICB9XG59XG5leHBvcnRzLnRvVk5vZGUgPSB0b1ZOb2RlO1xuZXhwb3J0cy5kZWZhdWx0ID0gdG9WTm9kZTtcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXRvdm5vZGUuanMubWFwIiwiXCJ1c2Ugc3RyaWN0XCI7XG5PYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgXCJfX2VzTW9kdWxlXCIsIHsgdmFsdWU6IHRydWUgfSk7XG5mdW5jdGlvbiB2bm9kZShzZWwsIGRhdGEsIGNoaWxkcmVuLCB0ZXh0LCBlbG0pIHtcbiAgICB2YXIga2V5ID0gZGF0YSA9PT0gdW5kZWZpbmVkID8gdW5kZWZpbmVkIDogZGF0YS5rZXk7XG4gICAgcmV0dXJuIHsgc2VsOiBzZWwsIGRhdGE6IGRhdGEsIGNoaWxkcmVuOiBjaGlsZHJlbixcbiAgICAgICAgdGV4dDogdGV4dCwgZWxtOiBlbG0sIGtleToga2V5IH07XG59XG5leHBvcnRzLnZub2RlID0gdm5vZGU7XG5leHBvcnRzLmRlZmF1bHQgPSB2bm9kZTtcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXZub2RlLmpzLm1hcCJdfQ==
+/***/ }),
+
+/***/ "./node_modules/strophe.js/dist/strophe.js":
+/*!*************************************************!*\
+ !*** ./node_modules/strophe.js/dist/strophe.js ***!
+ \*************************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+(function webpackUniversalModuleDefinition(root, factory) {
+ if(true)
+ module.exports = factory();
+ else {}
+})(window, function() {
+return /******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
+/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
+/******/ }
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // create a fake namespace object
+/******/ // mode & 1: value is a module id, require it
+/******/ // mode & 2: merge all properties of value into the ns
+/******/ // mode & 4: return value when already ns object
+/******/ // mode & 8|1: behave like require
+/******/ __webpack_require__.t = function(value, mode) {
+/******/ if(mode & 1) value = __webpack_require__(value);
+/******/ if(mode & 8) return value;
+/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
+/******/ var ns = Object.create(null);
+/******/ __webpack_require__.r(ns);
+/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
+/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
+/******/ return ns;
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "";
+/******/
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = "./src/strophe.js");
+/******/ })
+/************************************************************************/
+/******/ ({
+
+/***/ "./src/bosh.js":
+/*!*********************!*\
+ !*** ./src/bosh.js ***!
+ \*********************/
+/*! no exports provided */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core */ "./src/core.js");
+/*
+ This program is distributed under the terms of the MIT license.
+ Please see the LICENSE file for details.
+
+ Copyright 2006-2008, OGG, LLC
+*/
+
+/* global window, setTimeout, clearTimeout, XMLHttpRequest, ActiveXObject */
+
+var Strophe = core__WEBPACK_IMPORTED_MODULE_0__["default"].Strophe;
+var $build = core__WEBPACK_IMPORTED_MODULE_0__["default"].$build;
+/** PrivateClass: Strophe.Request
+ * _Private_ helper class that provides a cross implementation abstraction
+ * for a BOSH related XMLHttpRequest.
+ *
+ * The Strophe.Request class is used internally to encapsulate BOSH request
+ * information. It is not meant to be used from user's code.
+ */
+
+/** PrivateConstructor: Strophe.Request
+ * Create and initialize a new Strophe.Request object.
+ *
+ * Parameters:
+ * (XMLElement) elem - The XML data to be sent in the request.
+ * (Function) func - The function that will be called when the
+ * XMLHttpRequest readyState changes.
+ * (Integer) rid - The BOSH rid attribute associated with this request.
+ * (Integer) sends - The number of times this same request has been sent.
+ */
+
+Strophe.Request = function (elem, func, rid, sends) {
+ this.id = ++Strophe._requestId;
+ this.xmlData = elem;
+ this.data = Strophe.serialize(elem); // save original function in case we need to make a new request
+ // from this one.
+
+ this.origFunc = func;
+ this.func = func;
+ this.rid = rid;
+ this.date = NaN;
+ this.sends = sends || 0;
+ this.abort = false;
+ this.dead = null;
+
+ this.age = function () {
+ if (!this.date) {
+ return 0;
+ }
+
+ var now = new Date();
+ return (now - this.date) / 1000;
+ };
+
+ this.timeDead = function () {
+ if (!this.dead) {
+ return 0;
+ }
+
+ var now = new Date();
+ return (now - this.dead) / 1000;
+ };
+
+ this.xhr = this._newXHR();
+};
+
+Strophe.Request.prototype = {
+ /** PrivateFunction: getResponse
+ * Get a response from the underlying XMLHttpRequest.
+ *
+ * This function attempts to get a response from the request and checks
+ * for errors.
+ *
+ * Throws:
+ * "parsererror" - A parser error occured.
+ * "bad-format" - The entity has sent XML that cannot be processed.
+ *
+ * Returns:
+ * The DOM element tree of the response.
+ */
+ getResponse: function getResponse() {
+ var node = null;
+
+ if (this.xhr.responseXML && this.xhr.responseXML.documentElement) {
+ node = this.xhr.responseXML.documentElement;
+
+ if (node.tagName === "parsererror") {
+ Strophe.error("invalid response received");
+ Strophe.error("responseText: " + this.xhr.responseText);
+ Strophe.error("responseXML: " + Strophe.serialize(this.xhr.responseXML));
+ throw new Error("parsererror");
+ }
+ } else if (this.xhr.responseText) {
+ // In React Native, we may get responseText but no responseXML. We can try to parse it manually.
+ Strophe.debug("Got responseText but no responseXML; attempting to parse it with DOMParser...");
+ node = new DOMParser().parseFromString(this.xhr.responseText, 'application/xml').documentElement;
+
+ if (!node) {
+ throw new Error('Parsing produced null node');
+ } else if (node.querySelector('parsererror')) {
+ Strophe.error("invalid response received: " + node.querySelector('parsererror').textContent);
+ Strophe.error("responseText: " + this.xhr.responseText);
+ var error = new Error();
+ error.name = Strophe.ErrorCondition.BAD_FORMAT;
+ throw error;
+ }
+ }
+
+ return node;
+ },
+
+ /** PrivateFunction: _newXHR
+ * _Private_ helper function to create XMLHttpRequests.
+ *
+ * This function creates XMLHttpRequests across all implementations.
+ *
+ * Returns:
+ * A new XMLHttpRequest.
+ */
+ _newXHR: function _newXHR() {
+ var xhr = null;
+
+ if (window.XMLHttpRequest) {
+ xhr = new XMLHttpRequest();
+
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType("text/xml; charset=utf-8");
+ }
+ } else if (window.ActiveXObject) {
+ xhr = new ActiveXObject("Microsoft.XMLHTTP");
+ } // use Function.bind() to prepend ourselves as an argument
+
+
+ xhr.onreadystatechange = this.func.bind(null, this);
+ return xhr;
+ }
+};
+/** Class: Strophe.Bosh
+ * _Private_ helper class that handles BOSH Connections
+ *
+ * The Strophe.Bosh class is used internally by Strophe.Connection
+ * to encapsulate BOSH sessions. It is not meant to be used from user's code.
+ */
+
+/** File: bosh.js
+ * A JavaScript library to enable BOSH in Strophejs.
+ *
+ * this library uses Bidirectional-streams Over Synchronous HTTP (BOSH)
+ * to emulate a persistent, stateful, two-way connection to an XMPP server.
+ * More information on BOSH can be found in XEP 124.
+ */
+
+/** PrivateConstructor: Strophe.Bosh
+ * Create and initialize a Strophe.Bosh object.
+ *
+ * Parameters:
+ * (Strophe.Connection) connection - The Strophe.Connection that will use BOSH.
+ *
+ * Returns:
+ * A new Strophe.Bosh object.
+ */
+
+Strophe.Bosh = function (connection) {
+ this._conn = connection;
+ /* request id for body tags */
+
+ this.rid = Math.floor(Math.random() * 4294967295);
+ /* The current session ID. */
+
+ this.sid = null; // default BOSH values
+
+ this.hold = 1;
+ this.wait = 60;
+ this.window = 5;
+ this.errors = 0;
+ this.inactivity = null;
+ this.lastResponseHeaders = null;
+ this._requests = [];
+};
+
+Strophe.Bosh.prototype = {
+ /** Variable: strip
+ *
+ * BOSH-Connections will have all stanzas wrapped in a
tag when
+ * passed to or .
+ * To strip this tag, User code can set to "body":
+ *
+ * > Strophe.Bosh.prototype.strip = "body";
+ *
+ * This will enable stripping of the body tag in both
+ * and .
+ */
+ strip: null,
+
+ /** PrivateFunction: _buildBody
+ * _Private_ helper function to generate the wrapper for BOSH.
+ *
+ * Returns:
+ * A Strophe.Builder with a element.
+ */
+ _buildBody: function _buildBody() {
+ var bodyWrap = $build('body', {
+ 'rid': this.rid++,
+ 'xmlns': Strophe.NS.HTTPBIND
+ });
+
+ if (this.sid !== null) {
+ bodyWrap.attrs({
+ 'sid': this.sid
+ });
+ }
+
+ if (this._conn.options.keepalive && this._conn._sessionCachingSupported()) {
+ this._cacheSession();
+ }
+
+ return bodyWrap;
+ },
+
+ /** PrivateFunction: _reset
+ * Reset the connection.
+ *
+ * This function is called by the reset function of the Strophe Connection
+ */
+ _reset: function _reset() {
+ this.rid = Math.floor(Math.random() * 4294967295);
+ this.sid = null;
+ this.errors = 0;
+
+ if (this._conn._sessionCachingSupported()) {
+ window.sessionStorage.removeItem('strophe-bosh-session');
+ }
+
+ this._conn.nextValidRid(this.rid);
+ },
+
+ /** PrivateFunction: _connect
+ * _Private_ function that initializes the BOSH connection.
+ *
+ * Creates and sends the Request that initializes the BOSH connection.
+ */
+ _connect: function _connect(wait, hold, route) {
+ this.wait = wait || this.wait;
+ this.hold = hold || this.hold;
+ this.errors = 0;
+
+ var body = this._buildBody().attrs({
+ "to": this._conn.domain,
+ "xml:lang": "en",
+ "wait": this.wait,
+ "hold": this.hold,
+ "content": "text/xml; charset=utf-8",
+ "ver": "1.6",
+ "xmpp:version": "1.0",
+ "xmlns:xmpp": Strophe.NS.BOSH
+ });
+
+ if (route) {
+ body.attrs({
+ 'route': route
+ });
+ }
+
+ var _connect_cb = this._conn._connect_cb;
+
+ this._requests.push(new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, _connect_cb.bind(this._conn)), body.tree().getAttribute("rid")));
+
+ this._throttledRequestHandler();
+ },
+
+ /** PrivateFunction: _attach
+ * Attach to an already created and authenticated BOSH session.
+ *
+ * This function is provided to allow Strophe to attach to BOSH
+ * sessions which have been created externally, perhaps by a Web
+ * application. This is often used to support auto-login type features
+ * without putting user credentials into the page.
+ *
+ * Parameters:
+ * (String) jid - The full JID that is bound by the session.
+ * (String) sid - The SID of the BOSH session.
+ * (String) rid - The current RID of the BOSH session. This RID
+ * will be used by the next request.
+ * (Function) callback The connect callback function.
+ * (Integer) wait - The optional HTTPBIND wait value. This is the
+ * time the server will wait before returning an empty result for
+ * a request. The default setting of 60 seconds is recommended.
+ * Other settings will require tweaks to the Strophe.TIMEOUT value.
+ * (Integer) hold - The optional HTTPBIND hold value. This is the
+ * number of connections the server will hold at one time. This
+ * should almost always be set to 1 (the default).
+ * (Integer) wind - The optional HTTBIND window value. This is the
+ * allowed range of request ids that are valid. The default is 5.
+ */
+ _attach: function _attach(jid, sid, rid, callback, wait, hold, wind) {
+ this._conn.jid = jid;
+ this.sid = sid;
+ this.rid = rid;
+ this._conn.connect_callback = callback;
+ this._conn.domain = Strophe.getDomainFromJid(this._conn.jid);
+ this._conn.authenticated = true;
+ this._conn.connected = true;
+ this.wait = wait || this.wait;
+ this.hold = hold || this.hold;
+ this.window = wind || this.window;
+
+ this._conn._changeConnectStatus(Strophe.Status.ATTACHED, null);
+ },
+
+ /** PrivateFunction: _restore
+ * Attempt to restore a cached BOSH session
+ *
+ * Parameters:
+ * (String) jid - The full JID that is bound by the session.
+ * This parameter is optional but recommended, specifically in cases
+ * where prebinded BOSH sessions are used where it's important to know
+ * that the right session is being restored.
+ * (Function) callback The connect callback function.
+ * (Integer) wait - The optional HTTPBIND wait value. This is the
+ * time the server will wait before returning an empty result for
+ * a request. The default setting of 60 seconds is recommended.
+ * Other settings will require tweaks to the Strophe.TIMEOUT value.
+ * (Integer) hold - The optional HTTPBIND hold value. This is the
+ * number of connections the server will hold at one time. This
+ * should almost always be set to 1 (the default).
+ * (Integer) wind - The optional HTTBIND window value. This is the
+ * allowed range of request ids that are valid. The default is 5.
+ */
+ _restore: function _restore(jid, callback, wait, hold, wind) {
+ var session = JSON.parse(window.sessionStorage.getItem('strophe-bosh-session'));
+
+ if (typeof session !== "undefined" && session !== null && session.rid && session.sid && session.jid && (typeof jid === "undefined" || jid === null || Strophe.getBareJidFromJid(session.jid) === Strophe.getBareJidFromJid(jid) || // If authcid is null, then it's an anonymous login, so
+ // we compare only the domains:
+ Strophe.getNodeFromJid(jid) === null && Strophe.getDomainFromJid(session.jid) === jid)) {
+ this._conn.restored = true;
+
+ this._attach(session.jid, session.sid, session.rid, callback, wait, hold, wind);
+ } else {
+ var error = new Error("_restore: no restoreable session.");
+ error.name = "StropheSessionError";
+ throw error;
+ }
+ },
+
+ /** PrivateFunction: _cacheSession
+ * _Private_ handler for the beforeunload event.
+ *
+ * This handler is used to process the Bosh-part of the initial request.
+ * Parameters:
+ * (Strophe.Request) bodyWrap - The received stanza.
+ */
+ _cacheSession: function _cacheSession() {
+ if (this._conn.authenticated) {
+ if (this._conn.jid && this.rid && this.sid) {
+ window.sessionStorage.setItem('strophe-bosh-session', JSON.stringify({
+ 'jid': this._conn.jid,
+ 'rid': this.rid,
+ 'sid': this.sid
+ }));
+ }
+ } else {
+ window.sessionStorage.removeItem('strophe-bosh-session');
+ }
+ },
+
+ /** PrivateFunction: _connect_cb
+ * _Private_ handler for initial connection request.
+ *
+ * This handler is used to process the Bosh-part of the initial request.
+ * Parameters:
+ * (Strophe.Request) bodyWrap - The received stanza.
+ */
+ _connect_cb: function _connect_cb(bodyWrap) {
+ var typ = bodyWrap.getAttribute("type");
+
+ if (typ !== null && typ === "terminate") {
+ // an error occurred
+ var cond = bodyWrap.getAttribute("condition");
+ Strophe.error("BOSH-Connection failed: " + cond);
+ var conflict = bodyWrap.getElementsByTagName("conflict");
+
+ if (cond !== null) {
+ if (cond === "remote-stream-error" && conflict.length > 0) {
+ cond = "conflict";
+ }
+
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, cond);
+ } else {
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "unknown");
+ }
+
+ this._conn._doDisconnect(cond);
+
+ return Strophe.Status.CONNFAIL;
+ } // check to make sure we don't overwrite these if _connect_cb is
+ // called multiple times in the case of missing stream:features
+
+
+ if (!this.sid) {
+ this.sid = bodyWrap.getAttribute("sid");
+ }
+
+ var wind = bodyWrap.getAttribute('requests');
+
+ if (wind) {
+ this.window = parseInt(wind, 10);
+ }
+
+ var hold = bodyWrap.getAttribute('hold');
+
+ if (hold) {
+ this.hold = parseInt(hold, 10);
+ }
+
+ var wait = bodyWrap.getAttribute('wait');
+
+ if (wait) {
+ this.wait = parseInt(wait, 10);
+ }
+
+ var inactivity = bodyWrap.getAttribute('inactivity');
+
+ if (inactivity) {
+ this.inactivity = parseInt(inactivity, 10);
+ }
+ },
+
+ /** PrivateFunction: _disconnect
+ * _Private_ part of Connection.disconnect for Bosh
+ *
+ * Parameters:
+ * (Request) pres - This stanza will be sent before disconnecting.
+ */
+ _disconnect: function _disconnect(pres) {
+ this._sendTerminate(pres);
+ },
+
+ /** PrivateFunction: _doDisconnect
+ * _Private_ function to disconnect.
+ *
+ * Resets the SID and RID.
+ */
+ _doDisconnect: function _doDisconnect() {
+ this.sid = null;
+ this.rid = Math.floor(Math.random() * 4294967295);
+
+ if (this._conn._sessionCachingSupported()) {
+ window.sessionStorage.removeItem('strophe-bosh-session');
+ }
+
+ this._conn.nextValidRid(this.rid);
+ },
+
+ /** PrivateFunction: _emptyQueue
+ * _Private_ function to check if the Request queue is empty.
+ *
+ * Returns:
+ * True, if there are no Requests queued, False otherwise.
+ */
+ _emptyQueue: function _emptyQueue() {
+ return this._requests.length === 0;
+ },
+
+ /** PrivateFunction: _callProtocolErrorHandlers
+ * _Private_ function to call error handlers registered for HTTP errors.
+ *
+ * Parameters:
+ * (Strophe.Request) req - The request that is changing readyState.
+ */
+ _callProtocolErrorHandlers: function _callProtocolErrorHandlers(req) {
+ var reqStatus = this._getRequestStatus(req);
+
+ var err_callback = this._conn.protocolErrorHandlers.HTTP[reqStatus];
+
+ if (err_callback) {
+ err_callback.call(this, reqStatus);
+ }
+ },
+
+ /** PrivateFunction: _hitError
+ * _Private_ function to handle the error count.
+ *
+ * Requests are resent automatically until their error count reaches
+ * 5. Each time an error is encountered, this function is called to
+ * increment the count and disconnect if the count is too high.
+ *
+ * Parameters:
+ * (Integer) reqStatus - The request status.
+ */
+ _hitError: function _hitError(reqStatus) {
+ this.errors++;
+ Strophe.warn("request errored, status: " + reqStatus + ", number of errors: " + this.errors);
+
+ if (this.errors > 4) {
+ this._conn._onDisconnectTimeout();
+ }
+ },
+
+ /** PrivateFunction: _no_auth_received
+ *
+ * Called on stream start/restart when no stream:features
+ * has been received and sends a blank poll request.
+ */
+ _no_auth_received: function _no_auth_received(callback) {
+ Strophe.warn("Server did not yet offer a supported authentication " + "mechanism. Sending a blank poll request.");
+
+ if (callback) {
+ callback = callback.bind(this._conn);
+ } else {
+ callback = this._conn._connect_cb.bind(this._conn);
+ }
+
+ var body = this._buildBody();
+
+ this._requests.push(new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, callback), body.tree().getAttribute("rid")));
+
+ this._throttledRequestHandler();
+ },
+
+ /** PrivateFunction: _onDisconnectTimeout
+ * _Private_ timeout handler for handling non-graceful disconnection.
+ *
+ * Cancels all remaining Requests and clears the queue.
+ */
+ _onDisconnectTimeout: function _onDisconnectTimeout() {
+ this._abortAllRequests();
+ },
+
+ /** PrivateFunction: _abortAllRequests
+ * _Private_ helper function that makes sure all pending requests are aborted.
+ */
+ _abortAllRequests: function _abortAllRequests() {
+ while (this._requests.length > 0) {
+ var req = this._requests.pop();
+
+ req.abort = true;
+ req.xhr.abort(); // jslint complains, but this is fine. setting to empty func
+ // is necessary for IE6
+
+ req.xhr.onreadystatechange = function () {}; // jshint ignore:line
+
+ }
+ },
+
+ /** PrivateFunction: _onIdle
+ * _Private_ handler called by Strophe.Connection._onIdle
+ *
+ * Sends all queued Requests or polls with empty Request if there are none.
+ */
+ _onIdle: function _onIdle() {
+ var data = this._conn._data; // if no requests are in progress, poll
+
+ if (this._conn.authenticated && this._requests.length === 0 && data.length === 0 && !this._conn.disconnecting) {
+ Strophe.info("no requests during idle cycle, sending " + "blank request");
+ data.push(null);
+ }
+
+ if (this._conn.paused) {
+ return;
+ }
+
+ if (this._requests.length < 2 && data.length > 0) {
+ var body = this._buildBody();
+
+ for (var i = 0; i < data.length; i++) {
+ if (data[i] !== null) {
+ if (data[i] === "restart") {
+ body.attrs({
+ "to": this._conn.domain,
+ "xml:lang": "en",
+ "xmpp:restart": "true",
+ "xmlns:xmpp": Strophe.NS.BOSH
+ });
+ } else {
+ body.cnode(data[i]).up();
+ }
+ }
+ }
+
+ delete this._conn._data;
+ this._conn._data = [];
+
+ this._requests.push(new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, this._conn._dataRecv.bind(this._conn)), body.tree().getAttribute("rid")));
+
+ this._throttledRequestHandler();
+ }
+
+ if (this._requests.length > 0) {
+ var time_elapsed = this._requests[0].age();
+
+ if (this._requests[0].dead !== null) {
+ if (this._requests[0].timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) {
+ this._throttledRequestHandler();
+ }
+ }
+
+ if (time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait)) {
+ Strophe.warn("Request " + this._requests[0].id + " timed out, over " + Math.floor(Strophe.TIMEOUT * this.wait) + " seconds since last activity");
+
+ this._throttledRequestHandler();
+ }
+ }
+ },
+
+ /** PrivateFunction: _getRequestStatus
+ *
+ * Returns the HTTP status code from a Strophe.Request
+ *
+ * Parameters:
+ * (Strophe.Request) req - The Strophe.Request instance.
+ * (Integer) def - The default value that should be returned if no
+ * status value was found.
+ */
+ _getRequestStatus: function _getRequestStatus(req, def) {
+ var reqStatus;
+
+ if (req.xhr.readyState === 4) {
+ try {
+ reqStatus = req.xhr.status;
+ } catch (e) {
+ // ignore errors from undefined status attribute. Works
+ // around a browser bug
+ Strophe.error("Caught an error while retrieving a request's status, " + "reqStatus: " + reqStatus);
+ }
+ }
+
+ if (typeof reqStatus === "undefined") {
+ reqStatus = typeof def === 'number' ? def : 0;
+ }
+
+ return reqStatus;
+ },
+
+ /** PrivateFunction: _onRequestStateChange
+ * _Private_ handler for Strophe.Request state changes.
+ *
+ * This function is called when the XMLHttpRequest readyState changes.
+ * It contains a lot of error handling logic for the many ways that
+ * requests can fail, and calls the request callback when requests
+ * succeed.
+ *
+ * Parameters:
+ * (Function) func - The handler for the request.
+ * (Strophe.Request) req - The request that is changing readyState.
+ */
+ _onRequestStateChange: function _onRequestStateChange(func, req) {
+ Strophe.debug("request id " + req.id + "." + req.sends + " state changed to " + req.xhr.readyState);
+
+ if (req.abort) {
+ req.abort = false;
+ return;
+ }
+
+ if (req.xhr.readyState !== 4) {
+ // The request is not yet complete
+ return;
+ }
+
+ var reqStatus = this._getRequestStatus(req);
+
+ this.lastResponseHeaders = req.xhr.getAllResponseHeaders();
+
+ if (this.disconnecting && reqStatus >= 400) {
+ this._hitError(reqStatus);
+
+ this._callProtocolErrorHandlers(req);
+
+ return;
+ }
+
+ var valid_request = reqStatus > 0 && reqStatus < 500;
+ var too_many_retries = req.sends > this._conn.maxRetries;
+
+ if (valid_request || too_many_retries) {
+ // remove from internal queue
+ this._removeRequest(req);
+
+ Strophe.debug("request id " + req.id + " should now be removed");
+ }
+
+ if (reqStatus === 200) {
+ // request succeeded
+ var reqIs0 = this._requests[0] === req;
+ var reqIs1 = this._requests[1] === req; // if request 1 finished, or request 0 finished and request
+ // 1 is over Strophe.SECONDARY_TIMEOUT seconds old, we need to
+ // restart the other - both will be in the first spot, as the
+ // completed request has been removed from the queue already
+
+ if (reqIs1 || reqIs0 && this._requests.length > 0 && this._requests[0].age() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) {
+ this._restartRequest(0);
+ }
+
+ this._conn.nextValidRid(Number(req.rid) + 1);
+
+ Strophe.debug("request id " + req.id + "." + req.sends + " got 200");
+ func(req); // call handler
+
+ this.errors = 0;
+ } else if (reqStatus === 0 || reqStatus >= 400 && reqStatus < 600 || reqStatus >= 12000) {
+ // request failed
+ Strophe.error("request id " + req.id + "." + req.sends + " error " + reqStatus + " happened");
+
+ this._hitError(reqStatus);
+
+ this._callProtocolErrorHandlers(req);
+
+ if (reqStatus >= 400 && reqStatus < 500) {
+ this._conn._changeConnectStatus(Strophe.Status.DISCONNECTING, null);
+
+ this._conn._doDisconnect();
+ }
+ } else {
+ Strophe.error("request id " + req.id + "." + req.sends + " error " + reqStatus + " happened");
+ }
+
+ if (!valid_request && !too_many_retries) {
+ this._throttledRequestHandler();
+ } else if (too_many_retries && !this._conn.connected) {
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "giving-up");
+ }
+ },
+
+ /** PrivateFunction: _processRequest
+ * _Private_ function to process a request in the queue.
+ *
+ * This function takes requests off the queue and sends them and
+ * restarts dead requests.
+ *
+ * Parameters:
+ * (Integer) i - The index of the request in the queue.
+ */
+ _processRequest: function _processRequest(i) {
+ var _this = this;
+
+ var req = this._requests[i];
+
+ var reqStatus = this._getRequestStatus(req, -1); // make sure we limit the number of retries
+
+
+ if (req.sends > this._conn.maxRetries) {
+ this._conn._onDisconnectTimeout();
+
+ return;
+ }
+
+ var time_elapsed = req.age();
+ var primary_timeout = !isNaN(time_elapsed) && time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait);
+ var secondary_timeout = req.dead !== null && req.timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait);
+ var server_error = req.xhr.readyState === 4 && (reqStatus < 1 || reqStatus >= 500);
+
+ if (primary_timeout || secondary_timeout || server_error) {
+ if (secondary_timeout) {
+ Strophe.error("Request ".concat(this._requests[i].id, " timed out (secondary), restarting"));
+ }
+
+ req.abort = true;
+ req.xhr.abort(); // setting to null fails on IE6, so set to empty function
+
+ req.xhr.onreadystatechange = function () {};
+
+ this._requests[i] = new Strophe.Request(req.xmlData, req.origFunc, req.rid, req.sends);
+ req = this._requests[i];
+ }
+
+ if (req.xhr.readyState === 0) {
+ Strophe.debug("request id " + req.id + "." + req.sends + " posting");
+
+ try {
+ var content_type = this._conn.options.contentType || "text/xml; charset=utf-8";
+ req.xhr.open("POST", this._conn.service, this._conn.options.sync ? false : true);
+
+ if (typeof req.xhr.setRequestHeader !== 'undefined') {
+ // IE9 doesn't have setRequestHeader
+ req.xhr.setRequestHeader("Content-Type", content_type);
+ }
+
+ if (this._conn.options.withCredentials) {
+ req.xhr.withCredentials = true;
+ }
+ } catch (e2) {
+ Strophe.error("XHR open failed: " + e2.toString());
+
+ if (!this._conn.connected) {
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "bad-service");
+ }
+
+ this._conn.disconnect();
+
+ return;
+ } // Fires the XHR request -- may be invoked immediately
+ // or on a gradually expanding retry window for reconnects
+
+
+ var sendFunc = function sendFunc() {
+ req.date = new Date();
+
+ if (_this._conn.options.customHeaders) {
+ var headers = _this._conn.options.customHeaders;
+
+ for (var header in headers) {
+ if (Object.prototype.hasOwnProperty.call(headers, header)) {
+ req.xhr.setRequestHeader(header, headers[header]);
+ }
+ }
+ }
+
+ req.xhr.send(req.data);
+ }; // Implement progressive backoff for reconnects --
+ // First retry (send === 1) should also be instantaneous
+
+
+ if (req.sends > 1) {
+ // Using a cube of the retry number creates a nicely
+ // expanding retry window
+ var backoff = Math.min(Math.floor(Strophe.TIMEOUT * this.wait), Math.pow(req.sends, 3)) * 1000;
+ setTimeout(function () {
+ // XXX: setTimeout should be called only with function expressions (23974bc1)
+ sendFunc();
+ }, backoff);
+ } else {
+ sendFunc();
+ }
+
+ req.sends++;
+
+ if (this._conn.xmlOutput !== Strophe.Connection.prototype.xmlOutput) {
+ if (req.xmlData.nodeName === this.strip && req.xmlData.childNodes.length) {
+ this._conn.xmlOutput(req.xmlData.childNodes[0]);
+ } else {
+ this._conn.xmlOutput(req.xmlData);
+ }
+ }
+
+ if (this._conn.rawOutput !== Strophe.Connection.prototype.rawOutput) {
+ this._conn.rawOutput(req.data);
+ }
+ } else {
+ Strophe.debug("_processRequest: " + (i === 0 ? "first" : "second") + " request has readyState of " + req.xhr.readyState);
+ }
+ },
+
+ /** PrivateFunction: _removeRequest
+ * _Private_ function to remove a request from the queue.
+ *
+ * Parameters:
+ * (Strophe.Request) req - The request to remove.
+ */
+ _removeRequest: function _removeRequest(req) {
+ Strophe.debug("removing request");
+
+ for (var i = this._requests.length - 1; i >= 0; i--) {
+ if (req === this._requests[i]) {
+ this._requests.splice(i, 1);
+ }
+ } // IE6 fails on setting to null, so set to empty function
+
+
+ req.xhr.onreadystatechange = function () {};
+
+ this._throttledRequestHandler();
+ },
+
+ /** PrivateFunction: _restartRequest
+ * _Private_ function to restart a request that is presumed dead.
+ *
+ * Parameters:
+ * (Integer) i - The index of the request in the queue.
+ */
+ _restartRequest: function _restartRequest(i) {
+ var req = this._requests[i];
+
+ if (req.dead === null) {
+ req.dead = new Date();
+ }
+
+ this._processRequest(i);
+ },
+
+ /** PrivateFunction: _reqToData
+ * _Private_ function to get a stanza out of a request.
+ *
+ * Tries to extract a stanza out of a Request Object.
+ * When this fails the current connection will be disconnected.
+ *
+ * Parameters:
+ * (Object) req - The Request.
+ *
+ * Returns:
+ * The stanza that was passed.
+ */
+ _reqToData: function _reqToData(req) {
+ try {
+ return req.getResponse();
+ } catch (e) {
+ if (e.message !== "parsererror") {
+ throw e;
+ }
+
+ this._conn.disconnect("strophe-parsererror");
+ }
+ },
+
+ /** PrivateFunction: _sendTerminate
+ * _Private_ function to send initial disconnect sequence.
+ *
+ * This is the first step in a graceful disconnect. It sends
+ * the BOSH server a terminate body and includes an unavailable
+ * presence if authentication has completed.
+ */
+ _sendTerminate: function _sendTerminate(pres) {
+ Strophe.info("_sendTerminate was called");
+
+ var body = this._buildBody().attrs({
+ type: "terminate"
+ });
+
+ if (pres) {
+ body.cnode(pres.tree());
+ }
+
+ var req = new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, this._conn._dataRecv.bind(this._conn)), body.tree().getAttribute("rid"));
+
+ this._requests.push(req);
+
+ this._throttledRequestHandler();
+ },
+
+ /** PrivateFunction: _send
+ * _Private_ part of the Connection.send function for BOSH
+ *
+ * Just triggers the RequestHandler to send the messages that are in the queue
+ */
+ _send: function _send() {
+ var _this2 = this;
+
+ clearTimeout(this._conn._idleTimeout);
+
+ this._throttledRequestHandler();
+
+ this._conn._idleTimeout = setTimeout(function () {
+ return _this2._conn._onIdle();
+ }, 100);
+ },
+
+ /** PrivateFunction: _sendRestart
+ *
+ * Send an xmpp:restart stanza.
+ */
+ _sendRestart: function _sendRestart() {
+ this._throttledRequestHandler();
+
+ clearTimeout(this._conn._idleTimeout);
+ },
+
+ /** PrivateFunction: _throttledRequestHandler
+ * _Private_ function to throttle requests to the connection window.
+ *
+ * This function makes sure we don't send requests so fast that the
+ * request ids overflow the connection window in the case that one
+ * request died.
+ */
+ _throttledRequestHandler: function _throttledRequestHandler() {
+ if (!this._requests) {
+ Strophe.debug("_throttledRequestHandler called with " + "undefined requests");
+ } else {
+ Strophe.debug("_throttledRequestHandler called with " + this._requests.length + " requests");
+ }
+
+ if (!this._requests || this._requests.length === 0) {
+ return;
+ }
+
+ if (this._requests.length > 0) {
+ this._processRequest(0);
+ }
+
+ if (this._requests.length > 1 && Math.abs(this._requests[0].rid - this._requests[1].rid) < this.window) {
+ this._processRequest(1);
+ }
+ }
+};
+
+/***/ }),
+
+/***/ "./src/core.js":
+/*!*********************!*\
+ !*** ./src/core.js ***!
+ \*********************/
+/*! exports provided: default */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var md5__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! md5 */ "./src/md5.js");
+/* harmony import */ var sha1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sha1 */ "./src/sha1.js");
+/* harmony import */ var utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! utils */ "./src/utils.js");
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
+
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
+
+function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
+
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
+
+function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+/*
+ This program is distributed under the terms of the MIT license.
+ Please see the LICENSE file for details.
+
+ Copyright 2006-2018, OGG, LLC
+*/
+
+/*global define, document, sessionStorage, setTimeout, clearTimeout, ActiveXObject, DOMParser, btoa, atob, module */
+
+
+
+/** Function: $build
+ * Create a Strophe.Builder.
+ * This is an alias for 'new Strophe.Builder(name, attrs)'.
+ *
+ * Parameters:
+ * (String) name - The root element name.
+ * (Object) attrs - The attributes for the root element in object notation.
+ *
+ * Returns:
+ * A new Strophe.Builder object.
+ */
+
+function $build(name, attrs) {
+ return new Strophe.Builder(name, attrs);
+}
+/** Function: $msg
+ * Create a Strophe.Builder with a element as the root.
+ *
+ * Parameters:
+ * (Object) attrs - The element attributes in object notation.
+ *
+ * Returns:
+ * A new Strophe.Builder object.
+ */
+
+
+function $msg(attrs) {
+ return new Strophe.Builder("message", attrs);
+}
+/** Function: $iq
+ * Create a Strophe.Builder with an element as the root.
+ *
+ * Parameters:
+ * (Object) attrs - The element attributes in object notation.
+ *
+ * Returns:
+ * A new Strophe.Builder object.
+ */
+
+
+function $iq(attrs) {
+ return new Strophe.Builder("iq", attrs);
+}
+/** Function: $pres
+ * Create a Strophe.Builder with a element as the root.
+ *
+ * Parameters:
+ * (Object) attrs - The element attributes in object notation.
+ *
+ * Returns:
+ * A new Strophe.Builder object.
+ */
+
+
+function $pres(attrs) {
+ return new Strophe.Builder("presence", attrs);
+}
+/** Class: Strophe
+ * An object container for all Strophe library functions.
+ *
+ * This class is just a container for all the objects and constants
+ * used in the library. It is not meant to be instantiated, but to
+ * provide a namespace for library objects, constants, and functions.
+ */
+
+
+var Strophe = {
+ /** Constant: VERSION */
+ VERSION: "1.3.0",
+
+ /** Constants: XMPP Namespace Constants
+ * Common namespace constants from the XMPP RFCs and XEPs.
+ *
+ * NS.HTTPBIND - HTTP BIND namespace from XEP 124.
+ * NS.BOSH - BOSH namespace from XEP 206.
+ * NS.CLIENT - Main XMPP client namespace.
+ * NS.AUTH - Legacy authentication namespace.
+ * NS.ROSTER - Roster operations namespace.
+ * NS.PROFILE - Profile namespace.
+ * NS.DISCO_INFO - Service discovery info namespace from XEP 30.
+ * NS.DISCO_ITEMS - Service discovery items namespace from XEP 30.
+ * NS.MUC - Multi-User Chat namespace from XEP 45.
+ * NS.SASL - XMPP SASL namespace from RFC 3920.
+ * NS.STREAM - XMPP Streams namespace from RFC 3920.
+ * NS.BIND - XMPP Binding namespace from RFC 3920.
+ * NS.SESSION - XMPP Session namespace from RFC 3920.
+ * NS.XHTML_IM - XHTML-IM namespace from XEP 71.
+ * NS.XHTML - XHTML body namespace from XEP 71.
+ */
+ NS: {
+ HTTPBIND: "http://jabber.org/protocol/httpbind",
+ BOSH: "urn:xmpp:xbosh",
+ CLIENT: "jabber:client",
+ AUTH: "jabber:iq:auth",
+ ROSTER: "jabber:iq:roster",
+ PROFILE: "jabber:iq:profile",
+ DISCO_INFO: "http://jabber.org/protocol/disco#info",
+ DISCO_ITEMS: "http://jabber.org/protocol/disco#items",
+ MUC: "http://jabber.org/protocol/muc",
+ SASL: "urn:ietf:params:xml:ns:xmpp-sasl",
+ STREAM: "http://etherx.jabber.org/streams",
+ FRAMING: "urn:ietf:params:xml:ns:xmpp-framing",
+ BIND: "urn:ietf:params:xml:ns:xmpp-bind",
+ SESSION: "urn:ietf:params:xml:ns:xmpp-session",
+ VERSION: "jabber:iq:version",
+ STANZAS: "urn:ietf:params:xml:ns:xmpp-stanzas",
+ XHTML_IM: "http://jabber.org/protocol/xhtml-im",
+ XHTML: "http://www.w3.org/1999/xhtml"
+ },
+
+ /** Constants: XHTML_IM Namespace
+ * contains allowed tags, tag attributes, and css properties.
+ * Used in the createHtml function to filter incoming html into the allowed XHTML-IM subset.
+ * See http://xmpp.org/extensions/xep-0071.html#profile-summary for the list of recommended
+ * allowed tags and their attributes.
+ */
+ XHTML: {
+ tags: ['a', 'blockquote', 'br', 'cite', 'em', 'img', 'li', 'ol', 'p', 'span', 'strong', 'ul', 'body'],
+ attributes: {
+ 'a': ['href'],
+ 'blockquote': ['style'],
+ 'br': [],
+ 'cite': ['style'],
+ 'em': [],
+ 'img': ['src', 'alt', 'style', 'height', 'width'],
+ 'li': ['style'],
+ 'ol': ['style'],
+ 'p': ['style'],
+ 'span': ['style'],
+ 'strong': [],
+ 'ul': ['style'],
+ 'body': []
+ },
+ css: ['background-color', 'color', 'font-family', 'font-size', 'font-style', 'font-weight', 'margin-left', 'margin-right', 'text-align', 'text-decoration'],
+
+ /** Function: XHTML.validTag
+ *
+ * Utility method to determine whether a tag is allowed
+ * in the XHTML_IM namespace.
+ *
+ * XHTML tag names are case sensitive and must be lower case.
+ */
+ validTag: function validTag(tag) {
+ for (var i = 0; i < Strophe.XHTML.tags.length; i++) {
+ if (tag === Strophe.XHTML.tags[i]) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ /** Function: XHTML.validAttribute
+ *
+ * Utility method to determine whether an attribute is allowed
+ * as recommended per XEP-0071
+ *
+ * XHTML attribute names are case sensitive and must be lower case.
+ */
+ validAttribute: function validAttribute(tag, attribute) {
+ if (typeof Strophe.XHTML.attributes[tag] !== 'undefined' && Strophe.XHTML.attributes[tag].length > 0) {
+ for (var i = 0; i < Strophe.XHTML.attributes[tag].length; i++) {
+ if (attribute === Strophe.XHTML.attributes[tag][i]) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ },
+ validCSS: function validCSS(style) {
+ for (var i = 0; i < Strophe.XHTML.css.length; i++) {
+ if (style === Strophe.XHTML.css[i]) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ },
+
+ /** Constants: Connection Status Constants
+ * Connection status constants for use by the connection handler
+ * callback.
+ *
+ * Status.ERROR - An error has occurred
+ * Status.CONNECTING - The connection is currently being made
+ * Status.CONNFAIL - The connection attempt failed
+ * Status.AUTHENTICATING - The connection is authenticating
+ * Status.AUTHFAIL - The authentication attempt failed
+ * Status.CONNECTED - The connection has succeeded
+ * Status.DISCONNECTED - The connection has been terminated
+ * Status.DISCONNECTING - The connection is currently being terminated
+ * Status.ATTACHED - The connection has been attached
+ * Status.REDIRECT - The connection has been redirected
+ * Status.CONNTIMEOUT - The connection has timed out
+ */
+ Status: {
+ ERROR: 0,
+ CONNECTING: 1,
+ CONNFAIL: 2,
+ AUTHENTICATING: 3,
+ AUTHFAIL: 4,
+ CONNECTED: 5,
+ DISCONNECTED: 6,
+ DISCONNECTING: 7,
+ ATTACHED: 8,
+ REDIRECT: 9,
+ CONNTIMEOUT: 10
+ },
+ ErrorCondition: {
+ BAD_FORMAT: "bad-format",
+ CONFLICT: "conflict",
+ MISSING_JID_NODE: "x-strophe-bad-non-anon-jid",
+ NO_AUTH_MECH: "no-auth-mech",
+ UNKNOWN_REASON: "unknown"
+ },
+
+ /** Constants: Log Level Constants
+ * Logging level indicators.
+ *
+ * LogLevel.DEBUG - Debug output
+ * LogLevel.INFO - Informational output
+ * LogLevel.WARN - Warnings
+ * LogLevel.ERROR - Errors
+ * LogLevel.FATAL - Fatal errors
+ */
+ LogLevel: {
+ DEBUG: 0,
+ INFO: 1,
+ WARN: 2,
+ ERROR: 3,
+ FATAL: 4
+ },
+
+ /** PrivateConstants: DOM Element Type Constants
+ * DOM element types.
+ *
+ * ElementType.NORMAL - Normal element.
+ * ElementType.TEXT - Text data element.
+ * ElementType.FRAGMENT - XHTML fragment element.
+ */
+ ElementType: {
+ NORMAL: 1,
+ TEXT: 3,
+ CDATA: 4,
+ FRAGMENT: 11
+ },
+
+ /** PrivateConstants: Timeout Values
+ * Timeout values for error states. These values are in seconds.
+ * These should not be changed unless you know exactly what you are
+ * doing.
+ *
+ * TIMEOUT - Timeout multiplier. A waiting request will be considered
+ * failed after Math.floor(TIMEOUT * wait) seconds have elapsed.
+ * This defaults to 1.1, and with default wait, 66 seconds.
+ * SECONDARY_TIMEOUT - Secondary timeout multiplier. In cases where
+ * Strophe can detect early failure, it will consider the request
+ * failed if it doesn't return after
+ * Math.floor(SECONDARY_TIMEOUT * wait) seconds have elapsed.
+ * This defaults to 0.1, and with default wait, 6 seconds.
+ */
+ TIMEOUT: 1.1,
+ SECONDARY_TIMEOUT: 0.1,
+
+ /** Function: addNamespace
+ * This function is used to extend the current namespaces in
+ * Strophe.NS. It takes a key and a value with the key being the
+ * name of the new namespace, with its actual value.
+ * For example:
+ * Strophe.addNamespace('PUBSUB', "http://jabber.org/protocol/pubsub");
+ *
+ * Parameters:
+ * (String) name - The name under which the namespace will be
+ * referenced under Strophe.NS
+ * (String) value - The actual namespace.
+ */
+ addNamespace: function addNamespace(name, value) {
+ Strophe.NS[name] = value;
+ },
+
+ /** Function: forEachChild
+ * Map a function over some or all child elements of a given element.
+ *
+ * This is a small convenience function for mapping a function over
+ * some or all of the children of an element. If elemName is null, all
+ * children will be passed to the function, otherwise only children
+ * whose tag names match elemName will be passed.
+ *
+ * Parameters:
+ * (XMLElement) elem - The element to operate on.
+ * (String) elemName - The child element tag name filter.
+ * (Function) func - The function to apply to each child. This
+ * function should take a single argument, a DOM element.
+ */
+ forEachChild: function forEachChild(elem, elemName, func) {
+ for (var i = 0; i < elem.childNodes.length; i++) {
+ var childNode = elem.childNodes[i];
+
+ if (childNode.nodeType === Strophe.ElementType.NORMAL && (!elemName || this.isTagEqual(childNode, elemName))) {
+ func(childNode);
+ }
+ }
+ },
+
+ /** Function: isTagEqual
+ * Compare an element's tag name with a string.
+ *
+ * This function is case sensitive.
+ *
+ * Parameters:
+ * (XMLElement) el - A DOM element.
+ * (String) name - The element name.
+ *
+ * Returns:
+ * true if the element's tag name matches _el_, and false
+ * otherwise.
+ */
+ isTagEqual: function isTagEqual(el, name) {
+ return el.tagName === name;
+ },
+
+ /** PrivateVariable: _xmlGenerator
+ * _Private_ variable that caches a DOM document to
+ * generate elements.
+ */
+ _xmlGenerator: null,
+
+ /** PrivateFunction: _makeGenerator
+ * _Private_ function that creates a dummy XML DOM document to serve as
+ * an element and text node generator.
+ */
+ _makeGenerator: function _makeGenerator() {
+ var doc; // IE9 does implement createDocument(); however, using it will cause the browser to leak memory on page unload.
+ // Here, we test for presence of createDocument() plus IE's proprietary documentMode attribute, which would be
+ // less than 10 in the case of IE9 and below.
+
+ if (document.implementation.createDocument === undefined || document.implementation.createDocument && document.documentMode && document.documentMode < 10) {
+ doc = this._getIEXmlDom();
+ doc.appendChild(doc.createElement('strophe'));
+ } else {
+ doc = document.implementation.createDocument('jabber:client', 'strophe', null);
+ }
+
+ return doc;
+ },
+
+ /** Function: xmlGenerator
+ * Get the DOM document to generate elements.
+ *
+ * Returns:
+ * The currently used DOM document.
+ */
+ xmlGenerator: function xmlGenerator() {
+ if (!Strophe._xmlGenerator) {
+ Strophe._xmlGenerator = Strophe._makeGenerator();
+ }
+
+ return Strophe._xmlGenerator;
+ },
+
+ /** PrivateFunction: _getIEXmlDom
+ * Gets IE xml doc object
+ *
+ * Returns:
+ * A Microsoft XML DOM Object
+ * See Also:
+ * http://msdn.microsoft.com/en-us/library/ms757837%28VS.85%29.aspx
+ */
+ _getIEXmlDom: function _getIEXmlDom() {
+ var doc = null;
+ var docStrings = ["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"];
+
+ for (var d = 0; d < docStrings.length; d++) {
+ if (doc === null) {
+ try {
+ doc = new ActiveXObject(docStrings[d]);
+ } catch (e) {
+ doc = null;
+ }
+ } else {
+ break;
+ }
+ }
+
+ return doc;
+ },
+
+ /** Function: xmlElement
+ * Create an XML DOM element.
+ *
+ * This function creates an XML DOM element correctly across all
+ * implementations. Note that these are not HTML DOM elements, which
+ * aren't appropriate for XMPP stanzas.
+ *
+ * Parameters:
+ * (String) name - The name for the element.
+ * (Array|Object) attrs - An optional array or object containing
+ * key/value pairs to use as element attributes. The object should
+ * be in the format {'key': 'value'} or {key: 'value'}. The array
+ * should have the format [['key1', 'value1'], ['key2', 'value2']].
+ * (String) text - The text child data for the element.
+ *
+ * Returns:
+ * A new XML DOM element.
+ */
+ xmlElement: function xmlElement(name) {
+ if (!name) {
+ return null;
+ }
+
+ var node = Strophe.xmlGenerator().createElement(name); // FIXME: this should throw errors if args are the wrong type or
+ // there are more than two optional args
+
+ for (var a = 1; a < arguments.length; a++) {
+ var arg = arguments[a];
+
+ if (!arg) {
+ continue;
+ }
+
+ if (typeof arg === "string" || typeof arg === "number") {
+ node.appendChild(Strophe.xmlTextNode(arg));
+ } else if (_typeof(arg) === "object" && typeof arg.sort === "function") {
+ for (var i = 0; i < arg.length; i++) {
+ var attr = arg[i];
+
+ if (_typeof(attr) === "object" && typeof attr.sort === "function" && attr[1] !== undefined && attr[1] !== null) {
+ node.setAttribute(attr[0], attr[1]);
+ }
+ }
+ } else if (_typeof(arg) === "object") {
+ for (var k in arg) {
+ if (Object.prototype.hasOwnProperty.call(arg, k) && arg[k] !== undefined && arg[k] !== null) {
+ node.setAttribute(k, arg[k]);
+ }
+ }
+ }
+ }
+
+ return node;
+ },
+
+ /* Function: xmlescape
+ * Excapes invalid xml characters.
+ *
+ * Parameters:
+ * (String) text - text to escape.
+ *
+ * Returns:
+ * Escaped text.
+ */
+ xmlescape: function xmlescape(text) {
+ text = text.replace(/\&/g, "&");
+ text = text.replace(//g, ">");
+ text = text.replace(/'/g, "'");
+ text = text.replace(/"/g, """);
+ return text;
+ },
+
+ /* Function: xmlunescape
+ * Unexcapes invalid xml characters.
+ *
+ * Parameters:
+ * (String) text - text to unescape.
+ *
+ * Returns:
+ * Unescaped text.
+ */
+ xmlunescape: function xmlunescape(text) {
+ text = text.replace(/\&/g, "&");
+ text = text.replace(/</g, "<");
+ text = text.replace(/>/g, ">");
+ text = text.replace(/'/g, "'");
+ text = text.replace(/"/g, "\"");
+ return text;
+ },
+
+ /** Function: xmlTextNode
+ * Creates an XML DOM text node.
+ *
+ * Provides a cross implementation version of document.createTextNode.
+ *
+ * Parameters:
+ * (String) text - The content of the text node.
+ *
+ * Returns:
+ * A new XML DOM text node.
+ */
+ xmlTextNode: function xmlTextNode(text) {
+ return Strophe.xmlGenerator().createTextNode(text);
+ },
+
+ /** Function: xmlHtmlNode
+ * Creates an XML DOM html node.
+ *
+ * Parameters:
+ * (String) html - The content of the html node.
+ *
+ * Returns:
+ * A new XML DOM text node.
+ */
+ xmlHtmlNode: function xmlHtmlNode(html) {
+ var node; //ensure text is escaped
+
+ if (DOMParser) {
+ var parser = new DOMParser();
+ node = parser.parseFromString(html, "text/xml");
+ } else {
+ node = new ActiveXObject("Microsoft.XMLDOM");
+ node.async = "false";
+ node.loadXML(html);
+ }
+
+ return node;
+ },
+
+ /** Function: getText
+ * Get the concatenation of all text children of an element.
+ *
+ * Parameters:
+ * (XMLElement) elem - A DOM element.
+ *
+ * Returns:
+ * A String with the concatenated text of all text element children.
+ */
+ getText: function getText(elem) {
+ if (!elem) {
+ return null;
+ }
+
+ var str = "";
+
+ if (elem.childNodes.length === 0 && elem.nodeType === Strophe.ElementType.TEXT) {
+ str += elem.nodeValue;
+ }
+
+ for (var i = 0; i < elem.childNodes.length; i++) {
+ if (elem.childNodes[i].nodeType === Strophe.ElementType.TEXT) {
+ str += elem.childNodes[i].nodeValue;
+ }
+ }
+
+ return Strophe.xmlescape(str);
+ },
+
+ /** Function: copyElement
+ * Copy an XML DOM element.
+ *
+ * This function copies a DOM element and all its descendants and returns
+ * the new copy.
+ *
+ * Parameters:
+ * (XMLElement) elem - A DOM element.
+ *
+ * Returns:
+ * A new, copied DOM element tree.
+ */
+ copyElement: function copyElement(elem) {
+ var el;
+
+ if (elem.nodeType === Strophe.ElementType.NORMAL) {
+ el = Strophe.xmlElement(elem.tagName);
+
+ for (var i = 0; i < elem.attributes.length; i++) {
+ el.setAttribute(elem.attributes[i].nodeName, elem.attributes[i].value);
+ }
+
+ for (var _i = 0; _i < elem.childNodes.length; _i++) {
+ el.appendChild(Strophe.copyElement(elem.childNodes[_i]));
+ }
+ } else if (elem.nodeType === Strophe.ElementType.TEXT) {
+ el = Strophe.xmlGenerator().createTextNode(elem.nodeValue);
+ }
+
+ return el;
+ },
+
+ /** Function: createHtml
+ * Copy an HTML DOM element into an XML DOM.
+ *
+ * This function copies a DOM element and all its descendants and returns
+ * the new copy.
+ *
+ * Parameters:
+ * (HTMLElement) elem - A DOM element.
+ *
+ * Returns:
+ * A new, copied DOM element tree.
+ */
+ createHtml: function createHtml(elem) {
+ var el;
+
+ if (elem.nodeType === Strophe.ElementType.NORMAL) {
+ var tag = elem.nodeName.toLowerCase(); // XHTML tags must be lower case.
+
+ if (Strophe.XHTML.validTag(tag)) {
+ try {
+ el = Strophe.xmlElement(tag);
+
+ for (var i = 0; i < Strophe.XHTML.attributes[tag].length; i++) {
+ var attribute = Strophe.XHTML.attributes[tag][i];
+ var value = elem.getAttribute(attribute);
+
+ if (typeof value === 'undefined' || value === null || value === '' || value === false || value === 0) {
+ continue;
+ }
+
+ if (attribute === 'style' && _typeof(value) === 'object' && typeof value.cssText !== 'undefined') {
+ value = value.cssText; // we're dealing with IE, need to get CSS out
+ } // filter out invalid css styles
+
+
+ if (attribute === 'style') {
+ var css = [];
+ var cssAttrs = value.split(';');
+
+ for (var j = 0; j < cssAttrs.length; j++) {
+ var attr = cssAttrs[j].split(':');
+ var cssName = attr[0].replace(/^\s*/, "").replace(/\s*$/, "").toLowerCase();
+
+ if (Strophe.XHTML.validCSS(cssName)) {
+ var cssValue = attr[1].replace(/^\s*/, "").replace(/\s*$/, "");
+ css.push(cssName + ': ' + cssValue);
+ }
+ }
+
+ if (css.length > 0) {
+ value = css.join('; ');
+ el.setAttribute(attribute, value);
+ }
+ } else {
+ el.setAttribute(attribute, value);
+ }
+ }
+
+ for (var _i2 = 0; _i2 < elem.childNodes.length; _i2++) {
+ el.appendChild(Strophe.createHtml(elem.childNodes[_i2]));
+ }
+ } catch (e) {
+ // invalid elements
+ el = Strophe.xmlTextNode('');
+ }
+ } else {
+ el = Strophe.xmlGenerator().createDocumentFragment();
+
+ for (var _i3 = 0; _i3 < elem.childNodes.length; _i3++) {
+ el.appendChild(Strophe.createHtml(elem.childNodes[_i3]));
+ }
+ }
+ } else if (elem.nodeType === Strophe.ElementType.FRAGMENT) {
+ el = Strophe.xmlGenerator().createDocumentFragment();
+
+ for (var _i4 = 0; _i4 < elem.childNodes.length; _i4++) {
+ el.appendChild(Strophe.createHtml(elem.childNodes[_i4]));
+ }
+ } else if (elem.nodeType === Strophe.ElementType.TEXT) {
+ el = Strophe.xmlTextNode(elem.nodeValue);
+ }
+
+ return el;
+ },
+
+ /** Function: escapeNode
+ * Escape the node part (also called local part) of a JID.
+ *
+ * Parameters:
+ * (String) node - A node (or local part).
+ *
+ * Returns:
+ * An escaped node (or local part).
+ */
+ escapeNode: function escapeNode(node) {
+ if (typeof node !== "string") {
+ return node;
+ }
+
+ return node.replace(/^\s+|\s+$/g, '').replace(/\\/g, "\\5c").replace(/ /g, "\\20").replace(/\"/g, "\\22").replace(/\&/g, "\\26").replace(/\'/g, "\\27").replace(/\//g, "\\2f").replace(/:/g, "\\3a").replace(//g, "\\3e").replace(/@/g, "\\40");
+ },
+
+ /** Function: unescapeNode
+ * Unescape a node part (also called local part) of a JID.
+ *
+ * Parameters:
+ * (String) node - A node (or local part).
+ *
+ * Returns:
+ * An unescaped node (or local part).
+ */
+ unescapeNode: function unescapeNode(node) {
+ if (typeof node !== "string") {
+ return node;
+ }
+
+ return node.replace(/\\20/g, " ").replace(/\\22/g, '"').replace(/\\26/g, "&").replace(/\\27/g, "'").replace(/\\2f/g, "/").replace(/\\3a/g, ":").replace(/\\3c/g, "<").replace(/\\3e/g, ">").replace(/\\40/g, "@").replace(/\\5c/g, "\\");
+ },
+
+ /** Function: getNodeFromJid
+ * Get the node portion of a JID String.
+ *
+ * Parameters:
+ * (String) jid - A JID.
+ *
+ * Returns:
+ * A String containing the node.
+ */
+ getNodeFromJid: function getNodeFromJid(jid) {
+ if (jid.indexOf("@") < 0) {
+ return null;
+ }
+
+ return jid.split("@")[0];
+ },
+
+ /** Function: getDomainFromJid
+ * Get the domain portion of a JID String.
+ *
+ * Parameters:
+ * (String) jid - A JID.
+ *
+ * Returns:
+ * A String containing the domain.
+ */
+ getDomainFromJid: function getDomainFromJid(jid) {
+ var bare = Strophe.getBareJidFromJid(jid);
+
+ if (bare.indexOf("@") < 0) {
+ return bare;
+ } else {
+ var parts = bare.split("@");
+ parts.splice(0, 1);
+ return parts.join('@');
+ }
+ },
+
+ /** Function: getResourceFromJid
+ * Get the resource portion of a JID String.
+ *
+ * Parameters:
+ * (String) jid - A JID.
+ *
+ * Returns:
+ * A String containing the resource.
+ */
+ getResourceFromJid: function getResourceFromJid(jid) {
+ var s = jid.split("/");
+
+ if (s.length < 2) {
+ return null;
+ }
+
+ s.splice(0, 1);
+ return s.join('/');
+ },
+
+ /** Function: getBareJidFromJid
+ * Get the bare JID from a JID String.
+ *
+ * Parameters:
+ * (String) jid - A JID.
+ *
+ * Returns:
+ * A String containing the bare JID.
+ */
+ getBareJidFromJid: function getBareJidFromJid(jid) {
+ return jid ? jid.split("/")[0] : null;
+ },
+
+ /** PrivateFunction: _handleError
+ * _Private_ function that properly logs an error to the console
+ */
+ _handleError: function _handleError(e) {
+ if (typeof e.stack !== "undefined") {
+ Strophe.fatal(e.stack);
+ }
+
+ if (e.sourceURL) {
+ Strophe.fatal("error: " + this.handler + " " + e.sourceURL + ":" + e.line + " - " + e.name + ": " + e.message);
+ } else if (e.fileName) {
+ Strophe.fatal("error: " + this.handler + " " + e.fileName + ":" + e.lineNumber + " - " + e.name + ": " + e.message);
+ } else {
+ Strophe.fatal("error: " + e.message);
+ }
+ },
+
+ /** Function: log
+ * User overrideable logging function.
+ *
+ * This function is called whenever the Strophe library calls any
+ * of the logging functions. The default implementation of this
+ * function logs only fatal errors. If client code wishes to handle the logging
+ * messages, it should override this with
+ * > Strophe.log = function (level, msg) {
+ * > (user code here)
+ * > };
+ *
+ * Please note that data sent and received over the wire is logged
+ * via Strophe.Connection.rawInput() and Strophe.Connection.rawOutput().
+ *
+ * The different levels and their meanings are
+ *
+ * DEBUG - Messages useful for debugging purposes.
+ * INFO - Informational messages. This is mostly information like
+ * 'disconnect was called' or 'SASL auth succeeded'.
+ * WARN - Warnings about potential problems. This is mostly used
+ * to report transient connection errors like request timeouts.
+ * ERROR - Some error occurred.
+ * FATAL - A non-recoverable fatal error occurred.
+ *
+ * Parameters:
+ * (Integer) level - The log level of the log message. This will
+ * be one of the values in Strophe.LogLevel.
+ * (String) msg - The log message.
+ */
+ log: function log(level, msg) {
+ if (level === this.LogLevel.FATAL && _typeof(window.console) === 'object' && typeof window.console.error === 'function') {
+ window.console.error(msg);
+ }
+ },
+
+ /** Function: debug
+ * Log a message at the Strophe.LogLevel.DEBUG level.
+ *
+ * Parameters:
+ * (String) msg - The log message.
+ */
+ debug: function debug(msg) {
+ this.log(this.LogLevel.DEBUG, msg);
+ },
+
+ /** Function: info
+ * Log a message at the Strophe.LogLevel.INFO level.
+ *
+ * Parameters:
+ * (String) msg - The log message.
+ */
+ info: function info(msg) {
+ this.log(this.LogLevel.INFO, msg);
+ },
+
+ /** Function: warn
+ * Log a message at the Strophe.LogLevel.WARN level.
+ *
+ * Parameters:
+ * (String) msg - The log message.
+ */
+ warn: function warn(msg) {
+ this.log(this.LogLevel.WARN, msg);
+ },
+
+ /** Function: error
+ * Log a message at the Strophe.LogLevel.ERROR level.
+ *
+ * Parameters:
+ * (String) msg - The log message.
+ */
+ error: function error(msg) {
+ this.log(this.LogLevel.ERROR, msg);
+ },
+
+ /** Function: fatal
+ * Log a message at the Strophe.LogLevel.FATAL level.
+ *
+ * Parameters:
+ * (String) msg - The log message.
+ */
+ fatal: function fatal(msg) {
+ this.log(this.LogLevel.FATAL, msg);
+ },
+
+ /** Function: serialize
+ * Render a DOM element and all descendants to a String.
+ *
+ * Parameters:
+ * (XMLElement) elem - A DOM element.
+ *
+ * Returns:
+ * The serialized element tree as a String.
+ */
+ serialize: function serialize(elem) {
+ if (!elem) {
+ return null;
+ }
+
+ if (typeof elem.tree === "function") {
+ elem = elem.tree();
+ }
+
+ var names = _toConsumableArray(Array(elem.attributes.length).keys()).map(function (i) {
+ return elem.attributes[i].nodeName;
+ });
+
+ names.sort();
+ var result = names.reduce(function (a, n) {
+ return "".concat(a, " ").concat(n, "=\"").concat(Strophe.xmlescape(elem.attributes.getNamedItem(n).value), "\"");
+ }, "<".concat(elem.nodeName));
+
+ if (elem.childNodes.length > 0) {
+ result += ">";
+
+ for (var i = 0; i < elem.childNodes.length; i++) {
+ var child = elem.childNodes[i];
+
+ switch (child.nodeType) {
+ case Strophe.ElementType.NORMAL:
+ // normal element, so recurse
+ result += Strophe.serialize(child);
+ break;
+
+ case Strophe.ElementType.TEXT:
+ // text element to escape values
+ result += Strophe.xmlescape(child.nodeValue);
+ break;
+
+ case Strophe.ElementType.CDATA:
+ // cdata section so don't escape values
+ result += "";
+ }
+ }
+
+ result += "" + elem.nodeName + ">";
+ } else {
+ result += "/>";
+ }
+
+ return result;
+ },
+
+ /** PrivateVariable: _requestId
+ * _Private_ variable that keeps track of the request ids for
+ * connections.
+ */
+ _requestId: 0,
+
+ /** PrivateVariable: Strophe.connectionPlugins
+ * _Private_ variable Used to store plugin names that need
+ * initialization on Strophe.Connection construction.
+ */
+ _connectionPlugins: {},
+
+ /** Function: addConnectionPlugin
+ * Extends the Strophe.Connection object with the given plugin.
+ *
+ * Parameters:
+ * (String) name - The name of the extension.
+ * (Object) ptype - The plugin's prototype.
+ */
+ addConnectionPlugin: function addConnectionPlugin(name, ptype) {
+ Strophe._connectionPlugins[name] = ptype;
+ }
+};
+/** Class: Strophe.Builder
+ * XML DOM builder.
+ *
+ * This object provides an interface similar to JQuery but for building
+ * DOM elements easily and rapidly. All the functions except for toString()
+ * and tree() return the object, so calls can be chained. Here's an
+ * example using the $iq() builder helper.
+ * > $iq({to: 'you', from: 'me', type: 'get', id: '1'})
+ * > .c('query', {xmlns: 'strophe:example'})
+ * > .c('example')
+ * > .toString()
+ *
+ * The above generates this XML fragment
+ * >
+ * >
+ * >
+ * >
+ * >
+ * The corresponding DOM manipulations to get a similar fragment would be
+ * a lot more tedious and probably involve several helper variables.
+ *
+ * Since adding children makes new operations operate on the child, up()
+ * is provided to traverse up the tree. To add two children, do
+ * > builder.c('child1', ...).up().c('child2', ...)
+ * The next operation on the Builder will be relative to the second child.
+ */
+
+/** Constructor: Strophe.Builder
+ * Create a Strophe.Builder object.
+ *
+ * The attributes should be passed in object notation. For example
+ * > let b = new Builder('message', {to: 'you', from: 'me'});
+ * or
+ * > let b = new Builder('messsage', {'xml:lang': 'en'});
+ *
+ * Parameters:
+ * (String) name - The name of the root element.
+ * (Object) attrs - The attributes for the root element in object notation.
+ *
+ * Returns:
+ * A new Strophe.Builder.
+ */
+
+Strophe.Builder = function (name, attrs) {
+ // Set correct namespace for jabber:client elements
+ if (name === "presence" || name === "message" || name === "iq") {
+ if (attrs && !attrs.xmlns) {
+ attrs.xmlns = Strophe.NS.CLIENT;
+ } else if (!attrs) {
+ attrs = {
+ xmlns: Strophe.NS.CLIENT
+ };
+ }
+ } // Holds the tree being built.
+
+
+ this.nodeTree = Strophe.xmlElement(name, attrs); // Points to the current operation node.
+
+ this.node = this.nodeTree;
+};
+
+Strophe.Builder.prototype = {
+ /** Function: tree
+ * Return the DOM tree.
+ *
+ * This function returns the current DOM tree as an element object. This
+ * is suitable for passing to functions like Strophe.Connection.send().
+ *
+ * Returns:
+ * The DOM tree as a element object.
+ */
+ tree: function tree() {
+ return this.nodeTree;
+ },
+
+ /** Function: toString
+ * Serialize the DOM tree to a String.
+ *
+ * This function returns a string serialization of the current DOM
+ * tree. It is often used internally to pass data to a
+ * Strophe.Request object.
+ *
+ * Returns:
+ * The serialized DOM tree in a String.
+ */
+ toString: function toString() {
+ return Strophe.serialize(this.nodeTree);
+ },
+
+ /** Function: up
+ * Make the current parent element the new current element.
+ *
+ * This function is often used after c() to traverse back up the tree.
+ * For example, to add two children to the same element
+ * > builder.c('child1', {}).up().c('child2', {});
+ *
+ * Returns:
+ * The Stophe.Builder object.
+ */
+ up: function up() {
+ this.node = this.node.parentNode;
+ return this;
+ },
+
+ /** Function: root
+ * Make the root element the new current element.
+ *
+ * When at a deeply nested element in the tree, this function can be used
+ * to jump back to the root of the tree, instead of having to repeatedly
+ * call up().
+ *
+ * Returns:
+ * The Stophe.Builder object.
+ */
+ root: function root() {
+ this.node = this.nodeTree;
+ return this;
+ },
+
+ /** Function: attrs
+ * Add or modify attributes of the current element.
+ *
+ * The attributes should be passed in object notation. This function
+ * does not move the current element pointer.
+ *
+ * Parameters:
+ * (Object) moreattrs - The attributes to add/modify in object notation.
+ *
+ * Returns:
+ * The Strophe.Builder object.
+ */
+ attrs: function attrs(moreattrs) {
+ for (var k in moreattrs) {
+ if (Object.prototype.hasOwnProperty.call(moreattrs, k)) {
+ if (moreattrs[k] === undefined) {
+ this.node.removeAttribute(k);
+ } else {
+ this.node.setAttribute(k, moreattrs[k]);
+ }
+ }
+ }
+
+ return this;
+ },
+
+ /** Function: c
+ * Add a child to the current element and make it the new current
+ * element.
+ *
+ * This function moves the current element pointer to the child,
+ * unless text is provided. If you need to add another child, it
+ * is necessary to use up() to go back to the parent in the tree.
+ *
+ * Parameters:
+ * (String) name - The name of the child.
+ * (Object) attrs - The attributes of the child in object notation.
+ * (String) text - The text to add to the child.
+ *
+ * Returns:
+ * The Strophe.Builder object.
+ */
+ c: function c(name, attrs, text) {
+ var child = Strophe.xmlElement(name, attrs, text);
+ this.node.appendChild(child);
+
+ if (typeof text !== "string" && typeof text !== "number") {
+ this.node = child;
+ }
+
+ return this;
+ },
+
+ /** Function: cnode
+ * Add a child to the current element and make it the new current
+ * element.
+ *
+ * This function is the same as c() except that instead of using a
+ * name and an attributes object to create the child it uses an
+ * existing DOM element object.
+ *
+ * Parameters:
+ * (XMLElement) elem - A DOM element.
+ *
+ * Returns:
+ * The Strophe.Builder object.
+ */
+ cnode: function cnode(elem) {
+ var impNode;
+ var xmlGen = Strophe.xmlGenerator();
+
+ try {
+ impNode = xmlGen.importNode !== undefined;
+ } catch (e) {
+ impNode = false;
+ }
+
+ var newElem = impNode ? xmlGen.importNode(elem, true) : Strophe.copyElement(elem);
+ this.node.appendChild(newElem);
+ this.node = newElem;
+ return this;
+ },
+
+ /** Function: t
+ * Add a child text element.
+ *
+ * This *does not* make the child the new current element since there
+ * are no children of text elements.
+ *
+ * Parameters:
+ * (String) text - The text data to append to the current element.
+ *
+ * Returns:
+ * The Strophe.Builder object.
+ */
+ t: function t(text) {
+ var child = Strophe.xmlTextNode(text);
+ this.node.appendChild(child);
+ return this;
+ },
+
+ /** Function: h
+ * Replace current element contents with the HTML passed in.
+ *
+ * This *does not* make the child the new current element
+ *
+ * Parameters:
+ * (String) html - The html to insert as contents of current element.
+ *
+ * Returns:
+ * The Strophe.Builder object.
+ */
+ h: function h(html) {
+ var fragment = document.createElement('body'); // force the browser to try and fix any invalid HTML tags
+
+ fragment.innerHTML = html; // copy cleaned html into an xml dom
+
+ var xhtml = Strophe.createHtml(fragment);
+
+ while (xhtml.childNodes.length > 0) {
+ this.node.appendChild(xhtml.childNodes[0]);
+ }
+
+ return this;
+ }
+};
+/** PrivateClass: Strophe.Handler
+ * _Private_ helper class for managing stanza handlers.
+ *
+ * A Strophe.Handler encapsulates a user provided callback function to be
+ * executed when matching stanzas are received by the connection.
+ * Handlers can be either one-off or persistant depending on their
+ * return value. Returning true will cause a Handler to remain active, and
+ * returning false will remove the Handler.
+ *
+ * Users will not use Strophe.Handler objects directly, but instead they
+ * will use Strophe.Connection.addHandler() and
+ * Strophe.Connection.deleteHandler().
+ */
+
+/** PrivateConstructor: Strophe.Handler
+ * Create and initialize a new Strophe.Handler.
+ *
+ * Parameters:
+ * (Function) handler - A function to be executed when the handler is run.
+ * (String) ns - The namespace to match.
+ * (String) name - The element name to match.
+ * (String) type - The element type to match.
+ * (String) id - The element id attribute to match.
+ * (String) from - The element from attribute to match.
+ * (Object) options - Handler options
+ *
+ * Returns:
+ * A new Strophe.Handler object.
+ */
+
+Strophe.Handler = function (handler, ns, name, type, id, from, options) {
+ this.handler = handler;
+ this.ns = ns;
+ this.name = name;
+ this.type = type;
+ this.id = id;
+ this.options = options || {
+ 'matchBareFromJid': false,
+ 'ignoreNamespaceFragment': false
+ }; // BBB: Maintain backward compatibility with old `matchBare` option
+
+ if (this.options.matchBare) {
+ Strophe.warn('The "matchBare" option is deprecated, use "matchBareFromJid" instead.');
+ this.options.matchBareFromJid = this.options.matchBare;
+ delete this.options.matchBare;
+ }
+
+ if (this.options.matchBareFromJid) {
+ this.from = from ? Strophe.getBareJidFromJid(from) : null;
+ } else {
+ this.from = from;
+ } // whether the handler is a user handler or a system handler
+
+
+ this.user = true;
+};
+
+Strophe.Handler.prototype = {
+ /** PrivateFunction: getNamespace
+ * Returns the XML namespace attribute on an element.
+ * If `ignoreNamespaceFragment` was passed in for this handler, then the
+ * URL fragment will be stripped.
+ *
+ * Parameters:
+ * (XMLElement) elem - The XML element with the namespace.
+ *
+ * Returns:
+ * The namespace, with optionally the fragment stripped.
+ */
+ getNamespace: function getNamespace(elem) {
+ var elNamespace = elem.getAttribute("xmlns");
+
+ if (elNamespace && this.options.ignoreNamespaceFragment) {
+ elNamespace = elNamespace.split('#')[0];
+ }
+
+ return elNamespace;
+ },
+
+ /** PrivateFunction: namespaceMatch
+ * Tests if a stanza matches the namespace set for this Strophe.Handler.
+ *
+ * Parameters:
+ * (XMLElement) elem - The XML element to test.
+ *
+ * Returns:
+ * true if the stanza matches and false otherwise.
+ */
+ namespaceMatch: function namespaceMatch(elem) {
+ var _this = this;
+
+ var nsMatch = false;
+
+ if (!this.ns) {
+ return true;
+ } else {
+ Strophe.forEachChild(elem, null, function (elem) {
+ if (_this.getNamespace(elem) === _this.ns) {
+ nsMatch = true;
+ }
+ });
+ return nsMatch || this.getNamespace(elem) === this.ns;
+ }
+ },
+
+ /** PrivateFunction: isMatch
+ * Tests if a stanza matches the Strophe.Handler.
+ *
+ * Parameters:
+ * (XMLElement) elem - The XML element to test.
+ *
+ * Returns:
+ * true if the stanza matches and false otherwise.
+ */
+ isMatch: function isMatch(elem) {
+ var from = elem.getAttribute('from');
+
+ if (this.options.matchBareFromJid) {
+ from = Strophe.getBareJidFromJid(from);
+ }
+
+ var elem_type = elem.getAttribute("type");
+
+ if (this.namespaceMatch(elem) && (!this.name || Strophe.isTagEqual(elem, this.name)) && (!this.type || (Array.isArray(this.type) ? this.type.indexOf(elem_type) !== -1 : elem_type === this.type)) && (!this.id || elem.getAttribute("id") === this.id) && (!this.from || from === this.from)) {
+ return true;
+ }
+
+ return false;
+ },
+
+ /** PrivateFunction: run
+ * Run the callback on a matching stanza.
+ *
+ * Parameters:
+ * (XMLElement) elem - The DOM element that triggered the
+ * Strophe.Handler.
+ *
+ * Returns:
+ * A boolean indicating if the handler should remain active.
+ */
+ run: function run(elem) {
+ var result = null;
+
+ try {
+ result = this.handler(elem);
+ } catch (e) {
+ Strophe._handleError(e);
+
+ throw e;
+ }
+
+ return result;
+ },
+
+ /** PrivateFunction: toString
+ * Get a String representation of the Strophe.Handler object.
+ *
+ * Returns:
+ * A String.
+ */
+ toString: function toString() {
+ return "{Handler: " + this.handler + "(" + this.name + "," + this.id + "," + this.ns + ")}";
+ }
+};
+/** PrivateClass: Strophe.TimedHandler
+ * _Private_ helper class for managing timed handlers.
+ *
+ * A Strophe.TimedHandler encapsulates a user provided callback that
+ * should be called after a certain period of time or at regular
+ * intervals. The return value of the callback determines whether the
+ * Strophe.TimedHandler will continue to fire.
+ *
+ * Users will not use Strophe.TimedHandler objects directly, but instead
+ * they will use Strophe.Connection.addTimedHandler() and
+ * Strophe.Connection.deleteTimedHandler().
+ */
+
+/** PrivateConstructor: Strophe.TimedHandler
+ * Create and initialize a new Strophe.TimedHandler object.
+ *
+ * Parameters:
+ * (Integer) period - The number of milliseconds to wait before the
+ * handler is called.
+ * (Function) handler - The callback to run when the handler fires. This
+ * function should take no arguments.
+ *
+ * Returns:
+ * A new Strophe.TimedHandler object.
+ */
+
+Strophe.TimedHandler = function (period, handler) {
+ this.period = period;
+ this.handler = handler;
+ this.lastCalled = new Date().getTime();
+ this.user = true;
+};
+
+Strophe.TimedHandler.prototype = {
+ /** PrivateFunction: run
+ * Run the callback for the Strophe.TimedHandler.
+ *
+ * Returns:
+ * true if the Strophe.TimedHandler should be called again, and false
+ * otherwise.
+ */
+ run: function run() {
+ this.lastCalled = new Date().getTime();
+ return this.handler();
+ },
+
+ /** PrivateFunction: reset
+ * Reset the last called time for the Strophe.TimedHandler.
+ */
+ reset: function reset() {
+ this.lastCalled = new Date().getTime();
+ },
+
+ /** PrivateFunction: toString
+ * Get a string representation of the Strophe.TimedHandler object.
+ *
+ * Returns:
+ * The string representation.
+ */
+ toString: function toString() {
+ return "{TimedHandler: " + this.handler + "(" + this.period + ")}";
+ }
+};
+/** Class: Strophe.Connection
+ * XMPP Connection manager.
+ *
+ * This class is the main part of Strophe. It manages a BOSH or websocket
+ * connection to an XMPP server and dispatches events to the user callbacks
+ * as data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, SASL SCRAM-SHA1
+ * and legacy authentication.
+ *
+ * After creating a Strophe.Connection object, the user will typically
+ * call connect() with a user supplied callback to handle connection level
+ * events like authentication failure, disconnection, or connection
+ * complete.
+ *
+ * The user will also have several event handlers defined by using
+ * addHandler() and addTimedHandler(). These will allow the user code to
+ * respond to interesting stanzas or do something periodically with the
+ * connection. These handlers will be active once authentication is
+ * finished.
+ *
+ * To send data to the connection, use send().
+ */
+
+/** Constructor: Strophe.Connection
+ * Create and initialize a Strophe.Connection object.
+ *
+ * The transport-protocol for this connection will be chosen automatically
+ * based on the given service parameter. URLs starting with "ws://" or
+ * "wss://" will use WebSockets, URLs starting with "http://", "https://"
+ * or without a protocol will use BOSH.
+ *
+ * To make Strophe connect to the current host you can leave out the protocol
+ * and host part and just pass the path, e.g.
+ *
+ * > let conn = new Strophe.Connection("/http-bind/");
+ *
+ * Options common to both Websocket and BOSH:
+ * ------------------------------------------
+ *
+ * cookies:
+ *
+ * The *cookies* option allows you to pass in cookies to be added to the
+ * document. These cookies will then be included in the BOSH XMLHttpRequest
+ * or in the websocket connection.
+ *
+ * The passed in value must be a map of cookie names and string values.
+ *
+ * > { "myCookie": {
+ * > "value": "1234",
+ * > "domain": ".example.org",
+ * > "path": "/",
+ * > "expires": expirationDate
+ * > }
+ * > }
+ *
+ * Note that cookies can't be set in this way for other domains (i.e. cross-domain).
+ * Those cookies need to be set under those domains, for example they can be
+ * set server-side by making a XHR call to that domain to ask it to set any
+ * necessary cookies.
+ *
+ * mechanisms:
+ *
+ * The *mechanisms* option allows you to specify the SASL mechanisms that this
+ * instance of Strophe.Connection (and therefore your XMPP client) will
+ * support.
+ *
+ * The value must be an array of objects with Strophe.SASLMechanism
+ * prototypes.
+ *
+ * If nothing is specified, then the following mechanisms (and their
+ * priorities) are registered:
+ *
+ * SCRAM-SHA1 - 70
+ * DIGEST-MD5 - 60
+ * PLAIN - 50
+ * OAUTH-BEARER - 40
+ * OAUTH-2 - 30
+ * ANONYMOUS - 20
+ * EXTERNAL - 10
+ *
+ * WebSocket options:
+ * ------------------
+ *
+ * If you want to connect to the current host with a WebSocket connection you
+ * can tell Strophe to use WebSockets through a "protocol" attribute in the
+ * optional options parameter. Valid values are "ws" for WebSocket and "wss"
+ * for Secure WebSocket.
+ * So to connect to "wss://CURRENT_HOSTNAME/xmpp-websocket" you would call
+ *
+ * > let conn = new Strophe.Connection("/xmpp-websocket/", {protocol: "wss"});
+ *
+ * Note that relative URLs _NOT_ starting with a "/" will also include the path
+ * of the current site.
+ *
+ * Also because downgrading security is not permitted by browsers, when using
+ * relative URLs both BOSH and WebSocket connections will use their secure
+ * variants if the current connection to the site is also secure (https).
+ *
+ * BOSH options:
+ * -------------
+ *
+ * By adding "sync" to the options, you can control if requests will
+ * be made synchronously or not. The default behaviour is asynchronous.
+ * If you want to make requests synchronous, make "sync" evaluate to true.
+ * > let conn = new Strophe.Connection("/http-bind/", {sync: true});
+ *
+ * You can also toggle this on an already established connection.
+ * > conn.options.sync = true;
+ *
+ * The *customHeaders* option can be used to provide custom HTTP headers to be
+ * included in the XMLHttpRequests made.
+ *
+ * The *keepalive* option can be used to instruct Strophe to maintain the
+ * current BOSH session across interruptions such as webpage reloads.
+ *
+ * It will do this by caching the sessions tokens in sessionStorage, and when
+ * "restore" is called it will check whether there are cached tokens with
+ * which it can resume an existing session.
+ *
+ * The *withCredentials* option should receive a Boolean value and is used to
+ * indicate wether cookies should be included in ajax requests (by default
+ * they're not).
+ * Set this value to true if you are connecting to a BOSH service
+ * and for some reason need to send cookies to it.
+ * In order for this to work cross-domain, the server must also enable
+ * credentials by setting the Access-Control-Allow-Credentials response header
+ * to "true". For most usecases however this setting should be false (which
+ * is the default).
+ * Additionally, when using Access-Control-Allow-Credentials, the
+ * Access-Control-Allow-Origin header can't be set to the wildcard "*", but
+ * instead must be restricted to actual domains.
+ *
+ * The *contentType* option can be set to change the default Content-Type
+ * of "text/xml; charset=utf-8", which can be useful to reduce the amount of
+ * CORS preflight requests that are sent to the server.
+ *
+ * Parameters:
+ * (String) service - The BOSH or WebSocket service URL.
+ * (Object) options - A hash of configuration options
+ *
+ * Returns:
+ * A new Strophe.Connection object.
+ */
+
+Strophe.Connection = function (service, options) {
+ var _this2 = this;
+
+ // The service URL
+ this.service = service; // Configuration options
+
+ this.options = options || {};
+ var proto = this.options.protocol || ""; // Select protocal based on service or options
+
+ if (service.indexOf("ws:") === 0 || service.indexOf("wss:") === 0 || proto.indexOf("ws") === 0) {
+ this._proto = new Strophe.Websocket(this);
+ } else {
+ this._proto = new Strophe.Bosh(this);
+ }
+ /* The connected JID. */
+
+
+ this.jid = "";
+ /* the JIDs domain */
+
+ this.domain = null;
+ /* stream:features */
+
+ this.features = null; // SASL
+
+ this._sasl_data = {};
+ this.do_session = false;
+ this.do_bind = false; // handler lists
+
+ this.timedHandlers = [];
+ this.handlers = [];
+ this.removeTimeds = [];
+ this.removeHandlers = [];
+ this.addTimeds = [];
+ this.addHandlers = [];
+ this.protocolErrorHandlers = {
+ 'HTTP': {},
+ 'websocket': {}
+ };
+ this._idleTimeout = null;
+ this._disconnectTimeout = null;
+ this.authenticated = false;
+ this.connected = false;
+ this.disconnecting = false;
+ this.do_authentication = true;
+ this.paused = false;
+ this.restored = false;
+ this._data = [];
+ this._uniqueId = 0;
+ this._sasl_success_handler = null;
+ this._sasl_failure_handler = null;
+ this._sasl_challenge_handler = null; // Max retries before disconnecting
+
+ this.maxRetries = 5; // Call onIdle callback every 1/10th of a second
+
+ this._idleTimeout = setTimeout(function () {
+ return _this2._onIdle();
+ }, 100);
+ utils__WEBPACK_IMPORTED_MODULE_2__["default"].addCookies(this.options.cookies);
+ this.registerSASLMechanisms(this.options.mechanisms); // initialize plugins
+
+ for (var k in Strophe._connectionPlugins) {
+ if (Object.prototype.hasOwnProperty.call(Strophe._connectionPlugins, k)) {
+ var F = function F() {};
+
+ F.prototype = Strophe._connectionPlugins[k];
+ this[k] = new F();
+ this[k].init(this);
+ }
+ }
+};
+
+Strophe.Connection.prototype = {
+ /** Function: reset
+ * Reset the connection.
+ *
+ * This function should be called after a connection is disconnected
+ * before that connection is reused.
+ */
+ reset: function reset() {
+ this._proto._reset(); // SASL
+
+
+ this.do_session = false;
+ this.do_bind = false; // handler lists
+
+ this.timedHandlers = [];
+ this.handlers = [];
+ this.removeTimeds = [];
+ this.removeHandlers = [];
+ this.addTimeds = [];
+ this.addHandlers = [];
+ this.authenticated = false;
+ this.connected = false;
+ this.disconnecting = false;
+ this.restored = false;
+ this._data = [];
+ this._requests = [];
+ this._uniqueId = 0;
+ },
+
+ /** Function: pause
+ * Pause the request manager.
+ *
+ * This will prevent Strophe from sending any more requests to the
+ * server. This is very useful for temporarily pausing
+ * BOSH-Connections while a lot of send() calls are happening quickly.
+ * This causes Strophe to send the data in a single request, saving
+ * many request trips.
+ */
+ pause: function pause() {
+ this.paused = true;
+ },
+
+ /** Function: resume
+ * Resume the request manager.
+ *
+ * This resumes after pause() has been called.
+ */
+ resume: function resume() {
+ this.paused = false;
+ },
+
+ /** Function: getUniqueId
+ * Generate a unique ID for use in elements.
+ *
+ * All stanzas are required to have unique id attributes. This
+ * function makes creating these easy. Each connection instance has
+ * a counter which starts from zero, and the value of this counter
+ * plus a colon followed by the suffix becomes the unique id. If no
+ * suffix is supplied, the counter is used as the unique id.
+ *
+ * Suffixes are used to make debugging easier when reading the stream
+ * data, and their use is recommended. The counter resets to 0 for
+ * every new connection for the same reason. For connections to the
+ * same server that authenticate the same way, all the ids should be
+ * the same, which makes it easy to see changes. This is useful for
+ * automated testing as well.
+ *
+ * Parameters:
+ * (String) suffix - A optional suffix to append to the id.
+ *
+ * Returns:
+ * A unique string to be used for the id attribute.
+ */
+ getUniqueId: function getUniqueId(suffix) {
+ var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
+ var r = Math.random() * 16 | 0,
+ v = c === 'x' ? r : r & 0x3 | 0x8;
+ return v.toString(16);
+ });
+
+ if (typeof suffix === "string" || typeof suffix === "number") {
+ return uuid + ":" + suffix;
+ } else {
+ return uuid + "";
+ }
+ },
+
+ /** Function: addProtocolErrorHandler
+ * Register a handler function for when a protocol (websocker or HTTP)
+ * error occurs.
+ *
+ * NOTE: Currently only HTTP errors for BOSH requests are handled.
+ * Patches that handle websocket errors would be very welcome.
+ *
+ * Parameters:
+ * (String) protocol - 'HTTP' or 'websocket'
+ * (Integer) status_code - Error status code (e.g 500, 400 or 404)
+ * (Function) callback - Function that will fire on Http error
+ *
+ * Example:
+ * function onError(err_code){
+ * //do stuff
+ * }
+ *
+ * let conn = Strophe.connect('http://example.com/http-bind');
+ * conn.addProtocolErrorHandler('HTTP', 500, onError);
+ * // Triggers HTTP 500 error and onError handler will be called
+ * conn.connect('user_jid@incorrect_jabber_host', 'secret', onConnect);
+ */
+ addProtocolErrorHandler: function addProtocolErrorHandler(protocol, status_code, callback) {
+ this.protocolErrorHandlers[protocol][status_code] = callback;
+ },
+
+ /** Function: connect
+ * Starts the connection process.
+ *
+ * As the connection process proceeds, the user supplied callback will
+ * be triggered multiple times with status updates. The callback
+ * should take two arguments - the status code and the error condition.
+ *
+ * The status code will be one of the values in the Strophe.Status
+ * constants. The error condition will be one of the conditions
+ * defined in RFC 3920 or the condition 'strophe-parsererror'.
+ *
+ * The Parameters _wait_, _hold_ and _route_ are optional and only relevant
+ * for BOSH connections. Please see XEP 124 for a more detailed explanation
+ * of the optional parameters.
+ *
+ * Parameters:
+ * (String) jid - The user's JID. This may be a bare JID,
+ * or a full JID. If a node is not supplied, SASL OAUTHBEARER or
+ * SASL ANONYMOUS authentication will be attempted (OAUTHBEARER will
+ * process the provided password value as an access token).
+ * (String) pass - The user's password.
+ * (Function) callback - The connect callback function.
+ * (Integer) wait - The optional HTTPBIND wait value. This is the
+ * time the server will wait before returning an empty result for
+ * a request. The default setting of 60 seconds is recommended.
+ * (Integer) hold - The optional HTTPBIND hold value. This is the
+ * number of connections the server will hold at one time. This
+ * should almost always be set to 1 (the default).
+ * (String) route - The optional route value.
+ * (String) authcid - The optional alternative authentication identity
+ * (username) if intending to impersonate another user.
+ * When using the SASL-EXTERNAL authentication mechanism, for example
+ * with client certificates, then the authcid value is used to
+ * determine whether an authorization JID (authzid) should be sent to
+ * the server. The authzid should not be sent to the server if the
+ * authzid and authcid are the same. So to prevent it from being sent
+ * (for example when the JID is already contained in the client
+ * certificate), set authcid to that same JID. See XEP-178 for more
+ * details.
+ */
+ connect: function connect(jid, pass, callback, wait, hold, route, authcid) {
+ this.jid = jid;
+ /** Variable: authzid
+ * Authorization identity.
+ */
+
+ this.authzid = Strophe.getBareJidFromJid(this.jid);
+ /** Variable: authcid
+ * Authentication identity (User name).
+ */
+
+ this.authcid = authcid || Strophe.getNodeFromJid(this.jid);
+ /** Variable: pass
+ * Authentication identity (User password).
+ */
+
+ this.pass = pass;
+ /** Variable: servtype
+ * Digest MD5 compatibility.
+ */
+
+ this.servtype = "xmpp";
+ this.connect_callback = callback;
+ this.disconnecting = false;
+ this.connected = false;
+ this.authenticated = false;
+ this.restored = false; // parse jid for domain
+
+ this.domain = Strophe.getDomainFromJid(this.jid);
+
+ this._changeConnectStatus(Strophe.Status.CONNECTING, null);
+
+ this._proto._connect(wait, hold, route);
+ },
+
+ /** Function: attach
+ * Attach to an already created and authenticated BOSH session.
+ *
+ * This function is provided to allow Strophe to attach to BOSH
+ * sessions which have been created externally, perhaps by a Web
+ * application. This is often used to support auto-login type features
+ * without putting user credentials into the page.
+ *
+ * Parameters:
+ * (String) jid - The full JID that is bound by the session.
+ * (String) sid - The SID of the BOSH session.
+ * (String) rid - The current RID of the BOSH session. This RID
+ * will be used by the next request.
+ * (Function) callback The connect callback function.
+ * (Integer) wait - The optional HTTPBIND wait value. This is the
+ * time the server will wait before returning an empty result for
+ * a request. The default setting of 60 seconds is recommended.
+ * Other settings will require tweaks to the Strophe.TIMEOUT value.
+ * (Integer) hold - The optional HTTPBIND hold value. This is the
+ * number of connections the server will hold at one time. This
+ * should almost always be set to 1 (the default).
+ * (Integer) wind - The optional HTTBIND window value. This is the
+ * allowed range of request ids that are valid. The default is 5.
+ */
+ attach: function attach(jid, sid, rid, callback, wait, hold, wind) {
+ if (this._proto instanceof Strophe.Bosh) {
+ this._proto._attach(jid, sid, rid, callback, wait, hold, wind);
+ } else {
+ var error = new Error('The "attach" method can only be used with a BOSH connection.');
+ error.name = 'StropheSessionError';
+ throw error;
+ }
+ },
+
+ /** Function: restore
+ * Attempt to restore a cached BOSH session.
+ *
+ * This function is only useful in conjunction with providing the
+ * "keepalive":true option when instantiating a new Strophe.Connection.
+ *
+ * When "keepalive" is set to true, Strophe will cache the BOSH tokens
+ * RID (Request ID) and SID (Session ID) and then when this function is
+ * called, it will attempt to restore the session from those cached
+ * tokens.
+ *
+ * This function must therefore be called instead of connect or attach.
+ *
+ * For an example on how to use it, please see examples/restore.js
+ *
+ * Parameters:
+ * (String) jid - The user's JID. This may be a bare JID or a full JID.
+ * (Function) callback - The connect callback function.
+ * (Integer) wait - The optional HTTPBIND wait value. This is the
+ * time the server will wait before returning an empty result for
+ * a request. The default setting of 60 seconds is recommended.
+ * (Integer) hold - The optional HTTPBIND hold value. This is the
+ * number of connections the server will hold at one time. This
+ * should almost always be set to 1 (the default).
+ * (Integer) wind - The optional HTTBIND window value. This is the
+ * allowed range of request ids that are valid. The default is 5.
+ */
+ restore: function restore(jid, callback, wait, hold, wind) {
+ if (this._sessionCachingSupported()) {
+ this._proto._restore(jid, callback, wait, hold, wind);
+ } else {
+ var error = new Error('The "restore" method can only be used with a BOSH connection.');
+ error.name = 'StropheSessionError';
+ throw error;
+ }
+ },
+
+ /** PrivateFunction: _sessionCachingSupported
+ * Checks whether sessionStorage and JSON are supported and whether we're
+ * using BOSH.
+ */
+ _sessionCachingSupported: function _sessionCachingSupported() {
+ if (this._proto instanceof Strophe.Bosh) {
+ if (!JSON) {
+ return false;
+ }
+
+ try {
+ sessionStorage.setItem('_strophe_', '_strophe_');
+ sessionStorage.removeItem('_strophe_');
+ } catch (e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /** Function: xmlInput
+ * User overrideable function that receives XML data coming into the
+ * connection.
+ *
+ * The default function does nothing. User code can override this with
+ * > Strophe.Connection.xmlInput = function (elem) {
+ * > (user code)
+ * > };
+ *
+ * Due to limitations of current Browsers' XML-Parsers the opening and closing
+ * tag for WebSocket-Connoctions will be passed as selfclosing here.
+ *
+ * BOSH-Connections will have all stanzas wrapped in a tag. See
+ * if you want to strip this tag.
+ *
+ * Parameters:
+ * (XMLElement) elem - The XML data received by the connection.
+ */
+
+ /* jshint unused:false */
+ xmlInput: function xmlInput(elem) {
+ return;
+ },
+
+ /* jshint unused:true */
+
+ /** Function: xmlOutput
+ * User overrideable function that receives XML data sent to the
+ * connection.
+ *
+ * The default function does nothing. User code can override this with
+ * > Strophe.Connection.xmlOutput = function (elem) {
+ * > (user code)
+ * > };
+ *
+ * Due to limitations of current Browsers' XML-Parsers the opening and closing
+ * tag for WebSocket-Connoctions will be passed as selfclosing here.
+ *
+ * BOSH-Connections will have all stanzas wrapped in a tag. See
+ * if you want to strip this tag.
+ *
+ * Parameters:
+ * (XMLElement) elem - The XMLdata sent by the connection.
+ */
+
+ /* jshint unused:false */
+ xmlOutput: function xmlOutput(elem) {
+ return;
+ },
+
+ /* jshint unused:true */
+
+ /** Function: rawInput
+ * User overrideable function that receives raw data coming into the
+ * connection.
+ *
+ * The default function does nothing. User code can override this with
+ * > Strophe.Connection.rawInput = function (data) {
+ * > (user code)
+ * > };
+ *
+ * Parameters:
+ * (String) data - The data received by the connection.
+ */
+
+ /* jshint unused:false */
+ rawInput: function rawInput(data) {
+ return;
+ },
+
+ /* jshint unused:true */
+
+ /** Function: rawOutput
+ * User overrideable function that receives raw data sent to the
+ * connection.
+ *
+ * The default function does nothing. User code can override this with
+ * > Strophe.Connection.rawOutput = function (data) {
+ * > (user code)
+ * > };
+ *
+ * Parameters:
+ * (String) data - The data sent by the connection.
+ */
+
+ /* jshint unused:false */
+ rawOutput: function rawOutput(data) {
+ return;
+ },
+
+ /* jshint unused:true */
+
+ /** Function: nextValidRid
+ * User overrideable function that receives the new valid rid.
+ *
+ * The default function does nothing. User code can override this with
+ * > Strophe.Connection.nextValidRid = function (rid) {
+ * > (user code)
+ * > };
+ *
+ * Parameters:
+ * (Number) rid - The next valid rid
+ */
+
+ /* jshint unused:false */
+ nextValidRid: function nextValidRid(rid) {
+ return;
+ },
+
+ /* jshint unused:true */
+
+ /** Function: send
+ * Send a stanza.
+ *
+ * This function is called to push data onto the send queue to
+ * go out over the wire. Whenever a request is sent to the BOSH
+ * server, all pending data is sent and the queue is flushed.
+ *
+ * Parameters:
+ * (XMLElement |
+ * [XMLElement] |
+ * Strophe.Builder) elem - The stanza to send.
+ */
+ send: function send(elem) {
+ if (elem === null) {
+ return;
+ }
+
+ if (typeof elem.sort === "function") {
+ for (var i = 0; i < elem.length; i++) {
+ this._queueData(elem[i]);
+ }
+ } else if (typeof elem.tree === "function") {
+ this._queueData(elem.tree());
+ } else {
+ this._queueData(elem);
+ }
+
+ this._proto._send();
+ },
+
+ /** Function: flush
+ * Immediately send any pending outgoing data.
+ *
+ * Normally send() queues outgoing data until the next idle period
+ * (100ms), which optimizes network use in the common cases when
+ * several send()s are called in succession. flush() can be used to
+ * immediately send all pending data.
+ */
+ flush: function flush() {
+ // cancel the pending idle period and run the idle function
+ // immediately
+ clearTimeout(this._idleTimeout);
+
+ this._onIdle();
+ },
+
+ /** Function: sendPresence
+ * Helper function to send presence stanzas. The main benefit is for
+ * sending presence stanzas for which you expect a responding presence
+ * stanza with the same id (for example when leaving a chat room).
+ *
+ * Parameters:
+ * (XMLElement) elem - The stanza to send.
+ * (Function) callback - The callback function for a successful request.
+ * (Function) errback - The callback function for a failed or timed
+ * out request. On timeout, the stanza will be null.
+ * (Integer) timeout - The time specified in milliseconds for a
+ * timeout to occur.
+ *
+ * Returns:
+ * The id used to send the presence.
+ */
+ sendPresence: function sendPresence(elem, callback, errback, timeout) {
+ var _this3 = this;
+
+ var timeoutHandler = null;
+
+ if (typeof elem.tree === "function") {
+ elem = elem.tree();
+ }
+
+ var id = elem.getAttribute('id');
+
+ if (!id) {
+ // inject id if not found
+ id = this.getUniqueId("sendPresence");
+ elem.setAttribute("id", id);
+ }
+
+ if (typeof callback === "function" || typeof errback === "function") {
+ var handler = this.addHandler(function (stanza) {
+ // remove timeout handler if there is one
+ if (timeoutHandler) {
+ _this3.deleteTimedHandler(timeoutHandler);
+ }
+
+ if (stanza.getAttribute('type') === 'error') {
+ if (errback) {
+ errback(stanza);
+ }
+ } else if (callback) {
+ callback(stanza);
+ }
+ }, null, 'presence', null, id); // if timeout specified, set up a timeout handler.
+
+ if (timeout) {
+ timeoutHandler = this.addTimedHandler(timeout, function () {
+ // get rid of normal handler
+ _this3.deleteHandler(handler); // call errback on timeout with null stanza
+
+
+ if (errback) {
+ errback(null);
+ }
+
+ return false;
+ });
+ }
+ }
+
+ this.send(elem);
+ return id;
+ },
+
+ /** Function: sendIQ
+ * Helper function to send IQ stanzas.
+ *
+ * Parameters:
+ * (XMLElement) elem - The stanza to send.
+ * (Function) callback - The callback function for a successful request.
+ * (Function) errback - The callback function for a failed or timed
+ * out request. On timeout, the stanza will be null.
+ * (Integer) timeout - The time specified in milliseconds for a
+ * timeout to occur.
+ *
+ * Returns:
+ * The id used to send the IQ.
+ */
+ sendIQ: function sendIQ(elem, callback, errback, timeout) {
+ var _this4 = this;
+
+ var timeoutHandler = null;
+
+ if (typeof elem.tree === "function") {
+ elem = elem.tree();
+ }
+
+ var id = elem.getAttribute('id');
+
+ if (!id) {
+ // inject id if not found
+ id = this.getUniqueId("sendIQ");
+ elem.setAttribute("id", id);
+ }
+
+ if (typeof callback === "function" || typeof errback === "function") {
+ var handler = this.addHandler(function (stanza) {
+ // remove timeout handler if there is one
+ if (timeoutHandler) {
+ _this4.deleteTimedHandler(timeoutHandler);
+ }
+
+ var iqtype = stanza.getAttribute('type');
+
+ if (iqtype === 'result') {
+ if (callback) {
+ callback(stanza);
+ }
+ } else if (iqtype === 'error') {
+ if (errback) {
+ errback(stanza);
+ }
+ } else {
+ var error = new Error("Got bad IQ type of ".concat(iqtype));
+ error.name = "StropheError";
+ throw error;
+ }
+ }, null, 'iq', ['error', 'result'], id); // if timeout specified, set up a timeout handler.
+
+ if (timeout) {
+ timeoutHandler = this.addTimedHandler(timeout, function () {
+ // get rid of normal handler
+ _this4.deleteHandler(handler); // call errback on timeout with null stanza
+
+
+ if (errback) {
+ errback(null);
+ }
+
+ return false;
+ });
+ }
+ }
+
+ this.send(elem);
+ return id;
+ },
+
+ /** PrivateFunction: _queueData
+ * Queue outgoing data for later sending. Also ensures that the data
+ * is a DOMElement.
+ */
+ _queueData: function _queueData(element) {
+ if (element === null || !element.tagName || !element.childNodes) {
+ var error = new Error("Cannot queue non-DOMElement.");
+ error.name = "StropheError";
+ throw error;
+ }
+
+ this._data.push(element);
+ },
+
+ /** PrivateFunction: _sendRestart
+ * Send an xmpp:restart stanza.
+ */
+ _sendRestart: function _sendRestart() {
+ var _this5 = this;
+
+ this._data.push("restart");
+
+ this._proto._sendRestart();
+
+ this._idleTimeout = setTimeout(function () {
+ return _this5._onIdle();
+ }, 100);
+ },
+
+ /** Function: addTimedHandler
+ * Add a timed handler to the connection.
+ *
+ * This function adds a timed handler. The provided handler will
+ * be called every period milliseconds until it returns false,
+ * the connection is terminated, or the handler is removed. Handlers
+ * that wish to continue being invoked should return true.
+ *
+ * Because of method binding it is necessary to save the result of
+ * this function if you wish to remove a handler with
+ * deleteTimedHandler().
+ *
+ * Note that user handlers are not active until authentication is
+ * successful.
+ *
+ * Parameters:
+ * (Integer) period - The period of the handler.
+ * (Function) handler - The callback function.
+ *
+ * Returns:
+ * A reference to the handler that can be used to remove it.
+ */
+ addTimedHandler: function addTimedHandler(period, handler) {
+ var thand = new Strophe.TimedHandler(period, handler);
+ this.addTimeds.push(thand);
+ return thand;
+ },
+
+ /** Function: deleteTimedHandler
+ * Delete a timed handler for a connection.
+ *
+ * This function removes a timed handler from the connection. The
+ * handRef parameter is *not* the function passed to addTimedHandler(),
+ * but is the reference returned from addTimedHandler().
+ *
+ * Parameters:
+ * (Strophe.TimedHandler) handRef - The handler reference.
+ */
+ deleteTimedHandler: function deleteTimedHandler(handRef) {
+ // this must be done in the Idle loop so that we don't change
+ // the handlers during iteration
+ this.removeTimeds.push(handRef);
+ },
+
+ /** Function: addHandler
+ * Add a stanza handler for the connection.
+ *
+ * This function adds a stanza handler to the connection. The
+ * handler callback will be called for any stanza that matches
+ * the parameters. Note that if multiple parameters are supplied,
+ * they must all match for the handler to be invoked.
+ *
+ * The handler will receive the stanza that triggered it as its argument.
+ * *The handler should return true if it is to be invoked again;
+ * returning false will remove the handler after it returns.*
+ *
+ * As a convenience, the ns parameters applies to the top level element
+ * and also any of its immediate children. This is primarily to make
+ * matching /iq/query elements easy.
+ *
+ * Options
+ * ~~~~~~~
+ * With the options argument, you can specify boolean flags that affect how
+ * matches are being done.
+ *
+ * Currently two flags exist:
+ *
+ * - matchBareFromJid:
+ * When set to true, the from parameter and the
+ * from attribute on the stanza will be matched as bare JIDs instead
+ * of full JIDs. To use this, pass {matchBareFromJid: true} as the
+ * value of options. The default value for matchBareFromJid is false.
+ *
+ * - ignoreNamespaceFragment:
+ * When set to true, a fragment specified on the stanza's namespace
+ * URL will be ignored when it's matched with the one configured for
+ * the handler.
+ *
+ * This means that if you register like this:
+ * > connection.addHandler(
+ * > handler,
+ * > 'http://jabber.org/protocol/muc',
+ * > null, null, null, null,
+ * > {'ignoreNamespaceFragment': true}
+ * > );
+ *
+ * Then a stanza with XML namespace of
+ * 'http://jabber.org/protocol/muc#user' will also be matched. If
+ * 'ignoreNamespaceFragment' is false, then only stanzas with
+ * 'http://jabber.org/protocol/muc' will be matched.
+ *
+ * Deleting the handler
+ * ~~~~~~~~~~~~~~~~~~~~
+ * The return value should be saved if you wish to remove the handler
+ * with deleteHandler().
+ *
+ * Parameters:
+ * (Function) handler - The user callback.
+ * (String) ns - The namespace to match.
+ * (String) name - The stanza name to match.
+ * (String|Array) type - The stanza type (or types if an array) to match.
+ * (String) id - The stanza id attribute to match.
+ * (String) from - The stanza from attribute to match.
+ * (String) options - The handler options
+ *
+ * Returns:
+ * A reference to the handler that can be used to remove it.
+ */
+ addHandler: function addHandler(handler, ns, name, type, id, from, options) {
+ var hand = new Strophe.Handler(handler, ns, name, type, id, from, options);
+ this.addHandlers.push(hand);
+ return hand;
+ },
+
+ /** Function: deleteHandler
+ * Delete a stanza handler for a connection.
+ *
+ * This function removes a stanza handler from the connection. The
+ * handRef parameter is *not* the function passed to addHandler(),
+ * but is the reference returned from addHandler().
+ *
+ * Parameters:
+ * (Strophe.Handler) handRef - The handler reference.
+ */
+ deleteHandler: function deleteHandler(handRef) {
+ // this must be done in the Idle loop so that we don't change
+ // the handlers during iteration
+ this.removeHandlers.push(handRef); // If a handler is being deleted while it is being added,
+ // prevent it from getting added
+
+ var i = this.addHandlers.indexOf(handRef);
+
+ if (i >= 0) {
+ this.addHandlers.splice(i, 1);
+ }
+ },
+
+ /** Function: registerSASLMechanisms
+ *
+ * Register the SASL mechanisms which will be supported by this instance of
+ * Strophe.Connection (i.e. which this XMPP client will support).
+ *
+ * Parameters:
+ * (Array) mechanisms - Array of objects with Strophe.SASLMechanism prototypes
+ *
+ */
+ registerSASLMechanisms: function registerSASLMechanisms(mechanisms) {
+ this.mechanisms = {};
+ mechanisms = mechanisms || [Strophe.SASLAnonymous, Strophe.SASLExternal, Strophe.SASLMD5, Strophe.SASLOAuthBearer, Strophe.SASLXOAuth2, Strophe.SASLPlain, Strophe.SASLSHA1];
+ mechanisms.forEach(this.registerSASLMechanism.bind(this));
+ },
+
+ /** Function: registerSASLMechanism
+ *
+ * Register a single SASL mechanism, to be supported by this client.
+ *
+ * Parameters:
+ * (Object) mechanism - Object with a Strophe.SASLMechanism prototype
+ *
+ */
+ registerSASLMechanism: function registerSASLMechanism(mechanism) {
+ this.mechanisms[mechanism.prototype.name] = mechanism;
+ },
+
+ /** Function: disconnect
+ * Start the graceful disconnection process.
+ *
+ * This function starts the disconnection process. This process starts
+ * by sending unavailable presence and sending BOSH body of type
+ * terminate. A timeout handler makes sure that disconnection happens
+ * even if the BOSH server does not respond.
+ * If the Connection object isn't connected, at least tries to abort all pending requests
+ * so the connection object won't generate successful requests (which were already opened).
+ *
+ * The user supplied connection callback will be notified of the
+ * progress as this process happens.
+ *
+ * Parameters:
+ * (String) reason - The reason the disconnect is occuring.
+ */
+ disconnect: function disconnect(reason) {
+ this._changeConnectStatus(Strophe.Status.DISCONNECTING, reason);
+
+ Strophe.info("Disconnect was called because: " + reason);
+
+ if (this.connected) {
+ var pres = false;
+ this.disconnecting = true;
+
+ if (this.authenticated) {
+ pres = $pres({
+ 'xmlns': Strophe.NS.CLIENT,
+ 'type': 'unavailable'
+ });
+ } // setup timeout handler
+
+
+ this._disconnectTimeout = this._addSysTimedHandler(3000, this._onDisconnectTimeout.bind(this));
+
+ this._proto._disconnect(pres);
+ } else {
+ Strophe.info("Disconnect was called before Strophe connected to the server");
+
+ this._proto._abortAllRequests();
+
+ this._doDisconnect();
+ }
+ },
+
+ /** PrivateFunction: _changeConnectStatus
+ * _Private_ helper function that makes sure plugins and the user's
+ * callback are notified of connection status changes.
+ *
+ * Parameters:
+ * (Integer) status - the new connection status, one of the values
+ * in Strophe.Status
+ * (String) condition - the error condition or null
+ * (XMLElement) elem - The triggering stanza.
+ */
+ _changeConnectStatus: function _changeConnectStatus(status, condition, elem) {
+ // notify all plugins listening for status changes
+ for (var k in Strophe._connectionPlugins) {
+ if (Object.prototype.hasOwnProperty.call(Strophe._connectionPlugins, k)) {
+ var plugin = this[k];
+
+ if (plugin.statusChanged) {
+ try {
+ plugin.statusChanged(status, condition);
+ } catch (err) {
+ Strophe.error("".concat(k, " plugin caused an exception changing status: ").concat(err));
+ }
+ }
+ }
+ } // notify the user's callback
+
+
+ if (this.connect_callback) {
+ try {
+ this.connect_callback(status, condition, elem);
+ } catch (e) {
+ Strophe._handleError(e);
+
+ Strophe.error("User connection callback caused an exception: ".concat(e));
+ }
+ }
+ },
+
+ /** PrivateFunction: _doDisconnect
+ * _Private_ function to disconnect.
+ *
+ * This is the last piece of the disconnection logic. This resets the
+ * connection and alerts the user's connection callback.
+ */
+ _doDisconnect: function _doDisconnect(condition) {
+ if (typeof this._idleTimeout === "number") {
+ clearTimeout(this._idleTimeout);
+ } // Cancel Disconnect Timeout
+
+
+ if (this._disconnectTimeout !== null) {
+ this.deleteTimedHandler(this._disconnectTimeout);
+ this._disconnectTimeout = null;
+ }
+
+ Strophe.info("_doDisconnect was called");
+
+ this._proto._doDisconnect();
+
+ this.authenticated = false;
+ this.disconnecting = false;
+ this.restored = false; // delete handlers
+
+ this.handlers = [];
+ this.timedHandlers = [];
+ this.removeTimeds = [];
+ this.removeHandlers = [];
+ this.addTimeds = [];
+ this.addHandlers = []; // tell the parent we disconnected
+
+ this._changeConnectStatus(Strophe.Status.DISCONNECTED, condition);
+
+ this.connected = false;
+ },
+
+ /** PrivateFunction: _dataRecv
+ * _Private_ handler to processes incoming data from the the connection.
+ *
+ * Except for _connect_cb handling the initial connection request,
+ * this function handles the incoming data for all requests. This
+ * function also fires stanza handlers that match each incoming
+ * stanza.
+ *
+ * Parameters:
+ * (Strophe.Request) req - The request that has data ready.
+ * (string) req - The stanza a raw string (optiona).
+ */
+ _dataRecv: function _dataRecv(req, raw) {
+ var _this6 = this;
+
+ Strophe.info("_dataRecv called");
+
+ var elem = this._proto._reqToData(req);
+
+ if (elem === null) {
+ return;
+ }
+
+ if (this.xmlInput !== Strophe.Connection.prototype.xmlInput) {
+ if (elem.nodeName === this._proto.strip && elem.childNodes.length) {
+ this.xmlInput(elem.childNodes[0]);
+ } else {
+ this.xmlInput(elem);
+ }
+ }
+
+ if (this.rawInput !== Strophe.Connection.prototype.rawInput) {
+ if (raw) {
+ this.rawInput(raw);
+ } else {
+ this.rawInput(Strophe.serialize(elem));
+ }
+ } // remove handlers scheduled for deletion
+
+
+ while (this.removeHandlers.length > 0) {
+ var hand = this.removeHandlers.pop();
+ var i = this.handlers.indexOf(hand);
+
+ if (i >= 0) {
+ this.handlers.splice(i, 1);
+ }
+ } // add handlers scheduled for addition
+
+
+ while (this.addHandlers.length > 0) {
+ this.handlers.push(this.addHandlers.pop());
+ } // handle graceful disconnect
+
+
+ if (this.disconnecting && this._proto._emptyQueue()) {
+ this._doDisconnect();
+
+ return;
+ }
+
+ var type = elem.getAttribute("type");
+
+ if (type !== null && type === "terminate") {
+ // Don't process stanzas that come in after disconnect
+ if (this.disconnecting) {
+ return;
+ } // an error occurred
+
+
+ var cond = elem.getAttribute("condition");
+ var conflict = elem.getElementsByTagName("conflict");
+
+ if (cond !== null) {
+ if (cond === "remote-stream-error" && conflict.length > 0) {
+ cond = "conflict";
+ }
+
+ this._changeConnectStatus(Strophe.Status.CONNFAIL, cond);
+ } else {
+ this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.UNKOWN_REASON);
+ }
+
+ this._doDisconnect(cond);
+
+ return;
+ } // send each incoming stanza through the handler chain
+
+
+ Strophe.forEachChild(elem, null, function (child) {
+ // process handlers
+ var newList = _this6.handlers;
+ _this6.handlers = [];
+
+ for (var _i5 = 0; _i5 < newList.length; _i5++) {
+ var _hand = newList[_i5]; // encapsulate 'handler.run' not to lose the whole handler list if
+ // one of the handlers throws an exception
+
+ try {
+ if (_hand.isMatch(child) && (_this6.authenticated || !_hand.user)) {
+ if (_hand.run(child)) {
+ _this6.handlers.push(_hand);
+ }
+ } else {
+ _this6.handlers.push(_hand);
+ }
+ } catch (e) {
+ // if the handler throws an exception, we consider it as false
+ Strophe.warn('Removing Strophe handlers due to uncaught exception: ' + e.message);
+ }
+ }
+ });
+ },
+
+ /** Attribute: mechanisms
+ * SASL Mechanisms available for Connection.
+ */
+ mechanisms: {},
+
+ /** PrivateFunction: _connect_cb
+ * _Private_ handler for initial connection request.
+ *
+ * This handler is used to process the initial connection request
+ * response from the BOSH server. It is used to set up authentication
+ * handlers and start the authentication process.
+ *
+ * SASL authentication will be attempted if available, otherwise
+ * the code will fall back to legacy authentication.
+ *
+ * Parameters:
+ * (Strophe.Request) req - The current request.
+ * (Function) _callback - low level (xmpp) connect callback function.
+ * Useful for plugins with their own xmpp connect callback (when they
+ * want to do something special).
+ */
+ _connect_cb: function _connect_cb(req, _callback, raw) {
+ Strophe.info("_connect_cb was called");
+ this.connected = true;
+ var bodyWrap;
+
+ try {
+ bodyWrap = this._proto._reqToData(req);
+ } catch (e) {
+ if (e.name !== Strophe.ErrorCondition.BAD_FORMAT) {
+ throw e;
+ }
+
+ this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.BAD_FORMAT);
+
+ this._doDisconnect(Strophe.ErrorCondition.BAD_FORMAT);
+ }
+
+ if (!bodyWrap) {
+ return;
+ }
+
+ if (this.xmlInput !== Strophe.Connection.prototype.xmlInput) {
+ if (bodyWrap.nodeName === this._proto.strip && bodyWrap.childNodes.length) {
+ this.xmlInput(bodyWrap.childNodes[0]);
+ } else {
+ this.xmlInput(bodyWrap);
+ }
+ }
+
+ if (this.rawInput !== Strophe.Connection.prototype.rawInput) {
+ if (raw) {
+ this.rawInput(raw);
+ } else {
+ this.rawInput(Strophe.serialize(bodyWrap));
+ }
+ }
+
+ var conncheck = this._proto._connect_cb(bodyWrap);
+
+ if (conncheck === Strophe.Status.CONNFAIL) {
+ return;
+ } // Check for the stream:features tag
+
+
+ var hasFeatures;
+
+ if (bodyWrap.getElementsByTagNameNS) {
+ hasFeatures = bodyWrap.getElementsByTagNameNS(Strophe.NS.STREAM, "features").length > 0;
+ } else {
+ hasFeatures = bodyWrap.getElementsByTagName("stream:features").length > 0 || bodyWrap.getElementsByTagName("features").length > 0;
+ }
+
+ if (!hasFeatures) {
+ this._proto._no_auth_received(_callback);
+
+ return;
+ }
+
+ var matched = [];
+ var mechanisms = bodyWrap.getElementsByTagName("mechanism");
+
+ if (mechanisms.length > 0) {
+ for (var i = 0; i < mechanisms.length; i++) {
+ var mech = Strophe.getText(mechanisms[i]);
+ if (this.mechanisms[mech]) matched.push(this.mechanisms[mech]);
+ }
+ }
+
+ if (matched.length === 0) {
+ if (bodyWrap.getElementsByTagName("auth").length === 0) {
+ // There are no matching SASL mechanisms and also no legacy
+ // auth available.
+ this._proto._no_auth_received(_callback);
+
+ return;
+ }
+ }
+
+ if (this.do_authentication !== false) {
+ this.authenticate(matched);
+ }
+ },
+
+ /** Function: sortMechanismsByPriority
+ *
+ * Sorts an array of objects with prototype SASLMechanism according to
+ * their priorities.
+ *
+ * Parameters:
+ * (Array) mechanisms - Array of SASL mechanisms.
+ *
+ */
+ sortMechanismsByPriority: function sortMechanismsByPriority(mechanisms) {
+ // Sorting mechanisms according to priority.
+ for (var i = 0; i < mechanisms.length - 1; ++i) {
+ var higher = i;
+
+ for (var j = i + 1; j < mechanisms.length; ++j) {
+ if (mechanisms[j].prototype.priority > mechanisms[higher].prototype.priority) {
+ higher = j;
+ }
+ }
+
+ if (higher !== i) {
+ var swap = mechanisms[i];
+ mechanisms[i] = mechanisms[higher];
+ mechanisms[higher] = swap;
+ }
+ }
+
+ return mechanisms;
+ },
+
+ /** PrivateFunction: _attemptSASLAuth
+ *
+ * Iterate through an array of SASL mechanisms and attempt authentication
+ * with the highest priority (enabled) mechanism.
+ *
+ * Parameters:
+ * (Array) mechanisms - Array of SASL mechanisms.
+ *
+ * Returns:
+ * (Boolean) mechanism_found - true or false, depending on whether a
+ * valid SASL mechanism was found with which authentication could be
+ * started.
+ */
+ _attemptSASLAuth: function _attemptSASLAuth(mechanisms) {
+ mechanisms = this.sortMechanismsByPriority(mechanisms || []);
+ var mechanism_found = false;
+
+ for (var i = 0; i < mechanisms.length; ++i) {
+ if (!mechanisms[i].prototype.test(this)) {
+ continue;
+ }
+
+ this._sasl_success_handler = this._addSysHandler(this._sasl_success_cb.bind(this), null, "success", null, null);
+ this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
+ this._sasl_challenge_handler = this._addSysHandler(this._sasl_challenge_cb.bind(this), null, "challenge", null, null);
+ this._sasl_mechanism = new mechanisms[i]();
+
+ this._sasl_mechanism.onStart(this);
+
+ var request_auth_exchange = $build("auth", {
+ 'xmlns': Strophe.NS.SASL,
+ 'mechanism': this._sasl_mechanism.name
+ });
+
+ if (this._sasl_mechanism.isClientFirst) {
+ var response = this._sasl_mechanism.onChallenge(this, null);
+
+ request_auth_exchange.t(btoa(response));
+ }
+
+ this.send(request_auth_exchange.tree());
+ mechanism_found = true;
+ break;
+ }
+
+ return mechanism_found;
+ },
+
+ /** PrivateFunction: _attemptLegacyAuth
+ *
+ * Attempt legacy (i.e. non-SASL) authentication.
+ *
+ */
+ _attemptLegacyAuth: function _attemptLegacyAuth() {
+ if (Strophe.getNodeFromJid(this.jid) === null) {
+ // we don't have a node, which is required for non-anonymous
+ // client connections
+ this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.MISSING_JID_NODE);
+
+ this.disconnect(Strophe.ErrorCondition.MISSING_JID_NODE);
+ } else {
+ // Fall back to legacy authentication
+ this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null);
+
+ this._addSysHandler(this._auth1_cb.bind(this), null, null, null, "_auth_1");
+
+ this.send($iq({
+ 'type': "get",
+ 'to': this.domain,
+ 'id': "_auth_1"
+ }).c("query", {
+ xmlns: Strophe.NS.AUTH
+ }).c("username", {}).t(Strophe.getNodeFromJid(this.jid)).tree());
+ }
+ },
+
+ /** Function: authenticate
+ * Set up authentication
+ *
+ * Continues the initial connection request by setting up authentication
+ * handlers and starting the authentication process.
+ *
+ * SASL authentication will be attempted if available, otherwise
+ * the code will fall back to legacy authentication.
+ *
+ * Parameters:
+ * (Array) matched - Array of SASL mechanisms supported.
+ *
+ */
+ authenticate: function authenticate(matched) {
+ if (!this._attemptSASLAuth(matched)) {
+ this._attemptLegacyAuth();
+ }
+ },
+
+ /** PrivateFunction: _sasl_challenge_cb
+ * _Private_ handler for the SASL challenge
+ *
+ */
+ _sasl_challenge_cb: function _sasl_challenge_cb(elem) {
+ var challenge = atob(Strophe.getText(elem));
+
+ var response = this._sasl_mechanism.onChallenge(this, challenge);
+
+ var stanza = $build('response', {
+ 'xmlns': Strophe.NS.SASL
+ });
+
+ if (response !== "") {
+ stanza.t(btoa(response));
+ }
+
+ this.send(stanza.tree());
+ return true;
+ },
+
+ /** PrivateFunction: _auth1_cb
+ * _Private_ handler for legacy authentication.
+ *
+ * This handler is called in response to the initial
+ * for legacy authentication. It builds an authentication and
+ * sends it, creating a handler (calling back to _auth2_cb()) to
+ * handle the result
+ *
+ * Parameters:
+ * (XMLElement) elem - The stanza that triggered the callback.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+
+ /* jshint unused:false */
+ _auth1_cb: function _auth1_cb(elem) {
+ // build plaintext auth iq
+ var iq = $iq({
+ type: "set",
+ id: "_auth_2"
+ }).c('query', {
+ xmlns: Strophe.NS.AUTH
+ }).c('username', {}).t(Strophe.getNodeFromJid(this.jid)).up().c('password').t(this.pass);
+
+ if (!Strophe.getResourceFromJid(this.jid)) {
+ // since the user has not supplied a resource, we pick
+ // a default one here. unlike other auth methods, the server
+ // cannot do this for us.
+ this.jid = Strophe.getBareJidFromJid(this.jid) + '/strophe';
+ }
+
+ iq.up().c('resource', {}).t(Strophe.getResourceFromJid(this.jid));
+
+ this._addSysHandler(this._auth2_cb.bind(this), null, null, null, "_auth_2");
+
+ this.send(iq.tree());
+ return false;
+ },
+
+ /* jshint unused:true */
+
+ /** PrivateFunction: _sasl_success_cb
+ * _Private_ handler for succesful SASL authentication.
+ *
+ * Parameters:
+ * (XMLElement) elem - The matching stanza.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+ _sasl_success_cb: function _sasl_success_cb(elem) {
+ var _this7 = this;
+
+ if (this._sasl_data["server-signature"]) {
+ var serverSignature;
+ var success = atob(Strophe.getText(elem));
+ var attribMatch = /([a-z]+)=([^,]+)(,|$)/;
+ var matches = success.match(attribMatch);
+
+ if (matches[1] === "v") {
+ serverSignature = matches[2];
+ }
+
+ if (serverSignature !== this._sasl_data["server-signature"]) {
+ // remove old handlers
+ this.deleteHandler(this._sasl_failure_handler);
+ this._sasl_failure_handler = null;
+
+ if (this._sasl_challenge_handler) {
+ this.deleteHandler(this._sasl_challenge_handler);
+ this._sasl_challenge_handler = null;
+ }
+
+ this._sasl_data = {};
+ return this._sasl_failure_cb(null);
+ }
+ }
+
+ Strophe.info("SASL authentication succeeded.");
+
+ if (this._sasl_mechanism) {
+ this._sasl_mechanism.onSuccess();
+ } // remove old handlers
+
+
+ this.deleteHandler(this._sasl_failure_handler);
+ this._sasl_failure_handler = null;
+
+ if (this._sasl_challenge_handler) {
+ this.deleteHandler(this._sasl_challenge_handler);
+ this._sasl_challenge_handler = null;
+ }
+
+ var streamfeature_handlers = [];
+
+ var wrapper = function wrapper(handlers, elem) {
+ while (handlers.length) {
+ _this7.deleteHandler(handlers.pop());
+ }
+
+ _this7._sasl_auth1_cb(elem);
+
+ return false;
+ };
+
+ streamfeature_handlers.push(this._addSysHandler(function (elem) {
+ return wrapper(streamfeature_handlers, elem);
+ }, null, "stream:features", null, null));
+ streamfeature_handlers.push(this._addSysHandler(function (elem) {
+ return wrapper(streamfeature_handlers, elem);
+ }, Strophe.NS.STREAM, "features", null, null)); // we must send an xmpp:restart now
+
+ this._sendRestart();
+
+ return false;
+ },
+
+ /** PrivateFunction: _sasl_auth1_cb
+ * _Private_ handler to start stream binding.
+ *
+ * Parameters:
+ * (XMLElement) elem - The matching stanza.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+ _sasl_auth1_cb: function _sasl_auth1_cb(elem) {
+ // save stream:features for future usage
+ this.features = elem;
+
+ for (var i = 0; i < elem.childNodes.length; i++) {
+ var child = elem.childNodes[i];
+
+ if (child.nodeName === 'bind') {
+ this.do_bind = true;
+ }
+
+ if (child.nodeName === 'session') {
+ this.do_session = true;
+ }
+ }
+
+ if (!this.do_bind) {
+ this._changeConnectStatus(Strophe.Status.AUTHFAIL, null);
+
+ return false;
+ } else {
+ this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, null, "_bind_auth_2");
+
+ var resource = Strophe.getResourceFromJid(this.jid);
+
+ if (resource) {
+ this.send($iq({
+ type: "set",
+ id: "_bind_auth_2"
+ }).c('bind', {
+ xmlns: Strophe.NS.BIND
+ }).c('resource', {}).t(resource).tree());
+ } else {
+ this.send($iq({
+ type: "set",
+ id: "_bind_auth_2"
+ }).c('bind', {
+ xmlns: Strophe.NS.BIND
+ }).tree());
+ }
+ }
+
+ return false;
+ },
+
+ /** PrivateFunction: _sasl_bind_cb
+ * _Private_ handler for binding result and session start.
+ *
+ * Parameters:
+ * (XMLElement) elem - The matching stanza.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+ _sasl_bind_cb: function _sasl_bind_cb(elem) {
+ if (elem.getAttribute("type") === "error") {
+ Strophe.info("SASL binding failed.");
+ var conflict = elem.getElementsByTagName("conflict");
+ var condition;
+
+ if (conflict.length > 0) {
+ condition = Strophe.ErrorCondition.CONFLICT;
+ }
+
+ this._changeConnectStatus(Strophe.Status.AUTHFAIL, condition, elem);
+
+ return false;
+ } // TODO - need to grab errors
+
+
+ var bind = elem.getElementsByTagName("bind");
+
+ if (bind.length > 0) {
+ var jidNode = bind[0].getElementsByTagName("jid");
+
+ if (jidNode.length > 0) {
+ this.jid = Strophe.getText(jidNode[0]);
+
+ if (this.do_session) {
+ this._addSysHandler(this._sasl_session_cb.bind(this), null, null, null, "_session_auth_2");
+
+ this.send($iq({
+ type: "set",
+ id: "_session_auth_2"
+ }).c('session', {
+ xmlns: Strophe.NS.SESSION
+ }).tree());
+ } else {
+ this.authenticated = true;
+
+ this._changeConnectStatus(Strophe.Status.CONNECTED, null);
+ }
+ }
+ } else {
+ Strophe.info("SASL binding failed.");
+
+ this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
+
+ return false;
+ }
+ },
+
+ /** PrivateFunction: _sasl_session_cb
+ * _Private_ handler to finish successful SASL connection.
+ *
+ * This sets Connection.authenticated to true on success, which
+ * starts the processing of user handlers.
+ *
+ * Parameters:
+ * (XMLElement) elem - The matching stanza.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+ _sasl_session_cb: function _sasl_session_cb(elem) {
+ if (elem.getAttribute("type") === "result") {
+ this.authenticated = true;
+
+ this._changeConnectStatus(Strophe.Status.CONNECTED, null);
+ } else if (elem.getAttribute("type") === "error") {
+ Strophe.info("Session creation failed.");
+
+ this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
+
+ return false;
+ }
+
+ return false;
+ },
+
+ /** PrivateFunction: _sasl_failure_cb
+ * _Private_ handler for SASL authentication failure.
+ *
+ * Parameters:
+ * (XMLElement) elem - The matching stanza.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+
+ /* jshint unused:false */
+ _sasl_failure_cb: function _sasl_failure_cb(elem) {
+ // delete unneeded handlers
+ if (this._sasl_success_handler) {
+ this.deleteHandler(this._sasl_success_handler);
+ this._sasl_success_handler = null;
+ }
+
+ if (this._sasl_challenge_handler) {
+ this.deleteHandler(this._sasl_challenge_handler);
+ this._sasl_challenge_handler = null;
+ }
+
+ if (this._sasl_mechanism) this._sasl_mechanism.onFailure();
+
+ this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
+
+ return false;
+ },
+
+ /* jshint unused:true */
+
+ /** PrivateFunction: _auth2_cb
+ * _Private_ handler to finish legacy authentication.
+ *
+ * This handler is called when the result from the jabber:iq:auth
+ * stanza is returned.
+ *
+ * Parameters:
+ * (XMLElement) elem - The stanza that triggered the callback.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+ _auth2_cb: function _auth2_cb(elem) {
+ if (elem.getAttribute("type") === "result") {
+ this.authenticated = true;
+
+ this._changeConnectStatus(Strophe.Status.CONNECTED, null);
+ } else if (elem.getAttribute("type") === "error") {
+ this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
+
+ this.disconnect('authentication failed');
+ }
+
+ return false;
+ },
+
+ /** PrivateFunction: _addSysTimedHandler
+ * _Private_ function to add a system level timed handler.
+ *
+ * This function is used to add a Strophe.TimedHandler for the
+ * library code. System timed handlers are allowed to run before
+ * authentication is complete.
+ *
+ * Parameters:
+ * (Integer) period - The period of the handler.
+ * (Function) handler - The callback function.
+ */
+ _addSysTimedHandler: function _addSysTimedHandler(period, handler) {
+ var thand = new Strophe.TimedHandler(period, handler);
+ thand.user = false;
+ this.addTimeds.push(thand);
+ return thand;
+ },
+
+ /** PrivateFunction: _addSysHandler
+ * _Private_ function to add a system level stanza handler.
+ *
+ * This function is used to add a Strophe.Handler for the
+ * library code. System stanza handlers are allowed to run before
+ * authentication is complete.
+ *
+ * Parameters:
+ * (Function) handler - The callback function.
+ * (String) ns - The namespace to match.
+ * (String) name - The stanza name to match.
+ * (String) type - The stanza type attribute to match.
+ * (String) id - The stanza id attribute to match.
+ */
+ _addSysHandler: function _addSysHandler(handler, ns, name, type, id) {
+ var hand = new Strophe.Handler(handler, ns, name, type, id);
+ hand.user = false;
+ this.addHandlers.push(hand);
+ return hand;
+ },
+
+ /** PrivateFunction: _onDisconnectTimeout
+ * _Private_ timeout handler for handling non-graceful disconnection.
+ *
+ * If the graceful disconnect process does not complete within the
+ * time allotted, this handler finishes the disconnect anyway.
+ *
+ * Returns:
+ * false to remove the handler.
+ */
+ _onDisconnectTimeout: function _onDisconnectTimeout() {
+ Strophe.info("_onDisconnectTimeout was called");
+
+ this._changeConnectStatus(Strophe.Status.CONNTIMEOUT, null);
+
+ this._proto._onDisconnectTimeout(); // actually disconnect
+
+
+ this._doDisconnect();
+
+ return false;
+ },
+
+ /** PrivateFunction: _onIdle
+ * _Private_ handler to process events during idle cycle.
+ *
+ * This handler is called every 100ms to fire timed handlers that
+ * are ready and keep poll requests going.
+ */
+ _onIdle: function _onIdle() {
+ var _this8 = this;
+
+ // add timed handlers scheduled for addition
+ // NOTE: we add before remove in the case a timed handler is
+ // added and then deleted before the next _onIdle() call.
+ while (this.addTimeds.length > 0) {
+ this.timedHandlers.push(this.addTimeds.pop());
+ } // remove timed handlers that have been scheduled for deletion
+
+
+ while (this.removeTimeds.length > 0) {
+ var thand = this.removeTimeds.pop();
+ var i = this.timedHandlers.indexOf(thand);
+
+ if (i >= 0) {
+ this.timedHandlers.splice(i, 1);
+ }
+ } // call ready timed handlers
+
+
+ var now = new Date().getTime();
+ var newList = [];
+
+ for (var _i6 = 0; _i6 < this.timedHandlers.length; _i6++) {
+ var _thand = this.timedHandlers[_i6];
+
+ if (this.authenticated || !_thand.user) {
+ var since = _thand.lastCalled + _thand.period;
+
+ if (since - now <= 0) {
+ if (_thand.run()) {
+ newList.push(_thand);
+ }
+ } else {
+ newList.push(_thand);
+ }
+ }
+ }
+
+ this.timedHandlers = newList;
+ clearTimeout(this._idleTimeout);
+
+ this._proto._onIdle(); // reactivate the timer only if connected
+
+
+ if (this.connected) {
+ this._idleTimeout = setTimeout(function () {
+ return _this8._onIdle();
+ }, 100);
+ }
+ }
+};
+/** Class: Strophe.SASLMechanism
+ *
+ * encapsulates SASL authentication mechanisms.
+ *
+ * User code may override the priority for each mechanism or disable it completely.
+ * See for information about changing priority and for informatian on
+ * how to disable a mechanism.
+ *
+ * By default, all mechanisms are enabled and the priorities are
+ *
+ * OAUTHBEARER - 60
+ * SCRAM-SHA1 - 50
+ * DIGEST-MD5 - 40
+ * PLAIN - 30
+ * ANONYMOUS - 20
+ * EXTERNAL - 10
+ *
+ * See: Strophe.Connection.addSupportedSASLMechanisms
+ */
+
+/**
+ * PrivateConstructor: Strophe.SASLMechanism
+ * SASL auth mechanism abstraction.
+ *
+ * Parameters:
+ * (String) name - SASL Mechanism name.
+ * (Boolean) isClientFirst - If client should send response first without challenge.
+ * (Number) priority - Priority.
+ *
+ * Returns:
+ * A new Strophe.SASLMechanism object.
+ */
+
+Strophe.SASLMechanism = function (name, isClientFirst, priority) {
+ /** PrivateVariable: name
+ * Mechanism name.
+ */
+ this.name = name;
+ /** PrivateVariable: isClientFirst
+ * If client sends response without initial server challenge.
+ */
+
+ this.isClientFirst = isClientFirst;
+ /** Variable: priority
+ * Determines which is chosen for authentication (Higher is better).
+ * Users may override this to prioritize mechanisms differently.
+ *
+ * In the default configuration the priorities are
+ *
+ * SCRAM-SHA1 - 40
+ * DIGEST-MD5 - 30
+ * Plain - 20
+ *
+ * Example: (This will cause Strophe to choose the mechanism that the server sent first)
+ *
+ * > Strophe.SASLMD5.priority = Strophe.SASLSHA1.priority;
+ *
+ * See for a list of available mechanisms.
+ *
+ */
+
+ this.priority = priority;
+};
+
+Strophe.SASLMechanism.prototype = {
+ /**
+ * Function: test
+ * Checks if mechanism able to run.
+ * To disable a mechanism, make this return false;
+ *
+ * To disable plain authentication run
+ * > Strophe.SASLPlain.test = function() {
+ * > return false;
+ * > }
+ *
+ * See for a list of available mechanisms.
+ *
+ * Parameters:
+ * (Strophe.Connection) connection - Target Connection.
+ *
+ * Returns:
+ * (Boolean) If mechanism was able to run.
+ */
+
+ /* jshint unused:false */
+ test: function test(connection) {
+ return true;
+ },
+
+ /* jshint unused:true */
+
+ /** PrivateFunction: onStart
+ * Called before starting mechanism on some connection.
+ *
+ * Parameters:
+ * (Strophe.Connection) connection - Target Connection.
+ */
+ onStart: function onStart(connection) {
+ this._connection = connection;
+ },
+
+ /** PrivateFunction: onChallenge
+ * Called by protocol implementation on incoming challenge. If client is
+ * first (isClientFirst === true) challenge will be null on the first call.
+ *
+ * Parameters:
+ * (Strophe.Connection) connection - Target Connection.
+ * (String) challenge - current challenge to handle.
+ *
+ * Returns:
+ * (String) Mechanism response.
+ */
+
+ /* jshint unused:false */
+ onChallenge: function onChallenge(connection, challenge) {
+ throw new Error("You should implement challenge handling!");
+ },
+
+ /* jshint unused:true */
+
+ /** PrivateFunction: onFailure
+ * Protocol informs mechanism implementation about SASL failure.
+ */
+ onFailure: function onFailure() {
+ this._connection = null;
+ },
+
+ /** PrivateFunction: onSuccess
+ * Protocol informs mechanism implementation about SASL success.
+ */
+ onSuccess: function onSuccess() {
+ this._connection = null;
+ }
+};
+/** Constants: SASL mechanisms
+ * Available authentication mechanisms
+ *
+ * Strophe.SASLAnonymous - SASL ANONYMOUS authentication.
+ * Strophe.SASLPlain - SASL PLAIN authentication.
+ * Strophe.SASLMD5 - SASL DIGEST-MD5 authentication
+ * Strophe.SASLSHA1 - SASL SCRAM-SHA1 authentication
+ * Strophe.SASLOAuthBearer - SASL OAuth Bearer authentication
+ * Strophe.SASLExternal - SASL EXTERNAL authentication
+ * Strophe.SASLXOAuth2 - SASL X-OAuth2 authentication
+ */
+// Building SASL callbacks
+
+/** PrivateConstructor: SASLAnonymous
+ * SASL ANONYMOUS authentication.
+ */
+
+Strophe.SASLAnonymous = function () {};
+
+Strophe.SASLAnonymous.prototype = new Strophe.SASLMechanism("ANONYMOUS", false, 20);
+
+Strophe.SASLAnonymous.prototype.test = function (connection) {
+ return connection.authcid === null;
+};
+/** PrivateConstructor: SASLPlain
+ * SASL PLAIN authentication.
+ */
+
+
+Strophe.SASLPlain = function () {};
+
+Strophe.SASLPlain.prototype = new Strophe.SASLMechanism("PLAIN", true, 50);
+
+Strophe.SASLPlain.prototype.test = function (connection) {
+ return connection.authcid !== null;
+};
+
+Strophe.SASLPlain.prototype.onChallenge = function (connection) {
+ var auth_str = connection.authzid;
+ auth_str = auth_str + "\0";
+ auth_str = auth_str + connection.authcid;
+ auth_str = auth_str + "\0";
+ auth_str = auth_str + connection.pass;
+ return utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(auth_str);
+};
+/** PrivateConstructor: SASLSHA1
+ * SASL SCRAM SHA 1 authentication.
+ */
+
+
+Strophe.SASLSHA1 = function () {};
+
+Strophe.SASLSHA1.prototype = new Strophe.SASLMechanism("SCRAM-SHA-1", true, 70);
+
+Strophe.SASLSHA1.prototype.test = function (connection) {
+ return connection.authcid !== null;
+};
+
+Strophe.SASLSHA1.prototype.onChallenge = function (connection, challenge, test_cnonce) {
+ var cnonce = test_cnonce || md5__WEBPACK_IMPORTED_MODULE_0__["default"].hexdigest(Math.random() * 1234567890);
+ var auth_str = "n=" + utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(connection.authcid);
+ auth_str += ",r=";
+ auth_str += cnonce;
+ connection._sasl_data.cnonce = cnonce;
+ connection._sasl_data["client-first-message-bare"] = auth_str;
+ auth_str = "n,," + auth_str;
+
+ this.onChallenge = function (connection, challenge) {
+ var nonce, salt, iter, Hi, U, U_old, i, k;
+ var responseText = "c=biws,";
+ var authMessage = "".concat(connection._sasl_data["client-first-message-bare"], ",").concat(challenge, ",");
+ var cnonce = connection._sasl_data.cnonce;
+ var attribMatch = /([a-z]+)=([^,]+)(,|$)/;
+
+ while (challenge.match(attribMatch)) {
+ var matches = challenge.match(attribMatch);
+ challenge = challenge.replace(matches[0], "");
+
+ switch (matches[1]) {
+ case "r":
+ nonce = matches[2];
+ break;
+
+ case "s":
+ salt = matches[2];
+ break;
+
+ case "i":
+ iter = matches[2];
+ break;
+ }
+ }
+
+ if (nonce.substr(0, cnonce.length) !== cnonce) {
+ connection._sasl_data = {};
+ return connection._sasl_failure_cb();
+ }
+
+ responseText += "r=" + nonce;
+ authMessage += responseText;
+ salt = atob(salt);
+ salt += "\x00\x00\x00\x01";
+ var pass = utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(connection.pass);
+ Hi = U_old = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].core_hmac_sha1(pass, salt);
+
+ for (i = 1; i < iter; i++) {
+ U = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].core_hmac_sha1(pass, sha1__WEBPACK_IMPORTED_MODULE_1__["default"].binb2str(U_old));
+
+ for (k = 0; k < 5; k++) {
+ Hi[k] ^= U[k];
+ }
+
+ U_old = U;
+ }
+
+ Hi = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].binb2str(Hi);
+ var clientKey = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].core_hmac_sha1(Hi, "Client Key");
+ var serverKey = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].str_hmac_sha1(Hi, "Server Key");
+ var clientSignature = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].core_hmac_sha1(sha1__WEBPACK_IMPORTED_MODULE_1__["default"].str_sha1(sha1__WEBPACK_IMPORTED_MODULE_1__["default"].binb2str(clientKey)), authMessage);
+ connection._sasl_data["server-signature"] = sha1__WEBPACK_IMPORTED_MODULE_1__["default"].b64_hmac_sha1(serverKey, authMessage);
+
+ for (k = 0; k < 5; k++) {
+ clientKey[k] ^= clientSignature[k];
+ }
+
+ responseText += ",p=" + btoa(sha1__WEBPACK_IMPORTED_MODULE_1__["default"].binb2str(clientKey));
+ return responseText;
+ };
+
+ return auth_str;
+};
+/** PrivateConstructor: SASLMD5
+ * SASL DIGEST MD5 authentication.
+ */
+
+
+Strophe.SASLMD5 = function () {};
+
+Strophe.SASLMD5.prototype = new Strophe.SASLMechanism("DIGEST-MD5", false, 60);
+
+Strophe.SASLMD5.prototype.test = function (connection) {
+ return connection.authcid !== null;
+};
+/** PrivateFunction: _quote
+ * _Private_ utility function to backslash escape and quote strings.
+ *
+ * Parameters:
+ * (String) str - The string to be quoted.
+ *
+ * Returns:
+ * quoted string
+ */
+
+
+Strophe.SASLMD5.prototype._quote = function (str) {
+ return '"' + str.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"'; //" end string workaround for emacs
+};
+
+Strophe.SASLMD5.prototype.onChallenge = function (connection, challenge, test_cnonce) {
+ var attribMatch = /([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/;
+ var cnonce = test_cnonce || md5__WEBPACK_IMPORTED_MODULE_0__["default"].hexdigest("" + Math.random() * 1234567890);
+ var realm = "";
+ var host = null;
+ var nonce = "";
+ var qop = "";
+
+ while (challenge.match(attribMatch)) {
+ var matches = challenge.match(attribMatch);
+ challenge = challenge.replace(matches[0], "");
+ matches[2] = matches[2].replace(/^"(.+)"$/, "$1");
+
+ switch (matches[1]) {
+ case "realm":
+ realm = matches[2];
+ break;
+
+ case "nonce":
+ nonce = matches[2];
+ break;
+
+ case "qop":
+ qop = matches[2];
+ break;
+
+ case "host":
+ host = matches[2];
+ break;
+ }
+ }
+
+ var digest_uri = connection.servtype + "/" + connection.domain;
+
+ if (host !== null) {
+ digest_uri = digest_uri + "/" + host;
+ }
+
+ var cred = utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(connection.authcid + ":" + realm + ":" + this._connection.pass);
+ var A1 = md5__WEBPACK_IMPORTED_MODULE_0__["default"].hash(cred) + ":" + nonce + ":" + cnonce;
+ var A2 = 'AUTHENTICATE:' + digest_uri;
+ var responseText = "";
+ responseText += 'charset=utf-8,';
+ responseText += 'username=' + this._quote(utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(connection.authcid)) + ',';
+ responseText += 'realm=' + this._quote(realm) + ',';
+ responseText += 'nonce=' + this._quote(nonce) + ',';
+ responseText += 'nc=00000001,';
+ responseText += 'cnonce=' + this._quote(cnonce) + ',';
+ responseText += 'digest-uri=' + this._quote(digest_uri) + ',';
+ responseText += 'response=' + md5__WEBPACK_IMPORTED_MODULE_0__["default"].hexdigest(md5__WEBPACK_IMPORTED_MODULE_0__["default"].hexdigest(A1) + ":" + nonce + ":00000001:" + cnonce + ":auth:" + md5__WEBPACK_IMPORTED_MODULE_0__["default"].hexdigest(A2)) + ",";
+ responseText += 'qop=auth';
+
+ this.onChallenge = function () {
+ return "";
+ };
+
+ return responseText;
+};
+/** PrivateConstructor: SASLOAuthBearer
+ * SASL OAuth Bearer authentication.
+ */
+
+
+Strophe.SASLOAuthBearer = function () {};
+
+Strophe.SASLOAuthBearer.prototype = new Strophe.SASLMechanism("OAUTHBEARER", true, 40);
+
+Strophe.SASLOAuthBearer.prototype.test = function (connection) {
+ return connection.pass !== null;
+};
+
+Strophe.SASLOAuthBearer.prototype.onChallenge = function (connection) {
+ var auth_str = 'n,';
+
+ if (connection.authcid !== null) {
+ auth_str = auth_str + 'a=' + connection.authzid;
+ }
+
+ auth_str = auth_str + ',';
+ auth_str = auth_str + "\x01";
+ auth_str = auth_str + 'auth=Bearer ';
+ auth_str = auth_str + connection.pass;
+ auth_str = auth_str + "\x01";
+ auth_str = auth_str + "\x01";
+ return utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(auth_str);
+};
+/** PrivateConstructor: SASLExternal
+ * SASL EXTERNAL authentication.
+ *
+ * The EXTERNAL mechanism allows a client to request the server to use
+ * credentials established by means external to the mechanism to
+ * authenticate the client. The external means may be, for instance,
+ * TLS services.
+ */
+
+
+Strophe.SASLExternal = function () {};
+
+Strophe.SASLExternal.prototype = new Strophe.SASLMechanism("EXTERNAL", true, 10);
+
+Strophe.SASLExternal.prototype.onChallenge = function (connection) {
+ /** According to XEP-178, an authzid SHOULD NOT be presented when the
+ * authcid contained or implied in the client certificate is the JID (i.e.
+ * authzid) with which the user wants to log in as.
+ *
+ * To NOT send the authzid, the user should therefore set the authcid equal
+ * to the JID when instantiating a new Strophe.Connection object.
+ */
+ return connection.authcid === connection.authzid ? '' : connection.authzid;
+};
+/** PrivateConstructor: SASLXOAuth2
+ * SASL X-OAuth2 authentication.
+ */
+
+
+Strophe.SASLXOAuth2 = function () {};
+
+Strophe.SASLXOAuth2.prototype = new Strophe.SASLMechanism("X-OAUTH2", true, 30);
+
+Strophe.SASLXOAuth2.prototype.test = function (connection) {
+ return connection.pass !== null;
+};
+
+Strophe.SASLXOAuth2.prototype.onChallenge = function (connection) {
+ var auth_str = "\0";
+
+ if (connection.authcid !== null) {
+ auth_str = auth_str + connection.authzid;
+ }
+
+ auth_str = auth_str + "\0";
+ auth_str = auth_str + connection.pass;
+ return utils__WEBPACK_IMPORTED_MODULE_2__["default"].utf16to8(auth_str);
+};
+
+/* harmony default export */ __webpack_exports__["default"] = ({
+ 'Strophe': Strophe,
+ '$build': $build,
+ '$iq': $iq,
+ '$msg': $msg,
+ '$pres': $pres,
+ 'SHA1': sha1__WEBPACK_IMPORTED_MODULE_1__["default"],
+ 'MD5': md5__WEBPACK_IMPORTED_MODULE_0__["default"],
+ 'b64_hmac_sha1': sha1__WEBPACK_IMPORTED_MODULE_1__["default"].b64_hmac_sha1,
+ 'b64_sha1': sha1__WEBPACK_IMPORTED_MODULE_1__["default"].b64_sha1,
+ 'str_hmac_sha1': sha1__WEBPACK_IMPORTED_MODULE_1__["default"].str_hmac_sha1,
+ 'str_sha1': sha1__WEBPACK_IMPORTED_MODULE_1__["default"].str_sha1
+});
+
+/***/ }),
+
+/***/ "./src/md5.js":
+/*!********************!*\
+ !*** ./src/md5.js ***!
+ \********************/
+/*! exports provided: default */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MD5; });
+/*
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for more info.
+ */
+
+/*
+ * Everything that isn't used by Strophe has been stripped here!
+ */
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+var safe_add = function safe_add(x, y) {
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return msw << 16 | lsw & 0xFFFF;
+};
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+
+
+var bit_rol = function bit_rol(num, cnt) {
+ return num << cnt | num >>> 32 - cnt;
+};
+/*
+ * Convert a string to an array of little-endian words
+ */
+
+
+var str2binl = function str2binl(str) {
+ var bin = [];
+
+ for (var i = 0; i < str.length * 8; i += 8) {
+ bin[i >> 5] |= (str.charCodeAt(i / 8) & 255) << i % 32;
+ }
+
+ return bin;
+};
+/*
+ * Convert an array of little-endian words to a string
+ */
+
+
+var binl2str = function binl2str(bin) {
+ var str = "";
+
+ for (var i = 0; i < bin.length * 32; i += 8) {
+ str += String.fromCharCode(bin[i >> 5] >>> i % 32 & 255);
+ }
+
+ return str;
+};
+/*
+ * Convert an array of little-endian words to a hex string.
+ */
+
+
+var binl2hex = function binl2hex(binarray) {
+ var hex_tab = "0123456789abcdef";
+ var str = "";
+
+ for (var i = 0; i < binarray.length * 4; i++) {
+ str += hex_tab.charAt(binarray[i >> 2] >> i % 4 * 8 + 4 & 0xF) + hex_tab.charAt(binarray[i >> 2] >> i % 4 * 8 & 0xF);
+ }
+
+ return str;
+};
+/*
+ * These functions implement the four basic operations the algorithm uses.
+ */
+
+
+var md5_cmn = function md5_cmn(q, a, b, x, s, t) {
+ return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
+};
+
+var md5_ff = function md5_ff(a, b, c, d, x, s, t) {
+ return md5_cmn(b & c | ~b & d, a, b, x, s, t);
+};
+
+var md5_gg = function md5_gg(a, b, c, d, x, s, t) {
+ return md5_cmn(b & d | c & ~d, a, b, x, s, t);
+};
+
+var md5_hh = function md5_hh(a, b, c, d, x, s, t) {
+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
+};
+
+var md5_ii = function md5_ii(a, b, c, d, x, s, t) {
+ return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
+};
+/*
+ * Calculate the MD5 of an array of little-endian words, and a bit length
+ */
+
+
+var core_md5 = function core_md5(x, len) {
+ /* append padding */
+ x[len >> 5] |= 0x80 << len % 32;
+ x[(len + 64 >>> 9 << 4) + 14] = len;
+ var a = 1732584193;
+ var b = -271733879;
+ var c = -1732584194;
+ var d = 271733878;
+ var olda, oldb, oldc, oldd;
+
+ for (var i = 0; i < x.length; i += 16) {
+ olda = a;
+ oldb = b;
+ oldc = c;
+ oldd = d;
+ a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
+ d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
+ c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
+ b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
+ a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
+ d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
+ c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
+ b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
+ a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
+ d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
+ c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
+ b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
+ a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
+ d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
+ c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
+ b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
+ a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
+ d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
+ c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
+ b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
+ a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
+ d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
+ c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
+ b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
+ a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
+ d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
+ c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
+ b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
+ a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
+ d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
+ c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
+ b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
+ a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
+ d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
+ c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
+ b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
+ a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
+ d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
+ c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
+ b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
+ a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
+ d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
+ c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
+ b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
+ a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
+ d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
+ c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
+ b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
+ a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
+ d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
+ c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
+ b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
+ a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
+ d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
+ c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
+ b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
+ a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
+ d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
+ c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
+ b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
+ a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
+ d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
+ c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
+ b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
+ a = safe_add(a, olda);
+ b = safe_add(b, oldb);
+ c = safe_add(c, oldc);
+ d = safe_add(d, oldd);
+ }
+
+ return [a, b, c, d];
+};
+/*
+ * These are the functions you'll usually want to call.
+ * They take string arguments and return either hex or base-64 encoded
+ * strings.
+ */
+
+
+var MD5 = {
+ hexdigest: function hexdigest(s) {
+ return binl2hex(core_md5(str2binl(s), s.length * 8));
+ },
+ hash: function hash(s) {
+ return binl2str(core_md5(str2binl(s), s.length * 8));
+ }
+};
+
+
+/***/ }),
+
+/***/ "./src/sha1.js":
+/*!*********************!*\
+ !*** ./src/sha1.js ***!
+ \*********************/
+/*! exports provided: default */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return SHA1; });
+/*
+ * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
+ * in FIPS PUB 180-1
+ * Version 2.1a Copyright Paul Johnston 2000 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for details.
+ */
+
+/* jshint undef: true, unused: true:, noarg: true, latedef: false */
+
+/* global define */
+
+/* Some functions and variables have been stripped for use with Strophe */
+
+/*
+ * Calculate the SHA-1 of an array of big-endian words, and a bit length
+ */
+function core_sha1(x, len) {
+ /* append padding */
+ x[len >> 5] |= 0x80 << 24 - len % 32;
+ x[(len + 64 >> 9 << 4) + 15] = len;
+ var w = new Array(80);
+ var a = 1732584193;
+ var b = -271733879;
+ var c = -1732584194;
+ var d = 271733878;
+ var e = -1009589776;
+ var i, j, t, olda, oldb, oldc, oldd, olde;
+
+ for (i = 0; i < x.length; i += 16) {
+ olda = a;
+ oldb = b;
+ oldc = c;
+ oldd = d;
+ olde = e;
+
+ for (j = 0; j < 80; j++) {
+ if (j < 16) {
+ w[j] = x[i + j];
+ } else {
+ w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
+ }
+
+ t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
+ e = d;
+ d = c;
+ c = rol(b, 30);
+ b = a;
+ a = t;
+ }
+
+ a = safe_add(a, olda);
+ b = safe_add(b, oldb);
+ c = safe_add(c, oldc);
+ d = safe_add(d, oldd);
+ e = safe_add(e, olde);
+ }
+
+ return [a, b, c, d, e];
+}
+/*
+ * Perform the appropriate triplet combination function for the current
+ * iteration
+ */
+
+
+function sha1_ft(t, b, c, d) {
+ if (t < 20) {
+ return b & c | ~b & d;
+ }
+
+ if (t < 40) {
+ return b ^ c ^ d;
+ }
+
+ if (t < 60) {
+ return b & c | b & d | c & d;
+ }
+
+ return b ^ c ^ d;
+}
+/*
+ * Determine the appropriate additive constant for the current iteration
+ */
+
+
+function sha1_kt(t) {
+ return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
+}
+/*
+ * Calculate the HMAC-SHA1 of a key and some data
+ */
+
+
+function core_hmac_sha1(key, data) {
+ var bkey = str2binb(key);
+
+ if (bkey.length > 16) {
+ bkey = core_sha1(bkey, key.length * 8);
+ }
+
+ var ipad = new Array(16),
+ opad = new Array(16);
+
+ for (var i = 0; i < 16; i++) {
+ ipad[i] = bkey[i] ^ 0x36363636;
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
+ }
+
+ var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * 8);
+ return core_sha1(opad.concat(hash), 512 + 160);
+}
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+
+
+function safe_add(x, y) {
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return msw << 16 | lsw & 0xFFFF;
+}
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+
+
+function rol(num, cnt) {
+ return num << cnt | num >>> 32 - cnt;
+}
+/*
+ * Convert an 8-bit or 16-bit string to an array of big-endian words
+ * In 8-bit function, characters >255 have their hi-byte silently ignored.
+ */
+
+
+function str2binb(str) {
+ var bin = [];
+ var mask = 255;
+
+ for (var i = 0; i < str.length * 8; i += 8) {
+ bin[i >> 5] |= (str.charCodeAt(i / 8) & mask) << 24 - i % 32;
+ }
+
+ return bin;
+}
+/*
+ * Convert an array of big-endian words to a base-64 string
+ */
+
+
+function binb2b64(binarray) {
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ var str = "";
+ var triplet, j;
+
+ for (var i = 0; i < binarray.length * 4; i += 3) {
+ triplet = (binarray[i >> 2] >> 8 * (3 - i % 4) & 0xFF) << 16 | (binarray[i + 1 >> 2] >> 8 * (3 - (i + 1) % 4) & 0xFF) << 8 | binarray[i + 2 >> 2] >> 8 * (3 - (i + 2) % 4) & 0xFF;
+
+ for (j = 0; j < 4; j++) {
+ if (i * 8 + j * 6 > binarray.length * 32) {
+ str += "=";
+ } else {
+ str += tab.charAt(triplet >> 6 * (3 - j) & 0x3F);
+ }
+ }
+ }
+
+ return str;
+}
+/*
+ * Convert an array of big-endian words to a string
+ */
+
+
+function binb2str(bin) {
+ var str = "";
+ var mask = 255;
+
+ for (var i = 0; i < bin.length * 32; i += 8) {
+ str += String.fromCharCode(bin[i >> 5] >>> 24 - i % 32 & mask);
+ }
+
+ return str;
+}
+/*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
+
+
+var SHA1 = {
+ b64_hmac_sha1: function b64_hmac_sha1(key, data) {
+ return binb2b64(core_hmac_sha1(key, data));
+ },
+ b64_sha1: function b64_sha1(s) {
+ return binb2b64(core_sha1(str2binb(s), s.length * 8));
+ },
+ binb2str: binb2str,
+ core_hmac_sha1: core_hmac_sha1,
+ str_hmac_sha1: function str_hmac_sha1(key, data) {
+ return binb2str(core_hmac_sha1(key, data));
+ },
+ str_sha1: function str_sha1(s) {
+ return binb2str(core_sha1(str2binb(s), s.length * 8));
+ }
+};
+
+
+/***/ }),
+
+/***/ "./src/strophe.js":
+/*!************************!*\
+ !*** ./src/strophe.js ***!
+ \************************/
+/*! exports provided: default */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var bosh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! bosh */ "./src/bosh.js");
+/* harmony import */ var websocket__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! websocket */ "./src/websocket.js");
+/* harmony import */ var core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core */ "./src/core.js");
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "default", function() { return core__WEBPACK_IMPORTED_MODULE_2__["default"]; });
+
+
+
+
+
+/***/ }),
+
+/***/ "./src/utils.js":
+/*!**********************!*\
+ !*** ./src/utils.js ***!
+ \**********************/
+/*! exports provided: default */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return utils; });
+function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+var utils = {
+ utf16to8: function utf16to8(str) {
+ var i, c;
+ var out = "";
+ var len = str.length;
+
+ for (i = 0; i < len; i++) {
+ c = str.charCodeAt(i);
+
+ if (c >= 0x0000 && c <= 0x007F) {
+ out += str.charAt(i);
+ } else if (c > 0x07FF) {
+ out += String.fromCharCode(0xE0 | c >> 12 & 0x0F);
+ out += String.fromCharCode(0x80 | c >> 6 & 0x3F);
+ out += String.fromCharCode(0x80 | c >> 0 & 0x3F);
+ } else {
+ out += String.fromCharCode(0xC0 | c >> 6 & 0x1F);
+ out += String.fromCharCode(0x80 | c >> 0 & 0x3F);
+ }
+ }
+
+ return out;
+ },
+ addCookies: function addCookies(cookies) {
+ /* Parameters:
+ * (Object) cookies - either a map of cookie names
+ * to string values or to maps of cookie values.
+ *
+ * For example:
+ * { "myCookie": "1234" }
+ *
+ * or:
+ * { "myCookie": {
+ * "value": "1234",
+ * "domain": ".example.org",
+ * "path": "/",
+ * "expires": expirationDate
+ * }
+ * }
+ *
+ * These values get passed to Strophe.Connection via
+ * options.cookies
+ */
+ cookies = cookies || {};
+
+ for (var cookieName in cookies) {
+ if (Object.prototype.hasOwnProperty.call(cookies, cookieName)) {
+ var expires = '';
+ var domain = '';
+ var path = '';
+ var cookieObj = cookies[cookieName];
+ var isObj = _typeof(cookieObj) === "object";
+ var cookieValue = escape(unescape(isObj ? cookieObj.value : cookieObj));
+
+ if (isObj) {
+ expires = cookieObj.expires ? ";expires=" + cookieObj.expires : '';
+ domain = cookieObj.domain ? ";domain=" + cookieObj.domain : '';
+ path = cookieObj.path ? ";path=" + cookieObj.path : '';
+ }
+
+ document.cookie = cookieName + '=' + cookieValue + expires + domain + path;
+ }
+ }
+ }
+};
+
+
+/***/ }),
+
+/***/ "./src/websocket.js":
+/*!**************************!*\
+ !*** ./src/websocket.js ***!
+ \**************************/
+/*! no exports provided */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core */ "./src/core.js");
+/*
+ This program is distributed under the terms of the MIT license.
+ Please see the LICENSE file for details.
+
+ Copyright 2006-2008, OGG, LLC
+*/
+
+/* global window, clearTimeout, WebSocket, DOMParser */
+
+var Strophe = core__WEBPACK_IMPORTED_MODULE_0__["default"].Strophe;
+var $build = core__WEBPACK_IMPORTED_MODULE_0__["default"].$build;
+/** Class: Strophe.WebSocket
+ * _Private_ helper class that handles WebSocket Connections
+ *
+ * The Strophe.WebSocket class is used internally by Strophe.Connection
+ * to encapsulate WebSocket sessions. It is not meant to be used from user's code.
+ */
+
+/** File: websocket.js
+ * A JavaScript library to enable XMPP over Websocket in Strophejs.
+ *
+ * This file implements XMPP over WebSockets for Strophejs.
+ * If a Connection is established with a Websocket url (ws://...)
+ * Strophe will use WebSockets.
+ * For more information on XMPP-over-WebSocket see RFC 7395:
+ * http://tools.ietf.org/html/rfc7395
+ *
+ * WebSocket support implemented by Andreas Guth (andreas.guth@rwth-aachen.de)
+ */
+
+/** PrivateConstructor: Strophe.Websocket
+ * Create and initialize a Strophe.WebSocket object.
+ * Currently only sets the connection Object.
+ *
+ * Parameters:
+ * (Strophe.Connection) connection - The Strophe.Connection that will use WebSockets.
+ *
+ * Returns:
+ * A new Strophe.WebSocket object.
+ */
+
+Strophe.Websocket = function (connection) {
+ this._conn = connection;
+ this.strip = "wrapper";
+ var service = connection.service;
+
+ if (service.indexOf("ws:") !== 0 && service.indexOf("wss:") !== 0) {
+ // If the service is not an absolute URL, assume it is a path and put the absolute
+ // URL together from options, current URL and the path.
+ var new_service = "";
+
+ if (connection.options.protocol === "ws" && window.location.protocol !== "https:") {
+ new_service += "ws";
+ } else {
+ new_service += "wss";
+ }
+
+ new_service += "://" + window.location.host;
+
+ if (service.indexOf("/") !== 0) {
+ new_service += window.location.pathname + service;
+ } else {
+ new_service += service;
+ }
+
+ connection.service = new_service;
+ }
+};
+
+Strophe.Websocket.prototype = {
+ /** PrivateFunction: _buildStream
+ * _Private_ helper function to generate the start tag for WebSockets
+ *
+ * Returns:
+ * A Strophe.Builder with a element.
+ */
+ _buildStream: function _buildStream() {
+ return $build("open", {
+ "xmlns": Strophe.NS.FRAMING,
+ "to": this._conn.domain,
+ "version": '1.0'
+ });
+ },
+
+ /** PrivateFunction: _check_streamerror
+ * _Private_ checks a message for stream:error
+ *
+ * Parameters:
+ * (Strophe.Request) bodyWrap - The received stanza.
+ * connectstatus - The ConnectStatus that will be set on error.
+ * Returns:
+ * true if there was a streamerror, false otherwise.
+ */
+ _check_streamerror: function _check_streamerror(bodyWrap, connectstatus) {
+ var errors;
+
+ if (bodyWrap.getElementsByTagNameNS) {
+ errors = bodyWrap.getElementsByTagNameNS(Strophe.NS.STREAM, "error");
+ } else {
+ errors = bodyWrap.getElementsByTagName("stream:error");
+ }
+
+ if (errors.length === 0) {
+ return false;
+ }
+
+ var error = errors[0];
+ var condition = "";
+ var text = "";
+ var ns = "urn:ietf:params:xml:ns:xmpp-streams";
+
+ for (var i = 0; i < error.childNodes.length; i++) {
+ var e = error.childNodes[i];
+
+ if (e.getAttribute("xmlns") !== ns) {
+ break;
+ }
+
+ if (e.nodeName === "text") {
+ text = e.textContent;
+ } else {
+ condition = e.nodeName;
+ }
+ }
+
+ var errorString = "WebSocket stream error: ";
+
+ if (condition) {
+ errorString += condition;
+ } else {
+ errorString += "unknown";
+ }
+
+ if (text) {
+ errorString += " - " + text;
+ }
+
+ Strophe.error(errorString); // close the connection on stream_error
+
+ this._conn._changeConnectStatus(connectstatus, condition);
+
+ this._conn._doDisconnect();
+
+ return true;
+ },
+
+ /** PrivateFunction: _reset
+ * Reset the connection.
+ *
+ * This function is called by the reset function of the Strophe Connection.
+ * Is not needed by WebSockets.
+ */
+ _reset: function _reset() {
+ return;
+ },
+
+ /** PrivateFunction: _connect
+ * _Private_ function called by Strophe.Connection.connect
+ *
+ * Creates a WebSocket for a connection and assigns Callbacks to it.
+ * Does nothing if there already is a WebSocket.
+ */
+ _connect: function _connect() {
+ // Ensure that there is no open WebSocket from a previous Connection.
+ this._closeSocket(); // Create the new WobSocket
+
+
+ this.socket = new WebSocket(this._conn.service, "xmpp");
+ this.socket.onopen = this._onOpen.bind(this);
+ this.socket.onerror = this._onError.bind(this);
+ this.socket.onclose = this._onClose.bind(this);
+ this.socket.onmessage = this._connect_cb_wrapper.bind(this);
+ },
+
+ /** PrivateFunction: _connect_cb
+ * _Private_ function called by Strophe.Connection._connect_cb
+ *
+ * checks for stream:error
+ *
+ * Parameters:
+ * (Strophe.Request) bodyWrap - The received stanza.
+ */
+ _connect_cb: function _connect_cb(bodyWrap) {
+ var error = this._check_streamerror(bodyWrap, Strophe.Status.CONNFAIL);
+
+ if (error) {
+ return Strophe.Status.CONNFAIL;
+ }
+ },
+
+ /** PrivateFunction: _handleStreamStart
+ * _Private_ function that checks the opening tag for errors.
+ *
+ * Disconnects if there is an error and returns false, true otherwise.
+ *
+ * Parameters:
+ * (Node) message - Stanza containing the tag.
+ */
+ _handleStreamStart: function _handleStreamStart(message) {
+ var error = false; // Check for errors in the tag
+
+ var ns = message.getAttribute("xmlns");
+
+ if (typeof ns !== "string") {
+ error = "Missing xmlns in ";
+ } else if (ns !== Strophe.NS.FRAMING) {
+ error = "Wrong xmlns in : " + ns;
+ }
+
+ var ver = message.getAttribute("version");
+
+ if (typeof ver !== "string") {
+ error = "Missing version in ";
+ } else if (ver !== "1.0") {
+ error = "Wrong version in : " + ver;
+ }
+
+ if (error) {
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, error);
+
+ this._conn._doDisconnect();
+
+ return false;
+ }
+
+ return true;
+ },
+
+ /** PrivateFunction: _connect_cb_wrapper
+ * _Private_ function that handles the first connection messages.
+ *
+ * On receiving an opening stream tag this callback replaces itself with the real
+ * message handler. On receiving a stream error the connection is terminated.
+ */
+ _connect_cb_wrapper: function _connect_cb_wrapper(message) {
+ if (message.data.indexOf("\s*)*/, "");
+ if (data === '') return;
+ var streamStart = new DOMParser().parseFromString(data, "text/xml").documentElement;
+
+ this._conn.xmlInput(streamStart);
+
+ this._conn.rawInput(message.data); //_handleStreamSteart will check for XML errors and disconnect on error
+
+
+ if (this._handleStreamStart(streamStart)) {
+ //_connect_cb will check for stream:error and disconnect on error
+ this._connect_cb(streamStart);
+ }
+ } else if (message.data.indexOf("WSS, WS->ANY
+
+ var isSecureRedirect = service.indexOf("wss:") >= 0 && see_uri.indexOf("wss:") >= 0 || service.indexOf("ws:") >= 0;
+
+ if (isSecureRedirect) {
+ this._conn._changeConnectStatus(Strophe.Status.REDIRECT, "Received see-other-uri, resetting connection");
+
+ this._conn.reset();
+
+ this._conn.service = see_uri;
+
+ this._connect();
+ }
+ } else {
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Received closing stream");
+
+ this._conn._doDisconnect();
+ }
+ } else {
+ var string = this._streamWrap(message.data);
+
+ var elem = new DOMParser().parseFromString(string, "text/xml").documentElement;
+ this.socket.onmessage = this._onMessage.bind(this);
+
+ this._conn._connect_cb(elem, null, message.data);
+ }
+ },
+
+ /** PrivateFunction: _disconnect
+ * _Private_ function called by Strophe.Connection.disconnect
+ *
+ * Disconnects and sends a last stanza if one is given
+ *
+ * Parameters:
+ * (Request) pres - This stanza will be sent before disconnecting.
+ */
+ _disconnect: function _disconnect(pres) {
+ if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
+ if (pres) {
+ this._conn.send(pres);
+ }
+
+ var close = $build("close", {
+ "xmlns": Strophe.NS.FRAMING
+ });
+
+ this._conn.xmlOutput(close.tree());
+
+ var closeString = Strophe.serialize(close);
+
+ this._conn.rawOutput(closeString);
+
+ try {
+ this.socket.send(closeString);
+ } catch (e) {
+ Strophe.info("Couldn't send tag.");
+ }
+ }
+
+ this._conn._doDisconnect();
+ },
+
+ /** PrivateFunction: _doDisconnect
+ * _Private_ function to disconnect.
+ *
+ * Just closes the Socket for WebSockets
+ */
+ _doDisconnect: function _doDisconnect() {
+ Strophe.info("WebSockets _doDisconnect was called");
+
+ this._closeSocket();
+ },
+
+ /** PrivateFunction _streamWrap
+ * _Private_ helper function to wrap a stanza in a tag.
+ * This is used so Strophe can process stanzas from WebSockets like BOSH
+ */
+ _streamWrap: function _streamWrap(stanza) {
+ return "" + stanza + '';
+ },
+
+ /** PrivateFunction: _closeSocket
+ * _Private_ function to close the WebSocket.
+ *
+ * Closes the socket if it is still open and deletes it
+ */
+ _closeSocket: function _closeSocket() {
+ if (this.socket) {
+ try {
+ this.socket.onerror = null;
+ this.socket.close();
+ } catch (e) {
+ Strophe.debug(e.message);
+ }
+ }
+
+ this.socket = null;
+ },
+
+ /** PrivateFunction: _emptyQueue
+ * _Private_ function to check if the message queue is empty.
+ *
+ * Returns:
+ * True, because WebSocket messages are send immediately after queueing.
+ */
+ _emptyQueue: function _emptyQueue() {
+ return true;
+ },
+
+ /** PrivateFunction: _onClose
+ * _Private_ function to handle websockets closing.
+ *
+ * Nothing to do here for WebSockets
+ */
+ _onClose: function _onClose(e) {
+ if (this._conn.connected && !this._conn.disconnecting) {
+ Strophe.error("Websocket closed unexpectedly");
+
+ this._conn._doDisconnect();
+ } else if (e && e.code === 1006 && !this._conn.connected && this.socket) {
+ // in case the onError callback was not called (Safari 10 does not
+ // call onerror when the initial connection fails) we need to
+ // dispatch a CONNFAIL status update to be consistent with the
+ // behavior on other browsers.
+ Strophe.error("Websocket closed unexcectedly");
+
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
+
+ this._conn._doDisconnect();
+ } else {
+ Strophe.info("Websocket closed");
+ }
+ },
+
+ /** PrivateFunction: _no_auth_received
+ *
+ * Called on stream start/restart when no stream:features
+ * has been received.
+ */
+ _no_auth_received: function _no_auth_received(callback) {
+ Strophe.error("Server did not offer a supported authentication mechanism");
+
+ this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.NO_AUTH_MECH);
+
+ if (callback) {
+ callback.call(this._conn);
+ }
+
+ this._conn._doDisconnect();
+ },
+
+ /** PrivateFunction: _onDisconnectTimeout
+ * _Private_ timeout handler for handling non-graceful disconnection.
+ *
+ * This does nothing for WebSockets
+ */
+ _onDisconnectTimeout: function _onDisconnectTimeout() {},
+
+ /** PrivateFunction: _abortAllRequests
+ * _Private_ helper function that makes sure all pending requests are aborted.
+ */
+ _abortAllRequests: function _abortAllRequests() {},
+
+ /** PrivateFunction: _onError
+ * _Private_ function to handle websockets errors.
+ *
+ * Parameters:
+ * (Object) error - The websocket error.
+ */
+ _onError: function _onError(error) {
+ Strophe.error("Websocket error " + error);
+
+ this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
+
+ this._disconnect();
+ },
+
+ /** PrivateFunction: _onIdle
+ * _Private_ function called by Strophe.Connection._onIdle
+ *
+ * sends all queued stanzas
+ */
+ _onIdle: function _onIdle() {
+ var data = this._conn._data;
+
+ if (data.length > 0 && !this._conn.paused) {
+ for (var i = 0; i < data.length; i++) {
+ if (data[i] !== null) {
+ var stanza = void 0;
+
+ if (data[i] === "restart") {
+ stanza = this._buildStream().tree();
+ } else {
+ stanza = data[i];
+ }
+
+ var rawStanza = Strophe.serialize(stanza);
+
+ this._conn.xmlOutput(stanza);
+
+ this._conn.rawOutput(rawStanza);
+
+ this.socket.send(rawStanza);
+ }
+ }
+
+ this._conn._data = [];
+ }
+ },
+
+ /** PrivateFunction: _onMessage
+ * _Private_ function to handle websockets messages.
+ *
+ * This function parses each of the messages as if they are full documents.
+ * [TODO : We may actually want to use a SAX Push parser].
+ *
+ * Since all XMPP traffic starts with
+ *
+ *
+ * The first stanza will always fail to be parsed.
+ *
+ * Additionally, the seconds stanza will always be with
+ * the stream NS defined in the previous stanza, so we need to 'force'
+ * the inclusion of the NS in this stanza.
+ *
+ * Parameters:
+ * (string) message - The websocket message.
+ */
+ _onMessage: function _onMessage(message) {
+ var elem; // check for closing stream
+
+ var close = '';
+
+ if (message.data === close) {
+ this._conn.rawInput(close);
+
+ this._conn.xmlInput(message);
+
+ if (!this._conn.disconnecting) {
+ this._conn._doDisconnect();
+ }
+
+ return;
+ } else if (message.data.search(" tag before we close the connection
+
+
+ return;
+ }
+
+ this._conn._dataRecv(elem, message.data);
+ },
+
+ /** PrivateFunction: _onOpen
+ * _Private_ function to handle websockets connection setup.
+ *
+ * The opening stream tag is sent here.
+ */
+ _onOpen: function _onOpen() {
+ Strophe.info("Websocket open");
+
+ var start = this._buildStream();
+
+ this._conn.xmlOutput(start.tree());
+
+ var startString = Strophe.serialize(start);
+
+ this._conn.rawOutput(startString);
+
+ this.socket.send(startString);
+ },
+
+ /** PrivateFunction: _reqToData
+ * _Private_ function to get a stanza out of a request.
+ *
+ * WebSockets don't use requests, so the passed argument is just returned.
+ *
+ * Parameters:
+ * (Object) stanza - The stanza.
+ *
+ * Returns:
+ * The stanza that was passed.
+ */
+ _reqToData: function _reqToData(stanza) {
+ return stanza;
+ },
+
+ /** PrivateFunction: _send
+ * _Private_ part of the Connection.send function for WebSocket
+ *
+ * Just flushes the messages that are in the queue
+ */
+ _send: function _send() {
+ this._conn.flush();
+ },
+
+ /** PrivateFunction: _sendRestart
+ *
+ * Send an xmpp:restart stanza.
+ */
+ _sendRestart: function _sendRestart() {
+ clearTimeout(this._conn._idleTimeout);
+
+ this._conn._onIdle.bind(this._conn)();
+ }
+};
+
+/***/ })
+
+/******/ })["default"];
+});
+//# sourceMappingURL=strophe.js.map
+
+/***/ }),
+
+/***/ "./node_modules/strophejs-plugin-ping/strophe.ping.js":
+/*!************************************************************!*\
+ !*** ./node_modules/strophejs-plugin-ping/strophe.ping.js ***!
+ \************************************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*
+* Based on Ping Strophejs plugins (https://github.com/metajack/strophejs-plugins/tree/master/ping)
+* This plugin is distributed under the terms of the MIT licence.
+* Please see the LICENCE file for details.
+*
+* Copyright (c) Markus Kohlhase, 2010
+* Refactored by Pavel Lang, 2011
+* AMD Support added by Thierry
+*/
+/**
+* File: strophe.ping.js
+* A Strophe plugin for XMPP Ping ( http://xmpp.org/extensions/xep-0199.html )
+*/
+(function (root, factory) {
+ if (true) {
+ // AMD. Register as an anonymous module.
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [
+ __webpack_require__(/*! strophe.js */ "./node_modules/strophe.js/dist/strophe.js")
+ ], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Strophe) {
+ factory(
+ Strophe.Strophe,
+ Strophe.$build,
+ Strophe.$iq ,
+ Strophe.$msg,
+ Strophe.$pres
+ );
+ return Strophe;
+ }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
+ } else {}
+}(this, function (Strophe, $build, $iq, $msg, $pres) {
+ Strophe.addConnectionPlugin('ping', {
+ _c: null,
+
+ // called by the Strophe.Connection constructor
+ init: function(conn) {
+ this._c = conn;
+ Strophe.addNamespace('PING', "urn:xmpp:ping");
+ },
+
+ /**
+ * Function: ping
+ *
+ * Parameters:
+ * (String) to - The JID you want to ping
+ * (Function) success - Callback function on success
+ * (Function) error - Callback function on error
+ * (Integer) timeout - Timeout in milliseconds
+ */
+ ping: function(jid, success, error, timeout) {
+ var id = this._c.getUniqueId('ping');
+ var iq = $iq({type: 'get', to: jid, id: id}).c(
+ 'ping', {xmlns: Strophe.NS.PING});
+ this._c.sendIQ(iq, success, error, timeout);
+ },
+
+ /**
+ * Function: pong
+ *
+ * Parameters:
+ * (Object) ping - The ping stanza from the server.
+ */
+ pong: function(ping) {
+ var from = ping.getAttribute('from');
+ var id = ping.getAttribute('id');
+ var iq = $iq({type: 'result', to: from,id: id});
+ this._c.sendIQ(iq);
+ },
+
+ /**
+ * Function: addPingHandler
+ *
+ * Parameters:
+ * (Function) handler - Ping handler
+ *
+ * Returns:
+ * A reference to the handler that can be used to remove it.
+ */
+ addPingHandler: function(handler) {
+ return this._c.addHandler(handler, Strophe.NS.PING, "iq", "get");
+ }
+ });
+}));
+
+
+/***/ }),
+
+/***/ "./node_modules/strophejs-plugin-rsm/lib/strophe.rsm.js":
+/*!**************************************************************!*\
+ !*** ./node_modules/strophejs-plugin-rsm/lib/strophe.rsm.js ***!
+ \**************************************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+(function (global, factory) {
+ true ? factory(__webpack_require__(/*! strophe.js */ "./node_modules/strophe.js/dist/strophe.js")) :
+ undefined;
+}(this, (function (strophe_js) { 'use strict';
+
+strophe_js.Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
+
+strophe_js.Strophe.RSM = function(options) {
+ this.attribs = ['max', 'first', 'last', 'after', 'before', 'index', 'count'];
+
+ if (typeof options.xml != 'undefined') {
+ this.fromXMLElement(options.xml);
+ } else {
+ for (var ii = 0; ii < this.attribs.length; ii++) {
+ var attrib = this.attribs[ii];
+ this[attrib] = options[attrib];
+ }
+ }
+};
+
+strophe_js.Strophe.RSM.prototype = {
+ toXML: function() {
+ var xml = strophe_js.$build('set', {xmlns: strophe_js.Strophe.NS.RSM});
+ for (var ii = 0; ii < this.attribs.length; ii++) {
+ var attrib = this.attribs[ii];
+ if (typeof this[attrib] != 'undefined') {
+ xml = xml.c(attrib).t(this[attrib].toString()).up();
+ }
+ }
+ return xml.tree();
+ },
+
+ next: function(max) {
+ var newSet = new strophe_js.Strophe.RSM({max: max, after: this.last});
+ return newSet;
+ },
+
+ previous: function(max) {
+ var newSet = new strophe_js.Strophe.RSM({max: max, before: this.first});
+ return newSet;
+ },
+
+ fromXMLElement: function(xmlElement) {
+ for (var ii = 0; ii < this.attribs.length; ii++) {
+ var attrib = this.attribs[ii];
+ var elem = xmlElement.getElementsByTagName(attrib)[0];
+ if (typeof elem != 'undefined' && elem !== null) {
+ this[attrib] = strophe_js.Strophe.getText(elem);
+ if (attrib == 'first') {
+ this.index = elem.getAttribute('index');
+ }
+ }
+ }
+ }
+};
+
+})));
+//# sourceMappingURL=strophe.rsm.js.map
+
+
/***/ }),
/***/ "./node_modules/twemoji/2/esm.js":
@@ -31814,10 +38034,7 @@ exports["filterCSS"] = (filterCSS);
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-/*global define */
+var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*global define */
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! backbone */ "./node_modules/backbone/backbone.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Backbone) {
return Backbone.noConflict();
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
@@ -31832,20 +38049,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
-
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -31857,14 +38061,14 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
- var _converse$env = converse.env,
- _ = _converse$env._,
- Backbone = _converse$env.Backbone,
- u = converse.env.utils;
+})(this, function (converse) {
+ const _converse$env = converse.env,
+ _ = _converse$env._,
+ Backbone = _converse$env.Backbone,
+ u = converse.env.utils;
converse.plugins.add("converse-autocomplete", {
- initialize: function initialize() {
- var _converse = this._converse;
+ initialize() {
+ const _converse = this._converse;
_converse.FILTER_CONTAINS = function (text, input) {
return RegExp(helpers.regExpEscape(input.trim()), "i").test(text);
@@ -31874,7 +38078,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
return RegExp("^" + helpers.regExpEscape(input.trim()), "i").test(text);
};
- var SORT_BYLENGTH = function SORT_BYLENGTH(a, b) {
+ const SORT_BYLENGTH = function SORT_BYLENGTH(a, b) {
if (a.length !== b.length) {
return a.length - b.length;
}
@@ -31882,15 +38086,15 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
return a < b ? -1 : 1;
};
- var ITEM = function ITEM(text, input) {
+ const ITEM = (text, input) => {
input = input.trim();
- var element = document.createElement("li");
+ const element = document.createElement("li");
element.setAttribute("aria-selected", "false");
- var regex = new RegExp("(" + input + ")", "ig");
- var parts = input ? text.split(regex) : [text];
- parts.forEach(function (txt) {
+ const regex = new RegExp("(" + input + ")", "ig");
+ const parts = input ? text.split(regex) : [text];
+ parts.forEach(txt => {
if (input && txt.match(regex)) {
- var match = document.createElement("mark");
+ const match = document.createElement("mark");
match.textContent = txt;
element.appendChild(match);
} else {
@@ -31900,14 +38104,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
return element;
};
- var AutoComplete =
- /*#__PURE__*/
- function () {
- function AutoComplete(el) {
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
-
- _classCallCheck(this, AutoComplete);
-
+ class AutoComplete {
+ constructor(el, config = {}) {
this.is_opened = false;
if (u.hasClass('.suggestion-box', el)) {
@@ -31950,327 +38148,288 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
}
}
- _createClass(AutoComplete, [{
- key: "bindEvents",
- value: function bindEvents() {
- var _this = this;
+ bindEvents() {
+ // Bind events
+ const input = {
+ "blur": () => this.close({
+ 'reason': 'blur'
+ })
+ };
- // Bind events
- var input = {
- "blur": function blur() {
- return _this.close({
- 'reason': 'blur'
- });
- }
- };
-
- if (this.auto_evaluate) {
- input["input"] = function () {
- return _this.evaluate();
- };
- }
-
- this._events = {
- 'input': input,
- 'form': {
- "submit": function submit() {
- return _this.close({
- 'reason': 'submit'
- });
- }
- },
- 'ul': {
- "mousedown": function mousedown(ev) {
- return _this.onMouseDown(ev);
- },
- "mouseover": function mouseover(ev) {
- return _this.onMouseOver(ev);
- }
- }
- };
- helpers.bind(this.input, this._events.input);
- helpers.bind(this.input.form, this._events.form);
- helpers.bind(this.ul, this._events.ul);
+ if (this.auto_evaluate) {
+ input["input"] = () => this.evaluate();
}
- }, {
- key: "close",
- value: function close(o) {
- if (!this.opened) {
- return;
+
+ this._events = {
+ 'input': input,
+ 'form': {
+ "submit": () => this.close({
+ 'reason': 'submit'
+ })
+ },
+ 'ul': {
+ "mousedown": ev => this.onMouseDown(ev),
+ "mouseover": ev => this.onMouseOver(ev)
}
+ };
+ helpers.bind(this.input, this._events.input);
+ helpers.bind(this.input.form, this._events.form);
+ helpers.bind(this.ul, this._events.ul);
+ }
- this.ul.setAttribute("hidden", "");
- this.is_opened = false;
- this.index = -1;
- this.trigger("suggestion-box-close", o || {});
- }
- }, {
- key: "insertValue",
- value: function insertValue(suggestion) {
- var value;
+ set list(list) {
+ if (Array.isArray(list) || typeof list === "function") {
+ this._list = list;
+ } else if (typeof list === "string" && _.includes(list, ",")) {
+ this._list = list.split(/\s*,\s*/);
+ } else {
+ // Element or CSS selector
+ list = helpers.getElement(list);
- if (this.match_current_word) {
- u.replaceCurrentWord(this.input, suggestion.value);
- } else {
- this.input.value = suggestion.value;
- }
- }
- }, {
- key: "open",
- value: function open() {
- this.ul.removeAttribute("hidden");
- this.is_opened = true;
-
- if (this.auto_first && this.index === -1) {
- this.goto(0);
- }
-
- this.trigger("suggestion-box-open");
- }
- }, {
- key: "destroy",
- value: function destroy() {
- //remove events from the input and its form
- helpers.unbind(this.input, this._events.input);
- helpers.unbind(this.input.form, this._events.form); //move the input out of the suggestion-box container and remove the container and its children
-
- var parentNode = this.container.parentNode;
- parentNode.insertBefore(this.input, this.container);
- parentNode.removeChild(this.container); //remove autocomplete and aria-autocomplete attributes
-
- this.input.removeAttribute("autocomplete");
- this.input.removeAttribute("aria-autocomplete");
- }
- }, {
- key: "next",
- value: function next() {
- var count = this.ul.children.length;
- this.goto(this.index < count - 1 ? this.index + 1 : count ? 0 : -1);
- }
- }, {
- key: "previous",
- value: function previous() {
- var count = this.ul.children.length,
- pos = this.index - 1;
- this.goto(this.selected && pos !== -1 ? pos : count - 1);
- }
- }, {
- key: "goto",
- value: function goto(i) {
- // Should not be used directly, highlights specific item without any checks!
- var list = this.ul.children;
-
- if (this.selected) {
- list[this.index].setAttribute("aria-selected", "false");
- }
-
- this.index = i;
-
- if (i > -1 && list.length > 0) {
- list[i].setAttribute("aria-selected", "true");
- list[i].focus();
- this.status.textContent = list[i].textContent; // scroll to highlighted element in case parent's height is fixed
-
- this.ul.scrollTop = list[i].offsetTop - this.ul.clientHeight + list[i].clientHeight;
- this.trigger("suggestion-box-highlight", {
- 'text': this.suggestions[this.index]
- });
- }
- }
- }, {
- key: "select",
- value: function select(selected, origin) {
- if (selected) {
- this.index = u.siblingIndex(selected);
- } else {
- selected = this.ul.children[this.index];
- }
-
- if (selected) {
- var suggestion = this.suggestions[this.index];
- this.insertValue(suggestion);
- this.close({
- 'reason': 'select'
- });
- this.auto_completing = false;
- this.trigger("suggestion-box-selectcomplete", {
- 'text': suggestion
- });
- }
- }
- }, {
- key: "onMouseOver",
- value: function onMouseOver(ev) {
- var li = u.ancestor(ev.target, 'li');
-
- if (li) {
- this.goto(Array.prototype.slice.call(this.ul.children).indexOf(li));
- }
- }
- }, {
- key: "onMouseDown",
- value: function onMouseDown(ev) {
- if (ev.button !== 0) {
- return; // Only select on left click
- }
-
- var li = u.ancestor(ev.target, 'li');
-
- if (li) {
- ev.preventDefault();
- this.select(li, ev.target);
- }
- }
- }, {
- key: "keyPressed",
- value: function keyPressed(ev) {
- if (this.opened) {
- if (_.includes([_converse.keycodes.ENTER, _converse.keycodes.TAB], ev.keyCode) && this.selected) {
- ev.preventDefault();
- ev.stopPropagation();
- this.select();
- return true;
- } else if (ev.keyCode === _converse.keycodes.ESCAPE) {
- this.close({
- 'reason': 'esc'
- });
- return true;
- } else if (_.includes([_converse.keycodes.UP_ARROW, _converse.keycodes.DOWN_ARROW], ev.keyCode)) {
- ev.preventDefault();
- ev.stopPropagation();
- this[ev.keyCode === _converse.keycodes.UP_ARROW ? "previous" : "next"]();
- return true;
- }
- }
-
- if (_.includes([_converse.keycodes.SHIFT, _converse.keycodes.META, _converse.keycodes.META_RIGHT, _converse.keycodes.ESCAPE, _converse.keycodes.ALT], ev.keyCode)) {
- return;
- }
-
- if (this.match_on_tab && ev.keyCode === _converse.keycodes.TAB) {
- ev.preventDefault();
- this.auto_completing = true;
- } else if (this.trigger_on_at && ev.keyCode === _converse.keycodes.AT) {
- this.auto_completing = true;
- }
- }
- }, {
- key: "evaluate",
- value: function evaluate(ev) {
- var _this2 = this;
-
- var arrow_pressed = ev.keyCode === _converse.keycodes.UP_ARROW || ev.keyCode === _converse.keycodes.DOWN_ARROW;
-
- if (!this.auto_completing || this.selected && arrow_pressed) {
- return;
- }
-
- var list = typeof this._list === "function" ? this._list() : this._list;
-
- if (list.length === 0) {
- return;
- }
-
- var value = this.match_current_word ? u.getCurrentWord(this.input) : this.input.value;
- var ignore_min_chars = false;
-
- if (this.trigger_on_at && value.startsWith('@')) {
- ignore_min_chars = true;
- value = value.slice('1');
- }
-
- if (value.length >= this.min_chars || ignore_min_chars) {
- this.index = -1; // Populate list with options that match
-
- this.ul.innerHTML = "";
- this.suggestions = list.map(function (item) {
- return new Suggestion(_this2.data(item, value));
- }).filter(function (item) {
- return _this2.filter(item, value);
- });
-
- if (this.sort !== false) {
- this.suggestions = this.suggestions.sort(this.sort);
- }
-
- this.suggestions = this.suggestions.slice(0, this.max_items);
- this.suggestions.forEach(function (text) {
- return _this2.ul.appendChild(_this2.item(text, value));
- });
-
- if (this.ul.children.length === 0) {
- this.close({
- 'reason': 'nomatches'
- });
- } else {
- this.open();
- }
- } else {
- this.close({
- 'reason': 'nomatches'
- });
- this.auto_completing = false;
- }
- }
- }, {
- key: "list",
- set: function set(list) {
- if (Array.isArray(list) || typeof list === "function") {
- this._list = list;
- } else if (typeof list === "string" && _.includes(list, ",")) {
- this._list = list.split(/\s*,\s*/);
- } else {
- // Element or CSS selector
- list = helpers.getElement(list);
-
- if (list && list.children) {
- var items = [];
- slice.apply(list.children).forEach(function (el) {
- if (!el.disabled) {
- var text = el.textContent.trim(),
+ if (list && list.children) {
+ const items = [];
+ slice.apply(list.children).forEach(function (el) {
+ if (!el.disabled) {
+ const text = el.textContent.trim(),
value = el.value || text,
label = el.label || text;
- if (value !== "") {
- items.push({
- label: label,
- value: value
- });
- }
+ if (value !== "") {
+ items.push({
+ label: label,
+ value: value
+ });
}
- });
- this._list = items;
- }
- }
-
- if (document.activeElement === this.input) {
- this.evaluate();
+ }
+ });
+ this._list = items;
}
}
- }, {
- key: "selected",
- get: function get() {
- return this.index > -1;
- }
- }, {
- key: "opened",
- get: function get() {
- return this.is_opened;
- }
- }]);
- return AutoComplete;
- }(); // Make it an event emitter
+ if (document.activeElement === this.input) {
+ this.evaluate();
+ }
+ }
+
+ get selected() {
+ return this.index > -1;
+ }
+
+ get opened() {
+ return this.is_opened;
+ }
+
+ close(o) {
+ if (!this.opened) {
+ return;
+ }
+
+ this.ul.setAttribute("hidden", "");
+ this.is_opened = false;
+ this.index = -1;
+ this.trigger("suggestion-box-close", o || {});
+ }
+
+ insertValue(suggestion) {
+ let value;
+
+ if (this.match_current_word) {
+ u.replaceCurrentWord(this.input, suggestion.value);
+ } else {
+ this.input.value = suggestion.value;
+ }
+ }
+
+ open() {
+ this.ul.removeAttribute("hidden");
+ this.is_opened = true;
+
+ if (this.auto_first && this.index === -1) {
+ this.goto(0);
+ }
+
+ this.trigger("suggestion-box-open");
+ }
+
+ destroy() {
+ //remove events from the input and its form
+ helpers.unbind(this.input, this._events.input);
+ helpers.unbind(this.input.form, this._events.form); //move the input out of the suggestion-box container and remove the container and its children
+
+ const parentNode = this.container.parentNode;
+ parentNode.insertBefore(this.input, this.container);
+ parentNode.removeChild(this.container); //remove autocomplete and aria-autocomplete attributes
+
+ this.input.removeAttribute("autocomplete");
+ this.input.removeAttribute("aria-autocomplete");
+ }
+
+ next() {
+ const count = this.ul.children.length;
+ this.goto(this.index < count - 1 ? this.index + 1 : count ? 0 : -1);
+ }
+
+ previous() {
+ const count = this.ul.children.length,
+ pos = this.index - 1;
+ this.goto(this.selected && pos !== -1 ? pos : count - 1);
+ }
+
+ goto(i) {
+ // Should not be used directly, highlights specific item without any checks!
+ const list = this.ul.children;
+
+ if (this.selected) {
+ list[this.index].setAttribute("aria-selected", "false");
+ }
+
+ this.index = i;
+
+ if (i > -1 && list.length > 0) {
+ list[i].setAttribute("aria-selected", "true");
+ list[i].focus();
+ this.status.textContent = list[i].textContent; // scroll to highlighted element in case parent's height is fixed
+
+ this.ul.scrollTop = list[i].offsetTop - this.ul.clientHeight + list[i].clientHeight;
+ this.trigger("suggestion-box-highlight", {
+ 'text': this.suggestions[this.index]
+ });
+ }
+ }
+
+ select(selected, origin) {
+ if (selected) {
+ this.index = u.siblingIndex(selected);
+ } else {
+ selected = this.ul.children[this.index];
+ }
+
+ if (selected) {
+ const suggestion = this.suggestions[this.index];
+ this.insertValue(suggestion);
+ this.close({
+ 'reason': 'select'
+ });
+ this.auto_completing = false;
+ this.trigger("suggestion-box-selectcomplete", {
+ 'text': suggestion
+ });
+ }
+ }
+
+ onMouseOver(ev) {
+ const li = u.ancestor(ev.target, 'li');
+
+ if (li) {
+ this.goto(Array.prototype.slice.call(this.ul.children).indexOf(li));
+ }
+ }
+
+ onMouseDown(ev) {
+ if (ev.button !== 0) {
+ return; // Only select on left click
+ }
+
+ const li = u.ancestor(ev.target, 'li');
+
+ if (li) {
+ ev.preventDefault();
+ this.select(li, ev.target);
+ }
+ }
+
+ keyPressed(ev) {
+ if (this.opened) {
+ if (_.includes([_converse.keycodes.ENTER, _converse.keycodes.TAB], ev.keyCode) && this.selected) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ this.select();
+ return true;
+ } else if (ev.keyCode === _converse.keycodes.ESCAPE) {
+ this.close({
+ 'reason': 'esc'
+ });
+ return true;
+ } else if (_.includes([_converse.keycodes.UP_ARROW, _converse.keycodes.DOWN_ARROW], ev.keyCode)) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ this[ev.keyCode === _converse.keycodes.UP_ARROW ? "previous" : "next"]();
+ return true;
+ }
+ }
+
+ if (_.includes([_converse.keycodes.SHIFT, _converse.keycodes.META, _converse.keycodes.META_RIGHT, _converse.keycodes.ESCAPE, _converse.keycodes.ALT], ev.keyCode)) {
+ return;
+ }
+
+ if (this.match_on_tab && ev.keyCode === _converse.keycodes.TAB) {
+ ev.preventDefault();
+ this.auto_completing = true;
+ } else if (this.trigger_on_at && ev.keyCode === _converse.keycodes.AT) {
+ this.auto_completing = true;
+ }
+ }
+
+ evaluate(ev) {
+ const arrow_pressed = ev.keyCode === _converse.keycodes.UP_ARROW || ev.keyCode === _converse.keycodes.DOWN_ARROW;
+
+ if (!this.auto_completing || this.selected && arrow_pressed) {
+ return;
+ }
+
+ const list = typeof this._list === "function" ? this._list() : this._list;
+
+ if (list.length === 0) {
+ return;
+ }
+
+ let value = this.match_current_word ? u.getCurrentWord(this.input) : this.input.value;
+ let ignore_min_chars = false;
+
+ if (this.trigger_on_at && value.startsWith('@')) {
+ ignore_min_chars = true;
+ value = value.slice('1');
+ }
+
+ if (value.length >= this.min_chars || ignore_min_chars) {
+ this.index = -1; // Populate list with options that match
+
+ this.ul.innerHTML = "";
+ this.suggestions = list.map(item => new Suggestion(this.data(item, value))).filter(item => this.filter(item, value));
+
+ if (this.sort !== false) {
+ this.suggestions = this.suggestions.sort(this.sort);
+ }
+
+ this.suggestions = this.suggestions.slice(0, this.max_items);
+ this.suggestions.forEach(text => this.ul.appendChild(this.item(text, value)));
+
+ if (this.ul.children.length === 0) {
+ this.close({
+ 'reason': 'nomatches'
+ });
+ } else {
+ this.open();
+ }
+ } else {
+ this.close({
+ 'reason': 'nomatches'
+ });
+ this.auto_completing = false;
+ }
+ }
+
+ } // Make it an event emitter
_.extend(AutoComplete.prototype, Backbone.Events); // Private functions
function Suggestion(data) {
- var o = Array.isArray(data) ? {
+ const o = Array.isArray(data) ? {
label: data[0],
value: data[1]
- } : _typeof(data) === "object" && "label" in data && "value" in data ? data : {
+ } : typeof data === "object" && "label" in data && "value" in data ? data : {
label: data,
value: data
};
@@ -32290,56 +38449,45 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
var slice = Array.prototype.slice;
- var helpers = {
- getElement: function getElement(expr, el) {
+ const helpers = {
+ getElement(expr, el) {
return typeof expr === "string" ? (el || document).querySelector(expr) : expr || null;
},
- bind: function bind(element, o) {
+
+ bind(element, o) {
if (element) {
- var _loop = function _loop() {
+ for (var event in o) {
if (!Object.prototype.hasOwnProperty.call(o, event)) {
- return "continue";
+ continue;
}
- var callback = o[event];
- event.split(/\s+/).forEach(function (event) {
- return element.addEventListener(event, callback);
- });
- };
-
- for (var event in o) {
- var _ret = _loop();
-
- if (_ret === "continue") continue;
+ const callback = o[event];
+ event.split(/\s+/).forEach(event => element.addEventListener(event, callback));
}
}
},
- unbind: function unbind(element, o) {
+
+ unbind(element, o) {
if (element) {
- var _loop2 = function _loop2() {
+ for (var event in o) {
if (!Object.prototype.hasOwnProperty.call(o, event)) {
- return "continue";
+ continue;
}
- var callback = o[event];
- event.split(/\s+/).forEach(function (event) {
- return element.removeEventListener(event, callback);
- });
- };
-
- for (var event in o) {
- var _ret2 = _loop2();
-
- if (_ret2 === "continue") continue;
+ const callback = o[event];
+ event.split(/\s+/).forEach(event => element.removeEventListener(event, callback));
}
}
},
- regExpEscape: function regExpEscape(s) {
+
+ regExpEscape(s) {
return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
}
+
};
_converse.AutoComplete = AutoComplete;
}
+
});
});
@@ -32352,10 +38500,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -32372,16 +38517,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, muc, tpl_chatroom_bookmark_form, tpl_chatroom_bookmark_toggle, tpl_bookmark, tpl_bookmarks_list) {
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- $iq = _converse$env.$iq,
- b64_sha1 = _converse$env.b64_sha1,
- sizzle = _converse$env.sizzle,
- _ = _converse$env._;
- var u = converse.env.utils;
+})(this, function (converse, muc, tpl_chatroom_bookmark_form, tpl_chatroom_bookmark_toggle, tpl_bookmark, tpl_bookmarks_list) {
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ $iq = _converse$env.$iq,
+ b64_sha1 = _converse$env.b64_sha1,
+ sizzle = _converse$env.sizzle,
+ _ = _converse$env._;
+ const u = converse.env.utils;
converse.plugins.add('converse-bookmarks', {
/* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before
@@ -32404,53 +38549,55 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
events: {
'click .toggle-bookmark': 'toggleBookmark'
},
- initialize: function initialize() {
+
+ initialize() {
this.__super__.initialize.apply(this, arguments);
this.model.on('change:bookmarked', this.onBookmarked, this);
this.setBookmarkState();
},
- renderBookmarkToggle: function renderBookmarkToggle() {
+
+ renderBookmarkToggle() {
if (this.el.querySelector('.chat-head .toggle-bookmark')) {
return;
}
- var _converse = this.__super__._converse,
- __ = _converse.__;
- var bookmark_button = tpl_chatroom_bookmark_toggle(_.assignIn(this.model.toJSON(), {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
+ const bookmark_button = tpl_chatroom_bookmark_toggle(_.assignIn(this.model.toJSON(), {
info_toggle_bookmark: __('Bookmark this groupchat'),
bookmarked: this.model.get('bookmarked')
}));
- var close_button = this.el.querySelector('.close-chatbox-button');
+ const close_button = this.el.querySelector('.close-chatbox-button');
close_button.insertAdjacentHTML('afterend', bookmark_button);
},
- renderHeading: function renderHeading() {
- var _this = this;
+ renderHeading() {
this.__super__.renderHeading.apply(this, arguments);
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
if (_converse.allow_bookmarks) {
- _converse.checkBookmarksSupport().then(function (supported) {
+ _converse.checkBookmarksSupport().then(supported => {
if (supported) {
- _this.renderBookmarkToggle();
+ this.renderBookmarkToggle();
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
},
- checkForReservedNick: function checkForReservedNick() {
+
+ checkForReservedNick() {
/* Check if the user has a bookmark with a saved nickanme
* for this groupchat, and if so use it.
* Otherwise delegate to the super method.
*/
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
if (_.isUndefined(_converse.bookmarks) || !_converse.allow_bookmarks) {
return this.__super__.checkForReservedNick.apply(this, arguments);
}
- var model = _converse.bookmarks.findWhere({
+ const model = _converse.bookmarks.findWhere({
'jid': this.model.get('jid')
});
@@ -32460,8 +38607,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.checkForReservedNick.apply(this, arguments);
}
},
- onBookmarked: function onBookmarked() {
- var icon = this.el.querySelector('.toggle-bookmark');
+
+ onBookmarked() {
+ const icon = this.el.querySelector('.toggle-bookmark');
if (_.isNull(icon)) {
return;
@@ -32473,13 +38621,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
icon.classList.remove('button-on');
}
},
- setBookmarkState: function setBookmarkState() {
+
+ setBookmarkState() {
/* Set whether the groupchat is bookmarked or not.
*/
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
if (!_.isUndefined(_converse.bookmarks)) {
- var models = _converse.bookmarks.where({
+ const models = _converse.bookmarks.where({
'jid': this.model.get('jid')
});
@@ -32490,16 +38639,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
},
- renderBookmarkForm: function renderBookmarkForm() {
- var _this2 = this;
- var _converse = this.__super__._converse,
- __ = _converse.__,
- body = this.el.querySelector('.chatroom-body');
+ renderBookmarkForm() {
+ const _converse = this.__super__._converse,
+ __ = _converse.__,
+ body = this.el.querySelector('.chatroom-body');
- _.each(body.children, function (child) {
- return child.classList.add('hidden');
- });
+ _.each(body.children, child => child.classList.add('hidden'));
_.each(body.querySelectorAll('.chatroom-form-container'), u.removeElement);
@@ -32513,17 +38659,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'label_submit': __('Save'),
'name': this.model.get('name')
}));
- var form = body.querySelector('form.chatroom-form');
- form.addEventListener('submit', function (ev) {
- return _this2.onBookmarkFormSubmitted(ev);
- });
- form.querySelector('.button-cancel').addEventListener('click', function () {
- return _this2.closeForm();
- });
+ const form = body.querySelector('form.chatroom-form');
+ form.addEventListener('submit', ev => this.onBookmarkFormSubmitted(ev));
+ form.querySelector('.button-cancel').addEventListener('click', () => this.closeForm());
},
- onBookmarkFormSubmitted: function onBookmarkFormSubmitted(ev) {
+
+ onBookmarkFormSubmitted(ev) {
ev.preventDefault();
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
_converse.bookmarks.createBookmark({
'jid': this.model.get('jid'),
@@ -32535,15 +38678,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.removeElement(this.el.querySelector('div.chatroom-form-container'));
this.renderAfterTransition();
},
- toggleBookmark: function toggleBookmark(ev) {
+
+ toggleBookmark(ev) {
if (ev) {
ev.preventDefault();
ev.stopPropagation();
}
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
- var models = _converse.bookmarks.where({
+ const models = _converse.bookmarks.where({
'jid': this.model.get('jid')
});
@@ -32557,14 +38701,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.el.querySelector('.toggle-bookmark').classList.remove('button-on');
}
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__; // Configuration values for this plugin
+ const _converse = this._converse,
+ __ = _converse.__; // Configuration values for this plugin
// ====================================
// Refer to docs/source/configuration.rst for explanations of these
// configuration settings.
@@ -32580,13 +38726,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_.extend(_converse, {
- removeBookmarkViaEvent: function removeBookmarkViaEvent(ev) {
+ removeBookmarkViaEvent(ev) {
/* Remove a bookmark as determined by the passed in
* event.
*/
ev.preventDefault();
- var name = ev.target.getAttribute('data-bookmark-name');
- var jid = ev.target.getAttribute('data-room-jid');
+ const name = ev.target.getAttribute('data-bookmark-name');
+ const jid = ev.target.getAttribute('data-room-jid');
if (confirm(__("Are you sure you want to remove the bookmark \"%1$s\"?", name))) {
_.invokeMap(_converse.bookmarks.where({
@@ -32594,41 +38740,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}), Backbone.Model.prototype.destroy);
}
},
- addBookmarkViaEvent: function addBookmarkViaEvent(ev) {
+
+ addBookmarkViaEvent(ev) {
/* Add a bookmark as determined by the passed in
* event.
*/
ev.preventDefault();
- var jid = ev.target.getAttribute('data-room-jid');
+ const jid = ev.target.getAttribute('data-room-jid');
- var chatroom = _converse.api.rooms.open(jid, {
+ const chatroom = _converse.api.rooms.open(jid, {
'bring_to_foreground': true
});
_converse.chatboxviews.get(jid).renderBookmarkForm();
}
+
});
_converse.Bookmark = Backbone.Model;
_converse.Bookmarks = Backbone.Collection.extend({
model: _converse.Bookmark,
- comparator: function comparator(item) {
- return item.get('name').toLowerCase();
- },
- initialize: function initialize() {
+ comparator: item => item.get('name').toLowerCase(),
+
+ initialize() {
this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked));
this.on('remove', this.markRoomAsUnbookmarked, this);
this.on('remove', this.sendBookmarkStanza, this);
- var storage = _converse.config.get('storage'),
- cache_key = "converse.room-bookmarks".concat(_converse.bare_jid);
+ const storage = _converse.config.get('storage'),
+ cache_key = `converse.room-bookmarks${_converse.bare_jid}`;
this.fetched_flag = b64_sha1(cache_key + 'fetched');
this.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1(cache_key));
},
- openBookmarkedRoom: function openBookmarkedRoom(bookmark) {
+
+ openBookmarkedRoom(bookmark) {
if (bookmark.get('autojoin')) {
- var groupchat = _converse.api.rooms.create(bookmark.get('jid'), bookmark.get('nick'));
+ const groupchat = _converse.api.rooms.create(bookmark.get('jid'), bookmark.get('nick'));
if (!groupchat.get('hidden')) {
groupchat.trigger('show');
@@ -32637,8 +38785,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return bookmark;
},
- fetchBookmarks: function fetchBookmarks() {
- var deferred = u.getResolveablePromise();
+
+ fetchBookmarks() {
+ const deferred = u.getResolveablePromise();
if (this.browserStorage.records.length > 0) {
this.fetch({
@@ -32657,19 +38806,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return deferred;
},
- onCachedBookmarksFetched: function onCachedBookmarksFetched(deferred) {
+
+ onCachedBookmarksFetched(deferred) {
return deferred.resolve();
},
- createBookmark: function createBookmark(options) {
- var _this3 = this;
+ createBookmark(options) {
this.create(options);
- this.sendBookmarkStanza().catch(function (iq) {
- return _this3.onBookmarkError(iq, options);
- });
+ this.sendBookmarkStanza().catch(iq => this.onBookmarkError(iq, options));
},
- sendBookmarkStanza: function sendBookmarkStanza() {
- var stanza = $iq({
+
+ sendBookmarkStanza() {
+ const stanza = $iq({
'type': 'set',
'from': _converse.connection.jid
}).c('pubsub', {
@@ -32681,7 +38829,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}).c('storage', {
'xmlns': 'storage:bookmarks'
});
- this.each(function (model) {
+ this.each(model => {
stanza.c('conference', {
'name': model.get('name'),
'autojoin': model.get('autojoin'),
@@ -32702,7 +38850,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}).c('value').t('whitelist');
return _converse.api.sendIQ(stanza);
},
- onBookmarkError: function onBookmarkError(iq, options) {
+
+ onBookmarkError(iq, options) {
_converse.log("Error while trying to add bookmark", Strophe.LogLevel.ERROR);
_converse.log(iq);
@@ -32713,10 +38862,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'jid': options.jid
}).destroy();
},
- fetchBookmarksFromServer: function fetchBookmarksFromServer(deferred) {
- var _this4 = this;
- var stanza = $iq({
+ fetchBookmarksFromServer(deferred) {
+ const stanza = $iq({
'from': _converse.connection.jid,
'type': 'get'
}).c('pubsub', {
@@ -32725,35 +38873,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'node': 'storage:bookmarks'
});
- _converse.api.sendIQ(stanza).then(function (iq) {
- return _this4.onBookmarksReceived(deferred, iq);
- }).catch(function (iq) {
- return _this4.onBookmarksReceivedError(deferred, iq);
- });
+ _converse.api.sendIQ(stanza).then(iq => this.onBookmarksReceived(deferred, iq)).catch(iq => this.onBookmarksReceivedError(deferred, iq));
},
- markRoomAsBookmarked: function markRoomAsBookmarked(bookmark) {
- var groupchat = _converse.chatboxes.get(bookmark.get('jid'));
+
+ markRoomAsBookmarked(bookmark) {
+ const groupchat = _converse.chatboxes.get(bookmark.get('jid'));
if (!_.isUndefined(groupchat)) {
groupchat.save('bookmarked', true);
}
},
- markRoomAsUnbookmarked: function markRoomAsUnbookmarked(bookmark) {
- var groupchat = _converse.chatboxes.get(bookmark.get('jid'));
+
+ markRoomAsUnbookmarked(bookmark) {
+ const groupchat = _converse.chatboxes.get(bookmark.get('jid'));
if (!_.isUndefined(groupchat)) {
groupchat.save('bookmarked', false);
}
},
- createBookmarksFromStanza: function createBookmarksFromStanza(stanza) {
- var _this5 = this;
- var bookmarks = sizzle('items[node="storage:bookmarks"] ' + 'item#current ' + 'storage[xmlns="storage:bookmarks"] ' + 'conference', stanza);
+ createBookmarksFromStanza(stanza) {
+ const bookmarks = sizzle('items[node="storage:bookmarks"] ' + 'item#current ' + 'storage[xmlns="storage:bookmarks"] ' + 'conference', stanza);
- _.forEach(bookmarks, function (bookmark) {
- var jid = bookmark.getAttribute('jid');
-
- _this5.create({
+ _.forEach(bookmarks, bookmark => {
+ const jid = bookmark.getAttribute('jid');
+ this.create({
'jid': jid,
'name': bookmark.getAttribute('name') || jid,
'autojoin': bookmark.getAttribute('autojoin') === 'true',
@@ -32761,14 +38905,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
},
- onBookmarksReceived: function onBookmarksReceived(deferred, iq) {
+
+ onBookmarksReceived(deferred, iq) {
this.createBookmarksFromStanza(iq);
if (!_.isUndefined(deferred)) {
return deferred.resolve();
}
},
- onBookmarksReceivedError: function onBookmarksReceivedError(deferred, iq) {
+
+ onBookmarksReceivedError(deferred, iq) {
window.sessionStorage.setItem(this.fetched_flag, true);
_converse.log('Error while fetching bookmarks', Strophe.LogLevel.WARN);
@@ -32785,6 +38931,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
}
+
});
_converse.BookmarksList = Backbone.Model.extend({
defaults: {
@@ -32792,7 +38939,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
});
_converse.BookmarkView = Backbone.VDOMView.extend({
- toHTML: function toHTML() {
+ toHTML() {
return tpl_bookmark({
'hidden': _converse.hide_open_bookmarks && _converse.chatboxes.where({
'jid': this.model.get('jid')
@@ -32807,6 +38954,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'open_title': __('Click to open this groupchat')
});
}
+
});
_converse.BookmarksView = Backbone.OrderedListView.extend({
tagName: 'div',
@@ -32820,7 +38968,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
listSelector: '.rooms-list',
ItemView: _converse.BookmarkView,
subviewIndex: 'jid',
- initialize: function initialize() {
+
+ initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.showOrHide, this);
this.model.on('remove', this.showOrHide, this);
@@ -32829,8 +38978,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.chatboxes.on('remove', this.renderBookmarkListElement, this);
- var storage = _converse.config.get('storage'),
- id = b64_sha1("converse.room-bookmarks".concat(_converse.bare_jid, "-list-model"));
+ const storage = _converse.config.get('storage'),
+ id = b64_sha1(`converse.room-bookmarks${_converse.bare_jid}-list-model`);
this.list_model = new _converse.BookmarksList({
'id': id
@@ -32840,7 +38989,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.render();
this.sortAndPositionAllItems();
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_bookmarks_list({
'toggle_state': this.list_model.get('toggle-state'),
'desc_bookmarks': __('Click to toggle the bookmarks list'),
@@ -32851,31 +39001,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertIntoControlBox();
return this;
},
- insertIntoControlBox: function insertIntoControlBox() {
- var controlboxview = _converse.chatboxviews.get('controlbox');
+
+ insertIntoControlBox() {
+ const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview) && !u.rootContains(_converse.root, this.el)) {
- var el = controlboxview.el.querySelector('.bookmarks-list');
+ const el = controlboxview.el.querySelector('.bookmarks-list');
if (!_.isNull(el)) {
el.parentNode.replaceChild(this.el, el);
}
}
},
- openRoom: function openRoom(ev) {
+
+ openRoom(ev) {
ev.preventDefault();
- var name = ev.target.textContent;
- var jid = ev.target.getAttribute('data-room-jid');
- var data = {
+ const name = ev.target.textContent;
+ const jid = ev.target.getAttribute('data-room-jid');
+ const data = {
'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)) || jid
};
_converse.api.rooms.open(jid, data);
},
+
removeBookmark: _converse.removeBookmarkViaEvent,
addBookmark: _converse.addBookmarkViaEvent,
- renderBookmarkListElement: function renderBookmarkListElement(chatbox) {
- var bookmarkview = this.get(chatbox.get('jid'));
+
+ renderBookmarkListElement(chatbox) {
+ const bookmarkview = this.get(chatbox.get('jid'));
if (_.isNil(bookmarkview)) {
// A chat box has been closed, but we don't have a
@@ -32886,11 +39040,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
bookmarkview.render();
this.showOrHide();
},
- showOrHide: function showOrHide(item) {
+
+ showOrHide(item) {
if (_converse.hide_open_bookmarks) {
- var bookmarks = this.model.filter(function (bookmark) {
- return !_converse.chatboxes.get(bookmark.get('jid'));
- });
+ const bookmarks = this.model.filter(bookmark => !_converse.chatboxes.get(bookmark.get('jid')));
if (!bookmarks.length) {
u.hideElement(this.el);
@@ -32902,12 +39055,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.showElement(this.el);
}
},
- toggleBookmarksList: function toggleBookmarksList(ev) {
+
+ toggleBookmarksList(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var icon_el = ev.target.querySelector('.fa');
+ const icon_el = ev.target.querySelector('.fa');
if (u.hasClass('fa-caret-down', icon_el)) {
u.slideIn(this.el.querySelector('.bookmarks'));
@@ -32925,31 +39079,30 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
}
+
});
_converse.checkBookmarksSupport = function () {
- return new Promise(function (resolve, reject) {
- Promise.all([_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid), _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', _converse.bare_jid)]).then(function (args) {
+ return new Promise((resolve, reject) => {
+ Promise.all([_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid), _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', _converse.bare_jid)]).then(args => {
resolve(args[0] && (args[1].length || _converse.allow_public_bookmarks));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
};
- var initBookmarks = function initBookmarks() {
+ const initBookmarks = function initBookmarks() {
if (!_converse.allow_bookmarks) {
return;
}
- _converse.checkBookmarksSupport().then(function (supported) {
+ _converse.checkBookmarksSupport().then(supported => {
if (supported) {
_converse.bookmarks = new _converse.Bookmarks();
_converse.bookmarksview = new _converse.BookmarksView({
'model': _converse.bookmarks
});
- _converse.bookmarks.fetchBookmarks().catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)).then(function () {
- return _converse.emit('bookmarksInitialized');
- });
+ _converse.bookmarks.fetchBookmarks().catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)).then(() => _converse.emit('bookmarksInitialized'));
} else {
_converse.emit('bookmarksInitialized');
}
@@ -32964,7 +39117,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'event': 'roomsPanelRendered'
}], initBookmarks);
- _converse.on('clearSession', function () {
+ _converse.on('clearSession', () => {
if (!_.isUndefined(_converse.bookmarks)) {
_converse.bookmarks.browserStorage._clear();
@@ -32974,18 +39127,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.on('reconnected', initBookmarks);
- _converse.on('connected', function () {
+ _converse.on('connected', () => {
// Add a handler for bookmarks pushed from other connected clients
// (from the same user obviously)
- _converse.connection.addHandler(function (message) {
+ _converse.connection.addHandler(message => {
if (sizzle('event[xmlns="' + Strophe.NS.PUBSUB + '#event"] items[node="storage:bookmarks"]', message).length) {
- _converse.api.waitUntil('bookmarksInitialized').then(function () {
- return _converse.bookmarks.createBookmarksFromStanza(message);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ _converse.api.waitUntil('bookmarksInitialized').then(() => _converse.bookmarks.createBookmarksFromStanza(message)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
}, null, 'message', 'headline', null, _converse.bare_jid);
});
}
+
});
});
@@ -32998,10 +39150,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -33011,23 +39160,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- $build = _converse$env.$build,
- _ = _converse$env._,
- b64_sha1 = _converse$env.b64_sha1;
+})(this, function (converse) {
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ $build = _converse$env.$build,
+ _ = _converse$env._,
+ b64_sha1 = _converse$env.b64_sha1;
Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps");
function propertySort(array, property) {
- return array.sort(function (a, b) {
+ return array.sort((a, b) => {
return a[property] > b[property] ? -1 : 1;
});
}
function generateVerificationString(_converse) {
- var identities = _converse.api.disco.own.identities.get(),
- features = _converse.api.disco.own.features.get();
+ const identities = _converse.api.disco.own.identities.get(),
+ features = _converse.api.disco.own.features.get();
if (identities.length > 1) {
propertySort(identities, "category");
@@ -33035,14 +39184,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
propertySort(identities, "lang");
}
- var S = _.reduce(identities, function (result, id) {
- return "".concat(result).concat(id.category, "/").concat(id.type, "/").concat(_.get(id, 'lang', ''), "/").concat(id.name, "<");
- }, "");
+ let S = _.reduce(identities, (result, id) => `${result}${id.category}/${id.type}/${_.get(id, 'lang', '')}/${id.name}<`, "");
features.sort();
- S = _.reduce(features, function (result, feature) {
- return "".concat(result).concat(feature, "<");
- }, S);
+ S = _.reduce(features, (result, feature) => `${result}${feature}<`, S);
return b64_sha1(S);
}
@@ -33061,12 +39206,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
XMPPStatus: {
- constructPresence: function constructPresence() {
- var presence = this.__super__.constructPresence.apply(this, arguments);
+ constructPresence() {
+ const presence = this.__super__.constructPresence.apply(this, arguments);
presence.root().cnode(createCapsNode(this.__super__._converse));
return presence;
}
+
}
}
});
@@ -33081,10 +39227,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -33094,45 +39237,47 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, filesize) {
+})(this, function (converse, filesize) {
"use strict";
- var _converse$env = converse.env,
- $msg = _converse$env.$msg,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- b64_sha1 = _converse$env.b64_sha1,
- moment = _converse$env.moment,
- sizzle = _converse$env.sizzle,
- utils = _converse$env.utils,
- _ = _converse$env._;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ $msg = _converse$env.$msg,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ b64_sha1 = _converse$env.b64_sha1,
+ moment = _converse$env.moment,
+ sizzle = _converse$env.sizzle,
+ utils = _converse$env.utils,
+ _ = _converse$env._;
+ const u = converse.env.utils;
Strophe.addNamespace('MESSAGE_CORRECT', 'urn:xmpp:message-correct:0');
Strophe.addNamespace('REFERENCE', 'urn:xmpp:reference:0');
converse.plugins.add('converse-chatboxes', {
dependencies: ["converse-roster", "converse-vcard"],
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__; // Configuration values for this plugin
+ const _converse = this._converse,
+ __ = _converse.__; // Configuration values for this plugin
// ====================================
// Refer to docs/source/configuration.rst for explanations of these
// configuration settings.
_converse.api.settings.update({
- 'filter_by_resource': false,
'auto_join_private_chats': [],
- 'forward_messages': false
+ 'filter_by_resource': false,
+ 'forward_messages': false,
+ 'send_chat_state_notifications': true
});
_converse.api.promises.add(['chatBoxesFetched', 'chatBoxesInitialized', 'privateChatsAutoJoined']);
function openChat(jid) {
if (!utils.isValidJID(jid)) {
- return _converse.log("Invalid JID \"".concat(jid, "\" provided in URL fragment"), Strophe.LogLevel.WARN);
+ return _converse.log(`Invalid JID "${jid}" provided in URL fragment`, Strophe.LogLevel.WARN);
}
_converse.api.chats.open(jid);
@@ -33141,13 +39286,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.router.route('converse/chat?jid=:jid', openChat);
_converse.Message = Backbone.Model.extend({
- defaults: function defaults() {
+ defaults() {
return {
'msgid': _converse.connection.getUniqueId(),
'time': moment().format()
};
},
- initialize: function initialize() {
+
+ initialize() {
this.setVCard();
if (this.get('file')) {
@@ -33162,14 +39308,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
window.setTimeout(this.destroy.bind(this), 20000);
}
},
- getVCardForChatroomOccupant: function getVCardForChatroomOccupant() {
- var chatbox = this.collection.chatbox,
- nick = Strophe.getResourceFromJid(this.get('from'));
+
+ getVCardForChatroomOccupant() {
+ const chatbox = this.collection.chatbox,
+ nick = Strophe.getResourceFromJid(this.get('from'));
if (chatbox.get('nick') === nick) {
return _converse.xmppstatus.vcard;
} else {
- var vcard;
+ let vcard;
if (this.get('vcard_jid')) {
vcard = _converse.vcards.findWhere({
@@ -33178,8 +39325,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
if (!vcard) {
- var jid;
- var occupant = chatbox.occupants.findWhere({
+ let jid;
+ const occupant = chatbox.occupants.findWhere({
'nick': nick
});
@@ -33204,13 +39351,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return vcard;
}
},
- setVCard: function setVCard() {
+
+ setVCard() {
if (this.get('type') === 'error') {
return;
} else if (this.get('type') === 'groupchat') {
this.vcard = this.getVCardForChatroomOccupant();
} else {
- var jid = this.get('from');
+ const jid = this.get('from');
this.vcard = _converse.vcards.findWhere({
'jid': jid
}) || _converse.vcards.create({
@@ -33218,28 +39366,29 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
},
- isOnlyChatStateNotification: function isOnlyChatStateNotification() {
+
+ isOnlyChatStateNotification() {
return u.isOnlyChatStateNotification(this);
},
- getDisplayName: function getDisplayName() {
+
+ getDisplayName() {
if (this.get('type') === 'groupchat') {
return this.get('nick');
} else {
return this.vcard.get('fullname') || this.get('from');
}
},
- sendSlotRequestStanza: function sendSlotRequestStanza() {
- var _this = this;
+ sendSlotRequestStanza() {
/* Send out an IQ stanza to request a file upload slot.
*
* https://xmpp.org/extensions/xep-0363.html#request
*/
- var file = this.get('file');
- return new Promise(function (resolve, reject) {
- var iq = converse.env.$iq({
+ const file = this.get('file');
+ return new Promise((resolve, reject) => {
+ const iq = converse.env.$iq({
'from': _converse.jid,
- 'to': _this.get('slot_request_url'),
+ 'to': this.get('slot_request_url'),
'type': 'get'
}).c('request', {
'xmlns': Strophe.NS.HTTPUPLOAD,
@@ -33251,46 +39400,44 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.connection.sendIQ(iq, resolve, reject);
});
},
- getRequestSlotURL: function getRequestSlotURL() {
- var _this2 = this;
- this.sendSlotRequestStanza().then(function (stanza) {
- var slot = stanza.querySelector('slot');
+ getRequestSlotURL() {
+ this.sendSlotRequestStanza().then(stanza => {
+ const slot = stanza.querySelector('slot');
if (slot) {
- _this2.save({
+ this.save({
'get': slot.querySelector('get').getAttribute('url'),
'put': slot.querySelector('put').getAttribute('url')
});
} else {
- return _this2.save({
+ return this.save({
'type': 'error',
'message': __("Sorry, could not determine file upload URL.")
});
}
- }).catch(function (e) {
+ }).catch(e => {
_converse.log(e, Strophe.LogLevel.ERROR);
- return _this2.save({
+ return this.save({
'type': 'error',
'message': __("Sorry, could not determine upload URL.")
});
});
},
- uploadFile: function uploadFile() {
- var _this3 = this;
- var xhr = new XMLHttpRequest();
+ uploadFile() {
+ const xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function () {
+ xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
_converse.log("Status: " + xhr.status, Strophe.LogLevel.INFO);
if (xhr.status === 200 || xhr.status === 201) {
- _this3.save({
+ this.save({
'upload': _converse.SUCCESS,
- 'oob_url': _this3.get('get'),
- 'message': _this3.get('get')
+ 'oob_url': this.get('get'),
+ 'message': this.get('get')
});
} else {
xhr.onerror();
@@ -33298,14 +39445,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
};
- xhr.upload.addEventListener("progress", function (evt) {
+ xhr.upload.addEventListener("progress", evt => {
if (evt.lengthComputable) {
- _this3.set('progress', evt.loaded / evt.total);
+ this.set('progress', evt.loaded / evt.total);
}
}, false);
- xhr.onerror = function () {
- var message;
+ xhr.onerror = () => {
+ let message;
if (xhr.responseText) {
message = __('Sorry, could not succesfully upload your file. Your server’s response: "%1$s"', xhr.responseText);
@@ -33313,7 +39460,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
message = __('Sorry, could not succesfully upload your file.');
}
- _this3.save({
+ this.save({
'type': 'error',
'upload': _converse.FAILURE,
'message': message
@@ -33324,13 +39471,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
xhr.setRequestHeader("Content-type", this.get('file').type);
xhr.send(this.get('file'));
}
+
});
_converse.Messages = Backbone.Collection.extend({
model: _converse.Message,
comparator: 'time'
});
_converse.ChatBox = _converse.ModelWithVCardAndPresence.extend({
- defaults: function defaults() {
+ defaults() {
return {
'bookmarked': false,
'chat_state': undefined,
@@ -33341,26 +39489,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'hidden': _.includes(['mobile', 'fullscreen'], _converse.view_mode)
};
},
- initialize: function initialize() {
- var _this4 = this;
+ initialize() {
_converse.ModelWithVCardAndPresence.prototype.initialize.apply(this, arguments);
- _converse.api.waitUntil('rosterContactsFetched').then(function () {
- _this4.addRelatedContact(_converse.roster.findWhere({
- 'jid': _this4.get('jid')
+ _converse.api.waitUntil('rosterContactsFetched').then(() => {
+ this.addRelatedContact(_converse.roster.findWhere({
+ 'jid': this.get('jid')
}));
});
this.messages = new _converse.Messages();
- var storage = _converse.config.get('storage');
+ const storage = _converse.config.get('storage');
- this.messages.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1("converse.messages".concat(this.get('jid')).concat(_converse.bare_jid)));
+ this.messages.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1(`converse.messages${this.get('jid')}${_converse.bare_jid}`));
this.messages.chatbox = this;
- this.messages.on('change:upload', function (message) {
+ this.messages.on('change:upload', message => {
if (message.get('upload') === _converse.SUCCESS) {
- _this4.sendMessageStanza(_this4.createMessageStanza(message));
+ this.sendMessageStanza(this.createMessageStanza(message));
}
});
this.on('change:chat_state', this.sendChatState, this);
@@ -33372,22 +39519,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'user_id': Strophe.getNodeFromJid(this.get('jid'))
});
},
- addRelatedContact: function addRelatedContact(contact) {
+
+ addRelatedContact(contact) {
if (!_.isUndefined(contact)) {
this.contact = contact;
this.trigger('contactAdded', contact);
}
},
- getDisplayName: function getDisplayName() {
+
+ getDisplayName() {
return this.vcard.get('fullname') || this.get('jid');
},
- handleMessageCorrection: function handleMessageCorrection(stanza) {
- var replace = sizzle("replace[xmlns=\"".concat(Strophe.NS.MESSAGE_CORRECT, "\"]"), stanza).pop();
+
+ handleMessageCorrection(stanza) {
+ const replace = sizzle(`replace[xmlns="${Strophe.NS.MESSAGE_CORRECT}"]`, stanza).pop();
if (replace) {
- var msgid = replace && replace.getAttribute('id') || stanza.getAttribute('id'),
- message = msgid && this.messages.findWhere({
- msgid: msgid
+ const msgid = replace && replace.getAttribute('id') || stanza.getAttribute('id'),
+ message = msgid && this.messages.findWhere({
+ msgid
});
if (!message) {
@@ -33398,27 +39548,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
}
- var older_versions = message.get('older_versions') || [];
+ const older_versions = message.get('older_versions') || [];
older_versions.push(message.get('message'));
message.save({
'message': _converse.chatboxes.getMessageBody(stanza),
'references': this.getReferencesFromStanza(stanza),
'older_versions': older_versions,
- 'edited': true
+ 'edited': moment().format()
});
return true;
}
return false;
},
- createMessageStanza: function createMessageStanza(message) {
+
+ createMessageStanza(message) {
/* Given a _converse.Message Backbone.Model, return the XML
* stanza that represents it.
*
* Parameters:
* (Object) message - The Backbone.Model representing the message
*/
- var stanza = $msg({
+ const stanza = $msg({
'from': _converse.connection.jid,
'to': this.get('jid'),
'type': this.get('message_type'),
@@ -33439,8 +39590,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
- (message.get('references') || []).forEach(function (reference) {
- var attrs = {
+ (message.get('references') || []).forEach(reference => {
+ const attrs = {
'xmlns': Strophe.NS.REFERENCE,
'begin': reference.begin,
'end': reference.end,
@@ -33469,7 +39620,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return stanza;
},
- sendMessageStanza: function sendMessageStanza(stanza) {
+
+ sendMessageStanza(stanza) {
_converse.connection.send(stanza);
if (_converse.forward_messages) {
@@ -33485,8 +39637,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}).up().cnode(stanza.tree()));
}
},
- getOutgoingMessageAttributes: function getOutgoingMessageAttributes(text, spoiler_hint) {
- var is_spoiler = this.get('composing_spoiler');
+
+ getOutgoingMessageAttributes(text, spoiler_hint) {
+ const is_spoiler = this.get('composing_spoiler');
return _.extend(this.toJSON(), {
'id': _converse.connection.getUniqueId(),
'fullname': _converse.xmppstatus.get('fullname'),
@@ -33499,20 +39652,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'type': this.get('message_type')
});
},
- sendMessage: function sendMessage(attrs) {
+
+ sendMessage(attrs) {
/* Responsible for sending off a text message.
*
* Parameters:
* (Message) message - The chat message
*/
- var message = this.messages.findWhere('correcting');
+ let message = this.messages.findWhere('correcting');
if (message) {
- var older_versions = message.get('older_versions') || [];
+ const older_versions = message.get('older_versions') || [];
older_versions.push(message.get('message'));
message.save({
'correcting': false,
- 'edited': true,
+ 'edited': moment().format(),
'message': attrs.message,
'older_versions': older_versions,
'references': attrs.references
@@ -33523,53 +39677,54 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.sendMessageStanza(this.createMessageStanza(message));
},
- sendChatState: function sendChatState() {
+
+ sendChatState() {
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
* See XEP-0085 Chat State Notifications.
*/
- _converse.connection.send($msg({
- 'to': this.get('jid'),
- 'type': 'chat'
- }).c(this.get('chat_state'), {
- 'xmlns': Strophe.NS.CHATSTATES
- }).up().c('no-store', {
- 'xmlns': Strophe.NS.HINTS
- }).up().c('no-permanent-store', {
- 'xmlns': Strophe.NS.HINTS
- }));
+ if (_converse.send_chat_state_notifications) {
+ _converse.connection.send($msg({
+ 'to': this.get('jid'),
+ 'type': 'chat'
+ }).c(this.get('chat_state'), {
+ 'xmlns': Strophe.NS.CHATSTATES
+ }).up().c('no-store', {
+ 'xmlns': Strophe.NS.HINTS
+ }).up().c('no-permanent-store', {
+ 'xmlns': Strophe.NS.HINTS
+ }));
+ }
},
- sendFiles: function sendFiles(files) {
- var _this5 = this;
- _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then(function (result) {
- var item = result.pop(),
- data = item.dataforms.where({
+ sendFiles(files) {
+ _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then(result => {
+ const item = result.pop(),
+ data = item.dataforms.where({
'FORM_TYPE': {
'value': Strophe.NS.HTTPUPLOAD,
'type': "hidden"
}
}).pop(),
- max_file_size = window.parseInt(_.get(data, 'attributes.max-file-size.value')),
- slot_request_url = _.get(item, 'id');
+ max_file_size = window.parseInt(_.get(data, 'attributes.max-file-size.value')),
+ slot_request_url = _.get(item, 'id');
if (!slot_request_url) {
- _this5.messages.create({
+ this.messages.create({
'message': __("Sorry, looks like file upload is not supported by your server."),
'type': 'error'
});
-
return;
}
- _.each(files, function (file) {
+ _.each(files, file => {
if (!window.isNaN(max_file_size) && window.parseInt(file.size) > max_file_size) {
- return _this5.messages.create({
+ return this.messages.create({
'message': __('The size of your file, %1$s, exceeds the maximum allowed by your server, which is %2$s.', file.name, filesize(max_file_size)),
'type': 'error'
});
} else {
- _this5.messages.create(_.extend(_this5.getOutgoingMessageAttributes(), {
+ this.messages.create(_.extend(this.getOutgoingMessageAttributes(), {
'file': file,
'progress': 0,
'slot_request_url': slot_request_url
@@ -33578,12 +39733,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- getReferencesFromStanza: function getReferencesFromStanza(stanza) {
- var text = _.propertyOf(stanza.querySelector('body'))('textContent');
- return sizzle("reference[xmlns=\"".concat(Strophe.NS.REFERENCE, "\"]"), stanza).map(function (ref) {
- var begin = ref.getAttribute('begin'),
- end = ref.getAttribute('end');
+ getReferencesFromStanza(stanza) {
+ const text = _.propertyOf(stanza.querySelector('body'))('textContent');
+
+ return sizzle(`reference[xmlns="${Strophe.NS.REFERENCE}"]`, stanza).map(ref => {
+ const begin = ref.getAttribute('begin'),
+ end = ref.getAttribute('end');
return {
'begin': begin,
'end': end,
@@ -33593,7 +39749,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
});
},
- getMessageAttributesFromStanza: function getMessageAttributesFromStanza(stanza, original_stanza) {
+
+ getMessageAttributesFromStanza(stanza, original_stanza) {
/* Parses a passed in message stanza and returns an object
* of attributes.
*
@@ -33605,12 +39762,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* that contains the message stanza, if it was
* contained, otherwise it's the message stanza itself.
*/
- var archive = sizzle("result[xmlns=\"".concat(Strophe.NS.MAM, "\"]"), original_stanza).pop(),
- spoiler = sizzle("spoiler[xmlns=\"".concat(Strophe.NS.SPOILER, "\"]"), original_stanza).pop(),
- delay = sizzle("delay[xmlns=\"".concat(Strophe.NS.DELAY, "\"]"), original_stanza).pop(),
- chat_state = stanza.getElementsByTagName(_converse.COMPOSING).length && _converse.COMPOSING || stanza.getElementsByTagName(_converse.PAUSED).length && _converse.PAUSED || stanza.getElementsByTagName(_converse.INACTIVE).length && _converse.INACTIVE || stanza.getElementsByTagName(_converse.ACTIVE).length && _converse.ACTIVE || stanza.getElementsByTagName(_converse.GONE).length && _converse.GONE;
+ const archive = sizzle(`result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).pop(),
+ spoiler = sizzle(`spoiler[xmlns="${Strophe.NS.SPOILER}"]`, original_stanza).pop(),
+ delay = sizzle(`delay[xmlns="${Strophe.NS.DELAY}"]`, original_stanza).pop(),
+ chat_state = stanza.getElementsByTagName(_converse.COMPOSING).length && _converse.COMPOSING || stanza.getElementsByTagName(_converse.PAUSED).length && _converse.PAUSED || stanza.getElementsByTagName(_converse.INACTIVE).length && _converse.INACTIVE || stanza.getElementsByTagName(_converse.ACTIVE).length && _converse.ACTIVE || stanza.getElementsByTagName(_converse.GONE).length && _converse.GONE;
- var attrs = {
+ const attrs = {
'chat_state': chat_state,
'is_archived': !_.isNil(archive),
'is_delayed': !_.isNil(delay),
@@ -33638,7 +39795,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
- _.each(sizzle("x[xmlns=\"".concat(Strophe.NS.OUTOFBAND, "\"]"), stanza), function (xform) {
+ _.each(sizzle(`x[xmlns="${Strophe.NS.OUTOFBAND}"]`, stanza), xform => {
attrs['oob_url'] = xform.querySelector('url').textContent;
attrs['oob_desc'] = xform.querySelector('url').textContent;
});
@@ -33649,20 +39806,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return attrs;
},
- createMessage: function createMessage(message, original_stanza) {
+
+ createMessage(message, original_stanza) {
/* Create a Backbone.Message object inside this chat box
* based on the identified message stanza.
*/
- var that = this;
+ const that = this;
function _create(attrs) {
- var is_csn = u.isOnlyChatStateNotification(attrs);
+ const is_csn = u.isOnlyChatStateNotification(attrs);
if (is_csn && (attrs.is_delayed || attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == that.get('nick'))) {
// XXX: MUC leakage
// No need showing delayed or our own CSN messages
return;
- } else if (!is_csn && !attrs.file && !attrs.message && !attrs.oob_url && attrs.type !== 'error') {
+ } else if (!is_csn && !attrs.file && !attrs.plaintext && !attrs.message && !attrs.oob_url && attrs.type !== 'error') {
// TODO: handle messages (currently being done by ChatRoom)
return;
} else {
@@ -33670,27 +39828,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
- var result = this.getMessageAttributesFromStanza(message, original_stanza);
+ const result = this.getMessageAttributesFromStanza(message, original_stanza);
if (typeof result.then === "function") {
- return new Promise(function (resolve, reject) {
- return result.then(function (attrs) {
- return resolve(_create(attrs));
- });
- });
+ return new Promise((resolve, reject) => result.then(attrs => resolve(_create(attrs))));
} else {
- var _message = _create(result);
+ const message = _create(result);
- return Promise.resolve(_message);
+ return Promise.resolve(message);
}
},
- isHidden: function isHidden() {
+
+ isHidden() {
/* Returns a boolean to indicate whether a newly received
* message will be visible to the user or not.
*/
return this.get('hidden') || this.get('minimized') || this.isScrolledUp() || _converse.windowState === 'hidden';
},
- incrementUnreadMsgCounter: function incrementUnreadMsgCounter(message) {
+
+ incrementUnreadMsgCounter(message) {
/* Given a newly received message, update the unread counter if
* necessary.
*/
@@ -33710,68 +39866,71 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.incrementMsgCounter();
}
},
- clearUnreadMsgCounter: function clearUnreadMsgCounter() {
+
+ clearUnreadMsgCounter() {
u.safeSave(this, {
'num_unread': 0
});
},
- isScrolledUp: function isScrolledUp() {
+
+ isScrolledUp() {
return this.get('scrolled', true);
}
+
});
_converse.ChatBoxes = Backbone.Collection.extend({
comparator: 'time_opened',
- model: function model(attrs, options) {
+
+ model(attrs, options) {
return new _converse.ChatBox(attrs, options);
},
- registerMessageHandler: function registerMessageHandler() {
- var _this6 = this;
-
- _converse.connection.addHandler(function (stanza) {
- _this6.onMessage(stanza);
+ registerMessageHandler() {
+ _converse.connection.addHandler(stanza => {
+ this.onMessage(stanza);
return true;
}, null, 'message', 'chat');
- _converse.connection.addHandler(function (stanza) {
- _this6.onErrorMessage(stanza);
-
+ _converse.connection.addHandler(stanza => {
+ this.onErrorMessage(stanza);
return true;
}, null, 'message', 'error');
},
- chatBoxMayBeShown: function chatBoxMayBeShown(chatbox) {
+
+ chatBoxMayBeShown(chatbox) {
return true;
},
- onChatBoxesFetched: function onChatBoxesFetched(collection) {
- var _this7 = this;
+ onChatBoxesFetched(collection) {
/* Show chat boxes upon receiving them from sessionStorage */
- collection.each(function (chatbox) {
- if (_this7.chatBoxMayBeShown(chatbox)) {
+ collection.each(chatbox => {
+ if (this.chatBoxMayBeShown(chatbox)) {
chatbox.trigger('show');
}
});
_converse.emit('chatBoxesFetched');
},
- onConnected: function onConnected() {
- this.browserStorage = new Backbone.BrowserStorage.session("converse.chatboxes-".concat(_converse.bare_jid));
+
+ onConnected() {
+ this.browserStorage = new Backbone.BrowserStorage.session(`converse.chatboxes-${_converse.bare_jid}`);
this.registerMessageHandler();
this.fetch({
'add': true,
'success': this.onChatBoxesFetched.bind(this)
});
},
- onErrorMessage: function onErrorMessage(message) {
+
+ onErrorMessage(message) {
/* Handler method for all incoming error message stanzas
*/
- var from_jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
+ const from_jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
if (utils.isSameBareJID(from_jid, _converse.bare_jid)) {
return true;
}
- var chatbox = this.getChatBox(from_jid);
+ const chatbox = this.getChatBox(from_jid);
if (!chatbox) {
return true;
@@ -33780,49 +39939,51 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
chatbox.createMessage(message, message);
return true;
},
- getMessageBody: function getMessageBody(stanza) {
+
+ getMessageBody(stanza) {
/* Given a message stanza, return the text contained in its body.
*/
- var type = stanza.getAttribute('type');
+ const type = stanza.getAttribute('type');
if (type === 'error') {
- var error = stanza.querySelector('error');
+ const error = stanza.querySelector('error');
return _.propertyOf(error.querySelector('text'))('textContent') || __('Sorry, an error occurred:') + ' ' + error.innerHTML;
} else {
return _.propertyOf(stanza.querySelector('body'))('textContent');
}
},
- onMessage: function onMessage(stanza) {
+
+ onMessage(stanza) {
/* Handler method for all incoming single-user chat "message"
* stanzas.
*
* Parameters:
* (XMLElement) stanza - The incoming message stanza
*/
- var to_jid = stanza.getAttribute('to');
- var to_resource = Strophe.getResourceFromJid(to_jid);
+ let to_jid = stanza.getAttribute('to');
+ const to_resource = Strophe.getResourceFromJid(to_jid);
if (_converse.filter_by_resource && to_resource && to_resource !== _converse.resource) {
- _converse.log("onMessage: Ignoring incoming message intended for a different resource: ".concat(to_jid), Strophe.LogLevel.INFO);
+ _converse.log(`onMessage: Ignoring incoming message intended for a different resource: ${to_jid}`, Strophe.LogLevel.INFO);
return true;
} else if (utils.isHeadlineMessage(_converse, stanza)) {
// XXX: Ideally we wouldn't have to check for headline
// messages, but Prosody sends headline messages with the
// wrong type ('chat'), so we need to filter them out here.
- _converse.log("onMessage: Ignoring incoming headline message sent with type 'chat' from JID: ".concat(stanza.getAttribute('from')), Strophe.LogLevel.INFO);
+ _converse.log(`onMessage: Ignoring incoming headline message sent with type 'chat' from JID: ${stanza.getAttribute('from')}`, Strophe.LogLevel.INFO);
return true;
}
- var from_jid = stanza.getAttribute('from');
- var forwarded = stanza.querySelector('forwarded'),
- original_stanza = stanza;
+ let from_jid = stanza.getAttribute('from');
+ const forwarded = stanza.querySelector('forwarded'),
+ original_stanza = stanza;
if (!_.isNull(forwarded)) {
- var forwarded_message = forwarded.querySelector('message'),
- forwarded_from = forwarded_message.getAttribute('from'),
- is_carbon = !_.isNull(stanza.querySelector("received[xmlns=\"".concat(Strophe.NS.CARBONS, "\"]")));
+ const forwarded_message = forwarded.querySelector('message'),
+ forwarded_from = forwarded_message.getAttribute('from'),
+ is_carbon = !_.isNull(stanza.querySelector(`received[xmlns="${Strophe.NS.CARBONS}"]`));
if (is_carbon && Strophe.getBareJidFromJid(forwarded_from) !== from_jid) {
// Prevent message forging via carbons
@@ -33835,39 +39996,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
to_jid = stanza.getAttribute('to');
}
- var from_bare_jid = Strophe.getBareJidFromJid(from_jid),
- from_resource = Strophe.getResourceFromJid(from_jid),
- is_me = from_bare_jid === _converse.bare_jid;
- var contact_jid;
+ const from_bare_jid = Strophe.getBareJidFromJid(from_jid),
+ from_resource = Strophe.getResourceFromJid(from_jid),
+ is_me = from_bare_jid === _converse.bare_jid;
+ let contact_jid;
if (is_me) {
// I am the sender, so this must be a forwarded message...
if (_.isNull(to_jid)) {
- return _converse.log("Don't know how to handle message stanza without 'to' attribute. ".concat(stanza.outerHTML), Strophe.LogLevel.ERROR);
+ return _converse.log(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, Strophe.LogLevel.ERROR);
}
contact_jid = Strophe.getBareJidFromJid(to_jid);
} else {
contact_jid = from_bare_jid;
- } // Get chat box, but only create a new one when the message has a body.
+ }
+ const attrs = {
+ 'fullname': _.get(_converse.api.contacts.get(contact_jid), 'attributes.fullname') // Get chat box, but only create a new one when the message has a body.
- var attrs = {
- 'fullname': _.get(_converse.api.contacts.get(contact_jid), 'attributes.fullname')
};
- var chatbox = this.getChatBox(contact_jid, attrs, !_.isNull(stanza.querySelector('body')));
+ const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}`).length > 0;
+ const chatbox = this.getChatBox(contact_jid, attrs, has_body);
if (chatbox && !chatbox.handleMessageCorrection(stanza)) {
- var msgid = stanza.getAttribute('id'),
- message = msgid && chatbox.messages.findWhere({
- msgid: msgid
+ const msgid = stanza.getAttribute('id'),
+ message = msgid && chatbox.messages.findWhere({
+ msgid
});
if (!message) {
// Only create the message when we're sure it's not a duplicate
- chatbox.createMessage(stanza, original_stanza).then(function (msg) {
- return chatbox.incrementUnreadMsgCounter(msg);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ chatbox.createMessage(stanza, original_stanza).then(msg => chatbox.incrementUnreadMsgCounter(msg)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
}
@@ -33878,10 +40038,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return true;
},
- getChatBox: function getChatBox(jid) {
- var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var create = arguments.length > 2 ? arguments[2] : undefined;
+ getChatBox(jid, attrs = {}, create) {
/* Returns a chat box or optionally return a newly
* created one if one doesn't exist.
*
@@ -33897,7 +40055,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
jid = Strophe.getBareJidFromJid(jid.toLowerCase());
- var chatbox = this.get(Strophe.getBareJidFromJid(jid));
+ let chatbox = this.get(Strophe.getBareJidFromJid(jid));
if (!chatbox && create) {
_.extend(attrs, {
@@ -33906,14 +40064,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
chatbox = this.create(attrs, {
- 'error': function error(model, response) {
+ 'error'(model, response) {
_converse.log(response.responseText);
}
+
});
}
return chatbox;
}
+
});
function autoJoinChats() {
@@ -33941,12 +40101,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.on('chatBoxesFetched', autoJoinChats);
- _converse.api.waitUntil('rosterContactsFetched').then(function () {
- _converse.roster.on('add', function (contact) {
+ _converse.api.waitUntil('rosterContactsFetched').then(() => {
+ _converse.roster.on('add', contact => {
/* When a new contact is added, check if we already have a
* chatbox open for it, and if so attach it to the chatbox.
*/
- var chatbox = _converse.chatboxes.findWhere({
+ const chatbox = _converse.chatboxes.findWhere({
'jid': contact.get('jid')
});
@@ -33956,7 +40116,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
- _converse.on('addClientFeatures', function () {
+ _converse.on('addClientFeatures', () => {
_converse.api.disco.own.features.add(Strophe.NS.MESSAGE_CORRECT);
_converse.api.disco.own.features.add(Strophe.NS.HTTPUPLOAD);
@@ -33964,15 +40124,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.api.disco.own.features.add(Strophe.NS.OUTOFBAND);
});
- _converse.api.listen.on('pluginsInitialized', function () {
+ _converse.api.listen.on('pluginsInitialized', () => {
_converse.chatboxes = new _converse.ChatBoxes();
_converse.emit('chatBoxesInitialized');
});
- _converse.api.listen.on('presencesInitialized', function () {
- return _converse.chatboxes.onConnected();
- });
+ _converse.api.listen.on('presencesInitialized', () => _converse.chatboxes.onConnected());
/************************ END Event Handlers ************************/
/************************ BEGIN API ************************/
@@ -33991,7 +40149,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @param {string|string[]} jid|jids An jid or array of jids
* @param {object} attrs An object containing configuration attributes.
*/
- 'create': function create(jids, attrs) {
+ 'create'(jids, attrs) {
if (_.isUndefined(jids)) {
_converse.log("chats.create: You need to provide at least one JID", Strophe.LogLevel.ERROR);
@@ -34003,7 +40161,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
attrs.fullname = _.get(_converse.api.contacts.get(jids), 'attributes.fullname');
}
- var chatbox = _converse.chatboxes.getChatBox(jids, attrs, true);
+ const chatbox = _converse.chatboxes.getChatBox(jids, attrs, true);
if (_.isNil(chatbox)) {
_converse.log("Could not open chatbox for JID: " + jids, Strophe.LogLevel.ERROR);
@@ -34014,7 +40172,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return chatbox;
}
- return _.map(jids, function (jid) {
+ return _.map(jids, jid => {
attrs.fullname = _.get(_converse.api.contacts.get(jid), 'attributes.fullname');
return _converse.chatboxes.getChatBox(jid, attrs, true).trigger('show');
});
@@ -34052,11 +40210,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* });
*
*/
- 'open': function open(jids, attrs) {
- return new Promise(function (resolve, reject) {
- Promise.all([_converse.api.waitUntil('rosterContactsFetched'), _converse.api.waitUntil('chatBoxesFetched')]).then(function () {
+ 'open'(jids, attrs) {
+ return new Promise((resolve, reject) => {
+ Promise.all([_converse.api.waitUntil('rosterContactsFetched'), _converse.api.waitUntil('chatBoxesFetched')]).then(() => {
if (_.isUndefined(jids)) {
- var err_msg = "chats.open: You need to provide at least one JID";
+ const err_msg = "chats.open: You need to provide at least one JID";
_converse.log(err_msg, Strophe.LogLevel.ERROR);
@@ -34064,9 +40222,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} else if (_.isString(jids)) {
resolve(_converse.api.chats.create(jids, attrs).trigger('show'));
} else {
- resolve(_.map(jids, function (jid) {
- return _converse.api.chats.create(jid, attrs).trigger('show');
- }));
+ resolve(_.map(jids, jid => _converse.api.chats.create(jid, attrs).trigger('show')));
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
});
@@ -34092,9 +40248,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* const models = _converse.api.chats.get();
*
*/
- 'get': function get(jids) {
+ 'get'(jids) {
if (_.isUndefined(jids)) {
- var result = [];
+ const result = [];
_converse.chatboxes.each(function (chatbox) {
// FIXME: Leaky abstraction from MUC. We need to add a
@@ -34111,11 +40267,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return _.map(jids, _.partial(_converse.chatboxes.getChatBox.bind(_converse.chatboxes), _, {}, true));
}
+
}
});
/************************ END API ************************/
}
+
});
return converse;
});
@@ -34129,10 +40287,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -34142,41 +40297,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_chatboxes) {
+})(this, function (converse, tpl_chatboxes) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- _ = _converse$env._;
- var AvatarMixin = {
- renderAvatar: function renderAvatar() {
- var canvas_el = this.el.querySelector('canvas');
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ _ = _converse$env._;
+ const AvatarMixin = {
+ renderAvatar(el) {
+ el = el || this.el;
+ const canvas_el = el.querySelector('canvas');
if (_.isNull(canvas_el)) {
return;
}
- var image_type = this.model.vcard.get('image_type'),
- image = this.model.vcard.get('image'),
- img_src = "data:" + image_type + ";base64," + image,
- img = new Image();
+ const image_type = this.model.vcard.get('image_type'),
+ image = this.model.vcard.get('image'),
+ img_src = "data:" + image_type + ";base64," + image,
+ img = new Image();
+ return new Promise((resolve, reject) => {
+ img.onload = () => {
+ const ctx = canvas_el.getContext('2d'),
+ ratio = img.width / img.height;
+ ctx.clearRect(0, 0, canvas_el.width, canvas_el.height);
- img.onload = function () {
- var ctx = canvas_el.getContext('2d'),
- ratio = img.width / img.height;
- ctx.clearRect(0, 0, canvas_el.width, canvas_el.height);
+ if (ratio < 1) {
+ const scaled_img_with = canvas_el.width * ratio,
+ x = Math.floor((canvas_el.width - scaled_img_with) / 2);
+ ctx.drawImage(img, x, 0, scaled_img_with, canvas_el.height);
+ } else {
+ ctx.drawImage(img, 0, 0, canvas_el.width, canvas_el.height * ratio);
+ }
- if (ratio < 1) {
- var scaled_img_with = canvas_el.width * ratio,
- x = Math.floor((canvas_el.width - scaled_img_with) / 2);
- ctx.drawImage(img, x, 0, scaled_img_with, canvas_el.height);
- } else {
- ctx.drawImage(img, 0, 0, canvas_el.width, canvas_el.height * ratio);
- }
- };
+ resolve();
+ };
- img.src = img_src;
+ img.src = img_src;
+ });
}
+
};
converse.plugins.add('converse-chatboxviews', {
dependencies: ["converse-chatboxes"],
@@ -34185,7 +40345,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
initStatus: function initStatus(reconnecting) {
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
if (!reconnecting) {
_converse.chatboxviews.closeAllChatBoxes();
@@ -34194,30 +40354,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.initStatus.apply(this, arguments);
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.promises.add(['chatBoxViewsInitialized']);
_converse.ViewWithAvatar = Backbone.NativeView.extend(AvatarMixin);
_converse.VDOMViewWithAvatar = Backbone.VDOMView.extend(AvatarMixin);
_converse.ChatBoxViews = Backbone.Overview.extend({
- _ensureElement: function _ensureElement() {
+ _ensureElement() {
/* Override method from backbone.js
* If the #conversejs element doesn't exist, create it.
*/
if (!this.el) {
- var el = _converse.root.querySelector('#conversejs');
+ let el = _converse.root.querySelector('#conversejs');
if (_.isNull(el)) {
el = document.createElement('div');
el.setAttribute('id', 'conversejs');
- var body = _converse.root.querySelector('body');
+ const body = _converse.root.querySelector('body');
if (body) {
body.appendChild(el);
@@ -34233,12 +40394,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setElement(_.result(this, 'el'), false);
}
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on("destroy", this.removeChat, this);
- this.el.classList.add("converse-".concat(_converse.view_mode));
+ this.el.classList.add(`converse-${_converse.view_mode}`);
this.render();
},
- render: function render() {
+
+ render() {
try {
this.el.innerHTML = tpl_chatboxes();
} catch (e) {
@@ -34249,16 +40412,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.row_el = this.el.querySelector('.row');
},
- insertRowColumn: function insertRowColumn(el) {
+
+ insertRowColumn(el) {
/* Add a new DOM element (likely a chat box) into the
* the row managed by this overview.
*/
this.row_el.insertAdjacentElement('afterBegin', el);
},
- removeChat: function removeChat(item) {
+
+ removeChat(item) {
this.remove(item.get('id'));
},
- closeAllChatBoxes: function closeAllChatBoxes() {
+
+ closeAllChatBoxes() {
/* This method gets overridden in src/converse-controlbox.js if
* the controlbox plugin is active.
*/
@@ -34267,18 +40433,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this;
},
- chatBoxMayBeShown: function chatBoxMayBeShown(chatbox) {
+
+ chatBoxMayBeShown(chatbox) {
return this.model.chatBoxMayBeShown(chatbox);
}
+
});
/************************ BEGIN Event Handlers ************************/
- _converse.api.waitUntil('rosterContactsFetched').then(function () {
- _converse.roster.on('add', function (contact) {
+ _converse.api.waitUntil('rosterContactsFetched').then(() => {
+ _converse.roster.on('add', contact => {
/* When a new contact is added, check if we already have a
* chatbox open for it, and if so attach it to the chatbox.
*/
- var chatbox = _converse.chatboxes.findWhere({
+ const chatbox = _converse.chatboxes.findWhere({
'jid': contact.get('jid')
});
@@ -34288,7 +40456,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
- _converse.api.listen.on('chatBoxesInitialized', function () {
+ _converse.api.listen.on('chatBoxesInitialized', () => {
_converse.chatboxviews = new _converse.ChatBoxViews({
'model': _converse.chatboxes
});
@@ -34296,12 +40464,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('chatBoxViewsInitialized');
});
- _converse.api.listen.on('clearSession', function () {
- return _converse.chatboxviews.closeAllChatBoxes();
- });
+ _converse.api.listen.on('clearSession', () => _converse.chatboxviews.closeAllChatBoxes());
/************************ END Event Handlers ************************/
}
+
});
return converse;
});
@@ -34315,10 +40482,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -34328,19 +40492,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (u, converse, bootstrap, twemoji, xss, tpl_chatbox, tpl_chatbox_head, tpl_chatbox_message_form, tpl_emojis, tpl_error_message, tpl_help_message, tpl_info, tpl_new_day, tpl_user_details_modal, tpl_toolbar_fileupload, tpl_spinner, tpl_spoiler_button, tpl_status_message, tpl_toolbar) {
+})(this, function (u, converse, bootstrap, twemoji, xss, tpl_chatbox, tpl_chatbox_head, tpl_chatbox_message_form, tpl_emojis, tpl_error_message, tpl_help_message, tpl_info, tpl_new_day, tpl_user_details_modal, tpl_toolbar_fileupload, tpl_spinner, tpl_spoiler_button, tpl_status_message, tpl_toolbar) {
"use strict";
- var _converse$env = converse.env,
- $msg = _converse$env.$msg,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- _ = _converse$env._,
- b64_sha1 = _converse$env.b64_sha1,
- f = _converse$env.f,
- sizzle = _converse$env.sizzle,
- moment = _converse$env.moment;
+ const _converse$env = converse.env,
+ $msg = _converse$env.$msg,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ _ = _converse$env._,
+ b64_sha1 = _converse$env.b64_sha1,
+ f = _converse$env.f,
+ sizzle = _converse$env.sizzle,
+ moment = _converse$env.moment;
converse.plugins.add('converse-chatview', {
/* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before
@@ -34353,12 +40517,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* NB: These plugins need to have already been loaded via require.js.
*/
dependencies: ["converse-chatboxviews", "converse-disco", "converse-message-view", "converse-modal"],
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.settings.update({
'emoji_image_path': twemoji.default.base,
@@ -34378,8 +40543,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
function onWindowStateChanged(data) {
if (_converse.chatboxviews) {
- _converse.chatboxviews.each(function (view) {
- return view.onWindowStateChanged(data.state);
+ _converse.chatboxviews.each(view => {
+ if (view.model.get('id') !== 'controlbox') {
+ view.onWindowStateChanged(data.state);
+ }
});
}
}
@@ -34399,11 +40566,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click .emoji-category-picker li.emoji-category': 'chooseCategory',
'click .emoji-skintone-picker li.emoji-skintone': 'chooseSkinTone'
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change:current_skintone', this.render, this);
this.model.on('change:current_category', this.render, this);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_emojis(_.extend(this.model.toJSON(), {
'_': _,
'transform': u.getEmojiRenderer(_converse),
@@ -34413,7 +40582,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'shouldBeHidden': this.shouldBeHidden
}));
},
- shouldBeHidden: function shouldBeHidden(shortname, current_skintone, toned_emojis) {
+
+ shouldBeHidden(shortname, current_skintone, toned_emojis) {
/* Helper method for the template which decides whether an
* emoji should be hidden, based on which skin tone is
* currently being applied.
@@ -34430,11 +40600,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
},
- chooseSkinTone: function chooseSkinTone(ev) {
+
+ chooseSkinTone(ev) {
ev.preventDefault();
ev.stopPropagation();
- var target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
- var skintone = target.getAttribute("data-skintone").trim();
+ const target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
+ const skintone = target.getAttribute("data-skintone").trim();
if (this.model.get('current_skintone') === skintone) {
this.model.save({
@@ -34446,23 +40617,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
},
- chooseCategory: function chooseCategory(ev) {
+
+ chooseCategory(ev) {
ev.preventDefault();
ev.stopPropagation();
- var target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
- var category = target.getAttribute("data-category").trim();
+ const target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
+ const category = target.getAttribute("data-category").trim();
this.model.save({
'current_category': category,
'scroll_position': 0
});
}
+
});
_converse.ChatBoxHeading = _converse.ViewWithAvatar.extend({
- initialize: function initialize() {
+ initialize() {
this.model.on('change:status', this.onStatusMessageChanged, this);
this.model.vcard.on('change', this.render, this);
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_chatbox_head(_.extend(this.model.vcard.toJSON(), this.model.toJSON(), {
'_converse': _converse,
'info_close': __('Close this chat box')
@@ -34470,7 +40644,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.renderAvatar();
return this;
},
- onStatusMessageChanged: function onStatusMessageChanged(item) {
+
+ onStatusMessageChanged(item) {
this.render();
_converse.emit('contactStatusMessageChanged', {
@@ -34478,6 +40653,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'message': item.get('status')
});
}
+
});
_converse.UserDetailsModal = _converse.BootstrapModal.extend({
events: {
@@ -34485,7 +40661,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click button.refresh-contact': 'refreshContact',
'click .fingerprint-trust .btn input': 'toggleDeviceTrust'
},
- initialize: function initialize() {
+
+ initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('contactAdded', this.registerContactEventHandlers, this);
@@ -34494,7 +40671,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('userDetailsModalInitialized', this.model);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_user_details_modal(_.extend(this.model.toJSON(), this.model.vcard.toJSON(), {
'_': _,
'__': __,
@@ -34506,34 +40684,30 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'utils': u
}));
},
- registerContactEventHandlers: function registerContactEventHandlers() {
- var _this = this;
+ registerContactEventHandlers() {
if (!_.isUndefined(this.model.contact)) {
this.model.contact.on('change', this.render, this);
this.model.contact.vcard.on('change', this.render, this);
- this.model.contact.on('destroy', function () {
- delete _this.model.contact;
-
- _this.render();
+ this.model.contact.on('destroy', () => {
+ delete this.model.contact;
+ this.render();
});
}
},
- refreshContact: function refreshContact(ev) {
+
+ refreshContact(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var refresh_icon = this.el.querySelector('.fa-refresh');
+ const refresh_icon = this.el.querySelector('.fa-refresh');
u.addClass('fa-spin', refresh_icon);
- _converse.api.vcard.update(this.model.contact.vcard, true).then(function () {
- return u.removeClass('fa-spin', refresh_icon);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ _converse.api.vcard.update(this.model.contact.vcard, true).then(() => u.removeClass('fa-spin', refresh_icon)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- removeContact: function removeContact(ev) {
- var _this2 = this;
+ removeContact(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -34542,19 +40716,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var result = confirm(__("Are you sure you want to remove this contact?"));
+ const result = confirm(__("Are you sure you want to remove this contact?"));
if (result === true) {
this.modal.hide();
- this.model.contact.removeFromRoster(function (iq) {
- _this2.model.contact.destroy();
- }, function (err) {
+ this.model.contact.removeFromRoster(iq => {
+ this.model.contact.destroy();
+ }, err => {
_converse.log(err, Strophe.LogLevel.ERROR);
- _converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), [__('Sorry, there was an error while trying to remove %1$s as a contact.', _this2.model.contact.getDisplayName())]);
+ _converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), [__('Sorry, there was an error while trying to remove %1$s as a contact.', this.model.contact.getDisplayName())]);
});
}
}
+
});
_converse.ChatBoxView = Backbone.NativeView.extend({
length: 200,
@@ -34579,7 +40754,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'input .chat-textarea': 'inputChanged',
'keydown .chat-textarea': 'keyPressed'
},
- initialize: function initialize() {
+
+ initialize() {
this.initDebounced();
this.model.messages.on('add', this.onMessageAdded, this);
this.model.messages.on('rendered', this.scrollDown, this);
@@ -34594,14 +40770,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('chatBoxInitialized', this);
},
- initDebounced: function initDebounced() {
+
+ initDebounced() {
this.scrollDown = _.debounce(this._scrollDown, 250);
this.markScrolled = _.debounce(this._markScrolled, 100);
this.show = _.debounce(this._show, 250, {
'leading': true
});
},
- render: function render() {
+
+ render() {
// XXX: Is this still needed?
this.el.setAttribute('id', this.model.get('box_id'));
this.el.innerHTML = tpl_chatbox(_.extend(this.model.toJSON(), {
@@ -34612,7 +40790,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertHeading();
return this;
},
- renderToolbar: function renderToolbar(toolbar, options) {
+
+ renderToolbar(toolbar, options) {
if (!_converse.show_toolbar) {
return this;
}
@@ -34627,8 +40806,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- renderMessageForm: function renderMessageForm() {
- var placeholder;
+
+ renderMessageForm() {
+ let placeholder;
if (this.model.get('composing_spoiler')) {
placeholder = __('Hidden message');
@@ -34636,7 +40816,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
placeholder = __('Message');
}
- var form_container = this.el.querySelector('.message-form-container');
+ const form_container = this.el.querySelector('.message-form-container');
form_container.innerHTML = tpl_chatbox_message_form(_.extend(this.model.toJSON(), {
'hint_value': _.get(this.el.querySelector('.spoiler-hint'), 'value'),
'label_message': placeholder,
@@ -34649,14 +40829,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}));
this.renderToolbar();
},
- showControlBox: function showControlBox() {
+
+ showControlBox() {
// Used in mobile view, to navigate back to the controlbox
- var view = _converse.chatboxviews.get('controlbox');
+ const view = _converse.chatboxviews.get('controlbox');
view.show();
this.hide();
},
- showUserDetailsModal: function showUserDetailsModal(ev) {
+
+ showUserDetailsModal(ev) {
ev.preventDefault();
if (_.isUndefined(this.user_details_modal)) {
@@ -34667,26 +40849,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.user_details_modal.show(ev);
},
- toggleFileUpload: function toggleFileUpload(ev) {
+
+ toggleFileUpload(ev) {
this.el.querySelector('input.fileupload').click();
},
- onFileSelection: function onFileSelection(evt) {
+
+ onFileSelection(evt) {
this.model.sendFiles(evt.target.files);
},
- addFileUploadButton: function addFileUploadButton(options) {
- var _this3 = this;
- _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then(function (result) {
+ addFileUploadButton(options) {
+ _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then(result => {
if (result.length) {
- _this3.el.querySelector('.chat-toolbar').insertAdjacentHTML('beforeend', tpl_toolbar_fileupload({
+ this.el.querySelector('.chat-toolbar').insertAdjacentHTML('beforeend', tpl_toolbar_fileupload({
'tooltip_upload_file': __('Choose a file to send')
}));
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- addSpoilerButton: function addSpoilerButton(options) {
- var _this4 = this;
+ addSpoilerButton(options) {
/* Asynchronously adds a button for writing spoiler
* messages, based on whether the contact's client supports
* it.
@@ -34695,28 +40877,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var contact_jid = this.model.get('jid');
- var resources = this.model.presence.get('resources');
+ const contact_jid = this.model.get('jid');
+ const resources = this.model.presence.get('resources');
if (_.isEmpty(resources)) {
return;
}
- Promise.all(_.map(_.keys(resources), function (resource) {
- return _converse.api.disco.supports(Strophe.NS.SPOILER, "".concat(contact_jid, "/").concat(resource));
- })).then(function (results) {
+ Promise.all(_.map(_.keys(resources), resource => _converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${resource}`))).then(results => {
if (_.filter(results, 'length').length) {
- var html = tpl_spoiler_button(_this4.model.toJSON());
+ const html = tpl_spoiler_button(this.model.toJSON());
if (_converse.visible_toolbar_buttons.emoji) {
- _this4.el.querySelector('.toggle-smiley').insertAdjacentHTML('afterEnd', html);
+ this.el.querySelector('.toggle-smiley').insertAdjacentHTML('afterEnd', html);
} else {
- _this4.el.querySelector('.chat-toolbar').insertAdjacentHTML('afterBegin', html);
+ this.el.querySelector('.chat-toolbar').insertAdjacentHTML('afterBegin', html);
}
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- insertHeading: function insertHeading() {
+
+ insertHeading() {
this.heading = new _converse.ChatBoxHeading({
'model': this.model
});
@@ -34727,12 +40908,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.contact.on('destroy', this.heading.render, this);
}
- var flyout = this.el.querySelector('.flyout');
+ const flyout = this.el.querySelector('.flyout');
flyout.insertBefore(this.heading.el, flyout.querySelector('.chat-body'));
return this;
},
- getToolbarOptions: function getToolbarOptions(options) {
- var label_toggle_spoiler;
+
+ getToolbarOptions(options) {
+ let label_toggle_spoiler;
if (this.model.get('composing_spoiler')) {
label_toggle_spoiler = __('Click to write as a normal (non-spoiler) message');
@@ -34750,14 +40932,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'use_emoji': _converse.visible_toolbar_buttons.emoji
});
},
- afterMessagesFetched: function afterMessagesFetched() {
+
+ afterMessagesFetched() {
this.insertIntoDOM();
this.scrollDown();
this.content.addEventListener('scroll', this.markScrolled.bind(this));
_converse.emit('afterMessagesFetched', this);
},
- fetchMessages: function fetchMessages() {
+
+ fetchMessages() {
this.model.messages.fetch({
'add': true,
'success': this.afterMessagesFetched.bind(this),
@@ -34765,7 +40949,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this;
},
- insertIntoDOM: function insertIntoDOM() {
+
+ insertIntoDOM() {
/* This method gets overridden in src/converse-controlbox.js
* as well as src/converse-muc.js (if those plugins are
* enabled).
@@ -34774,29 +40959,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- showChatEvent: function showChatEvent(message) {
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- var isodate = moment().format();
+
+ showChatEvent(message) {
+ const isodate = moment().format();
this.content.insertAdjacentHTML('beforeend', tpl_info({
'extra_classes': 'chat-event',
'message': message,
- 'isodate': isodate,
- 'data': data
+ 'isodate': isodate
}));
this.insertDayIndicator(this.content.lastElementChild);
this.scrollDown();
return isodate;
},
- showErrorMessage: function showErrorMessage(message) {
+
+ showErrorMessage(message) {
this.content.insertAdjacentHTML('beforeend', tpl_error_message({
'message': message,
'isodate': moment().format()
}));
this.scrollDown();
},
- addSpinner: function addSpinner() {
- var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
+ addSpinner(append = false) {
if (_.isNull(this.el.querySelector('.spinner'))) {
if (append) {
this.content.insertAdjacentHTML('beforeend', tpl_spinner());
@@ -34806,12 +40990,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
},
- clearSpinner: function clearSpinner() {
- _.each(this.content.querySelectorAll('span.spinner'), function (el) {
- return el.parentNode.removeChild(el);
- });
+
+ clearSpinner() {
+ _.each(this.content.querySelectorAll('span.spinner'), el => el.parentNode.removeChild(el));
},
- insertDayIndicator: function insertDayIndicator(next_msg_el) {
+
+ insertDayIndicator(next_msg_el) {
/* Inserts an indicator into the chat area, showing the
* day as given by the passed in date.
*
@@ -34823,34 +41007,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* This element must have a "data-isodate" attribute
* which specifies its creation date.
*/
- var prev_msg_el = u.getPreviousElement(next_msg_el, ".message:not(.chat-state-notification)"),
- prev_msg_date = _.isNull(prev_msg_el) ? null : prev_msg_el.getAttribute('data-isodate'),
- next_msg_date = next_msg_el.getAttribute('data-isodate');
+ const prev_msg_el = u.getPreviousElement(next_msg_el, ".message:not(.chat-state-notification)"),
+ prev_msg_date = _.isNull(prev_msg_el) ? null : prev_msg_el.getAttribute('data-isodate'),
+ next_msg_date = next_msg_el.getAttribute('data-isodate');
if (_.isNull(prev_msg_date) || moment(next_msg_date).isAfter(prev_msg_date, 'day')) {
- var day_date = moment(next_msg_date).startOf('day');
+ const day_date = moment(next_msg_date).startOf('day');
next_msg_el.insertAdjacentHTML('beforeBegin', tpl_new_day({
'isodate': day_date.format(),
'datestring': day_date.format("dddd MMM Do YYYY")
}));
}
},
- getLastMessageDate: function getLastMessageDate(cutoff) {
+
+ getLastMessageDate(cutoff) {
/* Return the ISO8601 format date of the latest message.
*
* Parameters:
* (Object) cutoff: Moment Date cutoff date. The last
* message received cutoff this date will be returned.
*/
- var first_msg = u.getFirstChildElement(this.content, '.message:not(.chat-state-notification)'),
- oldest_date = first_msg ? first_msg.getAttribute('data-isodate') : null;
+ const first_msg = u.getFirstChildElement(this.content, '.message:not(.chat-state-notification)'),
+ oldest_date = first_msg ? first_msg.getAttribute('data-isodate') : null;
if (!_.isNull(oldest_date) && moment(oldest_date).isAfter(cutoff)) {
return null;
}
- var last_msg = u.getLastChildElement(this.content, '.message:not(.chat-state-notification)'),
- most_recent_date = last_msg ? last_msg.getAttribute('data-isodate') : null;
+ const last_msg = u.getLastChildElement(this.content, '.message:not(.chat-state-notification)'),
+ most_recent_date = last_msg ? last_msg.getAttribute('data-isodate') : null;
if (_.isNull(most_recent_date) || moment(most_recent_date).isBefore(cutoff)) {
return most_recent_date;
@@ -34863,7 +41048,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
*/
- var msg_dates = _.invokeMap(sizzle('.message:not(.chat-state-notification)', this.content), Element.prototype.getAttribute, 'data-isodate');
+ const msg_dates = _.invokeMap(sizzle('.message:not(.chat-state-notification)', this.content), Element.prototype.getAttribute, 'data-isodate');
if (_.isObject(cutoff)) {
cutoff = cutoff.format();
@@ -34871,7 +41056,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
msg_dates.push(cutoff);
msg_dates.sort();
- var idx = msg_dates.lastIndexOf(cutoff);
+ const idx = msg_dates.lastIndexOf(cutoff);
if (idx === 0) {
return null;
@@ -34879,20 +41064,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return msg_dates[idx - 1];
}
},
- setScrollPosition: function setScrollPosition(message_el) {
+
+ setScrollPosition(message_el) {
/* Given a newly inserted message, determine whether we
* should keep the scrollbar in place (so as to not scroll
* up when using infinite scroll).
*/
if (this.model.get('scrolled')) {
- var next_msg_el = u.getNextElement(message_el, ".chat-msg");
+ const next_msg_el = u.getNextElement(message_el, ".chat-msg");
if (next_msg_el) {
// The currently received message is not new, there
// are newer messages after it. So let's see if we
// should maintain our current scroll position.
if (this.content.scrollTop === 0 || this.model.get('top_visible_message')) {
- var top_visible_message = this.model.get('top_visible_message') || next_msg_el;
+ const top_visible_message = this.model.get('top_visible_message') || next_msg_el;
this.model.set('top_visible_message', top_visible_message);
this.content.scrollTop = top_visible_message.offsetTop - 30;
}
@@ -34901,11 +41087,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.scrollDown();
}
},
- showHelpMessages: function showHelpMessages(msgs, type, spinner) {
- var _this5 = this;
- _.each(msgs, function (msg) {
- _this5.content.insertAdjacentHTML('beforeend', tpl_help_message({
+ showHelpMessages(msgs, type, spinner) {
+ _.each(msgs, msg => {
+ this.content.insertAdjacentHTML('beforeend', tpl_help_message({
'isodate': moment().format(),
'type': type,
'message': xss.filterXSS(msg, {
@@ -34924,17 +41109,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.scrollDown();
},
- clearChatStateNotification: function clearChatStateNotification(message, isodate) {
+
+ clearChatStateNotification(message, isodate) {
if (isodate) {
- _.each(sizzle(".chat-state-notification[data-csn=\"".concat(message.get('from'), "\"][data-isodate=\"").concat(isodate, "\"]"), this.content), u.removeElement);
+ _.each(sizzle(`.chat-state-notification[data-csn="${message.get('from')}"][data-isodate="${isodate}"]`, this.content), u.removeElement);
} else {
- _.each(sizzle(".chat-state-notification[data-csn=\"".concat(message.get('from'), "\"]"), this.content), u.removeElement);
+ _.each(sizzle(`.chat-state-notification[data-csn="${message.get('from')}"]`, this.content), u.removeElement);
}
},
- shouldShowOnTextMessage: function shouldShowOnTextMessage() {
+
+ shouldShowOnTextMessage() {
return !u.isVisible(this.el);
},
- insertMessage: function insertMessage(view) {
+
+ insertMessage(view) {
/* Given a view representing a message, insert it into the
* content area of the chat box.
*
@@ -34942,32 +41130,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (Backbone.View) message: The message Backbone.View
*/
if (view.model.get('type') === 'error') {
- var previous_msg_el = this.content.querySelector("[data-msgid=\"".concat(view.model.get('msgid'), "\"]"));
+ const previous_msg_el = this.content.querySelector(`[data-msgid="${view.model.get('msgid')}"]`);
if (previous_msg_el) {
- return previous_msg_el.insertAdjacentElement('afterend', view.el);
+ previous_msg_el.insertAdjacentElement('afterend', view.el);
+ return this.trigger('messageInserted', view.el);
}
}
- var current_msg_date = moment(view.model.get('time')) || moment,
- previous_msg_date = this.getLastMessageDate(current_msg_date);
+ const current_msg_date = moment(view.model.get('time')) || moment,
+ previous_msg_date = this.getLastMessageDate(current_msg_date);
if (_.isNull(previous_msg_date)) {
this.content.insertAdjacentElement('afterbegin', view.el);
} else {
- var _previous_msg_el = sizzle("[data-isodate=\"".concat(previous_msg_date, "\"]:last"), this.content).pop();
+ const previous_msg_el = sizzle(`[data-isodate="${previous_msg_date}"]:last`, this.content).pop();
- if (view.model.get('type') === 'error' && u.hasClass('chat-error', _previous_msg_el) && _previous_msg_el.textContent === view.model.get('message')) {
+ if (view.model.get('type') === 'error' && u.hasClass('chat-error', previous_msg_el) && previous_msg_el.textContent === view.model.get('message')) {
// We don't show a duplicate error message
return;
}
- _previous_msg_el.insertAdjacentElement('afterend', view.el);
-
+ previous_msg_el.insertAdjacentElement('afterend', view.el);
this.markFollowups(view.el);
}
+
+ return this.trigger('messageInserted', view.el);
},
- markFollowups: function markFollowups(el) {
+
+ markFollowups(el) {
/* Given a message element, determine wether it should be
* marked as a followup message to the previous element.
*
@@ -34981,10 +41172,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* Parameters:
* (HTMLElement) el - The message element.
*/
- var from = el.getAttribute('data-from'),
- previous_el = el.previousElementSibling,
- date = moment(el.getAttribute('data-isodate')),
- next_el = el.nextElementSibling;
+ const from = el.getAttribute('data-from'),
+ previous_el = el.previousElementSibling,
+ date = moment(el.getAttribute('data-isodate')),
+ next_el = el.nextElementSibling;
if (!u.hasClass('chat-msg--action', el) && !u.hasClass('chat-msg--action', previous_el) && previous_el.getAttribute('data-from') === from && date.isBefore(moment(previous_el.getAttribute('data-isodate')).add(10, 'minutes')) && el.getAttribute('data-encrypted') === previous_el.getAttribute('data-encrypted')) {
u.addClass('chat-msg--followup', el);
@@ -35000,7 +41191,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.removeClass('chat-msg--followup', next_el);
}
},
- showMessage: function showMessage(message) {
+
+ async showMessage(message) {
/* Inserts a chat message into the content area of the chat box.
*
* Will also insert a new day indicator if the message is on a
@@ -35009,9 +41201,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* Parameters:
* (Backbone.Model) message: The message object
*/
- var view = new _converse.MessageView({
+ const view = new _converse.MessageView({
'model': message
});
+ await view.render();
this.clearChatStateNotification(message);
this.insertMessage(view);
this.insertDayIndicator(view.el);
@@ -35035,7 +41228,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.scrollDown();
}
},
- onMessageAdded: function onMessageAdded(message) {
+
+ onMessageAdded(message) {
/* Handler that gets called when a new message object is created.
*
* Parameters:
@@ -35052,21 +41246,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'chatbox': this.model
});
},
- parseMessageForCommands: function parseMessageForCommands(text) {
- var match = text.replace(/^\s*/, "").match(/^\/(.*)\s*$/);
+
+ parseMessageForCommands(text) {
+ const match = text.replace(/^\s*/, "").match(/^\/(.*)\s*$/);
if (match) {
if (match[1] === "clear") {
this.clearMessages();
return true;
} else if (match[1] === "help") {
- var msgs = ["/clear: ".concat(__('Remove messages')), "/me: ".concat(__('Write in the third person')), "/help: ".concat(__('Show this menu'))];
+ const msgs = [`/clear: ${__('Remove messages')}`, `/me: ${__('Write in the third person')}`, `/help: ${__('Show this menu')}`];
this.showHelpMessages(msgs);
return true;
}
}
},
- onMessageSubmitted: function onMessageSubmitted(text, spoiler_hint) {
+
+ onMessageSubmitted(text, spoiler_hint) {
/* This method gets called once the user has typed a message
* and then pressed enter in a chat box.
*
@@ -35083,10 +41279,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var attrs = this.model.getOutgoingMessageAttributes(text, spoiler_hint);
+ const attrs = this.model.getOutgoingMessageAttributes(text, spoiler_hint);
this.model.sendMessage(attrs);
},
- setChatState: function setChatState(state, options) {
+
+ setChatState(state, options) {
/* Mutator for setting the chat state of this chat session.
* Handles clearing of any chat state notification timeouts and
* setting new ones if necessary.
@@ -35111,19 +41308,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.set('chat_state', state, options);
return this;
},
- onFormSubmitted: function onFormSubmitted(ev) {
+
+ onFormSubmitted(ev) {
ev.preventDefault();
- var textarea = this.el.querySelector('.chat-textarea'),
- message = textarea.value;
+ const textarea = this.el.querySelector('.chat-textarea'),
+ message = textarea.value;
if (!message.replace(/\s/g, '').length) {
return;
}
- var spoiler_hint;
+ let spoiler_hint;
if (this.model.get('composing_spoiler')) {
- var hint_el = this.el.querySelector('form.sendXMPPMessage input.spoiler-hint');
+ const hint_el = this.el.querySelector('form.sendXMPPMessage input.spoiler-hint');
spoiler_hint = hint_el.value;
hint_el.value = '';
}
@@ -35132,7 +41330,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.removeClass('correcting', textarea);
textarea.focus(); // Trigger input event, so that the textarea resizes
- var event = document.createEvent('Event');
+ const event = document.createEvent('Event');
event.initEvent('input', true, true);
textarea.dispatchEvent(event);
this.onMessageSubmitted(message, spoiler_hint);
@@ -35145,7 +41343,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'silent': true
});
},
- keyPressed: function keyPressed(ev) {
+
+ keyPressed(ev) {
/* Event handler for when a key is pressed in a chat box textarea.
*/
if (ev.ctrlKey) {
@@ -35182,15 +41381,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setChatState(_converse.COMPOSING);
}
},
- getOwnMessages: function getOwnMessages() {
+
+ getOwnMessages() {
return f(this.model.messages.filter({
'sender': 'me'
}));
},
- onEscapePressed: function onEscapePressed(ev) {
+
+ onEscapePressed(ev) {
ev.preventDefault();
- var idx = this.model.messages.findLastIndex('correcting'),
- message = idx >= 0 ? this.model.messages.at(idx) : null;
+ const idx = this.model.messages.findLastIndex('correcting'),
+ message = idx >= 0 ? this.model.messages.at(idx) : null;
if (message) {
message.save('correcting', false);
@@ -35198,12 +41399,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertIntoTextArea('', true, false);
},
- onMessageEditButtonClicked: function onMessageEditButtonClicked(ev) {
+
+ onMessageEditButtonClicked(ev) {
ev.preventDefault();
- var idx = this.model.messages.findLastIndex('correcting'),
- currently_correcting = idx >= 0 ? this.model.messages.at(idx) : null,
- message_el = u.ancestor(ev.target, '.chat-msg'),
- message = this.model.messages.findWhere({
+ const idx = this.model.messages.findLastIndex('correcting'),
+ currently_correcting = idx >= 0 ? this.model.messages.at(idx) : null,
+ message_el = u.ancestor(ev.target, '.chat-msg'),
+ message = this.model.messages.findWhere({
'msgid': message_el.getAttribute('data-msgid')
});
@@ -35219,16 +41421,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertIntoTextArea('', true, false);
}
},
- editLaterMessage: function editLaterMessage() {
- var message;
- var idx = this.model.messages.findLastIndex('correcting');
+
+ editLaterMessage() {
+ let message;
+ let idx = this.model.messages.findLastIndex('correcting');
if (idx >= 0) {
this.model.messages.at(idx).save('correcting', false);
while (idx < this.model.messages.length - 1) {
idx += 1;
- var candidate = this.model.messages.at(idx);
+ const candidate = this.model.messages.at(idx);
if (candidate.get('sender') === 'me' && candidate.get('message')) {
message = candidate;
@@ -35244,16 +41447,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertIntoTextArea('', true, false);
}
},
- editEarlierMessage: function editEarlierMessage() {
- var message;
- var idx = this.model.messages.findLastIndex('correcting');
+
+ editEarlierMessage() {
+ let message;
+ let idx = this.model.messages.findLastIndex('correcting');
if (idx >= 0) {
this.model.messages.at(idx).save('correcting', false);
while (idx > 0) {
idx -= 1;
- var candidate = this.model.messages.at(idx);
+ const candidate = this.model.messages.at(idx);
if (candidate.get('sender') === 'me' && candidate.get('message')) {
message = candidate;
@@ -35262,26 +41466,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
- message = message || this.getOwnMessages().findLast(function (msg) {
- return msg.get('message');
- });
+ message = message || this.getOwnMessages().findLast(msg => msg.get('message'));
if (message) {
this.insertIntoTextArea(message.get('message'), true, true);
message.save('correcting', true);
}
},
- inputChanged: function inputChanged(ev) {
+
+ inputChanged(ev) {
ev.target.style.height = 'auto'; // Fixes weirdness
ev.target.style.height = ev.target.scrollHeight + 'px';
},
- clearMessages: function clearMessages(ev) {
+
+ clearMessages(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var result = confirm(__("Are you sure you want to clear the messages from this conversation?"));
+ const result = confirm(__("Are you sure you want to clear the messages from this conversation?"));
if (result === true) {
this.content.innerHTML = '';
@@ -35292,10 +41496,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- insertIntoTextArea: function insertIntoTextArea(value) {
- var replace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var correcting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- var textarea = this.el.querySelector('.chat-textarea');
+
+ insertIntoTextArea(value, replace = false, correcting = false) {
+ const textarea = this.el.querySelector('.chat-textarea');
if (correcting) {
u.addClass('correcting', textarea);
@@ -35307,7 +41510,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
textarea.value = '';
textarea.value = value;
} else {
- var existing = textarea.value;
+ let existing = textarea.value;
if (existing && existing[existing.length - 1] !== ' ') {
existing = existing + ' ';
@@ -35319,10 +41522,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.putCurserAtEnd(textarea);
},
- createEmojiPicker: function createEmojiPicker() {
+
+ createEmojiPicker() {
if (_.isUndefined(_converse.emojipicker)) {
- var storage = _converse.config.get('storage'),
- id = "converse.emoji-".concat(_converse.bare_jid);
+ const storage = _converse.config.get('storage'),
+ id = `converse.emoji-${_converse.bare_jid}`;
_converse.emojipicker = new _converse.EmojiPicker({
'id': id
@@ -35336,25 +41540,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'model': _converse.emojipicker
});
},
- insertEmoji: function insertEmoji(ev) {
+
+ insertEmoji(ev) {
ev.preventDefault();
ev.stopPropagation();
- var target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
+ const target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
this.insertIntoTextArea(target.getAttribute('data-emoji'));
},
- toggleEmojiMenu: function toggleEmojiMenu(ev) {
+
+ toggleEmojiMenu(ev) {
if (_.isUndefined(this.emoji_dropdown)) {
ev.stopPropagation();
this.createEmojiPicker();
this.insertEmojiPicker();
this.renderEmojiPicker();
- var dropdown_el = this.el.querySelector('.toggle-smiley.dropup');
+ const dropdown_el = this.el.querySelector('.toggle-smiley.dropup');
this.emoji_dropdown = new bootstrap.Dropdown(dropdown_el, true);
this.emoji_dropdown.el = dropdown_el;
this.emoji_dropdown.toggle();
}
},
- toggleCall: function toggleCall(ev) {
+
+ toggleCall(ev) {
ev.stopPropagation();
_converse.emit('callButtonClicked', {
@@ -35362,18 +41569,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
model: this.model
});
},
- toggleComposeSpoilerMessage: function toggleComposeSpoilerMessage() {
+
+ toggleComposeSpoilerMessage() {
this.model.set('composing_spoiler', !this.model.get('composing_spoiler'));
this.renderMessageForm();
this.focus();
},
- toggleSpoilerMessage: function toggleSpoilerMessage(ev) {
+
+ toggleSpoilerMessage(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var toggle_el = ev.target,
- icon_el = toggle_el.firstElementChild;
+ const toggle_el = ev.target,
+ icon_el = toggle_el.firstElementChild;
u.slideToggleElement(toggle_el.parentElement.parentElement.querySelector('.spoiler'));
if (toggle_el.getAttribute("data-toggle-state") == "closed") {
@@ -35390,10 +41599,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
toggle_el.setAttribute("data-toggle-state", "closed");
}
},
- onPresenceChanged: function onPresenceChanged(item) {
- var show = item.get('show'),
- fullname = this.model.getDisplayName();
- var text;
+
+ onPresenceChanged(item) {
+ const show = item.get('show'),
+ fullname = this.model.getDisplayName();
+ let text;
if (u.isVisible(this.el)) {
if (show === 'offline') {
@@ -35415,7 +41625,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
},
- close: function close(ev) {
+
+ close(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -35443,10 +41654,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- renderEmojiPicker: function renderEmojiPicker() {
+
+ renderEmojiPicker() {
this.emoji_picker_view.render();
},
- insertEmojiPicker: function insertEmojiPicker() {
+
+ insertEmojiPicker() {
var picker_el = this.el.querySelector('.emoji-picker');
if (!_.isNull(picker_el)) {
@@ -35454,8 +41667,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
picker_el.appendChild(this.emoji_picker_view.el);
}
},
- focus: function focus() {
- var textarea_el = this.el.querySelector('.chat-textarea');
+
+ focus() {
+ const textarea_el = this.el.querySelector('.chat-textarea');
if (!_.isNull(textarea_el)) {
textarea_el.focus();
@@ -35465,17 +41679,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- hide: function hide() {
+
+ hide() {
this.el.classList.add('hidden');
return this;
},
- afterShown: function afterShown() {
+
+ afterShown() {
this.model.clearUnreadMsgCounter();
this.setChatState(_converse.ACTIVE);
this.scrollDown();
this.focus();
},
- _show: function _show(f) {
+
+ _show(f) {
/* Inner show method that gets debounced */
if (u.isVisible(this.el)) {
this.focus();
@@ -35484,16 +41701,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.fadeIn(this.el, _.bind(this.afterShown, this));
},
- showNewMessagesIndicator: function showNewMessagesIndicator() {
+
+ showNewMessagesIndicator() {
u.showElement(this.el.querySelector('.new-msgs-indicator'));
},
- hideNewMessagesIndicator: function hideNewMessagesIndicator() {
- var new_msgs_indicator = this.el.querySelector('.new-msgs-indicator');
+
+ hideNewMessagesIndicator() {
+ const new_msgs_indicator = this.el.querySelector('.new-msgs-indicator');
if (!_.isNull(new_msgs_indicator)) {
new_msgs_indicator.classList.add('hidden');
}
},
+
_markScrolled: function _markScrolled(ev) {
/* Called when the chat content is scrolled up or down.
* We want to record when the user has scrolled away from
@@ -35505,8 +41725,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
ev.preventDefault();
}
- var scrolled = true;
- var is_at_bottom = this.content.scrollTop + this.content.clientHeight >= this.content.scrollHeight - 62; // sigh...
+ let scrolled = true;
+ const is_at_bottom = this.content.scrollTop + this.content.clientHeight >= this.content.scrollHeight - 62; // sigh...
if (is_at_bottom) {
scrolled = false;
@@ -35518,14 +41738,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'top_visible_message': null
});
},
- viewUnreadMessages: function viewUnreadMessages() {
+
+ viewUnreadMessages() {
this.model.save({
'scrolled': false,
'top_visible_message': null
});
this.scrollDown();
},
- _scrollDown: function _scrollDown() {
+
+ _scrollDown() {
/* Inner method that gets debounced */
if (_.isUndefined(this.content)) {
return;
@@ -35535,7 +41757,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.content.scrollTop = this.content.scrollHeight;
}
},
- onScrolledDown: function onScrolledDown() {
+
+ onScrolledDown() {
this.hideNewMessagesIndicator();
if (_converse.windowState !== 'hidden') {
@@ -35546,17 +41769,32 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'chatbox': this.model
});
},
- onWindowStateChanged: function onWindowStateChanged(state) {
- if (this.model.get('num_unread', 0) && !this.model.isHidden()) {
- this.model.clearUnreadMsgCounter();
+
+ onWindowStateChanged(state) {
+ if (state === 'visible') {
+ if (!this.model.isHidden()) {
+ this.setChatState(_converse.ACTIVE);
+
+ if (this.model.get('num_unread', 0)) {
+ this.model.clearUnreadMsgCounter();
+ }
+ }
+ } else if (state === 'hidden') {
+ this.setChatState(_converse.INACTIVE, {
+ 'silent': true
+ });
+ this.model.sendChatState();
+
+ _converse.connection.flush();
}
}
+
});
- _converse.on('chatBoxViewsInitialized', function () {
- var that = _converse.chatboxviews;
+ _converse.on('chatBoxViewsInitialized', () => {
+ const that = _converse.chatboxviews;
- _converse.chatboxes.on('add', function (item) {
+ _converse.chatboxes.on('add', item => {
if (!that.get(item.get('id')) && item.get('type') === _converse.PRIVATE_CHAT_TYPE) {
that.add(item.get('id'), new _converse.ChatBoxView({
model: item
@@ -35565,7 +41803,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
- _converse.on('connected', function () {
+ _converse.on('connected', () => {
// Advertise that we support XEP-0382 Message Spoilers
_converse.api.disco.own.features.add(Strophe.NS.SPOILER);
});
@@ -35596,7 +41834,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* // To return an array of views, provide an array of JIDs:
* _converse.api.chatviews.get(['buddy1@example.com', 'buddy2@example.com'])
*/
- 'get': function get(jids) {
+ 'get'(jids) {
if (_.isUndefined(jids)) {
_converse.log("chats.create: You need to provide at least one JID", Strophe.LogLevel.ERROR);
@@ -35607,15 +41845,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return _converse.chatboxviews.get(jids);
}
- return _.map(jids, function (jid) {
- return _converse.chatboxviews.get(jids);
- });
+ return _.map(jids, jid => _converse.chatboxviews.get(jids));
}
+
}
});
/************************ END API ************************/
}
+
});
return converse;
});
@@ -35629,10 +41867,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -35645,18 +41880,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, bootstrap, _FormData, fp, tpl_brand_heading, tpl_controlbox, tpl_controlbox_toggle, tpl_login_panel) {
+})(this, function (converse, bootstrap, _FormData, fp, tpl_brand_heading, tpl_controlbox, tpl_controlbox_toggle, tpl_login_panel) {
"use strict";
- var CHATBOX_TYPE = 'chatbox';
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- _ = _converse$env._,
- moment = _converse$env.moment;
- var u = converse.env.utils;
- var CONNECTION_STATUS_CSS_CLASS = {
+ const CHATBOX_TYPE = 'chatbox';
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ _ = _converse$env._,
+ moment = _converse$env.moment;
+ const u = converse.env.utils;
+ const CONNECTION_STATUS_CSS_CLASS = {
'Error': 'error',
'Connecting': 'info',
'Connection failure': 'error',
@@ -35669,7 +41904,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'Redirect': 'info',
'Reconnecting': 'warn'
};
- var PRETTY_CONNECTION_STATUS = {
+ const PRETTY_CONNECTION_STATUS = {
0: 'Error',
1: 'Connecting',
2: 'Connection failure',
@@ -35682,7 +41917,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
9: 'Redirect',
10: 'Reconnecting'
};
- var REPORTABLE_STATUSES = [0, // ERROR'
+ const REPORTABLE_STATUSES = [0, // ERROR'
1, // CONNECTING
2, // CONNFAIL
3, // AUTHENTICATING
@@ -35708,7 +41943,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// relevant objects or classes.
//
// New functions which don't exist yet can also be added.
- tearDown: function tearDown() {
+ tearDown() {
this.__super__.tearDown.apply(this, arguments);
if (this.rosterview) {
@@ -35721,14 +41956,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.rosterview.removeAll().remove();
}
},
+
ChatBoxes: {
- chatBoxMayBeShown: function chatBoxMayBeShown(chatbox) {
+ chatBoxMayBeShown(chatbox) {
return this.__super__.chatBoxMayBeShown.apply(this, arguments) && chatbox.get('id') !== 'controlbox';
}
+
},
ChatBoxViews: {
- closeAllChatBoxes: function closeAllChatBoxes() {
- var _converse = this.__super__._converse;
+ closeAllChatBoxes() {
+ const _converse = this.__super__._converse;
this.each(function (view) {
if (view.model.get('id') === 'controlbox' && (_converse.disconnection_cause !== _converse.LOGOUT || _converse.show_controlbox_by_default)) {
return;
@@ -35738,9 +41975,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this;
},
- getChatBoxWidth: function getChatBoxWidth(view) {
- var _converse = this.__super__._converse;
- var controlbox = this.get('controlbox');
+
+ getChatBoxWidth(view) {
+ const _converse = this.__super__._converse;
+ const controlbox = this.get('controlbox');
if (view.model.get('id') === 'controlbox') {
/* We return the width of the controlbox or its toggle,
@@ -35755,9 +41993,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.getChatBoxWidth.apply(this, arguments);
}
}
+
},
ChatBox: {
- initialize: function initialize() {
+ initialize() {
if (this.get('id') === 'controlbox') {
this.set({
'time_opened': moment(0).valueOf()
@@ -35766,10 +42005,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.__super__.initialize.apply(this, arguments);
}
}
+
},
ChatBoxView: {
- insertIntoDOM: function insertIntoDOM() {
- var view = this.__super__._converse.chatboxviews.get("controlbox");
+ insertIntoDOM() {
+ const view = this.__super__._converse.chatboxviews.get("controlbox");
if (view) {
view.el.insertAdjacentElement('afterend', this.el);
@@ -35779,14 +42019,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.settings.update({
allow_logout: true,
@@ -35798,7 +42040,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.api.promises.add('controlboxInitialized');
- _converse.addControlBox = function () {
+ _converse.addControlBox = () => {
return _converse.chatboxes.add({
'id': 'controlbox',
'box_id': 'controlbox',
@@ -35814,7 +42056,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
events: {
'click a.close-chatbox-button': 'close'
},
- initialize: function initialize() {
+
+ initialize() {
if (_.isUndefined(_converse.controlboxtoggle)) {
_converse.controlboxtoggle = new _converse.ControlBoxToggle();
}
@@ -35834,7 +42077,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('controlboxInitialized', this);
},
- render: function render() {
+
+ render() {
if (this.model.get('connected')) {
if (_.isUndefined(this.model.get('closed'))) {
this.model.set('closed', !_converse.show_controlbox_by_default);
@@ -35857,48 +42101,49 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- onConnected: function onConnected() {
+
+ onConnected() {
if (this.model.get('connected')) {
this.render();
this.insertRoster();
}
},
- insertRoster: function insertRoster() {
- var _this = this;
+ insertRoster() {
if (_converse.authentication === _converse.ANONYMOUS) {
return;
}
/* Place the rosterview inside the "Contacts" panel. */
- _converse.api.waitUntil('rosterViewInitialized').then(function () {
- return _this.controlbox_pane.el.insertAdjacentElement('beforeEnd', _converse.rosterview.el);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ _converse.api.waitUntil('rosterViewInitialized').then(() => this.controlbox_pane.el.insertAdjacentElement('beforeEnd', _converse.rosterview.el)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- createBrandHeadingHTML: function createBrandHeadingHTML() {
+
+ createBrandHeadingHTML() {
return tpl_brand_heading({
'sticky_controlbox': _converse.sticky_controlbox
});
},
- insertBrandHeading: function insertBrandHeading() {
- var heading_el = this.el.querySelector('.brand-heading-container');
+
+ insertBrandHeading() {
+ const heading_el = this.el.querySelector('.brand-heading-container');
if (_.isNull(heading_el)) {
- var el = this.el.querySelector('.controlbox-head');
+ const el = this.el.querySelector('.controlbox-head');
el.insertAdjacentHTML('beforeend', this.createBrandHeadingHTML());
} else {
heading_el.outerHTML = this.createBrandHeadingHTML();
}
},
- renderLoginPanel: function renderLoginPanel() {
+
+ renderLoginPanel() {
this.el.classList.add("logged-out");
if (_.isNil(this.loginpanel)) {
this.loginpanel = new _converse.LoginPanel({
'model': new _converse.LoginPanelModel()
});
- var panes = this.el.querySelector('.controlbox-panes');
+ const panes = this.el.querySelector('.controlbox-panes');
panes.innerHTML = '';
panes.appendChild(this.loginpanel.render().el);
this.insertBrandHeading();
@@ -35909,7 +42154,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.loginpanel.initPopovers();
return this;
},
- renderControlBoxPane: function renderControlBoxPane() {
+
+ renderControlBoxPane() {
/* Renders the "Contacts" panel of the controlbox.
*
* This will only be called after the user has already been
@@ -35924,7 +42170,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.controlbox_pane = new _converse.ControlBoxPane();
this.el.querySelector('.controlbox-panes').insertAdjacentElement('afterBegin', this.controlbox_pane.el);
},
- close: function close(ev) {
+
+ close(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -35945,14 +42192,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- ensureClosedState: function ensureClosedState() {
+
+ ensureClosedState() {
if (this.model.get('closed')) {
this.hide();
} else {
this.show();
}
},
- hide: function hide(callback) {
+
+ hide(callback) {
if (_converse.sticky_controlbox) {
return;
}
@@ -35969,18 +42218,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- onControlBoxToggleHidden: function onControlBoxToggleHidden() {
+
+ onControlBoxToggleHidden() {
this.model.set('closed', false);
this.el.classList.remove('hidden');
_converse.emit('controlBoxOpened', this);
},
- show: function show() {
+
+ show() {
_converse.controlboxtoggle.hide(this.onControlBoxToggleHidden.bind(this));
return this;
},
- showHelpMessages: function showHelpMessages() {
+
+ showHelpMessages() {
/* Override showHelpMessages in ChatBoxView, for now do nothing.
*
* Parameters:
@@ -35988,6 +42240,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
*/
return;
}
+
});
_converse.LoginPanelModel = Backbone.Model.extend({
defaults: {
@@ -36004,15 +42257,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'submit form#converse-login': 'authenticate',
'change input': 'validate'
},
- initialize: function initialize(cfg) {
+
+ initialize(cfg) {
this.model.on('change', this.render, this);
this.listenTo(_converse.connfeedback, 'change', this.render);
this.render();
},
- toHTML: function toHTML() {
- var connection_status = _converse.connfeedback.get('connection_status');
- var feedback_class, pretty_status;
+ toHTML() {
+ const connection_status = _converse.connfeedback.get('connection_status');
+
+ let feedback_class, pretty_status;
if (_.includes(REPORTABLE_STATUSES, connection_status)) {
pretty_status = PRETTY_CONNECTION_STATUS[connection_status];
@@ -36035,20 +42290,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'placeholder_username': (_converse.locked_domain || _converse.default_domain) && __('Username') || __('user@domain')
}));
},
- initPopovers: function initPopovers() {
- var _this2 = this;
- _.forEach(this.el.querySelectorAll('[data-title]'), function (el) {
- var popover = new bootstrap.Popover(el, {
+ initPopovers() {
+ _.forEach(this.el.querySelectorAll('[data-title]'), el => {
+ const popover = new bootstrap.Popover(el, {
'trigger': _converse.view_mode === 'mobile' && 'click' || 'hover',
'dismissible': _converse.view_mode === 'mobile' && true || false,
- 'container': _this2.el.parentElement.parentElement.parentElement
+ 'container': this.el.parentElement.parentElement.parentElement
});
});
},
- validate: function validate() {
- var form = this.el.querySelector('form');
- var jid_element = form.querySelector('input[name=jid]');
+
+ validate() {
+ const form = this.el.querySelector('form');
+ const jid_element = form.querySelector('input[name=jid]');
if (jid_element.value && !_converse.locked_domain && !_converse.default_domain && !u.isValidJID(jid_element.value)) {
jid_element.setCustomValidity(__('Please enter a valid XMPP address'));
@@ -36058,7 +42313,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
jid_element.setCustomValidity('');
return true;
},
- authenticate: function authenticate(ev) {
+
+ authenticate(ev) {
/* Authenticate the user based on a form submission event.
*/
if (ev && ev.preventDefault) {
@@ -36074,17 +42330,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var form_data = new FormData(ev.target);
+ const form_data = new FormData(ev.target);
_converse.config.save({
'trusted': form_data.get('trusted') && true || false,
'storage': form_data.get('trusted') ? 'local' : 'session'
});
- var jid = form_data.get('jid');
+ let jid = form_data.get('jid');
if (_converse.locked_domain) {
- var last_part = '@' + _converse.locked_domain;
+ const last_part = '@' + _converse.locked_domain;
if (jid.endsWith(last_part)) {
jid = jid.substr(0, jid.length - last_part.length);
@@ -36097,9 +42353,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.connect(jid, form_data.get('password'));
},
- connect: function connect(jid, password) {
+
+ connect(jid, password) {
if (jid) {
- var resource = Strophe.getResourceFromJid(jid);
+ const resource = Strophe.getResourceFromJid(jid);
if (!resource) {
jid = jid.toLowerCase() + _converse.generateResource();
@@ -36118,16 +42375,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.connection.connect(jid, password, _converse.onConnectStatusChanged);
}
+
});
_converse.ControlBoxPane = Backbone.NativeView.extend({
tagName: 'div',
className: 'controlbox-pane',
- initialize: function initialize() {
+
+ initialize() {
_converse.xmppstatusview = new _converse.XMPPStatusView({
'model': _converse.xmppstatus
});
this.el.insertAdjacentElement('afterBegin', _converse.xmppstatusview.render().el);
}
+
});
_converse.ControlBoxToggle = Backbone.NativeView.extend({
tagName: 'a',
@@ -36139,12 +42399,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
attributes: {
'href': "#"
},
- initialize: function initialize() {
+
+ initialize() {
_converse.chatboxviews.insertRowColumn(this.render().el);
_converse.api.waitUntil('initialized').then(this.render.bind(this)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- render: function render() {
+
+ render() {
// We let the render method of ControlBoxView decide whether
// the ControlBox or the Toggle must be shown. This prevents
// artifacts (i.e. on page load the toggle is shown only to then
@@ -36154,15 +42416,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this;
},
- hide: function hide(callback) {
+
+ hide(callback) {
u.hideElement(this.el);
callback();
},
- show: function show(callback) {
+
+ show(callback) {
u.fadeIn(this.el, callback);
},
- showControlBox: function showControlBox() {
- var controlbox = _converse.chatboxes.get('controlbox');
+
+ showControlBox() {
+ let controlbox = _converse.chatboxes.get('controlbox');
if (!controlbox) {
controlbox = _converse.addControlBox();
@@ -36176,11 +42441,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
controlbox.trigger('show');
}
},
- onClick: function onClick(e) {
+
+ onClick(e) {
e.preventDefault();
if (u.isVisible(_converse.root.querySelector("#controlbox"))) {
- var controlbox = _converse.chatboxes.get('controlbox');
+ const controlbox = _converse.chatboxes.get('controlbox');
if (_converse.connection.connected) {
controlbox.save({
@@ -36193,14 +42459,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showControlBox();
}
}
+
});
- _converse.on('chatBoxViewsInitialized', function () {
- var that = _converse.chatboxviews;
+ _converse.on('chatBoxViewsInitialized', () => {
+ const that = _converse.chatboxviews;
- _converse.chatboxes.on('add', function (item) {
+ _converse.chatboxes.on('add', item => {
if (item.get('type') === _converse.CONTROLBOX_TYPE) {
- var view = that.get(item.get('id'));
+ const view = that.get(item.get('id'));
if (view) {
view.model = item;
@@ -36214,12 +42481,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
- _converse.on('clearSession', function () {
+ _converse.on('clearSession', () => {
if (_converse.config.get('trusted')) {
- var chatboxes = _.get(_converse, 'chatboxes', null);
+ const chatboxes = _.get(_converse, 'chatboxes', null);
if (!_.isNil(chatboxes)) {
- var controlbox = chatboxes.get('controlbox');
+ const controlbox = chatboxes.get('controlbox');
if (controlbox && controlbox.collection && controlbox.collection.browserStorage) {
controlbox.save({
@@ -36232,20 +42499,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
Promise.all([_converse.api.waitUntil('connectionInitialized'), _converse.api.waitUntil('chatBoxViewsInitialized')]).then(_converse.addControlBox).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
- _converse.on('chatBoxesFetched', function () {
- var controlbox = _converse.chatboxes.get('controlbox') || _converse.addControlBox();
+ _converse.on('chatBoxesFetched', () => {
+ const controlbox = _converse.chatboxes.get('controlbox') || _converse.addControlBox();
controlbox.save({
connected: true
});
});
- var disconnect = function disconnect() {
+ const disconnect = function disconnect() {
/* Upon disconnection, set connected to `false`, so that if
* we reconnect, "onConnected" will be called,
* to fetch the roster again and to send out a presence stanza.
*/
- var view = _converse.chatboxviews.get('controlbox');
+ const view = _converse.chatboxviews.get('controlbox');
view.model.set({
'connected': false
@@ -36253,12 +42520,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return view;
};
- _converse.on('disconnected', function () {
- return disconnect().renderLoginPanel();
- });
+ _converse.on('disconnected', () => disconnect().renderLoginPanel());
_converse.on('will-reconnect', disconnect);
}
+
});
});
@@ -36271,30 +42537,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// https://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! sizzle */ "./node_modules/sizzle/dist/sizzle.js"), __webpack_require__(/*! es6-promise */ "es6-promise"), __webpack_require__(/*! lodash.noconflict */ "lodash.noconflict"), __webpack_require__(/*! lodash.fp */ "./src/lodash.fp.js"), __webpack_require__(/*! polyfill */ "./src/polyfill.js"), __webpack_require__(/*! i18n */ "./src/i18n.js"), __webpack_require__(/*! utils/core */ "./src/utils/core.js"), __webpack_require__(/*! moment */ "moment"), __webpack_require__(/*! strophe */ "strophe"), __webpack_require__(/*! pluggable */ "./node_modules/pluggable.js/dist/pluggable.js"), __webpack_require__(/*! backbone.noconflict */ "./src/backbone.noconflict.js"), __webpack_require__(/*! backbone.nativeview */ "./node_modules/backbone.nativeview/backbone.nativeview.js"), __webpack_require__(/*! backbone.browserStorage */ "backbone.browserStorage")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! sizzle */ "./node_modules/sizzle/dist/sizzle.js"), __webpack_require__(/*! es6-promise */ "es6-promise"), __webpack_require__(/*! lodash.noconflict */ "lodash.noconflict"), __webpack_require__(/*! lodash.fp */ "./src/lodash.fp.js"), __webpack_require__(/*! polyfill */ "./src/polyfill.js"), __webpack_require__(/*! i18n */ "./src/i18n.js"), __webpack_require__(/*! utils/core */ "./src/utils/core.js"), __webpack_require__(/*! moment */ "moment"), __webpack_require__(/*! strophe.js */ "./node_modules/strophe.js/dist/strophe.js"), __webpack_require__(/*! pluggable */ "./node_modules/pluggable.js/dist/pluggable.js"), __webpack_require__(/*! backbone.noconflict */ "./src/backbone.noconflict.js"), __webpack_require__(/*! backbone.nativeview */ "./node_modules/backbone.nativeview/backbone.nativeview.js"), __webpack_require__(/*! backbone.browserStorage */ "backbone.browserStorage")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (sizzle, Promise, _, f, polyfill, i18n, u, moment, Strophe, pluggable, Backbone) {
+})(this, function (sizzle, Promise, _, f, polyfill, i18n, u, moment, Strophe, pluggable, Backbone) {
"use strict"; // Strophe globals
- var _Strophe = Strophe,
- $build = _Strophe.$build,
- $iq = _Strophe.$iq,
- $msg = _Strophe.$msg,
- $pres = _Strophe.$pres;
- var b64_sha1 = Strophe.SHA1.b64_sha1;
+ const _Strophe = Strophe,
+ $build = _Strophe.$build,
+ $iq = _Strophe.$iq,
+ $msg = _Strophe.$msg,
+ $pres = _Strophe.$pres;
+ const b64_sha1 = Strophe.SHA1.b64_sha1;
Strophe = Strophe.Strophe; // Add Strophe Namespaces
Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
@@ -36306,6 +42567,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
+ Strophe.addNamespace('OMEMO', "eu.siacs.conversations.axolotl");
Strophe.addNamespace('OUTOFBAND', 'jabber:x:oob');
Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
Strophe.addNamespace('REGISTER', 'jabber:iq:register');
@@ -36336,7 +42598,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @namespace _converse
*/
- var _converse = {
+ const _converse = {
'templates': {},
'promises': {}
};
@@ -36348,7 +42610,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
// webserver, which is often also set to 60 and might therefore sometimes
// return a 504 error page instead of passing through to the BOSH proxy.
- var BOSH_WAIT = 59; // Make converse pluggable
+ const BOSH_WAIT = 59; // Make converse pluggable
pluggable.enable(_converse, '_converse', 'pluggable');
_converse.keycodes = {
@@ -36473,9 +42735,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
whitelisted_plugins: []
};
- _converse.log = function (message, level) {
- var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
-
+ _converse.log = function (message, level, style = '') {
/* Logs messages to the browser's developer console.
*
* Parameters:
@@ -36493,15 +42753,15 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
style = style || 'color: maroon';
}
- if (_instanceof(message, Error)) {
+ if (message instanceof Error) {
message = message.stack;
} else if (_.isElement(message)) {
message = message.outerHTML;
}
- var prefix = style ? '%c' : '';
+ const prefix = style ? '%c' : '';
- var logger = _.assign({
+ const logger = _.assign({
'debug': _.get(console, 'log') ? console.log.bind(console) : _.noop,
'error': _.get(console, 'log') ? console.log.bind(console) : _.noop,
'info': _.get(console, 'log') ? console.log.bind(console) : _.noop,
@@ -36509,18 +42769,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}, console);
if (level === Strophe.LogLevel.ERROR) {
- logger.error("".concat(prefix, " ERROR: ").concat(message), style);
+ logger.error(`${prefix} ERROR: ${message}`, style);
} else if (level === Strophe.LogLevel.WARN) {
if (_converse.debug) {
- logger.warn("".concat(prefix, " ").concat(moment().format(), " WARNING: ").concat(message), style);
+ logger.warn(`${prefix} ${moment().format()} WARNING: ${message}`, style);
}
} else if (level === Strophe.LogLevel.FATAL) {
- logger.error("".concat(prefix, " FATAL: ").concat(message), style);
+ logger.error(`${prefix} FATAL: ${message}`, style);
} else if (_converse.debug) {
if (level === Strophe.LogLevel.DEBUG) {
- logger.debug("".concat(prefix, " ").concat(moment().format(), " DEBUG: ").concat(message), style);
+ logger.debug(`${prefix} ${moment().format()} DEBUG: ${message}`, style);
} else {
- logger.info("".concat(prefix, " ").concat(moment().format(), " INFO: ").concat(message), style);
+ logger.info(`${prefix} ${moment().format()} INFO: ${message}`, style);
}
}
};
@@ -36546,8 +42806,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return i18n.translate.apply(i18n, arguments);
};
- var __ = _converse.__;
- var PROMISES = ['initialized', 'connectionInitialized', 'pluginsInitialized', 'statusInitialized'];
+ const __ = _converse.__;
+ const PROMISES = ['initialized', 'connectionInitialized', 'pluginsInitialized', 'statusInitialized'];
function addPromise(promise) {
/* Private function, used to add a new promise to the ones already
@@ -36560,7 +42820,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/* Event emitter and promise resolver */
_converse.trigger.apply(this, arguments);
- var promise = _converse.promises[name];
+ const promise = _converse.promises[name];
if (!_.isUndefined(promise)) {
promise.resolve();
@@ -36574,10 +42834,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.router = new Backbone.Router();
_converse.initialize = function (settings, callback) {
- var _this = this;
-
settings = !_.isUndefined(settings) ? settings : {};
- var init_promise = u.getResolveablePromise();
+ const init_promise = u.getResolveablePromise();
_.each(PROMISES, addPromise);
@@ -36658,9 +42916,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
// Module-level functions
// ----------------------
- this.generateResource = function () {
- return "/converse.js-".concat(Math.floor(Math.random() * 139749528).toString());
- };
+ this.generateResource = () => `/converse.js-${Math.floor(Math.random() * 139749528).toString()}`;
this.sendCSI = function (stat) {
/* Send out a Chat Status Notification (XEP-0352)
@@ -36712,7 +42968,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return;
}
- var stat = _converse.xmppstatus.get('status');
+ const stat = _converse.xmppstatus.get('status');
_converse.idle_seconds++;
@@ -36747,7 +43003,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
window.addEventListener('focus', _converse.onUserActivity);
window.addEventListener('keypress', _converse.onUserActivity);
window.addEventListener('mousemove', _converse.onUserActivity);
- var options = {
+ const options = {
'once': true,
'passive': true
};
@@ -36770,7 +43026,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* is being canceled.
* (String) message - An optional message to the user
*/
- var pres = $pres({
+ const pres = $pres({
to: jid,
type: "unsubscribed"
});
@@ -36817,7 +43073,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* Will either start a teardown process for converse.js or attempt
* to reconnect.
*/
- var reason = _converse.disconnection_reason;
+ const reason = _converse.disconnection_reason;
if (_converse.disconnection_cause === Strophe.Status.AUTHFAIL) {
if (_converse.credentials_url && _converse.auto_reconnect) {
@@ -36857,7 +43113,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* through various states while establishing or tearing down a
* connection.
*/
- _converse.log("Status changed to: ".concat(_converse.CONNECTION_STATUS[status]));
+ _converse.log(`Status changed to: ${_converse.CONNECTION_STATUS[status]}`);
if (status === Strophe.Status.CONNECTED || status === Strophe.Status.ATTACHED) {
_converse.setConnectionStatus(status); // By default we always want to send out an initial presence stanza.
@@ -36903,10 +43159,10 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.onDisconnected();
} else if (status === Strophe.Status.CONNFAIL) {
- var feedback = message;
+ let feedback = message;
if (message === "host-unknown" || message == "remote-connection-failed") {
- feedback = __("Sorry, we could not connect to the XMPP host with domain: %1$s", "\"".concat(Strophe.getDomainFromJid(_converse.connection.jid), "\""));
+ feedback = __("Sorry, we could not connect to the XMPP host with domain: %1$s", `\"${Strophe.getDomainFromJid(_converse.connection.jid)}\"`);
} else if (!_.isUndefined(message) && message === _.get(Strophe, 'ErrorCondition.NO_AUTH_MECH')) {
feedback = __("The XMPP server did not offer a supported authentication mechanism");
}
@@ -36921,23 +43177,23 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.incrementMsgCounter = function () {
this.msg_counter += 1;
- var unreadMsgCount = this.msg_counter;
- var title = document.title;
+ const unreadMsgCount = this.msg_counter;
+ let title = document.title;
if (_.isNil(title)) {
return;
}
if (title.search(/^Messages \(\d+\) /) === -1) {
- title = "Messages (".concat(unreadMsgCount, ") ").concat(title);
+ title = `Messages (${unreadMsgCount}) ${title}`;
} else {
- title = title.replace(/^Messages \(\d+\) /, "Messages (".concat(unreadMsgCount, ")"));
+ title = title.replace(/^Messages \(\d+\) /, `Messages (${unreadMsgCount})`);
}
};
this.clearMsgCounter = function () {
this.msg_counter = 0;
- var title = document.title;
+ let title = document.title;
if (_.isNil(title)) {
return;
@@ -36948,7 +43204,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
};
- this.initStatus = function (reconnecting) {
+ this.initStatus = reconnecting => {
// If there's no xmppstatus obj, then we were never connected to
// begin with, so we set reconnecting to false.
reconnecting = _.isUndefined(_converse.xmppstatus) ? false : reconnecting;
@@ -36956,13 +43212,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
if (reconnecting) {
_converse.onStatusInitialized(reconnecting);
} else {
- var id = "converse.xmppstatus-".concat(_converse.bare_jid);
- _this.xmppstatus = new _this.XMPPStatus({
+ const id = `converse.xmppstatus-${_converse.bare_jid}`;
+ this.xmppstatus = new this.XMPPStatus({
'id': id
});
- _this.xmppstatus.browserStorage = new Backbone.BrowserStorage.session(id);
-
- _this.xmppstatus.fetch({
+ this.xmppstatus.browserStorage = new Backbone.BrowserStorage.session(id);
+ this.xmppstatus.fetch({
'success': _.partial(_converse.onStatusInitialized, reconnecting),
'error': _.partial(_converse.onStatusInitialized, reconnecting)
});
@@ -36975,7 +43230,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* What this means is that config values need to persist across
* user sessions.
*/
- var id = b64_sha1('converse.client-config');
+ const id = b64_sha1('converse.client-config');
_converse.config = new Backbone.Model({
'id': id,
'trusted': _converse.trusted && true || false,
@@ -36989,7 +43244,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
};
this.initSession = function () {
- var id = b64_sha1('converse.bosh-session');
+ const id = b64_sha1('converse.bosh-session');
_converse.session = new Backbone.Model({
'id': id
});
@@ -37032,8 +43287,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
// XXX: eventually we should be able to just use
// document.visibilityState (when we drop support for older
// browsers).
- var state;
- var event_map = {
+ let state;
+ const event_map = {
'focus': "visible",
'focusin': "visible",
'pageshow': "visible",
@@ -37056,14 +43311,14 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.windowState = state;
_converse.emit('windowStateChanged', {
- state: state
+ state
});
};
this.registerGlobalEventHandlers = function () {
// Taken from:
// http://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active
- var hidden = "hidden"; // Standards:
+ let hidden = "hidden"; // Standards:
if (hidden in document) {
document.addEventListener("visibilitychange", _.partial(_converse.saveWindowState, _, hidden));
@@ -37092,8 +43347,6 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
};
this.enableCarbons = function () {
- var _this2 = this;
-
/* Ask the XMPP server to enable Message Carbons
* See XEP-0280 https://xmpp.org/extensions/xep-0280.html#enabling
*/
@@ -37101,18 +43354,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return;
}
- var carbons_iq = new Strophe.Builder('iq', {
+ const carbons_iq = new Strophe.Builder('iq', {
'from': this.connection.jid,
'id': 'enablecarbons',
'type': 'set'
}).c('enable', {
xmlns: Strophe.NS.CARBONS
});
- this.connection.addHandler(function (iq) {
+ this.connection.addHandler(iq => {
if (iq.querySelectorAll('error').length > 0) {
_converse.log('An error occurred while trying to enable message carbons.', Strophe.LogLevel.WARN);
} else {
- _this2.session.save({
+ this.session.save({
'carbons_enabled': true
});
@@ -37172,23 +43425,24 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'connection_status': Strophe.Status.DISCONNECTED,
'message': ''
},
- initialize: function initialize() {
- this.on('change', function () {
+
+ initialize() {
+ this.on('change', () => {
_converse.emit('connfeedback', _converse.connfeedback);
});
}
+
});
this.connfeedback = new this.ConnectionFeedback();
this.XMPPStatus = Backbone.Model.extend({
- defaults: function defaults() {
+ defaults() {
return {
"jid": _converse.bare_jid,
"status": _converse.default_state
};
},
- initialize: function initialize() {
- var _this3 = this;
+ initialize() {
this.vcard = _converse.vcards.findWhere({
'jid': this.get('jid')
});
@@ -37199,23 +43453,22 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
}
- this.on('change:status', function (item) {
- var status = _this3.get('status');
-
- _this3.sendPresence(status);
+ this.on('change:status', item => {
+ const status = this.get('status');
+ this.sendPresence(status);
_converse.emit('statusChanged', status);
});
- this.on('change:status_message', function () {
- var status_message = _this3.get('status_message');
-
- _this3.sendPresence(_this3.get('status'), status_message);
+ this.on('change:status_message', () => {
+ const status_message = this.get('status_message');
+ this.sendPresence(this.get('status'), status_message);
_converse.emit('statusMessageChanged', status_message);
});
},
- constructPresence: function constructPresence(type, status_message) {
- var presence;
+
+ constructPresence(type, status_message) {
+ let presence;
type = _.isString(type) ? type : this.get('status') || _converse.default_state;
status_message = _.isString(status_message) ? status_message : this.get('status_message'); // Most of these presence types are actually not explicitly sent,
// but I add all of them here for reference and future proofing.
@@ -37241,9 +43494,11 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
presence.c('priority').t(_.isNaN(Number(_converse.priority)) ? 0 : _converse.priority);
return presence;
},
- sendPresence: function sendPresence(type, status_message) {
+
+ sendPresence(type, status_message) {
_converse.connection.send(this.constructPresence(type, status_message));
}
+
});
this.setUpXMLLogging = function () {
@@ -37262,44 +43517,42 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
};
- this.fetchLoginCredentials = function () {
- return new Promise(function (resolve, reject) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', _converse.credentials_url, true);
- xhr.setRequestHeader('Accept', "application/json, text/javascript");
+ this.fetchLoginCredentials = () => new Promise((resolve, reject) => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', _converse.credentials_url, true);
+ xhr.setRequestHeader('Accept', "application/json, text/javascript");
- xhr.onload = function () {
- if (xhr.status >= 200 && xhr.status < 400) {
- var data = JSON.parse(xhr.responseText);
- resolve({
- 'jid': data.jid,
- 'password': data.password
- });
- } else {
- xhr.onerror();
- }
- };
+ xhr.onload = function () {
+ if (xhr.status >= 200 && xhr.status < 400) {
+ const data = JSON.parse(xhr.responseText);
+ resolve({
+ 'jid': data.jid,
+ 'password': data.password
+ });
+ } else {
+ xhr.onerror();
+ }
+ };
- xhr.onerror = function () {
- delete _converse.connection;
+ xhr.onerror = function () {
+ delete _converse.connection;
- _converse.emit('noResumeableSession', this);
+ _converse.emit('noResumeableSession', this);
- reject(xhr.responseText);
- };
+ reject(xhr.responseText);
+ };
- xhr.send();
- });
- };
+ xhr.send();
+ });
this.startNewBOSHSession = function () {
- var xhr = new XMLHttpRequest();
+ const xhr = new XMLHttpRequest();
xhr.open('GET', _converse.prebind_url, true);
xhr.setRequestHeader('Accept', "application/json, text/javascript");
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 400) {
- var data = JSON.parse(xhr.responseText);
+ const data = JSON.parse(xhr.responseText);
_converse.connection.attach(data.jid, data.sid, data.rid, _converse.onConnectStatusChanged);
} else {
@@ -37319,7 +43572,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.restoreBOSHSession = function (jid_is_required) {
/* Tries to restore a cached BOSH session. */
if (!this.jid) {
- var msg = "restoreBOSHSession: tried to restore a \"keepalive\" session " + "but we don't have the JID for the user!";
+ const msg = "restoreBOSHSession: tried to restore a \"keepalive\" session " + "but we don't have the JID for the user!";
if (jid_is_required) {
throw new Error(msg);
@@ -37408,7 +43661,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.connection.connect(this.jid.toLowerCase(), null, this.onConnectStatusChanged, BOSH_WAIT);
} else if (this.authentication === _converse.LOGIN) {
- var password = _.isNil(credentials) ? _converse.connection.pass || this.password : credentials.password;
+ const password = _.isNil(credentials) ? _converse.connection.pass || this.password : credentials.password;
if (!password) {
if (this.auto_login) {
@@ -37422,7 +43675,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return;
}
- var resource = Strophe.getResourceFromJid(this.jid);
+ const resource = Strophe.getResourceFromJid(this.jid);
if (!resource) {
this.jid = this.jid.toLowerCase() + _converse.generateResource();
@@ -37501,21 +43754,22 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
// in any case.
_converse.pluggable.initialized_plugins = [];
- var whitelist = _converse.core_plugins.concat(_converse.whitelisted_plugins);
+ const whitelist = _converse.core_plugins.concat(_converse.whitelisted_plugins);
if (_converse.view_mode === 'embedded') {
_.forEach([// eslint-disable-line lodash/prefer-map
- "converse-bookmarks", "converse-controlbox", "converse-headline", "converse-register"], function (name) {
+ "converse-bookmarks", "converse-controlbox", "converse-headline", "converse-register"], name => {
_converse.blacklisted_plugins.push(name);
});
}
_converse.pluggable.initializePlugins({
- 'updateSettings': function updateSettings() {
+ 'updateSettings'() {
_converse.log("(DEPRECATION) " + "The `updateSettings` method has been deprecated. " + "Please use `_converse.api.settings.update` instead.", Strophe.LogLevel.WARN);
_converse.api.settings.update.apply(_converse, arguments);
},
+
'_converse': _converse
}, whitelist, _converse.blacklisted_plugins);
@@ -37555,9 +43809,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
} else {
i18n.fetchTranslations(_converse.locale, _converse.locales, u.interpolate(_converse.locales_url, {
'locale': _converse.locale
- })).catch(function (e) {
- return _converse.log(e.message, Strophe.LogLevel.FATAL);
- }).then(finishInitialization).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ })).catch(e => _converse.log(e.message, Strophe.LogLevel.FATAL)).then(finishInitialization).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
return init_promise;
@@ -37590,7 +43842,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @memberOf _converse.api.connection
* @returns {boolean} Whether there is an established connection or not.
*/
- 'connected': function connected() {
+ 'connected'() {
return _converse.connection && _converse.connection.connected || false;
},
@@ -37600,9 +43852,10 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @method _converse.api.connection.disconnect
* @memberOf _converse.api.connection
*/
- 'disconnect': function disconnect() {
+ 'disconnect'() {
_converse.connection.disconnect();
}
+
},
/**
@@ -37612,7 +43865,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
*
* @method _converse.api.emit
*/
- 'emit': function emit() {
+ 'emit'() {
_converse.emit.apply(_converse, arguments);
},
@@ -37628,7 +43881,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @returns {string} The current user's full JID (Jabber ID)
* @example _converse.api.user.jid())
*/
- 'jid': function jid() {
+ 'jid'() {
return _converse.connection.jid;
},
@@ -37653,7 +43906,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* }
* });
*/
- 'login': function login(credentials) {
+ 'login'(credentials) {
_converse.logIn(credentials);
},
@@ -37663,7 +43916,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @method _converse.api.user.logout
* @example _converse.api.user.logout();
*/
- 'logout': function logout() {
+ 'logout'() {
_converse.logOut();
},
@@ -37679,7 +43932,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @method _converse.api.user.status.get
* @example _converse.api.user.status.get();
*/
- 'get': function get() {
+ 'get'() {
return _converse.xmppstatus.get('status');
},
@@ -37693,8 +43946,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @example this._converse.api.user.status.set('dnd');
* @example this._converse.api.user.status.set('dnd', 'In a meeting');
*/
- 'set': function set(value, message) {
- var data = {
+ 'set'(value, message) {
+ const data = {
'status': value
};
@@ -37723,7 +43976,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @returns {string} The status message
* @example const message = _converse.api.user.status.message.get()
*/
- 'get': function get() {
+ 'get'() {
return _converse.xmppstatus.get('status_message');
},
@@ -37732,11 +43985,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @param {string} status The status message
* @example _converse.api.user.status.message.set('In a meeting');
*/
- 'set': function set(status) {
+ 'set'(status) {
_converse.xmppstatus.save({
'status_message': status
});
}
+
}
}
},
@@ -37767,7 +44021,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* 'enable_foo': false
* });
*/
- 'update': function update(settings) {
+ 'update'(settings) {
u.merge(_converse.default_settings, settings);
u.merge(_converse, settings);
u.applyUserSettings(_converse, settings, _converse.user_settings);
@@ -37778,7 +44032,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @returns {*} Value of the particular configuration setting.
* @example _converse.api.settings.get("play_sounds");
*/
- 'get': function get(key) {
+ 'get'(key) {
if (_.includes(_.keys(_converse.default_settings), key)) {
return _converse[key];
}
@@ -37802,8 +44056,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* "hide_offline_users" true
* });
*/
- 'set': function set(key, val) {
- var o = {};
+ 'set'(key, val) {
+ const o = {};
if (_.isObject(key)) {
_.assignIn(_converse, _.pick(key, _.keys(_converse.default_settings)));
@@ -37813,6 +44067,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_.assignIn(_converse, _.pick(o, _.keys(_converse.default_settings)));
}
}
+
},
/**
@@ -37859,11 +44114,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @param {string|array} [name|names] The name or an array of names for the promise(s) to be added
* @example _converse.api.promises.add('foo-completed');
*/
- 'add': function add(promises) {
+ 'add'(promises) {
promises = _.isArray(promises) ? promises : [promises];
_.each(promises, addPromise);
}
+
},
/**
@@ -37879,7 +44135,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @returns 'string' A token, either the RID or SID token depending on what's asked for.
* @example _converse.api.tokens.get('rid');
*/
- 'get': function get(id) {
+ 'get'(id) {
if (!_converse.expose_rid_and_sid || _.isUndefined(_converse.connection)) {
return null;
}
@@ -37890,6 +44146,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return _converse.connection.sid || _converse.connection._proto.sid;
}
}
+
},
/**
@@ -37949,7 +44206,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* (e.g. 'ns' for namespace, 'type' for stanza type, also 'id' and 'from');
* @param {function} handler The callback method to be called when the stanza appears
*/
- 'stanza': function stanza(name, options, handler) {
+ 'stanza'(name, options, handler) {
if (_.isFunction(options)) {
handler = options;
options = {};
@@ -37959,6 +44216,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.connection.addHandler(handler, options.ns, name, options.type, options.id, options.from, options);
}
+
},
/**
@@ -37968,8 +44226,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @param {string} name The name of the promise
* @returns {Promise}
*/
- 'waitUntil': function waitUntil(name) {
- var promise = _converse.promises[name];
+ 'waitUntil'(name) {
+ const promise = _converse.promises[name];
if (_.isUndefined(promise)) {
return null;
@@ -37990,7 +44248,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* });
* _converse.api.send(msg);
*/
- 'send': function send(stanza) {
+ 'send'(stanza) {
_converse.connection.send(stanza);
},
@@ -38001,11 +44259,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @returns {Promise} A promise which resolves when we receive a `result` stanza
* or is rejected when we receive an `error` stanza.
*/
- 'sendIQ': function sendIQ(stanza) {
- return new Promise(function (resolve, reject) {
+ 'sendIQ'(stanza) {
+ return new Promise((resolve, reject) => {
_converse.connection.sendIQ(stanza, resolve, reject, _converse.IQ_TIMEOUT);
});
}
+
};
/**
* ### The Public API
@@ -38020,7 +44279,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @namespace converse
*/
- var converse = {
+ const converse = {
/**
* Public API method which initializes Converse.
* This method must always be called when using Converse.
@@ -38045,7 +44304,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* roster_groups: true
* });
*/
- 'initialize': function initialize(settings, callback) {
+ 'initialize'(settings, callback) {
return _converse.initialize(settings, callback);
},
@@ -38080,15 +44339,16 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* }
* converse.plugins.add('myplugin', plugin);
*/
- 'add': function add(name, plugin) {
+ 'add'(name, plugin) {
plugin.__name__ = name;
if (!_.isUndefined(_converse.pluggable.plugins[name])) {
- throw new TypeError("Error: plugin with name \"".concat(name, "\" has already been ") + 'registered!');
+ throw new TypeError(`Error: plugin with name "${name}" has already been ` + 'registered!');
} else {
_converse.pluggable.plugins[name] = plugin;
}
}
+
},
/**
@@ -38139,10 +44399,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2013-2018, the Converse developers
@@ -38154,22 +44411,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, sizzle) {
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- $iq = _converse$env.$iq,
- b64_sha1 = _converse$env.b64_sha1,
- utils = _converse$env.utils,
- _ = _converse$env._,
- f = _converse$env.f;
+})(this, function (converse, sizzle) {
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ $iq = _converse$env.$iq,
+ b64_sha1 = _converse$env.b64_sha1,
+ utils = _converse$env.utils,
+ _ = _converse$env._,
+ f = _converse$env.f;
converse.plugins.add('converse-disco', {
- initialize: function initialize() {
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse; // Promises exposed by this plugin
+ const _converse = this._converse; // Promises exposed by this plugin
_converse.api.promises.add('discoInitialized');
@@ -38180,24 +44437,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* See XEP-0030: https://xmpp.org/extensions/xep-0030.html
*/
idAttribute: 'jid',
- initialize: function initialize() {
+
+ initialize() {
this.waitUntilFeaturesDiscovered = utils.getResolveablePromise();
this.dataforms = new Backbone.Collection();
- this.dataforms.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.dataforms-{this.get('jid')}"));
+ this.dataforms.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.dataforms-{this.get('jid')}`));
this.features = new Backbone.Collection();
- this.features.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.features-".concat(this.get('jid'))));
+ this.features.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.features-${this.get('jid')}`));
this.features.on('add', this.onFeatureAdded, this);
this.fields = new Backbone.Collection();
- this.fields.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.fields-".concat(this.get('jid'))));
+ this.fields.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.fields-${this.get('jid')}`));
this.fields.on('add', this.onFieldAdded, this);
this.identities = new Backbone.Collection();
- this.identities.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.identities-".concat(this.get('jid'))));
+ this.identities.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.identities-${this.get('jid')}`));
this.fetchFeatures();
this.items = new _converse.DiscoEntities();
- this.items.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.disco-items-".concat(this.get('jid'))));
+ this.items.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.disco-items-${this.get('jid')}`));
this.items.fetch();
},
- getIdentity: function getIdentity(category, type) {
+
+ getIdentity(category, type) {
/* Returns a Promise which resolves with a map indicating
* whether a given identity is provided.
*
@@ -38205,10 +44464,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (String) category - The identity category
* (String) type - The identity type
*/
- var entity = this;
- return new Promise(function (resolve, reject) {
+ const entity = this;
+ return new Promise((resolve, reject) => {
function fulfillPromise() {
- var model = entity.identities.findWhere({
+ const model = entity.identities.findWhere({
'category': category,
'type': type
});
@@ -38218,15 +44477,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
entity.waitUntilFeaturesDiscovered.then(fulfillPromise).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
});
},
- hasFeature: function hasFeature(feature) {
+
+ hasFeature(feature) {
/* Returns a Promise which resolves with a map indicating
* whether a given feature is supported.
*
* Parameters:
* (String) feature - The feature that might be supported.
*/
- var entity = this;
- return new Promise(function (resolve, reject) {
+ const entity = this;
+ return new Promise((resolve, reject) => {
function fulfillPromise() {
if (entity.features.findWhere({
'var': feature
@@ -38240,28 +44500,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
entity.waitUntilFeaturesDiscovered.then(fulfillPromise).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
});
},
- onFeatureAdded: function onFeatureAdded(feature) {
+
+ onFeatureAdded(feature) {
feature.entity = this;
_converse.emit('serviceDiscovered', feature);
},
- onFieldAdded: function onFieldAdded(field) {
+
+ onFieldAdded(field) {
field.entity = this;
_converse.emit('discoExtensionFieldDiscovered', field);
},
- fetchFeatures: function fetchFeatures() {
- var _this = this;
+ fetchFeatures() {
if (this.features.browserStorage.records.length === 0) {
this.queryInfo();
} else {
this.features.fetch({
add: true,
- success: function success() {
- _this.waitUntilFeaturesDiscovered.resolve(_this);
-
- _this.trigger('featuresDiscovered');
+ success: () => {
+ this.waitUntilFeaturesDiscovered.resolve(this);
+ this.trigger('featuresDiscovered');
}
});
this.identities.fetch({
@@ -38269,45 +44529,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
},
- queryInfo: function queryInfo() {
- var _this2 = this;
- _converse.api.disco.info(this.get('jid'), null).then(function (stanza) {
- return _this2.onInfo(stanza);
- }).catch(function (iq) {
- _this2.waitUntilFeaturesDiscovered.resolve(_this2);
+ queryInfo() {
+ _converse.api.disco.info(this.get('jid'), null).then(stanza => this.onInfo(stanza)).catch(iq => {
+ this.waitUntilFeaturesDiscovered.resolve(this);
_converse.log(iq, Strophe.LogLevel.ERROR);
});
},
- onDiscoItems: function onDiscoItems(stanza) {
- var _this3 = this;
- _.each(sizzle("query[xmlns=\"".concat(Strophe.NS.DISCO_ITEMS, "\"] item"), stanza), function (item) {
+ onDiscoItems(stanza) {
+ _.each(sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"] item`, stanza), item => {
if (item.getAttribute("node")) {
// XXX: ignore nodes for now.
// See: https://xmpp.org/extensions/xep-0030.html#items-nodes
return;
}
- var jid = item.getAttribute('jid');
+ const jid = item.getAttribute('jid');
- if (_.isUndefined(_this3.items.get(jid))) {
- var entity = _converse.disco_entities.get(jid);
+ if (_.isUndefined(this.items.get(jid))) {
+ const entity = _converse.disco_entities.get(jid);
if (entity) {
- _this3.items.add(entity);
+ this.items.add(entity);
} else {
- _this3.items.create({
+ this.items.create({
'jid': jid
});
}
}
});
},
- queryForItems: function queryForItems() {
- var _this4 = this;
+ queryForItems() {
if (_.isEmpty(this.identities.where({
'category': 'server'
}))) {
@@ -38316,48 +44571,45 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- _converse.api.disco.items(this.get('jid')).then(function (stanza) {
- return _this4.onDiscoItems(stanza);
- });
+ _converse.api.disco.items(this.get('jid')).then(stanza => this.onDiscoItems(stanza));
},
- onInfo: function onInfo(stanza) {
- var _this5 = this;
- _.forEach(stanza.querySelectorAll('identity'), function (identity) {
- _this5.identities.create({
+ onInfo(stanza) {
+ _.forEach(stanza.querySelectorAll('identity'), identity => {
+ this.identities.create({
'category': identity.getAttribute('category'),
'type': identity.getAttribute('type'),
'name': identity.getAttribute('name')
});
});
- _.each(sizzle("x[type=\"result\"][xmlns=\"".concat(Strophe.NS.XFORM, "\"]"), stanza), function (form) {
- var data = {};
+ _.each(sizzle(`x[type="result"][xmlns="${Strophe.NS.XFORM}"]`, stanza), form => {
+ const data = {};
- _.each(form.querySelectorAll('field'), function (field) {
+ _.each(form.querySelectorAll('field'), field => {
data[field.getAttribute('var')] = {
'value': _.get(field.querySelector('value'), 'textContent'),
'type': field.getAttribute('type')
};
});
- _this5.dataforms.create(data);
+ this.dataforms.create(data);
});
- if (stanza.querySelector("feature[var=\"".concat(Strophe.NS.DISCO_ITEMS, "\"]"))) {
+ if (stanza.querySelector(`feature[var="${Strophe.NS.DISCO_ITEMS}"]`)) {
this.queryForItems();
}
- _.forEach(stanza.querySelectorAll('feature'), function (feature) {
- _this5.features.create({
+ _.forEach(stanza.querySelectorAll('feature'), feature => {
+ this.features.create({
'var': feature.getAttribute('var'),
'from': stanza.getAttribute('from')
});
}); // XEP-0128 Service Discovery Extensions
- _.forEach(sizzle('x[type="result"][xmlns="jabber:x:data"] field', stanza), function (field) {
- _this5.fields.create({
+ _.forEach(sizzle('x[type="result"][xmlns="jabber:x:data"] field', stanza), field => {
+ this.fields.create({
'var': field.getAttribute('var'),
'value': _.get(field.querySelector('value'), 'textContent'),
'from': stanza.getAttribute('from')
@@ -38367,22 +44619,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.waitUntilFeaturesDiscovered.resolve(this);
this.trigger('featuresDiscovered');
}
+
});
_converse.DiscoEntities = Backbone.Collection.extend({
model: _converse.DiscoEntity,
- fetchEntities: function fetchEntities() {
- var _this6 = this;
- return new Promise(function (resolve, reject) {
- _this6.fetch({
+ fetchEntities() {
+ return new Promise((resolve, reject) => {
+ this.fetch({
add: true,
success: resolve,
- error: function error() {
+
+ error() {
reject(new Error("Could not fetch disco entities"));
}
+
});
});
}
+
});
function addClientFeatures() {
@@ -38409,12 +44664,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
function initStreamFeatures() {
_converse.stream_features = new Backbone.Collection();
- _converse.stream_features.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.stream-features-".concat(_converse.bare_jid)));
+ _converse.stream_features.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.stream-features-${_converse.bare_jid}`));
_converse.stream_features.fetch({
- success: function success(collection) {
+ success(collection) {
if (collection.length === 0 && _converse.connection.features) {
- _.forEach(_converse.connection.features.childNodes, function (feature) {
+ _.forEach(_converse.connection.features.childNodes, feature => {
_converse.stream_features.create({
'name': feature.nodeName,
'xmlns': feature.getAttribute('xmlns')
@@ -38422,6 +44677,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
}
+
});
_converse.emit('streamFeaturesAdded');
@@ -38433,9 +44689,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.connection.addHandler(onDiscoInfoRequest, Strophe.NS.DISCO_INFO, 'iq', 'get', null, null);
_converse.disco_entities = new _converse.DiscoEntities();
- _converse.disco_entities.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.disco-entities-".concat(_converse.bare_jid)));
+ _converse.disco_entities.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.disco-entities-${_converse.bare_jid}`));
- _converse.disco_entities.fetchEntities().then(function (collection) {
+ _converse.disco_entities.fetchEntities().then(collection => {
if (collection.length === 0 || !collection.get(_converse.domain)) {
// If we don't have an entity for our own XMPP server,
// create one.
@@ -38454,9 +44710,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.api.listen.on('connected', initializeDisco);
- _converse.api.listen.on('beforeTearDown', function () {
+ _converse.api.listen.on('beforeTearDown', () => {
if (_converse.disco_entities) {
- _converse.disco_entities.each(function (entity) {
+ _converse.disco_entities.each(entity => {
entity.features.reset();
entity.features.browserStorage._clear();
@@ -38468,13 +44724,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
});
- var plugin = this;
+ const plugin = this;
plugin._identities = [];
plugin._features = [];
function onDiscoInfoRequest(stanza) {
- var node = stanza.getElementsByTagName('query')[0].getAttribute('node');
- var attrs = {
+ const node = stanza.getElementsByTagName('query')[0].getAttribute('node');
+ const attrs = {
xmlns: Strophe.NS.DISCO_INFO
};
@@ -38482,11 +44738,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
attrs.node = node;
}
- var iqresult = $iq({
+ const iqresult = $iq({
'type': 'result',
'id': stanza.getAttribute('id')
});
- var from = stanza.getAttribute('from');
+ const from = stanza.getAttribute('from');
if (from !== null) {
iqresult.attrs({
@@ -38496,8 +44752,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
iqresult.c('query', attrs);
- _.each(plugin._identities, function (identity) {
- var attrs = {
+ _.each(plugin._identities, identity => {
+ const attrs = {
'category': identity.category,
'type': identity.type
};
@@ -38513,7 +44769,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
iqresult.c('identity', attrs).up();
});
- _.each(plugin._features, function (feature) {
+ _.each(plugin._features, feature => {
iqresult.c('feature', {
'var': feature
}).up();
@@ -38579,7 +44835,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
*
* @example _converse.api.disco.own.identities.clear();
*/
- add: function add(category, type, name, lang) {
+ add(category, type, name, lang) {
for (var i = 0; i < plugin._identities.length; i++) {
if (plugin._identities[i].category == category && plugin._identities[i].type == type && plugin._identities[i].name == name && plugin._identities[i].lang == lang) {
return false;
@@ -38599,7 +44855,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @method _converse.api.disco.own.identities.clear
* @example _converse.api.disco.own.identities.clear();
*/
- clear: function clear() {
+ clear() {
plugin._identities = [];
},
@@ -38609,9 +44865,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @method _converse.api.disco.identities.get
* @example const identities = _converse.api.disco.own.identities.get();
*/
- get: function get() {
+ get() {
return plugin._identities;
}
+
},
/**
@@ -38625,7 +44882,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @param {String} name - e.g. http://jabber.org/protocol/caps
* @example _converse.api.disco.own.features.add("http://jabber.org/protocol/caps");
*/
- add: function add(name) {
+ add(name) {
for (var i = 0; i < plugin._features.length; i++) {
if (plugin._features[i] == name) {
return false;
@@ -38640,7 +44897,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @method _converse.api.disco.own.features.clear
* @example _converse.api.disco.own.features.clear();
*/
- clear: function clear() {
+ clear() {
plugin._features = [];
},
@@ -38649,9 +44906,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @method _converse.api.disco.own.features.get
* @example const features = _converse.api.disco.own.features.get();
*/
- get: function get() {
+ get() {
return plugin._features;
}
+
}
},
@@ -38663,8 +44921,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @param {string} [node] A specific node identifier associated with the JID
* @returns {promise} Promise which resolves once we have a result from the server.
*/
- 'info': function info(jid, node) {
- var attrs = {
+ 'info'(jid, node) {
+ const attrs = {
xmlns: Strophe.NS.DISCO_INFO
};
@@ -38672,7 +44930,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
attrs.node = node;
}
- var info = $iq({
+ const info = $iq({
'from': _converse.connection.jid,
'to': jid,
'type': 'get'
@@ -38688,8 +44946,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @param {string} [node] A specific node identifier associated with the JID
* @returns {promise} Promise which resolves once we have a result from the server.
*/
- 'items': function items(jid, node) {
- var attrs = {
+ 'items'(jid, node) {
+ const attrs = {
'xmlns': Strophe.NS.DISCO_ITEMS
};
@@ -38719,14 +44977,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @param {boolean} [create] Whether the entity should be created if it doesn't exist.
* @example _converse.api.disco.entities.get(jid);
*/
- 'get': function get(jid) {
- var create = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- return _converse.api.waitUntil('discoInitialized').then(function () {
+ 'get'(jid, create = false) {
+ return _converse.api.waitUntil('discoInitialized').then(() => {
if (_.isNil(jid)) {
return _converse.disco_entities;
}
- var entity = _converse.disco_entities.get(jid);
+ const entity = _converse.disco_entities.get(jid);
if (entity || !create) {
return entity;
@@ -38737,6 +44994,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
}
+
},
/**
@@ -38770,24 +45028,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* );
* });
*/
- 'supports': function supports(feature, jid) {
+ 'supports'(feature, jid) {
if (_.isNil(jid)) {
throw new TypeError('api.disco.supports: You need to provide an entity JID');
}
- return _converse.api.waitUntil('discoInitialized').then(function () {
- return _converse.api.disco.entities.get(jid, true);
- }).then(function (entity) {
- return entity.waitUntilFeaturesDiscovered;
- }).then(function (entity) {
- var promises = _.concat(entity.items.map(function (item) {
- return item.hasFeature(feature);
- }), entity.hasFeature(feature));
+ return _converse.api.waitUntil('discoInitialized').then(() => _converse.api.disco.entities.get(jid, true)).then(entity => entity.waitUntilFeaturesDiscovered).then(entity => {
+ const promises = _.concat(entity.items.map(item => item.hasFeature(feature)), entity.hasFeature(feature));
return Promise.all(promises);
- }).then(function (result) {
- return f.filter(f.isObject, result);
- });
+ }).then(result => f.filter(f.isObject, result));
},
/**
@@ -38800,20 +45050,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @example
* await _converse.api.disco.refreshFeatures('room@conference.example.org');
*/
- 'refreshFeatures': function refreshFeatures(jid) {
+ 'refreshFeatures'(jid) {
if (_.isNil(jid)) {
throw new TypeError('api.disco.refreshFeatures: You need to provide an entity JID');
}
- return _converse.api.waitUntil('discoInitialized').then(function () {
- return _converse.api.disco.entities.get(jid, true);
- }).then(function (entity) {
+ return _converse.api.waitUntil('discoInitialized').then(() => _converse.api.disco.entities.get(jid, true)).then(entity => {
entity.features.reset();
entity.fields.reset();
entity.identities.reset();
entity.waitUntilFeaturesDiscovered = utils.getResolveablePromise();
entity.queryInfo();
- return entity.waitUntilFeaturesDiscovered();
+ return entity.waitUntilFeaturesDiscovered;
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
@@ -38826,18 +45074,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @example
* const features = await _converse.api.disco.getFeatures('room@conference.example.org');
*/
- 'getFeatures': function getFeatures(jid) {
+ 'getFeatures'(jid) {
if (_.isNil(jid)) {
throw new TypeError('api.disco.getFeatures: You need to provide an entity JID');
}
- return _converse.api.waitUntil('discoInitialized').then(function () {
- return _converse.api.disco.entities.get(jid, true);
- }).then(function (entity) {
- return entity.waitUntilFeaturesDiscovered;
- }).then(function (entity) {
- return entity.features;
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ return _converse.api.waitUntil('discoInitialized').then(() => _converse.api.disco.entities.get(jid, true)).then(entity => entity.waitUntilFeaturesDiscovered).then(entity => entity.features).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
/**
@@ -38851,18 +45093,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @example
* const fields = await _converse.api.disco.getFields('room@conference.example.org');
*/
- 'getFields': function getFields(jid) {
+ 'getFields'(jid) {
if (_.isNil(jid)) {
throw new TypeError('api.disco.getFields: You need to provide an entity JID');
}
- return _converse.api.waitUntil('discoInitialized').then(function () {
- return _converse.api.disco.entities.get(jid, true);
- }).then(function (entity) {
- return entity.waitUntilFeaturesDiscovered;
- }).then(function (entity) {
- return entity.fields;
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ return _converse.api.waitUntil('discoInitialized').then(() => _converse.api.disco.entities.get(jid, true)).then(entity => entity.waitUntilFeaturesDiscovered).then(entity => entity.fields).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
/**
@@ -38896,14 +45132,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* }
* ).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
*/
- 'getIdentity': function getIdentity(category, type, jid) {
- return _converse.api.disco.entities.get(jid, true).then(function (e) {
- return e.getIdentity(category, type);
- });
+ 'getIdentity'(category, type, jid) {
+ return _converse.api.disco.entities.get(jid, true).then(e => e.getIdentity(category, type));
}
+
}
});
}
+
});
});
@@ -38916,10 +45152,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -38932,14 +45165,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_dragresize) {
+})(this, function (converse, tpl_dragresize) {
"use strict";
- var _ = converse.env._;
+ const _ = converse.env._;
function renderDragResizeHandles(_converse, view) {
- var flyout = view.el.querySelector('.box-flyout');
- var div = document.createElement('div');
+ const flyout = view.el.querySelector('.box-flyout');
+ const div = document.createElement('div');
div.innerHTML = tpl_dragresize();
flyout.insertBefore(div, flyout.firstChild);
}
@@ -38956,17 +45189,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* NB: These plugins need to have already been loaded via require.js.
*/
dependencies: ["converse-chatview", "converse-headline", "converse-muc-views"],
- enabled: function enabled(_converse) {
+
+ enabled(_converse) {
return _converse.view_mode == 'overlayed';
},
+
overrides: {
// Overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
//
// New functions which don't exist yet can also be added.
- registerGlobalEventHandlers: function registerGlobalEventHandlers() {
- var that = this;
+ registerGlobalEventHandlers() {
+ const that = this;
document.addEventListener('mousemove', function (ev) {
if (!that.resizing || !that.allow_dragresize) {
return true;
@@ -38981,8 +45216,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
ev.preventDefault();
- var height = that.applyDragResistance(that.resizing.chatbox.height, that.resizing.chatbox.model.get('default_height'));
- var width = that.applyDragResistance(that.resizing.chatbox.width, that.resizing.chatbox.model.get('default_width'));
+ const height = that.applyDragResistance(that.resizing.chatbox.height, that.resizing.chatbox.model.get('default_height'));
+ const width = that.applyDragResistance(that.resizing.chatbox.width, that.resizing.chatbox.model.get('default_width'));
if (that.connection.connected) {
that.resizing.chatbox.model.save({
@@ -39004,14 +45239,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this.__super__.registerGlobalEventHandlers.apply(this, arguments);
},
- ChatBox: {
- initialize: function initialize() {
- var _converse = this.__super__._converse;
- var result = this.__super__.initialize.apply(this, arguments),
- height = this.get('height'),
- width = this.get('width'),
- save = this.get('id') === 'controlbox' ? this.set.bind(this) : this.save.bind(this);
+ ChatBox: {
+ initialize() {
+ const _converse = this.__super__._converse;
+
+ const result = this.__super__.initialize.apply(this, arguments),
+ height = this.get('height'),
+ width = this.get('width'),
+ save = this.get('id') === 'controlbox' ? this.set.bind(this) : this.save.bind(this);
save({
'height': _converse.applyDragResistance(height, this.get('default_height')),
@@ -39019,6 +45255,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return result;
}
+
},
ChatBoxView: {
events: {
@@ -39026,49 +45263,54 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
},
- initialize: function initialize() {
+
+ initialize() {
window.addEventListener('resize', _.debounce(this.setDimensions.bind(this), 100));
this.__super__.initialize.apply(this, arguments);
},
- render: function render() {
- var result = this.__super__.render.apply(this, arguments);
+
+ render() {
+ const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result;
},
- setWidth: function setWidth() {
+
+ setWidth() {
// If a custom width is applied (due to drag-resizing),
// then we need to set the width of the .chatbox element as well.
if (this.model.get('width')) {
this.el.style.width = this.model.get('width');
}
},
- _show: function _show() {
+
+ _show() {
this.initDragResize().setDimensions();
this.__super__._show.apply(this, arguments);
},
- initDragResize: function initDragResize() {
+
+ initDragResize() {
/* Determine and store the default box size.
* We need this information for the drag-resizing feature.
*/
- var _converse = this.__super__._converse,
- flyout = this.el.querySelector('.box-flyout'),
- style = window.getComputedStyle(flyout);
+ const _converse = this.__super__._converse,
+ flyout = this.el.querySelector('.box-flyout'),
+ style = window.getComputedStyle(flyout);
if (_.isUndefined(this.model.get('height'))) {
- var height = parseInt(style.height.replace(/px$/, ''), 10),
- width = parseInt(style.width.replace(/px$/, ''), 10);
+ const height = parseInt(style.height.replace(/px$/, ''), 10),
+ width = parseInt(style.width.replace(/px$/, ''), 10);
this.model.set('height', height);
this.model.set('default_height', height);
this.model.set('width', width);
this.model.set('default_width', width);
}
- var min_width = style['min-width'];
- var min_height = style['min-height'];
+ const min_width = style['min-width'];
+ const min_height = style['min-height'];
this.model.set('min_width', min_width.endsWith('px') ? Number(min_width.replace(/px$/, '')) : 0);
this.model.set('min_height', min_height.endsWith('px') ? Number(min_height.replace(/px$/, '')) : 0); // Initialize last known mouse position
@@ -39082,14 +45324,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- setDimensions: function setDimensions() {
+
+ setDimensions() {
// Make sure the chat box has the right height and width.
this.adjustToViewport();
this.setChatBoxHeight(this.model.get('height'));
this.setChatBoxWidth(this.model.get('width'));
},
- setChatBoxHeight: function setChatBoxHeight(height) {
- var _converse = this.__super__._converse;
+
+ setChatBoxHeight(height) {
+ const _converse = this.__super__._converse;
if (height) {
height = _converse.applyDragResistance(height, this.model.get('default_height')) + 'px';
@@ -39097,14 +45341,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
height = "";
}
- var flyout_el = this.el.querySelector('.box-flyout');
+ const flyout_el = this.el.querySelector('.box-flyout');
if (!_.isNull(flyout_el)) {
flyout_el.style.height = height;
}
},
- setChatBoxWidth: function setChatBoxWidth(width) {
- var _converse = this.__super__._converse;
+
+ setChatBoxWidth(width) {
+ const _converse = this.__super__._converse;
if (width) {
width = _converse.applyDragResistance(width, this.model.get('default_width')) + 'px';
@@ -39113,18 +45358,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
this.el.style.width = width;
- var flyout_el = this.el.querySelector('.box-flyout');
+ const flyout_el = this.el.querySelector('.box-flyout');
if (!_.isNull(flyout_el)) {
flyout_el.style.width = width;
}
},
- adjustToViewport: function adjustToViewport() {
+
+ adjustToViewport() {
/* Event handler called when viewport gets resized. We remove
* custom width/height from chat boxes.
*/
- var viewport_width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
- var viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
+ const viewport_width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
+ const viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
if (viewport_width <= 480) {
this.model.set('height', undefined);
@@ -39135,16 +45381,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.set('height', undefined);
}
},
- onStartVerticalResize: function onStartVerticalResize(ev) {
- var _converse = this.__super__._converse;
+
+ onStartVerticalResize(ev) {
+ const _converse = this.__super__._converse;
if (!_converse.allow_dragresize) {
return true;
} // Record element attributes for mouseMove().
- var flyout = this.el.querySelector('.box-flyout'),
- style = window.getComputedStyle(flyout);
+ const flyout = this.el.querySelector('.box-flyout'),
+ style = window.getComputedStyle(flyout);
this.height = parseInt(style.height.replace(/px$/, ''), 10);
_converse.resizing = {
'chatbox': this,
@@ -39152,15 +45399,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
this.prev_pageY = ev.pageY;
},
- onStartHorizontalResize: function onStartHorizontalResize(ev) {
- var _converse = this.__super__._converse;
+
+ onStartHorizontalResize(ev) {
+ const _converse = this.__super__._converse;
if (!_converse.allow_dragresize) {
return true;
}
- var flyout = this.el.querySelector('.box-flyout'),
- style = window.getComputedStyle(flyout);
+ const flyout = this.el.querySelector('.box-flyout'),
+ style = window.getComputedStyle(flyout);
this.width = parseInt(style.width.replace(/px$/, ''), 10);
_converse.resizing = {
'chatbox': this,
@@ -39168,15 +45416,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
this.prev_pageX = ev.pageX;
},
- onStartDiagonalResize: function onStartDiagonalResize(ev) {
- var _converse = this.__super__._converse;
+
+ onStartDiagonalResize(ev) {
+ const _converse = this.__super__._converse;
this.onStartHorizontalResize(ev);
this.onStartVerticalResize(ev);
_converse.resizing.direction = 'topleft';
},
- resizeChatBox: function resizeChatBox(ev) {
- var diff;
- var _converse = this.__super__._converse;
+
+ resizeChatBox(ev) {
+ let diff;
+ const _converse = this.__super__._converse;
if (_converse.resizing.direction.indexOf('top') === 0) {
diff = ev.pageY - this.prev_pageY;
@@ -39198,6 +45448,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
}
+
},
HeadlinesBoxView: {
events: {
@@ -39205,17 +45456,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
},
- initialize: function initialize() {
+
+ initialize() {
window.addEventListener('resize', _.debounce(this.setDimensions.bind(this), 100));
return this.__super__.initialize.apply(this, arguments);
},
- render: function render() {
- var result = this.__super__.render.apply(this, arguments);
+
+ render() {
+ const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result;
}
+
},
ControlBoxView: {
events: {
@@ -39223,30 +45477,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
},
- initialize: function initialize() {
+
+ initialize() {
window.addEventListener('resize', _.debounce(this.setDimensions.bind(this), 100));
this.__super__.initialize.apply(this, arguments);
},
- render: function render() {
- var result = this.__super__.render.apply(this, arguments);
+
+ render() {
+ const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result;
},
- renderLoginPanel: function renderLoginPanel() {
- var result = this.__super__.renderLoginPanel.apply(this, arguments);
+
+ renderLoginPanel() {
+ const result = this.__super__.renderLoginPanel.apply(this, arguments);
this.initDragResize().setDimensions();
return result;
},
- renderControlBoxPane: function renderControlBoxPane() {
- var result = this.__super__.renderControlBoxPane.apply(this, arguments);
+
+ renderControlBoxPane() {
+ const result = this.__super__.renderControlBoxPane.apply(this, arguments);
this.initDragResize().setDimensions();
return result;
}
+
},
ChatRoomView: {
events: {
@@ -39254,25 +45513,29 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
},
- initialize: function initialize() {
+
+ initialize() {
window.addEventListener('resize', _.debounce(this.setDimensions.bind(this), 100));
this.__super__.initialize.apply(this, arguments);
},
- render: function render() {
- var result = this.__super__.render.apply(this, arguments);
+
+ render() {
+ const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result;
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse;
+ const _converse = this._converse;
_converse.api.settings.update({
allow_dragresize: true
@@ -39289,7 +45552,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return value;
}
- var resistance = 10;
+ const resistance = 10;
if (value !== default_value && Math.abs(value - default_value) < resistance) {
return default_value;
@@ -39298,6 +45561,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return value;
};
}
+
});
});
@@ -39310,10 +45574,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -39323,17 +45584,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
+})(this, function (converse) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- _ = _converse$env._;
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ _ = _converse$env._;
converse.plugins.add('converse-embedded', {
- enabled: function enabled(_converse) {
+ enabled(_converse) {
return _converse.view_mode === 'embedded';
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
@@ -39346,7 +45608,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'hide_muc_server': true
});
- var _converse = this._converse;
+ const _converse = this._converse;
if (!_.isArray(_converse.auto_join_rooms) && !_.isArray(_converse.auto_join_private_chats)) {
throw new Error("converse-embedded: auto_join_rooms must be an Array");
@@ -39356,6 +45618,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
throw new Error("converse-embedded: It doesn't make " + "sense to have the auto_join_rooms setting more then one, " + "since only one chat room can be open at any time.");
}
}
+
});
});
@@ -39368,10 +45631,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) JC Brand
@@ -39384,16 +45644,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_brand_heading) {
+})(this, function (converse, tpl_brand_heading) {
"use strict";
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- _ = _converse$env._;
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ _ = _converse$env._;
converse.plugins.add('converse-fullscreen', {
- enabled: function enabled(_converse) {
+ enabled(_converse) {
return _.includes(['fullscreen', 'embedded'], _converse.view_mode);
},
+
overrides: {
// overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the
@@ -39401,19 +45662,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//
// new functions which don't exist yet can also be added.
ControlBoxView: {
- createBrandHeadingHTML: function createBrandHeadingHTML() {
+ createBrandHeadingHTML() {
return tpl_brand_heading();
},
- insertBrandHeading: function insertBrandHeading() {
- var _converse = this.__super__._converse;
- var el = _converse.root.getElementById('converse-login-panel');
+ insertBrandHeading() {
+ const _converse = this.__super__._converse;
+
+ const el = _converse.root.getElementById('converse-login-panel');
el.parentNode.insertAdjacentHTML('afterbegin', this.createBrandHeadingHTML());
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
this._converse.api.settings.update({
chatview_avatar_height: 50,
chatview_avatar_width: 50,
@@ -39422,6 +45686,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
sticky_controlbox: true
});
}
+
});
});
@@ -39434,10 +45699,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -39450,12 +45712,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_chatbox) {
+})(this, function (converse, tpl_chatbox) {
"use strict";
- var _converse$env = converse.env,
- _ = _converse$env._,
- utils = _converse$env.utils;
+ const _converse$env = converse.env,
+ _ = _converse$env._,
+ utils = _converse$env.utils;
converse.plugins.add('converse-headline', {
/* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before
@@ -39475,8 +45737,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//
// New functions which don't exist yet can also be added.
ChatBoxes: {
- model: function model(attrs, options) {
- var _converse = this.__super__._converse;
+ model(attrs, options) {
+ const _converse = this.__super__._converse;
if (attrs.type == _converse.HEADLINES_TYPE) {
return new _converse.HeadlinesBox(attrs, options);
@@ -39484,14 +45746,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.model.apply(this, arguments);
}
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.HeadlinesBox = _converse.ChatBox.extend({
defaults: {
'type': _converse.HEADLINES_TYPE,
@@ -39508,7 +45772,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click .toggle-chatbox-button': 'minimize',
'keypress textarea.chat-textarea': 'keyPressed'
},
- initialize: function initialize() {
+
+ initialize() {
this.initDebounced();
this.disable_mam = true; // Don't do MAM queries for this box
@@ -39522,7 +45787,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('chatBoxInitialized', this);
},
- render: function render() {
+
+ render() {
this.el.setAttribute('id', this.model.get('box_id'));
this.el.innerHTML = tpl_chatbox(_.extend(this.model.toJSON(), {
info_close: '',
@@ -39534,6 +45800,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.content = this.el.querySelector('.chat-content');
return this;
},
+
// Override to avoid the methods in converse-chatview.js
'renderMessageForm': _.noop,
'afterShown': _.noop
@@ -39541,14 +45808,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
function onHeadlineMessage(message) {
/* Handler method for all incoming messages of type "headline". */
- var from_jid = message.getAttribute('from');
+ const from_jid = message.getAttribute('from');
if (utils.isHeadlineMessage(_converse, message)) {
- if (_.includes(from_jid, '@') && !_converse.allow_non_roster_messaging) {
+ if (_.includes(from_jid, '@') && !_converse.api.contacts.get(from_jid) && !_converse.allow_non_roster_messaging) {
return;
}
- var chatbox = _converse.chatboxes.create({
+ if (_.isNull(message.querySelector('body'))) {
+ // Avoid creating a chat box if we have nothing to show
+ // inside it.
+ return;
+ }
+
+ const chatbox = _converse.chatboxes.create({
'id': from_jid,
'jid': from_jid,
'type': _converse.HEADLINES_TYPE,
@@ -39574,10 +45847,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.on('reconnected', registerHeadlineHandler);
- _converse.on('chatBoxViewsInitialized', function () {
- var that = _converse.chatboxviews;
+ _converse.on('chatBoxViewsInitialized', () => {
+ const that = _converse.chatboxviews;
- _converse.chatboxes.on('add', function (item) {
+ _converse.chatboxes.on('add', item => {
if (!that.get(item.get('id')) && item.get('type') === _converse.HEADLINES_TYPE) {
that.add(item.get('id'), new _converse.HeadlinesBoxView({
model: item
@@ -39586,6 +45859,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
}
+
});
});
@@ -39598,12 +45872,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -39613,38 +45882,38 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/*global define */
// XEP-0059 Result Set Management
(function (root, factory) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! sizzle */ "./node_modules/sizzle/dist/sizzle.js"), __webpack_require__(/*! converse-core */ "./src/converse-core.js"), __webpack_require__(/*! converse-disco */ "./src/converse-disco.js"), __webpack_require__(/*! strophe.rsm */ "strophe.rsm")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! sizzle */ "./node_modules/sizzle/dist/sizzle.js"), __webpack_require__(/*! converse-core */ "./src/converse-core.js"), __webpack_require__(/*! converse-disco */ "./src/converse-disco.js"), __webpack_require__(/*! strophejs-plugin-rsm */ "./node_modules/strophejs-plugin-rsm/lib/strophe.rsm.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (sizzle, converse) {
+})(this, function (sizzle, converse) {
"use strict";
- var CHATROOMS_TYPE = 'chatroom';
- var _converse$env = converse.env,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- $iq = _converse$env.$iq,
- _ = _converse$env._,
- moment = _converse$env.moment;
- var u = converse.env.utils;
- var RSM_ATTRIBUTES = ['max', 'first', 'last', 'after', 'before', 'index', 'count']; // XEP-0313 Message Archive Management
+ const CHATROOMS_TYPE = 'chatroom';
+ const _converse$env = converse.env,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ $iq = _converse$env.$iq,
+ _ = _converse$env._,
+ moment = _converse$env.moment;
+ const u = converse.env.utils;
+ const RSM_ATTRIBUTES = ['max', 'first', 'last', 'after', 'before', 'index', 'count']; // XEP-0313 Message Archive Management
- var MAM_ATTRIBUTES = ['with', 'start', 'end'];
+ const MAM_ATTRIBUTES = ['with', 'start', 'end'];
function getMessageArchiveID(stanza) {
// See https://xmpp.org/extensions/xep-0313.html#results
//
// The result messages MUST contain a element with an 'id'
// attribute that gives the current message's archive UID
- var result = sizzle("result[xmlns=\"".concat(Strophe.NS.MAM, "\"]"), stanza).pop();
+ const result = sizzle(`result[xmlns="${Strophe.NS.MAM}"]`, stanza).pop();
if (!_.isUndefined(result)) {
return result.getAttribute('id');
} // See: https://xmpp.org/extensions/xep-0313.html#archives_id
- var stanza_id = sizzle("stanza-id[xmlns=\"".concat(Strophe.NS.SID, "\"]"), stanza).pop();
+ const stanza_id = sizzle(`stanza-id[xmlns="${Strophe.NS.SID}"]`, stanza).pop();
if (!_.isUndefined(stanza_id)) {
return stanza_id.getAttribute('id');
@@ -39654,7 +45923,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
function queryForArchivedMessages(_converse, options, callback, errback) {
/* Internal function, called by the "archive.query" API method.
*/
- var date;
+ let date;
if (_.isFunction(options)) {
callback = options;
@@ -39662,9 +45931,9 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
options = null;
}
- var queryid = _converse.connection.getUniqueId();
+ const queryid = _converse.connection.getUniqueId();
- var attrs = {
+ const attrs = {
'type': 'set'
};
@@ -39677,7 +45946,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
attrs.to = options['with']; // eslint-disable-line dot-notation
}
- var stanza = $iq(attrs).c('query', {
+ const stanza = $iq(attrs).c('query', {
'xmlns': Strophe.NS.MAM,
'queryid': queryid
});
@@ -39707,29 +45976,29 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'var': t
}).c('value').t(date.format()).up().up();
} else {
- throw new TypeError("archive.query: invalid date provided for: ".concat(t));
+ throw new TypeError(`archive.query: invalid date provided for: ${t}`);
}
}
});
stanza.up();
- if (_instanceof(options, Strophe.RSM)) {
+ if (options instanceof Strophe.RSM) {
stanza.cnode(options.toXML());
} else if (_.intersection(RSM_ATTRIBUTES, _.keys(options)).length) {
stanza.cnode(new Strophe.RSM(options).toXML());
}
}
- var messages = [];
+ const messages = [];
- var message_handler = _converse.connection.addHandler(function (message) {
+ const message_handler = _converse.connection.addHandler(message => {
if (options.groupchat && message.getAttribute('from') !== options['with']) {
// eslint-disable-line dot-notation
return true;
}
- var result = message.querySelector('result');
+ const result = message.querySelector('result');
if (!_.isNull(result) && result.getAttribute('queryid') === queryid) {
messages.push(message);
@@ -39742,8 +46011,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.connection.deleteHandler(message_handler);
if (_.isFunction(callback)) {
- var set = iq.querySelector('set');
- var rsm;
+ const set = iq.querySelector('set');
+ let rsm;
if (!_.isUndefined(set)) {
rsm = new Strophe.RSM({
@@ -39773,9 +46042,9 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
//
// New functions which don't exist yet can also be added.
ChatBox: {
- getMessageAttributesFromStanza: function getMessageAttributesFromStanza(message, original_stanza) {
+ getMessageAttributesFromStanza(message, original_stanza) {
function _process(attrs) {
- var archive_id = getMessageArchiveID(original_stanza);
+ const archive_id = getMessageArchiveID(original_stanza);
if (archive_id) {
attrs.archive_id = archive_id;
@@ -39784,22 +46053,19 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return attrs;
}
- var result = this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
+ const result = this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
- if (_instanceof(result, Promise)) {
- return new Promise(function (resolve, reject) {
- return result.then(function (attrs) {
- return resolve(_process(attrs));
- }).catch(reject);
- });
+ if (result instanceof Promise) {
+ return new Promise((resolve, reject) => result.then(attrs => resolve(_process(attrs))).catch(reject));
} else {
return _process(result);
}
}
+
},
ChatBoxView: {
- render: function render() {
- var result = this.__super__.render.apply(this, arguments);
+ render() {
+ const result = this.__super__.render.apply(this, arguments);
if (!this.disable_mam) {
this.content.addEventListener('scroll', _.debounce(this.onScroll.bind(this), 100));
@@ -39807,7 +46073,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return result;
},
- fetchNewestMessages: function fetchNewestMessages() {
+
+ fetchNewestMessages() {
/* Fetches messages that might have been archived *after*
* the last archived message in our local cache.
*/
@@ -39815,13 +46082,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return;
}
- var _converse = this.__super__._converse,
- most_recent_msg = u.getMostRecentMessage(this.model);
+ const _converse = this.__super__._converse,
+ most_recent_msg = u.getMostRecentMessage(this.model);
if (_.isNil(most_recent_msg)) {
this.fetchArchivedMessages();
} else {
- var archive_id = most_recent_msg.get('archive_id');
+ const archive_id = most_recent_msg.get('archive_id');
if (archive_id) {
this.fetchArchivedMessages({
@@ -39834,45 +46101,43 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
}
},
- fetchArchivedMessagesIfNecessary: function fetchArchivedMessagesIfNecessary() {
- var _this = this;
+ fetchArchivedMessagesIfNecessary() {
/* Check if archived messages should be fetched, and if so, do so. */
if (this.disable_mam || this.model.get('mam_initialized')) {
return;
}
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
- _converse.api.disco.supports(Strophe.NS.MAM, _converse.bare_jid).then(function (result) {
+ _converse.api.disco.supports(Strophe.NS.MAM, _converse.bare_jid).then(result => {
// Success
if (result.length) {
- _this.fetchArchivedMessages();
+ this.fetchArchivedMessages();
}
- _this.model.save({
+ this.model.save({
'mam_initialized': true
});
- }, function () {
+ }, () => {
// Error
_converse.log("Error or timeout while checking for MAM support", Strophe.LogLevel.ERROR);
- }).catch(function (msg) {
- _this.clearSpinner();
+ }).catch(msg => {
+ this.clearSpinner();
_converse.log(msg, Strophe.LogLevel.FATAL);
});
},
- fetchArchivedMessages: function fetchArchivedMessages(options) {
- var _this2 = this;
- var _converse = this.__super__._converse;
+ fetchArchivedMessages(options) {
+ const _converse = this.__super__._converse;
if (this.disable_mam) {
return;
}
- var is_groupchat = this.model.get('type') === CHATROOMS_TYPE;
- var mam_jid, message_handler;
+ const is_groupchat = this.model.get('type') === CHATROOMS_TYPE;
+ let mam_jid, message_handler;
if (is_groupchat) {
mam_jid = this.model.get('jid');
@@ -39882,46 +46147,47 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes);
}
- _converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(function (results) {
+ _converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(results => {
// Success
if (!results.length) {
return;
}
- _this2.addSpinner();
+ this.addSpinner();
_converse.api.archive.query(_.extend({
'groupchat': is_groupchat,
'before': '',
// Page backwards from the most recent message
'max': _converse.archived_messages_page_size,
- 'with': _this2.model.get('jid')
- }, options), function (messages) {
+ 'with': this.model.get('jid')
+ }, options), messages => {
// Success
- _this2.clearSpinner();
+ this.clearSpinner();
_.each(messages, message_handler);
- }, function () {
+ }, () => {
// Error
- _this2.clearSpinner();
+ this.clearSpinner();
_converse.log("Error or timeout while trying to fetch " + "archived messages", Strophe.LogLevel.ERROR);
});
- }, function () {
+ }, () => {
// Error
_converse.log("Error or timeout while checking for MAM support", Strophe.LogLevel.ERROR);
- }).catch(function (msg) {
- _this2.clearSpinner();
+ }).catch(msg => {
+ this.clearSpinner();
_converse.log(msg, Strophe.LogLevel.FATAL);
});
},
- onScroll: function onScroll(ev) {
- var _converse = this.__super__._converse;
+
+ onScroll(ev) {
+ const _converse = this.__super__._converse;
if (this.content.scrollTop === 0 && this.model.messages.length) {
- var oldest_message = this.model.messages.at(0);
- var archive_id = oldest_message.get('archive_id');
+ const oldest_message = this.model.messages.at(0);
+ const archive_id = oldest_message.get('archive_id');
if (archive_id) {
this.fetchArchivedMessages({
@@ -39934,16 +46200,17 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
}
}
+
},
ChatRoom: {
- isDuplicate: function isDuplicate(message, original_stanza) {
- var result = this.__super__.isDuplicate.apply(this, arguments);
+ isDuplicate(message, original_stanza) {
+ const result = this.__super__.isDuplicate.apply(this, arguments);
if (result) {
return result;
}
- var archive_id = getMessageArchiveID(original_stanza);
+ const archive_id = getMessageArchiveID(original_stanza);
if (archive_id) {
return this.messages.filter({
@@ -39951,18 +46218,20 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}).length > 0;
}
}
+
},
ChatRoomView: {
- initialize: function initialize() {
- var _converse = this.__super__._converse;
+ initialize() {
+ const _converse = this.__super__._converse;
this.__super__.initialize.apply(this, arguments);
this.model.on('change:mam_enabled', this.fetchArchivedMessagesIfNecessary, this);
this.model.on('change:connection_status', this.fetchArchivedMessagesIfNecessary, this);
},
- renderChatArea: function renderChatArea() {
- var result = this.__super__.renderChatArea.apply(this, arguments);
+
+ renderChatArea() {
+ const result = this.__super__.renderChatArea.apply(this, arguments);
if (!this.disable_mam) {
this.content.addEventListener('scroll', _.debounce(this.onScroll.bind(this), 100));
@@ -39970,7 +46239,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return result;
},
- fetchArchivedMessagesIfNecessary: function fetchArchivedMessagesIfNecessary() {
+
+ fetchArchivedMessagesIfNecessary() {
if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED || !this.model.get('mam_enabled') || this.model.get('mam_initialized')) {
return;
}
@@ -39980,13 +46250,15 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'mam_initialized': true
});
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by Converse.js's plugin machinery.
*/
- var _converse = this._converse;
+ const _converse = this._converse;
_converse.api.settings.update({
archived_messages_page_size: '50',
@@ -40017,11 +46289,11 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* Per JID preferences will be set in chat boxes, so it'll
* probbaly be handled elsewhere in any case.
*/
- var preference = sizzle("prefs[xmlns=\"".concat(Strophe.NS.MAM, "\"]"), iq).pop();
- var default_pref = preference.getAttribute('default');
+ const preference = sizzle(`prefs[xmlns="${Strophe.NS.MAM}"]`, iq).pop();
+ const default_pref = preference.getAttribute('default');
if (default_pref !== _converse.message_archiving) {
- var stanza = $iq({
+ const stanza = $iq({
'type': 'set'
}).c('prefs', {
'xmlns': Strophe.NS.MAM,
@@ -40053,8 +46325,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/* Event handlers */
- _converse.on('serviceDiscovered', function (feature) {
- var prefs = feature.get('preferences') || {};
+ _converse.on('serviceDiscovered', feature => {
+ const prefs = feature.get('preferences') || {};
if (feature.get('var') === Strophe.NS.MAM && prefs['default'] !== _converse.message_archiving && // eslint-disable-line dot-notation
!_.isUndefined(_converse.message_archiving)) {
@@ -40067,22 +46339,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
});
- _converse.on('addClientFeatures', function () {
+ _converse.on('addClientFeatures', () => {
_converse.api.disco.own.features.add(Strophe.NS.MAM);
});
- _converse.on('afterMessagesFetched', function (chatboxview) {
+ _converse.on('afterMessagesFetched', chatboxview => {
chatboxview.fetchNewestMessages();
});
- _converse.on('reconnected', function () {
- var private_chats = _converse.chatboxviews.filter(function (view) {
- return _.at(view, 'model.attributes.type')[0] === 'chatbox';
- });
+ _converse.on('reconnected', () => {
+ const private_chats = _converse.chatboxviews.filter(view => _.at(view, 'model.attributes.type')[0] === 'chatbox');
- _.each(private_chats, function (view) {
- return view.fetchNewestMessages();
- });
+ _.each(private_chats, view => view.fetchNewestMessages());
});
_.extend(_converse.api, {
@@ -40265,6 +46533,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
});
}
+
});
});
@@ -40277,10 +46546,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// https://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -40290,47 +46556,49 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (u, converse, xss, filesize, tpl_csn, tpl_file_progress, tpl_info, tpl_message, tpl_message_versions_modal) {
+})(this, function (u, converse, xss, filesize, tpl_csn, tpl_file_progress, tpl_info, tpl_message, tpl_message_versions_modal) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- _ = _converse$env._,
- moment = _converse$env.moment;
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ _ = _converse$env._,
+ moment = _converse$env.moment;
converse.plugins.add('converse-message-view', {
- initialize: function initialize() {
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
+
+ _converse.api.settings.update({
+ 'show_images_inline': true
+ });
+
_converse.MessageVersionsModal = _converse.BootstrapModal.extend({
- toHTML: function toHTML() {
+ toHTML() {
return tpl_message_versions_modal(_.extend(this.model.toJSON(), {
'__': __
}));
}
+
});
_converse.MessageView = _converse.ViewWithAvatar.extend({
events: {
'click .chat-msg__edit-modal': 'showMessageVersionsModal'
},
- initialize: function initialize() {
+
+ initialize() {
if (this.model.vcard) {
this.model.vcard.on('change', this.render, this);
}
- this.model.on('change:correcting', this.onMessageCorrection, this);
- this.model.on('change:message', this.render, this);
- this.model.on('change:progress', this.renderFileUploadProgresBar, this);
- this.model.on('change:type', this.render, this);
- this.model.on('change:upload', this.render, this);
+ this.model.on('change', this.onChanged, this);
this.model.on('destroy', this.remove, this);
- this.render();
},
- render: function render() {
- var is_followup = u.hasClass('chat-msg--followup', this.el);
- var msg;
+
+ async render() {
+ const is_followup = u.hasClass('chat-msg--followup', this.el);
if (this.model.isOnlyChatStateNotification()) {
this.renderChatStateNotification();
@@ -40339,7 +46607,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} else if (this.model.get('type') === 'error') {
this.renderErrorMessage();
} else {
- this.renderChatMessage();
+ await this.renderChatMessage();
}
if (is_followup) {
@@ -40348,19 +46616,36 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.el;
},
- onMessageCorrection: function onMessageCorrection() {
- var _this = this;
- this.render();
+ async onChanged(item) {
+ // Jot down whether it was edited because the `changed`
+ // attr gets removed when this.render() gets called further
+ // down.
+ const edited = item.changed.edited;
- if (!this.model.get('correcting') && this.model.changed.message) {
- this.el.addEventListener('animationend', function () {
- return u.removeClass('onload', _this.el);
- });
- u.addClass('onload', this.el);
+ if (this.model.changed.progress) {
+ return this.renderFileUploadProgresBar();
+ }
+
+ if (_.filter(['correcting', 'message', 'type', 'upload'], prop => Object.prototype.hasOwnProperty.call(this.model.changed, prop)).length) {
+ await this.render();
+ }
+
+ if (edited) {
+ this.onMessageEdited();
}
},
- replaceElement: function replaceElement(msg) {
+
+ onMessageEdited() {
+ if (this.model.get('is_archived')) {
+ return;
+ }
+
+ this.el.addEventListener('animationend', () => u.removeClass('onload', this.el));
+ u.addClass('onload', this.el);
+ },
+
+ replaceElement(msg) {
if (!_.isNil(this.el.parentElement)) {
this.el.parentElement.replaceChild(msg, this.el);
}
@@ -40368,14 +46653,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setElement(msg);
return this.el;
},
- renderChatMessage: function renderChatMessage() {
- var _this2 = this;
- var is_me_message = this.isMeCommand(),
- moment_time = moment(this.model.get('time')),
- role = this.model.vcard ? this.model.vcard.get('role') : null,
- roles = role ? role.split(',') : [];
- var msg = u.stringToElement(tpl_message(_.extend(this.model.toJSON(), {
+ async renderChatMessage() {
+ const is_me_message = this.isMeCommand(),
+ moment_time = moment(this.model.get('time')),
+ role = this.model.vcard ? this.model.vcard.get('role') : null,
+ roles = role ? role.split(',') : [];
+ const msg = u.stringToElement(tpl_message(_.extend(this.model.toJSON(), {
'__': __,
'is_me_message': is_me_message,
'roles': roles,
@@ -40385,14 +46669,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'label_show': __('Show more'),
'username': this.model.getDisplayName()
})));
- var url = this.model.get('oob_url');
+ const url = this.model.get('oob_url');
if (url) {
msg.querySelector('.chat-msg__media').innerHTML = _.flow(_.partial(u.renderFileURL, _converse), _.partial(u.renderMovieURL, _converse), _.partial(u.renderAudioURL, _converse), _.partial(u.renderImageURL, _converse))(url);
}
- var text = this.getMessageText();
- var msg_content = msg.querySelector('.chat-msg__text');
+ let text = this.getMessageText();
+ const msg_content = msg.querySelector('.chat-msg__text');
if (text && text !== url) {
if (is_me_message) {
@@ -40405,28 +46689,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
msg_content.innerHTML = _.flow(_.partial(u.geoUriToHttp, _, _converse.geouri_replacement), _.partial(u.addMentionsMarkup, _, this.model.get('references'), this.model.collection.chatbox), u.addHyperlinks, u.renderNewLines, _.partial(u.addEmoji, _converse, _))(text);
}
- u.renderImageURLs(_converse, msg_content).then(function () {
- _this2.model.collection.trigger('rendered');
- });
- this.replaceElement(msg);
+ const promises = [];
+ promises.push(u.renderImageURLs(_converse, msg_content));
if (this.model.get('type') !== 'headline') {
- this.renderAvatar();
+ promises.push(this.renderAvatar(msg));
}
+
+ await Promise.all(promises);
+ this.replaceElement(msg);
+ this.model.collection.trigger('rendered', this);
},
- renderErrorMessage: function renderErrorMessage() {
- var moment_time = moment(this.model.get('time')),
- msg = u.stringToElement(tpl_info(_.extend(this.model.toJSON(), {
+
+ renderErrorMessage() {
+ const moment_time = moment(this.model.get('time')),
+ msg = u.stringToElement(tpl_info(_.extend(this.model.toJSON(), {
'extra_classes': 'chat-error',
- 'isodate': moment_time.format(),
- 'data': ''
+ 'isodate': moment_time.format()
})));
return this.replaceElement(msg);
},
- renderChatStateNotification: function renderChatStateNotification() {
- var text;
- var from = this.model.get('from'),
- name = this.model.getDisplayName();
+
+ renderChatStateNotification() {
+ let text;
+ const from = this.model.get('from'),
+ name = this.model.getDisplayName();
if (this.model.get('chat_state') === _converse.COMPOSING) {
if (this.model.get('sender') === 'me') {
@@ -40446,21 +46733,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var isodate = moment().format();
+ const isodate = moment().format();
this.replaceElement(u.stringToElement(tpl_csn({
'message': text,
'from': from,
'isodate': isodate
})));
},
- renderFileUploadProgresBar: function renderFileUploadProgresBar() {
- var msg = u.stringToElement(tpl_file_progress(_.extend(this.model.toJSON(), {
+
+ renderFileUploadProgresBar() {
+ const msg = u.stringToElement(tpl_file_progress(_.extend(this.model.toJSON(), {
'filesize': filesize(this.model.get('file').size)
})));
this.replaceElement(msg);
this.renderAvatar();
},
- showMessageVersionsModal: function showMessageVersionsModal(ev) {
+
+ showMessageVersionsModal(ev) {
ev.preventDefault();
if (_.isUndefined(this.model.message_versions_modal)) {
@@ -40471,29 +46760,33 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.message_versions_modal.show(ev);
},
- getMessageText: function getMessageText() {
+
+ getMessageText() {
if (this.model.get('is_encrypted')) {
return this.model.get('plaintext') || (_converse.debug ? __('Unencryptable OMEMO message') : null);
}
return this.model.get('message');
},
- isMeCommand: function isMeCommand() {
- var text = this.getMessageText();
+
+ isMeCommand() {
+ const text = this.getMessageText();
if (!text) {
return false;
}
- var match = text.match(/^\/(.*?)(?: (.*))?$/);
+ const match = text.match(/^\/(.*?)(?: (.*))?$/);
return match && match[1] === 'me';
},
- processMessageText: function processMessageText() {
+
+ processMessageText() {
var text = this.get('message');
text = u.geoUriToHttp(text, _converse.geouri_replacement);
},
- getExtraMessageClasses: function getExtraMessageClasses() {
- var extra_classes = this.model.get('is_delayed') && 'delayed' || '';
+
+ getExtraMessageClasses() {
+ let extra_classes = this.model.get('is_delayed') && 'delayed' || '';
if (this.model.get('type') === 'groupchat' && this.model.get('sender') === 'them') {
if (this.model.collection.chatbox.isUserMentioned(this.model)) {
@@ -40509,8 +46802,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return extra_classes;
}
+
});
}
+
});
return converse;
});
@@ -40524,10 +46819,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -40540,17 +46832,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_chatbox_minimize, tpl_toggle_chats, tpl_trimmed_chat, tpl_chats_panel) {
+})(this, function (converse, tpl_chatbox_minimize, tpl_toggle_chats, tpl_trimmed_chat, tpl_chats_panel) {
"use strict";
- var _converse$env = converse.env,
- _ = _converse$env._,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- b64_sha1 = _converse$env.b64_sha1,
- moment = _converse$env.moment;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ _ = _converse$env._,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ b64_sha1 = _converse$env.b64_sha1,
+ moment = _converse$env.moment;
+ const u = converse.env.utils;
converse.plugins.add('converse-minimize', {
/* Optional dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before
@@ -40565,9 +46857,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* NB: These plugins need to have already been loaded via require.js.
*/
dependencies: ["converse-chatview", "converse-controlbox", "converse-muc", "converse-muc-views", "converse-headline"],
- enabled: function enabled(_converse) {
+
+ enabled(_converse) {
return _converse.view_mode == 'overlayed';
},
+
overrides: {
// Overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the
@@ -40575,7 +46869,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//
// New functions which don't exist yet can also be added.
ChatBox: {
- initialize: function initialize() {
+ initialize() {
this.__super__.initialize.apply(this, arguments);
this.on('show', this.maximize, this);
@@ -40589,29 +46883,34 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'time_minimized': this.get('time_minimized') || moment()
});
},
- maximize: function maximize() {
+
+ maximize() {
u.safeSave(this, {
'minimized': false,
'time_opened': moment().valueOf()
});
},
- minimize: function minimize() {
+
+ minimize() {
u.safeSave(this, {
'minimized': true,
'time_minimized': moment().format()
});
}
+
},
ChatBoxView: {
events: {
'click .toggle-chatbox-button': 'minimize'
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change:minimized', this.onMinimizedChanged, this);
return this.__super__.initialize.apply(this, arguments);
},
- _show: function _show() {
- var _converse = this.__super__._converse;
+
+ _show() {
+ const _converse = this.__super__._converse;
if (!this.model.get('minimized')) {
this.__super__._show.apply(this, arguments);
@@ -40621,32 +46920,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.minimize();
}
},
- isNewMessageHidden: function isNewMessageHidden() {
+
+ isNewMessageHidden() {
return this.model.get('minimized') || this.__super__.isNewMessageHidden.apply(this, arguments);
},
- shouldShowOnTextMessage: function shouldShowOnTextMessage() {
+
+ shouldShowOnTextMessage() {
return !this.model.get('minimized') && this.__super__.shouldShowOnTextMessage.apply(this, arguments);
},
- setChatBoxHeight: function setChatBoxHeight(height) {
+
+ setChatBoxHeight(height) {
if (!this.model.get('minimized')) {
return this.__super__.setChatBoxHeight.apply(this, arguments);
}
},
- setChatBoxWidth: function setChatBoxWidth(width) {
+
+ setChatBoxWidth(width) {
if (!this.model.get('minimized')) {
return this.__super__.setChatBoxWidth.apply(this, arguments);
}
},
- onMinimizedChanged: function onMinimizedChanged(item) {
+
+ onMinimizedChanged(item) {
if (item.get('minimized')) {
this.minimize();
} else {
this.maximize();
}
},
- maximize: function maximize() {
+
+ maximize() {
// Restores a minimized chat box
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
this.insertIntoDOM();
if (!this.model.isScrolledUp()) {
@@ -40659,8 +46964,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- minimize: function minimize(ev) {
- var _converse = this.__super__._converse;
+
+ minimize(ev) {
+ const _converse = this.__super__._converse;
if (ev && ev.preventDefault) {
ev.preventDefault();
@@ -40682,32 +46988,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('chatBoxMinimized', this);
}
+
},
ChatBoxHeading: {
- render: function render() {
- var _converse = this.__super__._converse,
- __ = _converse.__;
+ render() {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
- var result = this.__super__.render.apply(this, arguments);
+ const result = this.__super__.render.apply(this, arguments);
- var new_html = tpl_chatbox_minimize({
+ const new_html = tpl_chatbox_minimize({
info_minimize: __('Minimize this chat box')
});
- var el = this.el.querySelector('.toggle-chatbox-button');
+ const el = this.el.querySelector('.toggle-chatbox-button');
if (el) {
el.outerHTML = new_html;
} else {
- var button = this.el.querySelector('.close-chatbox-button');
+ const button = this.el.querySelector('.close-chatbox-button');
button.insertAdjacentHTML('afterEnd', new_html);
}
}
+
},
ChatRoomView: {
events: {
'click .toggle-chatbox-button': 'minimize'
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change:minimized', function (item) {
if (item.get('minimized')) {
this.hide();
@@ -40716,7 +47025,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}, this);
- var result = this.__super__.initialize.apply(this, arguments);
+ const result = this.__super__.initialize.apply(this, arguments);
if (this.model.get('minimized')) {
this.hide();
@@ -40724,46 +47033,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return result;
},
- generateHeadingHTML: function generateHeadingHTML() {
- var _converse = this.__super__._converse,
- __ = _converse.__;
- var html = this.__super__.generateHeadingHTML.apply(this, arguments);
+ generateHeadingHTML() {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
- var div = document.createElement('div');
+ const html = this.__super__.generateHeadingHTML.apply(this, arguments);
+
+ const div = document.createElement('div');
div.innerHTML = html;
- var button = div.querySelector('.close-chatbox-button');
+ const button = div.querySelector('.close-chatbox-button');
button.insertAdjacentHTML('afterend', tpl_chatbox_minimize({
'info_minimize': __('Minimize this chat box')
}));
return div.innerHTML;
}
+
},
ChatBoxes: {
- chatBoxMayBeShown: function chatBoxMayBeShown(chatbox) {
+ chatBoxMayBeShown(chatbox) {
return this.__super__.chatBoxMayBeShown.apply(this, arguments) && !chatbox.get('minimized');
}
+
},
ChatBoxViews: {
- getChatBoxWidth: function getChatBoxWidth(view) {
+ getChatBoxWidth(view) {
if (!view.model.get('minimized') && u.isVisible(view.el)) {
return u.getOuterWidth(view.el, true);
}
return 0;
},
- getShownChats: function getShownChats() {
- return this.filter(function (view) {
- return (// The controlbox can take a while to close,
- // so we need to check its state. That's why we checked
- // the 'closed' state.
- !view.model.get('minimized') && !view.model.get('closed') && u.isVisible(view.el)
- );
- });
- },
- trimChats: function trimChats(newchat) {
- var _this = this;
+ getShownChats() {
+ return this.filter(view => // The controlbox can take a while to close,
+ // so we need to check its state. That's why we checked
+ // the 'closed' state.
+ !view.model.get('minimized') && !view.model.get('closed') && u.isVisible(view.el));
+ },
+
+ trimChats(newchat) {
/* This method is called when a newly created chat box will
* be shown.
*
@@ -40771,9 +47080,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* another chat box. Otherwise it minimizes the oldest chat box
* to create space.
*/
- var _converse = this.__super__._converse,
- shown_chats = this.getShownChats(),
- body_width = u.getOuterWidth(document.querySelector('body'), true);
+ const _converse = this.__super__._converse,
+ shown_chats = this.getShownChats(),
+ body_width = u.getOuterWidth(document.querySelector('body'), true);
if (_converse.no_trimming || shown_chats.length <= 1) {
return;
@@ -40786,26 +47095,24 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- _converse.api.waitUntil('minimizedChatsInitialized').then(function () {
- var minimized_el = _.get(_converse.minimized_chats, 'el'),
- new_id = newchat ? newchat.model.get('id') : null;
+ _converse.api.waitUntil('minimizedChatsInitialized').then(() => {
+ const minimized_el = _.get(_converse.minimized_chats, 'el'),
+ new_id = newchat ? newchat.model.get('id') : null;
if (minimized_el) {
- var minimized_width = _.includes(_this.model.pluck('minimized'), true) ? u.getOuterWidth(minimized_el, true) : 0;
+ const minimized_width = _.includes(this.model.pluck('minimized'), true) ? u.getOuterWidth(minimized_el, true) : 0;
- var boxes_width = _.reduce(_this.xget(new_id), function (memo, view) {
- return memo + _this.getChatBoxWidth(view);
- }, newchat ? u.getOuterWidth(newchat.el, true) : 0);
+ const boxes_width = _.reduce(this.xget(new_id), (memo, view) => memo + this.getChatBoxWidth(view), newchat ? u.getOuterWidth(newchat.el, true) : 0);
if (minimized_width + boxes_width > body_width) {
- var oldest_chat = _this.getOldestMaximizedChat([new_id]);
+ const oldest_chat = this.getOldestMaximizedChat([new_id]);
if (oldest_chat) {
// We hide the chat immediately, because waiting
// for the event to fire (and letting the
// ChatBoxView hide it then) causes race
// conditions.
- var view = _this.get(oldest_chat.get('id'));
+ const view = this.get(oldest_chat.get('id'));
if (view) {
view.hide();
@@ -40817,11 +47124,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
- getOldestMaximizedChat: function getOldestMaximizedChat(exclude_ids) {
+
+ getOldestMaximizedChat(exclude_ids) {
// Get oldest view (if its id is not excluded)
exclude_ids.push('controlbox');
- var i = 0;
- var model = this.model.sort().at(i);
+ let i = 0;
+ let model = this.model.sort().at(i);
while (_.includes(exclude_ids, model.get('id')) || model.get('minimized') === true) {
i++;
@@ -40834,14 +47142,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return model;
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by Converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__; // Add new HTML templates.
+ const _converse = this._converse,
+ __ = _converse.__; // Add new HTML templates.
_converse.templates.chatbox_minimize = tpl_chatbox_minimize;
_converse.templates.toggle_chats = tpl_toggle_chats;
@@ -40862,11 +47172,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click .close-chatbox-button': 'close',
'click .restore-chat': 'restore'
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change:num_unread', this.render, this);
},
- render: function render() {
- var data = _.extend(this.model.toJSON(), {
+
+ render() {
+ const data = _.extend(this.model.toJSON(), {
'tooltip': __('Click to restore this chat')
});
@@ -40881,14 +47193,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.el.innerHTML = tpl_trimmed_chat(data);
return this.el;
},
- close: function close(ev) {
+
+ close(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
this.remove();
- var view = _converse.chatboxviews.get(this.model.get('id'));
+ const view = _converse.chatboxviews.get(this.model.get('id'));
if (view) {
// This will call model.destroy(), removing it from the
@@ -40902,6 +47215,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
+
restore: _.debounce(function (ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
@@ -40921,7 +47235,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
events: {
"click #toggle-minimized-chats": "toggle"
},
- initialize: function initialize() {
+
+ initialize() {
this.render();
this.initToggle();
this.addMultipleChats(this.model.where({
@@ -40932,7 +47247,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.on("change:minimized", this.onChanged, this);
this.model.on('change:num_unread', this.updateUnreadMessagesCounter, this);
},
- render: function render() {
+
+ render() {
if (!this.el.parentElement) {
this.el.innerHTML = tpl_chats_panel();
@@ -40949,16 +47265,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.el;
},
- tearDown: function tearDown() {
+
+ tearDown() {
this.model.off("add", this.onChanged);
this.model.off("destroy", this.removeChat);
this.model.off("change:minimized", this.onChanged);
this.model.off('change:num_unread', this.updateUnreadMessagesCounter);
return this;
},
- initToggle: function initToggle() {
- var storage = _converse.config.get('storage'),
- id = b64_sha1("converse.minchatstoggle".concat(_converse.bare_jid));
+
+ initToggle() {
+ const storage = _converse.config.get('storage'),
+ id = b64_sha1(`converse.minchatstoggle${_converse.bare_jid}`);
this.toggleview = new _converse.MinimizedChatsToggleView({
'model': new _converse.MinimizedChatsToggle({
@@ -40968,7 +47286,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.toggleview.model.browserStorage = new Backbone.BrowserStorage[storage](id);
this.toggleview.model.fetch();
},
- toggle: function toggle(ev) {
+
+ toggle(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -40978,7 +47297,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
u.slideToggleElement(this.el.querySelector('.minimized-chats-flyout'), 200);
},
- onChanged: function onChanged(item) {
+
+ onChanged(item) {
if (item.get('id') === 'controlbox') {
// The ControlBox has it's own minimize toggle
return;
@@ -40990,20 +47310,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.removeChat(item);
}
},
- addChatView: function addChatView(item) {
- var existing = this.get(item.get('id'));
+
+ addChatView(item) {
+ const existing = this.get(item.get('id'));
if (existing && existing.el.parentNode) {
return;
}
- var view = new _converse.MinimizedChatBoxView({
+ const view = new _converse.MinimizedChatBoxView({
model: item
});
this.el.querySelector('.minimized-chats-flyout').insertAdjacentElement('beforeEnd', view.render());
this.add(item.get('id'), view);
},
- addMultipleChats: function addMultipleChats(items) {
+
+ addMultipleChats(items) {
_.each(items, this.addChatView.bind(this));
this.toggleview.model.set({
@@ -41011,23 +47333,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
this.render();
},
- addChat: function addChat(item) {
+
+ addChat(item) {
this.addChatView(item);
this.toggleview.model.set({
'num_minimized': this.keys().length
});
this.render();
},
- removeChat: function removeChat(item) {
+
+ removeChat(item) {
this.remove(item.get('id'));
this.toggleview.model.set({
'num_minimized': this.keys().length
});
this.render();
},
- updateUnreadMessagesCounter: function updateUnreadMessagesCounter() {
- var ls = this.model.pluck('num_unread');
- var count = 0,
+
+ updateUnreadMessagesCounter() {
+ const ls = this.model.pluck('num_unread');
+ let count = 0,
i;
for (i = 0; i < ls.length; i++) {
@@ -41039,6 +47364,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
this.render();
}
+
});
_converse.MinimizedChatsToggle = Backbone.Model.extend({
defaults: {
@@ -41049,12 +47375,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
_converse.MinimizedChatsToggleView = Backbone.NativeView.extend({
el: '#toggle-minimized-chats',
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change:num_minimized', this.render, this);
this.model.on('change:num_unread', this.render, this);
this.flyout = this.el.parentElement.querySelector('.minimized-chats-flyout');
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_toggle_chats(_.extend(this.model.toJSON(), {
'Minimized': __('Minimized')
}));
@@ -41067,8 +47395,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.el;
}
+
});
- Promise.all([_converse.api.waitUntil('connectionInitialized'), _converse.api.waitUntil('chatBoxViewsInitialized')]).then(function () {
+ Promise.all([_converse.api.waitUntil('connectionInitialized'), _converse.api.waitUntil('chatBoxViewsInitialized')]).then(() => {
_converse.minimized_chats = new _converse.MinimizedChats({
model: _converse.chatboxes
});
@@ -41092,6 +47421,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
});
}
+
});
});
@@ -41104,10 +47434,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2018, the Converse.js developers
@@ -41119,37 +47446,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
-})(void 0, function (converse, tpl_alert_modal, bootstrap) {
+})(this, function (converse, tpl_alert_modal, bootstrap) {
"use strict";
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- Backbone = _converse$env.Backbone,
- _ = _converse$env._;
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ Backbone = _converse$env.Backbone,
+ _ = _converse$env._;
converse.plugins.add('converse-modal', {
- initialize: function initialize() {
- var _converse = this._converse;
+ initialize() {
+ const _converse = this._converse;
_converse.BootstrapModal = Backbone.VDOMView.extend({
- initialize: function initialize() {
- var _this = this;
-
+ initialize() {
this.render().insertIntoDOM();
this.modal = new bootstrap.Modal(this.el, {
backdrop: 'static',
keyboard: true
});
- this.el.addEventListener('hide.bs.modal', function (event) {
- if (!_.isNil(_this.trigger_el)) {
- _this.trigger_el.classList.remove('selected');
+ this.el.addEventListener('hide.bs.modal', event => {
+ if (!_.isNil(this.trigger_el)) {
+ this.trigger_el.classList.remove('selected');
}
}, false);
},
- insertIntoDOM: function insertIntoDOM() {
- var container_el = _converse.chatboxviews.el.querySelector("#converse-modals");
+
+ insertIntoDOM() {
+ const container_el = _converse.chatboxviews.el.querySelector("#converse-modals");
container_el.insertAdjacentElement('beforeEnd', this.el);
},
- show: function show(ev) {
+
+ show(ev) {
if (ev) {
ev.preventDefault();
this.trigger_el = ev.target;
@@ -41158,24 +47485,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.modal.show();
}
+
});
_converse.Alert = _converse.BootstrapModal.extend({
- initialize: function initialize() {
+ initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_alert_modal(this.model.toJSON());
}
+
});
- _converse.api.listen.on('afterTearDown', function () {
+ _converse.api.listen.on('afterTearDown', () => {
if (!_converse.chatboxviews) {
return;
}
- var container = _converse.chatboxviews.el.querySelector("#converse-modals");
+ const container = _converse.chatboxviews.el.querySelector("#converse-modals");
if (container) {
container.innerHTML = '';
@@ -41185,11 +47515,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// We extend the default converse.js API to add methods specific to MUC chat rooms.
- var alert;
+ let alert;
_.extend(_converse.api, {
'alert': {
- 'show': function show(type, title, messages) {
+ 'show'(type, title, messages) {
if (_.isString(messages)) {
messages = [messages];
}
@@ -41203,7 +47533,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
if (_.isUndefined(alert)) {
- var model = new Backbone.Model({
+ const model = new Backbone.Model({
'title': title,
'messages': messages,
'type': type
@@ -41221,9 +47551,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
alert.show();
}
+
}
});
}
+
});
});
@@ -41236,37 +47568,34 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! converse-core */ "./src/converse-core.js"), __webpack_require__(/*! formdata-polyfill */ "./node_modules/formdata-polyfill/FormData.js"), __webpack_require__(/*! utils/muc */ "./src/utils/muc.js"), __webpack_require__(/*! xss */ "./node_modules/xss/dist/xss.js"), __webpack_require__(/*! templates/add_chatroom_modal.html */ "./src/templates/add_chatroom_modal.html"), __webpack_require__(/*! templates/chatarea.html */ "./src/templates/chatarea.html"), __webpack_require__(/*! templates/chatroom.html */ "./src/templates/chatroom.html"), __webpack_require__(/*! templates/chatroom_details_modal.html */ "./src/templates/chatroom_details_modal.html"), __webpack_require__(/*! templates/chatroom_disconnect.html */ "./src/templates/chatroom_disconnect.html"), __webpack_require__(/*! templates/chatroom_features.html */ "./src/templates/chatroom_features.html"), __webpack_require__(/*! templates/chatroom_form.html */ "./src/templates/chatroom_form.html"), __webpack_require__(/*! templates/chatroom_head.html */ "./src/templates/chatroom_head.html"), __webpack_require__(/*! templates/chatroom_invite.html */ "./src/templates/chatroom_invite.html"), __webpack_require__(/*! templates/chatroom_nickname_form.html */ "./src/templates/chatroom_nickname_form.html"), __webpack_require__(/*! templates/chatroom_password_form.html */ "./src/templates/chatroom_password_form.html"), __webpack_require__(/*! templates/chatroom_sidebar.html */ "./src/templates/chatroom_sidebar.html"), __webpack_require__(/*! templates/info.html */ "./src/templates/info.html"), __webpack_require__(/*! templates/list_chatrooms_modal.html */ "./src/templates/list_chatrooms_modal.html"), __webpack_require__(/*! templates/occupant.html */ "./src/templates/occupant.html"), __webpack_require__(/*! templates/room_description.html */ "./src/templates/room_description.html"), __webpack_require__(/*! templates/room_item.html */ "./src/templates/room_item.html"), __webpack_require__(/*! templates/room_panel.html */ "./src/templates/room_panel.html"), __webpack_require__(/*! templates/rooms_results.html */ "./src/templates/rooms_results.html"), __webpack_require__(/*! templates/spinner.html */ "./src/templates/spinner.html"), __webpack_require__(/*! awesomplete */ "awesomplete"), __webpack_require__(/*! converse-modal */ "./src/converse-modal.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! converse-core */ "./src/converse-core.js"), __webpack_require__(/*! formdata-polyfill */ "./node_modules/formdata-polyfill/FormData.js"), __webpack_require__(/*! utils/muc */ "./src/utils/muc.js"), __webpack_require__(/*! xss */ "./node_modules/xss/dist/xss.js"), __webpack_require__(/*! templates/add_chatroom_modal.html */ "./src/templates/add_chatroom_modal.html"), __webpack_require__(/*! templates/chatarea.html */ "./src/templates/chatarea.html"), __webpack_require__(/*! templates/chatroom.html */ "./src/templates/chatroom.html"), __webpack_require__(/*! templates/chatroom_details_modal.html */ "./src/templates/chatroom_details_modal.html"), __webpack_require__(/*! templates/chatroom_destroyed.html */ "./src/templates/chatroom_destroyed.html"), __webpack_require__(/*! templates/chatroom_disconnect.html */ "./src/templates/chatroom_disconnect.html"), __webpack_require__(/*! templates/chatroom_features.html */ "./src/templates/chatroom_features.html"), __webpack_require__(/*! templates/chatroom_form.html */ "./src/templates/chatroom_form.html"), __webpack_require__(/*! templates/chatroom_head.html */ "./src/templates/chatroom_head.html"), __webpack_require__(/*! templates/chatroom_invite.html */ "./src/templates/chatroom_invite.html"), __webpack_require__(/*! templates/chatroom_nickname_form.html */ "./src/templates/chatroom_nickname_form.html"), __webpack_require__(/*! templates/chatroom_password_form.html */ "./src/templates/chatroom_password_form.html"), __webpack_require__(/*! templates/chatroom_sidebar.html */ "./src/templates/chatroom_sidebar.html"), __webpack_require__(/*! templates/info.html */ "./src/templates/info.html"), __webpack_require__(/*! templates/list_chatrooms_modal.html */ "./src/templates/list_chatrooms_modal.html"), __webpack_require__(/*! templates/occupant.html */ "./src/templates/occupant.html"), __webpack_require__(/*! templates/room_description.html */ "./src/templates/room_description.html"), __webpack_require__(/*! templates/room_item.html */ "./src/templates/room_item.html"), __webpack_require__(/*! templates/room_panel.html */ "./src/templates/room_panel.html"), __webpack_require__(/*! templates/rooms_results.html */ "./src/templates/rooms_results.html"), __webpack_require__(/*! templates/spinner.html */ "./src/templates/spinner.html"), __webpack_require__(/*! awesomplete */ "awesomplete"), __webpack_require__(/*! converse-modal */ "./src/converse-modal.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, _FormData, muc_utils, xss, tpl_add_chatroom_modal, tpl_chatarea, tpl_chatroom, tpl_chatroom_details_modal, tpl_chatroom_disconnect, tpl_chatroom_features, tpl_chatroom_form, tpl_chatroom_head, tpl_chatroom_invite, tpl_chatroom_nickname_form, tpl_chatroom_password_form, tpl_chatroom_sidebar, tpl_info, tpl_list_chatrooms_modal, tpl_occupant, tpl_room_description, tpl_room_item, tpl_room_panel, tpl_rooms_results, tpl_spinner, Awesomplete) {
+})(this, function (converse, _FormData, muc_utils, xss, tpl_add_chatroom_modal, tpl_chatarea, tpl_chatroom, tpl_chatroom_details_modal, tpl_chatroom_destroyed, tpl_chatroom_disconnect, tpl_chatroom_features, tpl_chatroom_form, tpl_chatroom_head, tpl_chatroom_invite, tpl_chatroom_nickname_form, tpl_chatroom_password_form, tpl_chatroom_sidebar, tpl_info, tpl_list_chatrooms_modal, tpl_occupant, tpl_room_description, tpl_room_item, tpl_room_panel, tpl_rooms_results, tpl_spinner, Awesomplete) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- b64_sha1 = _converse$env.b64_sha1,
- moment = _converse$env.moment,
- f = _converse$env.f,
- sizzle = _converse$env.sizzle,
- _ = _converse$env._,
- $build = _converse$env.$build,
- $iq = _converse$env.$iq,
- $msg = _converse$env.$msg,
- $pres = _converse$env.$pres;
- var u = converse.env.utils;
- var ROOM_FEATURES_MAP = {
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ b64_sha1 = _converse$env.b64_sha1,
+ moment = _converse$env.moment,
+ f = _converse$env.f,
+ sizzle = _converse$env.sizzle,
+ _ = _converse$env._,
+ $build = _converse$env.$build,
+ $iq = _converse$env.$iq,
+ $msg = _converse$env.$msg,
+ $pres = _converse$env.$pres;
+ const u = converse.env.utils;
+ const ROOM_FEATURES_MAP = {
'passwordprotected': 'unsecured',
'unsecured': 'passwordprotected',
'hidden': 'publicroom',
@@ -41296,13 +47625,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
dependencies: ["converse-autocomplete", "converse-modal", "converse-controlbox", "converse-chatview"],
overrides: {
ControlBoxView: {
- renderRoomsPanel: function renderRoomsPanel() {
- var _converse = this.__super__._converse;
+ renderRoomsPanel() {
+ const _converse = this.__super__._converse;
this.roomspanel = new _converse.RoomsPanel({
'model': new (_converse.RoomsPanelModel.extend({
- 'id': b64_sha1("converse.roomspanel".concat(_converse.bare_jid)),
+ 'id': b64_sha1(`converse.roomspanel${_converse.bare_jid}`),
// Required by sessionStorage
- 'browserStorage': new Backbone.BrowserStorage[_converse.config.get('storage')](b64_sha1("converse.roomspanel".concat(_converse.bare_jid)))
+ 'browserStorage': new Backbone.BrowserStorage[_converse.config.get('storage')](b64_sha1(`converse.roomspanel${_converse.bare_jid}`))
}))()
});
this.roomspanel.model.fetch();
@@ -41316,8 +47645,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('roomsPanelRendered');
},
- renderControlBoxPane: function renderControlBoxPane() {
- var _converse = this.__super__._converse;
+
+ renderControlBoxPane() {
+ const _converse = this.__super__._converse;
this.__super__.renderControlBoxPane.apply(this, arguments);
@@ -41325,11 +47655,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.renderRoomsPanel();
}
}
+
}
},
- initialize: function initialize() {
- var _converse = this._converse,
- __ = _converse.__;
+
+ initialize() {
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.promises.add(['roomsPanelRendered']); // Configuration values for this plugin
// ====================================
@@ -41469,10 +47801,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}));
}
- function _toggleRoomInfo(ev) {
+ function toggleRoomInfo(ev) {
/* Show/hide extra information about a groupchat in a listing. */
- var parent_el = u.ancestor(ev.target, '.room-item'),
- div_el = parent_el.querySelector('div.room-info');
+ const parent_el = u.ancestor(ev.target, '.room-item'),
+ div_el = parent_el.querySelector('div.room-info');
if (div_el) {
u.slideIn(div_el).then(u.removeElement);
@@ -41480,9 +47812,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} else {
parent_el.insertAdjacentHTML('beforeend', tpl_spinner());
- _converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null).then(function (stanza) {
- return insertRoomInfo(parent_el, stanza);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
+ _converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null).then(stanza => insertRoomInfo(parent_el, stanza)).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
}
}
@@ -41494,12 +47824,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'change input[name=server]': 'setDomain',
'click .open-room': 'openRoom'
},
- initialize: function initialize() {
+
+ initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change:muc_domain', this.onDomainChange, this);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_list_chatrooms_modal(_.extend(this.model.toJSON(), {
'heading_list_chatrooms': __('Query for Groupchats'),
'label_server_address': __('Server address'),
@@ -41507,36 +47839,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'server_placeholder': __('conference.example.org')
}));
},
- afterRender: function afterRender() {
- var _this = this;
- this.el.addEventListener('shown.bs.modal', function () {
- _this.el.querySelector('input[name="server"]').focus();
+ afterRender() {
+ this.el.addEventListener('shown.bs.modal', () => {
+ this.el.querySelector('input[name="server"]').focus();
}, false);
},
- openRoom: function openRoom(ev) {
+
+ openRoom(ev) {
ev.preventDefault();
- var jid = ev.target.getAttribute('data-room-jid');
- var name = ev.target.getAttribute('data-room-name');
+ const jid = ev.target.getAttribute('data-room-jid');
+ const name = ev.target.getAttribute('data-room-name');
this.modal.hide();
_converse.api.rooms.open(jid, {
'name': name
});
},
- toggleRoomInfo: function toggleRoomInfo(ev) {
- ev.preventDefault();
- _toggleRoomInfo(ev);
+ toggleRoomInfo(ev) {
+ ev.preventDefault();
+ toggleRoomInfo(ev);
},
- onDomainChange: function onDomainChange(model) {
+
+ onDomainChange(model) {
if (_converse.auto_list_rooms) {
this.updateRoomsList();
}
},
- roomStanzaItemToHTMLElement: function roomStanzaItemToHTMLElement(groupchat) {
- var name = Strophe.unescapeNode(groupchat.getAttribute('name') || groupchat.getAttribute('jid'));
- var div = document.createElement('div');
+
+ roomStanzaItemToHTMLElement(groupchat) {
+ const name = Strophe.unescapeNode(groupchat.getAttribute('name') || groupchat.getAttribute('jid'));
+ const div = document.createElement('div');
div.innerHTML = tpl_room_item({
'name': Strophe.xmlunescape(name),
'jid': groupchat.getAttribute('jid'),
@@ -41545,25 +47879,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return div.firstElementChild;
},
- removeSpinner: function removeSpinner() {
- _.each(this.el.querySelectorAll('span.spinner'), function (el) {
- return el.parentNode.removeChild(el);
- });
+
+ removeSpinner() {
+ _.each(this.el.querySelectorAll('span.spinner'), el => el.parentNode.removeChild(el));
},
- informNoRoomsFound: function informNoRoomsFound() {
- var chatrooms_el = this.el.querySelector('.available-chatrooms');
+
+ informNoRoomsFound() {
+ const chatrooms_el = this.el.querySelector('.available-chatrooms');
chatrooms_el.innerHTML = tpl_rooms_results({
'feedback_text': __('No groupchats found')
});
- var input_el = this.el.querySelector('input[name="server"]');
+ const input_el = this.el.querySelector('input[name="server"]');
input_el.classList.remove('hidden');
this.removeSpinner();
},
- onRoomsFound: function onRoomsFound(iq) {
+
+ onRoomsFound(iq) {
/* Handle the IQ stanza returned from the server, containing
* all its public groupchats.
*/
- var available_chatrooms = this.el.querySelector('.available-chatrooms');
+ const available_chatrooms = this.el.querySelector('.available-chatrooms');
this.rooms = iq.querySelectorAll('query item');
if (this.rooms.length) {
@@ -41572,13 +47907,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
available_chatrooms.innerHTML = tpl_rooms_results({
'feedback_text': __('Groupchats found:')
});
- var fragment = document.createDocumentFragment();
+ const fragment = document.createDocumentFragment();
- var children = _.reject(_.map(this.rooms, this.roomStanzaItemToHTMLElement), _.isNil);
+ const children = _.reject(_.map(this.rooms, this.roomStanzaItemToHTMLElement), _.isNil);
- _.each(children, function (child) {
- return fragment.appendChild(child);
- });
+ _.each(children, child => fragment.appendChild(child));
available_chatrooms.appendChild(fragment);
this.removeSpinner();
@@ -41588,7 +47921,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return true;
},
- updateRoomsList: function updateRoomsList() {
+
+ updateRoomsList() {
/* Send an IQ stanza to the server asking for all groupchats
*/
_converse.connection.sendIQ($iq({
@@ -41599,26 +47933,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
xmlns: Strophe.NS.DISCO_ITEMS
}), this.onRoomsFound.bind(this), this.informNoRoomsFound.bind(this), 5000);
},
- showRooms: function showRooms(ev) {
+
+ showRooms(ev) {
ev.preventDefault();
- var data = new FormData(ev.target);
+ const data = new FormData(ev.target);
this.model.save('muc_domain', Strophe.getDomainFromJid(data.get('server')));
this.updateRoomsList();
},
- setDomain: function setDomain(ev) {
+
+ setDomain(ev) {
this.model.save('muc_domain', Strophe.getDomainFromJid(ev.target.value));
},
- setNick: function setNick(ev) {
+
+ setNick(ev) {
this.model.save({
nick: ev.target.value
});
}
+
});
_converse.AddChatRoomModal = _converse.BootstrapModal.extend({
events: {
'submit form.add-chatroom': 'openChatRoom'
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_add_chatroom_modal(_.extend(this.model.toJSON(), {
'heading_new_chatroom': __('Enter a new Groupchat'),
'label_room_address': __('Groupchat address'),
@@ -41627,25 +47966,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'label_join': __('Join')
}));
},
- afterRender: function afterRender() {
- var _this2 = this;
- this.el.addEventListener('shown.bs.modal', function () {
- _this2.el.querySelector('input[name="chatroom"]').focus();
+ afterRender() {
+ this.el.addEventListener('shown.bs.modal', () => {
+ this.el.querySelector('input[name="chatroom"]').focus();
}, false);
},
- parseRoomDataFromEvent: function parseRoomDataFromEvent(form) {
- var data = new FormData(form);
- var jid = data.get('chatroom');
+
+ parseRoomDataFromEvent(form) {
+ const data = new FormData(form);
+ const jid = data.get('chatroom');
this.model.save('muc_domain', Strophe.getDomainFromJid(jid));
return {
'jid': jid,
'nick': data.get('nickname')
};
},
- openChatRoom: function openChatRoom(ev) {
+
+ openChatRoom(ev) {
ev.preventDefault();
- var data = this.parseRoomDataFromEvent(ev.target);
+ const data = this.parseRoomDataFromEvent(ev.target);
if (data.nick === "") {
// Make sure defaults apply if no nick is provided.
@@ -41657,15 +47997,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.modal.hide();
ev.target.reset();
}
+
});
_converse.RoomDetailsModal = _converse.BootstrapModal.extend({
- initialize: function initialize() {
+ initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this);
+ this.model.occupants.on('add', this.render, this);
this.model.occupants.on('change', this.render, this);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_chatroom_details_modal(_.extend(this.model.toJSON(), {
'_': _,
'__': __,
@@ -41676,6 +48019,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'num_occupants': this.model.occupants.length
}));
}
+
});
_converse.ChatRoomView = _converse.ChatBoxView.extend({
/* Backbone.NativeView which renders a groupchat, based upon the view
@@ -41691,11 +48035,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click .chatbox-navback': 'showControlBox',
'click .close-chatbox-button': 'close',
'click .configure-chatroom-button': 'getAndRenderConfigurationForm',
- 'click .show-room-details-modal': 'showRoomDetailsModal',
'click .hide-occupants': 'hideOccupants',
'click .new-msgs-indicator': 'viewUnreadMessages',
'click .occupant-nick': 'onOccupantClicked',
'click .send-button': 'onFormSubmitted',
+ 'click .show-room-details-modal': 'showRoomDetailsModal',
'click .toggle-call': 'toggleCall',
'click .toggle-occupants': 'toggleOccupants',
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
@@ -41705,22 +48049,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'keyup .chat-textarea': 'keyUp',
'input .chat-textarea': 'inputChanged'
},
- initialize: function initialize() {
- var _this3 = this;
+ initialize() {
this.initDebounced();
this.model.messages.on('add', this.onMessageAdded, this);
this.model.messages.on('rendered', this.scrollDown, this);
this.model.on('change:affiliation', this.renderHeading, this);
this.model.on('change:connection_status', this.afterConnected, this);
+ this.model.on('change:jid', this.renderHeading, this);
this.model.on('change:name', this.renderHeading, this);
this.model.on('change:subject', this.renderHeading, this);
this.model.on('change:subject', this.setChatRoomSubject, this);
this.model.on('configurationNeeded', this.getAndRenderConfigurationForm, this);
this.model.on('destroy', this.hide, this);
this.model.on('show', this.show, this);
- this.model.occupants.on('add', this.showJoinNotification, this);
- this.model.occupants.on('remove', this.showLeaveNotification, this);
+ this.model.occupants.on('add', this.onOccupantAdded, this);
+ this.model.occupants.on('remove', this.onOccupantRemoved, this);
this.model.occupants.on('change:show', this.showJoinOrLeaveNotification, this);
this.model.occupants.on('change:role', this.informOfOccupantsRoleChange, this);
this.model.occupants.on('change:affiliation', this.informOfOccupantsAffiliationChange, this);
@@ -41728,18 +48072,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.createOccupantsView();
this.render().insertIntoDOM();
this.registerHandlers();
+ this.enterRoom();
+ },
+
+ enterRoom(ev) {
+ if (ev) {
+ ev.preventDefault();
+ }
if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
- var handler = function handler() {
- if (!u.isPersistableModel(_this3.model)) {
+ const handler = () => {
+ if (!u.isPersistableModel(this.model)) {
// Happens during tests, nothing to do if this
// is a hanging chatbox (i.e. not in the collection anymore).
return;
}
- _this3.populateAndJoin();
+ this.populateAndJoin();
- _converse.emit('chatRoomOpened', _this3);
+ _converse.emit('chatRoomOpened', this);
};
this.model.getRoomFeatures().then(handler, handler);
@@ -41749,7 +48100,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.emit('chatRoomOpened', this);
}
},
- render: function render() {
+
+ render() {
this.el.setAttribute('id', this.model.get('box_id'));
this.el.innerHTML = tpl_chatroom();
this.renderHeading();
@@ -41763,15 +48115,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- renderHeading: function renderHeading() {
+
+ renderHeading() {
/* Render the heading UI of the groupchat. */
this.el.querySelector('.chat-head-chatroom').innerHTML = this.generateHeadingHTML();
},
- renderChatArea: function renderChatArea() {
+
+ renderChatArea() {
/* Render the UI container in which groupchat messages will appear.
*/
if (_.isNull(this.el.querySelector('.chat-area'))) {
- var container_el = this.el.querySelector('.chatroom-body');
+ const container_el = this.el.querySelector('.chatroom-body');
container_el.insertAdjacentHTML('beforeend', tpl_chatarea({
'show_send_button': _converse.show_send_button
}));
@@ -41782,41 +48136,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- initAutoComplete: function initAutoComplete() {
- var _this4 = this;
+ initAutoComplete() {
this.auto_complete = new _converse.AutoComplete(this.el, {
'auto_first': true,
'auto_evaluate': false,
'min_chars': 1,
'match_current_word': true,
'match_on_tab': true,
- 'list': function list() {
- return _this4.model.occupants.map(function (o) {
- return {
- 'label': o.getDisplayName(),
- 'value': "@".concat(o.getDisplayName())
- };
- });
- },
+ 'list': () => this.model.occupants.map(o => ({
+ 'label': o.getDisplayName(),
+ 'value': `@${o.getDisplayName()}`
+ })),
'filter': _converse.FILTER_STARTSWITH,
'trigger_on_at': true
});
- this.auto_complete.on('suggestion-box-selectcomplete', function () {
- return _this4.auto_completing = false;
- });
+ this.auto_complete.on('suggestion-box-selectcomplete', () => this.auto_completing = false);
},
- keyPressed: function keyPressed(ev) {
+
+ keyPressed(ev) {
if (this.auto_complete.keyPressed(ev)) {
return;
}
return _converse.ChatBoxView.prototype.keyPressed.apply(this, arguments);
},
- keyUp: function keyUp(ev) {
+
+ keyUp(ev) {
this.auto_complete.evaluate(ev);
},
- showRoomDetailsModal: function showRoomDetailsModal(ev) {
+
+ showRoomDetailsModal(ev) {
ev.preventDefault();
if (_.isUndefined(this.model.room_details_modal)) {
@@ -41827,14 +48177,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.room_details_modal.show(ev);
},
- showChatStateNotification: function showChatStateNotification(message) {
+
+ showChatStateNotification(message) {
if (message.get('sender') === 'me') {
return;
}
return _converse.ChatBoxView.prototype.showChatStateNotification.apply(this, arguments);
},
- createOccupantsView: function createOccupantsView() {
+
+ createOccupantsView() {
/* Create the ChatRoomOccupantsView Backbone.NativeView
*/
this.model.occupants.chatroomview = this;
@@ -41843,9 +48195,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this;
},
- informOfOccupantsAffiliationChange: function informOfOccupantsAffiliationChange(occupant, changed) {
- var previous_affiliation = occupant._previousAttributes.affiliation,
- current_affiliation = occupant.get('affiliation');
+
+ informOfOccupantsAffiliationChange(occupant, changed) {
+ const previous_affiliation = occupant._previousAttributes.affiliation,
+ current_affiliation = occupant.get('affiliation');
if (previous_affiliation === 'admin') {
this.showChatEvent(__("%1$s is no longer an admin of this groupchat", occupant.get('nick')));
@@ -41864,11 +48217,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} else if (current_affiliation === 'outcast') {
this.showChatEvent(__("%1$s has been banned from this groupchat", occupant.get('nick')));
} else if (current_affiliation === 'admin' || current_affiliation == 'owner') {
- this.showChatEvent(__("%1$s is now an ".concat(current_affiliation, " of this groupchat"), occupant.get('nick')));
+ this.showChatEvent(__(`%1$s is now an ${current_affiliation} of this groupchat`, occupant.get('nick')));
}
},
- informOfOccupantsRoleChange: function informOfOccupantsRoleChange(occupant, changed) {
- var previous_role = occupant._previousAttributes.role;
+
+ informOfOccupantsRoleChange(occupant, changed) {
+ const previous_role = occupant._previousAttributes.role;
if (previous_role === 'moderator') {
this.showChatEvent(__("%1$s is no longer a moderator", occupant.get('nick')));
@@ -41886,7 +48240,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showChatEvent(__("%1$s is now a moderator", occupant.get('nick')));
}
},
- generateHeadingHTML: function generateHeadingHTML() {
+
+ generateHeadingHTML() {
/* Returns the heading HTML to be rendered.
*/
return tpl_chatroom_head(_.extend(this.model.toJSON(), {
@@ -41894,10 +48249,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'info_close': __('Close and leave this groupchat'),
'info_configure': __('Configure this groupchat'),
'info_details': __('Show more details about this groupchat'),
- 'description': _.get(this.model.get('subject'), 'text') || ''
+ 'description': u.addHyperlinks(xss.filterXSS(_.get(this.model.get('subject'), 'text'), {
+ 'whiteList': {}
+ }))
}));
},
- afterShown: function afterShown() {
+
+ afterShown() {
/* Override from converse-chatview, specifically to avoid
* the 'active' chat state from being sent out prematurely.
*
@@ -41912,7 +48270,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.scrollDown();
this.renderEmojiPicker();
},
- show: function show() {
+
+ show() {
if (u.isVisible(this.el)) {
this.focus();
return;
@@ -41923,7 +48282,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.showElement(this.el);
this.afterShown();
},
- afterConnected: function afterConnected() {
+
+ afterConnected() {
if (this.model.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
this.hideSpinner();
this.setChatState(_converse.ACTIVE);
@@ -41931,13 +48291,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.focus();
}
},
- getToolbarOptions: function getToolbarOptions() {
+
+ getToolbarOptions() {
return _.extend(_converse.ChatBoxView.prototype.getToolbarOptions.apply(this, arguments), {
'label_hide_occupants': __('Hide the list of participants'),
'show_occupants_toggle': this.is_chatroom && _converse.visible_toolbar_buttons.toggle_occupants
});
},
- close: function close(ev) {
+
+ close(ev) {
/* Close this chat box, which implies leaving the groupchat as
* well.
*/
@@ -41951,8 +48313,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.ChatBoxView.prototype.close.apply(this, arguments);
},
- setOccupantsVisibility: function setOccupantsVisibility() {
- var icon_el = this.el.querySelector('.toggle-occupants');
+
+ setOccupantsVisibility() {
+ const icon_el = this.el.querySelector('.toggle-occupants');
if (this.model.get('hidden_occupants')) {
u.removeClass('fa-angle-double-right', icon_el);
@@ -41968,7 +48331,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.occupantsview.setOccupantsHeight();
},
- hideOccupants: function hideOccupants(ev, preserve_state) {
+
+ hideOccupants(ev, preserve_state) {
/* Show or hide the right sidebar containing the chat
* occupants (and the invite widget).
*/
@@ -41983,7 +48347,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setOccupantsVisibility();
this.scrollDown();
},
- toggleOccupants: function toggleOccupants(ev, preserve_state) {
+
+ toggleOccupants(ev, preserve_state) {
/* Show or hide the right sidebar containing the chat
* occupants (and the invite widget).
*/
@@ -42001,13 +48366,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setOccupantsVisibility();
this.scrollDown();
},
- onOccupantClicked: function onOccupantClicked(ev) {
+
+ onOccupantClicked(ev) {
/* When an occupant is clicked, insert their nickname into
* the chat textarea input.
*/
this.insertIntoTextArea(ev.target.textContent);
},
- handleChatStateNotification: function handleChatStateNotification(message) {
+
+ handleChatStateNotification(message) {
/* Override the method on the ChatBoxView base class to
* ignore notifications in groupchats.
*
@@ -42025,12 +48392,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.ChatBoxView.prototype.handleChatStateNotification.apply(this, arguments);
}
},
- modifyRole: function modifyRole(groupchat, nick, role, reason, onSuccess, onError) {
- var item = $build("item", {
- nick: nick,
- role: role
+
+ modifyRole(groupchat, nick, role, reason, onSuccess, onError) {
+ const item = $build("item", {
+ nick,
+ role
});
- var iq = $iq({
+ const iq = $iq({
to: groupchat,
type: "set"
}).c("query", {
@@ -42043,31 +48411,34 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return _converse.connection.sendIQ(iq, onSuccess, onError);
},
- verifyRoles: function verifyRoles(roles) {
- var me = this.model.occupants.findWhere({
+
+ verifyRoles(roles) {
+ const me = this.model.occupants.findWhere({
'jid': _converse.bare_jid
});
if (!_.includes(roles, me.get('role'))) {
- this.showErrorMessage(__("Forbidden: you do not have the necessary role in order to do that."));
+ this.showErrorMessage(__(`Forbidden: you do not have the necessary role in order to do that.`));
return false;
}
return true;
},
- verifyAffiliations: function verifyAffiliations(affiliations) {
- var me = this.model.occupants.findWhere({
+
+ verifyAffiliations(affiliations) {
+ const me = this.model.occupants.findWhere({
'jid': _converse.bare_jid
});
if (!_.includes(affiliations, me.get('affiliation'))) {
- this.showErrorMessage(__("Forbidden: you do not have the necessary affiliation in order to do that."));
+ this.showErrorMessage(__(`Forbidden: you do not have the necessary affiliation in order to do that.`));
return false;
}
return true;
},
- validateRoleChangeCommand: function validateRoleChangeCommand(command, args) {
+
+ validateRoleChangeCommand(command, args) {
/* Check that a command to change a groupchat user's role or
* affiliation has anough arguments.
*/
@@ -42087,14 +48458,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return true;
},
- onCommandError: function onCommandError(err) {
+
+ onCommandError(err) {
_converse.log(err, Strophe.LogLevel.FATAL);
this.showErrorMessage(__("Sorry, an error happened while running the command. Check your browser's developer console for details."));
},
- parseMessageForCommands: function parseMessageForCommands(text) {
- var _this5 = this;
+ parseMessageForCommands(text) {
if (_converse.ChatBoxView.prototype.parseMessageForCommands.apply(this, arguments)) {
return true;
}
@@ -42103,11 +48474,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
}
- var match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''],
- args = match[2] && match[2].splitOnce(' ').filter(function (s) {
- return s;
- }) || [],
- command = match[1].toLowerCase();
+ const match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''],
+ args = match[2] && match[2].splitOnce(' ').filter(s => s) || [],
+ command = match[1].toLowerCase();
switch (command) {
case 'admin':
@@ -42118,11 +48487,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.setAffiliation('admin', [{
'jid': args[0],
'reason': args[1]
- }]).then(function () {
- return _this5.model.occupants.fetchMembers();
- }, function (err) {
- return _this5.onCommandError(err);
- });
+ }]).then(() => this.model.occupants.fetchMembers(), err => this.onCommandError(err));
break;
case 'ban':
@@ -42133,11 +48498,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.setAffiliation('outcast', [{
'jid': args[0],
'reason': args[1]
- }]).then(function () {
- return _this5.model.occupants.fetchMembers();
- }, function (err) {
- return _this5.onCommandError(err);
- });
+ }]).then(() => this.model.occupants.fetchMembers(), err => this.onCommandError(err));
break;
case 'deop':
@@ -42149,7 +48510,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break;
case 'help':
- this.showHelpMessages(["/admin: ".concat(__("Change user's affiliation to admin")), "/ban: ".concat(__('Ban user from groupchat')), "/clear: ".concat(__('Remove messages')), "/deop: ".concat(__('Change user role to participant')), "/help: ".concat(__('Show this menu')), "/kick: ".concat(__('Kick user from groupchat')), "/me: ".concat(__('Write in 3rd person')), "/member: ".concat(__('Grant membership to a user')), "/mute: ".concat(__("Remove user's ability to post messages")), "/nick: ".concat(__('Change your nickname')), "/op: ".concat(__('Grant moderator role to user')), "/owner: ".concat(__('Grant ownership of this groupchat')), "/register: ".concat(__("Register a nickname for this room")), "/revoke: ".concat(__("Revoke user's membership")), "/subject: ".concat(__('Set groupchat subject')), "/topic: ".concat(__('Set groupchat subject (alias for /subject)')), "/voice: ".concat(__('Allow muted user to post messages'))]);
+ this.showHelpMessages([`/admin: ${__("Change user's affiliation to admin")}`, `/ban: ${__('Ban user from groupchat')}`, `/clear: ${__('Remove messages')}`, `/deop: ${__('Change user role to participant')}`, `/help: ${__('Show this menu')}`, `/kick: ${__('Kick user from groupchat')}`, `/me: ${__('Write in 3rd person')}`, `/member: ${__('Grant membership to a user')}`, `/mute: ${__("Remove user's ability to post messages")}`, `/nick: ${__('Change your nickname')}`, `/op: ${__('Grant moderator role to user')}`, `/owner: ${__('Grant ownership of this groupchat')}`, `/register: ${__("Register a nickname for this room")}`, `/revoke: ${__("Revoke user's membership")}`, `/subject: ${__('Set groupchat subject')}`, `/topic: ${__('Set groupchat subject (alias for /subject)')}`, `/voice: ${__('Allow muted user to post messages')}`]);
break;
case 'kick':
@@ -42174,12 +48535,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break;
}
- var occupant = this.model.occupants.findWhere({
+ const occupant = this.model.occupants.findWhere({
'nick': args[0]
}) || this.model.occupants.findWhere({
'jid': args[0]
}),
- attrs = {
+ attrs = {
'jid': occupant.get('jid'),
'reason': args[1]
};
@@ -42188,11 +48549,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
attrs['nick'] = occupant.get('nick');
}
- this.model.setAffiliation('member', [attrs]).then(function () {
- return _this5.model.occupants.fetchMembers();
- }).catch(function (err) {
- return _this5.onCommandError(err);
- });
+ this.model.setAffiliation('member', [attrs]).then(() => this.model.occupants.fetchMembers()).catch(err => this.onCommandError(err));
break;
}
@@ -42217,11 +48574,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.setAffiliation('owner', [{
'jid': args[0],
'reason': args[1]
- }]).then(function () {
- return _this5.model.occupants.fetchMembers();
- }, function (err) {
- return _this5.onCommandError(err);
- });
+ }]).then(() => this.model.occupants.fetchMembers(), err => this.onCommandError(err));
break;
case 'op':
@@ -42234,10 +48587,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
case 'register':
if (args.length > 1) {
- this.showErrorMessage(__("Error: invalid number of arguments"));
+ this.showErrorMessage(__(`Error: invalid number of arguments`));
} else {
- this.model.registerNickname().then(function (err_msg) {
- if (err_msg) _this5.showErrorMessage(err_msg);
+ this.model.registerNickname().then(err_msg => {
+ if (err_msg) this.showErrorMessage(err_msg);
});
}
@@ -42251,11 +48604,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.setAffiliation('none', [{
'jid': args[0],
'reason': args[1]
- }]).then(function () {
- return _this5.model.occupants.fetchMembers();
- }, function (err) {
- return _this5.onCommandError(err);
- });
+ }]).then(() => this.model.occupants.fetchMembers(), err => this.onCommandError(err));
break;
case 'topic':
@@ -42285,7 +48634,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return true;
},
- registerHandlers: function registerHandlers() {
+
+ registerHandlers() {
/* Register presence and message handlers for this chat
* groupchat
*/
@@ -42297,7 +48647,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.addHandler('message', 'ChatRoomView.showStatusMessages', this.showStatusMessages.bind(this));
},
- onPresence: function onPresence(pres) {
+
+ onPresence(pres) {
/* Handles all MUC presence stanzas.
*
* Parameters:
@@ -42318,12 +48669,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showStatusMessages(pres);
}
},
- populateAndJoin: function populateAndJoin() {
+
+ populateAndJoin() {
this.model.occupants.fetchMembers();
this.join();
this.fetchMessages();
},
- join: function join(nick, password) {
+
+ join(nick, password) {
/* Join the groupchat.
*
* Parameters:
@@ -42339,9 +48692,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.join(nick, password);
return this;
},
- renderConfigurationForm: function renderConfigurationForm(stanza) {
- var _this6 = this;
+ renderConfigurationForm(stanza) {
/* Renders a form given an IQ stanza containing the current
* groupchat configuration.
*
@@ -42352,7 +48704,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (XMLElement) stanza: The IQ stanza containing the groupchat
* config.
*/
- var container_el = this.el.querySelector('.chatroom-body');
+ const container_el = this.el.querySelector('.chatroom-body');
_.each(container_el.querySelectorAll('.chatroom-form-container'), u.removeElement);
@@ -42360,17 +48712,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
container_el.insertAdjacentHTML('beforeend', tpl_chatroom_form());
- var form_el = container_el.querySelector('form.chatroom-form'),
- fieldset_el = form_el.querySelector('fieldset'),
- fields = stanza.querySelectorAll('field'),
- title = _.get(stanza.querySelector('title'), 'textContent'),
- instructions = _.get(stanza.querySelector('instructions'), 'textContent');
+ const form_el = container_el.querySelector('form.chatroom-form'),
+ fieldset_el = form_el.querySelector('fieldset'),
+ fields = stanza.querySelectorAll('field'),
+ title = _.get(stanza.querySelector('title'), 'textContent'),
+ instructions = _.get(stanza.querySelector('instructions'), 'textContent');
u.removeElement(fieldset_el.querySelector('span.spinner'));
- fieldset_el.insertAdjacentHTML('beforeend', ""));
+ fieldset_el.insertAdjacentHTML('beforeend', ``);
if (instructions && instructions !== title) {
- fieldset_el.insertAdjacentHTML('beforeend', "".concat(instructions, "
"));
+ fieldset_el.insertAdjacentHTML('beforeend', `${instructions}
`);
}
_.each(fields, function (field) {
@@ -42378,33 +48730,30 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}); // Render save/cancel buttons
- var last_fieldset_el = document.createElement('fieldset');
- last_fieldset_el.insertAdjacentHTML('beforeend', ""));
- last_fieldset_el.insertAdjacentHTML('beforeend', ""));
+ const last_fieldset_el = document.createElement('fieldset');
+ last_fieldset_el.insertAdjacentHTML('beforeend', ``);
+ last_fieldset_el.insertAdjacentHTML('beforeend', ``);
form_el.insertAdjacentElement('beforeend', last_fieldset_el);
- last_fieldset_el.querySelector('input[type=button]').addEventListener('click', function (ev) {
+ last_fieldset_el.querySelector('input[type=button]').addEventListener('click', ev => {
ev.preventDefault();
-
- _this6.closeForm();
+ this.closeForm();
});
- form_el.addEventListener('submit', function (ev) {
+ form_el.addEventListener('submit', ev => {
ev.preventDefault();
-
- _this6.model.saveConfiguration(ev.target).then(function () {
- return _this6.model.refreshRoomFeatures();
- });
-
- _this6.closeForm();
+ this.model.saveConfiguration(ev.target).then(() => this.model.refreshRoomFeatures());
+ this.closeForm();
}, false);
},
- closeForm: function closeForm() {
+
+ closeForm() {
/* Remove the configuration form without submitting and
* return to the chat view.
*/
u.removeElement(this.el.querySelector('.chatroom-form-container'));
this.renderAfterTransition();
},
- getAndRenderConfigurationForm: function getAndRenderConfigurationForm(ev) {
+
+ getAndRenderConfigurationForm(ev) {
/* Start the process of configuring a groupchat, either by
* rendering a configuration form, or by auto-configuring
* based on the "roomconfig" data stored on the
@@ -42422,13 +48771,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showSpinner();
this.model.fetchRoomConfiguration().then(this.renderConfigurationForm.bind(this)).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
},
- submitNickname: function submitNickname(ev) {
+
+ submitNickname(ev) {
/* Get the nickname value from the form and then join the
* groupchat with it.
*/
ev.preventDefault();
- var nick_el = ev.target.nick;
- var nick = nick_el.value;
+ const nick_el = ev.target.nick;
+ const nick = nick_el.value;
if (!nick) {
nick_el.classList.add('error');
@@ -42440,7 +48790,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.el.querySelector('.chatroom-form-container').outerHTML = tpl_spinner();
this.join(nick);
},
- checkForReservedNick: function checkForReservedNick() {
+
+ checkForReservedNick() {
/* User service-discovery to ask the XMPP server whether
* this user has a reserved nickname for this groupchat.
* If so, we'll use that, otherwise we render the nickname form.
@@ -42448,15 +48799,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showSpinner();
this.model.checkForReservedNick().then(this.onReservedNickFound.bind(this)).catch(this.onReservedNickNotFound.bind(this));
},
- onReservedNickFound: function onReservedNickFound(iq) {
+
+ onReservedNickFound(iq) {
if (this.model.get('nick')) {
this.join();
} else {
this.onReservedNickNotFound();
}
},
- onReservedNickNotFound: function onReservedNickNotFound(message) {
- var nick = this.model.getDefaultNick();
+
+ onReservedNickNotFound(message) {
+ const nick = this.model.getDefaultNick();
if (nick) {
this.join(nick);
@@ -42464,7 +48817,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.renderNicknameForm(message);
}
},
- onNicknameClash: function onNicknameClash(presence) {
+
+ onNicknameClash(presence) {
/* When the nickname is already taken, we either render a
* form for the user to choose a new nickname, or we
* try to make the nickname unique by adding an integer to
@@ -42474,29 +48828,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* muc_nickname_from_jid.
*/
if (_converse.muc_nickname_from_jid) {
- var nick = presence.getAttribute('from').split('/')[1];
+ const nick = presence.getAttribute('from').split('/')[1];
if (nick === this.model.getDefaultNick()) {
this.join(nick + '-2');
} else {
- var del = nick.lastIndexOf("-");
- var num = nick.substring(del + 1, nick.length);
+ const del = nick.lastIndexOf("-");
+ const num = nick.substring(del + 1, nick.length);
this.join(nick.substring(0, del + 1) + String(Number(num) + 1));
}
} else {
this.renderNicknameForm(__("The nickname you chose is reserved or " + "currently in use, please choose a different one."));
}
},
- hideChatRoomContents: function hideChatRoomContents() {
- var container_el = this.el.querySelector('.chatroom-body');
+
+ hideChatRoomContents() {
+ const container_el = this.el.querySelector('.chatroom-body');
if (!_.isNull(container_el)) {
- _.each(container_el.children, function (child) {
+ _.each(container_el.children, child => {
child.classList.add('hidden');
});
}
},
- renderNicknameForm: function renderNicknameForm(message) {
+
+ renderNicknameForm(message) {
/* Render a form which allows the user to choose their
* nickname.
*/
@@ -42508,7 +48864,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
message = '';
}
- var container_el = this.el.querySelector('.chatroom-body');
+ const container_el = this.el.querySelector('.chatroom-body');
container_el.insertAdjacentHTML('beforeend', tpl_chatroom_nickname_form({
heading: __('Please choose your nickname'),
label_nickname: __('Nickname'),
@@ -42516,19 +48872,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
validation_message: message
}));
this.model.save('connection_status', converse.ROOMSTATUS.NICKNAME_REQUIRED);
- var form_el = this.el.querySelector('.chatroom-form');
+ const form_el = this.el.querySelector('.chatroom-form');
form_el.addEventListener('submit', this.submitNickname.bind(this), false);
},
- submitPassword: function submitPassword(ev) {
+
+ submitPassword(ev) {
ev.preventDefault();
- var password = this.el.querySelector('.chatroom-form input[type=password]').value;
+ const password = this.el.querySelector('.chatroom-form input[type=password]').value;
this.showSpinner();
this.join(this.model.get('nick'), password);
},
- renderPasswordForm: function renderPasswordForm() {
- var _this7 = this;
- var container_el = this.el.querySelector('.chatroom-body');
+ renderPasswordForm() {
+ const container_el = this.el.querySelector('.chatroom-body');
_.each(container_el.children, u.hideElement);
@@ -42542,11 +48898,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'label_submit': __('Submit')
}));
this.model.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
- this.el.querySelector('.chatroom-form').addEventListener('submit', function (ev) {
- return _this7.submitPassword(ev);
- }, false);
+ this.el.querySelector('.chatroom-form').addEventListener('submit', ev => this.submitPassword(ev), false);
},
- showDisconnectMessages: function showDisconnectMessages(msgs) {
+
+ showDestroyedMessage(error) {
+ u.hideElement(this.el.querySelector('.chat-area'));
+ u.hideElement(this.el.querySelector('.occupants'));
+
+ _.each(this.el.querySelectorAll('.spinner'), u.removeElement);
+
+ const container = this.el.querySelector('.disconnect-container');
+
+ const moved_jid = _.get(sizzle('gone[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]', error).pop(), 'textContent').replace(/^xmpp:/, '').replace(/\?join$/, '');
+
+ const reason = _.get(sizzle('text[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]', error).pop(), 'textContent');
+
+ container.innerHTML = tpl_chatroom_destroyed({
+ '_': _,
+ '__': __,
+ 'jid': moved_jid,
+ 'reason': reason ? `"${reason}"` : null
+ });
+ const switch_el = container.querySelector('a.switch-chat');
+
+ if (switch_el) {
+ switch_el.addEventListener('click', ev => {
+ ev.preventDefault();
+ this.model.save('jid', moved_jid);
+ container.innerHTML = '';
+ this.showSpinner();
+ this.enterRoom();
+ });
+ }
+
+ u.showElement(container);
+ },
+
+ showDisconnectMessages(msgs) {
if (_.isString(msgs)) {
msgs = [msgs];
}
@@ -42556,21 +48944,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_.each(this.el.querySelectorAll('.spinner'), u.removeElement);
- var container = this.el.querySelector('.disconnect-container');
+ const container = this.el.querySelector('.disconnect-container');
container.innerHTML = tpl_chatroom_disconnect({
'_': _,
'disconnect_messages': msgs
});
u.showElement(container);
},
- getMessageFromStatus: function getMessageFromStatus(stat, stanza, is_self) {
+
+ getMessageFromStatus(stat, stanza, is_self) {
/* Parameters:
* (XMLElement) stat: A element.
* (Boolean) is_self: Whether the element refers to the
* current user.
* (XMLElement) stanza: The original stanza received.
*/
- var code = stat.getAttribute('code');
+ const code = stat.getAttribute('code');
if (code === '110' || code === '100' && !is_self) {
return;
@@ -42580,7 +48969,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return _converse.muc.info_messages[code];
}
- var nick;
+ let nick;
if (!is_self) {
if (code in _converse.muc.action_info_messages) {
@@ -42599,30 +48988,49 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
},
- parseXUserElement: function parseXUserElement(x, stanza, is_self) {
+
+ getNotificationWithMessage(message) {
+ let el = this.content.lastElementChild;
+
+ while (!_.isNil(el)) {
+ const data = _.get(el, 'dataset', {});
+
+ if (!_.includes(_.get(el, 'classList', []), 'chat-info')) {
+ return;
+ }
+
+ if (el.textContent === message) {
+ return el;
+ }
+
+ el = el.previousElementSibling;
+ }
+ },
+
+ parseXUserElement(x, stanza, is_self) {
/* Parse the passed-in
* element and construct a map containing relevant
* information.
*/
// 1. Get notification messages based on the elements.
- var statuses = x.querySelectorAll('status');
+ const statuses = x.querySelectorAll('status');
- var mapper = _.partial(this.getMessageFromStatus, _, stanza, is_self);
+ const mapper = _.partial(this.getMessageFromStatus, _, stanza, is_self);
- var notification = {};
+ const notification = {};
- var messages = _.reject(_.map(statuses, mapper), _.isUndefined);
+ const messages = _.reject(_.reject(_.map(statuses, mapper), _.isUndefined), message => this.getNotificationWithMessage(message));
if (messages.length) {
notification.messages = messages;
} // 2. Get disconnection messages based on the elements
- var codes = _.invokeMap(statuses, Element.prototype.getAttribute, 'code');
+ const codes = _.invokeMap(statuses, Element.prototype.getAttribute, 'code');
- var disconnection_codes = _.intersection(codes, _.keys(_converse.muc.disconnect_messages));
+ const disconnection_codes = _.intersection(codes, _.keys(_converse.muc.disconnect_messages));
- var disconnected = is_self && disconnection_codes.length > 0;
+ const disconnected = is_self && disconnection_codes.length > 0;
if (disconnected) {
notification.disconnected = true;
@@ -42630,19 +49038,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} // 3. Find the reason and actor from the - element
- var item = x.querySelector('item'); // By using querySelector above, we assume here there is
+ const item = x.querySelector('item'); // By using querySelector above, we assume here there is
// one
- per
// element. This appears to be a safe assumption, since
// each element pertains to a single user.
if (!_.isNull(item)) {
- var reason = item.querySelector('reason');
+ const reason = item.querySelector('reason');
if (reason) {
notification.reason = reason ? reason.textContent : undefined;
}
- var actor = item.querySelector('actor');
+ const actor = item.querySelector('actor');
if (actor) {
notification.actor = actor ? actor.getAttribute('nick') : undefined;
@@ -42651,15 +49059,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return notification;
},
- showNotificationsforUser: function showNotificationsforUser(notification) {
- var _this8 = this;
+ showNotificationsforUser(notification) {
/* Given the notification object generated by
* parseXUserElement, display any relevant messages and
* information to the user.
*/
if (notification.disconnected) {
- var messages = [];
+ const messages = [];
messages.push(notification.disconnection_message);
if (notification.actor) {
@@ -42675,9 +49082,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- _.each(notification.messages, function (message) {
- _this8.content.insertAdjacentHTML('beforeend', tpl_info({
- 'data': '',
+ _.each(notification.messages, message => {
+ this.content.insertAdjacentHTML('beforeend', tpl_info({
'isodate': moment().format(),
'extra_classes': 'chat-event',
'message': message
@@ -42692,8 +49098,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.scrollDown();
}
},
- showJoinOrLeaveNotification: function showJoinOrLeaveNotification(occupant) {
- if (!occupant.isMember() || _.includes(occupant.get('states'), '303')) {
+
+ onOccupantAdded(occupant) {
+ if (occupant.get('show') === 'online') {
+ this.showJoinNotification(occupant);
+ }
+ },
+
+ onOccupantRemoved(occupant) {
+ if (occupant.get('show') === 'online') {
+ this.showLeaveNotification(occupant);
+ }
+ },
+
+ showJoinOrLeaveNotification(occupant) {
+ if (_.includes(occupant.get('states'), '303')) {
return;
}
@@ -42703,31 +49122,65 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showJoinNotification(occupant);
}
},
- showJoinNotification: function showJoinNotification(occupant) {
+
+ getPreviousJoinOrLeaveNotification(el, nick) {
+ /* Working backwards, get the first join/leave notification
+ * from the same user, on the same day and BEFORE any chat
+ * messages were received.
+ */
+ while (!_.isNil(el)) {
+ const data = _.get(el, 'dataset', {});
+
+ if (!_.includes(_.get(el, 'classList', []), 'chat-info')) {
+ return;
+ }
+
+ if (!moment(el.getAttribute('data-isodate')).isSame(new Date(), "day")) {
+ el = el.previousElementSibling;
+ continue;
+ }
+
+ if (data.join === nick || data.leave === nick || data.leavejoin === nick || data.joinleave === nick) {
+ return el;
+ }
+
+ el = el.previousElementSibling;
+ }
+ },
+
+ showJoinNotification(occupant) {
if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
return;
}
- var nick = occupant.get('nick'),
- stat = occupant.get('status'),
- last_el = this.content.lastElementChild;
+ const nick = occupant.get('nick'),
+ stat = occupant.get('status'),
+ prev_info_el = this.getPreviousJoinOrLeaveNotification(this.content.lastElementChild, nick),
+ data = _.get(prev_info_el, 'dataset', {});
- if (_.includes(_.get(last_el, 'classList', []), 'chat-info') && _.get(last_el, 'dataset', {}).leave === "\"".concat(nick, "\"")) {
- last_el.outerHTML = tpl_info({
- 'data': "data-leavejoin=\"".concat(nick, "\""),
+ if (data.leave === nick) {
+ let message;
+
+ if (_.isNil(stat)) {
+ message = __('%1$s has left and re-entered the groupchat', nick);
+ } else {
+ message = __('%1$s has left and re-entered the groupchat. "%2$s"', nick, stat);
+ }
+
+ const data = {
+ 'data_name': 'leavejoin',
+ 'data_value': nick,
'isodate': moment().format(),
'extra_classes': 'chat-event',
- 'message': __('%1$s has left and re-entered the groupchat', nick)
- });
- var el = this.content.lastElementChild;
- setTimeout(function () {
- return u.addClass('fade-out', el);
- }, 5000);
- setTimeout(function () {
- return el.parentElement && el.parentElement.removeChild(el);
- }, 5250);
+ 'message': message
+ };
+ this.content.removeChild(prev_info_el);
+ this.content.insertAdjacentHTML('beforeend', tpl_info(data));
+ const el = this.content.lastElementChild;
+ setTimeout(() => u.addClass('fade-out', el), 5000);
+ setTimeout(() => el.parentElement && el.parentElement.removeChild(el), 5500);
} else {
- var message;
+ let message;
if (_.isNil(stat)) {
message = __('%1$s has entered the groupchat', nick);
@@ -42735,36 +49188,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
message = __('%1$s has entered the groupchat. "%2$s"', nick, stat);
}
- var data = {
- 'data': "data-join=\"".concat(nick, "\""),
+ const data = {
+ 'data_name': 'join',
+ 'data_value': nick,
'isodate': moment().format(),
'extra_classes': 'chat-event',
'message': message
};
- if (_.includes(_.get(last_el, 'classList', []), 'chat-info') && _.get(last_el, 'dataset', {}).joinleave === "\"".concat(nick, "\"")) {
- last_el.outerHTML = tpl_info(data);
+ if (prev_info_el) {
+ this.content.removeChild(prev_info_el);
+ this.content.insertAdjacentHTML('beforeend', tpl_info(data));
} else {
- var _el = u.stringToElement(tpl_info(data));
-
- this.content.insertAdjacentElement('beforeend', _el);
- this.insertDayIndicator(_el);
+ this.content.insertAdjacentHTML('beforeend', tpl_info(data));
+ this.insertDayIndicator(this.content.lastElementChild);
}
}
this.scrollDown();
},
- showLeaveNotification: function showLeaveNotification(occupant) {
+
+ showLeaveNotification(occupant) {
if (_.includes(occupant.get('states'), '303') || _.includes(occupant.get('states'), '307')) {
return;
}
- var nick = occupant.get('nick'),
- stat = occupant.get('status'),
- last_el = this.content.lastElementChild;
+ const nick = occupant.get('nick'),
+ stat = occupant.get('status'),
+ prev_info_el = this.getPreviousJoinOrLeaveNotification(this.content.lastElementChild, nick),
+ dataset = _.get(prev_info_el, 'dataset', {});
- if (last_el && _.includes(_.get(last_el, 'classList', []), 'chat-info') && moment(last_el.getAttribute('data-isodate')).isSame(new Date(), "day") && _.get(last_el, 'dataset', {}).join === "\"".concat(nick, "\"")) {
- var message;
+ if (dataset.join === nick) {
+ let message;
if (_.isNil(stat)) {
message = __('%1$s has entered and left the groupchat', nick);
@@ -42772,48 +49227,48 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
message = __('%1$s has entered and left the groupchat. "%2$s"', nick, stat);
}
- last_el.outerHTML = tpl_info({
- 'data': "data-joinleave=\"".concat(nick, "\""),
+ const data = {
+ 'data_name': 'joinleave',
+ 'data_value': nick,
'isodate': moment().format(),
'extra_classes': 'chat-event',
'message': message
- });
- var el = this.content.lastElementChild;
- setTimeout(function () {
- return u.addClass('fade-out', el);
- }, 5000);
- setTimeout(function () {
- return el.parentElement && el.parentElement.removeChild(el);
- }, 5250);
+ };
+ this.content.removeChild(prev_info_el);
+ this.content.insertAdjacentHTML('beforeend', tpl_info(data));
+ const el = this.content.lastElementChild;
+ setTimeout(() => u.addClass('fade-out', el), 5000);
+ setTimeout(() => el.parentElement && el.parentElement.removeChild(el), 5500);
} else {
- var _message;
+ let message;
if (_.isNil(stat)) {
- _message = __('%1$s has left the groupchat', nick);
+ message = __('%1$s has left the groupchat', nick);
} else {
- _message = __('%1$s has left the groupchat. "%2$s"', nick, stat);
+ message = __('%1$s has left the groupchat. "%2$s"', nick, stat);
}
- var data = {
- 'message': _message,
+ const data = {
+ 'message': message,
'isodate': moment().format(),
'extra_classes': 'chat-event',
- 'data': "data-leave=\"".concat(nick, "\"")
+ 'data_name': 'leave',
+ 'data_value': nick
};
- if (last_el && _.includes(_.get(last_el, 'classList', []), 'chat-info') && _.get(last_el, 'dataset', {}).leavejoin === "\"".concat(nick, "\"")) {
- last_el.outerHTML = tpl_info(data);
+ if (prev_info_el) {
+ this.content.removeChild(prev_info_el);
+ this.content.insertAdjacentHTML('beforeend', tpl_info(data));
} else {
- var _el2 = u.stringToElement(tpl_info(data));
-
- this.content.insertAdjacentElement('beforeend', _el2);
- this.insertDayIndicator(_el2);
+ this.content.insertAdjacentHTML('beforeend', tpl_info(data));
+ this.insertDayIndicator(this.content.lastElementChild);
}
}
this.scrollDown();
},
- showStatusMessages: function showStatusMessages(stanza) {
+
+ showStatusMessages(stanza) {
/* Check for status codes and communicate their purpose to the user.
* See: http://xmpp.org/registrar/mucstatus.html
*
@@ -42821,18 +49276,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (XMLElement) stanza: The message or presence stanza
* containing the status codes.
*/
- var elements = sizzle("x[xmlns=\"".concat(Strophe.NS.MUC_USER, "\"]"), stanza);
- var is_self = stanza.querySelectorAll("status[code='110']").length;
+ const elements = sizzle(`x[xmlns="${Strophe.NS.MUC_USER}"]`, stanza);
+ const is_self = stanza.querySelectorAll("status[code='110']").length;
- var iteratee = _.partial(this.parseXUserElement.bind(this), _, stanza, is_self);
+ const iteratee = _.partial(this.parseXUserElement.bind(this), _, stanza, is_self);
- var notifications = _.reject(_.map(elements, iteratee), _.isEmpty);
+ const notifications = _.reject(_.map(elements, iteratee), _.isEmpty);
_.each(notifications, this.showNotificationsforUser.bind(this));
},
- showErrorMessageFromPresence: function showErrorMessageFromPresence(presence) {
+
+ showErrorMessageFromPresence(presence) {
// We didn't enter the groupchat, so we must remove it from the MUC add-on
- var error = presence.querySelector('error');
+ const error = presence.querySelector('error');
if (error.getAttribute('type') === 'auth') {
if (!_.isNull(error.querySelector('not-authorized'))) {
@@ -42851,6 +49307,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.showDisconnectMessages(__('You are not allowed to create new groupchats.'));
} else if (!_.isNull(error.querySelector('not-acceptable'))) {
this.showDisconnectMessages(__("Your nickname doesn't conform to this groupchat's policies."));
+ } else if (sizzle('gone[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]', error).length) {
+ this.showDestroyedMessage(error);
} else if (!_.isNull(error.querySelector('conflict'))) {
this.onNicknameClash(presence);
} else if (!_.isNull(error.querySelector('item-not-found'))) {
@@ -42858,9 +49316,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} else if (!_.isNull(error.querySelector('service-unavailable'))) {
this.showDisconnectMessages(__("This groupchat has reached its maximum number of participants."));
} else if (!_.isNull(error.querySelector('remote-server-not-found'))) {
- var messages = [__("Remote server not found")];
+ const messages = [__("Remote server not found")];
- var reason = _.get(error.querySelector('text'), 'textContent');
+ const reason = _.get(error.querySelector('text'), 'textContent');
if (reason) {
messages.push(__('The explanation given is: "%1$s".', reason));
@@ -42870,7 +49328,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
},
- renderAfterTransition: function renderAfterTransition() {
+
+ renderAfterTransition() {
/* Rerender the groupchat after some kind of transition. For
* example after the spinner has been removed or after a
* form has been submitted and removed.
@@ -42885,20 +49344,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.scrollDown();
}
},
- showSpinner: function showSpinner() {
+
+ showSpinner() {
u.removeElement(this.el.querySelector('.spinner'));
- var container_el = this.el.querySelector('.chatroom-body');
- var children = Array.prototype.slice.call(container_el.children, 0);
+ const container_el = this.el.querySelector('.chatroom-body');
+ const children = Array.prototype.slice.call(container_el.children, 0);
container_el.insertAdjacentHTML('afterbegin', tpl_spinner());
_.each(children, u.hideElement);
},
- hideSpinner: function hideSpinner() {
+
+ hideSpinner() {
/* Check if the spinner is being shown and if so, hide it.
* Also make sure then that the chat area and occupants
* list are both visible.
*/
- var spinner = this.el.querySelector('.spinner');
+ const spinner = this.el.querySelector('.spinner');
if (!_.isNull(spinner)) {
u.removeElement(spinner);
@@ -42907,15 +49368,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- setChatRoomSubject: function setChatRoomSubject() {
+
+ setChatRoomSubject() {
// For translators: the %1$s and %2$s parts will get
// replaced by the user and topic text respectively
// Example: Topic set by JC Brand to: Hello World!
- var subject = this.model.get('subject'),
- message = subject.text ? __('Topic set by %1$s', subject.author) : __('Topic cleared by %1$s', subject.author),
- date = moment().format();
+ const subject = this.model.get('subject'),
+ message = subject.text ? __('Topic set by %1$s', subject.author) : __('Topic cleared by %1$s', subject.author),
+ date = moment().format();
this.content.insertAdjacentHTML('beforeend', tpl_info({
- 'data': '',
'isodate': date,
'extra_classes': 'chat-event',
'message': message
@@ -42923,15 +49384,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
if (subject.text) {
this.content.insertAdjacentHTML('beforeend', tpl_info({
- 'data': '',
'isodate': date,
'extra_classes': 'chat-topic',
- 'message': subject.text
+ 'message': u.addHyperlinks(xss.filterXSS(_.get(this.model.get('subject'), 'text'), {
+ 'whiteList': {}
+ })),
+ 'render_message': true
}));
}
this.scrollDown();
}
+
});
_converse.RoomsPanel = Backbone.NativeView.extend({
/* Backbone.NativeView which renders MUC section of the control box.
@@ -42943,7 +49407,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click a.chatbox-btn.show-add-muc-modal': 'showAddRoomModal',
'click a.chatbox-btn.show-list-muc-modal': 'showListRoomsModal'
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_room_panel({
'heading_chatrooms': __('Groupchats'),
'title_new_room': __('Add a new groupchat'),
@@ -42951,7 +49416,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
return this;
},
- showAddRoomModal: function showAddRoomModal(ev) {
+
+ showAddRoomModal(ev) {
if (_.isUndefined(this.add_room_modal)) {
this.add_room_modal = new _converse.AddChatRoomModal({
'model': this.model
@@ -42960,7 +49426,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.add_room_modal.show(ev);
},
- showListRoomsModal: function showListRoomsModal(ev) {
+
+ showListRoomsModal(ev) {
if (_.isUndefined(this.list_rooms_modal)) {
this.list_rooms_modal = new _converse.ListChatRoomsModal({
'model': this.model
@@ -42969,14 +49436,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.list_rooms_modal.show(ev);
}
+
});
_converse.ChatRoomOccupantView = Backbone.VDOMView.extend({
tagName: 'li',
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change', this.render, this);
},
- toHTML: function toHTML() {
- var show = this.model.get('show');
+
+ toHTML() {
+ const show = this.model.get('show');
return tpl_occupant(_.extend({
'_': _,
// XXX Normally this should already be included,
@@ -42996,9 +49466,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'label_admin': __('Admin')
}, this.model.toJSON()));
},
- destroy: function destroy() {
+
+ destroy() {
this.el.parentElement.removeChild(this.el);
}
+
});
_converse.ChatRoomOccupantsView = Backbone.OrderedListView.extend({
tagName: 'div',
@@ -43007,7 +49479,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
sortEvent: 'change:role',
listSelector: '.occupant-list',
ItemView: _converse.ChatRoomOccupantView,
- initialize: function initialize() {
+
+ initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.chatroomview = this.model.chatroomview;
this.chatroomview.model.on('change:open', this.renderInviteWidget, this);
@@ -43032,7 +49505,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'success': this.sortAndPositionAllItems.bind(this)
});
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_chatroom_sidebar(_.extend(this.chatroomview.model.toJSON(), {
'allow_muc_invitations': _converse.allow_muc_invitations,
'label_occupants': __('Participants')
@@ -43044,12 +49518,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.renderRoomFeatures();
},
- renderInviteWidget: function renderInviteWidget() {
- var form = this.el.querySelector('form.room-invite');
+
+ renderInviteWidget() {
+ const form = this.el.querySelector('form.room-invite');
if (this.shouldInviteWidgetBeShown()) {
if (_.isNull(form)) {
- var heading = this.el.querySelector('.occupants-heading');
+ const heading = this.el.querySelector('.occupants-heading');
heading.insertAdjacentHTML('afterend', tpl_chatroom_invite({
'error_message': null,
'label_invitation': __('Invite')
@@ -43062,12 +49537,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- renderRoomFeatures: function renderRoomFeatures() {
- var picks = _.pick(this.chatroomview.model.attributes, converse.ROOM_FEATURES),
- iteratee = function iteratee(a, v) {
- return a || v;
- },
- el = this.el.querySelector('.chatroom-features');
+
+ renderRoomFeatures() {
+ const picks = _.pick(this.chatroomview.model.attributes, converse.ROOM_FEATURES),
+ iteratee = (a, v) => a || v,
+ el = this.el.querySelector('.chatroom-features');
el.innerHTML = tpl_chatroom_features(_.extend(this.chatroomview.model.toJSON(), {
'__': __,
@@ -43076,7 +49550,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setOccupantsHeight();
return this;
},
- onFeatureChanged: function onFeatureChanged(model) {
+
+ onFeatureChanged(model) {
/* When a feature has been changed, it's logical opposite
* must be set to the opposite value.
*
@@ -43092,7 +49567,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
- var changed_features = {};
+ const changed_features = {};
_.each(_.keys(model.changed), function (k) {
if (!_.isNil(ROOM_FEATURES_MAP[k])) {
@@ -43105,19 +49580,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
this.debouncedRenderRoomFeatures();
},
- setOccupantsHeight: function setOccupantsHeight() {
- var el = this.el.querySelector('.chatroom-features');
- this.el.querySelector('.occupant-list').style.cssText = "height: calc(100% - ".concat(el.offsetHeight, "px - 5em);");
+
+ setOccupantsHeight() {
+ const el = this.el.querySelector('.chatroom-features');
+ this.el.querySelector('.occupant-list').style.cssText = `height: calc(100% - ${el.offsetHeight}px - 5em);`;
},
- promptForInvite: function promptForInvite(suggestion) {
- var reason = prompt(__('You are about to invite %1$s to the groupchat "%2$s". ' + 'You may optionally include a message, explaining the reason for the invitation.', suggestion.text.label, this.model.get('id')));
+
+ promptForInvite(suggestion) {
+ const reason = prompt(__('You are about to invite %1$s to the groupchat "%2$s". ' + 'You may optionally include a message, explaining the reason for the invitation.', suggestion.text.label, this.model.get('id')));
if (reason !== null) {
this.chatroomview.model.directInvite(suggestion.text.value, reason);
}
- var form = suggestion.target.form,
- error = form.querySelector('.pure-form-message.error');
+ const form = suggestion.target.form,
+ error = form.querySelector('.pure-form-message.error');
if (!_.isNull(error)) {
error.parentNode.removeChild(error);
@@ -43125,10 +49602,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
suggestion.target.value = '';
},
- inviteFormSubmitted: function inviteFormSubmitted(evt) {
+
+ inviteFormSubmitted(evt) {
evt.preventDefault();
- var el = evt.target.querySelector('input.invited-contact'),
- jid = el.value;
+ const el = evt.target.querySelector('input.invited-contact'),
+ jid = el.value;
if (!jid || _.compact(jid.split('@')).length < 2) {
evt.target.outerHTML = tpl_chatroom_invite({
@@ -43147,33 +49625,36 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
});
},
- shouldInviteWidgetBeShown: function shouldInviteWidgetBeShown() {
+
+ shouldInviteWidgetBeShown() {
return _converse.allow_muc_invitations && (this.chatroomview.model.get('open') || this.chatroomview.model.get('affiliation') === "owner");
},
- initInviteWidget: function initInviteWidget() {
- var form = this.el.querySelector('form.room-invite');
+
+ initInviteWidget() {
+ const form = this.el.querySelector('form.room-invite');
if (_.isNull(form)) {
return;
}
form.addEventListener('submit', this.inviteFormSubmitted.bind(this), false);
- var el = this.el.querySelector('input.invited-contact');
+ const el = this.el.querySelector('input.invited-contact');
- var list = _converse.roster.map(function (item) {
- var label = item.get('fullname') || item.get('jid');
+ const list = _converse.roster.map(function (item) {
+ const label = item.get('fullname') || item.get('jid');
return {
'label': label,
'value': item.get('jid')
};
});
- var awesomplete = new Awesomplete(el, {
+ const awesomplete = new Awesomplete(el, {
'minChars': 1,
'list': list
});
el.addEventListener('awesomplete-selectcomplete', this.promptForInvite.bind(this));
}
+
});
function setMUCDomain(domain, controlboxview) {
@@ -43192,7 +49673,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
if (feature.get('var') === Strophe.NS.MUC) {
- feature.entity.getIdentity('conference', 'text').then(function (identity) {
+ feature.entity.getIdentity('conference', 'text').then(identity => {
if (identity) {
setMUCDomain(feature.get('from'), controlboxview);
}
@@ -43200,16 +49681,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
- _converse.api.waitUntil('discoInitialized').then(function () {
+ _converse.api.waitUntil('discoInitialized').then(() => {
_converse.api.listen.on('serviceDiscovered', featureAdded); // Features could have been added before the controlbox was
// initialized. We're only interested in MUC
- _converse.disco_entities.each(function (entity) {
- return featureAdded(entity.features.findWhere({
- 'var': Strophe.NS.MUC
- }));
- });
+ _converse.disco_entities.each(entity => featureAdded(entity.features.findWhere({
+ 'var': Strophe.NS.MUC
+ })));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
}
@@ -43227,10 +49706,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/************************ BEGIN Event Handlers ************************/
- _converse.on('chatBoxViewsInitialized', function () {
- var that = _converse.chatboxviews;
+ _converse.on('chatBoxViewsInitialized', () => {
+ function openChatRoomFromURIClicked(ev) {
+ ev.preventDefault();
- _converse.chatboxes.on('add', function (item) {
+ _converse.api.rooms.open(ev.target.href);
+ }
+
+ _converse.chatboxviews.delegate('click', 'a.open-chatroom', openChatRoomFromURIClicked);
+
+ const that = _converse.chatboxviews;
+
+ _converse.chatboxes.on('add', item => {
if (!that.get(item.get('id')) && item.get('type') === _converse.CHATROOMS_TYPE) {
return that.add(item.get('id'), new _converse.ChatRoomView({
'model': item
@@ -43239,7 +49726,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
- _converse.on('controlboxInitialized', function (view) {
+ _converse.on('controlboxInitialized', view => {
if (!_converse.allow_muc) {
return;
}
@@ -43286,7 +49773,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* @method _converse.api.roomviews.close
* @param {(String[]|String)} jids The JID or array of JIDs of the chatroom(s)
*/
- 'close': function close(jids) {
+ 'close'(jids) {
if (_.isUndefined(jids)) {
_converse.chatboxviews.each(function (view) {
if (view.is_chatroom && view.model) {
@@ -43294,14 +49781,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
});
} else if (_.isString(jids)) {
- var view = _converse.chatboxviews.get(jids);
+ const view = _converse.chatboxviews.get(jids);
if (view) {
view.close();
}
} else {
_.each(jids, function (jid) {
- var view = _converse.chatboxviews.get(jid);
+ const view = _converse.chatboxviews.get(jid);
if (view) {
view.close();
@@ -43309,9 +49796,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
}
+
}
});
}
+
});
});
@@ -43324,12 +49813,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
-
-function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
@@ -43347,28 +49831,28 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (u, converse) {
+})(this, function (u, converse) {
"use strict";
- var MUC_ROLE_WEIGHTS = {
+ const MUC_ROLE_WEIGHTS = {
'moderator': 1,
'participant': 2,
'visitor': 3,
'none': 2
};
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- $iq = _converse$env.$iq,
- $build = _converse$env.$build,
- $msg = _converse$env.$msg,
- $pres = _converse$env.$pres,
- b64_sha1 = _converse$env.b64_sha1,
- sizzle = _converse$env.sizzle,
- f = _converse$env.f,
- moment = _converse$env.moment,
- _ = _converse$env._; // Add Strophe Namespaces
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ $iq = _converse$env.$iq,
+ $build = _converse$env.$build,
+ $msg = _converse$env.$msg,
+ $pres = _converse$env.$pres,
+ b64_sha1 = _converse$env.b64_sha1,
+ sizzle = _converse$env.sizzle,
+ f = _converse$env.f,
+ moment = _converse$env.moment,
+ _ = _converse$env._; // Add Strophe Namespaces
Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin");
Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner");
@@ -43400,23 +49884,22 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
*/
dependencies: ["converse-chatboxes", "converse-disco", "converse-controlbox"],
overrides: {
- tearDown: function tearDown() {
- var _converse = this.__super__._converse,
- groupchats = this.chatboxes.where({
+ tearDown() {
+ const _converse = this.__super__._converse,
+ groupchats = this.chatboxes.where({
'type': _converse.CHATROOMS_TYPE
});
- _.each(groupchats, function (gc) {
- return u.safeSave(gc, {
- 'connection_status': converse.ROOMSTATUS.DISCONNECTED
- });
- });
+ _.each(groupchats, gc => u.safeSave(gc, {
+ 'connection_status': converse.ROOMSTATUS.DISCONNECTED
+ }));
this.__super__.tearDown.call(this, arguments);
},
+
ChatBoxes: {
- model: function model(attrs, options) {
- var _converse = this.__super__._converse;
+ model(attrs, options) {
+ const _converse = this.__super__._converse;
if (attrs.type == _converse.CHATROOMS_TYPE) {
return new _converse.ChatRoom(attrs, options);
@@ -43424,14 +49907,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return this.__super__.model.apply(this, arguments);
}
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__; // Configuration values for this plugin
+ const _converse = this._converse,
+ __ = _converse.__; // Configuration values for this plugin
// ====================================
// Refer to docs/source/configuration.rst for explanations of these
// configuration settings.
@@ -43452,16 +49937,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function openRoom(jid) {
if (!u.isValidMUCJID(jid)) {
- return _converse.log("Invalid JID \"".concat(jid, "\" provided in URL fragment"), Strophe.LogLevel.WARN);
+ return _converse.log(`Invalid JID "${jid}" provided in URL fragment`, Strophe.LogLevel.WARN);
}
- var promises = [_converse.api.waitUntil('roomsAutoJoined')];
+ const promises = [_converse.api.waitUntil('roomsAutoJoined')];
if (_converse.allow_bookmarks) {
promises.push(_converse.api.waitUntil('bookmarksInitialized'));
}
- Promise.all(promises).then(function () {
+ Promise.all(promises).then(() => {
_converse.api.rooms.open(jid);
});
}
@@ -43477,14 +49962,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
settings.id = jid;
settings.box_id = b64_sha1(jid);
- var chatbox = _converse.chatboxes.getChatBox(jid, settings, true);
+ const chatbox = _converse.chatboxes.getChatBox(jid, settings, true);
chatbox.trigger('show', true);
return chatbox;
};
_converse.ChatRoom = _converse.ChatBox.extend({
- defaults: function defaults() {
+ defaults() {
return _.assign(_.clone(_converse.ChatBox.prototype.defaults), _.zipObject(converse.ROOM_FEATURES, _.map(converse.ROOM_FEATURES, _.stubFalse)), {
// For group chats, we distinguish between generally unread
// messages and those ones that specifically mention the
@@ -43506,57 +49991,53 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
'message_type': 'groupchat'
});
},
- initialize: function initialize() {
+
+ initialize() {
this.constructor.__super__.initialize.apply(this, arguments);
this.on('change:connection_status', this.onConnectionStatusChanged, this);
this.occupants = new _converse.ChatRoomOccupants();
- this.occupants.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.occupants-".concat(_converse.bare_jid).concat(this.get('jid'))));
+ this.occupants.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.occupants-${_converse.bare_jid}${this.get('jid')}`));
this.occupants.chatroom = this;
this.registerHandlers();
},
- onConnectionStatusChanged: async function onConnectionStatusChanged() {
+
+ async onConnectionStatusChanged() {
if (this.get('connection_status') === converse.ROOMSTATUS.ENTERED && _converse.auto_register_muc_nickname && !this.get('reserved_nick')) {
- var result = await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'));
+ const result = await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'));
if (result.length) {
this.registerNickname();
}
}
},
- registerHandlers: function registerHandlers() {
- var _this = this;
+ registerHandlers() {
/* Register presence and message handlers for this chat
* groupchat
*/
- var room_jid = this.get('jid');
+ const room_jid = this.get('jid');
this.removeHandlers();
- this.presence_handler = _converse.connection.addHandler(function (stanza) {
- _.each(_.values(_this.handlers.presence), function (callback) {
- return callback(stanza);
- });
-
- _this.onPresence(stanza);
+ this.presence_handler = _converse.connection.addHandler(stanza => {
+ _.each(_.values(this.handlers.presence), callback => callback(stanza));
+ this.onPresence(stanza);
return true;
}, null, 'presence', null, null, room_jid, {
'ignoreNamespaceFragment': true,
'matchBareFromJid': true
});
- this.message_handler = _converse.connection.addHandler(function (stanza) {
- _.each(_.values(_this.handlers.message), function (callback) {
- return callback(stanza);
- });
-
- _this.onMessage(stanza);
+ this.message_handler = _converse.connection.addHandler(stanza => {
+ _.each(_.values(this.handlers.message), callback => callback(stanza));
+ this.onMessage(stanza);
return true;
}, null, 'message', 'groupchat', null, room_jid, {
'matchBareFromJid': true
});
},
- removeHandlers: function removeHandlers() {
+
+ removeHandlers() {
/* Remove the presence and message handlers that were
* registered for this groupchat.
*/
@@ -43574,7 +50055,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return this;
},
- addHandler: function addHandler(type, name, callback) {
+
+ addHandler(type, name, callback) {
/* Allows 'presence' and 'message' handlers to be
* registered. These will be executed once presence or
* message stanzas are received, and *before* this model's
@@ -43590,10 +50072,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
this.handlers[type][name] = callback;
},
- getDisplayName: function getDisplayName() {
+
+ getDisplayName() {
return this.get('name') || this.get('jid');
},
- join: function join(nick, password) {
+
+ join(nick, password) {
/* Join the groupchat.
*
* Parameters:
@@ -43613,7 +50097,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return this;
}
- var stanza = $pres({
+ const stanza = $pres({
'from': _converse.connection.jid,
'to': this.getRoomJIDAndNick(nick)
}).c("x", {
@@ -43632,7 +50116,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return this;
},
- leave: function leave(exit_msg) {
+
+ leave(exit_msg) {
/* Leave the groupchat.
*
* Parameters:
@@ -43643,7 +50128,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
this.occupants.reset();
- var disco_entity = _converse.disco_entities.get(this.get('jid'));
+ const disco_entity = _converse.disco_entities.get(this.get('jid'));
if (disco_entity) {
disco_entity.destroy();
@@ -43658,8 +50143,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
});
this.removeHandlers();
},
- sendUnavailablePresence: function sendUnavailablePresence(exit_msg) {
- var presence = $pres({
+
+ sendUnavailablePresence(exit_msg) {
+ const presence = $pres({
type: "unavailable",
from: _converse.connection.jid,
to: this.getRoomJIDAndNick()
@@ -43671,10 +50157,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
_converse.connection.sendPresence(presence);
},
- getReferenceForMention: function getReferenceForMention(mention, index) {
- var longest_match = u.getLongestSubstring(mention, this.occupants.map(function (o) {
- return o.getDisplayName();
- }));
+
+ getReferenceForMention(mention, index) {
+ const longest_match = u.getLongestSubstring(mention, this.occupants.map(o => o.getDisplayName()));
if (!longest_match) {
return null;
@@ -43687,7 +50172,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return null;
}
- var occupant = this.occupants.findOccupant({
+ const occupant = this.occupants.findOccupant({
'nick': longest_match
}) || this.occupants.findOccupant({
'jid': longest_match
@@ -43697,7 +50182,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return null;
}
- var obj = {
+ const obj = {
'begin': index,
'end': index + longest_match.length,
'value': longest_match,
@@ -43705,18 +50190,19 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
};
if (occupant.get('jid')) {
- obj.uri = "xmpp:".concat(occupant.get('jid'));
+ obj.uri = `xmpp:${occupant.get('jid')}`;
}
return obj;
},
- extractReference: function extractReference(text, index) {
- for (var i = index; i < text.length; i++) {
+
+ extractReference(text, index) {
+ for (let i = index; i < text.length; i++) {
if (text[i] !== '@') {
continue;
} else {
- var match = text.slice(i + 1),
- ref = this.getReferenceForMention(match, i);
+ const match = text.slice(i + 1),
+ ref = this.getReferenceForMention(match, i);
if (ref) {
return [text.slice(0, i) + match, ref, i];
@@ -43726,12 +50212,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return;
},
- parseTextForReferences: function parseTextForReferences(text) {
- var refs = [];
- var index = 0;
+
+ parseTextForReferences(text) {
+ const refs = [];
+ let index = 0;
while (index < (text || '').length) {
- var result = this.extractReference(text, index);
+ const result = this.extractReference(text, index);
if (result) {
text = result[0]; // @ gets filtered out
@@ -43745,8 +50232,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return [text, refs];
},
- getOutgoingMessageAttributes: function getOutgoingMessageAttributes(text, spoiler_hint) {
- var is_spoiler = this.get('composing_spoiler');
+
+ getOutgoingMessageAttributes(text, spoiler_hint) {
+ const is_spoiler = this.get('composing_spoiler');
var references;
var _this$parseTextForRef = this.parseTextForReferences(text);
@@ -43756,7 +50244,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
text = _this$parseTextForRef2[0];
references = _this$parseTextForRef2[1];
return {
- 'from': "".concat(this.get('jid'), "/").concat(this.get('nick')),
+ 'from': `${this.get('jid')}/${this.get('nick')}`,
'fullname': this.get('nick'),
'is_spoiler': is_spoiler,
'message': text ? u.httpToGeoUri(u.shortnameToUnicode(text), _converse) : undefined,
@@ -43767,7 +50255,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
'type': 'groupchat'
};
},
- getRoomJIDAndNick: function getRoomJIDAndNick(nick) {
+
+ getRoomJIDAndNick(nick) {
/* Utility method to construct the JID for the current user
* as occupant of the groupchat.
*
@@ -43784,11 +50273,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
nick = this.get('nick');
}
- var groupchat = this.get('jid');
- var jid = Strophe.getBareJidFromJid(groupchat);
- return jid + (nick !== null ? "/".concat(nick) : "");
+ const groupchat = this.get('jid');
+ const jid = Strophe.getBareJidFromJid(groupchat);
+ return jid + (nick !== null ? `/${nick}` : "");
},
- sendChatState: function sendChatState() {
+
+ sendChatState() {
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
* See XEP-0085 Chat State Notifications.
@@ -43797,7 +50287,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return;
}
- var chat_state = this.get('chat_state');
+ const chat_state = this.get('chat_state');
if (chat_state === _converse.GONE) {
// is not applicable within MUC context
@@ -43815,7 +50305,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
'xmlns': Strophe.NS.HINTS
}));
},
- directInvite: function directInvite(recipient, reason) {
+
+ directInvite(recipient, reason) {
/* Send a direct invitation as per XEP-0249
*
* Parameters:
@@ -43827,10 +50318,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
// the person to the member list by giving them an
// affiliation of 'member' (if they're not affiliated
// already), otherwise they won't be able to join.
- var map = {};
+ const map = {};
map[recipient] = 'member';
- var deltaFunc = _.partial(u.computeAffiliationsDelta, true, false);
+ const deltaFunc = _.partial(u.computeAffiliationsDelta, true, false);
this.updateMemberLists([{
'jid': recipient,
@@ -43839,7 +50330,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}], ['member', 'owner', 'admin'], deltaFunc);
}
- var attrs = {
+ const attrs = {
'xmlns': 'jabber:x:conference',
'jid': this.get('jid')
};
@@ -43852,7 +50343,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
attrs.password = this.get('password');
}
- var invitation = $msg({
+ const invitation = $msg({
from: _converse.connection.jid,
to: recipient,
id: _converse.connection.getUniqueId()
@@ -43866,20 +50357,22 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
'reason': reason
});
},
- refreshRoomFeatures: async function refreshRoomFeatures() {
+
+ async refreshRoomFeatures() {
await _converse.api.disco.refreshFeatures(this.get('jid'));
return this.getRoomFeatures();
},
- getRoomFeatures: async function getRoomFeatures() {
- var features = await _converse.api.disco.getFeatures(this.get('jid')),
- fields = await _converse.api.disco.getFields(this.get('jid')),
- identity = await _converse.api.disco.getIdentity('conference', 'text', this.get('jid')),
- attrs = {
+
+ async getRoomFeatures() {
+ const features = await _converse.api.disco.getFeatures(this.get('jid')),
+ fields = await _converse.api.disco.getFields(this.get('jid')),
+ identity = await _converse.api.disco.getIdentity('conference', 'text', this.get('jid')),
+ attrs = {
'features_fetched': moment().format(),
'name': identity && identity.get('name')
};
- features.each(function (feature) {
- var fieldname = feature.get('var');
+ features.each(feature => {
+ const fieldname = feature.get('var');
if (!fieldname.startsWith('muc_')) {
if (fieldname === Strophe.NS.MAM) {
@@ -43896,7 +50389,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}), 'attributes.value');
this.save(attrs);
},
- requestMemberList: function requestMemberList(affiliation) {
+
+ requestMemberList(affiliation) {
/* Send an IQ stanza to the server, asking it for the
* member-list of this groupchat.
*
@@ -43911,7 +50405,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* retrieved.
*/
affiliation = affiliation || 'member';
- var iq = $iq({
+ const iq = $iq({
to: this.get('jid'),
type: "get"
}).c("query", {
@@ -43921,7 +50415,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
});
return _converse.api.sendIQ(iq);
},
- setAffiliation: function setAffiliation(affiliation, members) {
+
+ setAffiliation(affiliation, members) {
/* Send IQ stanzas to the server to set an affiliation for
* the provided JIDs.
*
@@ -43943,20 +50438,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* A promise which resolves and fails depending on the
* XMPP server response.
*/
- members = _.filter(members, function (member) {
- return (// We only want those members who have the right
- // affiliation (or none, which implies the provided one).
- _.isUndefined(member.affiliation) || member.affiliation === affiliation
- );
- });
+ members = _.filter(members, member => // We only want those members who have the right
+ // affiliation (or none, which implies the provided one).
+ _.isUndefined(member.affiliation) || member.affiliation === affiliation);
- var promises = _.map(members, _.bind(this.sendAffiliationIQ, this, affiliation));
+ const promises = _.map(members, _.bind(this.sendAffiliationIQ, this, affiliation));
return Promise.all(promises);
},
- saveConfiguration: function saveConfiguration(form) {
- var _this2 = this;
+ saveConfiguration(form) {
/* Submit the groupchat configuration form by sending an IQ
* stanza to the server.
*
@@ -43968,34 +50459,32 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* If no form is provided, the default configuration
* values will be used.
*/
- return new Promise(function (resolve, reject) {
- var inputs = form ? sizzle(':input:not([type=button]):not([type=submit])', form) : [],
- configArray = _.map(inputs, u.webForm2xForm);
+ return new Promise((resolve, reject) => {
+ const inputs = form ? sizzle(':input:not([type=button]):not([type=submit])', form) : [],
+ configArray = _.map(inputs, u.webForm2xForm);
- _this2.sendConfiguration(configArray, resolve, reject);
+ this.sendConfiguration(configArray, resolve, reject);
});
},
- autoConfigureChatRoom: function autoConfigureChatRoom() {
- var _this3 = this;
+ autoConfigureChatRoom() {
/* Automatically configure groupchat based on this model's
* 'roomconfig' data.
*
* Returns a promise which resolves once a response IQ has
* been received.
*/
- return new Promise(function (resolve, reject) {
- _this3.fetchRoomConfiguration().then(function (stanza) {
- var configArray = [],
- fields = stanza.querySelectorAll('field'),
- config = _this3.get('roomconfig');
+ return new Promise((resolve, reject) => {
+ this.fetchRoomConfiguration().then(stanza => {
+ const configArray = [],
+ fields = stanza.querySelectorAll('field'),
+ config = this.get('roomconfig');
+ let count = fields.length;
- var count = fields.length;
-
- _.each(fields, function (field) {
- var fieldname = field.getAttribute('var').replace('muc#roomconfig_', ''),
- type = field.getAttribute('type');
- var value;
+ _.each(fields, field => {
+ const fieldname = field.getAttribute('var').replace('muc#roomconfig_', ''),
+ type = field.getAttribute('type');
+ let value;
if (fieldname in config) {
switch (type) {
@@ -44018,29 +50507,29 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
configArray.push(field);
if (! --count) {
- _this3.sendConfiguration(configArray, resolve, reject);
+ this.sendConfiguration(configArray, resolve, reject);
}
});
});
});
},
- fetchRoomConfiguration: function fetchRoomConfiguration() {
- var _this4 = this;
+ fetchRoomConfiguration() {
/* Send an IQ stanza to fetch the groupchat configuration data.
* Returns a promise which resolves once the response IQ
* has been received.
*/
- return new Promise(function (resolve, reject) {
+ return new Promise((resolve, reject) => {
_converse.connection.sendIQ($iq({
- 'to': _this4.get('jid'),
+ 'to': this.get('jid'),
'type': "get"
}).c("query", {
xmlns: Strophe.NS.MUC_OWNER
}), resolve, reject);
});
},
- sendConfiguration: function sendConfiguration(config, callback, errback) {
+
+ sendConfiguration(config, callback, errback) {
/* Send an IQ stanza with the groupchat configuration.
*
* Parameters:
@@ -44054,7 +50543,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* groupchat configuration.
* The second is the response IQ from the server.
*/
- var iq = $iq({
+ const iq = $iq({
to: this.get('jid'),
type: "set"
}).c("query", {
@@ -44072,19 +50561,20 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
errback = _.isUndefined(errback) ? _.noop : _.partial(errback, iq.nodeTree);
return _converse.connection.sendIQ(iq, callback, errback);
},
- saveAffiliationAndRole: function saveAffiliationAndRole(pres) {
+
+ saveAffiliationAndRole(pres) {
/* Parse the presence stanza for the current user's
* affiliation.
*
* Parameters:
* (XMLElement) pres: A stanza.
*/
- var item = sizzle("x[xmlns=\"".concat(Strophe.NS.MUC_USER, "\"] item"), pres).pop();
- var is_self = pres.querySelector("status[code='110']");
+ const item = sizzle(`x[xmlns="${Strophe.NS.MUC_USER}"] item`, pres).pop();
+ const is_self = pres.querySelector("status[code='110']");
if (is_self && !_.isNil(item)) {
- var affiliation = item.getAttribute('affiliation');
- var role = item.getAttribute('role');
+ const affiliation = item.getAttribute('affiliation');
+ const role = item.getAttribute('role');
if (affiliation) {
this.save({
@@ -44099,9 +50589,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}
}
},
- sendAffiliationIQ: function sendAffiliationIQ(affiliation, member) {
- var _this5 = this;
+ sendAffiliationIQ(affiliation, member) {
/* Send an IQ stanza specifying an affiliation change.
*
* Paremeters:
@@ -44110,9 +50599,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* (Object) member: Map containing the member's jid and
* optionally a reason and affiliation.
*/
- return new Promise(function (resolve, reject) {
- var iq = $iq({
- to: _this5.get('jid'),
+ return new Promise((resolve, reject) => {
+ const iq = $iq({
+ to: this.get('jid'),
type: "set"
}).c("query", {
xmlns: Strophe.NS.MUC_ADMIN
@@ -44129,7 +50618,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
_converse.connection.sendIQ(iq, resolve, reject);
});
},
- setAffiliations: function setAffiliations(members) {
+
+ setAffiliations(members) {
/* Send IQ stanzas to the server to modify the
* affiliations in this groupchat.
*
@@ -44140,13 +50630,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* (Function) onSuccess: callback for a succesful response
* (Function) onError: callback for an error response
*/
- var affiliations = _.uniq(_.map(members, 'affiliation'));
+ const affiliations = _.uniq(_.map(members, 'affiliation'));
return Promise.all(_.map(affiliations, _.partial(this.setAffiliation.bind(this), _, members)));
},
- getJidsWithAffiliations: async function getJidsWithAffiliations(affiliations) {
- var _this6 = this;
+ async getJidsWithAffiliations(affiliations) {
/* Returns a map of JIDs that have the affiliations
* as provided.
*/
@@ -44154,20 +50643,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
affiliations = [affiliations];
}
- var result = await Promise.all(affiliations.map(function (a) {
- return _this6.requestMemberList(a).then(function (iq) {
- return u.parseMemberListIQ(iq);
- }).catch(function (iq) {
- _converse.log(iq, Strophe.LogLevel.ERROR);
- });
- }));
- return [].concat.apply([], result).filter(function (p) {
- return p;
- });
+ const result = await Promise.all(affiliations.map(a => this.requestMemberList(a).then(iq => u.parseMemberListIQ(iq)).catch(iq => {
+ _converse.log(iq, Strophe.LogLevel.ERROR);
+ })));
+ return [].concat.apply([], result).filter(p => p);
},
- updateMemberLists: function updateMemberLists(members, affiliations, deltaFunc) {
- var _this7 = this;
+ updateMemberLists(members, affiliations, deltaFunc) {
/* Fetch the lists of users with the given affiliations.
* Then compute the delta between those users and
* the passed in members, and if it exists, send the delta
@@ -44185,19 +50667,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* updated or once it's been established there's no need
* to update the list.
*/
- this.getJidsWithAffiliations(affiliations).then(function (old_members) {
- return _this7.setAffiliations(deltaFunc(members, old_members));
- }).then(function () {
- return _this7.occupants.fetchMembers();
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
+ this.getJidsWithAffiliations(affiliations).then(old_members => this.setAffiliations(deltaFunc(members, old_members))).then(() => this.occupants.fetchMembers()).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
},
- getDefaultNick: function getDefaultNick() {
+
+ getDefaultNick() {
/* The default nickname (used when muc_nickname_from_jid is true)
* is the node part of the user's JID.
* We put this in a separate method so that it can be
* overridden by plugins.
*/
- var nick = _converse.xmppstatus.vcard.get('nickname');
+ const nick = _converse.xmppstatus.vcard.get('nickname');
if (nick) {
return nick;
@@ -44205,9 +50684,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return Strophe.unescapeNode(Strophe.getNodeFromJid(_converse.bare_jid));
}
},
- checkForReservedNick: function checkForReservedNick() {
- var _this8 = this;
+ checkForReservedNick() {
/* Use service-discovery to ask the XMPP server whether
* this user has a reserved nickname for this groupchat.
* If so, we'll use that, otherwise we render the nickname form.
@@ -44223,25 +50701,24 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}).c("query", {
'xmlns': Strophe.NS.DISCO_INFO,
'node': 'x-roomuser-item'
- })).then(function (iq) {
- var identity_el = iq.querySelector('query[node="x-roomuser-item"] identity'),
- nick = identity_el ? identity_el.getAttribute('name') : null;
-
- _this8.save({
+ })).then(iq => {
+ const identity_el = iq.querySelector('query[node="x-roomuser-item"] identity'),
+ nick = identity_el ? identity_el.getAttribute('name') : null;
+ this.save({
'reserved_nick': nick,
'nick': nick
}, {
'silent': true
});
-
return iq;
});
},
- registerNickname: async function registerNickname() {
+
+ async registerNickname() {
// See https://xmpp.org/extensions/xep-0045.html#register
- var nick = this.get('nick'),
- jid = this.get('jid');
- var iq, err_msg;
+ const nick = this.get('nick'),
+ jid = this.get('jid');
+ let iq, err_msg;
try {
iq = await _converse.api.sendIQ($iq({
@@ -44263,12 +50740,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return err_msg;
}
- var required_fields = sizzle('field required', iq).map(function (f) {
- return f.parentElement;
- });
+ const required_fields = sizzle('field required', iq).map(f => f.parentElement);
if (required_fields.length > 1 && required_fields[0].getAttribute('var') !== 'muc#register_roomnick') {
- return _converse.log("Can't register the user register in the groupchat ".concat(jid, " due to the required fields"));
+ return _converse.log(`Can't register the user register in the groupchat ${jid} due to the required fields`);
}
try {
@@ -44300,20 +50775,21 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return err_msg;
}
},
- updateOccupantsOnPresence: function updateOccupantsOnPresence(pres) {
+
+ updateOccupantsOnPresence(pres) {
/* Given a presence stanza, update the occupant model
* based on its contents.
*
* Parameters:
* (XMLElement) pres: The presence stanza
*/
- var data = this.parsePresence(pres);
+ const data = this.parsePresence(pres);
if (data.type === 'error' || !data.jid && !data.nick) {
return true;
}
- var occupant = this.occupants.findOccupant(data);
+ const occupant = this.occupants.findOccupant(data);
if (data.type === 'unavailable' && occupant) {
if (!_.includes(data.states, converse.MUC_NICK_CHANGED_CODE) && !occupant.isMember()) {
@@ -44327,9 +50803,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}
}
- var jid = Strophe.getBareJidFromJid(data.jid);
+ const jid = Strophe.getBareJidFromJid(data.jid);
- var attributes = _.extend(data, {
+ const attributes = _.extend(data, {
'jid': jid ? jid : undefined,
'resource': data.jid ? Strophe.getResourceFromJid(data.jid) : undefined
});
@@ -44340,10 +50816,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
this.occupants.create(attributes);
}
},
- parsePresence: function parsePresence(pres) {
- var from = pres.getAttribute("from"),
- type = pres.getAttribute("type"),
- data = {
+
+ parsePresence(pres) {
+ const from = pres.getAttribute("from"),
+ type = pres.getAttribute("type"),
+ data = {
'from': from,
'nick': Strophe.getResourceFromJid(from),
'type': type,
@@ -44388,9 +50865,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return data;
},
- isDuplicate: function isDuplicate(message, original_stanza) {
- var msgid = message.getAttribute('id'),
- jid = message.getAttribute('from');
+
+ isDuplicate(message, original_stanza) {
+ const msgid = message.getAttribute('id'),
+ jid = message.getAttribute('from');
if (msgid) {
return this.messages.where({
@@ -44401,29 +50879,29 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return false;
},
- fetchFeaturesIfConfigurationChanged: function fetchFeaturesIfConfigurationChanged(stanza) {
- var configuration_changed = stanza.querySelector("status[code='104']"),
- logging_enabled = stanza.querySelector("status[code='170']"),
- logging_disabled = stanza.querySelector("status[code='171']"),
- room_no_longer_anon = stanza.querySelector("status[code='172']"),
- room_now_semi_anon = stanza.querySelector("status[code='173']"),
- room_now_fully_anon = stanza.querySelector("status[code='173']");
+
+ fetchFeaturesIfConfigurationChanged(stanza) {
+ const configuration_changed = stanza.querySelector("status[code='104']"),
+ logging_enabled = stanza.querySelector("status[code='170']"),
+ logging_disabled = stanza.querySelector("status[code='171']"),
+ room_no_longer_anon = stanza.querySelector("status[code='172']"),
+ room_now_semi_anon = stanza.querySelector("status[code='173']"),
+ room_now_fully_anon = stanza.querySelector("status[code='173']");
if (configuration_changed || logging_enabled || logging_disabled || room_no_longer_anon || room_now_semi_anon || room_now_fully_anon) {
this.refreshRoomFeatures();
}
},
- onMessage: function onMessage(stanza) {
- var _this9 = this;
+ onMessage(stanza) {
/* Handler for all MUC messages sent to this groupchat.
*
* Parameters:
* (XMLElement) stanza: The message stanza.
*/
this.fetchFeaturesIfConfigurationChanged(stanza);
- var original_stanza = stanza,
- forwarded = stanza.querySelector('forwarded');
+ const original_stanza = stanza,
+ forwarded = stanza.querySelector('forwarded');
if (!_.isNull(forwarded)) {
stanza = forwarded.querySelector('message');
@@ -44433,19 +50911,19 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return;
}
- var jid = stanza.getAttribute('from'),
- resource = Strophe.getResourceFromJid(jid),
- sender = resource && Strophe.unescapeNode(resource) || '';
+ const jid = stanza.getAttribute('from'),
+ resource = Strophe.getResourceFromJid(jid),
+ sender = resource && Strophe.unescapeNode(resource) || '';
if (!this.handleMessageCorrection(stanza)) {
if (sender === '') {
return;
}
- var subject_el = stanza.querySelector('subject');
+ const subject_el = stanza.querySelector('subject');
if (subject_el) {
- var subject = _.propertyOf(subject_el)('textContent') || '';
+ const subject = _.propertyOf(subject_el)('textContent') || '';
u.safeSave(this, {
'subject': {
'author': sender,
@@ -44454,9 +50932,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
});
}
- this.createMessage(stanza, original_stanza).then(function (msg) {
- return _this9.incrementUnreadMsgCounter(msg);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ this.createMessage(stanza, original_stanza).then(msg => this.incrementUnreadMsgCounter(msg)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
if (sender !== this.get('nick')) {
@@ -44467,7 +50943,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
});
}
},
- onPresence: function onPresence(pres) {
+
+ onPresence(pres) {
/* Handles all MUC presence stanzas.
*
* Parameters:
@@ -44478,7 +50955,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return;
}
- var is_self = pres.querySelector("status[code='110']");
+ const is_self = pres.querySelector("status[code='110']");
if (is_self && pres.getAttribute('type') !== 'unavailable') {
this.onOwnPresence(pres);
@@ -44490,9 +50967,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
this.save('connection_status', converse.ROOMSTATUS.CONNECTED);
}
},
- onOwnPresence: function onOwnPresence(pres) {
- var _this10 = this;
+ onOwnPresence(pres) {
/* Handles a received presence relating to the current
* user.
*
@@ -44509,18 +50985,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* (XMLElement) pres: The stanza
*/
this.saveAffiliationAndRole(pres);
- var locked_room = pres.querySelector("status[code='201']");
+ const locked_room = pres.querySelector("status[code='201']");
if (locked_room) {
if (this.get('auto_configure')) {
- this.autoConfigureChatRoom().then(function () {
- return _this10.refreshRoomFeatures();
- });
+ this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
} else if (_converse.muc_instant_rooms) {
// Accept default configuration
- this.saveConfiguration().then(function () {
- return _this10.getRoomFeatures();
- });
+ this.saveConfiguration().then(() => this.getRoomFeatures());
} else {
this.trigger('configurationNeeded');
return; // We haven't yet entered the groupchat, so bail here.
@@ -44532,9 +51004,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
// otherwise the features would have been fetched in
// the "initialize" method already.
if (this.get('affiliation') === 'owner' && this.get('auto_configure')) {
- this.autoConfigureChatRoom().then(function () {
- return _this10.refreshRoomFeatures();
- });
+ this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
} else {
this.getRoomFeatures();
}
@@ -44542,27 +51012,25 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
this.save('connection_status', converse.ROOMSTATUS.ENTERED);
},
- isUserMentioned: function isUserMentioned(message) {
+
+ isUserMentioned(message) {
/* Returns a boolean to indicate whether the current user
* was mentioned in a message.
*
* Parameters:
* (String): The text message
*/
- var nick = this.get('nick');
+ const nick = this.get('nick');
if (message.get('references').length) {
- var mentions = message.get('references').filter(function (ref) {
- return ref.type === 'mention';
- }).map(function (ref) {
- return ref.value;
- });
+ const mentions = message.get('references').filter(ref => ref.type === 'mention').map(ref => ref.value);
return _.includes(mentions, nick);
} else {
- return new RegExp("\\b".concat(nick, "\\b")).test(message.get('message'));
+ return new RegExp(`\\b${nick}\\b`).test(message.get('message'));
}
},
- incrementUnreadMsgCounter: function incrementUnreadMsgCounter(message) {
+
+ incrementUnreadMsgCounter(message) {
/* Given a newly received message, update the unread counter if
* necessary.
*
@@ -44573,14 +51041,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return;
}
- var body = message.get('message');
+ const body = message.get('message');
if (_.isNil(body)) {
return;
}
if (u.isNewMessage(message) && this.isHidden()) {
- var settings = {
+ const settings = {
'num_unread_general': this.get('num_unread_general') + 1
};
@@ -44593,26 +51061,30 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
this.save(settings);
}
},
- clearUnreadMsgCounter: function clearUnreadMsgCounter() {
+
+ clearUnreadMsgCounter() {
u.safeSave(this, {
'num_unread': 0,
'num_unread_general': 0
});
}
+
});
_converse.ChatRoomOccupant = Backbone.Model.extend({
defaults: {
'show': 'offline'
},
- initialize: function initialize(attributes) {
+
+ initialize(attributes) {
this.set(_.extend({
'id': _converse.connection.getUniqueId()
}, attributes));
this.on('change:image_hash', this.onAvatarChanged, this);
},
- onAvatarChanged: function onAvatarChanged() {
- var hash = this.get('image_hash');
- var vcards = [];
+
+ onAvatarChanged() {
+ const hash = this.get('image_hash');
+ const vcards = [];
if (this.get('jid')) {
vcards.push(_converse.vcards.findWhere({
@@ -44624,52 +51096,47 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
'jid': this.get('from')
}));
- _.forEach(_.filter(vcards, undefined), function (vcard) {
+ _.forEach(_.filter(vcards, undefined), vcard => {
if (hash && vcard.get('image_hash') !== hash) {
_converse.api.vcard.update(vcard);
}
});
},
- getDisplayName: function getDisplayName() {
+
+ getDisplayName() {
return this.get('nick') || this.get('jid');
},
- isMember: function isMember() {
+
+ isMember() {
return _.includes(['admin', 'owner', 'member'], this.get('affiliation'));
}
+
});
_converse.ChatRoomOccupants = Backbone.Collection.extend({
model: _converse.ChatRoomOccupant,
- comparator: function comparator(occupant1, occupant2) {
- var role1 = occupant1.get('role') || 'none';
- var role2 = occupant2.get('role') || 'none';
+
+ comparator(occupant1, occupant2) {
+ const role1 = occupant1.get('role') || 'none';
+ const role2 = occupant2.get('role') || 'none';
if (MUC_ROLE_WEIGHTS[role1] === MUC_ROLE_WEIGHTS[role2]) {
- var nick1 = occupant1.getDisplayName().toLowerCase();
- var nick2 = occupant2.getDisplayName().toLowerCase();
+ const nick1 = occupant1.getDisplayName().toLowerCase();
+ const nick2 = occupant2.getDisplayName().toLowerCase();
return nick1 < nick2 ? -1 : nick1 > nick2 ? 1 : 0;
} else {
return MUC_ROLE_WEIGHTS[role1] < MUC_ROLE_WEIGHTS[role2] ? -1 : 1;
}
},
- fetchMembers: function fetchMembers() {
- var _this11 = this;
- this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin']).then(function (new_members) {
- var new_jids = new_members.map(function (m) {
- return m.jid;
- }).filter(function (m) {
- return !_.isUndefined(m);
- }),
- new_nicks = new_members.map(function (m) {
- return !m.jid && m.nick || undefined;
- }).filter(function (m) {
- return !_.isUndefined(m);
- }),
- removed_members = _this11.filter(function (m) {
+ fetchMembers() {
+ this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin']).then(new_members => {
+ const new_jids = new_members.map(m => m.jid).filter(m => !_.isUndefined(m)),
+ new_nicks = new_members.map(m => !m.jid && m.nick || undefined).filter(m => !_.isUndefined(m)),
+ removed_members = this.filter(m => {
return f.includes(m.get('affiliation'), ['admin', 'member', 'owner']) && !f.includes(m.get('nick'), new_nicks) && !f.includes(m.get('jid'), new_jids);
});
- _.each(removed_members, function (occupant) {
+ _.each(removed_members, occupant => {
if (occupant.get('jid') === _converse.bare_jid) {
return;
}
@@ -44679,15 +51146,15 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}
});
- _.each(new_members, function (attrs) {
- var occupant;
+ _.each(new_members, attrs => {
+ let occupant;
if (attrs.jid) {
- occupant = _this11.findOccupant({
+ occupant = this.findOccupant({
'jid': attrs.jid
});
} else {
- occupant = _this11.findOccupant({
+ occupant = this.findOccupant({
'nick': attrs.nick
});
}
@@ -44695,12 +51162,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
if (occupant) {
occupant.save(attrs);
} else {
- _this11.create(attrs);
+ this.create(attrs);
}
});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
},
- findOccupant: function findOccupant(data) {
+
+ findOccupant(data) {
/* Try to find an existing occupant based on the passed in
* data object.
*
@@ -44708,7 +51176,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* otherwise we use the nick. We don't always have both,
* but should have at least one or the other.
*/
- var jid = Strophe.getBareJidFromJid(data.jid);
+ const jid = Strophe.getBareJidFromJid(data.jid);
if (jid !== null) {
return this.where({
@@ -44720,6 +51188,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}).pop();
}
}
+
});
_converse.RoomsPanelModel = Backbone.Model.extend({
defaults: {
@@ -44735,12 +51204,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* (XMLElement) message: The message stanza containing the
* invitation.
*/
- var x_el = sizzle('x[xmlns="jabber:x:conference"]', message).pop(),
- from = Strophe.getBareJidFromJid(message.getAttribute('from')),
- room_jid = x_el.getAttribute('jid'),
- reason = x_el.getAttribute('reason');
+ const x_el = sizzle('x[xmlns="jabber:x:conference"]', message).pop(),
+ from = Strophe.getBareJidFromJid(message.getAttribute('from')),
+ room_jid = x_el.getAttribute('jid'),
+ reason = x_el.getAttribute('reason');
- var contact = _converse.roster.get(from),
+ let contact = _converse.roster.get(from),
result;
if (_converse.auto_join_on_invite) {
@@ -44757,7 +51226,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}
if (result === true) {
- var chatroom = _converse.openChatRoom(room_jid, {
+ const chatroom = _converse.openChatRoom(room_jid, {
'password': x_el.getAttribute('password')
});
@@ -44768,8 +51237,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
};
if (_converse.allow_muc_invitations) {
- var registerDirectInvitationHandler = function registerDirectInvitationHandler() {
- _converse.connection.addHandler(function (message) {
+ const registerDirectInvitationHandler = function registerDirectInvitationHandler() {
+ _converse.connection.addHandler(message => {
_converse.onDirectMUCInvitation(message);
return true;
@@ -44781,7 +51250,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
_converse.on('reconnected', registerDirectInvitationHandler);
}
- var getChatRoom = function getChatRoom(jid, attrs, create) {
+ const getChatRoom = function getChatRoom(jid, attrs, create) {
jid = jid.toLowerCase();
attrs.type = _converse.CHATROOMS_TYPE;
attrs.id = jid;
@@ -44789,7 +51258,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return _converse.chatboxes.getChatBox(jid, attrs, create);
};
- var createChatRoom = function createChatRoom(jid, attrs) {
+ const createChatRoom = function createChatRoom(jid, attrs) {
+ if (jid.startsWith('xmpp:') && jid.endsWith('?join')) {
+ jid = jid.replace(/^xmpp:/, '').replace(/\?join$/, '');
+ }
+
return getChatRoom(jid, attrs, true);
};
@@ -44831,26 +51304,24 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}
function fetchRegistrationForm(room_jid, user_jid) {
- var _this12 = this;
-
_converse.api.sendIQ($iq({
'from': user_jid,
'to': room_jid,
'type': 'get'
}).c('query', {
'xmlns': Strophe.NS.REGISTER
- })).then(function (iq) {}).catch(function (iq) {
+ })).then(iq => {}).catch(iq => {
if (sizzle('item-not-found[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]', iq).length) {
- _this12.feedback.set('error', __("Error: the groupchat ".concat(_this12.model.getDisplayName(), " does not exist.")));
+ this.feedback.set('error', __(`Error: the groupchat ${this.model.getDisplayName()} does not exist.`));
} else if (sizzle('not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
- _this12.feedback.set('error', __("Sorry, you're not allowed to registerd in this groupchat"));
+ this.feedback.set('error', __(`Sorry, you're not allowed to register in this groupchat`));
}
});
}
/************************ BEGIN Event Handlers ************************/
- _converse.on('addClientFeatures', function () {
+ _converse.on('addClientFeatures', () => {
if (_converse.allow_muc) {
_converse.api.disco.own.features.add(Strophe.NS.MUC);
}
@@ -44865,16 +51336,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
_converse.api.listen.on('disconnecting', disconnectChatRooms);
- _converse.api.listen.on('statusInitialized', function () {
+ _converse.api.listen.on('statusInitialized', () => {
// XXX: For websocket connections, we disconnect from all
// chatrooms when the page reloads. This is a workaround for
// issue #1111 and should be removed once we support XEP-0198
- var options = {
+ const options = {
'once': true,
'passive': true
};
- window.addEventListener(_converse.unloadevent, function () {
- if (_instanceof(_converse.connection._proto, Strophe.Websocket)) {
+ window.addEventListener(_converse.unloadevent, () => {
+ if (_converse.connection._proto instanceof Strophe.Websocket) {
disconnectChatRooms();
}
});
@@ -44906,7 +51377,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* JIDs of the chatroom(s) to create
* @param {object} [attrs] attrs The room attributes
*/
- 'create': function create(jids, attrs) {
+ 'create'(jids, attrs) {
if (_.isString(attrs)) {
attrs = {
'nick': attrs
@@ -44986,11 +51457,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* true
* );
*/
- 'open': function open(jids, attrs) {
- return new Promise(function (resolve, reject) {
- _converse.api.waitUntil('chatBoxesFetched').then(function () {
+ 'open'(jids, attrs) {
+ return new Promise((resolve, reject) => {
+ _converse.api.waitUntil('chatBoxesFetched').then(() => {
if (_.isUndefined(jids)) {
- var err_msg = 'rooms.open: You need to provide at least one JID';
+ const err_msg = 'rooms.open: You need to provide at least one JID';
_converse.log(err_msg, Strophe.LogLevel.ERROR);
@@ -44998,9 +51469,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
} else if (_.isString(jids)) {
resolve(_converse.api.rooms.create(jids, attrs).trigger('show'));
} else {
- resolve(_.map(jids, function (jid) {
- return _converse.api.rooms.create(jid, attrs).trigger('show');
- }));
+ resolve(_.map(jids, jid => _converse.api.rooms.create(jid, attrs).trigger('show')));
}
});
});
@@ -45029,7 +51498,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
* )
* });
*/
- 'get': function get(jids, attrs, create) {
+ 'get'(jids, attrs, create) {
if (_.isString(attrs)) {
attrs = {
'nick': attrs
@@ -45039,7 +51508,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}
if (_.isUndefined(jids)) {
- var result = [];
+ const result = [];
_converse.chatboxes.each(function (chatbox) {
if (chatbox.get('type') === _converse.CHATROOMS_TYPE) {
@@ -45060,11 +51529,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
return _.map(jids, _.partial(getChatRoom, _, attrs));
}
+
}
});
/************************ END API ************************/
}
+
});
});
@@ -45077,10 +51548,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2013-2018, JC Brand
@@ -45093,22 +51561,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
+})(this, function (converse) {
"use strict";
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- _ = _converse$env._,
- sizzle = _converse$env.sizzle,
- u = converse.env.utils;
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ _ = _converse$env._,
+ sizzle = _converse$env.sizzle,
+ u = converse.env.utils;
converse.plugins.add('converse-notification', {
dependencies: ["converse-chatboxes"],
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse;
- var __ = _converse.__;
+ const _converse = this._converse;
+ const __ = _converse.__;
_converse.supports_html5_notification = "Notification" in window;
_converse.api.settings.update({
@@ -45122,34 +51591,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
notification_icon: '/logo/conversejs-filled.svg'
});
- _converse.isOnlyChatStateNotification = function (msg) {
- return (// See XEP-0085 Chat State Notification
- _.isNull(msg.querySelector('body')) && (_.isNull(msg.querySelector(_converse.ACTIVE)) || _.isNull(msg.querySelector(_converse.COMPOSING)) || _.isNull(msg.querySelector(_converse.INACTIVE)) || _.isNull(msg.querySelector(_converse.PAUSED)) || _.isNull(msg.querySelector(_converse.GONE)))
- );
- };
+ _converse.isOnlyChatStateNotification = msg => // See XEP-0085 Chat State Notification
+ _.isNull(msg.querySelector('body')) && (_.isNull(msg.querySelector(_converse.ACTIVE)) || _.isNull(msg.querySelector(_converse.COMPOSING)) || _.isNull(msg.querySelector(_converse.INACTIVE)) || _.isNull(msg.querySelector(_converse.PAUSED)) || _.isNull(msg.querySelector(_converse.GONE)));
_converse.shouldNotifyOfGroupMessage = function (message) {
/* Is this a group message worthy of notification?
*/
- var notify_all = _converse.notify_all_room_messages;
- var jid = message.getAttribute('from'),
- resource = Strophe.getResourceFromJid(jid),
- room_jid = Strophe.getBareJidFromJid(jid),
- sender = resource && Strophe.unescapeNode(resource) || '';
+ let notify_all = _converse.notify_all_room_messages;
+ const jid = message.getAttribute('from'),
+ resource = Strophe.getResourceFromJid(jid),
+ room_jid = Strophe.getBareJidFromJid(jid),
+ sender = resource && Strophe.unescapeNode(resource) || '';
if (sender === '' || message.querySelectorAll('delay').length > 0) {
return false;
}
- var room = _converse.chatboxes.get(room_jid);
+ const room = _converse.chatboxes.get(room_jid);
- var body = message.querySelector('body');
+ const body = message.querySelector('body');
if (_.isNull(body)) {
return false;
}
- var mentioned = new RegExp("\\b".concat(room.get('nick'), "\\b")).test(body.textContent);
+ const mentioned = new RegExp(`\\b${room.get('nick')}\\b`).test(body.textContent);
notify_all = notify_all === true || _.isArray(notify_all) && _.includes(notify_all, room_jid);
if (sender === room.get('nick') || !notify_all && !mentioned) {
@@ -45161,8 +51627,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.isMessageToHiddenChat = function (message) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode)) {
- var jid = Strophe.getBareJidFromJid(message.getAttribute('from')),
- view = _converse.chatboxviews.get(jid);
+ const jid = Strophe.getBareJidFromJid(message.getAttribute('from')),
+ view = _converse.chatboxviews.get(jid);
if (!_.isNil(view)) {
return view.model.get('hidden') || _converse.windowState === 'hidden' || !u.isVisible(view.el);
@@ -45175,7 +51641,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
_converse.shouldNotifyOfMessage = function (message) {
- var forwarded = message.querySelector('forwarded');
+ const forwarded = message.querySelector('forwarded');
if (!_.isNull(forwarded)) {
return false;
@@ -45186,7 +51652,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return _converse.isMessageToHiddenChat(message);
}
- var is_me = Strophe.getBareJidFromJid(message.getAttribute('from')) === _converse.bare_jid;
+ const is_me = Strophe.getBareJidFromJid(message.getAttribute('from')) === _converse.bare_jid;
return !_converse.isOnlyChatStateNotification(message) && !is_me && _converse.isMessageToHiddenChat(message);
};
@@ -45197,7 +51663,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// XXX Eventually this can be refactored to use Notification's sound
// feature, but no browser currently supports it.
// https://developer.mozilla.org/en-US/docs/Web/API/notification/sound
- var audio;
+ let audio;
if (_converse.play_sounds && !_.isUndefined(window.Audio)) {
audio = new Audio(_converse.sounds_path + "msg_received.ogg");
@@ -45222,9 +51688,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/* Shows an HTML5 Notification to indicate that a new chat
* message was received.
*/
- var title, roster_item;
- var full_from_jid = message.getAttribute('from'),
- from_jid = Strophe.getBareJidFromJid(full_from_jid);
+ let title, roster_item;
+ const full_from_jid = message.getAttribute('from'),
+ from_jid = Strophe.getBareJidFromJid(full_from_jid);
if (message.getAttribute('type') === 'headline') {
if (!_.includes(from_jid, '@') || _converse.allow_non_roster_messaging) {
@@ -45259,13 +51725,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// the message...
- var body = sizzle("encrypted[xmlns=\"".concat(Strophe.NS.OMEMO, "\"]"), message).length ? __('OMEMO Message received') : _.get(message.querySelector('body'), 'textContent');
+ const body = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, message).length ? __('OMEMO Message received') : _.get(message.querySelector('body'), 'textContent');
if (!body) {
return;
}
- var n = new Notification(title, {
+ const n = new Notification(title, {
'body': body,
'lang': _converse.locale,
'icon': _converse.notification_icon
@@ -45282,8 +51748,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var chat_state = contact.chat_status;
- var message = null;
+ const chat_state = contact.chat_status;
+ let message = null;
if (chat_state === 'offline') {
message = __('has gone offline');
@@ -45299,7 +51765,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var n = new Notification(contact.getDisplayName(), {
+ const n = new Notification(contact.getDisplayName(), {
body: message,
lang: _converse.locale,
icon: _converse.notification_icon
@@ -45308,7 +51774,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
_converse.showContactRequestNotification = function (contact) {
- var n = new Notification(contact.getDisplayName(), {
+ const n = new Notification(contact.getDisplayName(), {
body: __('wants to be your contact'),
lang: _converse.locale,
icon: _converse.notification_icon
@@ -45318,7 +51784,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.showFeedbackNotification = function (data) {
if (data.klass === 'error' || data.klass === 'warn') {
- var n = new Notification(data.subject, {
+ const n = new Notification(data.subject, {
body: data.message,
lang: _converse.locale,
icon: _converse.notification_icon
@@ -45341,7 +51807,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/* Event handler for the on('message') event. Will call methods
* to play sounds and show HTML5 notifications.
*/
- var message = data.stanza;
+ const message = data.stanza;
if (!_converse.shouldNotifyOfMessage(message)) {
return false;
@@ -45388,6 +51854,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.on('connected', _converse.requestPermission);
});
}
+
});
});
@@ -45400,14 +51867,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -45419,29 +51879,28 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_toolbar_omemo) {
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- moment = _converse$env.moment,
- sizzle = _converse$env.sizzle,
- $iq = _converse$env.$iq,
- $msg = _converse$env.$msg,
- _ = _converse$env._,
- f = _converse$env.f,
- b64_sha1 = _converse$env.b64_sha1;
- var u = converse.env.utils;
- Strophe.addNamespace('OMEMO', "eu.siacs.conversations.axolotl");
+})(this, function (converse, tpl_toolbar_omemo) {
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ moment = _converse$env.moment,
+ sizzle = _converse$env.sizzle,
+ $iq = _converse$env.$iq,
+ $msg = _converse$env.$msg,
+ _ = _converse$env._,
+ f = _converse$env.f,
+ b64_sha1 = _converse$env.b64_sha1;
+ const u = converse.env.utils;
Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO + ".devicelist");
Strophe.addNamespace('OMEMO_VERIFICATION', Strophe.NS.OMEMO + ".verification");
Strophe.addNamespace('OMEMO_WHITELISTED', Strophe.NS.OMEMO + ".whitelisted");
Strophe.addNamespace('OMEMO_BUNDLES', Strophe.NS.OMEMO + ".bundles");
- var UNDECIDED = 0;
- var TRUSTED = 1;
- var UNTRUSTED = -1;
- var TAG_LENGTH = 128;
- var KEY_ALGO = {
+ const UNDECIDED = 0;
+ const TRUSTED = 1;
+ const UNTRUSTED = -1;
+ const TAG_LENGTH = 128;
+ const KEY_ALGO = {
'name': "AES-GCM",
'length': 128
};
@@ -45450,11 +51909,11 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/* Given an XML element representing a user's OMEMO bundle, parse it
* and return a map.
*/
- var signed_prekey_public_el = bundle_el.querySelector('signedPreKeyPublic'),
- signed_prekey_signature_el = bundle_el.querySelector('signedPreKeySignature'),
- identity_key_el = bundle_el.querySelector('identityKey');
+ const signed_prekey_public_el = bundle_el.querySelector('signedPreKeyPublic'),
+ signed_prekey_signature_el = bundle_el.querySelector('signedPreKeySignature'),
+ identity_key_el = bundle_el.querySelector('identityKey');
- var prekeys = _.map(sizzle("prekeys > preKeyPublic", bundle_el), function (el) {
+ const prekeys = _.map(sizzle(`prekeys > preKeyPublic`, bundle_el), el => {
return {
'id': parseInt(el.getAttribute('preKeyId'), 10),
'key': el.textContent
@@ -45473,9 +51932,10 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
converse.plugins.add('converse-omemo', {
- enabled: function enabled(_converse) {
+ enabled(_converse) {
return !_.isNil(window.libsignal) && !f.includes('converse-omemo', _converse.blacklisted_plugins);
},
+
dependencies: ["converse-chatview"],
overrides: {
ProfileModal: {
@@ -45483,8 +51943,9 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'change input.select-all': 'selectAll',
'submit .fingerprint-removal': 'removeSelectedFingerprints'
},
- initialize: function initialize() {
- var _converse = this.__super__._converse;
+
+ initialize() {
+ const _converse = this.__super__._converse;
this.debouncedRender = _.debounce(this.render, 50);
this.devicelist = _converse.devicelists.get(_converse.bare_jid);
this.devicelist.devices.on('change:bundle', this.debouncedRender, this);
@@ -45493,54 +51954,55 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.devicelist.devices.on('add', this.debouncedRender, this);
return this.__super__.initialize.apply(this, arguments);
},
- beforeRender: function beforeRender() {
- var _converse = this.__super__._converse,
- device_id = _converse.omemo_store.get('device_id');
+
+ beforeRender() {
+ const _converse = this.__super__._converse,
+ device_id = _converse.omemo_store.get('device_id');
this.current_device = this.devicelist.devices.get(device_id);
- this.other_devices = this.devicelist.devices.filter(function (d) {
- return d.get('id') !== device_id;
- });
+ this.other_devices = this.devicelist.devices.filter(d => d.get('id') !== device_id);
if (this.__super__.beforeRender) {
return this.__super__.beforeRender.apply(this, arguments);
}
},
- selectAll: function selectAll(ev) {
- var sibling = u.ancestor(ev.target, 'li');
+
+ selectAll(ev) {
+ let sibling = u.ancestor(ev.target, 'li');
while (sibling) {
sibling.querySelector('input[type="checkbox"]').checked = ev.target.checked;
sibling = sibling.nextElementSibling;
}
},
- removeSelectedFingerprints: function removeSelectedFingerprints(ev) {
- var _this = this;
+ removeSelectedFingerprints(ev) {
ev.preventDefault();
ev.stopPropagation();
ev.target.querySelector('.select-all').checked = false;
- var checkboxes = ev.target.querySelectorAll('.fingerprint-removal-item input[type="checkbox"]:checked'),
- device_ids = _.map(checkboxes, 'value');
+ const checkboxes = ev.target.querySelectorAll('.fingerprint-removal-item input[type="checkbox"]:checked'),
+ device_ids = _.map(checkboxes, 'value');
- this.devicelist.removeOwnDevices(device_ids).then(this.modal.hide).catch(function (err) {
- var _converse = _this.__super__._converse,
- __ = _converse.__;
+ this.devicelist.removeOwnDevices(device_ids).then(this.modal.hide).catch(err => {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
_converse.log(err, Strophe.LogLevel.ERROR);
_converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), [__('Sorry, an error occurred while trying to remove the devices.')]);
});
}
+
},
UserDetailsModal: {
events: {
'click .fingerprint-trust .btn input': 'toggleDeviceTrust'
},
- initialize: function initialize() {
- var _converse = this.__super__._converse;
- var jid = this.model.get('jid');
+
+ initialize() {
+ const _converse = this.__super__._converse;
+ const jid = this.model.get('jid');
this.devicelist = _converse.devicelists.get(jid) || _converse.devicelists.create({
'jid': jid
});
@@ -45551,39 +52013,34 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.devicelist.devices.on('reset', this.render, this);
return this.__super__.initialize.apply(this, arguments);
},
- toggleDeviceTrust: function toggleDeviceTrust(ev) {
- var radio = ev.target;
- var device = this.devicelist.devices.get(radio.getAttribute('name'));
+
+ toggleDeviceTrust(ev) {
+ const radio = ev.target;
+ const device = this.devicelist.devices.get(radio.getAttribute('name'));
device.save('trusted', parseInt(radio.value, 10));
}
+
},
ChatBox: {
- getBundlesAndBuildSessions: function getBundlesAndBuildSessions() {
- var _this2 = this;
-
- var _converse = this.__super__._converse;
- var devices;
- return _converse.getDevicesForContact(this.get('jid')).then(function (their_devices) {
- var device_id = _converse.omemo_store.get('device_id'),
- devicelist = _converse.devicelists.get(_converse.bare_jid),
- own_devices = devicelist.devices.filter(function (device) {
- return device.get('id') !== device_id;
- });
+ getBundlesAndBuildSessions() {
+ const _converse = this.__super__._converse;
+ let devices;
+ return _converse.getDevicesForContact(this.get('jid')).then(their_devices => {
+ const device_id = _converse.omemo_store.get('device_id'),
+ devicelist = _converse.devicelists.get(_converse.bare_jid),
+ own_devices = devicelist.devices.filter(device => device.get('id') !== device_id);
devices = _.concat(own_devices, their_devices.models);
- return Promise.all(devices.map(function (device) {
- return device.getBundle();
- }));
- }).then(function () {
- return _this2.buildSessions(devices);
- });
+ return Promise.all(devices.map(device => device.getBundle()));
+ }).then(() => this.buildSessions(devices));
},
- buildSession: function buildSession(device) {
- var _converse = this.__super__._converse,
- address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id')),
- sessionBuilder = new libsignal.SessionBuilder(_converse.omemo_store, address),
- prekey = device.getRandomPreKey();
- return device.getBundle().then(function (bundle) {
+
+ buildSession(device) {
+ const _converse = this.__super__._converse,
+ address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id')),
+ sessionBuilder = new libsignal.SessionBuilder(_converse.omemo_store, address),
+ prekey = device.getRandomPreKey();
+ return device.getBundle().then(bundle => {
return sessionBuilder.processPreKey({
'registrationId': parseInt(device.get('id'), 10),
'identityKey': u.base64ToArrayBuffer(bundle.identity_key),
@@ -45601,20 +52058,20 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
});
},
- getSession: function getSession(device) {
- var _this3 = this;
- var _converse = this.__super__._converse,
- address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id'));
- return _converse.omemo_store.loadSession(address.toString()).then(function (session) {
+ getSession(device) {
+ const _converse = this.__super__._converse,
+ address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id'));
+ return _converse.omemo_store.loadSession(address.toString()).then(session => {
if (session) {
return Promise.resolve();
} else {
- return _this3.buildSession(device);
+ return this.buildSession(device);
}
});
},
- encryptMessage: async function encryptMessage(plaintext) {
+
+ async encryptMessage(plaintext) {
// The client MUST use fresh, randomly generated key/IV pairs
// with AES-128 in Galois/Counter Mode (GCM).
// For GCM a 12 byte IV is strongly suggested as other IV lengths
@@ -45624,18 +52081,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
// by implementations.
//
// https://crypto.stackexchange.com/questions/26783/ciphertext-and-tag-size-and-iv-transmission-with-aes-in-gcm-mode
- var iv = crypto.getRandomValues(new window.Uint8Array(12)),
- key = await crypto.subtle.generateKey(KEY_ALGO, true, ["encrypt", "decrypt"]),
- algo = {
+ const iv = crypto.getRandomValues(new window.Uint8Array(12)),
+ key = await crypto.subtle.generateKey(KEY_ALGO, true, ["encrypt", "decrypt"]),
+ algo = {
'name': 'AES-GCM',
'iv': iv,
'tagLength': TAG_LENGTH
},
- encrypted = await crypto.subtle.encrypt(algo, key, u.stringToArrayBuffer(plaintext)),
- length = encrypted.byteLength - (128 + 7 >> 3),
- ciphertext = encrypted.slice(0, length),
- tag = encrypted.slice(length),
- exported_key = await crypto.subtle.exportKey("raw", key);
+ encrypted = await crypto.subtle.encrypt(algo, key, u.stringToArrayBuffer(plaintext)),
+ length = encrypted.byteLength - (128 + 7 >> 3),
+ ciphertext = encrypted.slice(0, length),
+ tag = encrypted.slice(length),
+ exported_key = await crypto.subtle.exportKey("raw", key);
return Promise.resolve({
'key': exported_key,
'tag': tag,
@@ -45644,54 +52101,53 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'iv': u.arrayBufferToBase64(iv)
});
},
- decryptMessage: async function decryptMessage(obj) {
- var key_obj = await crypto.subtle.importKey('raw', obj.key, KEY_ALGO, true, ['encrypt', 'decrypt']),
- cipher = u.appendArrayBuffer(u.base64ToArrayBuffer(obj.payload), obj.tag),
- algo = {
+
+ async decryptMessage(obj) {
+ const key_obj = await crypto.subtle.importKey('raw', obj.key, KEY_ALGO, true, ['encrypt', 'decrypt']),
+ cipher = u.appendArrayBuffer(u.base64ToArrayBuffer(obj.payload), obj.tag),
+ algo = {
'name': "AES-GCM",
'iv': u.base64ToArrayBuffer(obj.iv),
'tagLength': TAG_LENGTH
};
return u.arrayBufferToString((await crypto.subtle.decrypt(algo, key_obj, cipher)));
},
- reportDecryptionError: function reportDecryptionError(e) {
- var _converse = this.__super__._converse;
+
+ reportDecryptionError(e) {
+ const _converse = this.__super__._converse;
if (_converse.debug) {
- var __ = _converse.__;
+ const __ = _converse.__;
this.messages.create({
- 'message': __("Sorry, could not decrypt a received OMEMO message due to an error.") + " ".concat(e.name, " ").concat(e.message),
+ 'message': __("Sorry, could not decrypt a received OMEMO message due to an error.") + ` ${e.name} ${e.message}`,
'type': 'error'
});
}
- _converse.log("".concat(e.name, " ").concat(e.message), Strophe.LogLevel.ERROR);
+ _converse.log(`${e.name} ${e.message}`, Strophe.LogLevel.ERROR);
},
- decrypt: function decrypt(attrs) {
- var _this4 = this;
- var _converse = this.__super__._converse,
- session_cipher = this.getSessionCipher(attrs.from, parseInt(attrs.encrypted.device_id, 10)); // https://xmpp.org/extensions/xep-0384.html#usecases-receiving
+ decrypt(attrs) {
+ const _converse = this.__super__._converse,
+ session_cipher = this.getSessionCipher(attrs.from, parseInt(attrs.encrypted.device_id, 10)); // https://xmpp.org/extensions/xep-0384.html#usecases-receiving
if (attrs.encrypted.prekey === 'true') {
- var plaintext;
- return session_cipher.decryptPreKeyWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary').then(function (key_and_tag) {
+ let plaintext;
+ return session_cipher.decryptPreKeyWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary').then(key_and_tag => {
if (attrs.encrypted.payload) {
- var key = key_and_tag.slice(0, 16),
- tag = key_and_tag.slice(16);
- return _this4.decryptMessage(_.extend(attrs.encrypted, {
+ const key = key_and_tag.slice(0, 16),
+ tag = key_and_tag.slice(16);
+ return this.decryptMessage(_.extend(attrs.encrypted, {
'key': key,
'tag': tag
}));
}
return Promise.resolve();
- }).then(function (pt) {
+ }).then(pt => {
plaintext = pt;
return _converse.omemo_store.generateMissingPreKeys();
- }).then(function () {
- return _converse.omemo_store.publishBundle();
- }).then(function () {
+ }).then(() => _converse.omemo_store.publishBundle()).then(() => {
if (plaintext) {
return _.extend(attrs, {
'plaintext': plaintext
@@ -45701,35 +52157,32 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'is_only_key': true
});
}
- }).catch(function (e) {
- _this4.reportDecryptionError(e);
-
+ }).catch(e => {
+ this.reportDecryptionError(e);
return attrs;
});
} else {
- return session_cipher.decryptWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary').then(function (key_and_tag) {
- var key = key_and_tag.slice(0, 16),
- tag = key_and_tag.slice(16);
- return _this4.decryptMessage(_.extend(attrs.encrypted, {
+ return session_cipher.decryptWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary').then(key_and_tag => {
+ const key = key_and_tag.slice(0, 16),
+ tag = key_and_tag.slice(16);
+ return this.decryptMessage(_.extend(attrs.encrypted, {
'key': key,
'tag': tag
}));
- }).then(function (plaintext) {
- return _.extend(attrs, {
- 'plaintext': plaintext
- });
- }).catch(function (e) {
- _this4.reportDecryptionError(e);
-
+ }).then(plaintext => _.extend(attrs, {
+ 'plaintext': plaintext
+ })).catch(e => {
+ this.reportDecryptionError(e);
return attrs;
});
}
},
- getEncryptionAttributesfromStanza: function getEncryptionAttributesfromStanza(stanza, original_stanza, attrs) {
- var _converse = this.__super__._converse,
- encrypted = sizzle("encrypted[xmlns=\"".concat(Strophe.NS.OMEMO, "\"]"), original_stanza).pop(),
- header = encrypted.querySelector('header'),
- key = sizzle("key[rid=\"".concat(_converse.omemo_store.get('device_id'), "\"]"), encrypted).pop();
+
+ getEncryptionAttributesfromStanza(stanza, original_stanza, attrs) {
+ const _converse = this.__super__._converse,
+ encrypted = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, original_stanza).pop(),
+ header = encrypted.querySelector('header'),
+ key = sizzle(`key[rid="${_converse.omemo_store.get('device_id')}"]`, encrypted).pop();
if (key) {
attrs['is_encrypted'] = true;
@@ -45745,46 +52198,43 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve(attrs);
}
},
- getMessageAttributesFromStanza: function getMessageAttributesFromStanza(stanza, original_stanza) {
- var encrypted = sizzle("encrypted[xmlns=\"".concat(Strophe.NS.OMEMO, "\"]"), original_stanza).pop();
- var attrs = this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
+ getMessageAttributesFromStanza(stanza, original_stanza) {
+ const _converse = this.__super__._converse,
+ encrypted = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, original_stanza).pop(),
+ attrs = this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
- if (!encrypted) {
+ if (!encrypted || !_converse.config.get('trusted')) {
return attrs;
} else {
return this.getEncryptionAttributesfromStanza(stanza, original_stanza, attrs);
}
},
- buildSessions: function buildSessions(devices) {
- var _this5 = this;
- return Promise.all(devices.map(function (device) {
- return _this5.getSession(device);
- })).then(function () {
- return devices;
- });
+ buildSessions(devices) {
+ return Promise.all(devices.map(device => this.getSession(device))).then(() => devices);
},
- getSessionCipher: function getSessionCipher(jid, id) {
- var _converse = this.__super__._converse,
- address = new libsignal.SignalProtocolAddress(jid, id);
+
+ getSessionCipher(jid, id) {
+ const _converse = this.__super__._converse,
+ address = new libsignal.SignalProtocolAddress(jid, id);
this.session_cipher = new window.libsignal.SessionCipher(_converse.omemo_store, address);
return this.session_cipher;
},
- encryptKey: function encryptKey(plaintext, device) {
- return this.getSessionCipher(device.get('jid'), device.get('id')).encrypt(plaintext).then(function (payload) {
- return {
- 'payload': payload,
- 'device': device
- };
- });
+
+ encryptKey(plaintext, device) {
+ return this.getSessionCipher(device.get('jid'), device.get('id')).encrypt(plaintext).then(payload => ({
+ 'payload': payload,
+ 'device': device
+ }));
},
- addKeysToMessageStanza: function addKeysToMessageStanza(stanza, dicts, iv) {
+
+ addKeysToMessageStanza(stanza, dicts, iv) {
for (var i in dicts) {
if (Object.prototype.hasOwnProperty.call(dicts, i)) {
- var payload = dicts[i].payload,
- device = dicts[i].device,
- prekey = 3 == parseInt(payload.type, 10);
+ const payload = dicts[i].payload,
+ device = dicts[i].device,
+ prekey = 3 == parseInt(payload.type, 10);
stanza.c('key', {
'rid': device.get('id')
}).t(btoa(payload.body));
@@ -45805,19 +52255,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve(stanza);
},
- createOMEMOMessageStanza: function createOMEMOMessageStanza(message, devices) {
- var _this6 = this;
- var _converse = this.__super__._converse,
- __ = _converse.__;
+ createOMEMOMessageStanza(message, devices) {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
- var body = __("This is an OMEMO encrypted message which your client doesn’t seem to support. " + "Find more information on https://conversations.im/omemo");
+ const body = __("This is an OMEMO encrypted message which your client doesn’t seem to support. " + "Find more information on https://conversations.im/omemo");
if (!message.get('message')) {
throw new Error("No message body to encrypt!");
}
- var stanza = $msg({
+ const stanza = $msg({
'from': _converse.connection.jid,
'to': this.get('jid'),
'type': this.get('message_type'),
@@ -45833,21 +52282,15 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}).c('header', {
'sid': _converse.omemo_store.get('device_id')
});
- return this.encryptMessage(message.get('message')).then(function (obj) {
+ return this.encryptMessage(message.get('message')).then(obj => {
// The 16 bytes key and the GCM authentication tag (The tag
// SHOULD have at least 128 bit) are concatenated and for each
// intended recipient device, i.e. both own devices as well as
// devices associated with the contact, the result of this
// concatenation is encrypted using the corresponding
// long-standing SignalProtocol session.
- var promises = devices.filter(function (device) {
- return device.get('trusted') != UNTRUSTED;
- }).map(function (device) {
- return _this6.encryptKey(obj.key_and_tag, device);
- });
- return Promise.all(promises).then(function (dicts) {
- return _this6.addKeysToMessageStanza(stanza, dicts, obj.iv);
- }).then(function (stanza) {
+ const promises = devices.filter(device => device.get('trusted') != UNTRUSTED).map(device => this.encryptKey(obj.key_and_tag, device));
+ return Promise.all(promises).then(dicts => this.addKeysToMessageStanza(stanza, dicts, obj.iv)).then(stanza => {
stanza.c('payload').t(obj.payload).up().up();
stanza.c('store', {
'xmlns': Strophe.NS.HINTS
@@ -45856,23 +52299,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
});
},
- sendMessage: function sendMessage(attrs) {
- var _this7 = this;
- var _converse = this.__super__._converse,
- __ = _converse.__;
+ sendMessage(attrs) {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
if (this.get('omemo_active') && attrs.message) {
attrs['is_encrypted'] = true;
attrs['plaintext'] = attrs.message;
- var message = this.messages.create(attrs);
- this.getBundlesAndBuildSessions().then(function (devices) {
- return _this7.createOMEMOMessageStanza(message, devices);
- }).then(function (stanza) {
- return _this7.sendMessageStanza(stanza);
- }).catch(function (e) {
- _this7.messages.create({
- 'message': __("Sorry, could not send the message due to an error.") + " ".concat(e.message),
+ const message = this.messages.create(attrs);
+ this.getBundlesAndBuildSessions().then(devices => this.createOMEMOMessageStanza(message, devices)).then(stanza => this.sendMessageStanza(stanza)).catch(e => {
+ this.messages.create({
+ 'message': __("Sorry, could not send the message due to an error.") + ` ${e.message}`,
'type': 'error'
});
@@ -45882,52 +52320,55 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this.__super__.sendMessage.apply(this, arguments);
}
}
+
},
ChatBoxView: {
events: {
'click .toggle-omemo': 'toggleOMEMO'
},
- showMessage: function showMessage(message) {
+
+ showMessage(message) {
// We don't show a message if it's only keying material
if (!message.get('is_only_key')) {
return this.__super__.showMessage.apply(this, arguments);
}
},
- renderOMEMOToolbarButton: function renderOMEMOToolbarButton() {
- var _this8 = this;
- var _converse = this.__super__._converse,
- __ = _converse.__;
+ async renderOMEMOToolbarButton() {
+ const _converse = this.__super__._converse,
+ __ = _converse.__;
+ const support = await _converse.contactHasOMEMOSupport(this.model.get('jid'));
- _converse.contactHasOMEMOSupport(this.model.get('jid')).then(function (support) {
- if (support) {
- var icon = _this8.el.querySelector('.toggle-omemo'),
- html = tpl_toolbar_omemo(_.extend(_this8.model.toJSON(), {
- '__': __
- }));
+ if (support) {
+ const icon = this.el.querySelector('.toggle-omemo'),
+ html = tpl_toolbar_omemo(_.extend(this.model.toJSON(), {
+ '__': __
+ }));
- if (icon) {
- icon.outerHTML = html;
- } else {
- _this8.el.querySelector('.chat-toolbar').insertAdjacentHTML('beforeend', html);
- }
+ if (icon) {
+ icon.outerHTML = html;
+ } else {
+ this.el.querySelector('.chat-toolbar').insertAdjacentHTML('beforeend', html);
}
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
+ }
},
- toggleOMEMO: function toggleOMEMO(ev) {
+
+ toggleOMEMO(ev) {
ev.preventDefault();
this.model.save({
'omemo_active': !this.model.get('omemo_active')
});
this.renderOMEMOToolbarButton();
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by Converse.js's plugin machinery.
*/
- var _converse = this._converse;
+ const _converse = this._converse;
_converse.api.promises.add(['OMEMOInitialized']);
@@ -45938,7 +52379,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return;
}
- return device.getBundle().then(function (bundle) {
+ return device.getBundle().then(bundle => {
bundle['fingerprint'] = u.arrayBufferToHex(u.base64ToArrayBuffer(bundle['identity_key']));
device.save('bundle', bundle);
device.trigger('change:bundle'); // Doesn't get triggered automatically due to pass-by-reference
@@ -45946,46 +52387,36 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
_converse.generateFingerprints = function (jid) {
- return _converse.getDevicesForContact(jid).then(function (devices) {
- return Promise.all(devices.map(function (d) {
- return generateFingerprint(d);
- }));
- });
+ return _converse.getDevicesForContact(jid).then(devices => Promise.all(devices.map(d => generateFingerprint(d))));
};
_converse.getDeviceForContact = function (jid, device_id) {
- return _converse.getDevicesForContact(jid).then(function (devices) {
- return devices.get(device_id);
- });
+ return _converse.getDevicesForContact(jid).then(devices => devices.get(device_id));
};
_converse.getDevicesForContact = function (jid) {
- var devicelist;
- return _converse.api.waitUntil('OMEMOInitialized').then(function () {
+ let devicelist;
+ return _converse.api.waitUntil('OMEMOInitialized').then(() => {
devicelist = _converse.devicelists.get(jid) || _converse.devicelists.create({
'jid': jid
});
return devicelist.fetchDevices();
- }).then(function () {
- return devicelist.devices;
- });
+ }).then(() => devicelist.devices);
};
_converse.contactHasOMEMOSupport = function (jid) {
/* Checks whether the contact advertises any OMEMO-compatible devices. */
- return new Promise(function (resolve, reject) {
- _converse.getDevicesForContact(jid).then(function (devices) {
- return resolve(devices.length > 0);
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
+ return new Promise((resolve, reject) => {
+ _converse.getDevicesForContact(jid).then(devices => resolve(devices.length > 0)).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
});
};
function generateDeviceID() {
/* Generates a device ID, making sure that it's unique */
- var existing_ids = _converse.devicelists.get(_converse.bare_jid).devices.pluck('id');
+ const existing_ids = _converse.devicelists.get(_converse.bare_jid).devices.pluck('id');
- var device_id = libsignal.KeyHelper.generateRegistrationId();
- var i = 0;
+ let device_id = libsignal.KeyHelper.generateRegistrationId();
+ let i = 0;
while (_.includes(existing_ids, device_id)) {
device_id = libsignal.KeyHelper.generateRegistrationId();
@@ -46004,26 +52435,29 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
SENDING: 1,
RECEIVING: 2
},
- getIdentityKeyPair: function getIdentityKeyPair() {
- var keypair = this.get('identity_keypair');
+
+ getIdentityKeyPair() {
+ const keypair = this.get('identity_keypair');
return Promise.resolve({
'privKey': u.base64ToArrayBuffer(keypair.privKey),
'pubKey': u.base64ToArrayBuffer(keypair.pubKey)
});
},
- getLocalRegistrationId: function getLocalRegistrationId() {
+
+ getLocalRegistrationId() {
return Promise.resolve(parseInt(this.get('device_id'), 10));
},
- isTrustedIdentity: function isTrustedIdentity(identifier, identity_key, direction) {
+
+ isTrustedIdentity(identifier, identity_key, direction) {
if (_.isNil(identifier)) {
throw new Error("Can't check identity key for invalid key");
}
- if (!_instanceof(identity_key, ArrayBuffer)) {
+ if (!(identity_key instanceof ArrayBuffer)) {
throw new Error("Expected identity_key to be an ArrayBuffer");
}
- var trusted = this.get('identity_key' + identifier);
+ const trusted = this.get('identity_key' + identifier);
if (trusted === undefined) {
return Promise.resolve(true);
@@ -46031,21 +52465,23 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve(u.arrayBufferToBase64(identity_key) === trusted);
},
- loadIdentityKey: function loadIdentityKey(identifier) {
+
+ loadIdentityKey(identifier) {
if (_.isNil(identifier)) {
throw new Error("Can't load identity_key for invalid identifier");
}
return Promise.resolve(u.base64ToArrayBuffer(this.get('identity_key' + identifier)));
},
- saveIdentity: function saveIdentity(identifier, identity_key) {
+
+ saveIdentity(identifier, identity_key) {
if (_.isNil(identifier)) {
throw new Error("Can't save identity_key for invalid identifier");
}
- var address = new libsignal.SignalProtocolAddress.fromString(identifier),
- existing = this.get('identity_key' + address.getName());
- var b64_idkey = u.arrayBufferToBase64(identity_key);
+ const address = new libsignal.SignalProtocolAddress.fromString(identifier),
+ existing = this.get('identity_key' + address.getName());
+ const b64_idkey = u.arrayBufferToBase64(identity_key);
this.save('identity_key' + address.getName(), b64_idkey);
if (existing && b64_idkey !== existing) {
@@ -46054,11 +52490,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve(false);
}
},
- getPreKeys: function getPreKeys() {
+
+ getPreKeys() {
return this.get('prekeys') || {};
},
- loadPreKey: function loadPreKey(key_id) {
- var res = this.getPreKeys()[key_id];
+
+ loadPreKey(key_id) {
+ const res = this.getPreKeys()[key_id];
if (res) {
return Promise.resolve({
@@ -46069,8 +52507,9 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve();
},
- storePreKey: function storePreKey(key_id, key_pair) {
- var prekey = {};
+
+ storePreKey(key_id, key_pair) {
+ const prekey = {};
prekey[key_id] = {
'pubKey': u.arrayBufferToBase64(key_pair.pubKey),
'privKey': u.arrayBufferToBase64(key_pair.privKey)
@@ -46078,12 +52517,14 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.save('prekeys', _.extend(this.getPreKeys(), prekey));
return Promise.resolve();
},
- removePreKey: function removePreKey(key_id) {
+
+ removePreKey(key_id) {
this.save('prekeys', _.omit(this.getPreKeys(), key_id));
return Promise.resolve();
},
- loadSignedPreKey: function loadSignedPreKey(keyId) {
- var res = this.get('signed_prekey');
+
+ loadSignedPreKey(keyId) {
+ const res = this.get('signed_prekey');
if (res) {
return Promise.resolve({
@@ -46094,8 +52535,9 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve();
},
- storeSignedPreKey: function storeSignedPreKey(spk) {
- if (_typeof(spk) !== "object") {
+
+ storeSignedPreKey(spk) {
+ if (typeof spk !== "object") {
// XXX: We've changed the signature of this method from the
// example given in InMemorySignalProtocolStore.
// Should be fine because the libsignal code doesn't
@@ -46116,7 +52558,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
return Promise.resolve();
},
- removeSignedPreKey: function removeSignedPreKey(key_id) {
+
+ removeSignedPreKey(key_id) {
if (this.get('signed_prekey')['id'] === key_id) {
this.unset('signed_prekey');
this.save();
@@ -46124,59 +52567,61 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve();
},
- loadSession: function loadSession(identifier) {
+
+ loadSession(identifier) {
return Promise.resolve(this.get('session' + identifier));
},
- storeSession: function storeSession(identifier, record) {
+
+ storeSession(identifier, record) {
return Promise.resolve(this.save('session' + identifier, record));
},
- removeSession: function removeSession(identifier) {
+
+ removeSession(identifier) {
return Promise.resolve(this.unset('session' + identifier));
},
- removeAllSessions: function removeAllSessions(identifier) {
- var keys = _.filter(_.keys(this.attributes), function (key) {
+
+ removeAllSessions(identifier) {
+ const keys = _.filter(_.keys(this.attributes), key => {
if (key.startsWith('session' + identifier)) {
return key;
}
});
- var attrs = {};
+ const attrs = {};
- _.forEach(keys, function (key) {
+ _.forEach(keys, key => {
attrs[key] = undefined;
});
this.save(attrs);
return Promise.resolve();
},
- publishBundle: function publishBundle() {
- var signed_prekey = this.get('signed_prekey');
- var stanza = $iq({
+
+ publishBundle() {
+ const signed_prekey = this.get('signed_prekey');
+ const stanza = $iq({
'from': _converse.bare_jid,
'type': 'set'
}).c('pubsub', {
'xmlns': Strophe.NS.PUBSUB
}).c('publish', {
- 'node': "".concat(Strophe.NS.OMEMO_BUNDLES, ":").concat(this.get('device_id'))
+ 'node': `${Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`
}).c('item').c('bundle', {
'xmlns': Strophe.NS.OMEMO
}).c('signedPreKeyPublic', {
'signedPreKeyId': signed_prekey.id
}).t(signed_prekey.pubKey).up().c('signedPreKeySignature').t(signed_prekey.signature).up().c('identityKey').t(this.get('identity_keypair').pubKey).up().c('prekeys');
- _.forEach(this.get('prekeys'), function (prekey, id) {
- return stanza.c('preKeyPublic', {
- 'preKeyId': id
- }).t(prekey.pubKey).up();
- });
+ _.forEach(this.get('prekeys'), (prekey, id) => stanza.c('preKeyPublic', {
+ 'preKeyId': id
+ }).t(prekey.pubKey).up());
return _converse.api.sendIQ(stanza);
},
- generateMissingPreKeys: function generateMissingPreKeys() {
- var _this9 = this;
- var current_keys = this.getPreKeys(),
- missing_keys = _.difference(_.invokeMap(_.range(0, _converse.NUM_PREKEYS), Number.prototype.toString), _.keys(current_keys));
+ generateMissingPreKeys() {
+ const current_keys = this.getPreKeys(),
+ missing_keys = _.difference(_.invokeMap(_.range(0, _converse.NUM_PREKEYS), Number.prototype.toString), _.keys(current_keys));
if (missing_keys.length < 1) {
_converse.log("No missing prekeys to generate for our own device", Strophe.LogLevel.WARN);
@@ -46184,102 +52629,83 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return Promise.resolve();
}
- return Promise.all(_.map(missing_keys, function (id) {
- return libsignal.KeyHelper.generatePreKey(parseInt(id, 10));
- })).then(function (keys) {
- _.forEach(keys, function (k) {
- return _this9.storePreKey(k.keyId, k.keyPair);
- });
+ return Promise.all(_.map(missing_keys, id => libsignal.KeyHelper.generatePreKey(parseInt(id, 10)))).then(keys => {
+ _.forEach(keys, k => this.storePreKey(k.keyId, k.keyPair));
- var marshalled_keys = _.map(_this9.getPreKeys(), function (k) {
- return {
- 'id': k.keyId,
- 'key': u.arrayBufferToBase64(k.pubKey)
- };
- }),
- devicelist = _converse.devicelists.get(_converse.bare_jid),
- device = devicelist.devices.get(_this9.get('device_id'));
+ const marshalled_keys = _.map(this.getPreKeys(), k => ({
+ 'id': k.keyId,
+ 'key': u.arrayBufferToBase64(k.pubKey)
+ })),
+ devicelist = _converse.devicelists.get(_converse.bare_jid),
+ device = devicelist.devices.get(this.get('device_id'));
- return device.getBundle().then(function (bundle) {
- return device.save('bundle', _.extend(bundle, {
- 'prekeys': marshalled_keys
- }));
- });
+ return device.getBundle().then(bundle => device.save('bundle', _.extend(bundle, {
+ 'prekeys': marshalled_keys
+ })));
});
},
- generateBundle: function generateBundle() {
- var _this10 = this;
+ async generateBundle() {
/* The first thing that needs to happen if a client wants to
* start using OMEMO is they need to generate an IdentityKey
* and a Device ID. The IdentityKey is a Curve25519 [6]
* public/private Key pair. The Device ID is a randomly
* generated integer between 1 and 2^31 - 1.
*/
- var bundle = {};
- return libsignal.KeyHelper.generateIdentityKeyPair().then(function (identity_keypair) {
- var identity_key = u.arrayBufferToBase64(identity_keypair.pubKey),
+ const identity_keypair = await libsignal.KeyHelper.generateIdentityKeyPair();
+ const bundle = {},
+ identity_key = u.arrayBufferToBase64(identity_keypair.pubKey),
device_id = generateDeviceID();
- bundle['identity_key'] = identity_key;
- bundle['device_id'] = device_id;
-
- _this10.save({
- 'device_id': device_id,
- 'identity_keypair': {
- 'privKey': u.arrayBufferToBase64(identity_keypair.privKey),
- 'pubKey': identity_key
- },
- 'identity_key': identity_key
- });
-
- return libsignal.KeyHelper.generateSignedPreKey(identity_keypair, 0);
- }).then(function (signed_prekey) {
- _converse.omemo_store.storeSignedPreKey(signed_prekey);
-
- bundle['signed_prekey'] = {
- 'id': signed_prekey.keyId,
- 'public_key': u.arrayBufferToBase64(signed_prekey.keyPair.privKey),
- 'signature': u.arrayBufferToBase64(signed_prekey.signature)
- };
- return Promise.all(_.map(_.range(0, _converse.NUM_PREKEYS), function (id) {
- return libsignal.KeyHelper.generatePreKey(id);
- }));
- }).then(function (keys) {
- _.forEach(keys, function (k) {
- return _converse.omemo_store.storePreKey(k.keyId, k.keyPair);
- });
-
- var devicelist = _converse.devicelists.get(_converse.bare_jid),
- device = devicelist.devices.create({
- 'id': bundle.device_id,
- 'jid': _converse.bare_jid
- }),
- marshalled_keys = _.map(keys, function (k) {
- return {
- 'id': k.keyId,
- 'key': u.arrayBufferToBase64(k.keyPair.pubKey)
- };
- });
-
- bundle['prekeys'] = marshalled_keys;
- device.save('bundle', bundle);
+ bundle['identity_key'] = identity_key;
+ bundle['device_id'] = device_id;
+ this.save({
+ 'device_id': device_id,
+ 'identity_keypair': {
+ 'privKey': u.arrayBufferToBase64(identity_keypair.privKey),
+ 'pubKey': identity_key
+ },
+ 'identity_key': identity_key
});
- },
- fetchSession: function fetchSession() {
- var _this11 = this;
+ const signed_prekey = await libsignal.KeyHelper.generateSignedPreKey(identity_keypair, 0);
+ _converse.omemo_store.storeSignedPreKey(signed_prekey);
+
+ bundle['signed_prekey'] = {
+ 'id': signed_prekey.keyId,
+ 'public_key': u.arrayBufferToBase64(signed_prekey.keyPair.privKey),
+ 'signature': u.arrayBufferToBase64(signed_prekey.signature)
+ };
+ const keys = await Promise.all(_.map(_.range(0, _converse.NUM_PREKEYS), id => libsignal.KeyHelper.generatePreKey(id)));
+
+ _.forEach(keys, k => _converse.omemo_store.storePreKey(k.keyId, k.keyPair));
+
+ const devicelist = _converse.devicelists.get(_converse.bare_jid),
+ device = devicelist.devices.create({
+ 'id': bundle.device_id,
+ 'jid': _converse.bare_jid
+ }),
+ marshalled_keys = _.map(keys, k => ({
+ 'id': k.keyId,
+ 'key': u.arrayBufferToBase64(k.keyPair.pubKey)
+ }));
+
+ bundle['prekeys'] = marshalled_keys;
+ device.save('bundle', bundle);
+ },
+
+ fetchSession() {
if (_.isUndefined(this._setup_promise)) {
- this._setup_promise = new Promise(function (resolve, reject) {
- _this11.fetch({
- 'success': function success() {
+ this._setup_promise = new Promise((resolve, reject) => {
+ this.fetch({
+ 'success': () => {
if (!_converse.omemo_store.get('device_id')) {
- _this11.generateBundle().then(resolve).catch(resolve);
+ this.generateBundle().then(resolve).catch(resolve);
} else {
resolve();
}
},
- 'error': function error() {
- _this11.generateBundle().then(resolve).catch(resolve);
+ 'error': () => {
+ this.generateBundle().then(resolve).catch(resolve);
}
});
});
@@ -46287,41 +52713,41 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this._setup_promise;
}
+
});
_converse.Device = Backbone.Model.extend({
defaults: {
'trusted': UNDECIDED
},
- getRandomPreKey: function getRandomPreKey() {
+
+ getRandomPreKey() {
// XXX: assumes that the bundle has already been fetched
- var bundle = this.get('bundle');
+ const bundle = this.get('bundle');
return bundle.prekeys[u.getRandomInt(bundle.prekeys.length)];
},
- fetchBundleFromServer: function fetchBundleFromServer() {
- var _this12 = this;
- var stanza = $iq({
+ fetchBundleFromServer() {
+ const stanza = $iq({
'type': 'get',
'from': _converse.bare_jid,
'to': this.get('jid')
}).c('pubsub', {
'xmlns': Strophe.NS.PUBSUB
}).c('items', {
- 'node': "".concat(Strophe.NS.OMEMO_BUNDLES, ":").concat(this.get('id'))
+ 'node': `${Strophe.NS.OMEMO_BUNDLES}:${this.get('id')}`
});
- return _converse.api.sendIQ(stanza).then(function (iq) {
- var publish_el = sizzle("items[node=\"".concat(Strophe.NS.OMEMO_BUNDLES, ":").concat(_this12.get('id'), "\"]"), iq).pop(),
- bundle_el = sizzle("bundle[xmlns=\"".concat(Strophe.NS.OMEMO, "\"]"), publish_el).pop(),
- bundle = parseBundle(bundle_el);
-
- _this12.save('bundle', bundle);
-
+ return _converse.api.sendIQ(stanza).then(iq => {
+ const publish_el = sizzle(`items[node="${Strophe.NS.OMEMO_BUNDLES}:${this.get('id')}"]`, iq).pop(),
+ bundle_el = sizzle(`bundle[xmlns="${Strophe.NS.OMEMO}"]`, publish_el).pop(),
+ bundle = parseBundle(bundle_el);
+ this.save('bundle', bundle);
return bundle;
- }).catch(function (iq) {
+ }).catch(iq => {
_converse.log(iq.outerHTML, Strophe.LogLevel.ERROR);
});
},
- getBundle: function getBundle() {
+
+ getBundle() {
/* Fetch and save the bundle information associated with
* this device, if the information is not at hand already.
*/
@@ -46331,29 +52757,28 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this.fetchBundleFromServer();
}
}
+
});
_converse.Devices = Backbone.Collection.extend({
model: _converse.Device
});
_converse.DeviceList = Backbone.Model.extend({
idAttribute: 'jid',
- initialize: function initialize() {
+
+ initialize() {
this.devices = new _converse.Devices();
- var id = "converse.devicelist-".concat(_converse.bare_jid, "-").concat(this.get('jid'));
+ const id = `converse.devicelist-${_converse.bare_jid}-${this.get('jid')}`;
this.devices.browserStorage = new Backbone.BrowserStorage.session(id);
this.fetchDevices();
},
- fetchDevices: function fetchDevices() {
- var _this13 = this;
+ fetchDevices() {
if (_.isUndefined(this._devices_promise)) {
- this._devices_promise = new Promise(function (resolve, reject) {
- _this13.devices.fetch({
- 'success': function success(collection) {
+ this._devices_promise = new Promise((resolve, reject) => {
+ this.devices.fetch({
+ 'success': collection => {
if (collection.length === 0) {
- _this13.fetchDevicesFromServer().then(function (ids) {
- return _this13.publishCurrentDevice(ids);
- }).then(resolve).catch(resolve);
+ this.fetchDevicesFromServer().then(ids => this.publishCurrentDevice(ids)).finally(resolve);
} else {
resolve();
}
@@ -46364,29 +52789,32 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this._devices_promise;
},
- publishCurrentDevice: function publishCurrentDevice(device_ids) {
- var _this14 = this;
+ async publishCurrentDevice(device_ids) {
if (this.get('jid') !== _converse.bare_jid) {
// We only publish for ourselves.
- return Promise.resolve();
+ return;
}
- return restoreOMEMOSession().then(function () {
- var device_id = _converse.omemo_store.get('device_id'),
- own_device = _this14.devices.findWhere({
- 'id': device_id
- });
+ await restoreOMEMOSession();
- if (!_.includes(device_ids, device_id)) {
- return _this14.publishDevices();
- }
- });
+ let device_id = _converse.omemo_store.get('device_id');
+
+ if (!this.devices.findWhere({
+ 'id': device_id
+ })) {
+ // Generate a new bundle if we cannot find our device
+ await _converse.omemo_store.generateBundle();
+ device_id = _converse.omemo_store.get('device_id');
+ }
+
+ if (!_.includes(device_ids, device_id)) {
+ return this.publishDevices();
+ }
},
- fetchDevicesFromServer: function fetchDevicesFromServer() {
- var _this15 = this;
- var stanza = $iq({
+ fetchDevicesFromServer() {
+ const stanza = $iq({
'type': 'get',
'from': _converse.bare_jid,
'to': this.get('jid')
@@ -46395,23 +52823,20 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}).c('items', {
'node': Strophe.NS.OMEMO_DEVICELIST
});
- return _converse.api.sendIQ(stanza).then(function (iq) {
- var device_ids = _.map(sizzle("list[xmlns=\"".concat(Strophe.NS.OMEMO, "\"] device"), iq), function (dev) {
- return dev.getAttribute('id');
- });
+ return _converse.api.sendIQ(stanza).then(iq => {
+ const device_ids = _.map(sizzle(`list[xmlns="${Strophe.NS.OMEMO}"] device`, iq), dev => dev.getAttribute('id'));
- _.forEach(device_ids, function (id) {
- return _this15.devices.create({
- 'id': id,
- 'jid': _this15.get('jid')
- });
- });
+ _.forEach(device_ids, id => this.devices.create({
+ 'id': id,
+ 'jid': this.get('jid')
+ }));
return device_ids;
});
},
- publishDevices: function publishDevices() {
- var stanza = $iq({
+
+ publishDevices() {
+ const stanza = $iq({
'from': _converse.bare_jid,
'type': 'set'
}).c('pubsub', {
@@ -46421,42 +52846,36 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}).c('item').c('list', {
'xmlns': Strophe.NS.OMEMO
});
- this.devices.each(function (device) {
- return stanza.c('device', {
- 'id': device.get('id')
- }).up();
- });
+ this.devices.each(device => stanza.c('device', {
+ 'id': device.get('id')
+ }).up());
return _converse.api.sendIQ(stanza);
},
- removeOwnDevices: function removeOwnDevices(device_ids) {
- var _this16 = this;
+ removeOwnDevices(device_ids) {
if (this.get('jid') !== _converse.bare_jid) {
throw new Error("Cannot remove devices from someone else's device list");
}
- _.forEach(device_ids, function (device_id) {
- return _this16.devices.get(device_id).destroy();
- });
+ _.forEach(device_ids, device_id => this.devices.get(device_id).destroy());
return this.publishDevices();
}
+
});
_converse.DeviceLists = Backbone.Collection.extend({
model: _converse.DeviceList
});
function fetchDeviceLists() {
- return new Promise(function (resolve, reject) {
- return _converse.devicelists.fetch({
- 'success': resolve
- });
- });
+ return new Promise((resolve, reject) => _converse.devicelists.fetch({
+ 'success': resolve
+ }));
}
function fetchOwnDevices() {
- return fetchDeviceLists().then(function () {
- var own_devicelist = _converse.devicelists.get(_converse.bare_jid);
+ return fetchDeviceLists().then(() => {
+ let own_devicelist = _converse.devicelists.get(_converse.bare_jid);
if (_.isNil(own_devicelist)) {
own_devicelist = _converse.devicelists.create({
@@ -46469,19 +52888,19 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
function updateBundleFromStanza(stanza) {
- var items_el = sizzle("items", stanza).pop();
+ const items_el = sizzle(`items`, stanza).pop();
if (!items_el || !items_el.getAttribute('node').startsWith(Strophe.NS.OMEMO_BUNDLES)) {
return;
}
- var device_id = items_el.getAttribute('node').split(':')[1],
- jid = stanza.getAttribute('from'),
- bundle_el = sizzle("item > bundle", items_el).pop(),
- devicelist = _converse.devicelists.get(jid) || _converse.devicelists.create({
+ const device_id = items_el.getAttribute('node').split(':')[1],
+ jid = stanza.getAttribute('from'),
+ bundle_el = sizzle(`item > bundle`, items_el).pop(),
+ devicelist = _converse.devicelists.get(jid) || _converse.devicelists.create({
'jid': jid
}),
- device = devicelist.devices.get(device_id) || devicelist.devices.create({
+ device = devicelist.devices.get(device_id) || devicelist.devices.create({
'id': device_id,
'jid': jid
});
@@ -46492,24 +52911,22 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
function updateDevicesFromStanza(stanza) {
- var items_el = sizzle("items[node=\"".concat(Strophe.NS.OMEMO_DEVICELIST, "\"]"), stanza).pop();
+ const items_el = sizzle(`items[node="${Strophe.NS.OMEMO_DEVICELIST}"]`, stanza).pop();
if (!items_el) {
return;
}
- var device_ids = _.map(sizzle("item list[xmlns=\"".concat(Strophe.NS.OMEMO, "\"] device"), items_el), function (device) {
- return device.getAttribute('id');
- });
+ const device_ids = _.map(sizzle(`item list[xmlns="${Strophe.NS.OMEMO}"] device`, items_el), device => device.getAttribute('id'));
- var jid = stanza.getAttribute('from'),
- devicelist = _converse.devicelists.get(jid) || _converse.devicelists.create({
+ const jid = stanza.getAttribute('from'),
+ devicelist = _converse.devicelists.get(jid) || _converse.devicelists.create({
'jid': jid
}),
- devices = devicelist.devices,
- removed_ids = _.difference(devices.pluck('id'), device_ids);
+ devices = devicelist.devices,
+ removed_ids = _.difference(devices.pluck('id'), device_ids);
- _.forEach(removed_ids, function (id) {
+ _.forEach(removed_ids, id => {
if (jid === _converse.bare_jid && id === _converse.omemo_store.get('device_id')) {
// We don't remove the current device
return;
@@ -46518,7 +52935,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
devices.get(id).destroy();
});
- _.forEach(device_ids, function (device_id) {
+ _.forEach(device_ids, device_id => {
if (!devices.get(device_id)) {
devices.create({
'id': device_id,
@@ -46536,9 +52953,9 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
function registerPEPPushHandler() {
// Add a handler for devices pushed from other connected clients
- _converse.connection.addHandler(function (message) {
+ _converse.connection.addHandler(message => {
try {
- if (sizzle("event[xmlns=\"".concat(Strophe.NS.PUBSUB, "#event\"]"), message).length) {
+ if (sizzle(`event[xmlns="${Strophe.NS.PUBSUB}#event"]`, message).length) {
updateDevicesFromStanza(message);
updateBundleFromStanza(message);
}
@@ -46552,8 +52969,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
function restoreOMEMOSession() {
if (_.isUndefined(_converse.omemo_store)) {
- var storage = _converse.config.get('storage'),
- id = "converse.omemosession-".concat(_converse.bare_jid);
+ const storage = _converse.config.get('storage'),
+ id = `converse.omemosession-${_converse.bare_jid}`;
_converse.omemo_store = new _converse.OMEMOStore({
'id': id
@@ -46565,22 +52982,20 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
function initOMEMO() {
+ if (!_converse.config.get('trusted')) {
+ return;
+ }
+
_converse.devicelists = new _converse.DeviceLists();
- var storage = _converse.config.get('storage'),
- id = "converse.devicelists-".concat(_converse.bare_jid);
+ const storage = _converse.config.get('storage'),
+ id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id);
- fetchOwnDevices().then(function () {
- return restoreOMEMOSession();
- }).then(function () {
- return _converse.omemo_store.publishBundle();
- }).then(function () {
- return _converse.emit('OMEMOInitialized');
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
+ fetchOwnDevices().then(() => restoreOMEMOSession()).then(() => _converse.omemo_store.publishBundle()).then(() => _converse.emit('OMEMOInitialized')).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
}
- _converse.api.listen.on('afterTearDown', function () {
+ _converse.api.listen.on('afterTearDown', () => {
if (_converse.devicelists) {
_converse.devicelists.reset();
}
@@ -46590,26 +53005,23 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.api.listen.on('connected', registerPEPPushHandler);
- _converse.api.listen.on('renderToolbar', function (view) {
- return view.renderOMEMOToolbarButton();
- });
+ _converse.api.listen.on('renderToolbar', view => view.renderOMEMOToolbarButton());
_converse.api.listen.on('statusInitialized', initOMEMO);
- _converse.api.listen.on('addClientFeatures', function () {
- return _converse.api.disco.own.features.add("".concat(Strophe.NS.OMEMO_DEVICELIST, "+notify"));
- });
+ _converse.api.listen.on('addClientFeatures', () => _converse.api.disco.own.features.add(`${Strophe.NS.OMEMO_DEVICELIST}+notify`));
- _converse.api.listen.on('userDetailsModalInitialized', function (contact) {
- var jid = contact.get('jid');
+ _converse.api.listen.on('userDetailsModalInitialized', contact => {
+ const jid = contact.get('jid');
_converse.generateFingerprints(jid).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
});
- _converse.api.listen.on('profileModalInitialized', function (contact) {
+ _converse.api.listen.on('profileModalInitialized', contact => {
_converse.generateFingerprints(_converse.bare_jid).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
});
}
+
});
});
@@ -46622,10 +53034,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// https://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -46635,22 +53044,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* as specified in XEP-0199 XMPP Ping.
*/
(function (root, factory) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! converse-core */ "./src/converse-core.js"), __webpack_require__(/*! strophe.ping */ "strophe.ping")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! converse-core */ "./src/converse-core.js"), __webpack_require__(/*! strophejs-plugin-ping */ "./node_modules/strophejs-plugin-ping/strophe.ping.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
+})(this, function (converse) {
"use strict"; // Strophe methods for building stanzas
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- _ = _converse$env._;
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ _ = _converse$env._;
converse.plugins.add('converse-ping', {
- initialize: function initialize() {
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse;
+ const _converse = this._converse;
_converse.api.settings.update({
ping_interval: 180 //in seconds
@@ -46720,7 +53129,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
_converse.connection.addTimedHandler(1000, function () {
- var now = new Date();
+ const now = new Date();
if (!_converse.lastStanzaDate) {
_converse.lastStanzaDate = now;
@@ -46735,7 +53144,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
};
- var onConnected = function onConnected() {
+ const onConnected = function onConnected() {
// Wrapper so that we can spy on registerPingHandler in tests
_converse.registerPingHandler();
};
@@ -46744,6 +53153,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.on('reconnected', onConnected);
}
+
});
});
@@ -46756,10 +53166,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2013-2017, Jan-Carel Brand
@@ -46772,39 +53179,42 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, bootstrap, _FormData, tpl_alert, tpl_chat_status_modal, tpl_profile_modal, tpl_profile_view, tpl_status_option) {
+})(this, function (converse, bootstrap, _FormData, tpl_alert, tpl_chat_status_modal, tpl_profile_modal, tpl_profile_view, tpl_status_option) {
"use strict";
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- utils = _converse$env.utils,
- _ = _converse$env._,
- moment = _converse$env.moment;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ utils = _converse$env.utils,
+ _ = _converse$env._,
+ moment = _converse$env.moment;
+ const u = converse.env.utils;
converse.plugins.add('converse-profile', {
dependencies: ["converse-modal", "converse-vcard", "converse-chatboxviews"],
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.ProfileModal = _converse.BootstrapModal.extend({
events: {
'click .change-avatar': "openFileSelection",
'change input[type="file"': "updateFilePreview",
'submit .profile-form': 'onFormSubmitted'
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change', this.render, this);
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
_converse.emit('profileModalInitialized', this.model);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_profile_modal(_.extend(this.model.toJSON(), this.model.vcard.toJSON(), {
'_': _,
'__': __,
@@ -46823,33 +53233,29 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'view': this
}));
},
- afterRender: function afterRender() {
- this.tabs = _.map(this.el.querySelectorAll('.nav-item'), function (tab) {
- return new bootstrap.Tab(tab);
- });
+
+ afterRender() {
+ this.tabs = _.map(this.el.querySelectorAll('.nav-item'), tab => new bootstrap.Tab(tab));
},
- openFileSelection: function openFileSelection(ev) {
+
+ openFileSelection(ev) {
ev.preventDefault();
this.el.querySelector('input[type="file"]').click();
},
- updateFilePreview: function updateFilePreview(ev) {
- var _this = this;
- var file = ev.target.files[0],
- reader = new FileReader();
+ updateFilePreview(ev) {
+ const file = ev.target.files[0],
+ reader = new FileReader();
- reader.onloadend = function () {
- _this.el.querySelector('.avatar').setAttribute('src', reader.result);
+ reader.onloadend = () => {
+ this.el.querySelector('.avatar').setAttribute('src', reader.result);
};
reader.readAsDataURL(file);
},
- setVCard: function setVCard(data) {
- var _this2 = this;
- _converse.api.vcard.set(_converse.bare_jid, data).then(function () {
- return _converse.api.vcard.update(_this2.model.vcard, true);
- }).catch(function (err) {
+ setVCard(data) {
+ _converse.api.vcard.set(_converse.bare_jid, data).then(() => _converse.api.vcard.update(this.model.vcard, true)).catch(err => {
_converse.log(err, Strophe.LogLevel.FATAL);
_converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), [__("Sorry, an error happened while trying to save your profile data."), __("You can check your browser's developer console for any error output.")]);
@@ -46857,14 +53263,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.modal.hide();
},
- onFormSubmitted: function onFormSubmitted(ev) {
- var _this3 = this;
+ onFormSubmitted(ev) {
ev.preventDefault();
- var reader = new FileReader(),
- form_data = new FormData(ev.target),
- image_file = form_data.get('image');
- var data = {
+ const reader = new FileReader(),
+ form_data = new FormData(ev.target),
+ image_file = form_data.get('image');
+ const data = {
'fn': form_data.get('fn'),
'nickname': form_data.get('nickname'),
'role': form_data.get('role'),
@@ -46880,25 +53285,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setVCard(data);
} else {
- reader.onloadend = function () {
+ reader.onloadend = () => {
_.extend(data, {
'image': btoa(reader.result),
'image_type': image_file.type
});
- _this3.setVCard(data);
+ this.setVCard(data);
};
reader.readAsBinaryString(image_file);
}
}
+
});
_converse.ChatStatusModal = _converse.BootstrapModal.extend({
events: {
"submit form#set-xmpp-status": "onFormSubmitted",
"click .clear-input": "clearStatusMessage"
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_chat_status_modal(_.extend(this.model.toJSON(), this.model.vcard.toJSON(), {
'label_away': __('Away'),
'label_close': __('Close'),
@@ -46913,31 +53320,33 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'placeholder_status_message': __('Personal status message')
}));
},
- afterRender: function afterRender() {
- var _this4 = this;
- this.el.addEventListener('shown.bs.modal', function () {
- _this4.el.querySelector('input[name="status_message"]').focus();
+ afterRender() {
+ this.el.addEventListener('shown.bs.modal', () => {
+ this.el.querySelector('input[name="status_message"]').focus();
}, false);
},
- clearStatusMessage: function clearStatusMessage(ev) {
+
+ clearStatusMessage(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
u.hideElement(this.el.querySelector('.clear-input'));
}
- var roster_filter = this.el.querySelector('input[name="status_message"]');
+ const roster_filter = this.el.querySelector('input[name="status_message"]');
roster_filter.value = '';
},
- onFormSubmitted: function onFormSubmitted(ev) {
+
+ onFormSubmitted(ev) {
ev.preventDefault();
- var data = new FormData(ev.target);
+ const data = new FormData(ev.target);
this.model.save({
'status_message': data.get('status_message'),
'status': data.get('chat_status')
});
this.modal.hide();
}
+
});
_converse.XMPPStatusView = _converse.VDOMViewWithAvatar.extend({
tagName: "div",
@@ -46946,12 +53355,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
"click a.change-status": "showStatusChangeModal",
"click .logout": "logOut"
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on("change", this.render, this);
this.model.vcard.on("change", this.render, this);
},
- toHTML: function toHTML() {
- var chat_status = this.model.get('status') || 'offline';
+
+ toHTML() {
+ const chat_status = this.model.get('status') || 'offline';
return tpl_profile_view(_.extend(this.model.toJSON(), this.model.vcard.toJSON(), {
'__': __,
'fullname': this.model.vcard.get('fullname') || _converse.bare_jid,
@@ -46964,10 +53375,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'title_your_profile': __('Your profile')
}));
},
- afterRender: function afterRender() {
+
+ afterRender() {
this.renderAvatar();
},
- showProfileModal: function showProfileModal(ev) {
+
+ showProfileModal(ev) {
if (_.isUndefined(this.profile_modal)) {
this.profile_modal = new _converse.ProfileModal({
model: this.model
@@ -46976,7 +53389,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.profile_modal.show(ev);
},
- showStatusChangeModal: function showStatusChangeModal(ev) {
+
+ showStatusChangeModal(ev) {
if (_.isUndefined(this.status_modal)) {
this.status_modal = new _converse.ChatStatusModal({
model: this.model
@@ -46985,15 +53399,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.status_modal.show(ev);
},
- logOut: function logOut(ev) {
+
+ logOut(ev) {
ev.preventDefault();
- var result = confirm(__("Are you sure you want to log out?"));
+ const result = confirm(__("Are you sure you want to log out?"));
if (result === true) {
_converse.logOut();
}
},
- getPrettyStatus: function getPrettyStatus(stat) {
+
+ getPrettyStatus(stat) {
if (stat === 'chat') {
return __('online');
} else if (stat === 'dnd') {
@@ -47008,8 +53424,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return __(stat) || __('online');
}
}
+
});
}
+
});
});
@@ -47022,10 +53440,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// https://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -47039,21 +53454,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
+})(this, function (converse) {
"use strict";
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- $iq = _converse$env.$iq,
- _ = _converse$env._;
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ $iq = _converse$env.$iq,
+ _ = _converse$env._;
Strophe.addNamespace('PUSH', 'urn:xmpp:push:0');
converse.plugins.add('converse-push', {
- initialize: function initialize() {
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.settings.update({
'push_app_servers': [],
@@ -47065,13 +53480,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var result = await _converse.api.disco.supports(Strophe.NS.PUSH, domain || _converse.bare_jid);
+ const result = await _converse.api.disco.supports(Strophe.NS.PUSH, domain || _converse.bare_jid);
if (!result.length) {
- return _converse.log("Not disabling push app server \"".concat(push_app_server.jid, "\", no disco support from your server."), Strophe.LogLevel.WARN);
+ return _converse.log(`Not disabling push app server "${push_app_server.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
}
- var stanza = $iq({
+ const stanza = $iq({
'type': 'set'
});
@@ -47092,8 +53507,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
- _converse.api.sendIQ(stanza).catch(function (e) {
- _converse.log("Could not disable push app server for ".concat(push_app_server.jid), Strophe.LogLevel.ERROR);
+ _converse.api.sendIQ(stanza).catch(e => {
+ _converse.log(`Could not disable push app server for ${push_app_server.jid}`, Strophe.LogLevel.ERROR);
_converse.log(e, Strophe.LogLevel.ERROR);
});
@@ -47104,19 +53519,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var identity = await _converse.api.disco.getIdentity('pubsub', 'push', push_app_server.jid);
+ const identity = await _converse.api.disco.getIdentity('pubsub', 'push', push_app_server.jid);
if (!identity) {
- return _converse.log("Not enabling push the service \"".concat(push_app_server.jid, "\", it doesn't have the right disco identtiy."), Strophe.LogLevel.WARN);
+ return _converse.log(`Not enabling push the service "${push_app_server.jid}", it doesn't have the right disco identtiy.`, Strophe.LogLevel.WARN);
}
- var result = await Promise.all([_converse.api.disco.supports(Strophe.NS.PUSH, push_app_server.jid), _converse.api.disco.supports(Strophe.NS.PUSH, domain)]);
+ const result = await Promise.all([_converse.api.disco.supports(Strophe.NS.PUSH, push_app_server.jid), _converse.api.disco.supports(Strophe.NS.PUSH, domain)]);
if (!result[0].length && !result[1].length) {
- return _converse.log("Not enabling push app server \"".concat(push_app_server.jid, "\", no disco support from your server."), Strophe.LogLevel.WARN);
+ return _converse.log(`Not enabling push app server "${push_app_server.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
}
- var stanza = $iq({
+ const stanza = $iq({
'type': 'set'
});
@@ -47138,7 +53553,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'type': 'submit'
}).c('field', {
'var': 'FORM_TYPE'
- }).c('value').t("".concat(Strophe.NS.PUBSUB, "#publish-options")).up().up().c('field', {
+ }).c('value').t(`${Strophe.NS.PUBSUB}#publish-options`).up().up().c('field', {
'var': 'secret'
}).c('value').t(push_app_server.secret);
}
@@ -47148,13 +53563,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
async function enablePush(domain) {
domain = domain || _converse.bare_jid;
- var push_enabled = _converse.session.get('push_enabled') || [];
+ const push_enabled = _converse.session.get('push_enabled') || [];
if (_.includes(push_enabled, domain)) {
return;
}
- var enabled_services = _.reject(_converse.push_app_servers, 'disable');
+ const enabled_services = _.reject(_converse.push_app_servers, 'disable');
try {
await Promise.all(_.map(enabled_services, _.partial(enablePushAppServer, domain)));
@@ -47166,16 +53581,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
push_enabled.push(domain);
}
- var disabled_services = _.filter(_converse.push_app_servers, 'disable');
+ const disabled_services = _.filter(_converse.push_app_servers, 'disable');
_.each(disabled_services, _.partial(disablePushAppServer, domain));
_converse.session.save('push_enabled', push_enabled);
}
- _converse.api.listen.on('statusInitialized', function () {
- return enablePush();
- });
+ _converse.api.listen.on('statusInitialized', () => enablePush());
function onChatBoxAdded(model) {
if (model.get('type') == _converse.CHATROOMS_TYPE) {
@@ -47184,11 +53597,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
if (_converse.enable_muc_push) {
- _converse.api.listen.on('chatBoxesInitialized', function () {
- return _converse.chatboxes.on('add', onChatBoxAdded);
- });
+ _converse.api.listen.on('chatBoxesInitialized', () => _converse.chatboxes.on('add', onChatBoxAdded));
}
}
+
});
});
@@ -47201,10 +53613,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -47221,19 +53630,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (utils, converse, tpl_form_username, tpl_register_link, tpl_register_panel, tpl_registration_form, tpl_registration_request, tpl_form_input, tpl_spinner) {
+})(this, function (utils, converse, tpl_form_username, tpl_register_link, tpl_register_panel, tpl_registration_form, tpl_registration_request, tpl_form_input, tpl_spinner) {
"use strict"; // Strophe methods for building stanzas
- var _converse$env = converse.env,
- Strophe = _converse$env.Strophe,
- Backbone = _converse$env.Backbone,
- sizzle = _converse$env.sizzle,
- $iq = _converse$env.$iq,
- _ = _converse$env._; // Add Strophe Namespaces
+ const _converse$env = converse.env,
+ Strophe = _converse$env.Strophe,
+ Backbone = _converse$env.Backbone,
+ sizzle = _converse$env.sizzle,
+ $iq = _converse$env.$iq,
+ _ = _converse$env._; // Add Strophe Namespaces
Strophe.addNamespace('REGISTER', 'jabber:iq:register'); // Add Strophe Statuses
- var i = 0;
+ let i = 0;
_.each(_.keys(Strophe.Status), function (key) {
i = Math.max(i, Strophe.Status[key]);
@@ -47251,8 +53660,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//
// New functions which don't exist yet can also be added.
LoginPanel: {
- insertRegisterLink: function insertRegisterLink() {
- var _converse = this.__super__._converse;
+ insertRegisterLink() {
+ const _converse = this.__super__._converse;
if (_.isUndefined(this.registerlinkview)) {
this.registerlinkview = new _converse.RegisterLinkView({
@@ -47264,8 +53673,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.registerlinkview.render();
},
- render: function render(cfg) {
- var _converse = this.__super__._converse;
+
+ render(cfg) {
+ const _converse = this.__super__._converse;
this.__super__.render.apply(this, arguments);
@@ -47275,15 +53685,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
}
+
},
ControlBoxView: {
- initialize: function initialize() {
+ initialize() {
this.__super__.initialize.apply(this, arguments);
this.model.on('change:active-form', this.showLoginOrRegisterForm.bind(this));
},
- showLoginOrRegisterForm: function showLoginOrRegisterForm() {
- var _converse = this.__super__._converse;
+
+ showLoginOrRegisterForm() {
+ const _converse = this.__super__._converse;
if (_.isNil(this.registerpanel)) {
return;
@@ -47297,8 +53709,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.registerpanel.el.classList.add('hidden');
}
},
- renderRegistrationPanel: function renderRegistrationPanel() {
- var _converse = this.__super__._converse;
+
+ renderRegistrationPanel() {
+ const _converse = this.__super__._converse;
if (_converse.allow_registration) {
this.registerpanel = new _converse.RegisterPanel({
@@ -47312,7 +53725,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- renderLoginPanel: function renderLoginPanel() {
+
+ renderLoginPanel() {
/* Also render a registration panel, when rendering the
* login panel.
*/
@@ -47321,14 +53735,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.renderRegistrationPanel();
return this;
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.CONNECTION_STATUS[Strophe.Status.REGIFAIL] = 'REGIFAIL';
_converse.CONNECTION_STATUS[Strophe.Status.REGISTERED] = 'REGISTERED';
_converse.CONNECTION_STATUS[Strophe.Status.CONFLICT] = 'CONFLICT';
@@ -47344,8 +53760,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
function setActiveForm(value) {
- _converse.api.waitUntil('controlboxInitialized').then(function () {
- var controlbox = _converse.chatboxes.get('controlbox');
+ _converse.api.waitUntil('controlboxInitialized').then(() => {
+ const controlbox = _converse.chatboxes.get('controlbox');
controlbox.set({
'active-form': value
@@ -47358,13 +53774,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.router.route('converse/register', _.partial(setActiveForm, 'register'));
_converse.RegisterLinkView = Backbone.VDOMView.extend({
- toHTML: function toHTML() {
+ toHTML() {
return tpl_register_link(_.extend(this.model.toJSON(), {
'__': _converse.__,
'_converse': _converse,
'connection_status': _converse.connfeedback.get('connection_status')
}));
}
+
});
_converse.RegisterPanel = Backbone.NativeView.extend({
tagName: 'div',
@@ -47374,11 +53791,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'submit form#converse-register': 'onFormSubmission',
'click .button-cancel': 'renderProviderChoiceForm'
},
- initialize: function initialize(cfg) {
+
+ initialize(cfg) {
this.reset();
this.registerHooks();
},
- render: function render() {
+
+ render() {
this.model.set('registration_form_rendered', false);
this.el.innerHTML = tpl_register_panel({
'__': __,
@@ -47396,37 +53815,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- registerHooks: function registerHooks() {
- var _this = this;
+ registerHooks() {
/* Hook into Strophe's _connect_cb, so that we can send an IQ
* requesting the registration fields.
*/
- var conn = _converse.connection;
+ const conn = _converse.connection;
- var connect_cb = conn._connect_cb.bind(conn);
+ const connect_cb = conn._connect_cb.bind(conn);
- conn._connect_cb = function (req, callback, raw) {
- if (!_this._registering) {
+ conn._connect_cb = (req, callback, raw) => {
+ if (!this._registering) {
connect_cb(req, callback, raw);
} else {
- if (_this.getRegistrationFields(req, callback, raw)) {
- _this._registering = false;
+ if (this.getRegistrationFields(req, callback, raw)) {
+ this._registering = false;
}
}
};
},
- getRegistrationFields: function getRegistrationFields(req, _callback, raw) {
+
+ getRegistrationFields(req, _callback, raw) {
/* Send an IQ stanza to the XMPP server asking for the
* registration fields.
* Parameters:
* (Strophe.Request) req - The current request
* (Function) callback
*/
- var conn = _converse.connection;
+ const conn = _converse.connection;
conn.connected = true;
- var body = conn._proto._reqToData(req);
+ const body = conn._proto._reqToData(req);
if (!body) {
return;
@@ -47437,8 +53856,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
}
- var register = body.getElementsByTagName("register");
- var mechanisms = body.getElementsByTagName("mechanism");
+ const register = body.getElementsByTagName("register");
+ const mechanisms = body.getElementsByTagName("mechanism");
if (register.length === 0 && mechanisms.length === 0) {
conn._proto._no_auth_received(_callback);
@@ -47456,7 +53875,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
conn._addSysHandler(this.onRegistrationFields.bind(this), null, "iq", null, null);
- var stanza = $iq({
+ const stanza = $iq({
type: "get"
}).c("query", {
xmlns: Strophe.NS.REGISTER
@@ -47466,7 +53885,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
conn.connected = false;
return true;
},
- onRegistrationFields: function onRegistrationFields(stanza) {
+
+ onRegistrationFields(stanza) {
/* Handler for Registration Fields Request.
*
* Parameters:
@@ -47492,8 +53912,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
},
- reset: function reset(settings) {
- var defaults = {
+
+ reset(settings) {
+ const defaults = {
fields: {},
urls: [],
title: "",
@@ -47510,7 +53931,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_.extend(this, _.pick(settings, _.keys(defaults)));
}
},
- onFormSubmission: function onFormSubmission(ev) {
+
+ onFormSubmission(ev) {
/* Event handler when the #converse-register form is
* submitted.
*
@@ -47527,15 +53949,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.onProviderChosen(ev.target);
}
},
- onProviderChosen: function onProviderChosen(form) {
+
+ onProviderChosen(form) {
/* Callback method that gets called when the user has chosen an
* XMPP provider.
*
* Parameters:
* (HTMLElement) form - The form that was submitted
*/
- var domain_input = form.querySelector('input[name=domain]'),
- domain = _.get(domain_input, 'value');
+ const domain_input = form.querySelector('input[name=domain]'),
+ domain = _.get(domain_input, 'value');
if (!domain) {
// TODO: add validation message
@@ -47546,7 +53969,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
form.querySelector('input[type=submit]').classList.add('hidden');
this.fetchRegistrationForm(domain.trim());
},
- fetchRegistrationForm: function fetchRegistrationForm(domain_name) {
+
+ fetchRegistrationForm(domain_name) {
/* This is called with a domain name based on which, it fetches a
* registration form from the requested domain.
*
@@ -47566,7 +53990,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
},
- renderRegistrationRequest: function renderRegistrationRequest() {
+
+ renderRegistrationRequest() {
/* Clear the form and inform the user that the registration
* form is being fetched.
*/
@@ -47575,14 +54000,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'cancel': _converse.registration_domain
}));
},
- giveFeedback: function giveFeedback(message, klass) {
- var feedback = this.el.querySelector('.reg-feedback');
+
+ giveFeedback(message, klass) {
+ let feedback = this.el.querySelector('.reg-feedback');
if (!_.isNull(feedback)) {
feedback.parentNode.removeChild(feedback);
}
- var form = this.el.querySelector('form');
+ const form = this.el.querySelector('form');
form.insertAdjacentHTML('afterbegin', '');
feedback = form.querySelector('.reg-feedback');
feedback.textContent = message;
@@ -47591,19 +54017,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
feedback.classList.add(klass);
}
},
- clearRegistrationForm: function clearRegistrationForm() {
- var form = this.el.querySelector('form');
+
+ clearRegistrationForm() {
+ const form = this.el.querySelector('form');
form.innerHTML = '';
this.model.set('registration_form_rendered', false);
return form;
},
- showSpinner: function showSpinner() {
- var form = this.el.querySelector('form');
+
+ showSpinner() {
+ const form = this.el.querySelector('form');
form.innerHTML = tpl_spinner();
this.model.set('registration_form_rendered', false);
return this;
},
- onConnectStatusChanged: function onConnectStatusChanged(status_code) {
+
+ onConnectStatusChanged(status_code) {
/* Callback function called by Strophe whenever the
* connection status changes.
*
@@ -47616,7 +54045,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.log('converse-register: onConnectStatusChanged');
if (_.includes([Strophe.Status.DISCONNECTED, Strophe.Status.CONNFAIL, Strophe.Status.REGIFAIL, Strophe.Status.NOTACCEPTABLE, Strophe.Status.CONFLICT], status_code)) {
- _converse.log("Problem during registration: Strophe.Status is ".concat(_converse.CONNECTION_STATUS[status_code]), Strophe.LogLevel.ERROR);
+ _converse.log(`Problem during registration: Strophe.Status is ${_converse.CONNECTION_STATUS[status_code]}`, Strophe.LogLevel.ERROR);
this.abortRegistration();
} else if (status_code === Strophe.Status.REGISTERED) {
@@ -47646,13 +54075,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.reset();
}
},
- renderLegacyRegistrationForm: function renderLegacyRegistrationForm(form) {
- var _this2 = this;
- _.each(_.keys(this.fields), function (key) {
+ renderLegacyRegistrationForm(form) {
+ _.each(_.keys(this.fields), key => {
if (key === "username") {
form.insertAdjacentHTML('beforeend', tpl_form_username({
- 'domain': " @".concat(_this2.domain),
+ 'domain': ` @${this.domain}`,
'name': key,
'type': "text",
'label': key,
@@ -47672,20 +54100,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}); // Show urls
- _.each(this.urls, function (url) {
+ _.each(this.urls, url => {
form.insertAdjacentHTML('afterend', '' + url + '');
});
},
- renderRegistrationForm: function renderRegistrationForm(stanza) {
- var _this3 = this;
+ renderRegistrationForm(stanza) {
/* Renders the registration form based on the XForm fields
* received from the XMPP server.
*
* Parameters:
* (XMLElement) stanza - The IQ stanza received from the XMPP server.
*/
- var form = this.el.querySelector('form');
+ const form = this.el.querySelector('form');
form.innerHTML = tpl_registration_form({
'__': _converse.__,
'domain': this.domain,
@@ -47693,11 +54120,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'instructions': this.instructions,
'registration_domain': _converse.registration_domain
});
- var buttons = form.querySelector('fieldset.buttons');
+ const buttons = form.querySelector('fieldset.buttons');
if (this.form_type === 'xform') {
- _.each(stanza.querySelectorAll('field'), function (field) {
- buttons.insertAdjacentHTML('beforebegin', utils.xForm2webForm(field, stanza, _this3.domain));
+ _.each(stanza.querySelectorAll('field'), field => {
+ buttons.insertAdjacentHTML('beforebegin', utils.xForm2webForm(field, stanza, this.domain));
});
} else {
this.renderLegacyRegistrationForm(form);
@@ -47710,13 +54137,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
form.classList.remove('hidden');
this.model.set('registration_form_rendered', true);
},
- showValidationError: function showValidationError(message) {
- var form = this.el.querySelector('form');
- var flash = form.querySelector('.form-errors');
+
+ showValidationError(message) {
+ const form = this.el.querySelector('form');
+ let flash = form.querySelector('.form-errors');
if (_.isNull(flash)) {
flash = '';
- var instructions = form.querySelector('p.instructions');
+ const instructions = form.querySelector('p.instructions');
if (_.isNull(instructions)) {
form.insertAdjacentHTML('afterbegin', flash);
@@ -47732,9 +54160,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
flash.insertAdjacentHTML('beforeend', '
' + message + '
');
flash.classList.remove('hidden');
},
- reportErrors: function reportErrors(stanza) {
- var _this4 = this;
+ reportErrors(stanza) {
/* Report back to the user any error messages received from the
* XMPP server after attempted registration.
*
@@ -47742,19 +54169,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (XMLElement) stanza - The IQ stanza received from the
* XMPP server.
*/
- var errors = stanza.querySelectorAll('error');
+ const errors = stanza.querySelectorAll('error');
- _.each(errors, function (error) {
- _this4.showValidationError(error.textContent);
+ _.each(errors, error => {
+ this.showValidationError(error.textContent);
});
if (!errors.length) {
- var message = __('The provider rejected your registration attempt. ' + 'Please check the values you entered for correctness.');
+ const message = __('The provider rejected your registration attempt. ' + 'Please check the values you entered for correctness.');
this.showValidationError(message);
}
},
- renderProviderChoiceForm: function renderProviderChoiceForm(ev) {
+
+ renderProviderChoiceForm(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -47765,7 +54193,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.render();
},
- abortRegistration: function abortRegistration() {
+
+ abortRegistration() {
_converse.connection._proto._abortAllRequests();
_converse.connection.reset();
@@ -47778,7 +54207,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.render();
}
},
- submitRegistrationForm: function submitRegistrationForm(form) {
+
+ submitRegistrationForm(form) {
/* Handler, when the user submits the registration form.
* Provides form error feedback or starts the registration
* process.
@@ -47786,7 +54216,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* Parameters:
* (HTMLElement) form - The HTML form that was submitted
*/
- var has_empty_inputs = _.reduce(this.el.querySelectorAll('input.required'), function (result, input) {
+ const has_empty_inputs = _.reduce(this.el.querySelectorAll('input.required'), function (result, input) {
if (input.value === '') {
input.classList.add('error');
return result + 1;
@@ -47799,8 +54229,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var inputs = sizzle(':input:not([type=button]):not([type=submit])', form),
- iq = $iq({
+ const inputs = sizzle(':input:not([type=button]):not([type=submit])', form),
+ iq = $iq({
'type': 'set',
'id': _converse.connection.getUniqueId()
}).c("query", {
@@ -47813,11 +54243,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
type: 'submit'
});
- _.each(inputs, function (input) {
+ _.each(inputs, input => {
iq.cnode(utils.webForm2xForm(input)).up();
});
} else {
- _.each(inputs, function (input) {
+ _.each(inputs, input => {
iq.c(input.getAttribute('name'), {}, input.value);
});
}
@@ -47828,15 +54258,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.setFields(iq.tree());
},
- setFields: function setFields(stanza) {
+
+ setFields(stanza) {
/* Stores the values that will be sent to the XMPP server
* during attempted registration.
*
* Parameters:
* (XMLElement) stanza - the IQ stanza that will be sent to the XMPP server.
*/
- var query = stanza.querySelector('query');
- var xform = sizzle("x[xmlns=\"".concat(Strophe.NS.XFORM, "\"]"), query);
+ const query = stanza.querySelector('query');
+ const xform = sizzle(`x[xmlns="${Strophe.NS.XFORM}"]`, query);
if (xform.length > 0) {
this._setFieldsFromXForm(xform.pop());
@@ -47844,37 +54275,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this._setFieldsFromLegacy(query);
}
},
- _setFieldsFromLegacy: function _setFieldsFromLegacy(query) {
- var _this5 = this;
- _.each(query.children, function (field) {
+ _setFieldsFromLegacy(query) {
+ _.each(query.children, field => {
if (field.tagName.toLowerCase() === 'instructions') {
- _this5.instructions = Strophe.getText(field);
+ this.instructions = Strophe.getText(field);
return;
} else if (field.tagName.toLowerCase() === 'x') {
if (field.getAttribute('xmlns') === 'jabber:x:oob') {
- _this5.urls.concat(_.map(field.querySelectorAll('url'), 'textContent'));
+ this.urls.concat(_.map(field.querySelectorAll('url'), 'textContent'));
}
return;
}
- _this5.fields[field.tagName.toLowerCase()] = Strophe.getText(field);
+ this.fields[field.tagName.toLowerCase()] = Strophe.getText(field);
});
this.form_type = 'legacy';
},
- _setFieldsFromXForm: function _setFieldsFromXForm(xform) {
- var _this6 = this;
+ _setFieldsFromXForm(xform) {
this.title = _.get(xform.querySelector('title'), 'textContent');
this.instructions = _.get(xform.querySelector('instructions'), 'textContent');
- _.each(xform.querySelectorAll('field'), function (field) {
- var _var = field.getAttribute('var');
+ _.each(xform.querySelectorAll('field'), field => {
+ const _var = field.getAttribute('var');
if (_var) {
- _this6.fields[_var.toLowerCase()] = _.get(field.querySelector('value'), 'textContent', '');
+ this.fields[_var.toLowerCase()] = _.get(field.querySelector('value'), 'textContent', '');
} else {
// TODO: other option seems to be type="fixed"
_converse.log("Found field we couldn't parse", Strophe.LogLevel.WARN);
@@ -47883,7 +54312,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.form_type = 'xform';
},
- _onRegisterIQ: function _onRegisterIQ(stanza) {
+
+ _onRegisterIQ(stanza) {
/* Callback method that gets called when a return IQ stanza
* is received from the XMPP server, after attempting to
* register a new user.
@@ -47895,7 +54325,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.log("Registration failed.", Strophe.LogLevel.ERROR);
this.reportErrors(stanza);
- var error = stanza.getElementsByTagName("error");
+ let error = stanza.getElementsByTagName("error");
if (error.length !== 1) {
_converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, "unknown");
@@ -47918,8 +54348,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
}
+
});
}
+
});
});
@@ -47932,10 +54364,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// Copyright (c) 2012-2017, Jan-Carel Brand
@@ -47952,15 +54381,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, muc, tpl_rooms_list, tpl_rooms_list_item) {
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- b64_sha1 = _converse$env.b64_sha1,
- sizzle = _converse$env.sizzle,
- _ = _converse$env._;
- var u = converse.env.utils;
+})(this, function (converse, muc, tpl_rooms_list, tpl_rooms_list_item) {
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ b64_sha1 = _converse$env.b64_sha1,
+ sizzle = _converse$env.sizzle,
+ _ = _converse$env._;
+ const u = converse.env.utils;
converse.plugins.add('converse-roomslist', {
/* Optional dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before
@@ -47975,16 +54404,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* NB: These plugins need to have already been loaded via require.js.
*/
dependencies: ["converse-singleton", "converse-controlbox", "converse-muc", "converse-bookmarks"],
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.OpenRooms = Backbone.Collection.extend({
- comparator: function comparator(room) {
+ comparator(room) {
if (room.get('bookmarked')) {
- var bookmark = _.head(_converse.bookmarksview.model.where({
+ const bookmark = _.head(_converse.bookmarksview.model.where({
'jid': room.get('jid')
}));
@@ -47993,7 +54423,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return room.get('name');
}
},
- initialize: function initialize() {
+
+ initialize() {
_converse.chatboxes.on('add', this.onChatBoxAdded, this);
_converse.chatboxes.on('change:hidden', this.onChatBoxChanged, this);
@@ -48012,26 +54443,30 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'type': 'chatroom'
}), 'attributes'));
},
- onChatBoxAdded: function onChatBoxAdded(item) {
+
+ onChatBoxAdded(item) {
if (item.get('type') === 'chatroom') {
this.create(item.attributes);
}
},
- onChatBoxChanged: function onChatBoxChanged(item) {
+
+ onChatBoxChanged(item) {
if (item.get('type') === 'chatroom') {
- var room = this.get(item.get('jid'));
+ const room = this.get(item.get('jid'));
if (!_.isNil(room)) {
room.set(item.attributes);
}
}
},
- onChatBoxRemoved: function onChatBoxRemoved(item) {
+
+ onChatBoxRemoved(item) {
if (item.get('type') === 'chatroom') {
- var room = this.get(item.get('jid'));
+ const room = this.get(item.get('jid'));
this.remove(room);
}
}
+
});
_converse.RoomsList = Backbone.Model.extend({
defaults: {
@@ -48042,7 +54477,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
events: {
'click .room-info': 'showRoomDetailsModal'
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('destroy', this.remove, this);
this.model.on('remove', this.remove, this);
this.model.on('change:bookmarked', this.render, this);
@@ -48051,7 +54487,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.on('change:num_unread', this.render, this);
this.model.on('change:num_unread_general', this.render, this);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_rooms_list_item(_.extend(this.model.toJSON(), {
// XXX: By the time this renders, the _converse.bookmarks
// collection should already exist if bookmarks are
@@ -48067,8 +54504,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'open_title': __('Click to open this groupchat')
}));
},
- showRoomDetailsModal: function showRoomDetailsModal(ev) {
- var room = _converse.chatboxes.get(this.model.get('jid'));
+
+ showRoomDetailsModal(ev) {
+ const room = _converse.chatboxes.get(this.model.get('jid'));
ev.preventDefault();
@@ -48080,9 +54518,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
room.room_details_modal.show(ev);
},
- getRoomsListElementName: function getRoomsListElementName() {
+
+ getRoomsListElementName() {
if (this.model.get('bookmarked') && _converse.bookmarksview) {
- var bookmark = _.head(_converse.bookmarksview.model.where({
+ const bookmark = _.head(_converse.bookmarksview.model.where({
'jid': this.model.get('jid')
}));
@@ -48091,6 +54530,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.model.get('name');
}
}
+
});
_converse.RoomsListView = Backbone.OrderedListView.extend({
tagName: 'div',
@@ -48105,13 +54545,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
listSelector: '.rooms-list',
ItemView: _converse.RoomsListElementView,
subviewIndex: 'jid',
- initialize: function initialize() {
+
+ initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.showOrHide, this);
this.model.on('remove', this.showOrHide, this);
- var storage = _converse.config.get('storage'),
- id = b64_sha1("converse.roomslist".concat(_converse.bare_jid));
+ const storage = _converse.config.get('storage'),
+ id = b64_sha1(`converse.roomslist${_converse.bare_jid}`);
this.list_model = new _converse.RoomsList({
'id': id
@@ -48121,7 +54562,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.render();
this.sortAndPositionAllItems();
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_rooms_list({
'toggle_state': this.list_model.get('toggle-state'),
'desc_rooms': __('Click to toggle the list of open groupchats'),
@@ -48137,87 +54579,92 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertIntoControlBox();
return this;
},
- insertIntoControlBox: function insertIntoControlBox() {
- var controlboxview = _converse.chatboxviews.get('controlbox');
+
+ insertIntoControlBox() {
+ const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview) && !u.rootContains(_converse.root, this.el)) {
- var el = controlboxview.el.querySelector('.open-rooms-list');
+ const el = controlboxview.el.querySelector('.open-rooms-list');
if (!_.isNull(el)) {
el.parentNode.replaceChild(this.el, el);
}
}
},
- hide: function hide() {
+
+ hide() {
u.hideElement(this.el);
},
- show: function show() {
+
+ show() {
u.showElement(this.el);
},
- openRoom: function openRoom(ev) {
+
+ openRoom(ev) {
ev.preventDefault();
- var name = ev.target.textContent;
- var jid = ev.target.getAttribute('data-room-jid');
- var data = {
+ const name = ev.target.textContent;
+ const jid = ev.target.getAttribute('data-room-jid');
+ const data = {
'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)) || jid
};
_converse.api.rooms.open(jid, data);
},
- closeRoom: function closeRoom(ev) {
+
+ closeRoom(ev) {
ev.preventDefault();
- var name = ev.target.getAttribute('data-room-name');
- var jid = ev.target.getAttribute('data-room-jid');
+ const name = ev.target.getAttribute('data-room-name');
+ const jid = ev.target.getAttribute('data-room-jid');
if (confirm(__("Are you sure you want to leave the groupchat %1$s?", name))) {
// TODO: replace with API call
_converse.chatboxviews.get(jid).close();
}
},
- showOrHide: function showOrHide(item) {
+
+ showOrHide(item) {
if (!this.model.models.length) {
u.hideElement(this.el);
} else {
u.showElement(this.el);
}
},
+
removeBookmark: _converse.removeBookmarkViaEvent,
addBookmark: _converse.addBookmarkViaEvent,
- toggleRoomsList: function toggleRoomsList(ev) {
- var _this = this;
+ toggleRoomsList(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var icon_el = ev.target.querySelector('.fa');
+ const icon_el = ev.target.querySelector('.fa');
if (icon_el.classList.contains("fa-caret-down")) {
- u.slideIn(this.el.querySelector('.open-rooms-list')).then(function () {
- _this.list_model.save({
+ u.slideIn(this.el.querySelector('.open-rooms-list')).then(() => {
+ this.list_model.save({
'toggle-state': _converse.CLOSED
});
-
icon_el.classList.remove("fa-caret-down");
icon_el.classList.add("fa-caret-right");
});
} else {
- u.slideOut(this.el.querySelector('.open-rooms-list')).then(function () {
- _this.list_model.save({
+ u.slideOut(this.el.querySelector('.open-rooms-list')).then(() => {
+ this.list_model.save({
'toggle-state': _converse.OPENED
});
-
icon_el.classList.remove("fa-caret-right");
icon_el.classList.add("fa-caret-down");
});
}
}
+
});
- var initRoomsListView = function initRoomsListView() {
- var storage = _converse.config.get('storage'),
- id = b64_sha1("converse.open-rooms-{_converse.bare_jid}"),
- model = new _converse.OpenRooms();
+ const initRoomsListView = function initRoomsListView() {
+ const storage = _converse.config.get('storage'),
+ id = b64_sha1(`converse.open-rooms-{_converse.bare_jid}`),
+ model = new _converse.OpenRooms();
model.browserStorage = new Backbone.BrowserStorage[storage](id);
_converse.rooms_list_view = new _converse.RoomsListView({
@@ -48248,6 +54695,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.api.listen.on('reconnected', initRoomsListView);
}
+
});
});
@@ -48260,12 +54708,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -48275,28 +54718,29 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
+})(this, function (converse) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- $iq = _converse$env.$iq,
- $pres = _converse$env.$pres,
- b64_sha1 = _converse$env.b64_sha1,
- moment = _converse$env.moment,
- sizzle = _converse$env.sizzle,
- _ = _converse$env._;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ $iq = _converse$env.$iq,
+ $pres = _converse$env.$pres,
+ b64_sha1 = _converse$env.b64_sha1,
+ moment = _converse$env.moment,
+ sizzle = _converse$env.sizzle,
+ _ = _converse$env._;
+ const u = converse.env.utils;
converse.plugins.add('converse-roster', {
dependencies: ["converse-vcard"],
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.settings.update({
'allow_contact_requests': true,
@@ -48320,26 +54764,24 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/* Initialize the Bakcbone collections that represent the contats
* roster and the roster groups.
*/
- var storage = _converse.config.get('storage');
+ const storage = _converse.config.get('storage');
_converse.roster = new _converse.RosterContacts();
- _converse.roster.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1("converse.contacts-".concat(_converse.bare_jid)));
+ _converse.roster.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1(`converse.contacts-${_converse.bare_jid}`));
_converse.roster.data = new Backbone.Model();
- var id = b64_sha1("converse-roster-model-".concat(_converse.bare_jid));
+ const id = b64_sha1(`converse-roster-model-${_converse.bare_jid}`);
_converse.roster.data.id = id;
_converse.roster.data.browserStorage = new Backbone.BrowserStorage[storage](id);
_converse.roster.data.fetch();
_converse.rostergroups = new _converse.RosterGroups();
- _converse.rostergroups.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1("converse.roster.groups".concat(_converse.bare_jid)));
+ _converse.rostergroups.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1(`converse.roster.groups${_converse.bare_jid}`));
_converse.emit('rosterInitialized');
};
- _converse.populateRoster = function () {
- var ignore_cache = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
-
+ _converse.populateRoster = function (ignore_cache = false) {
/* Fetch all the roster groups, and then the roster contacts.
* Emit an event after fetching is done in each case.
*
@@ -48351,25 +54793,25 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
if (ignore_cache) {
_converse.send_initial_presence = true;
- _converse.roster.fetchFromServer().then(function () {
+ _converse.roster.fetchFromServer().then(() => {
_converse.emit('rosterContactsFetched');
_converse.sendInitialPresence();
- }).catch(function (reason) {
+ }).catch(reason => {
_converse.log(reason, Strophe.LogLevel.ERROR);
_converse.sendInitialPresence();
});
} else {
- _converse.rostergroups.fetchRosterGroups().then(function () {
+ _converse.rostergroups.fetchRosterGroups().then(() => {
_converse.emit('rosterGroupsFetched');
return _converse.roster.fetchRosterContacts();
- }).then(function () {
+ }).then(() => {
_converse.emit('rosterContactsFetched');
_converse.sendInitialPresence();
- }).catch(function (reason) {
+ }).catch(reason => {
_converse.log(reason, Strophe.LogLevel.ERROR);
_converse.sendInitialPresence();
@@ -48378,52 +54820,54 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
};
_converse.Presence = Backbone.Model.extend({
- defaults: function defaults() {
+ defaults() {
return {
'show': 'offline',
'resources': {}
};
},
- getHighestPriorityResource: function getHighestPriorityResource() {
+
+ getHighestPriorityResource() {
/* Return the resource with the highest priority.
*
* If multiple resources have the same priority, take the
* latest one.
*/
- var resources = this.get('resources');
+ const resources = this.get('resources');
if (_.isObject(resources) && _.size(resources)) {
- var val = _.flow(_.values, _.partial(_.sortBy, _, ['priority', 'timestamp']), _.reverse)(resources)[0];
+ const val = _.flow(_.values, _.partial(_.sortBy, _, ['priority', 'timestamp']), _.reverse)(resources)[0];
if (!_.isUndefined(val)) {
return val;
}
}
},
- addResource: function addResource(presence) {
+
+ addResource(presence) {
/* Adds a new resource and it's associated attributes as taken
* from the passed in presence stanza.
*
* Also updates the presence if the resource has higher priority (and is newer).
*/
- var jid = presence.getAttribute('from'),
- show = _.propertyOf(presence.querySelector('show'))('textContent') || 'online',
- resource = Strophe.getResourceFromJid(jid),
- delay = sizzle("delay[xmlns=\"".concat(Strophe.NS.DELAY, "\"]"), presence).pop(),
- timestamp = _.isNil(delay) ? moment().format() : moment(delay.getAttribute('stamp')).format();
- var priority = _.propertyOf(presence.querySelector('priority'))('textContent') || 0;
+ const jid = presence.getAttribute('from'),
+ show = _.propertyOf(presence.querySelector('show'))('textContent') || 'online',
+ resource = Strophe.getResourceFromJid(jid),
+ delay = sizzle(`delay[xmlns="${Strophe.NS.DELAY}"]`, presence).pop(),
+ timestamp = _.isNil(delay) ? moment().format() : moment(delay.getAttribute('stamp')).format();
+ let priority = _.propertyOf(presence.querySelector('priority'))('textContent') || 0;
priority = _.isNaN(parseInt(priority, 10)) ? 0 : parseInt(priority, 10);
- var resources = _.isObject(this.get('resources')) ? this.get('resources') : {};
+ const resources = _.isObject(this.get('resources')) ? this.get('resources') : {};
resources[resource] = {
'name': resource,
'priority': priority,
'show': show,
'timestamp': timestamp
};
- var changed = {
+ const changed = {
'resources': resources
};
- var hpr = this.getHighestPriorityResource();
+ const hpr = this.getHighestPriorityResource();
if (priority == hpr.priority && timestamp == hpr.timestamp) {
// Only set the "global" presence if this is the newest resource
@@ -48434,13 +54878,14 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.save(changed);
return resources;
},
- removeResource: function removeResource(resource) {
+
+ removeResource(resource) {
/* Remove the passed in resource from the resources map.
*
* Also redetermines the presence given that there's one less
* resource.
*/
- var resources = this.get('resources');
+ let resources = this.get('resources');
if (!_.isObject(resources)) {
resources = {};
@@ -48453,31 +54898,35 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'show': _.propertyOf(this.getHighestPriorityResource())('show') || 'offline'
});
}
+
});
_converse.Presences = Backbone.Collection.extend({
model: _converse.Presence
});
_converse.ModelWithVCardAndPresence = Backbone.Model.extend({
- initialize: function initialize() {
+ initialize() {
this.setVCard();
this.setPresence();
},
- setVCard: function setVCard() {
- var jid = this.get('jid');
+
+ setVCard() {
+ const jid = this.get('jid');
this.vcard = _converse.vcards.findWhere({
'jid': jid
}) || _converse.vcards.create({
'jid': jid
});
},
- setPresence: function setPresence() {
- var jid = this.get('jid');
+
+ setPresence() {
+ const jid = this.get('jid');
this.presence = _converse.presences.findWhere({
'jid': jid
}) || _converse.presences.create({
'jid': jid
});
}
+
});
_converse.RosterContact = _converse.ModelWithVCardAndPresence.extend({
defaults: {
@@ -48487,14 +54936,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'num_unread': 0,
'status': ''
},
- initialize: function initialize(attributes) {
- var _this = this;
+ initialize(attributes) {
_converse.ModelWithVCardAndPresence.prototype.initialize.apply(this, arguments);
- var jid = attributes.jid,
- bare_jid = Strophe.getBareJidFromJid(jid).toLowerCase(),
- resource = Strophe.getResourceFromJid(jid);
+ const jid = attributes.jid,
+ bare_jid = Strophe.getBareJidFromJid(jid).toLowerCase(),
+ resource = Strophe.getResourceFromJid(jid);
attributes.jid = bare_jid;
this.set(_.assignIn({
'groups': [],
@@ -48503,15 +54951,11 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'user_id': Strophe.getNodeFromJid(jid)
}, attributes));
this.setChatBox();
- this.presence.on('change:show', function () {
- return _converse.emit('contactPresenceChanged', _this);
- });
- this.presence.on('change:show', function () {
- return _this.trigger('presenceChanged');
- });
+ this.presence.on('change:show', () => _converse.emit('contactPresenceChanged', this));
+ this.presence.on('change:show', () => this.trigger('presenceChanged'));
},
- setChatBox: function setChatBox() {
- var chatbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
+
+ setChatBox(chatbox = null) {
chatbox = chatbox || _converse.chatboxes.get(this.get('jid'));
if (chatbox) {
@@ -48519,20 +54963,23 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.chatbox.on('change:hidden', this.render, this);
}
},
- getDisplayName: function getDisplayName() {
+
+ getDisplayName() {
return this.get('nickname') || this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid');
},
- getFullname: function getFullname() {
+
+ getFullname() {
return this.vcard.get('fullname');
},
- subscribe: function subscribe(message) {
+
+ subscribe(message) {
/* Send a presence subscription request to this roster contact
*
* Parameters:
* (String) message - An optional message to explain the
* reason for the subscription request.
*/
- var pres = $pres({
+ const pres = $pres({
to: this.get('jid'),
type: "subscribe"
});
@@ -48541,7 +54988,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
pres.c("status").t(message).up();
}
- var nick = _converse.xmppstatus.vcard.get('nickname') || _converse.xmppstatus.vcard.get('fullname');
+ const nick = _converse.xmppstatus.vcard.get('nickname') || _converse.xmppstatus.vcard.get('fullname');
if (nick) {
pres.c('nick', {
@@ -48555,7 +55002,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this;
},
- ackSubscribe: function ackSubscribe() {
+
+ ackSubscribe() {
/* Upon receiving the presence stanza of type "subscribed",
* the user SHOULD acknowledge receipt of that subscription
* state notification by sending a presence stanza of type
@@ -48566,7 +55014,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'to': this.get('jid')
}));
},
- ackUnsubscribe: function ackUnsubscribe() {
+
+ ackUnsubscribe() {
/* Upon receiving the presence stanza of type "unsubscribed",
* the user SHOULD acknowledge receipt of that subscription state
* notification by sending a presence stanza of type "unsubscribe"
@@ -48583,7 +55032,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.removeFromRoster();
this.destroy();
},
- unauthorize: function unauthorize(message) {
+
+ unauthorize(message) {
/* Unauthorize this contact's presence subscription
* Parameters:
* (String) message - Optional message to send to the person being unauthorized
@@ -48592,12 +55042,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this;
},
- authorize: function authorize(message) {
+
+ authorize(message) {
/* Authorize presence subscription
* Parameters:
* (String) message - Optional message to send to the person being authorized
*/
- var pres = $pres({
+ const pres = $pres({
'to': this.get('jid'),
'type': "subscribed"
});
@@ -48610,12 +55061,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this;
},
- removeFromRoster: function removeFromRoster(callback, errback) {
+
+ removeFromRoster(callback, errback) {
/* Instruct the XMPP server to remove this contact from our roster
* Parameters:
* (Function) callback
*/
- var iq = $iq({
+ const iq = $iq({
type: 'set'
}).c('query', {
xmlns: Strophe.NS.ROSTER
@@ -48628,22 +55080,25 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return this;
}
+
});
_converse.RosterContacts = Backbone.Collection.extend({
model: _converse.RosterContact,
- comparator: function comparator(contact1, contact2) {
- var status1 = contact1.presence.get('show') || 'offline';
- var status2 = contact2.presence.get('show') || 'offline';
+
+ comparator(contact1, contact2) {
+ const status1 = contact1.presence.get('show') || 'offline';
+ const status2 = contact2.presence.get('show') || 'offline';
if (_converse.STATUS_WEIGHTS[status1] === _converse.STATUS_WEIGHTS[status2]) {
- var name1 = contact1.getDisplayName().toLowerCase();
- var name2 = contact2.getDisplayName().toLowerCase();
+ const name1 = contact1.getDisplayName().toLowerCase();
+ const name2 = contact2.getDisplayName().toLowerCase();
return name1 < name2 ? -1 : name1 > name2 ? 1 : 0;
} else {
return _converse.STATUS_WEIGHTS[status1] < _converse.STATUS_WEIGHTS[status2] ? -1 : 1;
}
},
- onConnected: function onConnected() {
+
+ onConnected() {
/* Called as soon as the connection has been established
* (either after initial login, or after reconnection).
*
@@ -48652,21 +55107,23 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.registerRosterHandler();
this.registerRosterXHandler();
},
- registerRosterHandler: function registerRosterHandler() {
+
+ registerRosterHandler() {
/* Register a handler for roster IQ "set" stanzas, which update
* roster contacts.
*/
- _converse.connection.addHandler(function (iq) {
+ _converse.connection.addHandler(iq => {
_converse.roster.onRosterPush(iq);
return true;
}, Strophe.NS.ROSTER, 'iq', "set");
},
- registerRosterXHandler: function registerRosterXHandler() {
+
+ registerRosterXHandler() {
/* Register a handler for RosterX message stanzas, which are
* used to suggest roster contacts to a user.
*/
- var t = 0;
+ let t = 0;
_converse.connection.addHandler(function (msg) {
window.setTimeout(function () {
@@ -48678,9 +55135,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return true;
}, Strophe.NS.ROSTERX, 'message', null);
},
- fetchRosterContacts: function fetchRosterContacts() {
- var _this2 = this;
+ fetchRosterContacts() {
/* Fetches the roster contacts, first by trying the
* sessionStorage cache, and if that's empty, then by querying
* the XMPP server.
@@ -48688,12 +55144,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* Returns a promise which resolves once the contacts have been
* fetched.
*/
- var that = this;
- return new Promise(function (resolve, reject) {
- _this2.fetch({
+ const that = this;
+ return new Promise((resolve, reject) => {
+ this.fetch({
'add': true,
'silent': true,
- success: function success(collection) {
+
+ success(collection) {
if (collection.length === 0 || that.rosterVersioningSupported() && !_converse.session.get('roster_fetched')) {
_converse.send_initial_presence = true;
@@ -48704,10 +55161,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
resolve();
}
}
+
});
});
},
- subscribeToSuggestedItems: function subscribeToSuggestedItems(msg) {
+
+ subscribeToSuggestedItems(msg) {
_.each(msg.querySelectorAll('item'), function (item) {
if (item.getAttribute('action') === 'add') {
_converse.roster.addAndSubscribe(item.getAttribute('jid'), _converse.xmppstatus.vcard.get('nickname') || _converse.xmppstatus.vcard.get('fullname'));
@@ -48716,10 +55175,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return true;
},
- isSelf: function isSelf(jid) {
+
+ isSelf(jid) {
return u.isSameBareJID(jid, _converse.connection.jid);
},
- addAndSubscribe: function addAndSubscribe(jid, name, groups, message, attributes) {
+
+ addAndSubscribe(jid, name, groups, message, attributes) {
/* Add a roster contact and then once we have confirmation from
* the XMPP server we subscribe to that contact's presence updates.
* Parameters:
@@ -48730,15 +55191,16 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* reason for the subscription request.
* (Object) attributes - Any additional attributes to be stored on the user's model.
*/
- var handler = function handler(contact) {
- if (_instanceof(contact, _converse.RosterContact)) {
+ const handler = contact => {
+ if (contact instanceof _converse.RosterContact) {
contact.subscribe(message);
}
};
this.addContactToRoster(jid, name, groups, attributes).then(handler, handler);
},
- sendContactAddIQ: function sendContactAddIQ(jid, name, groups, callback, errback) {
+
+ sendContactAddIQ(jid, name, groups, callback, errback) {
/* Send an IQ stanza to the XMPP server to add a new roster contact.
*
* Parameters:
@@ -48749,13 +55211,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* (Function) errback - A function to call if an error occurred
*/
name = _.isEmpty(name) ? jid : name;
- var iq = $iq({
+ const iq = $iq({
type: 'set'
}).c('query', {
xmlns: Strophe.NS.ROSTER
}).c('item', {
- jid: jid,
- name: name
+ jid,
+ name
});
_.each(groups, function (group) {
@@ -48764,9 +55226,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.connection.sendIQ(iq, callback, errback);
},
- addContactToRoster: function addContactToRoster(jid, name, groups, attributes) {
- var _this3 = this;
+ addContactToRoster(jid, name, groups, attributes) {
/* Adds a RosterContact instance to _converse.roster and
* registers the contact on the XMPP server.
* Returns a promise which is resolved once the XMPP server has
@@ -48778,21 +55239,19 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* (Array of Strings) groups - Any roster groups the user might belong to
* (Object) attributes - Any additional attributes to be stored on the user's model.
*/
- return new Promise(function (resolve, reject) {
+ return new Promise((resolve, reject) => {
groups = groups || [];
-
- _this3.sendContactAddIQ(jid, name, groups, function () {
- var contact = _this3.create(_.assignIn({
+ this.sendContactAddIQ(jid, name, groups, () => {
+ const contact = this.create(_.assignIn({
'ask': undefined,
'nickname': name,
- groups: groups,
- jid: jid,
+ groups,
+ jid,
'requesting': false,
'subscription': 'none'
}, attributes), {
sort: false
});
-
resolve(contact);
}, function (err) {
alert(__('Sorry, there was an error while trying to add %1$s as a contact.', name));
@@ -48803,48 +55262,49 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
});
},
- subscribeBack: function subscribeBack(bare_jid, presence) {
- var contact = this.get(bare_jid);
- if (_instanceof(contact, _converse.RosterContact)) {
+ subscribeBack(bare_jid, presence) {
+ const contact = this.get(bare_jid);
+
+ if (contact instanceof _converse.RosterContact) {
contact.authorize().subscribe();
} else {
// Can happen when a subscription is retried or roster was deleted
- var handler = function handler(contact) {
- if (_instanceof(contact, _converse.RosterContact)) {
+ const handler = contact => {
+ if (contact instanceof _converse.RosterContact) {
contact.authorize().subscribe();
}
};
- var nickname = _.get(sizzle("nick[xmlns=\"".concat(Strophe.NS.NICK, "\"]"), presence).pop(), 'textContent', null);
+ const nickname = _.get(sizzle(`nick[xmlns="${Strophe.NS.NICK}"]`, presence).pop(), 'textContent', null);
this.addContactToRoster(bare_jid, nickname, [], {
'subscription': 'from'
}).then(handler, handler);
}
},
- getNumOnlineContacts: function getNumOnlineContacts() {
- var ignored = ['offline', 'unavailable'];
+
+ getNumOnlineContacts() {
+ let ignored = ['offline', 'unavailable'];
if (_converse.show_only_online_users) {
ignored = _.union(ignored, ['dnd', 'xa', 'away']);
}
- return _.sum(this.models.filter(function (model) {
- return !_.includes(ignored, model.presence.get('show'));
- }));
+ return _.sum(this.models.filter(model => !_.includes(ignored, model.presence.get('show'))));
},
- onRosterPush: function onRosterPush(iq) {
+
+ onRosterPush(iq) {
/* Handle roster updates from the XMPP server.
* See: https://xmpp.org/rfcs/rfc6121.html#roster-syntax-actions-push
*
* Parameters:
* (XMLElement) IQ - The IQ stanza received from the XMPP server.
*/
- var id = iq.getAttribute('id');
- var from = iq.getAttribute('from');
+ const id = iq.getAttribute('id');
+ const from = iq.getAttribute('from');
- if (from && from !== _converse.connection.jid) {
+ if (from && from !== _converse.bare_jid) {
// https://tools.ietf.org/html/rfc6121#page-15
//
// A receiving client MUST ignore the stanza unless it has no 'from'
@@ -48856,13 +55316,13 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.connection.send($iq({
type: 'result',
- id: id,
+ id,
from: _converse.connection.jid
}));
- var query = sizzle("query[xmlns=\"".concat(Strophe.NS.ROSTER, "\"]"), iq).pop();
+ const query = sizzle(`query[xmlns="${Strophe.NS.ROSTER}"]`, iq).pop();
this.data.save('version', query.getAttribute('ver'));
- var items = sizzle("item", query);
+ const items = sizzle(`item`, query);
if (items.length > 1) {
_converse.log(iq, Strophe.LogLevel.ERROR);
@@ -48884,31 +55344,31 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return;
},
- rosterVersioningSupported: function rosterVersioningSupported() {
+
+ rosterVersioningSupported() {
return _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') && this.data.get('version');
},
- fetchFromServer: function fetchFromServer() {
- var _this4 = this;
+ fetchFromServer() {
/* Fetch the roster from the XMPP server */
- return new Promise(function (resolve, reject) {
- var iq = $iq({
+ return new Promise((resolve, reject) => {
+ const iq = $iq({
'type': 'get',
'id': _converse.connection.getUniqueId('roster')
}).c('query', {
xmlns: Strophe.NS.ROSTER
});
- if (_this4.rosterVersioningSupported()) {
+ if (this.rosterVersioningSupported()) {
iq.attrs({
- 'ver': _this4.data.get('version')
+ 'ver': this.data.get('version')
});
}
- var callback = _.flow(_this4.onReceivedFromServer.bind(_this4), resolve);
+ const callback = _.flow(this.onReceivedFromServer.bind(this), resolve);
- var errback = function errback(iq) {
- var errmsg = "Error while trying to fetch roster from the server";
+ const errback = function errback(iq) {
+ const errmsg = "Error while trying to fetch roster from the server";
_converse.log(errmsg, Strophe.LogLevel.ERROR);
@@ -48918,20 +55378,17 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
return _converse.connection.sendIQ(iq, callback, errback);
});
},
- onReceivedFromServer: function onReceivedFromServer(iq) {
- var _this5 = this;
+ onReceivedFromServer(iq) {
/* An IQ stanza containing the roster has been received from
* the XMPP server.
*/
- var query = sizzle("query[xmlns=\"".concat(Strophe.NS.ROSTER, "\"]"), iq).pop();
+ const query = sizzle(`query[xmlns="${Strophe.NS.ROSTER}"]`, iq).pop();
if (query) {
- var items = sizzle("item", query);
+ const items = sizzle(`item`, query);
- _.each(items, function (item) {
- return _this5.updateContact(item);
- });
+ _.each(items, item => this.updateContact(item));
this.data.save('version', query.getAttribute('ver'));
@@ -48940,20 +55397,21 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.emit('roster', iq);
},
- updateContact: function updateContact(item) {
+
+ updateContact(item) {
/* Update or create RosterContact models based on items
* received in the IQ from the server.
*/
- var jid = item.getAttribute('jid');
+ const jid = item.getAttribute('jid');
if (this.isSelf(jid)) {
return;
}
- var contact = this.get(jid),
- subscription = item.getAttribute("subscription"),
- ask = item.getAttribute("ask"),
- groups = _.map(item.getElementsByTagName('group'), Strophe.getText);
+ const contact = this.get(jid),
+ subscription = item.getAttribute("subscription"),
+ ask = item.getAttribute("ask"),
+ groups = _.map(item.getElementsByTagName('group'), Strophe.getText);
if (!contact) {
if (subscription === "none" && ask === null || subscription === "remove") {
@@ -48986,11 +55444,12 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
}
},
- createRequestingContact: function createRequestingContact(presence) {
- var bare_jid = Strophe.getBareJidFromJid(presence.getAttribute('from')),
- nickname = _.get(sizzle("nick[xmlns=\"".concat(Strophe.NS.NICK, "\"]"), presence).pop(), 'textContent', null);
- var user_data = {
+ createRequestingContact(presence) {
+ const bare_jid = Strophe.getBareJidFromJid(presence.getAttribute('from')),
+ nickname = _.get(sizzle(`nick[xmlns="${Strophe.NS.NICK}"]`, presence).pop(), 'textContent', null);
+
+ const user_data = {
'jid': bare_jid,
'subscription': 'none',
'ask': null,
@@ -49000,10 +55459,11 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.emit('contactRequest', this.create(user_data));
},
- handleIncomingSubscription: function handleIncomingSubscription(presence) {
- var jid = presence.getAttribute('from'),
- bare_jid = Strophe.getBareJidFromJid(jid),
- contact = this.get(bare_jid);
+
+ handleIncomingSubscription(presence) {
+ const jid = presence.getAttribute('from'),
+ bare_jid = Strophe.getBareJidFromJid(jid),
+ contact = this.get(bare_jid);
if (!_converse.allow_contact_requests) {
_converse.rejectPresenceSubscription(jid, __("This client does not allow presence subscriptions"));
@@ -49027,16 +55487,17 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
}
},
- handleOwnPresence: function handleOwnPresence(presence) {
- var jid = presence.getAttribute('from'),
- resource = Strophe.getResourceFromJid(jid),
- presence_type = presence.getAttribute('type');
+
+ handleOwnPresence(presence) {
+ const jid = presence.getAttribute('from'),
+ resource = Strophe.getResourceFromJid(jid),
+ presence_type = presence.getAttribute('type');
if (_converse.connection.jid !== jid && presence_type !== 'unavailable' && (_converse.synchronize_availability === true || _converse.synchronize_availability === resource)) {
// Another resource has changed its status and
// synchronize_availability option set to update,
// we'll update ours as well.
- var show = _.propertyOf(presence.querySelector('show'))('textContent') || 'online';
+ const show = _.propertyOf(presence.querySelector('show'))('textContent') || 'online';
_converse.xmppstatus.save({
'status': show
@@ -49044,7 +55505,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
'silent': true
});
- var status_message = _.propertyOf(presence.querySelector('status'))('textContent');
+ const status_message = _.propertyOf(presence.querySelector('status'))('textContent');
if (status_message) {
_converse.xmppstatus.save({
@@ -49071,24 +55532,25 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.xmppstatus.sendPresence();
}
},
- presenceHandler: function presenceHandler(presence) {
- var presence_type = presence.getAttribute('type');
+
+ presenceHandler(presence) {
+ const presence_type = presence.getAttribute('type');
if (presence_type === 'error') {
return true;
}
- var jid = presence.getAttribute('from'),
- bare_jid = Strophe.getBareJidFromJid(jid);
+ const jid = presence.getAttribute('from'),
+ bare_jid = Strophe.getBareJidFromJid(jid);
if (this.isSelf(bare_jid)) {
return this.handleOwnPresence(presence);
- } else if (sizzle("query[xmlns=\"".concat(Strophe.NS.MUC, "\"]"), presence).length) {
+ } else if (sizzle(`query[xmlns="${Strophe.NS.MUC}"]`, presence).length) {
return; // Ignore MUC
}
- var status_message = _.propertyOf(presence.querySelector('status'))('textContent'),
- contact = this.get(bare_jid);
+ const status_message = _.propertyOf(presence.querySelector('status'))('textContent'),
+ contact = this.get(bare_jid);
if (contact && status_message !== contact.get('status')) {
contact.save({
@@ -49105,16 +55567,17 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
} else if (presence_type === 'subscribe') {
this.handleIncomingSubscription(presence);
} else if (presence_type === 'unavailable' && contact) {
- var resource = Strophe.getResourceFromJid(jid);
+ const resource = Strophe.getResourceFromJid(jid);
contact.presence.removeResource(resource);
} else if (contact) {
// presence_type is undefined
contact.presence.addResource(presence);
}
}
+
});
_converse.RosterGroup = Backbone.Model.extend({
- initialize: function initialize(attributes) {
+ initialize(attributes) {
this.set(_.assignIn({
description: __('Click to hide these contacts'),
state: _converse.OPENED
@@ -49122,19 +55585,19 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
this.contacts = new _converse.RosterContacts();
}
+
});
_converse.RosterGroups = Backbone.Collection.extend({
model: _converse.RosterGroup,
- fetchRosterGroups: function fetchRosterGroups() {
- var _this6 = this;
+ fetchRosterGroups() {
/* Fetches all the roster groups from sessionStorage.
*
* Returns a promise which resolves once the groups have been
* returned.
*/
- return new Promise(function (resolve, reject) {
- _this6.fetch({
+ return new Promise((resolve, reject) => {
+ this.fetch({
silent: true,
// We need to first have all groups before
// we can start positioning them, so we set
@@ -49143,6 +55606,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
});
});
}
+
});
_converse.unregisterPresenceHandler = function () {
@@ -49156,7 +55620,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
function updateUnreadCounter(chatbox) {
- var contact = _converse.roster.findWhere({
+ const contact = _converse.roster.findWhere({
'jid': chatbox.get('jid')
});
@@ -49167,29 +55631,29 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
}
}
- _converse.api.listen.on('chatBoxesInitialized', function () {
+ _converse.api.listen.on('chatBoxesInitialized', () => {
_converse.chatboxes.on('change:num_unread', updateUnreadCounter);
});
_converse.api.listen.on('beforeTearDown', _converse.unregisterPresenceHandler());
- _converse.api.listen.on('afterTearDown', function () {
+ _converse.api.listen.on('afterTearDown', () => {
if (_converse.presences) {
_converse.presences.off().reset(); // Remove presences
}
});
- _converse.api.listen.on('clearSession', function () {
+ _converse.api.listen.on('clearSession', () => {
if (_converse.presences) {
_converse.presences.browserStorage._clear();
}
});
- _converse.api.listen.on('statusInitialized', function (reconnecting) {
+ _converse.api.listen.on('statusInitialized', reconnecting => {
if (!reconnecting) {
_converse.presences = new _converse.Presences();
- _converse.presences.browserStorage = new Backbone.BrowserStorage.session(b64_sha1("converse.presences-".concat(_converse.bare_jid)));
+ _converse.presences.browserStorage = new Backbone.BrowserStorage.session(b64_sha1(`converse.presences-${_converse.bare_jid}`));
_converse.presences.fetch();
}
@@ -49197,7 +55661,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
_converse.emit('presencesInitialized', reconnecting);
});
- _converse.api.listen.on('presencesInitialized', function (reconnecting) {
+ _converse.api.listen.on('presencesInitialized', reconnecting => {
if (reconnecting) {
// No need to recreate the roster, otherwise we lose our
// cached data. However we still emit an event, to give
@@ -49258,8 +55722,8 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* // ...
* });
*/
- 'get': function get(jids) {
- var _getter = function _getter(jid) {
+ 'get'(jids) {
+ const _getter = function _getter(jid) {
return _converse.roster.get(Strophe.getBareJidFromJid(jid)) || null;
};
@@ -49284,16 +55748,18 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
* @example
* _converse.api.contacts.add('buddy@example.com', 'Buddy')
*/
- 'add': function add(jid, name) {
+ 'add'(jid, name) {
if (!_.isString(jid) || !_.includes(jid, '@')) {
throw new TypeError('contacts.add: invalid jid');
}
_converse.roster.addAndSubscribe(jid, _.isEmpty(name) ? jid : name);
}
+
}
});
}
+
});
});
@@ -49306,10 +55772,7 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -49319,17 +55782,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, _FormData, tpl_add_contact_modal, tpl_group_header, tpl_pending_contact, tpl_requesting_contact, tpl_roster, tpl_roster_filter, tpl_roster_item, tpl_search_contact, Awesomplete) {
+})(this, function (converse, _FormData, tpl_add_contact_modal, tpl_group_header, tpl_pending_contact, tpl_requesting_contact, tpl_roster, tpl_roster_filter, tpl_roster_item, tpl_search_contact, Awesomplete) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Strophe = _converse$env.Strophe,
- $iq = _converse$env.$iq,
- b64_sha1 = _converse$env.b64_sha1,
- sizzle = _converse$env.sizzle,
- _ = _converse$env._;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Strophe = _converse$env.Strophe,
+ $iq = _converse$env.$iq,
+ b64_sha1 = _converse$env.b64_sha1,
+ sizzle = _converse$env.sizzle,
+ _ = _converse$env._;
+ const u = converse.env.utils;
converse.plugins.add('converse-rosterview', {
dependencies: ["converse-roster", "converse-modal"],
overrides: {
@@ -49338,10 +55801,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// relevant objects or classes.
//
// New functions which don't exist yet can also be added.
- afterReconnected: function afterReconnected() {
+ afterReconnected() {
this.__super__.afterReconnected.apply(this, arguments);
},
- tearDown: function tearDown() {
+
+ tearDown() {
/* Remove the rosterview when tearing down. It gets created
* anew when reconnecting or logging in.
*/
@@ -49351,21 +55815,24 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.rosterview.remove();
}
},
+
RosterGroups: {
- comparator: function comparator() {
+ comparator() {
// RosterGroupsComparator only gets set later (once i18n is
// set up), so we need to wrap it in this nameless function.
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
return _converse.RosterGroupsComparator.apply(this, arguments);
}
+
}
},
- initialize: function initialize() {
+
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse,
- __ = _converse.__;
+ const _converse = this._converse,
+ __ = _converse.__;
_converse.api.settings.update({
'allow_chat_pending_contacts': true,
@@ -49379,7 +55846,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.api.promises.add('rosterViewInitialized');
- var STATUSES = {
+ const STATUSES = {
'dnd': __('This contact is busy'),
'online': __('This contact is online'),
'offline': __('This contact is offline'),
@@ -49388,17 +55855,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'away': __('This contact is away')
};
- var LABEL_GROUPS = __('Groups');
+ const LABEL_GROUPS = __('Groups');
- var HEADER_CURRENT_CONTACTS = __('My contacts');
+ const HEADER_CURRENT_CONTACTS = __('My contacts');
- var HEADER_PENDING_CONTACTS = __('Pending contacts');
+ const HEADER_PENDING_CONTACTS = __('Pending contacts');
- var HEADER_REQUESTING_CONTACTS = __('Contact requests');
+ const HEADER_REQUESTING_CONTACTS = __('Contact requests');
- var HEADER_UNGROUPED = __('Ungrouped');
+ const HEADER_UNGROUPED = __('Ungrouped');
- var HEADER_WEIGHTS = {};
+ const HEADER_WEIGHTS = {};
HEADER_WEIGHTS[HEADER_REQUESTING_CONTACTS] = 0;
HEADER_WEIGHTS[HEADER_CURRENT_CONTACTS] = 1;
HEADER_WEIGHTS[HEADER_UNGROUPED] = 2;
@@ -49412,11 +55879,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
a = a.get('name');
b = b.get('name');
- var special_groups = _.keys(HEADER_WEIGHTS);
+ const special_groups = _.keys(HEADER_WEIGHTS);
- var a_is_special = _.includes(special_groups, a);
+ const a_is_special = _.includes(special_groups, a);
- var b_is_special = _.includes(special_groups, b);
+ const b_is_special = _.includes(special_groups, b);
if (!a_is_special && !b_is_special) {
return a.toLowerCase() < b.toLowerCase() ? -1 : a.toLowerCase() > b.toLowerCase() ? 1 : 0;
@@ -49433,13 +55900,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
events: {
'submit form': 'addContactFromForm'
},
- initialize: function initialize() {
+
+ initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this);
},
- toHTML: function toHTML() {
- var label_nickname = _converse.xhr_user_search_url ? __('Contact name') : __('Optional nickname');
+
+ toHTML() {
+ const label_nickname = _converse.xhr_user_search_url ? __('Contact name') : __('Optional nickname');
return tpl_add_contact_modal(_.extend(this.model.toJSON(), {
'_converse': _converse,
'heading_new_contact': __('Add a Contact'),
@@ -49450,24 +55919,24 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'error_message': __('Please enter a valid XMPP address')
}));
},
- afterRender: function afterRender() {
+
+ afterRender() {
if (_converse.xhr_user_search_url && _.isString(_converse.xhr_user_search_url)) {
this.initXHRAutoComplete(this.el);
} else {
this.initJIDAutoComplete(this.el);
}
- var jid_input = this.el.querySelector('input[name="jid"]');
- this.el.addEventListener('shown.bs.modal', function () {
+ const jid_input = this.el.querySelector('input[name="jid"]');
+ this.el.addEventListener('shown.bs.modal', () => {
jid_input.focus();
}, false);
},
- initJIDAutoComplete: function initJIDAutoComplete(root) {
- var jid_input = root.querySelector('input[name="jid"]');
- var list = _.uniq(_converse.roster.map(function (item) {
- return Strophe.getDomainFromJid(item.get('jid'));
- }));
+ initJIDAutoComplete(root) {
+ const jid_input = root.querySelector('input[name="jid"]');
+
+ const list = _.uniq(_converse.roster.map(item => Strophe.getDomainFromJid(item.get('jid'))));
new Awesomplete(jid_input, {
'list': list,
@@ -49477,18 +55946,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'filter': Awesomplete.FILTER_STARTSWITH
});
},
- initXHRAutoComplete: function initXHRAutoComplete(root) {
- var name_input = this.el.querySelector('input[name="name"]');
- var jid_input = this.el.querySelector('input[name="jid"]');
- var awesomplete = new Awesomplete(name_input, {
+
+ initXHRAutoComplete(root) {
+ const name_input = this.el.querySelector('input[name="name"]');
+ const jid_input = this.el.querySelector('input[name="jid"]');
+ const awesomplete = new Awesomplete(name_input, {
'minChars': 1,
'list': []
});
- var xhr = new window.XMLHttpRequest(); // `open` must be called after `onload` for mock/testing purposes.
+ const xhr = new window.XMLHttpRequest(); // `open` must be called after `onload` for mock/testing purposes.
xhr.onload = function () {
if (xhr.responseText) {
- awesomplete.list = JSON.parse(xhr.responseText).map(function (i) {
+ awesomplete.list = JSON.parse(xhr.responseText).map(i => {
//eslint-disable-line arrow-body-style
return {
'label': i.fullname || i.jid,
@@ -49499,20 +55969,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
};
- name_input.addEventListener('input', _.debounce(function () {
- xhr.open("GET", "".concat(_converse.xhr_user_search_url, "q=").concat(name_input.value), true);
+ name_input.addEventListener('input', _.debounce(() => {
+ xhr.open("GET", `${_converse.xhr_user_search_url}q=${name_input.value}`, true);
xhr.send();
}, 300));
- this.el.addEventListener('awesomplete-selectcomplete', function (ev) {
+ this.el.addEventListener('awesomplete-selectcomplete', ev => {
jid_input.value = ev.text.value;
name_input.value = ev.text.label;
});
},
- addContactFromForm: function addContactFromForm(ev) {
+
+ addContactFromForm(ev) {
ev.preventDefault();
- var data = new FormData(ev.target),
- jid = data.get('jid'),
- name = data.get('name');
+ const data = new FormData(ev.target),
+ jid = data.get('jid'),
+ name = data.get('name');
if (!jid || _.compact(jid.split('@')).length < 2) {
// XXX: we have to do this manually, instead of via
@@ -49529,15 +56000,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.modal.hide();
}
}
+
});
_converse.RosterFilter = Backbone.Model.extend({
- initialize: function initialize() {
+ initialize() {
this.set({
'filter_text': '',
'filter_type': 'contacts',
'chat_state': ''
});
}
+
});
_converse.RosterFilterView = Backbone.VDOMView.extend({
tagName: 'form',
@@ -49549,11 +56022,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
"click .filter-by span": "changeTypeFilter",
"change .state-type": "changeChatStateFilter"
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on('change:filter_type', this.render, this);
this.model.on('change:filter_text', this.render, this);
},
- toHTML: function toHTML() {
+
+ toHTML() {
return tpl_roster_filter(_.extend(this.model.toJSON(), {
visible: this.shouldBeVisible(),
placeholder: __('Filter'),
@@ -49570,7 +56045,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
label_offline: __('Offline')
}));
},
- changeChatStateFilter: function changeChatStateFilter(ev) {
+
+ changeChatStateFilter(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -49579,12 +56055,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'chat_state': this.el.querySelector('.state-type').value
});
},
- changeTypeFilter: function changeTypeFilter(ev) {
+
+ changeTypeFilter(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var type = ev.target.dataset.type;
+ const type = ev.target.dataset.type;
if (type === 'state') {
this.model.save({
@@ -49598,12 +56075,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
},
+
liveFilter: _.debounce(function (ev) {
this.model.save({
'filter_text': this.el.querySelector('.roster-filter').value
});
}, 250),
- submitFilter: function submitFilter(ev) {
+
+ submitFilter(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -49611,7 +56090,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.liveFilter();
this.render();
},
- isActive: function isActive() {
+
+ isActive() {
/* Returns true if the filter is enabled (i.e. if the user
* has added values to the filter).
*/
@@ -49621,17 +56101,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return false;
},
- shouldBeVisible: function shouldBeVisible() {
+
+ shouldBeVisible() {
return _converse.roster.length >= 5 || this.isActive();
},
- showOrHide: function showOrHide() {
+
+ showOrHide() {
if (this.shouldBeVisible()) {
this.show();
} else {
this.hide();
}
},
- show: function show() {
+
+ show() {
if (u.isVisible(this.el)) {
return this;
}
@@ -49640,7 +56123,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.el.classList.remove('hidden');
return this;
},
- hide: function hide() {
+
+ hide() {
if (!u.isVisible(this.el)) {
return this;
}
@@ -49652,18 +56136,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.el.classList.add('hidden');
return this;
},
- clearFilter: function clearFilter(ev) {
+
+ clearFilter(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
u.hideElement(this.el.querySelector('.clear-input'));
}
- var roster_filter = this.el.querySelector('.roster-filter');
+ const roster_filter = this.el.querySelector('.roster-filter');
roster_filter.value = '';
this.model.save({
'filter_text': ''
});
}
+
});
_converse.RosterContactView = Backbone.NativeView.extend({
tagName: 'li',
@@ -49674,7 +56160,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
"click .open-chat": "openChat",
"click .remove-xmpp-contact": "removeContact"
},
- initialize: function initialize() {
+
+ initialize() {
this.model.on("change", this.render, this);
this.model.on("highlight", this.highlight, this);
this.model.on("destroy", this.remove, this);
@@ -49683,19 +56170,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.presence.on("change:show", this.render, this);
this.model.vcard.on('change:fullname', this.render, this);
},
- render: function render() {
- var that = this;
+
+ render() {
+ const that = this;
if (!this.mayBeShown()) {
u.hideElement(this.el);
return this;
}
- var ask = this.model.get('ask'),
- show = this.model.presence.get('show'),
- requesting = this.model.get('requesting'),
- subscription = this.model.get('subscription');
- var classes_to_remove = ['current-xmpp-contact', 'pending-xmpp-contact', 'requesting-xmpp-contact'].concat(_.keys(STATUSES));
+ const ask = this.model.get('ask'),
+ show = this.model.presence.get('show'),
+ requesting = this.model.get('requesting'),
+ subscription = this.model.get('subscription');
+ const classes_to_remove = ['current-xmpp-contact', 'pending-xmpp-contact', 'requesting-xmpp-contact'].concat(_.keys(STATUSES));
_.each(classes_to_remove, function (cls) {
if (_.includes(that.el.className, cls)) {
@@ -49708,7 +56196,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.highlight();
if (_converse.isSingleton()) {
- var chatbox = _converse.chatboxes.get(this.model.get('jid'));
+ const chatbox = _converse.chatboxes.get(this.model.get('jid'));
if (chatbox) {
if (chatbox.get('hidden')) {
@@ -49731,7 +56219,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
*
* So in both cases the user is a "pending" contact.
*/
- var display_name = this.model.getDisplayName();
+ const display_name = this.model.getDisplayName();
this.el.classList.add('pending-xmpp-contact');
this.el.innerHTML = tpl_pending_contact(_.extend(this.model.toJSON(), {
'display_name': display_name,
@@ -49739,13 +56227,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'allow_chat_pending_contacts': _converse.allow_chat_pending_contacts
}));
} else if (requesting === true) {
- var _display_name = this.model.getDisplayName();
-
+ const display_name = this.model.getDisplayName();
this.el.classList.add('requesting-xmpp-contact');
this.el.innerHTML = tpl_requesting_contact(_.extend(this.model.toJSON(), {
- 'display_name': _display_name,
- 'desc_accept': __("Click to accept the contact request from %1$s", _display_name),
- 'desc_decline': __("Click to decline the contact request from %1$s", _display_name),
+ 'display_name': display_name,
+ 'desc_accept': __("Click to accept the contact request from %1$s", display_name),
+ 'desc_decline': __("Click to decline the contact request from %1$s", display_name),
'allow_chat_pending_contacts': _converse.allow_chat_pending_contacts
}));
} else if (subscription === 'both' || subscription === 'to') {
@@ -49757,11 +56244,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
},
- highlight: function highlight() {
+
+ highlight() {
/* If appropriate, highlight the contact (by adding the 'open' class).
*/
if (_converse.isSingleton()) {
- var chatbox = _converse.chatboxes.get(this.model.get('jid'));
+ const chatbox = _converse.chatboxes.get(this.model.get('jid'));
if (chatbox) {
if (chatbox.get('hidden')) {
@@ -49772,21 +56260,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
},
- renderRosterItem: function renderRosterItem(item) {
- var status_icon = 'fa fa-times-circle';
- var show = item.presence.get('show') || 'offline';
+
+ renderRosterItem(item) {
+ let status_icon = 'fa fa-times-circle';
+ const show = item.presence.get('show') || 'offline';
if (show === 'online') {
- status_icon = 'fa fa-circle';
+ status_icon = 'fa fa-circle chat-status chat-status--online';
} else if (show === 'away') {
- status_icon = 'fa fa-dot-circle';
+ status_icon = 'fa fa-circle chat-status chat-status--away';
} else if (show === 'xa') {
- status_icon = 'far fa-circle';
+ status_icon = 'far fa-circle chat-status';
} else if (show === 'dnd') {
- status_icon = 'fa fa-minus-circle';
+ status_icon = 'fa fa-minus-circle chat-status chat-status--busy';
}
- var display_name = item.getDisplayName();
+ const display_name = item.getDisplayName();
this.el.innerHTML = tpl_roster_item(_.extend(item.toJSON(), {
'display_name': display_name,
'desc_status': STATUSES[show],
@@ -49798,14 +56287,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}));
return this;
},
- mayBeShown: function mayBeShown() {
+
+ mayBeShown() {
/* Return a boolean indicating whether this contact should
* generally be visible in the roster.
*
* It doesn't check for the more specific case of whether
* the group it's in is collapsed.
*/
- var chatStatus = this.model.presence.get('show');
+ const chatStatus = this.model.presence.get('show');
if (_converse.show_only_online_users && chatStatus !== 'online' || _converse.hide_offline_users && chatStatus === 'offline') {
// If pending or requesting, show
@@ -49818,18 +56308,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return true;
},
- openChat: function openChat(ev) {
+
+ openChat(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var attrs = this.model.attributes;
+ const attrs = this.model.attributes;
_converse.api.chats.open(attrs.jid, attrs);
},
- removeContact: function removeContact(ev) {
- var _this = this;
+ removeContact(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
@@ -49838,13 +56328,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
}
- var result = confirm(__("Are you sure you want to remove this contact?"));
+ const result = confirm(__("Are you sure you want to remove this contact?"));
if (result === true) {
- this.model.removeFromRoster(function (iq) {
- _this.model.destroy();
-
- _this.remove();
+ this.model.removeFromRoster(iq => {
+ this.model.destroy();
+ this.remove();
}, function (err) {
alert(__('Sorry, there was an error while trying to remove %1$s as a contact.', name));
@@ -49852,23 +56341,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
},
- acceptRequest: function acceptRequest(ev) {
- var _this2 = this;
+ acceptRequest(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- _converse.roster.sendContactAddIQ(this.model.get('jid'), this.model.getFullname(), [], function () {
- _this2.model.authorize().subscribe();
+ _converse.roster.sendContactAddIQ(this.model.get('jid'), this.model.getFullname(), [], () => {
+ this.model.authorize().subscribe();
});
},
- declineRequest: function declineRequest(ev) {
+
+ declineRequest(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var result = confirm(__("Are you sure you want to decline this contact request?"));
+ const result = confirm(__("Are you sure you want to decline this contact request?"));
if (result === true) {
this.model.unauthorize().destroy();
@@ -49876,6 +56365,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
}
+
});
_converse.RosterGroupView = Backbone.OrderedListView.extend({
tagName: 'div',
@@ -49887,7 +56377,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
listItems: 'model.contacts',
listSelector: '.roster-group-contacts',
sortEvent: 'presenceChanged',
- initialize: function initialize() {
+
+ initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.model.contacts.on("change:subscription", this.onContactSubscriptionChange, this);
this.model.contacts.on("change:requesting", this.onContactRequestChange, this);
@@ -49901,7 +56392,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.rosterview.on('rosterContactsFetchedAndProcessed', this.sortAndPositionAllItems.bind(this));
},
- render: function render() {
+
+ render() {
this.el.setAttribute('data-group', this.model.get('name'));
this.el.innerHTML = tpl_group_header({
'label_group': this.model.get('name'),
@@ -49912,38 +56404,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.contacts_el = this.el.querySelector('.roster-group-contacts');
return this;
},
- show: function show() {
- var _this3 = this;
+ show() {
u.showElement(this.el);
- _.each(this.getAll(), function (contact_view) {
- if (contact_view.mayBeShown() && _this3.model.get('state') === _converse.OPENED) {
+ _.each(this.getAll(), contact_view => {
+ if (contact_view.mayBeShown() && this.model.get('state') === _converse.OPENED) {
u.showElement(contact_view.el);
}
});
return this;
},
- collapse: function collapse() {
+
+ collapse() {
return u.slideIn(this.contacts_el);
},
- filterOutContacts: function filterOutContacts() {
- var _this4 = this;
-
- var contacts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ filterOutContacts(contacts = []) {
/* Given a list of contacts, make sure they're filtered out
* (aka hidden) and that all other contacts are visible.
*
* If all contacts are hidden, then also hide the group
* title.
*/
- var shown = 0;
- var all_contact_views = this.getAll();
+ let shown = 0;
+ const all_contact_views = this.getAll();
- _.each(this.model.contacts.models, function (contact) {
- var contact_view = _this4.get(contact.get('id'));
+ _.each(this.model.contacts.models, contact => {
+ const contact_view = this.get(contact.get('id'));
if (_.includes(contacts, contact)) {
u.hideElement(contact_view.el);
@@ -49959,7 +56448,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.hideElement(this.el);
}
},
- getFilterMatches: function getFilterMatches(q, type) {
+
+ getFilterMatches(q, type) {
/* Given the filter query "q" and the filter type "type",
* return a list of contacts that need to be filtered out.
*/
@@ -49967,7 +56457,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return [];
}
- var matches;
+ let matches;
q = q.toLowerCase();
if (type === 'state') {
@@ -49975,27 +56465,24 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// When filtering by chat state, we still want to
// show requesting contacts, even though they don't
// have the state in question.
- matches = this.model.contacts.filter(function (contact) {
- return !_.includes(contact.presence.get('show'), q) && !contact.get('requesting');
- });
+ matches = this.model.contacts.filter(contact => !_.includes(contact.presence.get('show'), q) && !contact.get('requesting'));
} else if (q === 'unread_messages') {
matches = this.model.contacts.filter({
'num_unread': 0
});
} else {
- matches = this.model.contacts.filter(function (contact) {
- return !_.includes(contact.presence.get('show'), q);
- });
+ matches = this.model.contacts.filter(contact => !_.includes(contact.presence.get('show'), q));
}
} else {
- matches = this.model.contacts.filter(function (contact) {
+ matches = this.model.contacts.filter(contact => {
return !_.includes(contact.getDisplayName().toLowerCase(), q.toLowerCase());
});
}
return matches;
},
- filter: function filter(q, type) {
+
+ filter(q, type) {
/* Filter the group's contacts based on the query "q".
*
* If all contacts are filtered out (i.e. hidden), then the
@@ -50013,18 +56500,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.filterOutContacts(this.getFilterMatches(q, type));
},
- toggle: function toggle(ev) {
+
+ toggle(ev) {
if (ev && ev.preventDefault) {
ev.preventDefault();
}
- var icon_el = ev.target.querySelector('.fa');
+ const icon_el = ev.target.querySelector('.fa');
if (_.includes(icon_el.classList, "fa-caret-down")) {
this.model.save({
state: _converse.CLOSED
});
- this.collapse().then(function () {
+ this.collapse().then(() => {
icon_el.classList.remove("fa-caret-down");
icon_el.classList.add("fa-caret-right");
});
@@ -50039,11 +56527,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.slideOut(this.contacts_el);
}
},
- onContactGroupChange: function onContactGroupChange(contact) {
- var in_this_group = _.includes(contact.get('groups'), this.model.get('name'));
- var cid = contact.get('id');
- var in_this_overview = !this.get(cid);
+ onContactGroupChange(contact) {
+ const in_this_group = _.includes(contact.get('groups'), this.model.get('name'));
+
+ const cid = contact.get('id');
+ const in_this_overview = !this.get(cid);
if (in_this_group && !in_this_overview) {
this.items.trigger('add', contact);
@@ -50051,17 +56540,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.removeContact(contact);
}
},
- onContactSubscriptionChange: function onContactSubscriptionChange(contact) {
+
+ onContactSubscriptionChange(contact) {
if (this.model.get('name') === HEADER_PENDING_CONTACTS && contact.get('subscription') !== 'from') {
this.removeContact(contact);
}
},
- onContactRequestChange: function onContactRequestChange(contact) {
+
+ onContactRequestChange(contact) {
if (this.model.get('name') === HEADER_REQUESTING_CONTACTS && !contact.get('requesting')) {
this.removeContact(contact);
}
},
- removeContact: function removeContact(contact) {
+
+ removeContact(contact) {
// We suppress events, otherwise the remove event will
// also cause the contact's view to be removed from the
// "Pending Contacts" group.
@@ -50070,13 +56562,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
this.onRemove(contact);
},
- onRemove: function onRemove(contact) {
+
+ onRemove(contact) {
this.remove(contact.get('jid'));
if (this.model.contacts.length === 0) {
this.remove();
}
}
+
});
_converse.RosterView = Backbone.OrderedListView.extend({
tagName: 'div',
@@ -50091,9 +56585,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
events: {
'click a.chatbox-btn.add-contact': 'showAddContactModal'
},
- initialize: function initialize() {
- var _this5 = this;
+ initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
_converse.roster.on("add", this.onContactAdded, this);
@@ -50106,10 +56599,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.roster.on("remove", this.update, this);
- _converse.presences.on('change:show', function () {
- _this5.update();
-
- _this5.updateFilter();
+ _converse.presences.on('change:show', () => {
+ this.update();
+ this.updateFilter();
});
this.model.on("reset", this.reset, this); // This event gets triggered once *all* contacts (i.e. not
@@ -50119,34 +56611,32 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.on('rosterGroupsFetched', this.sortAndPositionAllItems.bind(this));
- _converse.on('rosterContactsFetched', function () {
- _converse.roster.each(function (contact) {
- return _this5.addRosterContact(contact, {
- 'silent': true
- });
- });
+ _converse.on('rosterContactsFetched', () => {
+ _converse.roster.each(contact => this.addRosterContact(contact, {
+ 'silent': true
+ }));
- _this5.update();
-
- _this5.updateFilter();
-
- _this5.trigger('rosterContactsFetchedAndProcessed');
+ this.update();
+ this.updateFilter();
+ this.trigger('rosterContactsFetchedAndProcessed');
});
this.createRosterFilter();
},
- render: function render() {
+
+ render() {
this.el.innerHTML = tpl_roster({
'allow_contact_requests': _converse.allow_contact_requests,
'heading_contacts': __('Contacts'),
'title_add_contact': __('Add a contact')
});
- var form = this.el.querySelector('.roster-filter-form');
+ const form = this.el.querySelector('.roster-filter-form');
this.el.replaceChild(this.filter_view.render().el, form);
this.roster_el = this.el.querySelector('.roster-contacts');
return this;
},
- showAddContactModal: function showAddContactModal(ev) {
+
+ showAddContactModal(ev) {
if (_.isUndefined(this.add_contact_modal)) {
this.add_contact_modal = new _converse.AddContactModal({
'model': new Backbone.Model()
@@ -50155,10 +56645,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.add_contact_modal.show(ev);
},
- createRosterFilter: function createRosterFilter() {
+
+ createRosterFilter() {
// Create a model on which we can store filter properties
- var model = new _converse.RosterFilter();
- model.id = b64_sha1("_converse.rosterfilter".concat(_converse.bare_jid));
+ const model = new _converse.RosterFilter();
+ model.id = b64_sha1(`_converse.rosterfilter${_converse.bare_jid}`);
model.browserStorage = new Backbone.BrowserStorage.local(this.filter.id);
this.filter_view = new _converse.RosterFilterView({
'model': model
@@ -50166,6 +56657,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.filter_view.model.on('change', this.updateFilter, this);
this.filter_view.model.fetch();
},
+
updateFilter: _.debounce(function () {
/* Filter the roster again.
* Called whenever the filter settings have been changed or
@@ -50174,7 +56666,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* Debounced so that it doesn't get called for every
* contact fetched from browser storage.
*/
- var type = this.filter_view.model.get('filter_type');
+ const type = this.filter_view.model.get('filter_type');
if (type === 'state') {
this.filter(this.filter_view.model.get('chat_state'), type);
@@ -50190,7 +56682,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.filter_view.showOrHide();
return this;
}, _converse.animate ? 100 : 0),
- filter: function filter(query, type) {
+
+ filter(query, type) {
// First we make sure the filter is restored to its
// original state
_.each(this.getAll(), function (view) {
@@ -50216,19 +56709,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
}
},
- reset: function reset() {
+
+ reset() {
_converse.roster.reset();
this.removeAll();
this.render().update();
return this;
},
- onContactAdded: function onContactAdded(contact) {
+
+ onContactAdded(contact) {
this.addRosterContact(contact);
this.update();
this.updateFilter();
},
- onContactChange: function onContactChange(contact) {
+
+ onContactChange(contact) {
this.updateChatBox(contact);
this.update();
@@ -50250,12 +56746,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.updateFilter();
},
- updateChatBox: function updateChatBox(contact) {
+
+ updateChatBox(contact) {
if (!this.model.chatbox) {
return this;
}
- var changes = {};
+ const changes = {};
if (_.has(contact.changed, 'status')) {
changes.status = contact.get('status');
@@ -50264,27 +56761,30 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.chatbox.save(changes);
return this;
},
- getGroup: function getGroup(name) {
+
+ getGroup(name) {
/* Returns the group as specified by name.
* Creates the group if it doesn't exist.
*/
- var view = this.get(name);
+ const view = this.get(name);
if (view) {
return view.model;
}
return this.model.create({
- name: name,
+ name,
id: b64_sha1(name)
});
},
- addContactToGroup: function addContactToGroup(contact, name, options) {
+
+ addContactToGroup(contact, name, options) {
this.getGroup(name).contacts.add(contact, options);
this.sortAndPositionAllItems();
},
- addExistingContact: function addExistingContact(contact, options) {
- var groups;
+
+ addExistingContact(contact, options) {
+ let groups;
if (_converse.roster_groups) {
groups = contact.get('groups');
@@ -50298,12 +56798,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_.each(groups, _.bind(this.addContactToGroup, this, contact, _, options));
},
- addRosterContact: function addRosterContact(contact, options) {
+
+ addRosterContact(contact, options) {
if (contact.get('subscription') === 'both' || contact.get('subscription') === 'to') {
this.addExistingContact(contact, options);
} else {
if (!_converse.allow_contact_requests) {
- _converse.log("Not adding requesting or pending contact ".concat(contact.get('jid'), " ") + "because allow_contact_requests is false", Strophe.LogLevel.DEBUG);
+ _converse.log(`Not adding requesting or pending contact ${contact.get('jid')} ` + `because allow_contact_requests is false`, Strophe.LogLevel.DEBUG);
return;
}
@@ -50317,12 +56818,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this;
}
+
});
/* -------- Event Handlers ----------- */
- _converse.api.listen.on('chatBoxesInitialized', function () {
- _converse.chatboxes.on('change:hidden', function (chatbox) {
- var contact = _converse.roster.findWhere({
+ _converse.api.listen.on('chatBoxesInitialized', () => {
+ _converse.chatboxes.on('change:hidden', chatbox => {
+ const contact = _converse.roster.findWhere({
'jid': chatbox.get('jid')
});
@@ -50353,6 +56855,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.api.listen.on('rosterReadyAfterReconnection', initRoster);
}
+
});
});
@@ -50365,10 +56868,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2012-2018, the Converse.js developers
@@ -50390,13 +56890,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse) {
+})(this, function (converse) {
"use strict";
- var _converse$env = converse.env,
- _ = _converse$env._,
- Strophe = _converse$env.Strophe;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ _ = _converse$env._,
+ Strophe = _converse$env.Strophe;
+ const u = converse.env.utils;
function hideChat(view) {
if (view.model.get('id') === 'controlbox') {
@@ -50423,19 +56923,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//
// new functions which don't exist yet can also be added.
ChatBoxes: {
- chatBoxMayBeShown: function chatBoxMayBeShown(chatbox) {
- var _converse = this.__super__._converse;
+ chatBoxMayBeShown(chatbox) {
+ const _converse = this.__super__._converse;
if (chatbox.get('id') === 'controlbox') {
return true;
}
if (_converse.isSingleton()) {
- var any_chats_visible = _converse.chatboxes.filter(function (cb) {
- return cb.get('id') != 'controlbox';
- }).filter(function (cb) {
- return !cb.get('hidden');
- }).length > 0;
+ const any_chats_visible = _converse.chatboxes.filter(cb => cb.get('id') != 'controlbox').filter(cb => !cb.get('hidden')).length > 0;
if (any_chats_visible) {
return !chatbox.get('hidden');
@@ -50446,9 +56942,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.chatBoxMayBeShown.apply(this, arguments);
}
},
- createChatBox: function createChatBox(jid, attrs) {
+
+ createChatBox(jid, attrs) {
/* Make sure new chat boxes are hidden by default. */
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
if (_converse.isSingleton()) {
attrs = attrs || {};
@@ -50457,10 +56954,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.createChatBox.call(this, jid, attrs);
}
+
},
ChatBoxView: {
- shouldShowOnTextMessage: function shouldShowOnTextMessage() {
- var _converse = this.__super__._converse;
+ shouldShowOnTextMessage() {
+ const _converse = this.__super__._converse;
if (_converse.isSingleton()) {
return false;
@@ -50468,12 +56966,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.shouldShowOnTextMessage.apply(this, arguments);
}
},
- _show: function _show(focus) {
+
+ _show(focus) {
/* We only have one chat visible at any one
* time. So before opening a chat, we make sure all other
* chats are hidden.
*/
- var _converse = this.__super__._converse;
+ const _converse = this.__super__._converse;
if (_converse.isSingleton()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
@@ -50485,10 +56984,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__._show.apply(this, arguments);
}
+
},
ChatRoomView: {
- show: function show(focus) {
- var _converse = this.__super__._converse;
+ show(focus) {
+ const _converse = this.__super__._converse;
if (_converse.isSingleton()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
@@ -50500,6 +57000,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return this.__super__.show.apply(this, arguments);
}
+
}
}
});
@@ -50514,12 +57015,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-// Converse.js
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js
// http://conversejs.org
//
// Copyright (c) 2013-2018, the Converse.js developers
@@ -50529,37 +57025,38 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (converse, tpl_vcard) {
+})(this, function (converse, tpl_vcard) {
"use strict";
- var _converse$env = converse.env,
- Backbone = _converse$env.Backbone,
- Promise = _converse$env.Promise,
- Strophe = _converse$env.Strophe,
- _ = _converse$env._,
- $iq = _converse$env.$iq,
- $build = _converse$env.$build,
- b64_sha1 = _converse$env.b64_sha1,
- moment = _converse$env.moment,
- sizzle = _converse$env.sizzle;
- var u = converse.env.utils;
+ const _converse$env = converse.env,
+ Backbone = _converse$env.Backbone,
+ Promise = _converse$env.Promise,
+ Strophe = _converse$env.Strophe,
+ _ = _converse$env._,
+ $iq = _converse$env.$iq,
+ $build = _converse$env.$build,
+ b64_sha1 = _converse$env.b64_sha1,
+ moment = _converse$env.moment,
+ sizzle = _converse$env.sizzle;
+ const u = converse.env.utils;
converse.plugins.add('converse-vcard', {
- initialize: function initialize() {
+ initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
- var _converse = this._converse;
+ const _converse = this._converse;
_converse.VCard = Backbone.Model.extend({
defaults: {
'image': _converse.DEFAULT_IMAGE,
'image_type': _converse.DEFAULT_IMAGE_TYPE
},
- set: function set(key, val, options) {
+
+ set(key, val, options) {
// Override Backbone.Model.prototype.set to make sure that the
// default `image` and `image_type` values are maintained.
- var attrs;
+ let attrs;
- if (_typeof(key) === 'object') {
+ if (typeof key === 'object') {
attrs = key;
options = val;
} else {
@@ -50574,19 +57071,20 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
return Backbone.Model.prototype.set.apply(this, arguments);
}
}
+
});
_converse.VCards = Backbone.Collection.extend({
model: _converse.VCard,
- initialize: function initialize() {
- this.on('add', function (vcard) {
- return _converse.api.vcard.update(vcard);
- });
+
+ initialize() {
+ this.on('add', vcard => _converse.api.vcard.update(vcard));
}
+
});
function onVCardData(jid, iq, callback) {
- var vcard = iq.querySelector('vCard');
- var result = {};
+ const vcard = iq.querySelector('vCard');
+ let result = {};
if (!_.isNull(vcard)) {
result = {
@@ -50604,8 +57102,8 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
}
if (result.image) {
- var buffer = u.base64ToArrayBuffer(result['image']);
- crypto.subtle.digest('SHA-1', buffer).then(function (ab) {
+ const buffer = u.base64ToArrayBuffer(result['image']);
+ crypto.subtle.digest('SHA-1', buffer).then(ab => {
result['image_hash'] = u.arrayBufferToHex(ab);
if (callback) callback(result);
});
@@ -50625,7 +57123,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
}
function createStanza(type, jid, vcard_el) {
- var iq = $iq(jid ? {
+ const iq = $iq(jid ? {
'type': type,
'to': jid
} : {
@@ -50648,7 +57146,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
throw Error("No jid provided for the VCard data");
}
- var vcard_el = Strophe.xmlHtmlNode(tpl_vcard(data)).firstElementChild;
+ const vcard_el = Strophe.xmlHtmlNode(tpl_vcard(data)).firstElementChild;
return _converse.api.sendIQ(createStanza("set", jid, vcard_el));
}
@@ -50659,8 +57157,8 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
* (String) jid - The Jabber ID of the user whose VCard
* is being requested.
*/
- var to = Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
- return new Promise(function (resolve, reject) {
+ const to = Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
+ return new Promise((resolve, reject) => {
_converse.connection.sendIQ(createStanza("get", to), _.partial(onVCardData, jid, _, resolve), _.partial(onVCardError, jid, _, resolve), _converse.IQ_TIMEOUT);
});
}
@@ -50669,7 +57167,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
_converse.initVCardCollection = function () {
_converse.vcards = new _converse.VCards();
- var id = b64_sha1("converse.vcards");
+ const id = b64_sha1(`converse.vcards`);
_converse.vcards.browserStorage = new Backbone.BrowserStorage[_converse.config.get('storage')](id);
_converse.vcards.fetch();
@@ -50677,7 +57175,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
_converse.api.listen.on('sessionInitialized', _converse.initVCardCollection);
- _converse.on('addClientFeatures', function () {
+ _converse.on('addClientFeatures', () => {
_converse.api.disco.own.features.add(Strophe.NS.VCARD);
});
@@ -50708,7 +57206,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
* // Failure
* }).
*/
- 'set': function set(jid, data) {
+ 'set'(jid, data) {
return setVCard(jid, data);
},
@@ -50732,11 +57230,11 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
* );
* });
*/
- 'get': function get(model, force) {
+ 'get'(model, force) {
if (_.isString(model)) {
return getVCard(_converse, model);
} else if (force || !model.get('vcard_updated') || !moment(model.get('vcard_error')).isSame(new Date(), "day")) {
- var jid = model.get('jid');
+ const jid = model.get('jid');
if (!jid) {
throw new Error("No JID to get vcard for!");
@@ -50764,15 +57262,17 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
* _converse.api.vcard.update(chatbox);
* });
*/
- 'update': function update(model, force) {
- return this.get(model, force).then(function (vcard) {
+ 'update'(model, force) {
+ return this.get(model, force).then(vcard => {
delete vcard['stanza'];
model.save(vcard);
});
}
+
}
});
}
+
});
});
@@ -50785,10 +57285,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-/*global define */
+var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*global define */
if (true) {
// The section below determines which plugins will be included in a build
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! converse-core */ "./src/converse-core.js"),
@@ -50826,10 +57323,7 @@ if (true) {
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-// Converse.js (A browser based XMPP chat client)
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Converse.js (A browser based XMPP chat client)
// http://conversejs.org
//
// This is the internationalization module.
@@ -50844,7 +57338,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
-})(void 0, function (Promise, Jed, _, moment) {
+})(this, function (Promise, Jed, _, moment) {
'use strict';
function detectLocale(library_check) {
@@ -50918,13 +57412,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
}
- var jed_instance;
+ let jed_instance;
return {
- setLocales: function setLocales(preferred_locale, _converse) {
+ setLocales(preferred_locale, _converse) {
_converse.locale = getLocale(preferred_locale, _.partial(isConverseLocale, _, _converse.locales));
moment.locale(getLocale(preferred_locale, isMomentLocale));
},
- translate: function translate(str) {
+
+ translate(str) {
if (_.isNil(jed_instance)) {
return Jed.sprintf.apply(Jed, arguments);
}
@@ -50937,7 +57432,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return t.fetch();
}
},
- fetchTranslations: function fetchTranslations(locale, supported_locales, locale_url) {
+
+ fetchTranslations(locale, supported_locales, locale_url) {
/* Fetch the translations for the given local at the given URL.
*
* Parameters:
@@ -50946,19 +57442,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (String) locale_url: The URL from which the translations
* should be fetched.
*/
- return new Promise(function (resolve, reject) {
+ return new Promise((resolve, reject) => {
if (!isConverseLocale(locale, supported_locales) || locale === 'en') {
return resolve();
}
- var xhr = new XMLHttpRequest();
+ const xhr = new XMLHttpRequest();
xhr.open('GET', locale_url, true);
xhr.setRequestHeader('Accept', "application/json, text/javascript");
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 400) {
try {
- var data = window.JSON.parse(xhr.responseText);
+ const data = window.JSON.parse(xhr.responseText);
jed_instance = new Jed(data);
resolve();
} catch (e) {
@@ -50969,14 +57465,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}
};
- xhr.onerror = function (e) {
- var err_message = e ? " Error: ".concat(e.message) : '';
- reject(new Error("Could not fetch translations. Status: ".concat(xhr.statusText, ". ").concat(err_message)));
+ xhr.onerror = e => {
+ const err_message = e ? ` Error: ${e.message}` : '';
+ reject(new Error(`Could not fetch translations. Status: ${xhr.statusText}. ${err_message}`));
};
xhr.send();
});
}
+
};
});
@@ -50989,10 +57486,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-/*global define */
+var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*global define */
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
return Object;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
@@ -51007,10 +57501,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-"use strict";
-var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
-
-!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! lodash */ "lodash"), __webpack_require__(/*! lodash.converter */ "lodash.converter")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (_, lodashConverter) {
+var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! lodash */ "lodash"), __webpack_require__(/*! lodash.converter */ "lodash.converter")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (_, lodashConverter) {
var fp = lodashConverter(_.runInContext());
return fp;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
@@ -51023,10 +57514,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
!*** ./src/polyfill.js ***!
\*************************/
/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
+/***/ (function(module, exports) {
function CustomEvent(event, params) {
params = params || {
@@ -51321,25 +57809,25 @@ __e(o.label_close) +
if (o.status === 'online') { ;
__p += ' checked="checked" ';
} ;
-__p += '\n type="radio" id="radio-online" value="online" name="chat_status" class="custom-control-input">\n