mirror of
https://github.com/Mibew/design.git
synced 2024-11-15 17:34:12 +03:00
Update MibewAPICoreInteraction
Move it to separate file and rename it to MibewAPIChatInteraction
This commit is contained in:
parent
de68b862da
commit
46ce6f2a91
@ -5,8 +5,8 @@
|
|||||||
Copyright (c) 2005-2011 Mibew Messenger Community
|
Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
License: http://mibew.org/license.php
|
License: http://mibew.org/license.php
|
||||||
*/
|
*/
|
||||||
(function(a,j){var f=new j.Marionette.Application;f.addRegions({controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:a.Regions.Messages,statusRegion:"#status-region",messageFormRegion:"#message-form-region",soundRegion:"#sound-region"});f.addInitializer(function(d){var g=a.Objects,c=a.Objects.Models,b=a.Objects.Models.Controls,h=a.Objects.Models.Status;g.server=new a.Server(d.server);g.thread=new a.Thread(d.thread);c.user=new a.Models.User(d.user);c.page=new a.Models.Page(d.page);
|
(function(a,j,k){var f=new j.Marionette.Application;f.addRegions({controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:a.Regions.Messages,statusRegion:"#status-region",messageFormRegion:"#message-form-region",soundRegion:"#sound-region"});f.addInitializer(function(d){var g=a.Objects,c=a.Objects.Models,b=a.Objects.Models.Controls,h=a.Objects.Models.Status;g.server=new a.Server(k.extend({interactionType:MibewAPIChatInteraction},d.server));g.thread=new a.Thread(d.thread);c.user=
|
||||||
var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history));b.sound=new a.Models.SoundControl({weight:160});e.push(b.sound);
|
new a.Models.User(d.user);c.page=new a.Models.Page(d.page);var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history));
|
||||||
b.refresh=new a.Models.RefreshControl({weight:140});e.push(b.refresh);d.links.sslLink&&(b.secureMode=new a.Models.SecureModeControl({weight:120,link:d.links.sslLink}),e.push(b.secureMode));b.close=new a.Models.CloseControl({weight:100});e.push(b.close);g.Collections.controls=e;f.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3});g.Collections.status=new a.Collections.Status([h.message,
|
b.sound=new a.Models.SoundControl({weight:160});e.push(b.sound);b.refresh=new a.Models.RefreshControl({weight:140});e.push(b.refresh);d.links.sslLink&&(b.secureMode=new a.Models.SecureModeControl({weight:120,link:d.links.sslLink}),e.push(b.secureMode));b.close=new a.Models.CloseControl({weight:100});e.push(b.close);g.Collections.controls=e;f.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3});
|
||||||
h.typing]);f.statusRegion.show(new a.Views.StatusCollection({collection:g.Collections.status}));c.user.get("isAgent")||(c.avatar=new a.Models.Avatar,f.avatarRegion.show(new a.Views.Avatar({model:c.avatar})));g.Collections.messages=new a.Collections.Messages;c.messageForm=new a.Models.MessageForm(d.messageForm);f.messageFormRegion.show(new a.Views.MessageForm({model:c.messageForm}));f.messagesRegion.show(new a.Views.MessagesCollection({collection:g.Collections.messages}));c.sound=new a.Models.Sound;
|
g.Collections.status=new a.Collections.Status([h.message,h.typing]);f.statusRegion.show(new a.Views.StatusCollection({collection:g.Collections.status}));c.user.get("isAgent")||(c.avatar=new a.Models.Avatar,f.avatarRegion.show(new a.Views.Avatar({model:c.avatar})));g.Collections.messages=new a.Collections.Messages;c.messageForm=new a.Models.MessageForm(d.messageForm);f.messageFormRegion.show(new a.Views.MessageForm({model:c.messageForm}));f.messagesRegion.show(new a.Views.MessagesCollection({collection:g.Collections.messages}));
|
||||||
f.soundRegion.show(new a.Views.Sound({model:c.sound}));g.server.runUpdater()});a.Application=f})(Mibew,Backbone);
|
c.sound=new a.Models.Sound;f.soundRegion.show(new a.Views.Sound({model:c.sound}));g.server.runUpdater()});a.Application=f})(Mibew,Backbone,_);
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Mibew Messenger project.
|
||||||
|
http://mibew.org
|
||||||
|
|
||||||
|
Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
MibewAPIChatInteraction=function(){this.obligatoryArguments={"*":{threadId:null,token:null,"return":{},references:{}},result:{errorCode:0}};this.reservedFunctionNames=["result"]};MibewAPIChatInteraction.prototype=new MibewAPIInteraction;
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
(function(a){a.Regions={};a.Objects.Models.Controls={};a.Objects.Models.Status={}})(Mibew);
|
(function(a){a.Regions={};a.Objects.Models.Controls={};a.Objects.Models.Status={}})(Mibew);
|
||||||
(function(b){b.registerHelper("allowTags",function(a){a=a.replace(/<(span|strong)>(.*?)<\/\1>/g,"<$1>$2</$1>");a=a.replace(/<span class="(.*?)">(.*?)<\/span>/g,'<span class="$1">$2</span>');return new b.SafeString(a)})})(Handlebars);
|
(function(b){b.registerHelper("allowTags",function(a){a=a.replace(/<(span|strong)>(.*?)<\/\1>/g,"<$1>$2</$1>");a=a.replace(/<span class="(.*?)">(.*?)<\/span>/g,'<span class="$1">$2</span>');return new b.SafeString(a)})})(Handlebars);
|
||||||
|
MibewAPIChatInteraction=function(){this.obligatoryArguments={"*":{threadId:null,token:null,"return":{},references:{}},result:{errorCode:0}};this.reservedFunctionNames=["result"]};MibewAPIChatInteraction.prototype=new MibewAPIInteraction;
|
||||||
(function(a){a.Models.Control=a.Models.Base.extend({defaults:{title:"",weight:0}})})(Mibew);
|
(function(a){a.Models.Control=a.Models.Base.extend({defaults:{title:"",weight:0}})})(Mibew);
|
||||||
(function(b,c){b.Models.Status=b.Models.Base.extend({defaults:{visible:!0,weight:0,hideTimeout:4E3,title:""},initialize:function(){this.hideTimer=null},autoHide:function(a){a=a||this.get("hideTimeout");this.hideTimer&&clearTimeout(this.hideTimer);this.hideTimer=setTimeout(c.bind(function(){this.set({visible:!1})},this),a)}})})(Mibew,_);
|
(function(b,c){b.Models.Status=b.Models.Base.extend({defaults:{visible:!0,weight:0,hideTimeout:4E3,title:""},initialize:function(){this.hideTimer=null},autoHide:function(a){a=a||this.get("hideTimeout");this.hideTimer&&clearTimeout(this.hideTimer);this.hideTimer=setTimeout(c.bind(function(){this.set({visible:!1})},this),a)}})})(Mibew,_);
|
||||||
(function(a,b){a.Models.Avatar=a.Models.Base.extend({defaults:{imageLink:!1},initialize:function(){a.Objects.server.registerFunction("setupAvatar",b.bind(this.apiSetupAvatar,this))},apiSetupAvatar:function(a){a.imageLink&&this.set({imageLink:a.imageLink})}})})(Mibew,_);
|
(function(a,b){a.Models.Avatar=a.Models.Base.extend({defaults:{imageLink:!1},initialize:function(){a.Objects.server.registerFunction("setupAvatar",b.bind(this.apiSetupAvatar,this))},apiSetupAvatar:function(a){a.imageLink&&this.set({imageLink:a.imageLink})}})})(Mibew,_);
|
||||||
@ -99,8 +100,8 @@ c=""!=this.ui.message.val();c!=a.get("typing")&&a.set({typing:c})},setFocus:func
|
|||||||
(function(a,b){a.Views.StatusMessage=a.Views.Status.extend({template:b.templates.status_message})})(Mibew,Handlebars);
|
(function(a,b){a.Views.StatusMessage=a.Views.Status.extend({template:b.templates.status_message})})(Mibew,Handlebars);
|
||||||
(function(a){a.Views.StatusCollection=a.Views.CollectionBase.extend({itemView:a.Views.Status,className:"status-collection"})})(Mibew);
|
(function(a){a.Views.StatusCollection=a.Views.CollectionBase.extend({itemView:a.Views.Status,className:"status-collection"})})(Mibew);
|
||||||
(function(a,b){a.Views.StatusTyping=a.Views.Status.extend({template:b.templates.status_typing})})(Mibew,Handlebars);
|
(function(a,b){a.Views.StatusTyping=a.Views.Status.extend({template:b.templates.status_typing})})(Mibew,Handlebars);
|
||||||
(function(a,j){var f=new j.Marionette.Application;f.addRegions({controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:a.Regions.Messages,statusRegion:"#status-region",messageFormRegion:"#message-form-region",soundRegion:"#sound-region"});f.addInitializer(function(d){var g=a.Objects,c=a.Objects.Models,b=a.Objects.Models.Controls,h=a.Objects.Models.Status;g.server=new a.Server(d.server);g.thread=new a.Thread(d.thread);c.user=new a.Models.User(d.user);c.page=new a.Models.Page(d.page);
|
(function(a,j,k){var f=new j.Marionette.Application;f.addRegions({controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:a.Regions.Messages,statusRegion:"#status-region",messageFormRegion:"#message-form-region",soundRegion:"#sound-region"});f.addInitializer(function(d){var g=a.Objects,c=a.Objects.Models,b=a.Objects.Models.Controls,h=a.Objects.Models.Status;g.server=new a.Server(k.extend({interactionType:MibewAPIChatInteraction},d.server));g.thread=new a.Thread(d.thread);c.user=
|
||||||
var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history));b.sound=new a.Models.SoundControl({weight:160});e.push(b.sound);
|
new a.Models.User(d.user);c.page=new a.Models.Page(d.page);var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history));
|
||||||
b.refresh=new a.Models.RefreshControl({weight:140});e.push(b.refresh);d.links.sslLink&&(b.secureMode=new a.Models.SecureModeControl({weight:120,link:d.links.sslLink}),e.push(b.secureMode));b.close=new a.Models.CloseControl({weight:100});e.push(b.close);g.Collections.controls=e;f.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3});g.Collections.status=new a.Collections.Status([h.message,
|
b.sound=new a.Models.SoundControl({weight:160});e.push(b.sound);b.refresh=new a.Models.RefreshControl({weight:140});e.push(b.refresh);d.links.sslLink&&(b.secureMode=new a.Models.SecureModeControl({weight:120,link:d.links.sslLink}),e.push(b.secureMode));b.close=new a.Models.CloseControl({weight:100});e.push(b.close);g.Collections.controls=e;f.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3});
|
||||||
h.typing]);f.statusRegion.show(new a.Views.StatusCollection({collection:g.Collections.status}));c.user.get("isAgent")||(c.avatar=new a.Models.Avatar,f.avatarRegion.show(new a.Views.Avatar({model:c.avatar})));g.Collections.messages=new a.Collections.Messages;c.messageForm=new a.Models.MessageForm(d.messageForm);f.messageFormRegion.show(new a.Views.MessageForm({model:c.messageForm}));f.messagesRegion.show(new a.Views.MessagesCollection({collection:g.Collections.messages}));c.sound=new a.Models.Sound;
|
g.Collections.status=new a.Collections.Status([h.message,h.typing]);f.statusRegion.show(new a.Views.StatusCollection({collection:g.Collections.status}));c.user.get("isAgent")||(c.avatar=new a.Models.Avatar,f.avatarRegion.show(new a.Views.Avatar({model:c.avatar})));g.Collections.messages=new a.Collections.Messages;c.messageForm=new a.Models.MessageForm(d.messageForm);f.messageFormRegion.show(new a.Views.MessageForm({model:c.messageForm}));f.messagesRegion.show(new a.Views.MessagesCollection({collection:g.Collections.messages}));
|
||||||
f.soundRegion.show(new a.Views.Sound({model:c.sound}));g.server.runUpdater()});a.Application=f})(Mibew,Backbone);
|
c.sound=new a.Models.Sound;f.soundRegion.show(new a.Views.Sound({model:c.sound}));g.server.runUpdater()});a.Application=f})(Mibew,Backbone,_);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Copyright (c) 2005-2011 Mibew Messenger Community
|
Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
License: http://mibew.org/license.php
|
License: http://mibew.org/license.php
|
||||||
*/
|
*/
|
||||||
(function(b,f,g,c){b.Server=function(a){this.updateTimer=null;this.options=c.extend({url:"",requestsFrequency:2,reconnectPause:1,onTimeout:function(){},onTransportError:function(){},onCallError:function(){},onUpdateError:function(){},onResponseError:function(){}},a);this.callbacks={};this.callPeriodically=[];this.ajaxRequest=null;this.buffer=[];this.functions={};this.mibewAPI=new f(new MibewAPICoreInteraction)};b.Server.prototype.callFunctions=function(a,e,b){try{if(!(a instanceof Array))throw Error("The first arguments must be an array");
|
(function(b,f,g,c){b.Server=function(a){this.updateTimer=null;this.options=c.extend({url:"",requestsFrequency:2,reconnectPause:1,onTimeout:function(){},onTransportError:function(){},onCallError:function(){},onUpdateError:function(){},onResponseError:function(){}},a);this.callbacks={};this.callPeriodically=[];this.ajaxRequest=null;this.buffer=[];this.functions={};this.mibewAPI=new f(new this.options.interactionType)};b.Server.prototype.callFunctions=function(a,e,b){try{if(!(a instanceof Array))throw Error("The first arguments must be an array");
|
||||||
for(var d in a)a.hasOwnProperty(d)&&this.mibewAPI.checkFunction(a[d],!1);var c=this.generateToken();this.callbacks[c]=e;this.buffer.push({token:c,functions:a});b&&this.update()}catch(f){return this.options.onCallError(f),!1}return!0};b.Server.prototype.callFunctionsPeriodically=function(a,e){this.callPeriodically.push({functionsListBuilder:a,callbackFunction:e})};b.Server.prototype.generateToken=function(){var a;do a="wnd"+(new Date).getTime().toString()+Math.round(50*Math.random()).toString();while(a in
|
for(var d in a)a.hasOwnProperty(d)&&this.mibewAPI.checkFunction(a[d],!1);var c=this.generateToken();this.callbacks[c]=e;this.buffer.push({token:c,functions:a});b&&this.update()}catch(f){return this.options.onCallError(f),!1}return!0};b.Server.prototype.callFunctionsPeriodically=function(a,e){this.callPeriodically.push({functionsListBuilder:a,callbackFunction:e})};b.Server.prototype.generateToken=function(){var a;do a="wnd"+(new Date).getTime().toString()+Math.round(50*Math.random()).toString();while(a in
|
||||||
this.callbacks);return a};b.Server.prototype.processRequest=function(a){var e=new MibewAPIExecutionContext,b=this.mibewAPI.getResultFunction(a.functions,this.callbacks.hasOwnProperty(a.token));if(null===b)for(var d in a.functions)a.functions.hasOwnProperty(d)&&(this.processFunction(a.functions[d],e),this.buffer.push(this.mibewAPI.buildResult(e.getResults(),a.token)));else this.callbacks.hasOwnProperty(a.token)&&(this.callbacks[a.token](b.arguments),delete this.callbacks[a.token])};b.Server.prototype.processFunction=
|
this.callbacks);return a};b.Server.prototype.processRequest=function(a){var e=new MibewAPIExecutionContext,b=this.mibewAPI.getResultFunction(a.functions,this.callbacks.hasOwnProperty(a.token));if(null===b)for(var d in a.functions)a.functions.hasOwnProperty(d)&&(this.processFunction(a.functions[d],e),this.buffer.push(this.mibewAPI.buildResult(e.getResults(),a.token)));else this.callbacks.hasOwnProperty(a.token)&&(this.callbacks[a.token](b.arguments),delete this.callbacks[a.token])};b.Server.prototype.processFunction=
|
||||||
function(a,e){if(this.functions.hasOwnProperty(a["function"])){var b=e.getArgumentsList(a),d={},f;for(f in this.functions[a["function"]])this.functions[a["function"]].hasOwnProperty(f)&&(d=c.extend(d,this.functions[a["function"]][f](b)));e.storeFunctionResults(a,d)}};b.Server.prototype.sendRequests=function(a){this.ajaxRequest=g.ajax({url:this.options.url,timeout:5E3,async:!0,cache:!1,type:"POST",dataType:"text",data:{data:this.mibewAPI.encodePackage(a)},success:c.bind(this.receiveResponse,this),
|
function(a,e){if(this.functions.hasOwnProperty(a["function"])){var b=e.getArgumentsList(a),d={},f;for(f in this.functions[a["function"]])this.functions[a["function"]].hasOwnProperty(f)&&(d=c.extend(d,this.functions[a["function"]][f](b)));e.storeFunctionResults(a,d)}};b.Server.prototype.sendRequests=function(a){this.ajaxRequest=g.ajax({url:this.options.url,timeout:5E3,async:!0,cache:!1,type:"POST",dataType:"text",data:{data:this.mibewAPI.encodePackage(a)},success:c.bind(this.receiveResponse,this),
|
||||||
|
@ -8,7 +8,7 @@ var Mibew={};(function(a,b){b.Marionette.TemplateCache.prototype.compileTemplate
|
|||||||
(function(e,a){a.registerHelper("apply",function(c,b){var f=c,e=/^[0-9A-z_]+$/;b=b.split(/\s*,\s*/);for(var d in b)if(b.hasOwnProperty(d)&&e.test(b[d])){if("function"!=typeof a.helpers[b[d]])throw Error("Unregistered helper '"+b[d]+"'!");f=a.helpers[b[d]](f).toString()}return new a.SafeString(f)});a.registerHelper("formatTime",function(c){var b=new Date(1E3*c);c=b.getHours().toString();var a=b.getMinutes().toString(),b=b.getSeconds().toString();return(10<c?c:"0"+c)+":"+(10<a?a:"0"+a)+":"+(10<b?b:
|
(function(e,a){a.registerHelper("apply",function(c,b){var f=c,e=/^[0-9A-z_]+$/;b=b.split(/\s*,\s*/);for(var d in b)if(b.hasOwnProperty(d)&&e.test(b[d])){if("function"!=typeof a.helpers[b[d]])throw Error("Unregistered helper '"+b[d]+"'!");f=a.helpers[b[d]](f).toString()}return new a.SafeString(f)});a.registerHelper("formatTime",function(c){var b=new Date(1E3*c);c=b.getHours().toString();var a=b.getMinutes().toString(),b=b.getSeconds().toString();return(10<c?c:"0"+c)+":"+(10<a?a:"0"+a)+":"+(10<b?b:
|
||||||
"0"+b)});a.registerHelper("urlReplace",function(c){return new a.SafeString(c.replace(/((?:https?|ftp):\/\/\S*)/g,'<a href="$1" target="_blank">$1</a>'))});a.registerHelper("nl2br",function(c){return new a.SafeString(c.replace(/\n/g,"<br/>"))});a.registerHelper("L10n",function(a){return e.Localization.get(a)||""})})(Mibew,Handlebars);
|
"0"+b)});a.registerHelper("urlReplace",function(c){return new a.SafeString(c.replace(/((?:https?|ftp):\/\/\S*)/g,'<a href="$1" target="_blank">$1</a>'))});a.registerHelper("nl2br",function(c){return new a.SafeString(c.replace(/\n/g,"<br/>"))});a.registerHelper("L10n",function(a){return e.Localization.get(a)||""})})(Mibew,Handlebars);
|
||||||
(function(b,d){b.Localization={};var c={};b.Localization.get=function(a){return!c.hasOwnProperty(a)?!1:c[a]};b.Localization.set=function(a){d.extend(c,a)}})(Mibew,_);
|
(function(b,d){b.Localization={};var c={};b.Localization.get=function(a){return!c.hasOwnProperty(a)?!1:c[a]};b.Localization.set=function(a){d.extend(c,a)}})(Mibew,_);
|
||||||
(function(b,f,g,c){b.Server=function(a){this.updateTimer=null;this.options=c.extend({url:"",requestsFrequency:2,reconnectPause:1,onTimeout:function(){},onTransportError:function(){},onCallError:function(){},onUpdateError:function(){},onResponseError:function(){}},a);this.callbacks={};this.callPeriodically=[];this.ajaxRequest=null;this.buffer=[];this.functions={};this.mibewAPI=new f(new MibewAPICoreInteraction)};b.Server.prototype.callFunctions=function(a,e,b){try{if(!(a instanceof Array))throw Error("The first arguments must be an array");
|
(function(b,f,g,c){b.Server=function(a){this.updateTimer=null;this.options=c.extend({url:"",requestsFrequency:2,reconnectPause:1,onTimeout:function(){},onTransportError:function(){},onCallError:function(){},onUpdateError:function(){},onResponseError:function(){}},a);this.callbacks={};this.callPeriodically=[];this.ajaxRequest=null;this.buffer=[];this.functions={};this.mibewAPI=new f(new this.options.interactionType)};b.Server.prototype.callFunctions=function(a,e,b){try{if(!(a instanceof Array))throw Error("The first arguments must be an array");
|
||||||
for(var d in a)a.hasOwnProperty(d)&&this.mibewAPI.checkFunction(a[d],!1);var c=this.generateToken();this.callbacks[c]=e;this.buffer.push({token:c,functions:a});b&&this.update()}catch(f){return this.options.onCallError(f),!1}return!0};b.Server.prototype.callFunctionsPeriodically=function(a,e){this.callPeriodically.push({functionsListBuilder:a,callbackFunction:e})};b.Server.prototype.generateToken=function(){var a;do a="wnd"+(new Date).getTime().toString()+Math.round(50*Math.random()).toString();while(a in
|
for(var d in a)a.hasOwnProperty(d)&&this.mibewAPI.checkFunction(a[d],!1);var c=this.generateToken();this.callbacks[c]=e;this.buffer.push({token:c,functions:a});b&&this.update()}catch(f){return this.options.onCallError(f),!1}return!0};b.Server.prototype.callFunctionsPeriodically=function(a,e){this.callPeriodically.push({functionsListBuilder:a,callbackFunction:e})};b.Server.prototype.generateToken=function(){var a;do a="wnd"+(new Date).getTime().toString()+Math.round(50*Math.random()).toString();while(a in
|
||||||
this.callbacks);return a};b.Server.prototype.processRequest=function(a){var e=new MibewAPIExecutionContext,b=this.mibewAPI.getResultFunction(a.functions,this.callbacks.hasOwnProperty(a.token));if(null===b)for(var d in a.functions)a.functions.hasOwnProperty(d)&&(this.processFunction(a.functions[d],e),this.buffer.push(this.mibewAPI.buildResult(e.getResults(),a.token)));else this.callbacks.hasOwnProperty(a.token)&&(this.callbacks[a.token](b.arguments),delete this.callbacks[a.token])};b.Server.prototype.processFunction=
|
this.callbacks);return a};b.Server.prototype.processRequest=function(a){var e=new MibewAPIExecutionContext,b=this.mibewAPI.getResultFunction(a.functions,this.callbacks.hasOwnProperty(a.token));if(null===b)for(var d in a.functions)a.functions.hasOwnProperty(d)&&(this.processFunction(a.functions[d],e),this.buffer.push(this.mibewAPI.buildResult(e.getResults(),a.token)));else this.callbacks.hasOwnProperty(a.token)&&(this.callbacks[a.token](b.arguments),delete this.callbacks[a.token])};b.Server.prototype.processFunction=
|
||||||
function(a,e){if(this.functions.hasOwnProperty(a["function"])){var b=e.getArgumentsList(a),d={},f;for(f in this.functions[a["function"]])this.functions[a["function"]].hasOwnProperty(f)&&(d=c.extend(d,this.functions[a["function"]][f](b)));e.storeFunctionResults(a,d)}};b.Server.prototype.sendRequests=function(a){this.ajaxRequest=g.ajax({url:this.options.url,timeout:5E3,async:!0,cache:!1,type:"POST",dataType:"text",data:{data:this.mibewAPI.encodePackage(a)},success:c.bind(this.receiveResponse,this),
|
function(a,e){if(this.functions.hasOwnProperty(a["function"])){var b=e.getArgumentsList(a),d={},f;for(f in this.functions[a["function"]])this.functions[a["function"]].hasOwnProperty(f)&&(d=c.extend(d,this.functions[a["function"]][f](b)));e.storeFunctionResults(a,d)}};b.Server.prototype.sendRequests=function(a){this.ajaxRequest=g.ajax({url:this.options.url,timeout:5E3,async:!0,cache:!1,type:"POST",dataType:"text",data:{data:this.mibewAPI.encodePackage(a)},success:c.bind(this.receiveResponse,this),
|
||||||
|
@ -15,7 +15,7 @@ MibewAPI.prototype.buildResult=function(a,b){var c=this.interaction.getObligator
|
|||||||
MibewAPI.prototype.decodePackage=function(a){a=JSON.parse(decodeURIComponent(a.replace(/\+/gi," ")));this.checkPackage(a);return a};function MibewAPIInteraction(){this.obligatoryArguments={};this.reservedFunctionNames=[]}
|
MibewAPI.prototype.decodePackage=function(a){a=JSON.parse(decodeURIComponent(a.replace(/\+/gi," ")));this.checkPackage(a);return a};function MibewAPIInteraction(){this.obligatoryArguments={};this.reservedFunctionNames=[]}
|
||||||
MibewAPIInteraction.prototype.getObligatoryArguments=function(a){var b=[];if("object"==typeof this.obligatoryArguments["*"])for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&b.push(c);if("object"==typeof this.obligatoryArguments[a])for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&b.push(c);return b};
|
MibewAPIInteraction.prototype.getObligatoryArguments=function(a){var b=[];if("object"==typeof this.obligatoryArguments["*"])for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&b.push(c);if("object"==typeof this.obligatoryArguments[a])for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&b.push(c);return b};
|
||||||
MibewAPIInteraction.prototype.getObligatoryArgumentsDefaults=function(a){var b={};if("object"==typeof this.obligatoryArguments["*"])for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments["*"][c]);if("object"==typeof this.obligatoryArguments[a])for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments[a][c]);return b};
|
MibewAPIInteraction.prototype.getObligatoryArgumentsDefaults=function(a){var b={};if("object"==typeof this.obligatoryArguments["*"])for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments["*"][c]);if("object"==typeof this.obligatoryArguments[a])for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments[a][c]);return b};
|
||||||
function MibewAPICoreInteraction(){this.obligatoryArguments={"*":{threadId:null,token:null,"return":{},references:{}},result:{errorCode:0}};this.reservedFunctionNames=["result"]}MibewAPICoreInteraction.prototype=new MibewAPIInteraction;function MibewAPIExecutionContext(){this.returnValues={};this.functionsResults=[]}
|
function MibewAPIExecutionContext(){this.returnValues={};this.functionsResults=[]}
|
||||||
MibewAPIExecutionContext.prototype.getArgumentsList=function(a){var b=a.arguments,c=a.arguments.references,d,f,e;for(e in c)if(c.hasOwnProperty(e)){f=c[e];if("undefined"==typeof this.functionsResults[f-1])throw Error("Wrong reference in '"+a["function"]+"' function. Function #"+f+" does not call yet.");if("undefined"==typeof b[e]||""==b[e])throw Error("Wrong reference in '"+a["function"]+"' function. Empty '"+e+"' argument.");d=b[e];if("undefined"==typeof this.functionsResults[f-1][d])throw Error("Wrong reference in '"+
|
MibewAPIExecutionContext.prototype.getArgumentsList=function(a){var b=a.arguments,c=a.arguments.references,d,f,e;for(e in c)if(c.hasOwnProperty(e)){f=c[e];if("undefined"==typeof this.functionsResults[f-1])throw Error("Wrong reference in '"+a["function"]+"' function. Function #"+f+" does not call yet.");if("undefined"==typeof b[e]||""==b[e])throw Error("Wrong reference in '"+a["function"]+"' function. Empty '"+e+"' argument.");d=b[e];if("undefined"==typeof this.functionsResults[f-1][d])throw Error("Wrong reference in '"+
|
||||||
a["function"]+"' function. There is no '"+d+"' argument in #"+f+" function results");b[e]=this.functionsResults[f-1][d]}return b};MibewAPIExecutionContext.prototype.getResults=function(){return this.returnValues};
|
a["function"]+"' function. There is no '"+d+"' argument in #"+f+" function results");b[e]=this.functionsResults[f-1][d]}return b};MibewAPIExecutionContext.prototype.getResults=function(){return this.returnValues};
|
||||||
MibewAPIExecutionContext.prototype.storeFunctionResults=function(a,b){var c,d;for(d in a.arguments["return"])if(a.arguments["return"].hasOwnProperty(d)){c=a.arguments["return"][d];if("undefined"==typeof b[d])throw Error("Variable with name '"+d+"' is undefined in the results of the '"+a["function"]+"' function");this.returnValues[c]=b[d]}this.functionsResults.push(b)};
|
MibewAPIExecutionContext.prototype.storeFunctionResults=function(a,b){var c,d;for(d in a.arguments["return"])if(a.arguments["return"].hasOwnProperty(d)){c=a.arguments["return"][d];if("undefined"==typeof b[d])throw Error("Variable with name '"+d+"' is undefined in the results of the '"+a["function"]+"' function");this.returnValues[c]=b[d]}this.functionsResults.push(b)};
|
@ -6,7 +6,7 @@
|
|||||||
* License: http://mibew.org/license.php
|
* License: http://mibew.org/license.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function (Mibew, Backbone) {
|
(function (Mibew, Backbone, _) {
|
||||||
|
|
||||||
// Create application instance
|
// Create application instance
|
||||||
var App = new Backbone.Marionette.Application();
|
var App = new Backbone.Marionette.Application();
|
||||||
@ -31,7 +31,12 @@
|
|||||||
|
|
||||||
|
|
||||||
// Initialize Server, Thread and User
|
// Initialize Server, Thread and User
|
||||||
objs.server = new Mibew.Server(options.server);
|
objs.server = new Mibew.Server(_.extend(
|
||||||
|
{
|
||||||
|
'interactionType': MibewAPIChatInteraction
|
||||||
|
},
|
||||||
|
options.server
|
||||||
|
));
|
||||||
objs.thread = new Mibew.Thread(options.thread);
|
objs.thread = new Mibew.Thread(options.thread);
|
||||||
models.user = new Mibew.Models.User(options.user);
|
models.user = new Mibew.Models.User(options.user);
|
||||||
|
|
||||||
@ -169,4 +174,4 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
Mibew.Application = App;
|
Mibew.Application = App;
|
||||||
})(Mibew, Backbone);
|
})(Mibew, Backbone, _);
|
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* @preserve This file is part of Mibew Messenger project.
|
||||||
|
* http://mibew.org
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
* License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents Chat Window to core interaction type
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
MibewAPIChatInteraction = function() {
|
||||||
|
this.obligatoryArguments = {
|
||||||
|
'*': {
|
||||||
|
'threadId': null,
|
||||||
|
'token': null,
|
||||||
|
'return': {},
|
||||||
|
'references': {}
|
||||||
|
},
|
||||||
|
'result': {
|
||||||
|
'errorCode': 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.reservedFunctionNames = [
|
||||||
|
'result'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
MibewAPIChatInteraction.prototype = new MibewAPIInteraction();
|
@ -81,7 +81,7 @@
|
|||||||
* @type MibewAPI
|
* @type MibewAPI
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.mibewAPI = new MibewAPI(new MibewAPICoreInteraction());
|
this.mibewAPI = new MibewAPI(new this.options['interactionType']());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -377,30 +377,6 @@ MibewAPIInteraction.prototype.getObligatoryArgumentsDefaults = function(function
|
|||||||
* End of MibewAPIInteraction class
|
* End of MibewAPIInteraction class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents Window to core interaction type
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
* @todo Think about real values!
|
|
||||||
*/
|
|
||||||
function MibewAPICoreInteraction() {
|
|
||||||
this.obligatoryArguments = {
|
|
||||||
'*': {
|
|
||||||
'threadId': null,
|
|
||||||
'token': null,
|
|
||||||
'return': {},
|
|
||||||
'references': {}
|
|
||||||
},
|
|
||||||
'result': {
|
|
||||||
'errorCode': 0
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.reservedFunctionNames = [
|
|
||||||
'result'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
MibewAPICoreInteraction.prototype = new MibewAPIInteraction();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements functions execution context
|
* Implements functions execution context
|
||||||
|
Loading…
Reference in New Issue
Block a user