2016-05-08 16:31:58 +00:00
function inputPhoneMatrice ( a ) { this . container = a } inputPhoneMatrice . prototype = { container : this . container } ;
2016-05-08 17:11:03 +00:00
inputPhoneMatrice . prototype . fieldsToStorage = function ( ) { console . log ( "MATRICE: FIELDS TO STORAGE" ) ; var a = ( new FormDeflater ( this . container , [ "input" ] , [ "data-name" ] ) ) . deflate ( ) ; crc32 ( JSON . stringify ( a ) ) ; console . log ( a ) ; var b = { } , c ; for ( c in a ) if ( a [ c ] instanceof Array ) for ( var d in a [ c ] ) ! 0 === a [ c ] [ d ] . status && ( null == b [ c ] && ( b [ c ] = [ ] ) , b [ c ] . push ( parseInt ( a [ c ] [ d ] . value ) ) ) ; else ! 0 === a [ c ] . status && ( null == b [ c ] && ( b [ c ] = [ ] ) , b [ c ] . push ( parseInt ( a [ c ] . value ) ) ) ; lsi . set ( "matrice" , 0 , b ) } ;
inputPhoneMatrice . prototype . add = function ( a ) { console . log ( "MATRICE: 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-08 16:31:58 +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" ,
2016-05-08 17:11:03 +00:00
"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" ) } ; inputPhoneMatrice . prototype . storageToFields = function ( ) { console . log ( "MATRICE: STORAGE TO FIELDS" ) ; var a = lsi . get ( "mini-fiches" , this . selected ) ; this . container . innerHTML = "" ; this . add ( a ) ; this . updateNavBar ( ) } ;
inputPhoneMatrice . prototype . sync = function ( ) { console . log ( "MATRICE: 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 ) } } ; inputPhoneMatrice . 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" ) ) } ;
inputPhoneMatrice . 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 d in a ) b = $ ( '#nav-mini [data-n="' + a [ d ] . uid + '"]' ) , null != b && ( ! 0 === a [ d ] . valid ? b . addClass ( "done" ) : b . remClass ( "done" ) ) ; this . nav ( $ ( '#nav-mini [data-n="' + this . selected + '"]' ) ) } ;
inputPhoneMatrice . 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 } ; inputPhoneMatrice . prototype . attach = function ( a ) { console . log ( "MATRICE: ATTACH" ) ; lsi . createDataset ( "matrice" ) ; this . storageToFields ( ) ; this . handler = a } ;