2016-10-02 16:01:35 +00:00
var inputPhoneMatrice = function ( a ) { this . container = a } ; inputPhoneMatrice . prototype = { container : this . container } ;
2016-10-09 15:44:06 +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 ) ) ; var c = { } , b ; for ( b in a ) if ( a [ b ] instanceof Array ) for ( var e in a [ b ] ) null == c [ b ] && ( c [ b ] = [ ] ) , c [ b ] . push ( parseInt ( a [ b ] [ e ] ) ) ; else null !== a [ b ] && ( null == c [ b ] && ( c [ b ] = [ ] ) , c [ b ] . push ( parseInt ( a [ b ] ) ) ) ; lsi . set ( "p_matrice" , 0 , c ) } ;
inputPhoneMatrice . prototype . storageToFields = function ( ) { console . log ( "MATRICE: STORAGE TO FIELDS" ) ; var a = lsi [ "export" ] ( "p_fiches" ) , c = lsi . get ( "p_matrice" , 0 ) , b = lsi [ "export" ] ( "p_contacts" ) , e = [ ] , d ; for ( d in a ) - 1 == e . indexOf ( a [ d ] . contact ) && e . push ( a [ d ] . contact ) ; a = "<table class='line'>" ; for ( d = 0 ; d < e . length ; d ++ ) { var g = b [ d ] , a = a + "<tr>" ; 0 < d ? ( a += '<td style="text-align: right;">' , a += g . username , a += "</td>" ) : a += "<td></td>" ; for ( var f = 0 ; f < e . length ; f ++ ) if ( f < e . length - 1 ) { var h = b [ f ] ; 0 == d ? ( a += "<td>" , a += '<span style="writing-mode: vertical-lr; text-align: right;">' ,
a += h . username , a += "</span>" ) : f < d ? ( a += "<td>" , a += "<input type='checkbox' name='matrice_" + g . uid + "_" + h . uid + "' data-name='" + g . uid + "' value='" + h . uid + "' id='p_matrice_" + g . uid + "_" + h . uid + "'" , null != c [ d ] && - 1 < c [ d ] . indexOf ( f ) && ( a += " checked" ) , a += " >" , a += "<label for='p_matrice_" + g . uid + "_" + h . uid + "'></label>" ) : a += "<td class='hidden'>" ; a += "</td>" } a += "</tr>" } this . container . innerHTML = a + "</table>" } ;
inputPhoneMatrice . prototype . attach = function ( ) { console . log ( "MATRICE: ATTACH" ) ; lsi . createDataset ( "p_matrice" ) ; this . storageToFields ( ) ; var a = this ; this . container . addEventListener ( "click" , function ( c ) { a . fieldsToStorage ( ) ; setTimeout ( function ( ) { a . storageToFields ( ) } , 500 ) } , ! 1 ) } ;
inputPhoneMatrice . prototype . parseGrid = function ( ) { var a = $$ ( ".matrice-panel input[data-name][value]" ) , c ; for ( c in a ) if ( a [ c ] instanceof Element ) { var b = a [ c ] . getData ( "name" ) , e = a [ c ] . value ; this . sGrid [ b ] instanceof Array || ( this . sGrid [ b ] = [ ] ) ; this . sGrid [ b ] [ e ] = a [ c ] } } ;