2016-05-19 13:14:10 +00:00
function inputFacebookContact ( a , b ) { this . container = a ; this . nav _container = b } inputFacebookContact . prototype = { container : this . container , nav _container : this . nav _container , selected : 0 , handler : null } ; inputFacebookContact . prototype . check = function ( a ) { return 0 <= a . username . length } ;
2016-05-18 13:28:02 +00:00
inputFacebookContact . prototype . fieldsToStorage = function ( ) { console . log ( "CONTACTS: FIELDS TO STORAGE" ) ; for ( var a = $$ ( '[data-sublink="facebook"] article.contact-panel .new-contact' ) , b = 0 ; b < a . length ; b ++ ) { var c = ( new FormDeflater ( a [ b ] , [ "input" ] , [ "data-name" ] ) ) . deflate ( ) ; if ( this . check ( c ) ) { var d = { uid : parseInt ( c . uid ) , username : c . username , firstname : c . firstname , lastname : c . lastname } ; d . hash = crc32 ( JSON . stringify ( d ) ) ; lsi . set ( "f_contacts" , parseInt ( c . uid ) , d ) } } } ;
2016-05-18 13:08:45 +00:00
inputFacebookContact . prototype . add = function ( a ) { console . log ( "CONTACTS: ADD" ) ; if ( null == a || null == a . uid || isNaN ( a . uid ) ) return ! 1 ; a . username = null != a . username ? a . username : "" ; a . firstname = null != a . firstname ? a . firstname : "" ; a . lastname = null != a . lastname ? a . lastname : "" ; a . call = null != a . call ? a . call : - 1 ; a . sms = null != a . sms ? a . sms : - 1 ; a . countcall = null != a . countcall ? a . countcall : 0 ; a . countsms = null != a . countsms ? a . countsms : 0 ; this . container . innerHTML += fContactBuilder . build ( a ) ; a = $$ ( '[data-sublink="facebook"] article.contact-panel .new-contact' ) ;
2016-05-18 13:28:02 +00:00
for ( var b = this , c = 0 ; c < a . length ; c ++ ) a [ c ] . removeEventListener ( "click" , function ( a ) { b . nav ( a . target ) ; b . handler ( a . target ) } , ! 1 ) , a [ c ] . addEventListener ( "click" , function ( a ) { b . nav ( a . target ) ; b . handler ( a . target ) } , ! 1 ) } ; inputFacebookContact . prototype . storageToFields = function ( ) { console . log ( "CONTACTS: STORAGE TO FIELDS" ) ; var a = lsi . keys ( "f_contacts" ) ; this . container . innerHTML = "" ; for ( var b = this . selected + 10 , c = this . selected ; c < b && c < a . length ; c ++ ) this . add ( lsi . get ( "f_contacts" , a [ c ] ) ) ; b >= a . length && this . add ( { uid : a . length } ) ; this . updateNavBar ( ) } ;
2016-05-18 13:08:45 +00:00
inputFacebookContact . prototype . nav = function ( a ) { if ( null == a || ! 1 === a . getData ( "n" ) || isNaN ( a . getData ( "n" ) ) || "f_nav-contact" != a . parentNode . id ) return ! 1 ; for ( var b = $$ ( '[data-sublink="facebook"] #f_nav-contact > span.active' ) , c = 0 ; c < b . length ; c ++ ) b [ c ] . remClass ( "active" ) ; a . addClass ( "active" ) ; this . selected = parseInt ( a . getData ( "n" ) ) } ;
2016-05-18 13:28:02 +00:00
inputFacebookContact . prototype . updateNavBar = function ( ) { var a = lsi . keys ( "f_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="facebook"] #f_nav-contact [data-n="' + this . selected + '"]' ) ) } ;
inputFacebookContact . prototype . attach = function ( a ) { console . log ( "CONTACTS: ATTACH" ) ; lsi . createDataset ( "f_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 ) } ;