2016-05-08 13:25:20 +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 : [ defTrue , defFalse ] , age : "." , studies : "." , loc : [ defTrue , defFalse , defFalse , defFalse ] , reltype : [ defTrue , defFalse , defFalse , defFalse , defFalse , defFalse , defFalse , defFalse , defFalse ] , reltypeSpecial : "" , timestamp : 0 , valid : ! 1 } } ;
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 . value ) ; if ( ! 1 !== d ) { if ( null != d . hash && d . hash == e ) break ; console . warn ( "> MINI UPDATE" ) ; c = { uid : parseInt ( c . uid . value ) , firstname : d . firstname , lastname : d . lastname , username : d . username , sexe : c . sexe , age : c . age . value ,
studies : c . studies . value , reltype : c . reltype , reltypeSpecial : c . reltypeSpecial . value , loc : c . loc , hash : e } ; c . valid = this . check ( c ) ; 0 < diff ( d , c ) . length && ( 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-06 12:44:05 +00:00
this . container . innerHTML += miniFicheBuilder . build ( { firstname : b . firstname , lastname : b . lastname , username : 0 == b . username . length ? "" : "(" + b . username + ")" , 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="' +
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 < a . sexe . length ; b ++ ) a . sexe [ b ] . status ? 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 < a . reltype . length ; b ++ ) a . reltype [ b ] . status ? 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="loc"]' ) ; for ( b = 0 ; b < c . length && b < a . loc . length ; b ++ ) a . loc [ b ] . status ? 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 ) ; this . container . innerHTML = "" ; this . add ( a ) ; this . updateNavBar ( ) } ;
2016-05-04 17:37:46 +00:00
inputPhoneMini . prototype . sync = function ( ) { console . log ( "MINI FICHE: SYNC" ) ; var a = lsi [ "export" ] ( "contacts" ) , b ; for ( b in a ) { var c = lsi . get ( "mini-fiches" , b ) ; null == c && ( c = this . defaultData , c . valid = ! 1 ) ; c . uid = a [ b ] . uid ; lsi . set ( "mini-fiches" , b , c ) } } ; 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-08 13:25:20 +00:00
inputPhoneMini . prototype . updateNavBar = function ( ) { var a = lsi [ "export" ] ( "mini-fiches" ) , b = Object . keys ( a ) . length ; if ( $$ ( "#nav-mini [data-n]" ) . length != b ) { this . nav _container . innerHTML = "" ; for ( var c = 0 ; c < b ; c ++ ) this . nav _container . innerHTML += '<span data-n="' + c + '">' + ( c + 1 ) + "</span>" } for ( var e in a ) b = $ ( '#nav-mini [data-n="' + a [ e ] . uid + '"]' ) , null != b && ( ! 0 === a [ e ] . valid ? b . addClass ( "done" ) : b . remClass ( "done" ) ) ; this . nav ( $ ( '#nav-mini [data-n="' + this . selected + '"]' ) ) } ;
2016-05-06 12:48:19 +00:00
inputPhoneMini . prototype . check = function ( a ) { return ! checkRadioValue ( a . sexe ) || "." == a . studies || "." == a . age || ! checkRadioValue ( a . loc ) || ! checkRadioValue ( a . reltype ) || a . reltype [ 8 ] . status && 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 ) } ;