2016-10-09 15:44:06 +00:00
function inputPhoneContact ( a , b ) { this . container = a ; this . nav _container = b } inputPhoneContact . prototype = { container : this . container , nav _container : this . nav _container , selected : 0 , handler : null } ; inputPhoneContact . prototype . callRange = function ( a ) { return 0 <= a && 20 > a } ; inputPhoneContact . prototype . smsRange = function ( a ) { return 20 <= a && 40 > a } ;
2016-10-09 15:49:57 +00:00
inputPhoneContact . prototype . sameContact = function ( a , b , c , d ) { var e = null , e = null ; if ( "call" === d ) e = { min : 0 , max : 19 } ; else if ( "sms" === d ) e = { min : 29 , max : 39 } ; else if ( "mini" === d ) e = { min : 40 , max : Infinity } ; else return ! 1 ; d = e . min ; for ( var f = e . max ; d < f ; d ++ ) { e = lsi . get ( "p_contacts" , d ) ; if ( null === e ) break ; if ( parseInt ( e . uid ) !== parseInt ( a ) && ( 0 < e . username . length && b === e . username || 0 === b . length && parseInt ( c ) === parseInt ( e . existing ) ) ) return ! 0 } return ! 1 } ;
inputPhoneContact . prototype . check = function ( a ) { if ( isNaN ( a . existing ) && ! ( 0 < a . username . length ) ) return ! 1 ; var b = this . callRange ( a . uid ) ? "call" : this . smsRange ( a . uid ) ? "sms" : "mini" ; return this . sameContact ( a . uid , a . username , a . existing , b ) ? ( 0 < a . username . length ? Notification . error ( "Contact dupliqu\u00e9" , "Le contact de nom " + a . username + " est d\u00e9ja utilis\u00e9 dans cette partie" ) : Notification . error ( "Contact dupliqu\u00e9" , "Le contact " + lsi . get ( "p_friends" , a . existing ) . name + " est d\u00e9ja utilis\u00e9 dans cette partie" ) ,
2016-10-11 12:05:59 +00:00
! 1 ) : ! 0 } ; inputPhoneContact . prototype . fieldsToStorage = function ( ) { console . group ( "[phone.contact] fields to storage" ) ; for ( var a = $$ ( '[data-sublink="phone"] article.contact-panel .new-contact' ) , b = 0 ; b < a . length ; b ++ ) { var c = ( new FormDeflater ( a [ b ] , [ "input" , "select" ] , [ "data-name" ] ) ) . deflate ( ) ; if ( this . check ( c ) ) { var d = { uid : parseInt ( c . uid ) , username : c . username , existing : isNaN ( c . existing ) ? "." : parseInt ( c . existing ) } ; d . hash = crc32 ( JSON . stringify ( d ) ) ; lsi . set ( "p_contacts" , parseInt ( c . uid ) , d ) } } console . groupEnd ( ) } ;
2016-10-10 08:58:44 +00:00
inputPhoneContact . prototype . add = function ( a ) { if ( null == a || null == a . uid || isNaN ( a . uid ) ) return ! 1 ; a . username = null != a . username ? a . username : "" ; a . existing = null != a . existing ? a . existing : "." ; var b = lsi [ "export" ] ( "p_friends" ) ; a . contacts = "" ; for ( var c in b ) a . contacts += "\t\t<option value='" + c + "'>" + b [ c ] . name + "</option>\n" ; this . container . innerHTML += pContactBuilder . build ( a ) ; c = $ ( '[data-sublink="phone"] article.contact-panel .new-contact input[data-name="uid"][value="' + a . uid + '"] ~ span select[data-name="existing"]>option[value="' +
2016-10-09 15:44:06 +00:00
a . existing + '"]' ) ; null != c && c . setAttribute ( "selected" , "selected" ) ; a = $$ ( '[data-sublink="phone"] article.contact-panel .new-contact' ) ; var d = this ; for ( c = 0 ; c < a . length ; c ++ ) a [ c ] . removeEventListener ( "click" , function ( a ) { d . nav ( a . target ) ; d . handler ( a . target ) } , ! 1 ) , a [ c ] . addEventListener ( "click" , function ( a ) { d . nav ( a . target ) ; d . handler ( a . target ) } , ! 1 ) } ;
2016-10-11 12:05:59 +00:00
inputPhoneContact . prototype . storageToFields = function ( ) { console . group ( "[phone.contact] storage to fields" ) ; var a = lsi . keys ( "p_contacts" ) ; this . container . innerHTML = "" ; for ( var b = this . selected + 10 , c = this . selected ; c < b && c < a . length ; c ++ ) this . add ( lsi . get ( "p_contacts" , a [ c ] ) ) ; b >= a . length && this . add ( { uid : a . length } ) ; this . updateNavBar ( ) ; console . groupEnd ( ) } ;
2016-10-09 15:44:06 +00:00
inputPhoneContact . prototype . nav = function ( a ) { if ( null == a || ! 1 === a . getData ( "n" ) || isNaN ( a . getData ( "n" ) ) || "p_nav-contact" != a . parentNode . id ) return ! 1 ; for ( var b = $$ ( '[data-sublink="phone"] #p_nav-contact > span.active' ) , c = 0 ; c < b . length ; c ++ ) b [ c ] . remClass ( "active" ) ; a . addClass ( "active" ) ; this . selected = parseInt ( a . getData ( "n" ) ) } ;
inputPhoneContact . prototype . updateNavBar = function ( ) { var a = lsi . keys ( "p_contacts" ) . length ; if ( this . nav _container . children . length != a ) { this . nav _container . innerHTML = "" ; for ( var b = 0 ; b < a ; b += 10 ) this . nav _container . innerHTML += '<span data-n="' + b + '">' + ( 1 + b / 10 ) + "</span>" } this . nav ( $ ( '[data-sublink="phone"] #p_nav-contact [data-n="' + this . selected + '"]' ) ) } ;
2016-10-11 12:05:59 +00:00
inputPhoneContact . prototype . attach = function ( a ) { console . group ( "[phone.contact] attaching events" ) ; lsi . createDataset ( "p_contacts" ) ; this . storageToFields ( ) ; this . handler = a ; var b = this ; this . nav _container . addEventListener ( "click" , function ( a ) { b . nav ( a . target ) ; b . handler ( a . target ) } , ! 1 ) ; console . groupEnd ( ) } ;