1+ require ( "../cookiewarning" ) ;
2+ require ( "./stylesheet.js" ) ;
3+ require ( "./navigate-loader.js" ) ;
4+
5+ document . title = "Random Rants + | Credits" ;
6+
7+ var menuBar = require ( "../menu.js" ) ;
8+ var elements = require ( "../gp2/elements.js" ) ;
9+
10+ // Refined helper function
11+ function generateLicenseElement ( license ) {
12+ // 1. Prepare children array safely
13+ var licenseChildren = [
14+ {
15+ element : "strong" ,
16+ textContent : `${ license . name || "Unknown Package" } (v${ license . version || "?" } )`
17+ } ,
18+ { element : "br" }
19+ ] ;
20+
21+ // 2. Only add Author if it exists
22+ if ( license . author ) {
23+ licenseChildren . push ( {
24+ element : "span" ,
25+ textContent : `By ${ license . author } `
26+ } ) ;
27+ licenseChildren . push ( { element : "br" } ) ;
28+ }
29+
30+ // 3. Only add Source if it exists
31+ if ( license . source ) {
32+ var sourceChild ;
33+ // Check if it's a URL or just text
34+ if ( license . source . startsWith ( "http" ) ) {
35+ sourceChild = {
36+ element : "a" ,
37+ href : license . source ,
38+ target : "_blank" ,
39+ textContent : "Source Code Repository" ,
40+ style : { color : "#4dabf7" , textDecoration : "underline" } // Make link distinct
41+ } ;
42+ } else {
43+ sourceChild = {
44+ element : "span" ,
45+ textContent : "Source: " + license . source
46+ } ;
47+ }
48+ licenseChildren . push ( sourceChild ) ;
49+ licenseChildren . push ( { element : "br" } ) ;
50+ }
51+
52+ // 4. Add License Type and Text
53+ licenseChildren . push (
54+ {
55+ element : "span" ,
56+ textContent : `License: ${ license . license || "Unknown" } `
57+ } ,
58+ {
59+ element : "div" , // Use div for text block to separate it
60+ textContent : license . licenseText || "No license text provided." ,
61+ style : {
62+ marginTop : "5px" ,
63+ fontSize : "0.8em" ,
64+ opacity : "0.8" ,
65+ borderLeft : "2px solid #555" ,
66+ paddingLeft : "10px"
67+ }
68+ } ,
69+ { element : "hr" , style : { opacity : "0.2" , margin : "10px 0" } } // Separator line
70+ ) ;
71+
72+ return {
73+ element : "div" ,
74+ style : { marginBottom : "15px" } ,
75+ children : licenseChildren
76+ } ;
77+ }
78+
79+ var contentArray = [
80+ // Title and intro
81+ require ( "./sitenews-notice.js" ) ,
82+ {
83+ element : "h1" ,
84+ textContent : "Random Rants + Credits" ,
85+ style : { fontSize : "2.2em" , marginBottom : "0.5em" } ,
86+ children : [ ] ,
87+ } ,
88+ {
89+ element : "span" ,
90+ textContent : "Dig into the stuff that was used to make Random Rants +." ,
91+ children : [ ] ,
92+ } ,
93+ {
94+ element : "p" ,
95+ textContent : "Random Rants + wouldn't be possible without these open-source projects:" ,
96+ style : { marginBottom : "10px" } ,
97+ children : [ ] ,
98+ } ,
99+
100+ // Tech Stack List
101+ {
102+ element : "div" ,
103+ style : {
104+ backgroundColor : "rgba(0, 0, 0, 0.3)" , // Semi-transparent is safer for themes
105+ border : "1px solid rgba(255, 255, 255, 0.1)" ,
106+ color : "#ffffff" ,
107+ padding : "15px" ,
108+ borderRadius : "8px" ,
109+ fontSize : "0.9em" ,
110+ fontFamily : "monospace" ,
111+ marginBottom : "30px"
112+ } ,
113+ children : [
114+ {
115+ element : "ul" ,
116+ style : { margin : "0" , paddingLeft : "20px" } ,
117+ children : [
118+ {
119+ element : "li" ,
120+ children : [
121+ { element : "strong" , textContent : "Node.js & HTTP Module: " } ,
122+ { element : "span" , textContent : "Backend server logic." }
123+ ]
124+ } ,
125+ {
126+ element : "li" ,
127+ children : [
128+ { element : "strong" , textContent : "Webpack: " } ,
129+ { element : "span" , textContent : "Bundling our chaotic code for the UI." }
130+ ]
131+ } ,
132+ {
133+ element : "li" ,
134+ children : [
135+ { element : "strong" , textContent : "Socket.io / Websockets: " } ,
136+ { element : "span" , textContent : "Real-time communication (Chat)." }
137+ ]
138+ } ,
139+ {
140+ element : "li" ,
141+ children : [
142+ { element : "strong" , textContent : "Simple-Peer / WebRTC: " } ,
143+ { element : "span" , textContent : "P2P Video and Screen Sharing." }
144+ ]
145+ } ,
146+ {
147+ element : "li" ,
148+ children : [
149+ { element : "strong" , textContent : "GvbvdxxMod2: " } ,
150+ { element : "span" , textContent : "My modified version of TurboWarp for the mini-games." }
151+ ]
152+ }
153+ ]
154+ } ,
155+ ]
156+ } ,
157+
158+ // Automated License List
159+ {
160+ element : "h2" ,
161+ textContent : "Open Source Licenses" ,
162+ style : { fontSize : "1.5em" , marginBottom : "10px" } ,
163+ children : [ ] ,
164+ } ,
165+ {
166+ element : "div" ,
167+ style : {
168+ backgroundColor : "rgba(0, 0, 0, 0.5)" , // Semi-transparent
169+ border : "1px solid rgba(255, 255, 255, 0.1)" ,
170+ padding : "15px" ,
171+ borderRadius : "8px" ,
172+ fontSize : "0.9em" ,
173+ fontFamily : "monospace" ,
174+ maxHeight : "500px" , // Scrollable so the page isn't 10 miles long
175+ overflowY : "auto" ,
176+ color : "#ffffff" ,
177+ } ,
178+ children : [
179+ {
180+ element : "div" ,
181+ GPWhenCreated : async function ( elm ) {
182+ elements . setInnerJSON ( elm , [
183+ {
184+ element : "span" ,
185+ textContent : "Loading license data..." ,
186+ style : { fontStyle : "italic" , opacity : "0.7" }
187+ }
188+ ] )
189+
190+ try {
191+ var response = await fetch ( "/licenses.json" ) ;
192+ if ( ! response . ok ) {
193+ throw new Error ( "HTTP " + response . status ) ;
194+ }
195+ var json = await response . json ( ) ;
196+
197+ // Sort them alphabetically by name because it looks nicer
198+ json . sort ( ( a , b ) => ( a . name || "" ) . localeCompare ( b . name || "" ) ) ;
199+
200+ var arrayContent = json . map ( generateLicenseElement ) ;
201+ elements . setInnerJSON ( elm , arrayContent ) ;
202+ } catch ( e ) {
203+ console . error ( e ) ;
204+ elements . setInnerJSON ( elm , [
205+ {
206+ element : "div" ,
207+ style : {
208+ color : "#ff6b6b" , // Red error color
209+ fontWeight : "bold"
210+ } ,
211+ children : [
212+ { element : "span" , textContent : "Error loading licenses file." } ,
213+ { element : "br" } ,
214+ { element : "span" , textContent : "Details: " + e . message }
215+ ]
216+ }
217+ ] ) ;
218+ }
219+ }
220+ } ,
221+ ]
222+ } ,
223+ ] ;
224+
225+ var elementJSON = [
226+ {
227+ element : "div" ,
228+ className : "aboutDivCenter" ,
229+ children : contentArray ,
230+ } ,
231+ ] ;
232+
233+ var pageElements = elements . createElementsFromJSON ( elementJSON ) ;
234+ elements . appendElements ( elements . body , pageElements ) ;
0 commit comments