diff --git a/src/messenger/webim/js/compiled/users/app.js b/src/messenger/webim/js/compiled/users/app.js index 8fc54ffa..cfa8c6bc 100644 --- a/src/messenger/webim/js/compiled/users/app.js +++ b/src/messenger/webim/js/compiled/users/app.js @@ -5,6 +5,6 @@ Copyright (c) 2005-2011 Mibew Messenger Community License: http://mibew.org/license.php */ -(function(a,g,h){var b=new g.Marionette.Application;b.addRegions({agentsRegion:"#agents-region",statusPanelRegion:"#status-panel-region",threadsRegion:"#threads-region",visitorsRegion:"#visitors-region",soundRegion:"#sound-region"});b.addInitializer(function(e){var f=a.Objects,c=a.Objects.Models,d=a.Objects.Collections;f.server=new a.Server(h.extend({interactionType:MibewAPIUsersInteraction},e.server));c.page=new a.Models.Page(e.page);c.agent=new a.Models.Agent(e.agent);d.threads=new a.Collections.Threads; -b.threadsRegion.show(new a.Views.ThreadsCollection({collection:d.threads}));e.page.showOnlineOperators&&(d.visitors=new a.Collections.Visitors,b.visitorsRegion.show(new a.Views.VisitorsCollection({collection:d.visitors})));c.statusPanel=new a.Models.StatusPanel;b.statusPanelRegion.show(new a.Views.StatusPanel({model:c.statusPanel}));e.page.showOnlineOperators&&(d.agents=new a.Collections.Agents,b.agentsRegion.show(new a.Views.AgentsCollection({collection:d.agents})));c.sound=new a.Models.Sound;b.soundRegion.show(new a.Views.Sound({model:c.sound})); -f.server.callFunctionsPeriodically(function(){return[{"function":"update",arguments:{"return":{},references:{},agentId:c.agent.id}}]},function(){})});b.on("start",function(){a.Objects.server.runUpdater()});a.Application=b})(Mibew,Backbone,_); +(function(a,h,j){var d=0,g=function(){d++;10==d&&(alert(a.Localization.get("pending.errors.network")),d=0)},b=new h.Marionette.Application;b.addRegions({agentsRegion:"#agents-region",statusPanelRegion:"#status-panel-region",threadsRegion:"#threads-region",visitorsRegion:"#visitors-region",soundRegion:"#sound-region"});b.addInitializer(function(f){var d=a.Objects,c=a.Objects.Models,e=a.Objects.Collections;d.server=new a.Server(j.extend({interactionType:MibewAPIUsersInteraction,onTimeout:g,onTransportError:g}, +f.server));c.page=new a.Models.Page(f.page);c.agent=new a.Models.Agent(f.agent);e.threads=new a.Collections.Threads;b.threadsRegion.show(new a.Views.ThreadsCollection({collection:e.threads}));f.page.showOnlineOperators&&(e.visitors=new a.Collections.Visitors,b.visitorsRegion.show(new a.Views.VisitorsCollection({collection:e.visitors})));c.statusPanel=new a.Models.StatusPanel;b.statusPanelRegion.show(new a.Views.StatusPanel({model:c.statusPanel}));f.page.showOnlineOperators&&(e.agents=new a.Collections.Agents, +b.agentsRegion.show(new a.Views.AgentsCollection({collection:e.agents})));c.sound=new a.Models.Sound;b.soundRegion.show(new a.Views.Sound({model:c.sound}));d.server.callFunctionsPeriodically(function(){return[{"function":"update",arguments:{"return":{},references:{},agentId:c.agent.id}}]},function(){})});b.on("start",function(){a.Objects.server.runUpdater()});a.Application=b})(Mibew,Backbone,_); diff --git a/src/messenger/webim/js/compiled/users_app.js b/src/messenger/webim/js/compiled/users_app.js index e206a332..c187a850 100644 --- a/src/messenger/webim/js/compiled/users_app.js +++ b/src/messenger/webim/js/compiled/users_app.js @@ -157,6 +157,6 @@ this.updateStyles,this)}})})(Mibew,Backbone,Handlebars,_); Copyright (c) 2005-2011 Mibew Messenger Community License: http://mibew.org/license.php */ -(function(a,g,h){var b=new g.Marionette.Application;b.addRegions({agentsRegion:"#agents-region",statusPanelRegion:"#status-panel-region",threadsRegion:"#threads-region",visitorsRegion:"#visitors-region",soundRegion:"#sound-region"});b.addInitializer(function(e){var f=a.Objects,c=a.Objects.Models,d=a.Objects.Collections;f.server=new a.Server(h.extend({interactionType:MibewAPIUsersInteraction},e.server));c.page=new a.Models.Page(e.page);c.agent=new a.Models.Agent(e.agent);d.threads=new a.Collections.Threads; -b.threadsRegion.show(new a.Views.ThreadsCollection({collection:d.threads}));e.page.showOnlineOperators&&(d.visitors=new a.Collections.Visitors,b.visitorsRegion.show(new a.Views.VisitorsCollection({collection:d.visitors})));c.statusPanel=new a.Models.StatusPanel;b.statusPanelRegion.show(new a.Views.StatusPanel({model:c.statusPanel}));e.page.showOnlineOperators&&(d.agents=new a.Collections.Agents,b.agentsRegion.show(new a.Views.AgentsCollection({collection:d.agents})));c.sound=new a.Models.Sound;b.soundRegion.show(new a.Views.Sound({model:c.sound})); -f.server.callFunctionsPeriodically(function(){return[{"function":"update",arguments:{"return":{},references:{},agentId:c.agent.id}}]},function(){})});b.on("start",function(){a.Objects.server.runUpdater()});a.Application=b})(Mibew,Backbone,_); +(function(a,h,j){var d=0,g=function(){d++;10==d&&(alert(a.Localization.get("pending.errors.network")),d=0)},b=new h.Marionette.Application;b.addRegions({agentsRegion:"#agents-region",statusPanelRegion:"#status-panel-region",threadsRegion:"#threads-region",visitorsRegion:"#visitors-region",soundRegion:"#sound-region"});b.addInitializer(function(f){var d=a.Objects,c=a.Objects.Models,e=a.Objects.Collections;d.server=new a.Server(j.extend({interactionType:MibewAPIUsersInteraction,onTimeout:g,onTransportError:g}, +f.server));c.page=new a.Models.Page(f.page);c.agent=new a.Models.Agent(f.agent);e.threads=new a.Collections.Threads;b.threadsRegion.show(new a.Views.ThreadsCollection({collection:e.threads}));f.page.showOnlineOperators&&(e.visitors=new a.Collections.Visitors,b.visitorsRegion.show(new a.Views.VisitorsCollection({collection:e.visitors})));c.statusPanel=new a.Models.StatusPanel;b.statusPanelRegion.show(new a.Views.StatusPanel({model:c.statusPanel}));f.page.showOnlineOperators&&(e.agents=new a.Collections.Agents, +b.agentsRegion.show(new a.Views.AgentsCollection({collection:e.agents})));c.sound=new a.Models.Sound;b.soundRegion.show(new a.Views.Sound({model:c.sound}));d.server.callFunctionsPeriodically(function(){return[{"function":"update",arguments:{"return":{},references:{},agentId:c.agent.id}}]},function(){})});b.on("start",function(){a.Objects.server.runUpdater()});a.Application=b})(Mibew,Backbone,_); diff --git a/src/messenger/webim/js/source/users/app.js b/src/messenger/webim/js/source/users/app.js index 4140d08d..db56d33e 100644 --- a/src/messenger/webim/js/source/users/app.js +++ b/src/messenger/webim/js/source/users/app.js @@ -8,6 +8,26 @@ (function(Mibew, Backbone, _){ + /** + * Represent count of bad AJAX request + * @type Number + */ + var badRequestsCount = 0; + + /** + * Increase badRequestsCount and show reconnect message if need. + * Calls on every bad request. + */ + var requestErrorHandler = function() { + // Increase bad requests count + badRequestsCount++; + // Check if there is + if (badRequestsCount == 10) { + alert(Mibew.Localization.get('pending.errors.network')); + badRequestsCount = 0; + } + } + // Create application instance var App = new Backbone.Marionette.Application(); @@ -30,7 +50,11 @@ // Initialize Server, Thread and User objs.server = new Mibew.Server(_.extend( - {'interactionType': MibewAPIUsersInteraction}, + { + 'interactionType': MibewAPIUsersInteraction, + onTimeout: requestErrorHandler, + onTransportError: requestErrorHandler + }, options.server )); diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 771f905a..bce42121 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -408,6 +408,7 @@ page_settings.tab.main=General page_settings.tab.performance=Performance page_settings.tab.themes=Chat themes preview page_settings.tab.invitationthemes=Invitation themes preview +pending.errors.network=Network problems detected. Please refresh the page. pending.menu.hide=Hide menu >> pending.menu.show=Show menu >> pending.popup_notification=A new visitor is waiting for an answer. diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index 10461abe..72b8f9f1 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -408,6 +408,7 @@ page_settings.tab.main= page_settings.tab.performance=Производительность page_settings.tab.themes=Просмотр стилей диалогов page_settings.tab.invitationthemes=Просмотр стилей приглашений +pending.errors.network=Обнаружены проблемы с сетью. Пожалуйста, перезагрузите страницу. pending.menu.hide=Спрятать меню >> pending.menu.show=Показать меню >> pending.popup_notification=Новый посетитель ожидает ответа. diff --git a/src/messenger/webim/view/pending_users.php b/src/messenger/webim/view/pending_users.php index 2810a35a..c82e469a 100644 --- a/src/messenger/webim/view/pending_users.php +++ b/src/messenger/webim/view/pending_users.php @@ -83,7 +83,8 @@ function tpl_header() { global $page, $webimroot; 'chat.thread.state_chatting_with_agent': "", 'chat.thread.state_closed': "", 'chat.thread.state_loading': "", - 'chat.client.spam.prefix': "" + 'chat.client.spam.prefix': "", + 'pending.errors.network': "" }); //-->