2016-05-09 18:04:23 +00:00
function inputPhoneMini ( a , b ) { this . container = a ; this . nav _container = b } inputPhoneMini . prototype = { container : this . container , nav _container : this . nav _container , selected : 0 , handler : null , defaultData : { sexe : "H" , age : "." , studies : "." , loc : "0" , reltype : "0" , reltypeSpecial : "" , timestamp : 0 , valid : ! 1 } } ;
2016-05-11 20:02:20 +00:00
inputPhoneMini . prototype . fieldsToStorage = function ( ) { console . log ( "MINI FICHE: FIELDS TO STORAGE" ) ; for ( var a = $$ ( "article.mini-relation-panel .mini-fiche-relation" ) , b = 0 ; b < a . length ; b ++ ) { var c = ( new FormDeflater ( a [ b ] , [ "input" , "select" ] , [ "data-name" ] ) ) . deflate ( ) , e = crc32 ( JSON . stringify ( c ) ) , d = lsi . get ( "mini-fiches" , c . uid ) ; if ( ! 1 !== d ) { if ( null != d . hash && d . hash == e ) break ; console . warn ( "> MINI UPDATE" ) ; c = { uid : parseInt ( c . uid ) , sexe : c . sexe , age : c . age , studies : c . studies , reltype : c . reltype , reltypeSpecial : c . reltypeSpecial ,
loc : c . loc , hash : e } ; c . valid = this . check ( c ) ; 0 < diff ( d , c , [ "hash" , "valid" , "timestamp" ] ) . length && ( console . log ( diff ( d , c , [ "hash" , "valid" , "timestamp" ] ) ) , console . warn ( "> FICHE UPDATE" ) , c . timestamp = Date . now ( ) ) ; lsi . set ( "mini-fiches" , c . uid , c ) } } } ;
2016-05-06 12:16:02 +00:00
inputPhoneMini . prototype . add = function ( a ) { console . log ( "MINI FICHE: ADD" ) ; if ( null == a || null == a . uid ) return ! 1 ; a . age = null != a . age ? a . age : this . defaultData . age ; a . sexe = null != a . sexe ? a . sexe : this . defaultData . sexe ; a . studies = null != a . studies ? a . studies : this . defaultData . studies ; a . reltype = null != a . reltype ? a . reltype : this . defaultData . reltype ; a . reltypeSpecial = null != a . reltypeSpecial ? a . reltypeSpecial : this . defaultData . reltypeSpecial ; a . loc = null != a . loc ? a . loc : this . defaultData . loc ; var b = lsi . get ( "contacts" , a . uid ) ; if ( ! 1 === b ) return ! 1 ;
2016-05-11 20:02:20 +00:00
this . container . innerHTML += miniFicheBuilder . build ( { name : readableName ( b . username , b . firstname , b . lastname ) , countcall : b . countcall , countsms : b . countsms , uid : a . uid , reltypespecial : a . reltypeSpecial } ) ; b = $ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>span>select[data-name="studies"]>option[value="' + a . studies + '"]' ) ; null != b && b . setAttribute ( "selected" , "selected" ) ; b = $ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>span>select[data-name="age"]>option[value="' +
2016-05-09 18:04:23 +00:00
a . age + '"]' ) ; null != b && b . setAttribute ( "selected" , "selected" ) ; for ( var c = $$ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>input[type="radio"][data-name="sexe"]' ) , b = 0 ; b < c . length ; b ++ ) c [ b ] . value == a . sexe ? c [ b ] . setAttribute ( "checked" , "checked" ) : c [ b ] . removeAttribute ( "checked" ) ; c = $$ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>input[type="radio"][data-name="reltype"]' ) ; for ( b = 0 ; b < c . length ; b ++ ) c [ b ] . value == a . reltype ? c [ b ] . setAttribute ( "checked" , "checked" ) :
2016-05-11 20:02:20 +00:00
c [ b ] . removeAttribute ( "checked" ) ; c = $$ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>input[type="radio"][data-name="loc"]' ) ; for ( b = 0 ; b < c . length ; b ++ ) c [ b ] . value == a . loc ? c [ b ] . setAttribute ( "checked" , "checked" ) : c [ b ] . removeAttribute ( "checked" ) } ; inputPhoneMini . prototype . storageToFields = function ( ) { console . log ( "MINI FICHE: STORAGE TO FIELDS" ) ; var a = lsi . get ( "mini-fiches" , this . selected ) ; if ( null == a ) return this . updateNavBar ( ) , ! 1 ; this . container . innerHTML = "" ; this . add ( a ) ; this . updateNavBar ( ) } ;
inputPhoneMini . prototype . sync = function ( ) { console . log ( "MINI FICHE: SYNC" ) ; var a = lsi [ "export" ] ( "contacts" ) , b = lsi [ "export" ] ( "fiches" ) , c = [ ] , e ; for ( e in b ) - 1 == c . indexOf ( b [ e ] . contact ) && c . push ( b [ e ] . contact ) ; for ( var d in a ) - 1 < c . indexOf ( parseInt ( d ) ) ? lsi . del ( "mini-fiches" , d ) : ( b = 0 == a [ d ] . username . length + a [ d ] . firstname . length + a [ d ] . lastname . length ? d . toString ( ) + "-" : d , e = lsi . get ( "mini-fiches" , b ) , null == e && ( e = this . defaultData , e . valid = ! 1 , isNaN ( b ) && ( e . reltype = "9" ) ) , e . uid = parseInt ( d ) , lsi . set ( "mini-fiches" , b , e ) ) } ;
2016-05-11 17:34:52 +00:00
inputPhoneMini . prototype . nav = function ( a ) { if ( null == a || ! 1 === a . getData ( "n" ) || isNaN ( a . getData ( "n" ) ) || "nav-mini" != a . parentNode . id ) return ! 1 ; for ( var b = $$ ( "#nav-mini > span.active" ) , c = 0 ; c < b . length ; c ++ ) b [ c ] . remClass ( "active" ) ; a . addClass ( "active" ) ; this . selected = parseInt ( a . getData ( "n" ) ) } ;
2016-05-11 20:02:20 +00:00
inputPhoneMini . prototype . updateNavBar = function ( ) { var a = lsi [ "export" ] ( "mini-fiches" ) ; this . nav _container . innerHTML = "" ; var b = 0 , c ; for ( c in a ) isNaN ( c ) || ( this . nav _container . innerHTML += '<span data-n="' + c + '">' + ++ b + "</span>" ) ; for ( c in a ) isNaN ( c ) || ( b = $ ( '#nav-mini [data-n="' + a [ c ] . uid + '"]' ) , null != b && ( ! 0 === a [ c ] . valid ? b . addClass ( "done" ) : b . remClass ( "done" ) ) ) ; this . nav ( $ ( '#nav-mini [data-n="' + this . selected + '"]' ) ) } ;
2016-05-10 14:51:09 +00:00
inputPhoneMini . prototype . check = function ( a ) { return "" == a . sexe || "." == a . studies || "." == a . age || "" == a . loc || "" == a . reltype || "8" == a . reltype && 2 > a . reltypeSpecial . length ? ! 1 : ! 0 } ; inputPhoneMini . prototype . attach = function ( a ) { console . log ( "MINI FICHE: ATTACH" ) ; lsi . createDataset ( "mini-fiches" ) ; this . storageToFields ( ) ; this . handler = a ; var b = this ; this . nav _container . addEventListener ( "click" , function ( a ) { b . nav ( a . target ) ; b . handler ( a . target ) } , ! 1 ) } ;