@@ -331,8 +331,6 @@ function updateAgentsMenu(nav, agents, addCloseButton) {
331331 navElement . appendChild ( lag ) ;
332332 } ) ;
333333 navElement . appendChild ( createDefaultHR ( ) ) ;
334- var br = document . createElement ( "br" ) ;
335- navElement . appendChild ( br ) ;
336334 var ldf = document . createElement ( 'a' ) ;
337335 ldf . setAttribute ( "href" , "./agents_df.html" ) ;
338336 ldf . innerHTML = "directory facilitator" ;
@@ -801,53 +799,54 @@ function updateWorkspaceMenu(nav, ws, ar, addCloseButton) {
801799 const selectedWorkspace = params . get ( 'workspace' ) ;
802800 const selectedArtifact = params . get ( 'artifact' ) ;
803801
802+ let promisses = [ ] ;
804803 ws . sort ( ) . forEach ( function ( n ) {
805- get ( "./workspaces/" + n ) . then ( function ( r ) {
806- let ar = JSON . parse ( r ) ;
807- let validContent = 0 ;
808- Object . keys ( ar . artifacts ) . sort ( ) . forEach ( function ( a ) {
809- if ( HIDDEN_ARTS . indexOf ( ar . artifacts [ a ] . type ) < 0 ) {
810- validContent ++ ;
811- /* if printing the first artifact, also print the workspace */
812- if ( selectedWorkspace === n ) {
813- if ( validContent === 1 ) {
814- var lag = document . createElement ( 'a' ) ;
815- lag . setAttribute ( "href" , "./workspace.html?workspace=" + n ) ;
816- lag . innerHTML = "<h5><b>" + n + "</b></h5>" ;
817- document . getElementById ( nav ) . appendChild ( lag ) ;
818- }
819- /* Add artifacts on menu */
820- var lar = document . createElement ( 'a' ) ;
821- if ( selectedArtifact === a ) {
822- lar . innerHTML = "<h5><b>   " + a + "</b></h5>" ;
804+ promisses . push ( get ( "./workspaces/" + n ) ) ;
805+ } ) ;
806+ Promise . all ( promisses ) . then ( function ( r ) {
807+ console . log ( r ) ;
808+ r . forEach ( function ( e ) {
809+ let ar = JSON . parse ( e ) ;
810+ let validContent = 0 ;
811+ Object . keys ( ar . artifacts ) . sort ( ) . forEach ( function ( a ) {
812+ if ( HIDDEN_ARTS . indexOf ( ar . artifacts [ a ] . type ) < 0 ) {
813+ validContent ++ ;
814+ /* if printing the first artifact, also print the workspace */
815+ if ( selectedWorkspace === ar . workspace ) {
816+ if ( validContent === 1 ) {
817+ var lag = document . createElement ( 'a' ) ;
818+ lag . setAttribute ( "href" , "./workspace.html?workspace=" + ar . workspace ) ;
819+ lag . innerHTML = "<h5><b>" + ar . workspace + "</b></h5>" ;
820+ document . getElementById ( nav ) . appendChild ( lag ) ;
821+ }
822+ /* Add artifacts on menu */
823+ var lar = document . createElement ( 'a' ) ;
824+ if ( selectedArtifact === a ) {
825+ lar . innerHTML = "<h5><b>   " + a + "</b></h5>" ;
826+ } else {
827+ lar . innerHTML = "<h5>   " + a + "</h5>" ;
828+ }
829+ lar . setAttribute ( "href" , "./artifact.html?workspace=" + ar . workspace + "&artifact=" + a +
830+ "&javafile=" + ar . artifacts [ a ] . type + ".java" ) ;
831+ document . getElementById ( nav ) . appendChild ( lar ) ;
823832 } else {
824- lar . innerHTML = "<h5>   " + a + "</h5>" ;
825- }
826- lar . setAttribute ( "href" , "./artifact.html?workspace=" + n + "&artifact=" + a +
827- "&javafile=" + ar . artifacts [ a ] . type + ".java" ) ;
828- document . getElementById ( nav ) . appendChild ( lar ) ;
829- } else {
830- /* if would print at least one artifact, also print the workspace */
831- if ( validContent === 1 ) {
832- var lag = document . createElement ( 'a' ) ;
833- lag . setAttribute ( "href" , "./workspace.html?workspace=" + n ) ;
834- lag . innerHTML = "<h5>" + n + "</h5>" ;
835- document . getElementById ( nav ) . appendChild ( lag ) ;
833+ /* if would print at least one artifact, also print the workspace */
834+ if ( validContent === 1 ) {
835+ var lag = document . createElement ( 'a' ) ;
836+ lag . setAttribute ( "href" , "./workspace.html?workspace=" + ar . workspace ) ;
837+ lag . innerHTML = "<h5>" + ar . workspace + "</h5>" ;
838+ document . getElementById ( nav ) . appendChild ( lag ) ;
839+ }
836840 }
837841 }
838- }
842+ } ) ;
839843 } ) ;
840- /* Bypass for promisses challenge. Did I just printed the last element content? */
841- setTimeout ( function ( f ) {
842- if ( ws [ ws . length - 1 ] === n ) {
843- document . getElementById ( nav ) . appendChild ( createDefaultHR ( ) ) ;
844- var lnew = document . createElement ( 'a' ) ;
845- lnew . setAttribute ( "href" , "./artifact_new.html" ) ;
846- lnew . innerHTML = "create template" ;
847- document . getElementById ( nav ) . appendChild ( lnew ) ;
848- }
849- } , 500 ) ;
850- } ) ;
844+ } ) . then ( function ( r ) {
845+ document . getElementById ( nav ) . appendChild ( createDefaultHR ( ) ) ;
846+ var lnew = document . createElement ( 'a' ) ;
847+ lnew . setAttribute ( "href" , "./artifact_new.html" ) ;
848+ lnew . innerHTML = "create template" ;
849+ document . getElementById ( nav ) . appendChild ( lnew ) ;
851850 } ) ;
852851}
853852
0 commit comments