Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorsualko <klaus@jsxc.org>2018-05-16 14:54:15 +0300
committersualko <klaus@jsxc.org>2018-05-16 14:54:15 +0300
commit91d1b828ee38961785ddfccbe6d8322621804ebb (patch)
tree5c935338d2d78aa9a63cc7aad6003793c7d7ca36 /js
parent596a223f7ed47d2f8742b18370ab9556934f9714 (diff)
beautify all js and scss files
Diffstat (limited to 'js')
-rw-r--r--js/eof.js2
-rw-r--r--js/ojsxc.js824
-rw-r--r--js/settings/admin.js2
-rw-r--r--js/settings/personal.js6
4 files changed, 418 insertions, 416 deletions
diff --git a/js/eof.js b/js/eof.js
index a63b61f..2b01c42 100644
--- a/js/eof.js
+++ b/js/eof.js
@@ -1,4 +1,4 @@
/**
* This is a helper file for the concatenation.
*/
-; \ No newline at end of file
+;
diff --git a/js/ojsxc.js b/js/ojsxc.js
index bc61c9f..3a52f77 100644
--- a/js/ojsxc.js
+++ b/js/ojsxc.js
@@ -3,45 +3,45 @@
(function($) {
- "use strict";
+ "use strict";
- var serverTypes = {
- INTERNAL: 0,
- EXTERNAL: 1,
- MANAGED: 2
- };
+ var serverTypes = {
+ INTERNAL: 0,
+ EXTERNAL: 1,
+ MANAGED: 2
+ };
- function observeContactsMenu() {
- var target = document.getElementById('contactsmenu');
+ function observeContactsMenu() {
+ var target = document.getElementById('contactsmenu');
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (mutation.target.id !== 'contactsmenu-contacts') {
- return;
- }
-
- $(mutation.target).find('[href^="xmpp:"]').addClass('jsxc_statusIndicator');
+ var observer = new MutationObserver(function(mutations) {
+ mutations.forEach(function(mutation) {
+ if (mutation.target.id !== 'contactsmenu-contacts') {
+ return;
+ }
- $(mutation.target).find('.contact').each(function(){
- updateContactItem($(this));
- });
+ $(mutation.target).find('[href^="xmpp:"]').addClass('jsxc_statusIndicator');
- jsxc.gui.detectUriScheme(mutation.target);
+ $(mutation.target).find('.contact').each(function() {
+ updateContactItem($(this));
});
- });
- var config = {
- attributes: true,
- childList: true,
- characterData: true,
- subtree: true
- };
+ jsxc.gui.detectUriScheme(mutation.target);
+ });
+ });
- observer.observe(target, config);
- }
+ var config = {
+ attributes: true,
+ childList: true,
+ characterData: true,
+ subtree: true
+ };
- function updateContactItem(contactElement) {
- var xmppAddresses = contactElement.find('[href^="xmpp:"]').map(function(){
+ observer.observe(target, config);
+ }
+
+ function updateContactItem(contactElement) {
+ var xmppAddresses = contactElement.find('[href^="xmpp:"]').map(function() {
return $(this).attr('href').replace(/^xmpp:/, '');
});
@@ -53,7 +53,7 @@
var highestPresent = jsxc.CONST.STATUS.indexOf('offline');
var highestPresentBid = xmppAddresses.get(0);
- xmppAddresses.each(function(index, bid){
+ xmppAddresses.each(function(index, bid) {
var lastMsg = jsxc.getLastMsg(bid);
if (lastMsg) {
@@ -68,8 +68,10 @@
}
});
- var latestMsg = {date: 0};
- $(lastMessages).each(function(index, msg){
+ var latestMsg = {
+ date: 0
+ };
+ $(lastMessages).each(function(index, msg) {
if (msg.date > latestMsg.date) {
latestMsg = msg;
}
@@ -98,401 +100,401 @@
jsxc.gui.queryActions.message(highestPresentBid);
});
}
- }
+ }
- function injectChatIcon() {
- var div = $('<div/>');
+ function injectChatIcon() {
+ var div = $('<div/>');
- div.addClass('jsxc_chatIcon');
- div.click(function() {
- jsxc.gui.roster.toggle();
- });
+ div.addClass('jsxc_chatIcon');
+ div.click(function() {
+ jsxc.gui.roster.toggle();
+ });
- $('#header form.searchbox').after(div);
+ $('#header form.searchbox').after(div);
- }
+ }
- function onRosterToggle(ev, state, duration) {
- $('body').removeClass('jsxc-roster-hidden jsxc-roster-shown').addClass('jsxc-roster-' + state);
+ function onRosterToggle(ev, state, duration) {
+ $('body').removeClass('jsxc-roster-hidden jsxc-roster-shown').addClass('jsxc-roster-' + state);
- // trigger nextcloud/owncloud triggers
- setTimeout(function() {
- $(window).resize();
- }, duration + 50);
- }
+ // trigger nextcloud/owncloud triggers
+ setTimeout(function() {
+ $(window).resize();
+ }, duration + 50);
+ }
- function onRosterReady(ev, rosterState) {
- injectChatIcon();
+ function onRosterReady(ev, rosterState) {
+ injectChatIcon();
- $('body').removeClass('jsxc-roster-hidden jsxc-roster-shown').addClass('jsxc-roster-' + rosterState);
+ $('body').removeClass('jsxc-roster-hidden jsxc-roster-shown').addClass('jsxc-roster-' + rosterState);
- // update webodf
- $(window).on('hashchange', function() {
- if (window.location.pathname.match(/\/documents\/$/)) {
- var docNo = window.location.hash.replace(/^#/, '');
+ // update webodf
+ $(window).on('hashchange', function() {
+ if (window.location.pathname.match(/\/documents\/$/)) {
+ var docNo = window.location.hash.replace(/^#/, '');
- if (docNo.match(/[0-9]+/) && typeof dijit !== 'undefined') {
- dijit.byId("mainContainer").resize();
- }
+ if (docNo.match(/[0-9]+/) && typeof dijit !== 'undefined') {
+ dijit.byId("mainContainer").resize();
}
- });
- }
-
- function defaultAvatar(element, jid) {
- var adminSettings = jsxc.options.get('adminSettings') || {};
- var cache = jsxc.storage.getUserItem('defaultAvatars') || {};
- var data = jsxc.storage.getUserItem('buddy', jsxc.jidToBid(jid)) || {};
-
- var node = Strophe.getNodeFromJid(jid);
- var domain = Strophe.getDomainFromJid(jid);
- var user = Strophe.unescapeNode(node);
-
- $(element).each(function() {
-
- var $div = $(this).find('.jsxc_avatar');
- var size = $div.width();
- var key = user + '@' + size;
-
- var handleResponse = function(result) {
- if (typeof(result) === 'object') {
- if (result.data && result.data.displayname) {
- $div.imageplaceholder(user, result.data.displayname);
- } else {
- $div.imageplaceholder(user);
- }
- } else {
- $div.css('backgroundImage', 'url(' + result + ')');
- $div.text('');
- }
- };
-
- if (domain !== adminSettings.xmppDomain) {
- // probably external user, don't request avatar
- $div.imageplaceholder(user);
- } else if (typeof cache[key] === 'undefined' || cache[key] === null) {
- if (data.status === 0) {
- // don't query avatar for offline users
- $div.imageplaceholder(user, data.name);
-
- return;
- }
-
- var url;
-
- url = OC.generateUrl('/avatar/' + encodeURIComponent(user) + '/' + size + '?requesttoken={requesttoken}', {
- user: user,
- size: size,
- requesttoken: oc_requesttoken
- });
-
- $.get(url, function(result) {
-
- var val = (typeof result === 'object') ? result : url;
- handleResponse(val);
-
- jsxc.storage.updateItem('defaultAvatars', key, val, true);
- });
-
+ }
+ });
+ }
+
+ function defaultAvatar(element, jid) {
+ var adminSettings = jsxc.options.get('adminSettings') || {};
+ var cache = jsxc.storage.getUserItem('defaultAvatars') || {};
+ var data = jsxc.storage.getUserItem('buddy', jsxc.jidToBid(jid)) || {};
+
+ var node = Strophe.getNodeFromJid(jid);
+ var domain = Strophe.getDomainFromJid(jid);
+ var user = Strophe.unescapeNode(node);
+
+ $(element).each(function() {
+
+ var $div = $(this).find('.jsxc_avatar');
+ var size = $div.width();
+ var key = user + '@' + size;
+
+ var handleResponse = function(result) {
+ if (typeof(result) === 'object') {
+ if (result.data && result.data.displayname) {
+ $div.imageplaceholder(user, result.data.displayname);
+ } else {
+ $div.imageplaceholder(user);
+ }
} else {
- handleResponse(cache[key]);
- }
- });
- }
-
- function loadSettings(username, password, cb) {
- $.ajax({
- type: 'POST',
- url: OC.generateUrl('apps/ojsxc/settings'),
- data: {
- username: username,
- password: password
- },
- success: function(d) {
- if (d.result === 'success' && d.data && d.data.serverType !== 'internal' && d.data.xmpp.url !== '' && d.data.xmpp.url !== null) {
- jsxc.storage.setItem('serverType', serverTypes[d.data.serverType.toUpperCase()]);
- cb(d.data);
- } else if (d.data && d.data.serverType === 'internal') {
- jsxc.storage.setItem('serverType', serverTypes.INTERNAL);
-
- var node = username || OC.currentUser;
- jsxc.bid = node.toLowerCase() + '@' + window.location.host;
-
- jsxc.options.set('adminSettings', d.data.adminSettings);
-
- if (d.data.loginForm) {
- jsxc.options.set('loginForm', {
- startMinimized: d.data.loginForm.startMinimized
- });
- }
-
- cb(false);
- } else {
- cb(false);
- }
- },
- error: function(xhr) {
- jsxc.error('XHR error on getSettings.php');
-
- if (xhr.responseJSON && xhr.responseJSON.message) {
- jsxc.debug('Error message: ' + xhr.responseJSON.message);
- }
-
- if (xhr.status === 412) {
- jsxc.debug('Refresh page to get a new CSRF token');
-
- window.location.href = window.location.href;
- return;
- }
-
- cb(false);
+ $div.css('backgroundImage', 'url(' + result + ')');
+ $div.text('');
}
- });
- }
-
- function saveSettinsPermanent(data, cb) {
- $.ajax({
- type: 'POST',
- url: OC.generateUrl('apps/ojsxc/settings/user'),
- data: data,
- success: function(data) {
- cb(data && data.status === 'success');
- },
- error: function() {
- cb(false);
- }
- });
- }
-
- function getUsers(search, cb) {
- $.ajax({
- type: 'GET',
- url: OC.generateUrl('apps/ojsxc/settings/users'),
- data: {
- search: search
- },
- success: cb,
- error: function() {
- jsxc.error('XHR error on getUsers.php');
- }
- });
- }
-
- function getViewportSize() {
- var w = $(window).width() - $('#jsxc_windowListSB').width();
- var h = $(window).height() - $('#header').height() - 10;
-
- if (jsxc.storage.getUserItem('roster') === 'shown') {
- w -= $('#jsxc_roster').outerWidth(true);
- }
-
- return {
- width: w,
- height: h
- };
- }
-
- function addChatSubmitButton() {
- var submitWrapperElement = $('#submit-wrapper');
- var jsxcSubmitWrapperElement = $('<div>');
- jsxcSubmitWrapperElement.attr('id', 'jsxc_submit_wrapper');
-
- var submitElement = $('<input>');
- submitElement.attr({
- type: 'button',
- id: 'jsxc_submit',
- });
- submitElement.addClass('login primary');
- submitElement.val($.t('Log_in_without_chat'));
- submitElement.click(function() {
- jsxc.storage.setItem('login_without_chat', true);
- jsxc.submitLoginForm();
- });
-
- jsxcSubmitWrapperElement.append(submitElement);
- $('.login-additional').prepend(jsxcSubmitWrapperElement);
-
- $('#lost-password').mouseup(function(ev) {
- ev.preventDefault();
-
- jsxcSubmitWrapperElement.slideUp().fadeOut();
- });
- $('#lost-password-back').mouseup(function(ev) {
- ev.preventDefault();
-
- jsxcSubmitWrapperElement.slideDown().fadeIn();
- });
- }
-
- // initialization
- $(function() {
- if (location.pathname.substring(location.pathname.lastIndexOf("/") + 1) === 'public.php') {
- // abort on shares
- return;
- }
-
- if (window.parent && window !== window.parent) {
- // abort if inside a frame
- return;
- }
-
- if (typeof jsxc === 'undefined' || typeof emojione === 'undefined') {
- // abort if core or dependencies threw an error
- return;
- }
-
- if (typeof oc_config === 'undefined' || typeof oc_appswebroots === 'undefined' || typeof OC === 'undefined') {
- // abort if a dependency is missing
- return;
- }
-
- if (OC.generateUrl('login/flow') === window.location.pathname) {
- // abort on login flow
- return;
- }
-
- $(document).one('ready-roster-jsxc', onRosterReady);
- $(document).on('toggle.roster.jsxc', onRosterToggle);
-
- $(document).on('connected.jsxc', function() {
- // reset default avatar cache
- jsxc.storage.removeUserItem('defaultAvatars');
- // when we are connected it doesn't matter anymore whether we logged in without chat since the user
- // must have manually logged in
- jsxc.storage.setItem('login_without_chat', false);
- });
-
- $(document).on('connfail.jsxc', function(ev, condition) {
- if (condition === 'x-nc-not_allowed_to_chat') {
- jsxc.gui.roster.toggle(jsxc.CONST.HIDDEN);
- $('.jsxc_chatIcon').remove();
- jsxc.storage.removeItem('jid');
- jsxc.storage.removeItem('sid');
- jsxc.storage.removeItem('rid');
+ };
+
+ if (domain !== adminSettings.xmppDomain) {
+ // probably external user, don't request avatar
+ $div.imageplaceholder(user);
+ } else if (typeof cache[key] === 'undefined' || cache[key] === null) {
+ if (data.status === 0) {
+ // don't query avatar for offline users
+ $div.imageplaceholder(user, data.name);
+
+ return;
}
- });
- $(document).on('status.contacts.count status.contact.updated', function() {
- if (jsxc.restoreCompleted) {
- setTimeout(function() {
- jsxc.gui.detectEmail($('table#contactlist'));
- }, 500);
+ var url;
+
+ url = OC.generateUrl('/avatar/' + encodeURIComponent(user) + '/' + size + '?requesttoken={requesttoken}', {
+ user: user,
+ size: size,
+ requesttoken: oc_requesttoken
+ });
+
+ $.get(url, function(result) {
+
+ var val = (typeof result === 'object') ? result : url;
+ handleResponse(val);
+
+ jsxc.storage.updateItem('defaultAvatars', key, val, true);
+ });
+
+ } else {
+ handleResponse(cache[key]);
+ }
+ });
+ }
+
+ function loadSettings(username, password, cb) {
+ $.ajax({
+ type: 'POST',
+ url: OC.generateUrl('apps/ojsxc/settings'),
+ data: {
+ username: username,
+ password: password
+ },
+ success: function(d) {
+ if (d.result === 'success' && d.data && d.data.serverType !== 'internal' && d.data.xmpp.url !== '' && d.data.xmpp.url !== null) {
+ jsxc.storage.setItem('serverType', serverTypes[d.data.serverType.toUpperCase()]);
+ cb(d.data);
+ } else if (d.data && d.data.serverType === 'internal') {
+ jsxc.storage.setItem('serverType', serverTypes.INTERNAL);
+
+ var node = username || OC.currentUser;
+ jsxc.bid = node.toLowerCase() + '@' + window.location.host;
+
+ jsxc.options.set('adminSettings', d.data.adminSettings);
+
+ if (d.data.loginForm) {
+ jsxc.options.set('loginForm', {
+ startMinimized: d.data.loginForm.startMinimized
+ });
+ }
+
+ cb(false);
} else {
- $(document).on('restoreCompleted.jsxc', function() {
- jsxc.gui.detectEmail($('table#contactlist'));
- });
+ cb(false);
}
- });
-
- jsxc.init({
- app_name: 'Nextcloud',
- loginForm: {
- form: '#body-login form',
- jid: '#user',
- pass: '#password',
- ifFound: 'force',
- onConnecting: (oc_config.version.match(/^([8-9]|[0-9]{2,})+\./)) ? 'quiet' : 'dialog'
- },
- logoutElement: $('#logout'),
- rosterAppend: 'body',
- root: oc_appswebroots.ojsxc + '/js/jsxc',
- RTCPeerConfig: {
- url: OC.generateUrl('apps/ojsxc/settings/iceServers')
- },
- displayRosterMinimized: function() {
- return OC.currentUser != null;
- },
- defaultAvatar: function(jid) {
- defaultAvatar(this, jid);
- },
- loadSettings: loadSettings,
- saveSettinsPermanent: saveSettinsPermanent,
- getUsers: getUsers,
- viewport: {
- getSize: getViewportSize
+ },
+ error: function(xhr) {
+ jsxc.error('XHR error on getSettings.php');
+
+ if (xhr.responseJSON && xhr.responseJSON.message) {
+ jsxc.debug('Error message: ' + xhr.responseJSON.message);
}
- });
-
- // Add submit link without chat functionality
- if (jsxc.el_exists(jsxc.options.loginForm.form) && jsxc.el_exists(jsxc.options.loginForm.jid) && jsxc.el_exists(jsxc.options.loginForm.pass)) {
-
- addChatSubmitButton();
-
- Strophe.log = function(level, msg) {
- if (level === 3 && /^request id/.test(msg)) {
- console.warn('Something went wrong during BOSH connection establishment. Continue without chat.');
-
- jsxc.submitLoginForm();
- }
- };
- }
-
- if ($('#contactsmenu').length > 0) {
- observeContactsMenu();
- }
-
- });
-
- $(document).on('click', '#jsxc_roster p', function() {
- if (jsxc.storage.getItem('serverType') === serverTypes.INTERNAL) {
- startInternalBackend();
- }
- });
-
- function startInternalBackend() {
- var currentUser = OC.currentUser;
-
- if (!currentUser) {
- return;
- }
-
- jsxc.bid = currentUser.toLowerCase() + '@' + window.location.host;
-
- jsxc.options.set('xmpp', {
- url: OC.generateUrl('apps/ojsxc/http-bind')
- });
-
- $(document).one('attached.jsxc', function() {
- if (jsxc.options.get('loginForm').startMinimized !== true) {
- jsxc.gui.roster.toggle(jsxc.CONST.SHOWN);
- }
- });
-
- jsxc.start(jsxc.bid + '/internal', 'internal', '123456');
- }
-
- if (jsxc.storage.getItem('serverType') === serverTypes.INTERNAL) {
- jsxc.gui.showLoginBox = function(){};
- }
-
- $(document).on('stateChange.jsxc', function _handler(event, state) {
- if (state === jsxc.CONST.STATE.SUSPEND) {
- /**
- * The first time we go into suspend mode we check if we are using the internal backend.
- * If this is the case and the user explicitly press the "login_without_chat" button when logging
- * into Nextcloud we know we are using another authentication mechanism (like SAML/SSO) and thus have
- * to manually start the connection.
- */
- var chatDisabledByUser = jsxc.storage.getUserItem('forcedLogout') || jsxc.storage.getItem('login_without_chat');
- $(document).off('stateChange.jsxc', _handler);
- if (jsxc.storage.getItem('serverType') === null) {
- $.ajax({
- url: OC.generateUrl('apps/ojsxc/settings/servertype'),
- success: function (data) {
- jsxc.storage.setItem('serverType', serverTypes[data.serverType.toUpperCase()]);
-
- if (data.serverType === 'internal' && !chatDisabledByUser) {
- jsxc.gui.showLoginBox = function(){};
- startInternalBackend();
- }
- }
- });
- } else if (jsxc.storage.getItem('serverType') === serverTypes.INTERNAL && !chatDisabledByUser) {
- jsxc.gui.showLoginBox = function(){};
- startInternalBackend();
+
+ if (xhr.status === 412) {
+ jsxc.debug('Refresh page to get a new CSRF token');
+
+ window.location.href = window.location.href;
+ return;
+ }
+
+ cb(false);
+ }
+ });
+ }
+
+ function saveSettinsPermanent(data, cb) {
+ $.ajax({
+ type: 'POST',
+ url: OC.generateUrl('apps/ojsxc/settings/user'),
+ data: data,
+ success: function(data) {
+ cb(data && data.status === 'success');
+ },
+ error: function() {
+ cb(false);
+ }
+ });
+ }
+
+ function getUsers(search, cb) {
+ $.ajax({
+ type: 'GET',
+ url: OC.generateUrl('apps/ojsxc/settings/users'),
+ data: {
+ search: search
+ },
+ success: cb,
+ error: function() {
+ jsxc.error('XHR error on getUsers.php');
+ }
+ });
+ }
+
+ function getViewportSize() {
+ var w = $(window).width() - $('#jsxc_windowListSB').width();
+ var h = $(window).height() - $('#header').height() - 10;
+
+ if (jsxc.storage.getUserItem('roster') === 'shown') {
+ w -= $('#jsxc_roster').outerWidth(true);
+ }
+
+ return {
+ width: w,
+ height: h
+ };
+ }
+
+ function addChatSubmitButton() {
+ var submitWrapperElement = $('#submit-wrapper');
+ var jsxcSubmitWrapperElement = $('<div>');
+ jsxcSubmitWrapperElement.attr('id', 'jsxc_submit_wrapper');
+
+ var submitElement = $('<input>');
+ submitElement.attr({
+ type: 'button',
+ id: 'jsxc_submit',
+ });
+ submitElement.addClass('login primary');
+ submitElement.val($.t('Log_in_without_chat'));
+ submitElement.click(function() {
+ jsxc.storage.setItem('login_without_chat', true);
+ jsxc.submitLoginForm();
+ });
+
+ jsxcSubmitWrapperElement.append(submitElement);
+ $('.login-additional').prepend(jsxcSubmitWrapperElement);
+
+ $('#lost-password').mouseup(function(ev) {
+ ev.preventDefault();
+
+ jsxcSubmitWrapperElement.slideUp().fadeOut();
+ });
+ $('#lost-password-back').mouseup(function(ev) {
+ ev.preventDefault();
+
+ jsxcSubmitWrapperElement.slideDown().fadeIn();
+ });
+ }
+
+ // initialization
+ $(function() {
+ if (location.pathname.substring(location.pathname.lastIndexOf("/") + 1) === 'public.php') {
+ // abort on shares
+ return;
+ }
+
+ if (window.parent && window !== window.parent) {
+ // abort if inside a frame
+ return;
+ }
+
+ if (typeof jsxc === 'undefined' || typeof emojione === 'undefined') {
+ // abort if core or dependencies threw an error
+ return;
+ }
+
+ if (typeof oc_config === 'undefined' || typeof oc_appswebroots === 'undefined' || typeof OC === 'undefined') {
+ // abort if a dependency is missing
+ return;
+ }
+
+ if (OC.generateUrl('login/flow') === window.location.pathname) {
+ // abort on login flow
+ return;
+ }
+
+ $(document).one('ready-roster-jsxc', onRosterReady);
+ $(document).on('toggle.roster.jsxc', onRosterToggle);
+
+ $(document).on('connected.jsxc', function() {
+ // reset default avatar cache
+ jsxc.storage.removeUserItem('defaultAvatars');
+ // when we are connected it doesn't matter anymore whether we logged in without chat since the user
+ // must have manually logged in
+ jsxc.storage.setItem('login_without_chat', false);
+ });
+
+ $(document).on('connfail.jsxc', function(ev, condition) {
+ if (condition === 'x-nc-not_allowed_to_chat') {
+ jsxc.gui.roster.toggle(jsxc.CONST.HIDDEN);
+ $('.jsxc_chatIcon').remove();
+ jsxc.storage.removeItem('jid');
+ jsxc.storage.removeItem('sid');
+ jsxc.storage.removeItem('rid');
+ }
+ });
+
+ $(document).on('status.contacts.count status.contact.updated', function() {
+ if (jsxc.restoreCompleted) {
+ setTimeout(function() {
+ jsxc.gui.detectEmail($('table#contactlist'));
+ }, 500);
+ } else {
+ $(document).on('restoreCompleted.jsxc', function() {
+ jsxc.gui.detectEmail($('table#contactlist'));
+ });
+ }
+ });
+
+ jsxc.init({
+ app_name: 'Nextcloud',
+ loginForm: {
+ form: '#body-login form',
+ jid: '#user',
+ pass: '#password',
+ ifFound: 'force',
+ onConnecting: (oc_config.version.match(/^([8-9]|[0-9]{2,})+\./)) ? 'quiet' : 'dialog'
+ },
+ logoutElement: $('#logout'),
+ rosterAppend: 'body',
+ root: oc_appswebroots.ojsxc + '/js/jsxc',
+ RTCPeerConfig: {
+ url: OC.generateUrl('apps/ojsxc/settings/iceServers')
+ },
+ displayRosterMinimized: function() {
+ return OC.currentUser != null;
+ },
+ defaultAvatar: function(jid) {
+ defaultAvatar(this, jid);
+ },
+ loadSettings: loadSettings,
+ saveSettinsPermanent: saveSettinsPermanent,
+ getUsers: getUsers,
+ viewport: {
+ getSize: getViewportSize
+ }
+ });
+
+ // Add submit link without chat functionality
+ if (jsxc.el_exists(jsxc.options.loginForm.form) && jsxc.el_exists(jsxc.options.loginForm.jid) && jsxc.el_exists(jsxc.options.loginForm.pass)) {
+
+ addChatSubmitButton();
+
+ Strophe.log = function(level, msg) {
+ if (level === 3 && /^request id/.test(msg)) {
+ console.warn('Something went wrong during BOSH connection establishment. Continue without chat.');
+
+ jsxc.submitLoginForm();
}
- } else if (state === jsxc.CONST.STATE.READY) {
- // if JSXC is ready this means we successfully connected and thus don't have to listen to the suspend state
- $(document).off('stateChange.jsxc', _handler);
- }
- });
+ };
+ }
+
+ if ($('#contactsmenu').length > 0) {
+ observeContactsMenu();
+ }
+
+ });
+
+ $(document).on('click', '#jsxc_roster p', function() {
+ if (jsxc.storage.getItem('serverType') === serverTypes.INTERNAL) {
+ startInternalBackend();
+ }
+ });
+
+ function startInternalBackend() {
+ var currentUser = OC.currentUser;
+
+ if (!currentUser) {
+ return;
+ }
+
+ jsxc.bid = currentUser.toLowerCase() + '@' + window.location.host;
+
+ jsxc.options.set('xmpp', {
+ url: OC.generateUrl('apps/ojsxc/http-bind')
+ });
+
+ $(document).one('attached.jsxc', function() {
+ if (jsxc.options.get('loginForm').startMinimized !== true) {
+ jsxc.gui.roster.toggle(jsxc.CONST.SHOWN);
+ }
+ });
+
+ jsxc.start(jsxc.bid + '/internal', 'internal', '123456');
+ }
+
+ if (jsxc.storage.getItem('serverType') === serverTypes.INTERNAL) {
+ jsxc.gui.showLoginBox = function() {};
+ }
+
+ $(document).on('stateChange.jsxc', function _handler(event, state) {
+ if (state === jsxc.CONST.STATE.SUSPEND) {
+ /**
+ * The first time we go into suspend mode we check if we are using the internal backend.
+ * If this is the case and the user explicitly press the "login_without_chat" button when logging
+ * into Nextcloud we know we are using another authentication mechanism (like SAML/SSO) and thus have
+ * to manually start the connection.
+ */
+ var chatDisabledByUser = jsxc.storage.getUserItem('forcedLogout') || jsxc.storage.getItem('login_without_chat');
+ $(document).off('stateChange.jsxc', _handler);
+ if (jsxc.storage.getItem('serverType') === null) {
+ $.ajax({
+ url: OC.generateUrl('apps/ojsxc/settings/servertype'),
+ success: function(data) {
+ jsxc.storage.setItem('serverType', serverTypes[data.serverType.toUpperCase()]);
+
+ if (data.serverType === 'internal' && !chatDisabledByUser) {
+ jsxc.gui.showLoginBox = function() {};
+ startInternalBackend();
+ }
+ }
+ });
+ } else if (jsxc.storage.getItem('serverType') === serverTypes.INTERNAL && !chatDisabledByUser) {
+ jsxc.gui.showLoginBox = function() {};
+ startInternalBackend();
+ }
+ } else if (state === jsxc.CONST.STATE.READY) {
+ // if JSXC is ready this means we successfully connected and thus don't have to listen to the suspend state
+ $(document).off('stateChange.jsxc', _handler);
+ }
+ });
}(jQuery));
diff --git a/js/settings/admin.js b/js/settings/admin.js
index 1a81555..a3a8ab4 100644
--- a/js/settings/admin.js
+++ b/js/settings/admin.js
@@ -273,7 +273,7 @@ $(document).ready(function() {
});
});
- $('.ojsxc-refresh-registration').click(function(ev){
+ $('.ojsxc-refresh-registration').click(function(ev) {
ev.preventDefault();
var msgEl = $(this).parents('.msg');
diff --git a/js/settings/personal.js b/js/settings/personal.js
index e28ebc8..a8cfc2b 100644
--- a/js/settings/personal.js
+++ b/js/settings/personal.js
@@ -3,8 +3,8 @@
(function($) {
"use strict";
- $(function(){
- $('#ojsxc-settings [name="loginFormEnable"]').change(function(){
+ $(function() {
+ $('#ojsxc-settings [name="loginFormEnable"]').change(function() {
var loginFormData = {
enable: $(this).prop('checked')
};
@@ -20,7 +20,7 @@
data: {
loginForm: loginFormData
},
- success: function(data){
+ success: function(data) {
if (data && data.status === 'success') {
console.log('loginFormEnable saved.');
}