@@ -22,6 +22,34 @@ document.addEventListener("DOMContentLoaded", function () {
2222 const fileList = document . getElementById ( "fileList" ) ;
2323 const dragZone = document . getElementById ( "dragZone" ) ;
2424 const folderUploadBtn = document . getElementById ( "folderUpload" ) ;
25+ const infoIcon = document . getElementById ( "uploadInfoIcon" ) ;
26+ const infoTooltip = document . getElementById ( "infoTooltip" ) ;
27+ const tooltipContent = infoTooltip . querySelector ( ".tooltip-content" ) ;
28+
29+ infoIcon . addEventListener ( "click" , ( ) => {
30+ infoTooltip . classList . toggle ( "active" ) ;
31+ } ) ;
32+
33+ document . addEventListener ( "click" , ( e ) => {
34+ if ( ! infoIcon . contains ( e . target ) ) {
35+ infoTooltip . classList . remove ( "active" ) ;
36+ }
37+ } ) ;
38+
39+ fetch ( "/info" )
40+ . then ( ( response ) => response . json ( ) )
41+ . then ( ( data ) => {
42+ tooltipContent . innerHTML = `
43+ <p><i class="fas fa-tachometer-alt"></i>${ data . request_limit } requests in ${ data . rate_limit } </p>
44+ <p><i class="fas fa-file-alt"></i>${ data . file_size } MB max file size</p>
45+ <p><i class="fas fa-copy"></i>Max ${ data . max_files } files can be uploaded</p>
46+ ${ data . auto_delete_time ? `<p><i class="fas fa-clock"></i>Auto deletes after ${ formatMinutes ( data . auto_delete_time ) } </p>` : "" }
47+ ` ;
48+ } )
49+ . catch ( ( error ) => {
50+ tooltipContent . innerHTML = `<p>Error loading config info</p>` ;
51+ console . error ( "Error fetching config info:" , error ) ;
52+ } ) ;
2553
2654 folderUploadBtn . addEventListener ( "click" , function ( ) {
2755 const input = document . createElement ( "input" ) ;
@@ -247,4 +275,29 @@ document.addEventListener("DOMContentLoaded", function () {
247275 } , 300 ) ;
248276 } , 3000 ) ;
249277 }
278+
279+ function formatMinutes ( minutes ) {
280+ minutes = Number . parseInt ( minutes , 10 ) ;
281+
282+ if ( isNaN ( minutes ) ) return "unknown time" ;
283+
284+ if ( minutes < 60 ) {
285+ return `${ minutes } minute${ minutes !== 1 ? "s" : "" } ` ;
286+ } else if ( minutes < 24 * 60 ) {
287+ const hours = Math . floor ( minutes / 60 ) ;
288+ return `${ hours } hour${ hours !== 1 ? "s" : "" } ` ;
289+ } else if ( minutes < 7 * 24 * 60 ) {
290+ const days = Math . floor ( minutes / ( 24 * 60 ) ) ;
291+ return `${ days } day${ days !== 1 ? "s" : "" } ` ;
292+ } else if ( minutes < 30 * 24 * 60 ) {
293+ const weeks = Math . floor ( minutes / ( 7 * 24 * 60 ) ) ;
294+ return `${ weeks } week${ weeks !== 1 ? "s" : "" } ` ;
295+ } else if ( minutes < 365 * 24 * 60 ) {
296+ const months = Math . floor ( minutes / ( 30 * 24 * 60 ) ) ;
297+ return `${ months } month${ months !== 1 ? "s" : "" } ` ;
298+ } else {
299+ const years = Math . floor ( minutes / ( 365 * 24 * 60 ) ) ;
300+ return `${ years } year${ years !== 1 ? "s" : "" } ` ;
301+ }
302+ }
250303} ) ;
0 commit comments