diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..d02a93571 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*~ +*.mo +*.kpf +*.swp +.*.cfg +.hg/ +.bzr/ +.svn/ +.project +.pydevproject + +# OSX +.DS_Store diff --git a/CHANGES.rst b/CHANGES.rst index d1d2b9845..fb3398b83 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -32,7 +32,7 @@ Changelog - Fixed user status handling, which wasn't 100% according to the spec. [jcbrand] - Separate messages according to day in chats. [jcbrand] - Add support for specifying the BOSH bind URL as configuration setting. [jcbrand] -- Improve the message counter to only increment when the window is not focused [witekdev] +- #8 Improve the message counter to only increment when the window is not focused [witekdev] - Make fetching of list of chatrooms on a server a configuration option. [jcbrand] - Use service discovery to show all available features on a room. [jcbrand] - Multi-user chatrooms are now configurable. [jcbrand] diff --git a/Libraries/jarnxmpp.core.handlers.js b/Libraries/jarnxmpp.core.handlers.js deleted file mode 100644 index e0883d539..000000000 --- a/Libraries/jarnxmpp.core.handlers.js +++ /dev/null @@ -1,251 +0,0 @@ -/*global $:false, document:false, window:false, portal_url:false, -$msg:false, Strophe:false, setTimeout:false, navigator:false, jarn:false, google:false, jarnxmpp:false, jQuery:false, sessionStorage:false, $iq:false, $pres:false, Image:false, */ - -(function (jarnxmpp, $, portal_url) { - - portal_url = portal_url || ''; - - jarnxmpp.Storage = { - storage: null, - init: function () { - try { - if ('sessionStorage' in window && window.sessionStorage !== null && JSON in window && window.JSON !== null) { - jarnxmpp.Storage.storage = sessionStorage; - if (!('_user_info' in jarnxmpp.Storage.storage)) { - jarnxmpp.Storage.set('_user_info', {}); - } - if (!('_vCards' in jarnxmpp.Storage.storage)) { - jarnxmpp.Storage.set('_vCards', {}); - } - if (!('_subscriptions' in jarnxmpp.Storage.storage)) { - jarnxmpp.Storage.set('_subscriptions', null); - } - } - } catch (e) {} - }, - - get: function (key) { - if (key in sessionStorage) { - return JSON.parse(sessionStorage[key]); - } - return null; - }, - - set: function (key, value) { - sessionStorage[key] = JSON.stringify(value); - }, - - xmppGet: function (key, callback) { - var stanza = $iq({type: 'get'}) - .c('query', {xmlns: 'jabber:iq:private'}) - .c('jarnxmpp', {xmlns: 'http://jarn.com/ns/jarnxmpp:prefs:' + key}) - .tree(); - jarnxmpp.connection.sendIQ(stanza, function success(result) { - callback($('jarnxmpp ' + 'value', result).first().text()); - }); - }, - - xmppSet: function (key, value) { - var stanza = $iq({type: 'set'}) - .c('query', {xmlns: 'jabber:iq:private'}) - .c('jarnxmpp', {xmlns: 'http://jarn.com/ns/jarnxmpp:prefs:' + key}) - .c('value', value) - .tree(); - jarnxmpp.connection.sendIQ(stanza); - } - }; - - jarnxmpp.Storage.init(); - - jarnxmpp.Presence = { - online: {}, - _user_info: {}, - - onlineCount: function () { - var me = Strophe.getNodeFromJid(jarnxmpp.connection.jid), - counter = 0, - user; - for (user in jarnxmpp.Presence.online) { - if ((jarnxmpp.Presence.online.hasOwnProperty(user)) && user !== me) { - counter += 1; - } - } - return counter; - }, - - getUserInfo: function (user_id, callback) { - // User info on browsers without storage - if (jarnxmpp.Storage.storage === null) { - if (user_id in jarnxmpp.Presence._user_info) { - callback(jarnxmpp.Presence._user_info[user_id]); - } else { - $.getJSON(portal_url + "/xmpp-userinfo?user_id=" + user_id, function (data) { - jarnxmpp.Presence._user_info[user_id] = data; - callback(data); - }); - } - } else { - var _user_info = jarnxmpp.Storage.get('_user_info'); - if (user_id in _user_info) { - callback(_user_info[user_id]); - } else { - $.getJSON(portal_url + "/xmpp-userinfo?user_id=" + user_id, function (data) { - _user_info[user_id] = data; - jarnxmpp.Storage.set('_user_info', _user_info); - callback(data); - }); - } - } - } - }; - - jarnxmpp.vCard = { - - _vCards: {}, - - _getVCard: function (jid, callback) { - var stanza = - $iq({type: 'get', to: jid}) - .c('vCard', {xmlns: 'vcard-temp'}).tree(); - jarnxmpp.connection.sendIQ(stanza, function (data) { - var result = {}; - $('vCard[xmlns="vcard-temp"]', data).children().each(function (idx, element) { - result[element.nodeName] = element.textContent; - }); - if (typeof (callback) !== 'undefined') { - callback(result); - } - }); - }, - - getVCard: function (jid, callback) { - jid = Strophe.getBareJidFromJid(jid); - if (jarnxmpp.Storage.storage === null) { - if (jid in jarnxmpp.vCard._vCards) { - callback(jarnxmpp.vCard._vCards[jid]); - } else { - jarnxmpp.vCard._getVCard(jid, function (result) { - jarnxmpp.vCard._vCards[jid] = result; - callback(result); - }); - } - } else { - var _vCards = jarnxmpp.Storage.get('_vCards'); - if (jid in _vCards) { - callback(_vCards[jid]); - } else { - jarnxmpp.vCard._getVCard(jid, function (result) { - _vCards[jid] = result; - jarnxmpp.Storage.set('_vCards', _vCards); - callback(result); - }); - } - } - }, - - setVCard: function (params, photoUrl) { - var key, - vCard = Strophe.xmlElement('vCard', [['xmlns', 'vcard-temp'], ['version', '2.0']]); - for (key in params) { - if (params.hasOwnProperty(key)) { - vCard.appendChild(Strophe.xmlElement(key, [], params[key])); - } - } - var send = function () { - var stanza = $iq({type: 'set'}).cnode(vCard).tree(); - jarnxmpp.connection.sendIQ(stanza); - }; - if (typeof (photoUrl) === 'undefined') { - send(); - } else { - jarnxmpp.vCard.getBase64Image(photoUrl, function (base64img) { - base64img = base64img.replace(/^data:image\/png;base64,/, ""); - var photo = Strophe.xmlElement('PHOTO'); - photo.appendChild(Strophe.xmlElement('TYPE', [], 'image/png')); - photo.appendChild(Strophe.xmlElement('BINVAL', [], base64img)); - vCard.appendChild(photo); - send(); - }); - } - }, - - getBase64Image: function (url, callback) { - // Create the element, then draw it on a canvas to get the base64 data. - var img = new Image(); - $(img).load(function () { - var canvas = document.createElement('canvas'); - canvas.width = img.width; - canvas.height = img.height; - var ctx = canvas.getContext("2d"); - ctx.drawImage(img, 0, 0); - callback(canvas.toDataURL('image/png')); - }).attr('src', url); - } - }; - - jarnxmpp.onConnect = function (status) { - if ((status === Strophe.Status.ATTACHED) || (status === Strophe.Status.CONNECTED)) { - $(window).bind('beforeunload', function () { - $(document).trigger('jarnxmpp.disconnecting'); - var presence = $pres({type: 'unavailable'}); - jarnxmpp.connection.send(presence); - jarnxmpp.connection.disconnect(); - jarnxmpp.connection.flush(); - }); - $(document).trigger('jarnxmpp.connected'); - } else if (status === Strophe.Status.DISCONNECTED) { - $(document).trigger('jarnxmpp.disconnected'); - } - }; - - jarnxmpp.rawInput = function (data) { - var event = jQuery.Event('jarnxmpp.dataReceived'); - event.text = data; - $(document).trigger(event); - }; - - jarnxmpp.rawOutput = function (data) { - var event = jQuery.Event('jarnxmpp.dataSent'); - event.text = data; - $(document).trigger(event); - }; - - $(document).bind('jarnxmpp.connected', function () { - // Logging - jarnxmpp.connection.rawInput = jarnxmpp.rawInput; - jarnxmpp.connection.rawOutput = jarnxmpp.rawOutput; - }); - - $(document).bind('jarnxmpp.disconnecting', function () { - if (jarnxmpp.Storage.storage !== null) { - jarnxmpp.Storage.set('online-count', jarnxmpp.Presence.onlineCount()); - } - }); - - $(document).ready(function () { - var resource = jarnxmpp.Storage.get('xmppresource'); - if (resource) { - data = {'resource': resource}; - } else { - data = {}; - } - $.ajax({ - 'url':portal_url + '/@@xmpp-loader', - 'dataType': 'json', - 'data': data, - 'success': function (data) { - if (!(('rid' in data) && ('sid' in data) && ('BOSH_SERVICE' in data))) { - return; - } - if (!resource) { - jarnxmpp.Storage.set('xmppresource', Strophe.getResourceFromJid(data.jid)); - } - jarnxmpp.BOSH_SERVICE = data.BOSH_SERVICE; - jarnxmpp.jid = data.jid; - jarnxmpp.connection = new Strophe.Connection(jarnxmpp.BOSH_SERVICE); - jarnxmpp.connection.attach(jarnxmpp.jid, data.sid, data.rid, jarnxmpp.onConnect); - } - }); - }); - -})(window.jarnxmpp = window.jarnxmpp || {}, jQuery, portal_url); diff --git a/Libraries/strophe.muc.js b/Libraries/strophe.muc.js index 1591bd032..9dab34f94 100644 --- a/Libraries/strophe.muc.js +++ b/Libraries/strophe.muc.js @@ -180,7 +180,7 @@ xmlns: Strophe.NS.CLIENT }).t(message); msg.up(); - if (html_message !== null) { + if (html_message != null) { msg.c("html", {xmlns: Strophe.NS.XHTML_IM}).c("body", {xmlns: Strophe.NS.XHTML}).h(html_message); if (msg.node.childNodes.length === 0) { diff --git a/build.js b/build.js index daad093b5..b2091ccd9 100644 --- a/build.js +++ b/build.js @@ -7,7 +7,9 @@ "af": "locale/af/LC_MESSAGES/af", "en": "locale/en/LC_MESSAGES/en", "de": "locale/de/LC_MESSAGES/de", + "es": "locale/es/LC_MESSAGES/es", "hu": "locale/hu/LC_MESSAGES/hu", + "it": "locale/it/LC_MESSAGES/it", "sjcl": "Libraries/sjcl", "tinysort": "Libraries/jquery.tinysort", "underscore": "Libraries/underscore", diff --git a/converse.js b/converse.js index a3e577323..c26120dee 100644 --- a/converse.js +++ b/converse.js @@ -1162,7 +1162,7 @@ '

' + '' + '

' + - '' + + '' + '
'), chatarea_template: _.template( @@ -1247,7 +1247,7 @@ 'hidden': 'hidden', 'list-single': 'dropdown' }; - $form.find('img.spinner').remove(); + $form.find('span.spinner').remove(); $form.append($('').text(title)); if (instructions != title) { $form.append($('

').text(instructions)); @@ -1356,7 +1356,7 @@ this.$el.find('.chat-body').append( $('

'+ '
'+ - ''+ + ''+ ''+ '
')); converse.connection.muc.configure( @@ -1369,12 +1369,12 @@ ev.preventDefault(); var password = this.$el.find('.chatroom-form').find('input[type=password]').val(); this.$el.find('.chatroom-form-container').replaceWith( - ''); + ''); this.connect(password); }, renderPasswordForm: function () { - this.$el.find('img.centered.spinner').remove(); + this.$el.find('span.centered.spinner').remove(); this.$el.find('.chat-body').append( $('
'+ '
'+ @@ -1389,7 +1389,7 @@ showDisconnectMessage: function (msg) { this.$el.find('.chat-area').remove(); this.$el.find('.participants').remove(); - this.$el.find('img.centered.spinner').remove(); + this.$el.find('span.centered.spinner').remove(); this.$el.find('.chat-body').append($('

'+msg+'

')); }, @@ -2510,7 +2510,7 @@ connection = new Strophe.Connection(converse.bosh_service_url); if ($form) { $button = $form.find('input[type=submit]'); - $button.hide().after(''); + $button.hide().after('