2013-02-06 16:24:26 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-02-06 15:04:41 +04:00
( function ( ) { var a = Handlebars . template , b = Handlebars . templates = Handlebars . templates || { } ; b . default _control = a ( function ( a , b , c , d , e ) { c = c || a . helpers ; var f = "" , g , h , i = "function" , j = this . escapeExpression ; return f += "<strong>" , h = c . title , h ? g = h . call ( b , { hash : { } } ) : ( g = b . title , g = typeof g === i ? g ( ) : g ) , f += j ( g ) + "</strong>" , f } ) , b . sound = a ( function ( a , b , c , d , e ) { function j ( a , b ) { var d = "" , e , f ; return d += '\n<audio autoplay src="' , f = c . file , f ? e = f . call ( a , { hash : { } } ) : ( e = a . file , e = typeof e === g ? e ( ) : e ) , d += h ( e ) + '">\n <embed src="' , f = c . file , f ? e = f . call ( a , { hash : { } } ) : ( e = a . file , e = typeof e === g ? e ( ) : e ) , d += h ( e ) + '" hidden="true" autostart="true" loop="false" />\n</audio>\n' , d } c = c || a . helpers ; var f , g = "function" , h = this . escapeExpression , i = this ; return f = b . file , f = c [ "if" ] . call ( b , f , { hash : { } , inverse : i . noop , fn : i . program ( 1 , j , e ) } ) , f || f === 0 ? f : "" } ) , b . message = a ( function ( a , b , c , d , e ) { function m ( a , b ) { var d = "" , e , f ; return d += "<span class='n" , f = c . kindName , f ? e = f . call ( a , { hash : { } } ) : ( e = a . kindName , e = typeof e === i ? e ( ) : e ) , d += j ( e ) + "'>" , f = c . name , f ? e = f . call ( a , { hash : { } } ) : ( e = a . name , e = typeof e === i ? e ( ) : e ) , d += j ( e ) + "</span>: " , d } function n ( a , b ) { var d , e ; return d = a . message , e = c . apply , d = e ? e . call ( a , d , "urlReplace, nl2br, allowTags" , { hash : { } } ) : k . call ( a , "apply" , d , "urlReplace, nl2br, allowTags" , { hash : { } } ) , j ( d ) } function o ( a , b ) { var d , e ; return d = a . message , e = c . apply , d = e ? e . call ( a , d , "urlReplace, nl2br" , { hash : { } } ) : k . call ( a , "apply" , d , "urlReplace, nl2br" , { hash : { } } ) , j ( d ) } c = c || a . helpers ; var f = "" , g , h , i = "function" , j = this . escapeExpression , k = c . helperMissing , l = this ; f += "<span>" , g = b . created , h = c . formatTime , g = h ? h . call ( b , g , { hash : { } } ) : k . call ( b , "formatTime" , g , { hash : { } } ) , f += j ( g ) + "</span>\n" , g = b . name , g = c [ "if" ] . call ( b , g , { hash : { } , inverse : l . noop , fn : l . program ( 1 , m , e ) } ) ; if ( g || g === 0 ) f += g ; f += "\n<span class='m" , h = c . kindName , h ? g = h . call ( b , { hash : { } } ) : ( g = b . kindName , g = typeof g === i ? g ( ) : g ) , f += j ( g ) + "'>" , g = b . allowFormatting , g = c [ "if" ] . call ( b , g , { hash : { } , inverse : l . program ( 5 , o , e ) , fn : l . program ( 3 , n , e ) } ) ; if ( g || g === 0 ) f += g ; return f += "</span><br/>" , f } ) } ) ( ) ; / *
2012-12-27 18:07:11 +04:00
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
var Mibew = { } ; ( function ( a , b ) { b . Marionette . TemplateCache . prototype . compileTemplate = function ( a ) { return Handlebars . compile ( a ) } ; a . Models = { } ; a . Collections = { } ; a . Views = { } ; a . Objects = { } ; a . Objects . Models = { } ; a . Objects . Collections = { } } ) ( Mibew , Backbone ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
( function ( e , b ) { b . registerHelper ( "apply" , function ( a , c ) { var f = a , e = /^[0-9A-z_]+$/ ; c = c . split ( /\s*,\s*/ ) ; for ( var d in c ) if ( c . hasOwnProperty ( d ) && e . test ( c [ d ] ) ) { if ( "function" != typeof b . helpers [ c [ d ] ] ) throw Error ( "Unregistered helper '" + c [ d ] + "'!" ) ; f = b . helpers [ c [ d ] ] ( f ) . toString ( ) } return new b . SafeString ( f ) } ) ; 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>' ) ;
2013-02-04 14:34:48 +04:00
return new b . SafeString ( a ) } ) ; b . registerHelper ( "formatTime" , function ( a ) { var c = new Date ( 1E3 * a ) ; a = c . getHours ( ) . toString ( ) ; var b = c . getMinutes ( ) . toString ( ) , c = c . getSeconds ( ) . toString ( ) ; return ( 10 > a ? "0" + a : a ) + ":" + ( 10 > b ? "0" + b : b ) + ":" + ( 10 > c ? "0" + c : c ) } ) ; b . registerHelper ( "urlReplace" , function ( a ) { return new b . SafeString ( a . replace ( /((?:https?|ftp):\/\/\S*)/g , '<a href="$1" target="_blank">$1</a>' ) ) } ) ; b . registerHelper ( "nl2br" , function ( a ) { return new b . SafeString ( a . replace ( /\n/g , "<br/>" ) ) } ) ; b . registerHelper ( "L10n" , function ( a ) { return e . Localization . get ( a ) ||
"" } ) } ) ( Mibew , Handlebars ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2012-12-27 18:07:11 +04:00
( 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 , _ ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-16 15:16:00 +04:00
( 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" ) ;
2012-12-27 18:07:11 +04:00
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 =
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 ) ,
error : c . bind ( this . onError , this ) } ) } ; b . Server . prototype . runUpdater = function ( ) { null == this . updateTimer && this . update ( ) ; this . updateTimer = setTimeout ( c . bind ( this . update , this ) , 1E3 * this . options . requestsFrequency ) } ; b . Server . prototype . restartUpdater = function ( ) { this . updateTimer && clearTimeout ( this . updateTimer ) ; this . ajaxRequest && this . ajaxRequest . abort ( ) ; this . update ( ) ; this . updateTimer = setTimeout ( c . bind ( this . update , this ) , 1E3 * this . options . reconnectPause ) } ; b . Server . prototype . update = function ( ) { this . updateTimer && clearTimeout ( this . updateTimer ) ;
for ( var a = 0 ; a < this . callPeriodically . length ; a ++ ) this . callFunctions ( this . callPeriodically [ a ] . functionsListBuilder ( ) , this . callPeriodically [ a ] . callbackFunction ) ; if ( 0 == this . buffer . length ) this . runUpdater ( ) ; else try { this . sendRequests ( this . buffer ) , this . buffer = [ ] } catch ( b ) { this . options . onUpdateError ( b ) } } ; b . Server . prototype . receiveResponse = function ( a ) { "" == a && this . runUpdater ( ) ; try { var b = this . mibewAPI . decodePackage ( a ) , c ; for ( c in b . requests ) this . processRequest ( b . requests [ c ] ) } catch ( d ) { this . options . onResponseError ( d ) } finally { this . runUpdater ( ) } } ;
b . Server . prototype . registerFunction = function ( a , b ) { a in this . functions || ( this . functions [ a ] = [ ] ) ; this . functions [ a ] . push ( b ) } ; b . Server . prototype . onError = function ( a , b ) { if ( "abort" != b ) if ( this . restartUpdater ( ) , "timeout" == b ) this . options . onTimeout ( ) ; else if ( "error" == b ) this . options . onTransportError ( ) } } ) ( Mibew , MibewAPI , $ , _ ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2012-12-27 18:07:11 +04:00
( function ( c ) { c . Utils = { } ; c . Utils . toUpperCaseFirst = function ( a ) { return "string" != typeof a ? ! 1 : "" === a ? a : a . substring ( 0 , 1 ) . toUpperCase ( ) + a . substring ( 1 ) } ; c . Utils . toDashFormat = function ( a ) { if ( "string" != typeof a ) return ! 1 ; a = a . match ( /((?:[A-Z]?[a-z]+)|(?:[A-Z][a-z]*))/g ) ; for ( var b = 0 ; b < a . length ; b ++ ) a [ b ] = a [ b ] . toLowerCase ( ) ; return a . join ( "-" ) } } ) ( Mibew ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2012-12-27 18:07:11 +04:00
( function ( a , b ) { a . Models . Base = b . Model . extend ( { getModelType : function ( ) { return "" } } ) } ) ( Mibew , Backbone ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-17 13:12:43 +04:00
( function ( a ) { a . Models . Control = a . Models . Base . extend ( { defaults : { title : "" , weight : 0 } } ) } ) ( Mibew ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-02-06 18:29:37 +04:00
( function ( a ) { a . Models . Message = a . Models . Base . extend ( { defaults : { message : "" } , KIND _USER : 1 , KIND _AGENT : 2 , KIND _FOR _AGENT : 3 , KIND _INFO : 4 , KIND _CONN : 5 , KIND _EVENTS : 6 } ) } ) ( Mibew ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2012-12-27 18:07:11 +04:00
( function ( a , b ) { a . Models . Page = b . Model . extend ( ) } ) ( Mibew , Backbone ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2012-12-27 18:07:11 +04:00
( function ( a , b ) { a . Models . Sound = b . Model . extend ( { play : function ( a ) { this . set ( { file : a } ) ; this . trigger ( "sound:play" , this ) } } ) } ) ( Mibew , Backbone ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-29 16:08:10 +04:00
( function ( a ) { a . Models . Thread = a . Models . Base . extend ( { defaults : { id : 0 , token : 0 , lastId : 0 , state : null } , STATE _QUEUE : 0 , STATE _WAITING : 1 , STATE _CHATTING : 2 , STATE _CLOSED : 3 , STATE _LOADING : 4 , STATE _LEFT : 5 } ) } ) ( Mibew ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-23 15:42:50 +04:00
( function ( a ) { a . Models . User = a . Models . Base . extend ( { defaults : { isAgent : ! 1 , name : "" } } ) } ) ( Mibew ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-17 13:12:43 +04:00
( function ( a , b ) { a . Collections . Controls = b . Collection . extend ( { comparator : function ( a ) { return a . get ( "weight" ) } } ) } ) ( Mibew , Backbone ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-18 17:06:34 +04:00
( function ( b , c , d ) { b . Views . Control = c . Marionette . ItemView . extend ( { template : d . templates . default _control , modelEvents : { change : "render" } , events : { mouseover : "mouseOver" , mouseleave : "mouseLeave" } , attributes : function ( ) { var a = [ ] ; a . push ( "control" ) ; this . className && ( a . push ( this . className ) , this . className = "" ) ; var b = this . getDashedControlType ( ) ; b && a . push ( b ) ; return { "class" : a . join ( " " ) } } , mouseOver : function ( ) { var a = this . getDashedControlType ( ) ; this . $el . addClass ( "active" + ( a ? "-" + a : "" ) ) } , mouseLeave : function ( ) { var a = this . getDashedControlType ( ) ;
2013-01-17 13:12:43 +04:00
this . $el . removeClass ( "active" + ( a ? "-" + a : "" ) ) } , getDashedControlType : function ( ) { "undefined" == typeof this . dashedControlType && ( this . dashedControlType = b . Utils . toDashFormat ( this . model . getModelType ( ) ) || "" ) ; return this . dashedControlType } } ) } ) ( Mibew , Backbone , Handlebars ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-02-04 14:34:48 +04:00
( function ( c , d , e ) { var f = { "<" : "<" , ">" : ">" , "&" : "&" , '"' : """ , "'" : "'" , "`" : "`" } , g = /[&<>'"`]/g ; c . Views . Message = d . Marionette . ItemView . extend ( { template : e . templates . message , className : "message" , modelEvents : { change : "render" } , serializeData : function ( ) { var a = this . model . toJSON ( ) , b = this . model . get ( "kind" ) ; a . allowFormatting = b != this . model . KIND _USER && b != this . model . KIND _AGENT ; a . kindName = this . kindToString ( b ) ; a . message = this . escapeString ( a . message ) ; return a } , kindToString : function ( a ) { return a == this . model . KIND _USER ?
"user" : a == this . model . KIND _AGENT ? "agent" : a == this . model . KIND _FOR _AGENT ? "hidden" : a == this . model . KIND _INFO ? "inf" : a == this . model . KIND _CONN ? "conn" : a == this . model . KIND _EVENTS ? "event" : "" } , escapeString : function ( a ) { return a . replace ( g , function ( a ) { return f [ a ] || "&" } ) } } ) } ) ( Mibew , Backbone , Handlebars ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2012-12-27 18:07:11 +04:00
( function ( a , b , c ) { a . Views . Sound = b . Marionette . ItemView . extend ( { template : c . templates . sound , className : "sound-player" , modelEvents : { "sound:play" : "render" } } ) } ) ( Mibew , Backbone , Handlebars ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-29 12:59:53 +04:00
( function ( d , a , f ) { var e = function ( b , a , c ) { c = f . extend ( { model : b } , c ) ; return "function" != typeof b . getModelType ? new a ( c ) : ( b = b . getModelType ( ) ) && d . Views [ b ] ? new d . Views [ b ] ( c ) : new a ( c ) } ; d . Views . CollectionBase = a . Marionette . CollectionView . extend ( { itemView : a . Marionette . ItemView , buildItemView : e } ) ; d . Views . CompositeBase = a . Marionette . CompositeView . extend ( { buildItemView : e } ) } ) ( Mibew , Backbone , _ ) ;
2013-02-06 15:04:41 +04:00
/ *
This file is part of Mibew Messenger project .
http : //mibew.org
Copyright ( c ) 2005 - 2011 Mibew Messenger Community
License : http : //mibew.org/license.php
* /
2013-01-17 17:44:18 +04:00
( function ( a ) { a . Views . ControlsCollection = a . Views . CollectionBase . extend ( { itemView : a . Views . Control , className : "controls-collection" } ) } ) ( Mibew ) ;