2015-01-13 00:29:40 +01:00
/* ---- src/Ui/media/lib/00-jquery.min.js ---- */
/*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
! function ( a , b ) { "object" == typeof module && "object" == typeof module . exports ? module . exports = a . document ? b ( a , ! 0 ) : function ( a ) { if ( ! a . document ) throw new Error ( "jQuery requires a window with a document" ) ; return b ( a ) } : b ( a ) } ( "undefined" != typeof window ? window : this , function ( a , b ) { var c = [ ] , d = c . slice , e = c . concat , f = c . push , g = c . indexOf , h = { } , i = h . toString , j = h . hasOwnProperty , k = { } , l = a . document , m = "2.1.3" , n = function ( a , b ) { return new n . fn . init ( a , b ) } , o = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g , p = /^-ms-/ , q = /-([\da-z])/gi , r = function ( a , b ) { return b . toUpperCase ( ) } ; n . fn = n . prototype = { jquery : m , constructor : n , selector : "" , length : 0 , toArray : function ( ) { return d . call ( this ) } , get : function ( a ) { return null != a ? 0 > a ? this [ a + this . length ] : this [ a ] : d . call ( this ) } , pushStack : function ( a ) { var b = n . merge ( this . constructor ( ) , a ) ; return b . prevObject = this , b . context = this . context , b } , each : function ( a , b ) { return n . each ( this , a , b ) } , map : function ( a ) { return this . pushStack ( n . map ( this , function ( b , c ) { return a . call ( b , c , b ) } ) ) } , slice : function ( ) { return this . pushStack ( d . apply ( this , arguments ) ) } , first : function ( ) { return this . eq ( 0 ) } , last : function ( ) { return this . eq ( - 1 ) } , eq : function ( a ) { var b = this . length , c = + a + ( 0 > a ? b : 0 ) ; return this . pushStack ( c >= 0 && b > c ? [ this [ c ] ] : [ ] ) } , end : function ( ) { return this . prevObject || this . constructor ( null ) } , push : f , sort : c . sort , splice : c . splice } , n . extend = n . fn . extend = function ( ) { var a , b , c , d , e , f , g = arguments [ 0 ] || { } , h = 1 , i = arguments . length , j = ! 1 ; for ( "boolean" == typeof g && ( j = g , g = arguments [ h ] || { } , h ++ ) , "object" == typeof g || n . isFunction ( g ) || ( g = { } ) , h === i && ( g = this , h -- ) ; i > h ; h ++ ) if ( null != ( a = arguments [ h ] ) ) for ( b in a ) c = g [ b ] , d = a [ b ] , g !== d && ( j && d && ( n . isPlainObject ( d ) || ( e = n . isArray ( d ) ) ) ? ( e ? ( e = ! 1 , f = c && n . isArray ( c ) ? c : [ ] ) : f = c && n . isPlainObject ( c ) ? c : { } , g [ b ] = n . extend ( j , f , d ) ) : void 0 !== d && ( g [ b ] = d ) ) ; return g } , n . extend ( { expando : "jQuery" + ( m + Math . random ( ) ) . replace ( /\D/g , "" ) , isReady : ! 0 , error : function ( a ) { throw new Error ( a ) } , noop : function ( ) { } , isFunction : function ( a ) { return "function" === n . type ( a ) } , isArray : Array . isArray , isWindow : function ( a ) { return null != a && a === a . window } , isNumeric : function ( a ) { return ! n . isArray ( a ) && a - parseFloat ( a ) + 1 >= 0 } , isPlainObject : function ( a ) { return "object" !== n . type ( a ) || a . nodeType || n . isWindow ( a ) ? ! 1 : a . constructor && ! j . call ( a . constructor . prototype , "isPrototypeOf" ) ? ! 1 : ! 0 } , isEmptyObject : function ( a ) { var b ; for ( b in a ) return ! 1 ; return ! 0 } , type : function ( a ) { return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? h [ i . call ( a ) ] || "object" : typeof a } , globalEval : function ( a ) { var b , c = eval ; a = n . trim ( a ) , a && ( 1 === a . indexOf ( "use strict" ) ? ( b = l . createElement ( "script" ) , b . text = a , l . head . appendChild ( b ) . parentNode . removeChild ( b ) ) : c ( a ) ) } , camelCase : function ( a ) { return a . replace ( p , "ms-" ) . replace ( q , r ) } , nodeName : function ( a , b ) { return a . nodeName && a . nodeName . toLowerCase ( ) === b . toLowerCase ( ) } , each : function ( a , b , c ) { var d , e = 0 , f = a . length , g = s ( a ) ; if ( c ) { if ( g ) { for ( ; f > e ; e ++ ) if ( d = b . apply ( a [ e ] , c ) , d === ! 1 ) break } else for ( e in a ) if ( d = b . apply ( a [ e ] , c ) , d === ! 1 ) break } else if ( g ) { for ( ; f > e ; e ++ ) if ( d = b . call ( a [ e ] , e , a [ e ] ) , d === ! 1 ) break } else for ( e in a ) if ( d = b . call ( a [ e ] , e , a [ e ] ) , d === ! 1 ) break ; return a } , trim : function ( a ) { return null == a ? "" : ( a + "" ) . replace ( o , "" ) } , makeArray : function ( a , b ) { var c = b || [ ] ; return null != a && ( s ( Object ( a ) ) ? n . merge ( c , "string" == typeof a ? [ a ] : a ) : f . call ( c , a ) ) , c } , inArray : function ( a , b , c ) { return null == b ? - 1 : g . call ( b , a , c ) } , merge : function ( a , b ) { for ( var c = + b . length , d = 0 , e = a . length ; c > d ; d ++ ) a [ e ++ ] = b [ d ] ; return a . length = e , a } , grep : function ( a , b , c ) { for ( var d , e = [ ] , f = 0 , g = a . length , h = ! c ; g > f ; f ++ ) d = ! b ( a [ f ] , f ) , d !== h && e . push ( a [ f ] ) ; return e } , map : function ( a , b , c ) { var d , f = 0 , g = a . length , h = s ( a ) , i = [ ] ; if ( h ) for ( ; g > f ; f ++ ) d = b ( a [ f ] , f , c ) , null != d && i . push ( d ) ; else for ( f in a ) d = b ( a [ f ] , f , c ) , null != d && i . push ( d ) ; return e . apply ( [ ] , i ) } , guid : 1 , proxy : function ( a , b ) { var c , e , f ; return "string" == typeof b && ( c = a [ b ] , b = a , a = c ) , n . isFunction ( a ) ? ( e = d . call ( arguments , 2 ) , f = function ( ) { return a . apply ( b || this , e . concat ( d . call ( arguments ) ) ) } , f . guid = a . guid = a . guid || n . guid ++ , f ) : void 0 } , now : Date . now , support : k } ) , n . each ( "Boolean Number String Function Array Date RegExp Object Error" . split ( " " ) , function ( a , b ) { h [ "[object " + b + "]" ] = b . toLowerCase ( ) } ) ; function s ( a ) { var b = a . length , c = n . type ( a ) ; return "function" === c || n . isWindow ( a ) ? ! 1 : 1 === a . nodeType && b ? ! 0 : "array" === c || 0 === b || " n
} , removeData : function ( a , b ) { M . remove ( a , b ) } , _data : function ( a , b , c ) { return L . access ( a , b , c ) } , _removeData : function ( a , b ) { L . remove ( a , b ) } } ) , n . fn . extend ( { data : function ( a , b ) { var c , d , e , f = this [ 0 ] , g = f && f . attributes ; if ( void 0 === a ) { if ( this . length && ( e = M . get ( f ) , 1 === f . nodeType && ! L . get ( f , "hasDataAttrs" ) ) ) { c = g . length ; while ( c -- ) g [ c ] && ( d = g [ c ] . name , 0 === d . indexOf ( "data-" ) && ( d = n . camelCase ( d . slice ( 5 ) ) , P ( f , d , e [ d ] ) ) ) ; L . set ( f , "hasDataAttrs" , ! 0 ) } return e } return "object" == typeof a ? this . each ( function ( ) { M . set ( this , a ) } ) : J ( this , function ( b ) { var c , d = n . camelCase ( a ) ; if ( f && void 0 === b ) { if ( c = M . get ( f , a ) , void 0 !== c ) return c ; if ( c = M . get ( f , d ) , void 0 !== c ) return c ; if ( c = P ( f , d , void 0 ) , void 0 !== c ) return c } else this . each ( function ( ) { var c = M . get ( this , d ) ; M . set ( this , d , b ) , - 1 !== a . indexOf ( "-" ) && void 0 !== c && M . set ( this , a , b ) } ) } , null , b , arguments . length > 1 , null , ! 0 ) } , removeData : function ( a ) { return this . each ( function ( ) { M . remove ( this , a ) } ) } } ) , n . extend ( { queue : function ( a , b , c ) { var d ; return a ? ( b = ( b || "fx" ) + "queue" , d = L . get ( a , b ) , c && ( ! d || n . isArray ( c ) ? d = L . access ( a , b , n . makeArray ( c ) ) : d . push ( c ) ) , d || [ ] ) : void 0 } , dequeue : function ( a , b ) { b = b || "fx" ; var c = n . queue ( a , b ) , d = c . length , e = c . shift ( ) , f = n . _queueHooks ( a , b ) , g = function ( ) { n . dequeue ( a , b ) } ; "inprogress" === e && ( e = c . shift ( ) , d -- ) , e && ( "fx" === b && c . unshift ( "inprogress" ) , delete f . stop , e . call ( a , g , f ) ) , ! d && f && f . empty . fire ( ) } , _queueHooks : function ( a , b ) { var c = b + "queueHooks" ; return L . get ( a , c ) || L . access ( a , c , { empty : n . Callbacks ( "once memory" ) . add ( function ( ) { L . remove ( a , [ b + "queue" , c ] ) } ) } ) } } ) , n . fn . extend ( { queue : function ( a , b ) { var c = 2 ; return "string" != typeof a && ( b = a , a = "fx" , c -- ) , arguments . length < c ? n . queue ( this [ 0 ] , a ) : void 0 === b ? this : this . each ( function ( ) { var c = n . queue ( this , a , b ) ; n . _queueHooks ( this , a ) , "fx" === a && "inprogress" !== c [ 0 ] && n . dequeue ( this , a ) } ) } , dequeue : function ( a ) { return this . each ( function ( ) { n . dequeue ( this , a ) } ) } , clearQueue : function ( a ) { return this . queue ( a || "fx" , [ ] ) } , promise : function ( a , b ) { var c , d = 1 , e = n . Deferred ( ) , f = this , g = this . length , h = function ( ) { -- d || e . resolveWith ( f , [ f ] ) } ; "string" != typeof a && ( b = a , a = void 0 ) , a = a || "fx" ; while ( g -- ) c = L . get ( f [ g ] , a + "queueHooks" ) , c && c . empty && ( d ++ , c . empty . add ( h ) ) ; return h ( ) , e . promise ( b ) } } ) ; var Q = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ . source , R = [ "Top" , "Right" , "Bottom" , "Left" ] , S = function ( a , b ) { return a = b || a , "none" === n . css ( a , "display" ) || ! n . contains ( a . ownerDocument , a ) } , T = /^(?:checkbox|radio)$/i ; ! function ( ) { var a = l . createDocumentFragment ( ) , b = a . appendChild ( l . createElement ( "div" ) ) , c = l . createElement ( "input" ) ; c . setAttribute ( "type" , "radio" ) , c . setAttribute ( "checked" , "checked" ) , c . setAttribute ( "name" , "t" ) , b . appendChild ( c ) , k . checkClone = b . cloneNode ( ! 0 ) . cloneNode ( ! 0 ) . lastChild . checked , b . innerHTML = "<textarea>x</textarea>" , k . noCloneChecked = ! ! b . cloneNode ( ! 0 ) . lastChild . defaultValue } ( ) ; var U = "undefined" ; k . focusinBubbles = "onfocusin" in a ; var V = /^key/ , W = /^(?:mouse|pointer|contextmenu)|click/ , X = /^(?:focusinfocus|focusoutblur)$/ , Y = /^([^.]*)(?:\.(.+)|)$/ ; function Z ( ) { return ! 0 } function $ ( ) { return ! 1 } function _ ( ) { try { return l . activeElement } catch ( a ) { } } n . event = { global : { } , add : function ( a , b , c , d , e ) { var f , g , h , i , j , k , l , m , o , p , q , r = L . get ( a ) ; if ( r ) { c . handler && ( f = c , c = f . handler , e = f . selector ) , c . guid || ( c . guid = n . guid ++ ) , ( i = r . events ) || ( i = r . events = { } ) , ( g = r . handle ) || ( g = r . handle = function ( b ) { return typeof n !== U && n . event . triggered !== b . type ? n . event . dispatch . apply ( a , arguments ) : void 0 } ) , b = ( b || "" ) . match ( E ) || [ "" ] , j = b . length ; while ( j -- ) h = Y . exec ( b [ j ] ) || [ ] , o = q = h [ 1 ] , p = ( h [ 2 ] || "" ) . split ( "." ) . sort ( ) , o && ( l = n . event . special [ o ] || { } , o = ( e ? l . delegateType : l . bindType ) || o , l = n . event . special [ o ] || { } , k = n . extend ( { type : o , origType : q , data : d , handler : c , guid : c . guid , selector : e , needsContext : e && n . expr . match . needsContext . test ( e ) , namespace : p . join ( "." ) } , f ) , ( m = i [ o ] ) || ( m = i [ o ] = [ ] , m . delegateCount = 0 , l . setup && l . setup . call ( a , d , p , g ) !== ! 1 || a . addEventListener && a . addEventListener ( o , g , ! 1 ) ) , l . add && ( l . add . call ( a , k ) , k . handler . guid || ( k . handler . guid = c . guid ) ) , e ? m . splice ( m . delegateCount ++ , 0 , k ) : m . push ( k ) , n . event . global [ o ] = ! 0 ) } } , remove : function ( a , b , c , d , e ) { var f , g , h , i , j , k , l , m , o , p , q , r = L . hasData ( a ) && L . get ( a ) ; if ( r && ( i = r . events ) ) { b = ( b || "" ) . match ( E ) || [ "" ] , j = b . length ; while ( j -- ) if ( h = Y . exec ( b [ j ] ) || [ ] , o = q = h [ 1 ] , p = ( h [ 2 ] || "" ) . split ( "." ) . sort ( ) , o ) { l = n . event . special [ o ] || { } , o = ( d ? l . delegateTyp
} , removeAttr : function ( a , b ) { var c , d , e = 0 , f = b && b . match ( E ) ; if ( f && 1 === a . nodeType ) while ( c = f [ e ++ ] ) d = n . propFix [ c ] || c , n . expr . match . bool . test ( c ) && ( a [ d ] = ! 1 ) , a . removeAttribute ( c ) } , attrHooks : { type : { set : function ( a , b ) { if ( ! k . radioValue && "radio" === b && n . nodeName ( a , "input" ) ) { var c = a . value ; return a . setAttribute ( "type" , b ) , c && ( a . value = c ) , b } } } } } ) , Zb = { set : function ( a , b , c ) { return b === ! 1 ? n . removeAttr ( a , c ) : a . setAttribute ( c , c ) , c } } , n . each ( n . expr . match . bool . source . match ( /\w+/g ) , function ( a , b ) { var c = $b [ b ] || n . find . attr ; $b [ b ] = function ( a , b , d ) { var e , f ; return d || ( f = $b [ b ] , $b [ b ] = e , e = null != c ( a , b , d ) ? b . toLowerCase ( ) : null , $b [ b ] = f ) , e } } ) ; var _b = /^(?:input|select|textarea|button)$/i ; n . fn . extend ( { prop : function ( a , b ) { return J ( this , n . prop , a , b , arguments . length > 1 ) } , removeProp : function ( a ) { return this . each ( function ( ) { delete this [ n . propFix [ a ] || a ] } ) } } ) , n . extend ( { propFix : { "for" : "htmlFor" , "class" : "className" } , prop : function ( a , b , c ) { var d , e , f , g = a . nodeType ; if ( a && 3 !== g && 8 !== g && 2 !== g ) return f = 1 !== g || ! n . isXMLDoc ( a ) , f && ( b = n . propFix [ b ] || b , e = n . propHooks [ b ] ) , void 0 !== c ? e && "set" in e && void 0 !== ( d = e . set ( a , c , b ) ) ? d : a [ b ] = c : e && "get" in e && null !== ( d = e . get ( a , b ) ) ? d : a [ b ] } , propHooks : { tabIndex : { get : function ( a ) { return a . hasAttribute ( "tabindex" ) || _b . test ( a . nodeName ) || a . href ? a . tabIndex : - 1 } } } } ) , k . optSelected || ( n . propHooks . selected = { get : function ( a ) { var b = a . parentNode ; return b && b . parentNode && b . parentNode . selectedIndex , null } } ) , n . each ( [ "tabIndex" , "readOnly" , "maxLength" , "cellSpacing" , "cellPadding" , "rowSpan" , "colSpan" , "useMap" , "frameBorder" , "contentEditable" ] , function ( ) { n . propFix [ this . toLowerCase ( ) ] = this } ) ; var ac = /[\t\r\n\f]/g ; n . fn . extend ( { addClass : function ( a ) { var b , c , d , e , f , g , h = "string" == typeof a && a , i = 0 , j = this . length ; if ( n . isFunction ( a ) ) return this . each ( function ( b ) { n ( this ) . addClass ( a . call ( this , b , this . className ) ) } ) ; if ( h ) for ( b = ( a || "" ) . match ( E ) || [ ] ; j > i ; i ++ ) if ( c = this [ i ] , d = 1 === c . nodeType && ( c . className ? ( " " + c . className + " " ) . replace ( ac , " " ) : " " ) ) { f = 0 ; while ( e = b [ f ++ ] ) d . indexOf ( " " + e + " " ) < 0 && ( d += e + " " ) ; g = n . trim ( d ) , c . className !== g && ( c . className = g ) } return this } , removeClass : function ( a ) { var b , c , d , e , f , g , h = 0 === arguments . length || "string" == typeof a && a , i = 0 , j = this . length ; if ( n . isFunction ( a ) ) return this . each ( function ( b ) { n ( this ) . removeClass ( a . call ( this , b , this . className ) ) } ) ; if ( h ) for ( b = ( a || "" ) . match ( E ) || [ ] ; j > i ; i ++ ) if ( c = this [ i ] , d = 1 === c . nodeType && ( c . className ? ( " " + c . className + " " ) . replace ( ac , " " ) : "" ) ) { f = 0 ; while ( e = b [ f ++ ] ) while ( d . indexOf ( " " + e + " " ) >= 0 ) d = d . replace ( " " + e + " " , " " ) ; g = a ? n . trim ( d ) : "" , c . className !== g && ( c . className = g ) } return this } , toggleClass : function ( a , b ) { var c = typeof a ; return "boolean" == typeof b && "string" === c ? b ? this . addClass ( a ) : this . removeClass ( a ) : this . each ( n . isFunction ( a ) ? function ( c ) { n ( this ) . toggleClass ( a . call ( this , c , this . className , b ) , b ) } : function ( ) { if ( "string" === c ) { var b , d = 0 , e = n ( this ) , f = a . match ( E ) || [ ] ; while ( b = f [ d ++ ] ) e . hasClass ( b ) ? e . removeClass ( b ) : e . addClass ( b ) } else ( c === U || "boolean" === c ) && ( this . className && L . set ( this , "__className__" , this . className ) , this . className = this . className || a === ! 1 ? "" : L . get ( this , "__className__" ) || "" ) } ) } , hasClass : function ( a ) { for ( var b = " " + a + " " , c = 0 , d = this . length ; d > c ; c ++ ) if ( 1 === this [ c ] . nodeType && ( " " + this [ c ] . className + " " ) . replace ( ac , " " ) . indexOf ( b ) >= 0 ) return ! 0 ; return ! 1 } } ) ; var bc = /\r/g ; n . fn . extend ( { val : function ( a ) { var b , c , d , e = this [ 0 ] ; { if ( arguments . length ) return d = n . isFunction ( a ) , this . each ( function ( c ) { var e ; 1 === this . nodeType && ( e = d ? a . call ( this , c , n ( this ) . val ( ) ) : a , null == e ? e = "" : "number" == typeof e ? e += "" : n . isArray ( e ) && ( e = n . map ( e , function ( a ) { return null == a ? "" : a + "" } ) ) , b = n . valHooks [ this . type ] || n . valHooks [ this . nodeName . toLowerCase ( ) ] , b && "set" in b && void 0 !== b . set ( this , e , "value" ) || ( this . value = e ) ) } ) ; if ( e ) return b = n . valHooks [ e . type ] || n . valHooks [ e . nodeName . toLowerCase ( ) ] , b && "get" in b && void 0 !== ( c = b . get ( e , "value" ) ) ? c : ( c = e . value , "string" == typeof c ? c . replace ( bc , "" ) : null == c ? "" : c ) } } } ) , n . extend ( { valHooks : { option : { get : function ( a ) { var b = n . find . attr ( a , "value" ) ; return null != b ? b : n . trim ( n . text ( a ) ) } } , select : { get : function ( a ) { for ( var b , c , d = a . options , e = a . selectedIndex , f = "select-one" === a . type || 0 > e , g = f ? null : [ ] , h = f ? e + 1 : d . length , i = 0 > e ? h : f ? e : 0 ; h > i ; i ++ ) if ( c = d [ i ] , ! ( ! c . selected && i !== e || ( k . optDisabled ? c . disabled : null !== c . getAttribute ( "disabled" ) ) || c . par
/* ---- src/Ui/media/lib/ZeroWebsocket.coffee ---- */
( function ( ) {
var ZeroWebsocket ,
_ _bind = function ( fn , me ) { return function ( ) { return fn . apply ( me , arguments ) ; } ; } ,
_ _slice = [ ] . slice ;
ZeroWebsocket = ( function ( ) {
function ZeroWebsocket ( url ) {
this . onCloseWebsocket = _ _bind ( this . onCloseWebsocket , this ) ;
this . onErrorWebsocket = _ _bind ( this . onErrorWebsocket , this ) ;
this . onOpenWebsocket = _ _bind ( this . onOpenWebsocket , this ) ;
this . log = _ _bind ( this . log , this ) ;
this . route = _ _bind ( this . route , this ) ;
this . onMessage = _ _bind ( this . onMessage , this ) ;
this . url = url ;
this . next _message _id = 1 ;
this . waiting _cb = { } ;
this . init ( ) ;
}
ZeroWebsocket . prototype . init = function ( ) {
return this ;
} ;
ZeroWebsocket . prototype . connect = function ( ) {
this . ws = new WebSocket ( this . url ) ;
this . ws . onmessage = this . onMessage ;
this . ws . onopen = this . onOpenWebsocket ;
this . ws . onerror = this . onErrorWebsocket ;
return this . ws . onclose = this . onCloseWebsocket ;
} ;
ZeroWebsocket . prototype . onMessage = function ( e ) {
var cmd , message ;
message = JSON . parse ( e . data ) ;
cmd = message . cmd ;
if ( cmd === "response" ) {
if ( this . waiting _cb [ message . to ] != null ) {
return this . waiting _cb [ message . to ] ( message . result ) ;
} else {
return this . log ( "Websocket callback not found:" , message ) ;
}
} else if ( cmd === "ping" ) {
return this . response ( message . id , "pong" ) ;
} else {
return this . route ( cmd , message ) ;
}
} ;
ZeroWebsocket . prototype . route = function ( cmd , message ) {
return this . log ( "Unknown command" , message ) ;
} ;
ZeroWebsocket . prototype . response = function ( to , result ) {
return this . send ( {
"cmd" : "response" ,
"to" : to ,
"result" : result
} ) ;
} ;
ZeroWebsocket . prototype . cmd = function ( cmd , params , cb ) {
if ( params == null ) {
params = { } ;
}
if ( cb == null ) {
cb = null ;
}
return this . send ( {
"cmd" : cmd ,
"params" : params
} , cb ) ;
} ;
ZeroWebsocket . prototype . send = function ( message , cb ) {
if ( cb == null ) {
cb = null ;
}
if ( message . id == null ) {
message . id = this . next _message _id ;
this . next _message _id += 1 ;
}
this . ws . send ( JSON . stringify ( message ) ) ;
if ( cb ) {
return this . waiting _cb [ message . id ] = cb ;
}
} ;
ZeroWebsocket . prototype . log = function ( ) {
var args ;
args = 1 <= arguments . length ? _ _slice . call ( arguments , 0 ) : [ ] ;
return console . log . apply ( console , [ "[ZeroWebsocket]" ] . concat ( _ _slice . call ( args ) ) ) ;
} ;
ZeroWebsocket . prototype . onOpenWebsocket = function ( e ) {
2015-01-24 19:14:29 +01:00
this . log ( "Open" ) ;
2015-01-13 00:29:40 +01:00
if ( this . onOpen != null ) {
return this . onOpen ( e ) ;
}
} ;
ZeroWebsocket . prototype . onErrorWebsocket = function ( e ) {
this . log ( "Error" , e ) ;
if ( this . onError != null ) {
return this . onError ( e ) ;
}
} ;
ZeroWebsocket . prototype . onCloseWebsocket = function ( e ) {
this . log ( "Closed" , e ) ;
if ( e . code === 1000 ) {
this . log ( "Server error, please reload the page" ) ;
} else {
setTimeout ( ( ( function ( _this ) {
return function ( ) {
_this . log ( "Reconnecting..." ) ;
return _this . connect ( ) ;
} ;
} ) ( this ) ) , 10000 ) ;
}
if ( this . onClose != null ) {
return this . onClose ( e ) ;
}
} ;
return ZeroWebsocket ;
} ) ( ) ;
window . ZeroWebsocket = ZeroWebsocket ;
} ) . call ( this ) ;
/* ---- src/Ui/media/lib/jquery.cssanim.js ---- */
jQuery . cssHooks [ 'scale' ] = {
get : function ( elem , computed , extra ) {
var match = window . getComputedStyle ( elem ) . transform . match ( "[0-9\.]+" )
if ( match ) {
var scale = parseFloat ( match [ 0 ] )
return scale
} else {
return 1.0
}
} ,
set : function ( elem , val ) {
//var transforms = $(elem).css("transform").match(/[0-9\.]+/g)
var transforms = window . getComputedStyle ( elem ) . transform . match ( /[0-9\.]+/g )
if ( transforms ) {
transforms [ 0 ] = val
transforms [ 3 ] = val
//$(elem).css("transform", 'matrix('+transforms.join(", ")+")")
elem . style . transform = 'matrix(' + transforms . join ( ", " ) + ')'
} else {
elem . style . transform = "scale(" + val + ")"
}
}
}
jQuery . fx . step . scale = function ( fx ) {
jQuery . cssHooks [ 'scale' ] . set ( fx . elem , fx . now )
} ;
/* ---- src/Ui/media/lib/jquery.csslater.coffee ---- */
( function ( ) {
jQuery . fn . readdClass = function ( class _name ) {
var elem ;
elem = this ;
elem . removeClass ( class _name ) ;
setTimeout ( ( function ( ) {
return elem . addClass ( class _name ) ;
} ) , 1 ) ;
return this ;
} ;
jQuery . fn . removeLater = function ( time ) {
var elem ;
if ( time == null ) {
time = 500 ;
}
elem = this ;
setTimeout ( ( function ( ) {
return elem . remove ( ) ;
} ) , time ) ;
return this ;
} ;
jQuery . fn . hideLater = function ( time ) {
var elem ;
if ( time == null ) {
time = 500 ;
}
elem = this ;
setTimeout ( ( function ( ) {
return elem . css ( "display" , "none" ) ;
} ) , time ) ;
return this ;
} ;
jQuery . fn . addClassLater = function ( class _name , time ) {
var elem ;
if ( time == null ) {
time = 5 ;
}
elem = this ;
setTimeout ( ( function ( ) {
return elem . addClass ( class _name ) ;
} ) , time ) ;
return this ;
} ;
jQuery . fn . cssLater = function ( name , val , time ) {
var elem ;
if ( time == null ) {
time = 500 ;
}
elem = this ;
setTimeout ( ( function ( ) {
return elem . css ( name , val ) ;
} ) , time ) ;
return this ;
} ;
} ) . call ( this ) ;
/* ---- src/Ui/media/lib/jquery.easing.1.3.js ---- */
/ *
* jQuery Easing v1 . 3 - http : //gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
*
* Open source under the BSD License .
*
* Copyright © 2008 George McGinley Smith
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without modification ,
* are permitted provided that the following conditions are met :
*
* Redistributions of source code must retain the above copyright notice , this list of
* conditions and the following disclaimer .
* Redistributions in binary form must reproduce the above copyright notice , this list
* of conditions and the following disclaimer in the documentation and / or other materials
* provided with the distribution .
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL ,
* EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING
* NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE .
*
* /
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery . easing [ 'jswing' ] = jQuery . easing [ 'swing' ] ;
jQuery . extend ( jQuery . easing ,
{
def : 'easeOutQuad' ,
swing : function ( x , t , b , c , d ) {
//alert(jQuery.easing.default);
return jQuery . easing [ jQuery . easing . def ] ( x , t , b , c , d ) ;
} ,
easeInQuad : function ( x , t , b , c , d ) {
return c * ( t /= d ) * t + b ;
} ,
easeOutQuad : function ( x , t , b , c , d ) {
return - c * ( t /= d ) * ( t - 2 ) + b ;
} ,
easeInOutQuad : function ( x , t , b , c , d ) {
if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t + b ;
return - c / 2 * ( ( -- t ) * ( t - 2 ) - 1 ) + b ;
} ,
easeInCubic : function ( x , t , b , c , d ) {
return c * ( t /= d ) * t * t + b ;
} ,
easeOutCubic : function ( x , t , b , c , d ) {
return c * ( ( t = t / d - 1 ) * t * t + 1 ) + b ;
} ,
easeInOutCubic : function ( x , t , b , c , d ) {
if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t + b ;
return c / 2 * ( ( t -= 2 ) * t * t + 2 ) + b ;
} ,
easeInQuart : function ( x , t , b , c , d ) {
return c * ( t /= d ) * t * t * t + b ;
} ,
easeOutQuart : function ( x , t , b , c , d ) {
return - c * ( ( t = t / d - 1 ) * t * t * t - 1 ) + b ;
} ,
easeInOutQuart : function ( x , t , b , c , d ) {
if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t + b ;
return - c / 2 * ( ( t -= 2 ) * t * t * t - 2 ) + b ;
} ,
easeInQuint : function ( x , t , b , c , d ) {
return c * ( t /= d ) * t * t * t * t + b ;
} ,
easeOutQuint : function ( x , t , b , c , d ) {
return c * ( ( t = t / d - 1 ) * t * t * t * t + 1 ) + b ;
} ,
easeInOutQuint : function ( x , t , b , c , d ) {
if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t * t + b ;
return c / 2 * ( ( t -= 2 ) * t * t * t * t + 2 ) + b ;
} ,
easeInSine : function ( x , t , b , c , d ) {
return - c * Math . cos ( t / d * ( Math . PI / 2 ) ) + c + b ;
} ,
easeOutSine : function ( x , t , b , c , d ) {
return c * Math . sin ( t / d * ( Math . PI / 2 ) ) + b ;
} ,
easeInOutSine : function ( x , t , b , c , d ) {
return - c / 2 * ( Math . cos ( Math . PI * t / d ) - 1 ) + b ;
} ,
easeInExpo : function ( x , t , b , c , d ) {
return ( t == 0 ) ? b : c * Math . pow ( 2 , 10 * ( t / d - 1 ) ) + b ;
} ,
easeOutExpo : function ( x , t , b , c , d ) {
return ( t == d ) ? b + c : c * ( - Math . pow ( 2 , - 10 * t / d ) + 1 ) + b ;
} ,
easeInOutExpo : function ( x , t , b , c , d ) {
if ( t == 0 ) return b ;
if ( t == d ) return b + c ;
if ( ( t /= d / 2 ) < 1 ) return c / 2 * Math . pow ( 2 , 10 * ( t - 1 ) ) + b ;
return c / 2 * ( - Math . pow ( 2 , - 10 * -- t ) + 2 ) + b ;
} ,
easeInCirc : function ( x , t , b , c , d ) {
return - c * ( Math . sqrt ( 1 - ( t /= d ) * t ) - 1 ) + b ;
} ,
easeOutCirc : function ( x , t , b , c , d ) {
return c * Math . sqrt ( 1 - ( t = t / d - 1 ) * t ) + b ;
} ,
easeInOutCirc : function ( x , t , b , c , d ) {
if ( ( t /= d / 2 ) < 1 ) return - c / 2 * ( Math . sqrt ( 1 - t * t ) - 1 ) + b ;
return c / 2 * ( Math . sqrt ( 1 - ( t -= 2 ) * t ) + 1 ) + b ;
} ,
easeInElastic : function ( x , t , b , c , d ) {
var s = 1.70158 ; var p = 0 ; var a = c ;
if ( t == 0 ) return b ; if ( ( t /= d ) == 1 ) return b + c ; if ( ! p ) p = d * . 3 ;
if ( a < Math . abs ( c ) ) { a = c ; var s = p / 4 ; }
else var s = p / ( 2 * Math . PI ) * Math . asin ( c / a ) ;
return - ( a * Math . pow ( 2 , 10 * ( t -= 1 ) ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) ) + b ;
} ,
easeOutElastic : function ( x , t , b , c , d ) {
var s = 1.70158 ; var p = 0 ; var a = c ;
if ( t == 0 ) return b ; if ( ( t /= d ) == 1 ) return b + c ; if ( ! p ) p = d * . 3 ;
if ( a < Math . abs ( c ) ) { a = c ; var s = p / 4 ; }
else var s = p / ( 2 * Math . PI ) * Math . asin ( c / a ) ;
return a * Math . pow ( 2 , - 10 * t ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) + c + b ;
} ,
easeInOutElastic : function ( x , t , b , c , d ) {
var s = 1.70158 ; var p = 0 ; var a = c ;
if ( t == 0 ) return b ; if ( ( t /= d / 2 ) == 2 ) return b + c ; if ( ! p ) p = d * ( . 3 * 1.5 ) ;
if ( a < Math . abs ( c ) ) { a = c ; var s = p / 4 ; }
else var s = p / ( 2 * Math . PI ) * Math . asin ( c / a ) ;
if ( t < 1 ) return - . 5 * ( a * Math . pow ( 2 , 10 * ( t -= 1 ) ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) ) + b ;
return a * Math . pow ( 2 , - 10 * ( t -= 1 ) ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) * . 5 + c + b ;
} ,
easeInBack : function ( x , t , b , c , d , s ) {
if ( s == undefined ) s = 1.70158 ;
return c * ( t /= d ) * t * ( ( s + 1 ) * t - s ) + b ;
} ,
easeOutBack : function ( x , t , b , c , d , s ) {
if ( s == undefined ) s = 1.70158 ;
return c * ( ( t = t / d - 1 ) * t * ( ( s + 1 ) * t + s ) + 1 ) + b ;
} ,
easeInOutBack : function ( x , t , b , c , d , s ) {
if ( s == undefined ) s = 1.70158 ;
if ( ( t /= d / 2 ) < 1 ) return c / 2 * ( t * t * ( ( ( s *= ( 1.525 ) ) + 1 ) * t - s ) ) + b ;
return c / 2 * ( ( t -= 2 ) * t * ( ( ( s *= ( 1.525 ) ) + 1 ) * t + s ) + 2 ) + b ;
} ,
easeInBounce : function ( x , t , b , c , d ) {
return c - jQuery . easing . easeOutBounce ( x , d - t , 0 , c , d ) + b ;
} ,
easeOutBounce : function ( x , t , b , c , d ) {
if ( ( t /= d ) < ( 1 / 2.75 ) ) {
return c * ( 7.5625 * t * t ) + b ;
} else if ( t < ( 2 / 2.75 ) ) {
return c * ( 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + . 75 ) + b ;
} else if ( t < ( 2.5 / 2.75 ) ) {
return c * ( 7.5625 * ( t -= ( 2.25 / 2.75 ) ) * t + . 9375 ) + b ;
} else {
return c * ( 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + . 984375 ) + b ;
}
} ,
easeInOutBounce : function ( x , t , b , c , d ) {
if ( t < d / 2 ) return jQuery . easing . easeInBounce ( x , t * 2 , 0 , c , d ) * . 5 + b ;
return jQuery . easing . easeOutBounce ( x , t * 2 - d , 0 , c , d ) * . 5 + c * . 5 + b ;
}
} ) ;
/ *
*
* TERMS OF USE - EASING EQUATIONS
*
* Open source under the BSD License .
*
* Copyright © 2001 Robert Penner
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without modification ,
* are permitted provided that the following conditions are met :
*
* Redistributions of source code must retain the above copyright notice , this list of
* conditions and the following disclaimer .
* Redistributions in binary form must reproduce the above copyright notice , this list
* of conditions and the following disclaimer in the documentation and / or other materials
* provided with the distribution .
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL ,
* EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING
* NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE .
*
* /
/* ---- src/Ui/media/Loading.coffee ---- */
( function ( ) {
var Loading ;
Loading = ( function ( ) {
function Loading ( ) {
if ( window . show _loadingscreen ) {
this . showScreen ( ) ;
}
}
Loading . prototype . showScreen = function ( ) {
$ ( ".loadingscreen" ) . css ( "display" , "block" ) . addClassLater ( "ready" ) ;
this . screen _visible = true ;
return this . printLine ( " Connecting..." ) ;
} ;
Loading . prototype . hideScreen = function ( ) {
if ( ! $ ( ".loadingscreen" ) . hasClass ( "done" ) ) {
if ( this . screen _visible ) {
$ ( ".loadingscreen" ) . addClass ( "done" ) . removeLater ( 2000 ) ;
} else {
$ ( ".loadingscreen" ) . remove ( ) ;
}
}
return this . screen _visible = false ;
} ;
Loading . prototype . print = function ( text , type ) {
var last _line ;
if ( type == null ) {
type = "normal" ;
}
if ( ! this . screen _visible ) {
return false ;
}
$ ( ".loadingscreen .console .cursor" ) . remove ( ) ;
last _line = $ ( ".loadingscreen .console .console-line:last-child" ) ;
if ( type === "error" ) {
text = "<span class='console-error'>" + text + "</span>" ;
}
return last _line . html ( last _line . html ( ) + text ) ;
} ;
Loading . prototype . printLine = function ( text , type ) {
if ( type == null ) {
type = "normal" ;
}
if ( ! this . screen _visible ) {
return false ;
}
$ ( ".loadingscreen .console .cursor" ) . remove ( ) ;
if ( type === "error" ) {
text = "<span class='console-error'>" + text + "</span>" ;
} else {
text = text + "<span class='cursor'> </span>" ;
}
return $ ( ".loadingscreen .console" ) . append ( "<div class='console-line'>" + text + "</div>" ) ;
} ;
return Loading ;
} ) ( ) ;
window . Loading = Loading ;
} ) . call ( this ) ;
/* ---- src/Ui/media/Notifications.coffee ---- */
( function ( ) {
var Notifications ,
_ _slice = [ ] . slice ;
Notifications = ( function ( ) {
2015-01-27 22:37:13 +01:00
function Notifications ( _at _elem ) {
this . elem = _at _elem ;
2015-01-13 00:29:40 +01:00
this ;
}
Notifications . prototype . test = function ( ) {
setTimeout ( ( ( function ( _this ) {
return function ( ) {
_this . add ( "connection" , "error" , "Connection lost to <b>UiServer</b> on <b>localhost</b>!" ) ;
return _this . add ( "message-Anyone" , "info" , "New from <b>Anyone</b>." ) ;
} ;
} ) ( this ) ) , 1000 ) ;
return setTimeout ( ( ( function ( _this ) {
return function ( ) {
return _this . add ( "connection" , "done" , "<b>UiServer</b> connection recovered." , 5000 ) ;
} ;
} ) ( this ) ) , 3000 ) ;
} ;
Notifications . prototype . add = function ( id , type , body , timeout ) {
var elem , width , _i , _len , _ref ;
if ( timeout == null ) {
timeout = 0 ;
}
this . log ( id , type , body , timeout ) ;
_ref = $ ( ".notification-" + id ) ;
for ( _i = 0 , _len = _ref . length ; _i < _len ; _i ++ ) {
elem = _ref [ _i ] ;
this . close ( $ ( elem ) ) ;
}
elem = $ ( ".notification.template" , this . elem ) . clone ( ) . removeClass ( "template" ) ;
elem . addClass ( "notification-" + type ) . addClass ( "notification-" + id ) ;
if ( type === "error" ) {
$ ( ".notification-icon" , elem ) . html ( "!" ) ;
} else if ( type === "done" ) {
$ ( ".notification-icon" , elem ) . html ( "<div class='icon-success'></div>" ) ;
2015-01-21 12:58:26 +01:00
} else if ( type === "ask" ) {
$ ( ".notification-icon" , elem ) . html ( "?" ) ;
2015-01-13 00:29:40 +01:00
} else {
$ ( ".notification-icon" , elem ) . html ( "i" ) ;
}
2015-01-21 12:58:26 +01:00
if ( typeof body === "string" ) {
$ ( ".body" , elem ) . html ( body ) ;
} else {
$ ( ".body" , elem ) . html ( "" ) . append ( body ) ;
}
2015-01-13 00:29:40 +01:00
elem . appendTo ( this . elem ) ;
if ( timeout ) {
$ ( ".close" , elem ) . remove ( ) ;
setTimeout ( ( ( function ( _this ) {
return function ( ) {
return _this . close ( elem ) ;
} ;
} ) ( this ) ) , timeout ) ;
}
width = elem . outerWidth ( ) ;
if ( ! timeout ) {
width += 20 ;
}
elem . css ( {
"width" : "50px" ,
"transform" : "scale(0.01)"
} ) ;
elem . animate ( {
"scale" : 1
} , 800 , "easeOutElastic" ) ;
elem . animate ( {
"width" : width
} , 700 , "easeInOutCubic" ) ;
$ ( ".close" , elem ) . on ( "click" , ( function ( _this ) {
return function ( ) {
_this . close ( elem ) ;
return false ;
} ;
} ) ( this ) ) ;
2015-01-21 12:58:26 +01:00
return $ ( ".button" , elem ) . on ( "click" , ( function ( _this ) {
return function ( ) {
_this . close ( elem ) ;
return false ;
} ;
} ) ( this ) ) ;
2015-01-13 00:29:40 +01:00
} ;
Notifications . prototype . close = function ( elem ) {
elem . stop ( ) . animate ( {
"width" : 0 ,
"opacity" : 0
} , 700 , "easeInOutCubic" ) ;
return elem . slideUp ( 300 , ( function ( ) {
return elem . remove ( ) ;
} ) ) ;
} ;
Notifications . prototype . log = function ( ) {
var args ;
args = 1 <= arguments . length ? _ _slice . call ( arguments , 0 ) : [ ] ;
return console . log . apply ( console , [ "[Notifications]" ] . concat ( _ _slice . call ( args ) ) ) ;
} ;
return Notifications ;
} ) ( ) ;
window . Notifications = Notifications ;
} ) . call ( this ) ;
/* ---- src/Ui/media/Sidebar.coffee ---- */
( function ( ) {
var Sidebar ;
Sidebar = ( function ( ) {
function Sidebar ( ) {
this . initFixbutton ( ) ;
}
Sidebar . prototype . initFixbutton = function ( ) {
$ ( ".fixbutton-bg" ) . on ( "mouseover" , function ( ) {
$ ( this ) . stop ( ) . animate ( {
"scale" : 0.7
} , 800 , "easeOutElastic" ) ;
$ ( ".fixbutton-burger" ) . stop ( ) . animate ( {
"opacity" : 1.5 ,
"left" : 0
} , 800 , "easeOutElastic" ) ;
return $ ( ".fixbutton-text" ) . stop ( ) . animate ( {
"opacity" : 0 ,
"left" : 20
} , 300 , "easeOutCubic" ) ;
} ) ;
$ ( ".fixbutton-bg" ) . on ( "mouseout" , function ( ) {
$ ( this ) . stop ( ) . animate ( {
"scale" : 0.6
} , 300 , "easeOutCubic" ) ;
$ ( ".fixbutton-burger" ) . stop ( ) . animate ( {
"opacity" : 0 ,
"left" : - 20
} , 300 , "easeOutCubic" ) ;
return $ ( ".fixbutton-text" ) . stop ( ) . animate ( {
"opacity" : 1 ,
"left" : 0
} , 300 , "easeOutBack" ) ;
} ) ;
/ * $ ( " . f i x b u t t o n - b g " ) . o n " c l i c k " , - >
2015-01-27 22:37:13 +01:00
return false
* /
2015-01-13 00:29:40 +01:00
$ ( ".fixbutton-bg" ) . on ( "mousedown" , function ( ) {
return $ ( ".fixbutton-burger" ) . stop ( ) . animate ( {
"scale" : 0.7 ,
"left" : 0
} , 300 , "easeOutCubic" ) ;
} ) ;
return $ ( ".fixbutton-bg" ) . on ( "mouseup" , function ( ) {
return $ ( ".fixbutton-burger" ) . stop ( ) . animate ( {
"scale" : 1 ,
"left" : 0
} , 600 , "easeOutElastic" ) ;
} ) ;
} ;
return Sidebar ;
} ) ( ) ;
window . Sidebar = Sidebar ;
} ) . call ( this ) ;
/* ---- src/Ui/media/Wrapper.coffee ---- */
( function ( ) {
var Wrapper , ws _url ,
_ _bind = function ( fn , me ) { return function ( ) { return fn . apply ( me , arguments ) ; } ; } ,
_ _slice = [ ] . slice ;
Wrapper = ( function ( ) {
function Wrapper ( ws _url ) {
this . onLoad = _ _bind ( this . onLoad , this ) ;
this . onCloseWebsocket = _ _bind ( this . onCloseWebsocket , this ) ;
this . onOpenWebsocket = _ _bind ( this . onOpenWebsocket , this ) ;
this . onMessageInner = _ _bind ( this . onMessageInner , this ) ;
this . onMessageWebsocket = _ _bind ( this . onMessageWebsocket , this ) ;
this . log ( "Created!" ) ;
this . loading = new Loading ( ) ;
this . notifications = new Notifications ( $ ( ".notifications" ) ) ;
this . sidebar = new Sidebar ( ) ;
window . addEventListener ( "message" , this . onMessageInner , false ) ;
this . inner = document . getElementById ( "inner-iframe" ) . contentWindow ;
this . ws = new ZeroWebsocket ( ws _url ) ;
this . ws . next _message _id = 1000000 ;
this . ws . onOpen = this . onOpenWebsocket ;
this . ws . onClose = this . onCloseWebsocket ;
this . ws . onMessage = this . onMessageWebsocket ;
this . ws . connect ( ) ;
this . ws _error = null ;
this . site _info = null ;
this . inner _loaded = false ;
this . inner _ready = false ;
this . wrapperWsInited = false ;
this . site _error = null ;
window . onload = this . onLoad ;
2015-01-27 22:37:13 +01:00
$ ( window ) . on ( "hashchange" , ( function ( _this ) {
return function ( ) {
var src ;
_this . log ( "Hashchange" , window . location . hash ) ;
src = $ ( "#inner-iframe" ) . attr ( "src" ) . replace ( /#.*/ , "" ) + window . location . hash ;
return $ ( "#inner-iframe" ) . attr ( "src" , src ) ;
} ;
} ) ( this ) ) ;
2015-01-13 00:29:40 +01:00
this ;
}
Wrapper . prototype . onMessageWebsocket = function ( e ) {
var cmd , message ;
message = JSON . parse ( e . data ) ;
cmd = message . cmd ;
if ( cmd === "response" ) {
if ( this . ws . waiting _cb [ message . to ] != null ) {
return this . ws . waiting _cb [ message . to ] ( message . result ) ;
} else {
return this . sendInner ( message ) ;
}
} else if ( cmd === "notification" ) {
return this . notifications . add ( "notification-" + message . id , message . params [ 0 ] , message . params [ 1 ] , message . params [ 2 ] ) ;
} else if ( cmd === "setSiteInfo" ) {
this . sendInner ( message ) ;
if ( message . params . address === window . address ) {
return this . setSiteInfo ( message . params ) ;
}
} else {
return this . sendInner ( message ) ;
}
} ;
Wrapper . prototype . onMessageInner = function ( e ) {
var cmd , message ;
message = e . data ;
cmd = message . cmd ;
if ( cmd === "innerReady" ) {
this . inner _ready = true ;
this . log ( "innerReady" , this . ws . ws . readyState , this . wrapperWsInited ) ;
if ( this . ws . ws . readyState === 1 && ! this . wrapperWsInited ) {
this . sendInner ( {
"cmd" : "wrapperOpenedWebsocket"
} ) ;
return this . wrapperWsInited = true ;
}
} else if ( cmd === "wrapperNotification" ) {
2015-01-21 12:58:26 +01:00
message . params = this . toHtmlSafe ( message . params ) ;
2015-01-13 00:29:40 +01:00
return this . notifications . add ( "notification-" + message . id , message . params [ 0 ] , message . params [ 1 ] , message . params [ 2 ] ) ;
2015-01-21 12:58:26 +01:00
} else if ( cmd === "wrapperConfirm" ) {
return this . actionWrapperConfirm ( message ) ;
2015-01-24 19:14:29 +01:00
} else if ( cmd === "wrapperPrompt" ) {
return this . actionWrapperPrompt ( message ) ;
2015-01-13 00:29:40 +01:00
} else {
return this . ws . send ( message ) ;
}
} ;
2015-01-21 12:58:26 +01:00
Wrapper . prototype . actionWrapperConfirm = function ( message ) {
var body , button , caption ;
message . params = this . toHtmlSafe ( message . params ) ;
if ( message . params [ 1 ] ) {
caption = message . params [ 1 ] ;
} else {
caption = "ok" ;
}
body = $ ( "<span>" + message . params [ 0 ] + "</span>" ) ;
button = $ ( "<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>" ) ;
button . on ( "click" , ( function ( _this ) {
return function ( ) {
_this . sendInner ( {
"cmd" : "response" ,
"to" : message . id ,
"result" : "boom"
} ) ;
return false ;
} ;
} ) ( this ) ) ;
body . append ( button ) ;
return this . notifications . add ( "notification-" + message . id , "ask" , body ) ;
} ;
2015-01-24 19:14:29 +01:00
Wrapper . prototype . actionWrapperPrompt = function ( message ) {
var body , button , caption , input , type ;
message . params = this . toHtmlSafe ( message . params ) ;
if ( message . params [ 1 ] ) {
type = message . params [ 1 ] ;
} else {
type = "text" ;
}
caption = "OK" ;
body = $ ( "<span>" + message . params [ 0 ] + "</span>" ) ;
input = $ ( "<input type='" + type + "' class='input button-" + type + "'/>" ) ;
input . on ( "keyup" , ( function ( _this ) {
return function ( e ) {
if ( e . keyCode === 13 ) {
return _this . sendInner ( {
"cmd" : "response" ,
"to" : message . id ,
"result" : input . val ( )
} ) ;
}
} ;
} ) ( this ) ) ;
body . append ( input ) ;
button = $ ( "<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>" ) ;
button . on ( "click" , ( function ( _this ) {
return function ( ) {
_this . sendInner ( {
"cmd" : "response" ,
"to" : message . id ,
"result" : input . val ( )
} ) ;
return false ;
} ;
} ) ( this ) ) ;
body . append ( button ) ;
return this . notifications . add ( "notification-" + message . id , "ask" , body ) ;
} ;
2015-01-13 00:29:40 +01:00
Wrapper . prototype . onOpenWebsocket = function ( e ) {
this . ws . cmd ( "channelJoin" , {
"channel" : "siteChanged"
} ) ;
this . log ( "onOpenWebsocket" , this . inner _ready , this . wrapperWsInited ) ;
if ( ! this . wrapperWsInited && this . inner _ready ) {
this . sendInner ( {
"cmd" : "wrapperOpenedWebsocket"
} ) ;
this . wrapperWsInited = true ;
}
if ( this . inner _loaded ) {
this . reloadSiteInfo ( ) ;
}
setTimeout ( ( ( function ( _this ) {
return function ( ) {
if ( ! _this . site _info ) {
return _this . reloadSiteInfo ( ) ;
}
} ;
} ) ( this ) ) , 2000 ) ;
if ( this . ws _error ) {
this . notifications . add ( "connection" , "done" , "Connection with <b>UiServer Websocket</b> recovered." , 6000 ) ;
return this . ws _error = null ;
}
} ;
Wrapper . prototype . onCloseWebsocket = function ( e ) {
this . wrapperWsInited = false ;
return setTimeout ( ( ( function ( _this ) {
return function ( ) {
_this . sendInner ( {
"cmd" : "wrapperClosedWebsocket"
} ) ;
if ( e . code === 1000 ) {
return _this . ws _error = _this . notifications . add ( "connection" , "error" , "UiServer Websocket error, please reload the page." ) ;
} else if ( ! _this . ws _error ) {
return _this . ws _error = _this . notifications . add ( "connection" , "error" , "Connection with <b>UiServer Websocket</b> was lost. Reconnecting..." ) ;
}
} ;
} ) ( this ) ) , 500 ) ;
} ;
Wrapper . prototype . onLoad = function ( e ) {
2015-01-24 19:14:29 +01:00
this . log ( "onLoad" ) ;
2015-01-13 00:29:40 +01:00
this . inner _loaded = true ;
if ( ! this . inner _ready ) {
this . sendInner ( {
"cmd" : "wrapperReady"
} ) ;
}
if ( ! this . site _error ) {
this . loading . hideScreen ( ) ;
}
2015-01-24 19:14:29 +01:00
if ( window . location . hash ) {
$ ( "#inner-iframe" ) [ 0 ] . src += window . location . hash ;
}
2015-01-13 00:29:40 +01:00
if ( this . ws . ws . readyState === 1 && ! this . site _info ) {
return this . reloadSiteInfo ( ) ;
}
} ;
Wrapper . prototype . sendInner = function ( message ) {
return this . inner . postMessage ( message , '*' ) ;
} ;
Wrapper . prototype . reloadSiteInfo = function ( ) {
return this . ws . cmd ( "siteInfo" , { } , ( function ( _this ) {
return function ( site _info ) {
_this . setSiteInfo ( site _info ) ;
window . document . title = site _info . content . title + " - ZeroNet" ;
return _this . log ( "Setting title to" , window . document . title ) ;
} ;
} ) ( this ) ) ;
} ;
Wrapper . prototype . setSiteInfo = function ( site _info ) {
if ( site _info . event != null ) {
2015-01-18 22:52:19 +01:00
if ( site _info . event [ 0 ] === "file_added" && site _info . bad _files ) {
2015-01-27 22:37:13 +01:00
this . loading . printLine ( site _info . bad _files + " files needs to be downloaded" ) ;
2015-01-13 00:29:40 +01:00
} else if ( site _info . event [ 0 ] === "file_done" ) {
2015-01-27 22:37:13 +01:00
this . loading . printLine ( site _info . event [ 1 ] + " downloaded" ) ;
2015-01-13 00:29:40 +01:00
if ( site _info . event [ 1 ] === window . inner _path ) {
this . loading . hideScreen ( ) ;
2015-01-21 12:58:26 +01:00
if ( ! this . site _info ) {
this . reloadSiteInfo ( ) ;
}
2015-01-13 00:29:40 +01:00
if ( ! $ ( ".loadingscreen" ) . length ) {
this . notifications . add ( "modified" , "info" , "New version of this page has just released.<br>Reload to see the modified content." ) ;
}
}
} else if ( site _info . event [ 0 ] === "file_failed" ) {
this . site _error = site _info . event [ 1 ] ;
2015-01-27 22:37:13 +01:00
this . loading . printLine ( site _info . event [ 1 ] + " download failed" , "error" ) ;
2015-01-13 00:29:40 +01:00
} else if ( site _info . event [ 0 ] === "peers_added" ) {
this . loading . printLine ( "Peers found: " + site _info . peers ) ;
}
}
if ( this . loading . screen _visible && ! this . site _info ) {
if ( site _info . peers > 1 ) {
this . loading . printLine ( "Peers found: " + site _info . peers ) ;
} else {
this . site _error = "No peers found" ;
this . loading . printLine ( "No peers found" ) ;
}
}
return this . site _info = site _info ;
} ;
2015-01-21 12:58:26 +01:00
Wrapper . prototype . toHtmlSafe = function ( unsafe ) {
return unsafe ;
} ;
2015-01-13 00:29:40 +01:00
Wrapper . prototype . log = function ( ) {
var args ;
args = 1 <= arguments . length ? _ _slice . call ( arguments , 0 ) : [ ] ;
return console . log . apply ( console , [ "[Wrapper]" ] . concat ( _ _slice . call ( args ) ) ) ;
} ;
return Wrapper ;
} ) ( ) ;
2015-01-18 22:52:19 +01:00
ws _url = "ws://" + window . location . hostname + ":" + window . location . port + "/Websocket?wrapper_key=" + window . wrapper _key ;
2015-01-13 00:29:40 +01:00
window . wrapper = new Wrapper ( ws _url ) ;
} ) . call ( this ) ;