2121*/
2222
2323class ProjectViewer {
24-
2524 constructor ( Planet ) {
26- this . Planet = Planet ;
25+ this . Planet = Planet ;
2726 this . ProjectCache = Planet . GlobalPlanet . cache ;
2827 this . PlaceholderMBImage = "images/mbgraphic.png" ;
2928 this . PlaceholderTBImage = "images/tbgraphic.png" ;
3029 this . ReportError = _ ( "Error: Report could not be submitted. Try again later." ) ;
31- this . ReportSuccess = _ ( "Thank you for reporting this project. A moderator will review the project shortly, to verify violation of the Sugar Labs Code of Conduct." ) ;
30+ this . ReportSuccess = _ (
31+ "Thank you for reporting this project. A moderator will review the project shortly, to verify violation of the Sugar Labs Code of Conduct."
32+ ) ;
3233 this . ReportEnabledButton = _ ( "Report Project" ) ;
3334 this . ReportDisabledButton = _ ( "Project Reported" ) ;
3435 this . ReportDescriptionError = _ ( "Report description required" ) ;
@@ -37,25 +38,45 @@ class ProjectViewer {
3738 }
3839
3940 open ( id ) {
40- const Planet = this . Planet ;
41+ const Planet = this . Planet ;
4142 this . id = id ;
4243 const proj = this . ProjectCache [ id ] ;
43- const options = { year : "numeric" , month : "short" , day : "numeric" , hour : "numeric" , minute : "numeric" } ;
44+
45+ const setBoldText = ( el , text ) => {
46+ el . textContent = "" ;
47+ const b = document . createElement ( "b" ) ;
48+ b . textContent = String ( text ) ;
49+ el . appendChild ( b ) ;
50+ } ;
51+
52+ const options = {
53+ year : "numeric" ,
54+ month : "short" ,
55+ day : "numeric" ,
56+ hour : "numeric" ,
57+ minute : "numeric"
58+ } ;
4459 const last_updated_timestamp = proj . ProjectLastUpdated ;
45- const formatted_LastUpdated = new Date ( last_updated_timestamp ) . toLocaleString ( undefined , options ) ;
60+ const formatted_LastUpdated = new Date ( last_updated_timestamp ) . toLocaleString (
61+ undefined ,
62+ options
63+ ) ;
4664 const created_timestamp = proj . ProjectCreatedDate ;
47- const formatted_CreatedDate = new Date ( created_timestamp ) . toLocaleString ( undefined , options ) ;
65+ const formatted_CreatedDate = new Date ( created_timestamp ) . toLocaleString (
66+ undefined ,
67+ options
68+ ) ;
4869
4970 document . getElementById ( "projectviewer-title" ) . textContent = proj . ProjectName ;
50- document . getElementById ( "projectviewer-last-updated" ) . innerHTML = `<b> ${ formatted_LastUpdated } </b>` ;
51- document . getElementById ( "projectviewer-date" ) . innerHTML = `<b> ${ formatted_CreatedDate } </b>` ;
52- document . getElementById ( "projectviewer-downloads" ) . innerHTML = `<b> ${ proj . ProjectDownloads } </b>` ;
53- document . getElementById ( "projectviewer-likes" ) . innerHTML = `<b> ${ proj . ProjectLikes } </b>` ;
71+ setBoldText ( document . getElementById ( "projectviewer-last-updated" ) , formatted_LastUpdated ) ;
72+ setBoldText ( document . getElementById ( "projectviewer-date" ) , formatted_CreatedDate ) ;
73+ setBoldText ( document . getElementById ( "projectviewer-downloads" ) , proj . ProjectDownloads ) ;
74+ setBoldText ( document . getElementById ( "projectviewer-likes" ) , proj . ProjectLikes ) ;
5475
5576 let img = proj . ProjectImage ;
5677 if ( img === "" || img === null )
57- img = ( proj . ProjectIsMusicBlocks == 1 ) ?
58- this . PlaceholderMBImage : this . PlaceholderTBImage ;
78+ img =
79+ proj . ProjectIsMusicBlocks == 1 ? this . PlaceholderMBImage : this . PlaceholderTBImage ;
5980
6081 document . getElementById ( "projectviewer-image" ) . src = img ;
6182 document . getElementById ( "projectviewer-description" ) . textContent = proj . ProjectDescription ;
@@ -68,29 +89,28 @@ class ProjectViewer {
6889 tagcontainer . appendChild ( chip ) ;
6990 }
7091
71- if ( Planet . ProjectStorage . isReported ( this . id ) ) {
92+ if ( Planet . ProjectStorage . isReported ( this . id ) ) {
7293 document . getElementById ( "projectviewer-report-project" ) . style . display = "none" ;
73- document . getElementById ( "projectviewer-report-project-disabled" ) . style . display = "block" ;
74- }
75- else {
94+ document . getElementById ( "projectviewer-report-project-disabled" ) . style . display =
95+ "block" ;
96+ } else {
7697 document . getElementById ( "projectviewer-report-project" ) . style . display = "block" ;
7798 document . getElementById ( "projectviewer-report-project-disabled" ) . style . display = "none" ;
7899 }
79100
80101 jQuery ( "#projectviewer" ) . modal ( "open" ) ;
81- } ;
102+ }
82103
83104 download ( ) {
84- this . Planet . GlobalPlanet . getData ( this . id , this . afterDownload . bind ( this ) ) ;
85- } ;
105+ this . Planet . GlobalPlanet . getData ( this . id , this . afterDownload . bind ( this ) ) ;
106+ }
86107
87- afterDownload ( data ) {
88- const Planet = this . Planet ;
108+ afterDownload ( data ) {
109+ const Planet = this . Planet ;
89110
90111 const proj = this . ProjectCache [ this . id ] ;
91112 let image = Planet . ProjectStorage . ImageDataURL ;
92- if ( proj . ProjectImage !== "" )
93- image = proj . ProjectImage ;
113+ if ( proj . ProjectImage !== "" ) image = proj . ProjectImage ;
94114
95115 Planet . SaveInterface . saveHTML (
96116 proj . ProjectName ,
@@ -99,19 +119,19 @@ class ProjectViewer {
99119 proj . ProjectDescription ,
100120 this . id
101121 ) ;
102- } ;
122+ }
103123
104124 openProject ( ) {
105125 // newPageTitle = proj.ProjectName;
106126 // document.title = newPageTitle;
107127 this . Planet . GlobalPlanet . openGlobalProject ( this . id ) ;
108- } ;
128+ }
109129
110130 mergeProject ( ) {
111131 // newPageTitle = proj.ProjectName;
112132 // document.title = newPageTitle;
113133 this . Planet . GlobalPlanet . mergeGlobalProject ( this . id ) ;
114- } ;
134+ }
115135
116136 openReporter ( ) {
117137 // eslint-disable-next-line no-console
@@ -121,55 +141,54 @@ class ProjectViewer {
121141 document . getElementById ( "projectviewer-report-progress" ) . style . visibility = "hidden" ;
122142 document . getElementById ( "report-error" ) . style . display = "none" ;
123143 document . getElementById ( "projectviewer-report-card" ) . style . display = "block" ;
124-
144+
125145 hideOnClickOutside (
126146 [
127147 document . getElementById ( "projectviewer-report-card" ) ,
128148 document . getElementById ( "projectviewer-report-project" )
129149 ] ,
130150 "projectviewer-report-card"
131151 ) ;
132- } ;
152+ }
133153
134154 submitReporter ( ) {
135155 const text = document . getElementById ( "reportdescription" ) . value ;
136156
137- if ( text === "" ) {
157+ if ( text === "" ) {
138158 document . getElementById ( "report-error" ) . textContent = this . ReportDescriptionError ;
139159 document . getElementById ( "report-error" ) . style . display = "block" ;
140160 return ;
141- }
142- else if ( text . length > 1000 ) {
143- document . getElementById ( "report-error" ) . textContent = this . ReportDescriptionTooLongError ;
161+ } else if ( text . length > 1000 ) {
162+ document . getElementById (
163+ "report-error"
164+ ) . textContent = this . ReportDescriptionTooLongError ;
144165 document . getElementById ( "report-error" ) . style . display = "block" ;
145166 return ;
146- }
147- else {
167+ } else {
148168 document . getElementById ( "projectviewer-report-progress" ) . style . visibility = "hidden" ;
149169 this . Planet . ServerInterface . reportProject ( this . id , text , this . afterReport . bind ( this ) ) ;
150170 }
151- } ;
171+ }
152172
153173 afterReport ( data ) {
154174 if ( data . success ) {
155175 document . getElementById ( "submittext" ) . textContent = this . ReportSuccess ;
156- this . Planet . ProjectStorage . report ( this . id , true ) ;
176+ this . Planet . ProjectStorage . report ( this . id , true ) ;
157177 document . getElementById ( "projectviewer-report-project" ) . style . display = "none" ;
158- document . getElementById ( "projectviewer-report-project-disabled" ) . style . display = "block" ;
159- }
160- else document . getElementById ( "submittext" ) . textContent = this . ReportError ;
178+ document . getElementById ( "projectviewer-report-project-disabled" ) . style . display =
179+ "block" ;
180+ } else document . getElementById ( "submittext" ) . textContent = this . ReportError ;
161181
162182 document . getElementById ( "projectviewer-report-content" ) . style . display = "none" ;
163183 document . getElementById ( "projectviewer-report-progress" ) . style . visibility = "hidden" ;
164184 document . getElementById ( "projectviewer-reportsubmit-content" ) . style . display = "block" ;
165- } ;
185+ }
166186
167187 closeReporter ( ) {
168188 document . getElementById ( "projectviewer-report-card" ) . style . display = "none" ;
169- } ;
189+ }
170190
171191 init ( ) {
172-
173192 // eslint-disable-next-line no-unused-vars
174193 document . getElementById ( "projectviewer-download-file" ) . addEventListener ( "click" , evt => {
175194 this . download ( ) ;
@@ -199,6 +218,5 @@ class ProjectViewer {
199218 document . getElementById ( "projectviewer-report-close" ) . addEventListener ( "click" , evt => {
200219 this . closeReporter ( ) ;
201220 } ) ;
202- } ;
203-
204- }
221+ }
222+ }
0 commit comments