2020 <h2 ><fmt:message key =" public-profile.title" />: <span class =" user" ><%= request. getAttribute(" screenname" ) % > </span ></h2 >
2121 <div >
2222 <ul class =" nav nav-pills" role =" tablist" >
23- <li role =" presentation" class =" active" ><a data-toggle =" tab" href =" #profile " ><fmt:message key =" public-profile.nav.profile " /></a ></li >
24- <li role =" presentation" ><a data-toggle =" tab" href =" #projects " ><fmt:message key =" public-profile.nav.projects " /></a ></li >
25- </ul >
23+ <li role =" presentation" id = " select-projects " class =" active" ><a data-toggle =" tab" href =" #projects " ><fmt:message key =" public-profile.nav.projects " /></a ></li >
24+ <li role =" presentation" id = " select-profile " ><a data-toggle =" tab" href =" #profile " ><fmt:message key =" public-profile.nav.profile " /></a ></li >
25+ </ul >
2626 <div class =" tab-content" >
27- <div role =" tabpanel" class =" tab-pane active " id =" profile" >
27+ <div role =" tabpanel" class =" tab-pane" id =" profile" >
2828 <h3 ><fmt:message key =" public-profile.friends" /></h3 >
2929 </div >
30- <div role =" tabpanel" class =" tab-pane" id =" projects" >
30+ <div role =" tabpanel" class =" tab-pane active " id =" projects" >
3131 <h3 ><fmt:message key =" public-profile.projects" /></h3 >
32+ <hr >
33+ <ul class =" latest-projects" ></ul >
34+ <hr >
35+ <span id =" project-list-pages" >Projects: </span >
36+
37+ <script >
38+ var getUrlParameter = function getUrlParameter (sParam ) {
39+ var sPageURL = decodeURIComponent (window .location .search .substring (1 )),
40+ sURLVariables = sPageURL .split (' &' ),
41+ sParameterName,
42+ i;
43+
44+ for (i = 0 ; i < sURLVariables .length ; i++ ) {
45+ sParameterName = sURLVariables[i].split (' =' );
46+
47+ if (sParameterName[0 ] === sParam) {
48+ return sParameterName[1 ] === undefined ? true : sParameterName[1 ];
49+ }
50+ }
51+ };
52+
53+
54+ var getUrl = window .location ;
55+ var baseUrl = getUrl .protocol + " //" + getUrl .host + " /" + getUrl .pathname .split (' /' )[1 ];
56+ var pageUrl = getUrl .protocol + " /" + getUrl .host + " /" + getUrl .pathname .split (' ?' )[0 ];
57+
58+ var projectTypes = {
59+ " PROPC" : {
60+ " editor" : " blocklyc.jsp" ,
61+ " class" : " editor-c-link"
62+ },
63+ " SPIN" : {
64+ " editor" : " blocklyspin.jsp" ,
65+ " class" : " editor-spin-link"
66+ }
67+ };
68+
69+ var page = 0 ;
70+ if (getUrlParameter (' page' ) === undefined ) page = 0 ;
71+ else {
72+ $ (' #profile' ).removeClass (' active' );
73+ $ (' #projects' ).addClass (' active' );
74+ $ (' #select-projects' ).tab (' show' );
75+ page = parseInt (getUrlParameter (' page' )) * 10 ;
76+ }
77+
78+ $ .get (baseUrl + " /rest/shared/project/list/user/" + getUrlParameter (' id-user' ) + " ?sort=modified&order=desc&limit=10&offset=" + page .toString (10 ), function (data ) {
79+ $ .each (data[' rows' ], function (index , project ) {
80+ var projectItem = $ (" <li/>" , {
81+ " class" : " project"
82+ });
83+ $ (" <a/>" , {
84+ " class" : " editor-view-link editor-icon " + projectTypes[project[' type' ]][' class' ],
85+ " href" : baseUrl + " /projects.jsp#" + project[' id' ],
86+ " text" : project[' name' ]
87+ }).appendTo (projectItem);
88+ $ (" .latest-projects" ).append (projectItem);
89+ });
90+ var projPages = parseInt (data[' total' ]);
91+ for (var idx = 1 ; idx <= projPages; idx += 10 ) {
92+ var startNum = idx .toString (10 );
93+ var endNum = (idx + 9 ).toString (10 );
94+ if (endNum > projPages) endNum = projPages;
95+
96+ var linkPage = parseInt (idx/ 10 ).toString (10 );
97+ var btnLink = ' ' ;
98+ btnLink += ' <a href="?id-user=' + getUrlParameter (' id-user' );
99+ btnLink += ' &page=' + linkPage + ' " class="btn btn-secondary btn-sm" ' ;
100+ btnLink += ' role="button" id="projPage-' + linkPage + ' ">' ;
101+
102+ $ (" #project-list-pages" ).append (btnLink + startNum + " -" + endNum + " </a>" );
103+
104+ if (linkPage === getUrlParameter (' page' )) {
105+ $ (' #projPage-' + linkPage).removeClass (' btn-secondary' ).addClass (' btn-primary' );
106+ } else if ( getUrlParameter (' page' ) === undefined && linkPage === ' 0' ) {
107+ $ (' #projPage-' + linkPage).removeClass (' btn-secondary' ).addClass (' btn-primary' );
108+ }// Use to add active to button class
109+ }
110+ });
111+
112+ </script >
113+
32114 </div >
33115 </div >
34116 </div >
37119 </div >
38120 </div >
39121
122+
40123 <%@ include file =" /WEB-INF/includes/pageparts/footer.jsp" %>
41124
125+
42126 </body >
43127</html >
0 commit comments