2016-07-13 14:58:39 +00:00
var section = { view : { text : '#CONTAINER > section[data-sublink="view"] ' , element : document . querySelector ( '#CONTAINER > section[data-sublink="view"]' ) , searchbar : document . querySelector ( '#CONTAINER > section[data-sublink="view"] > .searchbar' ) } , create : { text : '#CONTAINER > section[data-sublink="create"] ' , element : document . querySelector ( '#CONTAINER > section[data-sublink="create"]' ) } , remove : { text : '#CONTAINER > section[data-sublink="remove"] ' , element : document . querySelector ( '#CONTAINER > section[data-sublink="remove"]' ) } ,
2016-07-14 08:52:04 +00:00
edit : { text : '#CONTAINER > section[data-sublink="edit"] ' , element : document . querySelector ( '#CONTAINER > section[data-sublink="edit"]' ) } , filter : { text : '#CONTAINER > section[data-sublink="filter"] ' , element : document . querySelector ( '#CONTAINER > section[data-sublink="filter"]' ) } } ;
if ( null != section . view . element ) { 1 < pageManager . vars . length && ! isNaN ( pageManager . vars [ 1 ] ) && ( document . location = "#" + pageManager . vars [ 1 ] , document . getElementById ( pageManager . vars [ 1 ] ) . addClass ( "selected" ) ) ; section . view . link = { edit : document . querySelectorAll ( section . view . text + ".link_edit[data-cluster]" ) , remove : document . querySelectorAll ( section . view . text + ".link_remove[data-cluster]" ) } ; section . view . group = { rem : document . querySelectorAll ( section . view . text + ".rem-group[data-cluster][data-member]" ) , add : document . querySelectorAll ( section . view . text +
2016-07-15 12:48:18 +00:00
".add-group[data-cluster]" ) } ; section . view . searchbar . addEventListener ( "keyup" , function ( a ) { api . send ( { path : "clusterDefault/search" , keywords : section . view . searchbar . value } , function ( b ) { if ( 0 == b . ModuleError ) { for ( var a = [ ] , c = 0 ; c < b . clusters . length ; c ++ ) a . push ( b . clusters [ c ] . id _cluster ) ; b = document . querySelectorAll ( section . view . text + "> article.inline-box[id]" ) ; for ( c = 0 ; c < b . length ; c ++ ) - 1 < a . indexOf ( b [ c ] . id ) ? b [ c ] . remClass ( "hidden" ) : b [ c ] . addClass ( "hidden" ) } } ) } , ! 1 ) ; for ( var i = 0 ; i < section . view . link . edit . length ; i ++ ) section . view . link . edit [ i ] . addEventListener ( "click" ,
2016-07-13 15:15:26 +00:00
function ( a ) { pageManager . vars [ 1 ] = a . target . getData ( "cluster" ) ; autofill _edit ( pageManager . vars [ 1 ] ) ; navSubMenu ( "edit" ) } , ! 1 ) ; for ( i = 0 ; i < section . view . link . remove . length ; i ++ ) section . view . link . remove [ i ] . addEventListener ( "click" , function ( a ) { pageManager . vars [ 1 ] = a . target . getData ( "cluster" ) ; autofill _remove ( pageManager . vars [ 1 ] ) ; navSubMenu ( "remove" ) } , ! 1 ) ; for ( i = 0 ; i < section . view . group . rem . length ; i ++ ) section . view . group . rem [ i ] . addEventListener ( "click" , function ( a ) { var b = { path : "clusterDefault/unlink" , id _user : a . target . getData ( "user" ) ,
2016-07-14 08:52:04 +00:00
id _cluster : a . target . getData ( "group" ) } ; api . send ( b , function ( b ) { if ( 0 != b . ModuleError ) return ! 1 ; a . target . parentNode . parentNode . removeChild ( a . target . parentNode ) } ) } , ! 1 ) ; for ( i = 0 ; i < section . view . group . add . length ; i ++ ) section . view . group . add [ i ] . addEventListener ( "click" , function ( a ) { pageManager . vars [ 1 ] = a . target . getData ( "cluster" ) ; navSubMenu ( "filter" ) ; document . location = "" } , ! 1 ) }
2016-07-15 12:48:18 +00:00
null != section . create . element && ( section . create . input = { name : document . querySelector ( section . create . text + "#create_name" ) , "class" : document . querySelector ( section . create . text + "#create_class" ) , submit : document . querySelector ( section . create . text + "#create_submit" ) } , section . create . input . submit . addEventListener ( "click" , function ( a ) { a . preventDefault ( ) ; api . send ( { path : "clusterDefault/create" , name : section . create . input . name . value , "class" : section . create . input [ "class" ] . value } , function ( b ) { 0 == b . ModuleError && ( console . log ( "Groupe cree!" ) ,
pageManager . vars [ 1 ] = b . id _cluster , navSubMenu ( "view" ) , document . location = "" , section . create . input . submit . anim ( "active" , 1500 ) ) } ) } , ! 1 ) ) ;
2016-07-13 15:15:26 +00:00
if ( null != section . remove . element ) { var autofill _remove = function ( ) { var a = "" , b = "" , d = ! 0 ; null == found _remove [ searchindex _remove ] ? searchindex _remove = section . remove . input . search . num . innerHTML = 0 : ( a = found _remove [ searchindex _remove ] . id _cluster , b = found _remove [ searchindex _remove ] . name , d = ! 1 , section . remove . input . search . num . innerHTML = searchindex _remove + 1 ) ; section . remove . input . search . id . value = a ; section . remove . input . name . value = b ; section . remove . input . submit . disabled = d } ; section . remove . input = { search : { view : document . querySelector ( section . remove . text +
2016-07-13 14:58:39 +00:00
".remove_search_view" ) , num : document . querySelector ( section . remove . text + ".remove_search_num" ) , sum : document . querySelector ( section . remove . text + ".remove_search_sum" ) , keyword : document . querySelector ( section . remove . text + "#remove_search_keyword" ) , id : document . querySelector ( section . remove . text + "#remove_search_id" ) , submit : document . querySelector ( section . remove . text + "#remove_search_submit" ) } , name : document . querySelector ( section . remove . text + "#remove_name" ) , submit : document . querySelector ( section . remove . text + "#remove_submit" ) } ;
2016-07-13 15:15:26 +00:00
var lastkeywords _remove = "" , found _remove = [ ] , searchindex _remove = 0 ; 2 <= pageManager . vars . length && ! isNaN ( pageManager . vars [ 1 ] ) && api . send ( { path : "clusterDefault/getById" , id _cluster : pageManager . vars [ 1 ] } , function ( a ) { 0 == a . ModuleError && ( found _remove = [ a . cluster ] , searchindex _remove = 0 , autofill _remove ( ) ) } ) ; section . remove . input . search . submit . addEventListener ( "click" , function ( a ) { a . preventDefault ( ) ; if ( "" != section . remove . input . search . keyword . value ) if ( section . remove . input . search . keyword . value == lastkeywords _remove ) searchindex _remove =
( searchindex _remove + 1 ) % found _remove . length , autofill _remove ( ) ; else { var b = { path : "clusterDefault/search" , keywords : section . remove . input . search . keyword . value } ; api . send ( b , function ( a ) { 0 == a . ModuleError && ( section . remove . input . search . submit . anim ( "active" , 1E3 ) , searchindex _remove = 0 , found _remove = a . clusters , section . remove . input . search . sum . innerHTML = found _remove . length , autofill _remove ( ) ) ; lastkeywords _remove = b . keywords } ) } } , ! 1 ) ; section . remove . input . submit . addEventListener ( "click" , function ( a ) { a . preventDefault ( ) ; "" !=
2016-07-15 12:48:18 +00:00
section . remove . input . search . id . value && api . send ( { path : "clusterDefault/delete" , id _cluster : section . remove . input . search . id . value } , function ( b ) { 0 == b . ModuleError && 1 == b . status ? ( console . log ( "Groupe supprimee!" ) , section . remove . input . submit . anim ( "active" , 1500 ) , autofill _remove ( null ) ) : console . error ( "ModuleError::" + b . ModuleError ) } ) } , ! 1 ) }
2016-07-13 15:15:26 +00:00
if ( null != section . edit . element ) { var autofill _edit = function ( ) { var a = "" , b = "" , d = ! 0 ; null == found _edit [ searchindex _edit ] ? searchindex _edit = section . edit . input . search . num . innerHTML = 0 : ( a = found _edit [ searchindex _edit ] . id _cluster , b = found _edit [ searchindex _edit ] . name , d = ! 1 , section . edit . input . search . num . innerHTML = searchindex _edit + 1 ) ; section . edit . input . search . id . value = a ; section . edit . input . name . value = b ; section . edit . input . submit . disabled = d } ; section . edit . input = { search : { view : document . querySelector ( section . edit . text + ".edit_search_view" ) ,
num : document . querySelector ( section . edit . text + ".edit_search_num" ) , sum : document . querySelector ( section . edit . text + ".edit_search_sum" ) , keyword : document . querySelector ( section . edit . text + "#edit_search_keyword" ) , id : document . querySelector ( section . edit . text + "#edit_search_id" ) , submit : document . querySelector ( section . edit . text + "#edit_search_submit" ) } , name : document . querySelector ( section . edit . text + "#edit_name" ) , submit : document . querySelector ( section . edit . text + "#edit_submit" ) } ; var lastkeywords _edit = "" , found _edit = [ ] ,
searchindex _edit = 0 ; 2 <= pageManager . vars . length && ! isNaN ( pageManager . vars [ 1 ] ) && api . send ( { path : "clusterDefault/getById" , id _cluster : pageManager . vars [ 1 ] } , function ( a ) { 0 == a . ModuleError && ( found _edit = [ a . cluster ] , searchindex _edit = 0 , autofill _edit ( ) ) } ) ; section . edit . input . search . submit . addEventListener ( "click" , function ( a ) { a . preventDefault ( ) ; if ( "" != section . edit . input . search . keyword . value ) if ( section . edit . input . search . keyword . value == lastkeywords _edit ) searchindex _edit = ( searchindex _edit + 1 ) % found _edit . length , autofill _edit ( ) ;
else { var b = { path : "clusterDefault/search" , keywords : section . edit . input . search . keyword . value } ; api . send ( b , function ( a ) { 0 == a . ModuleError && ( section . edit . input . search . submit . anim ( "active" , 1E3 ) , searchindex _edit = 0 , found _edit = a . clusters , section . edit . input . search . sum . innerHTML = found _edit . length , autofill _edit ( ) ) ; lastkeywords _edit = b . keywords } ) } } , ! 1 ) ; section . edit . input . submit . addEventListener ( "click" , function ( a ) { a . preventDefault ( ) ; "" != section . edit . input . search . id . value && api . send ( { path : "clusterDefault/edit" , id _cluster : section . edit . input . search . id . value ,
2016-07-14 08:52:04 +00:00
name : section . edit . input . name . value } , function ( a ) { 0 == a . ModuleError && 1 == a . status ? ( console . log ( "Groupe modifiee!" ) , section . edit . input . submit . anim ( "active" , 1500 ) , autofill _edit ( section . edit . input . search . id . value ) ) : console . error ( "ModuleError::" + a . ModuleError ) } ) } , ! 1 ) }
2016-07-15 12:48:18 +00:00
null != section . filter . element && ( section . filter . deflater = new FormDeflater ( section . filter . element , [ "input" ] , [ "data-name" ] ) , section . filter . baseData = section . filter . deflater . deflate ( ) . members , section . filter [ "class" ] = document . querySelector ( "#filter-member-class" ) . value , section . filter . idcluster = document . querySelector ( "#filter-member-idcluster" ) . value , section . filter . element . addEventListener ( "click" , function ( a ) { var b = [ ] ; a = [ ] ; var d = section . filter . deflater . deflate ( ) . members ; d instanceof Array || ( d = [ d ] ) ; for ( var c =
0 ; c < d . length ; c ++ ) - 1 == section . filter . baseData . indexOf ( d [ c ] ) && b . push ( d [ c ] ) ; for ( c = 0 ; c < section . filter . baseData . length ; c ++ ) - 1 == d . indexOf ( section . filter . baseData [ c ] ) && a . push ( section . filter . baseData [ c ] ) ; for ( c = 0 ; c < b . length ; c ++ ) { var e = { } ; e . path = 0 == section . filter [ "class" ] ? "userDefault/link" : "machineDefault/link" ; e . id _cluster = section . filter . idcluster ; 0 == section . filter [ "class" ] ? e . id _user = b [ c ] : e . id _machine = b [ c ] ; api . send ( e , function ( a ) { 0 != a . ModuleError && console . error ( "Erreur d'ajout de membre" ) } ) } for ( c = 0 ; c < a . length ; c ++ ) b =
{ } , b . path = 0 == section . filter [ "class" ] ? "userDefault/unlink" : "machineDefault/unlink" , b . id _cluster = section . filter . idcluster , 0 == section . filter [ "class" ] ? b . id _user = a [ c ] : b . id _machine = a [ c ] , api . send ( b , function ( a ) { 0 != a . ModuleError && console . error ( "Erreur d'ajout de membre" ) } ) ; section . filter . baseData = d } , ! 1 ) ) ;