Skip to content
Snippets Groups Projects
Commit 0f382e20 authored by rswindell's avatar rswindell
Browse files

Major cosmetic/information changes.

parent de082e79
No related branches found
No related tags found
No related merge requests found
// JavaScript HTML Index for Synchronet FTP Server // JavaScript HTML Index for Synchronet FTP Server
// $id$ // $id$
load("sbbsdefs.js"); load("sbbsdefs.js"); // Synchronet constants
var title=system.name + " FTP Server"; /* Utility Functions */
function date(time)
{
var mon=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
var d=new Date(time*1000);
return(format("%s %02d %d %02d:%02d"
,mon[d.getUTCMonth()]
,d.getUTCDate()
,d.getUTCFullYear()
,d.getUTCHours()
,d.getUTCMinutes()));
}
function kbytes(nbytes)
{
return(Math.round(nbytes/1024)+"k");
}
function secstr(sec)
{
return(format("%02u:%02u",sec/60,sec%60));
}
var title=system.name /* + " FTP Server" */ ;
if (curdir.name!=undefined) if (curdir.name!=undefined)
title += " - " + curdir.name; title += " - " + curdir.name;
else if(curlib.name!=undefined) else if(curlib.name!=undefined)
...@@ -18,30 +41,65 @@ write(title); ...@@ -18,30 +41,65 @@ write(title);
write("</title>\r\n"); write("</title>\r\n");
write("<META NAME='GENERATOR' content='" + system.version + "'>\r\n"); write("<META NAME='GENERATOR' content='" + system.version + "'>\r\n");
write("</head>\r\n"); write("</head>\r\n");
write("<body bgcolor=gray text=white link=yellow vlink=lime alink=white>\r\n"); write("<body bgcolor=teal text=white link=yellow vlink=lime alink=white>\r\n");
write("<font face=Arial,Helvetica,sans-serif>\r\n"); write("<font face=Arial,Helvetica,sans-serif>\r\n");
write("<H1><I><FONT COLOR=lime>" + title + "</FONT></I></H1>\r\n"); write("<H1><I><FONT COLOR=lime>" + title + "</FONT></I></H1>\r\n");
write("<h4>");
var prevdir; var prevdir;
var hdr_font="<font color=silver>";
var dat_font="<font color=white>";
/* User Info */
write("<table border=0 nowrap>\r\n");
write("<tr><th align=right>"+hdr_font+"User:<th align=left>"+dat_font+user.alias);
/* Library Info */
if(curlib.name!=undefined) { if(curlib.name!=undefined) {
write("<font color=silver>Library: </font>"+curlib.description+"<BR>\r\n"); write("<th align=right>"+hdr_font+"Library:<th align=left>"+dat_font+curlib.description);
prevdir="/"; prevdir="/";
} } else
write("<th align=right>"+hdr_font+"Logons:<th align=left>"+dat_font+user.total_logons);
write("<tr><th align=right>"+hdr_font+"Address:<th align=left width=150>"+dat_font+user.note);
if(curdir.name!=undefined) { if(curdir.name!=undefined) {
write("<font color=silver>Directory: </font>"+curdir.description); write("<th align=right>"+hdr_font+"Directory:<th align=left>"+dat_font+curdir.description);
if(curdir.misc&DIR_FREE) if(curdir.misc&DIR_FREE)
write("<font color=silver> - FREE Downloads</font>"); write(hdr_font+" - FREE Downloads</font>");
write("<BR>\r\n");
prevdir="/"+curlib.name+"/"; prevdir="/"+curlib.name+"/";
} else if(curlib.name==undefined)
write("<th align=right>"+hdr_font+"Last on:<th align=left>"+date(user.laston_date));
write("<tr><th align=right>"+hdr_font+"Credits:<th align=left>"+dat_font);
if(user.exemptions&UFLAG_D)
write("Exempt");
else
write(kbytes(user.credits+user.free_credits));
if(curdir.misc!=undefined) {
write("<th align=right>"+hdr_font+"Descriptions:<th align=left>");
if(user.settings&EXTDESC)
write(format("[<a href=%s?ext=off>short</a>]",html_index_file));
else
write(format("[<a href=%s?ext=on>extended</a>]",html_index_file));
} else if(curlib.name==undefined && user.files_uploaded) {
write("<th align=right>"+hdr_font+"Uploaded:<th align=left>"+dat_font);
write(format("%s bytes in %u files",kbytes(user.bytes_uploaded),user.files_uploaded));
} }
write("<tr><th align=right>"+hdr_font+"Time left:<th align=left>"+dat_font);
if(user.exemptions&UFLAG_T)
write("Exempt");
else
write(secstr(time_left));
if(prevdir!=undefined) { if(prevdir!=undefined) {
write("<BR>\r\n"); write("<th align=right>"+hdr_font+"Navigate:<th align=left>");
write(format("[<a href=%s%s>prev</a>] ",prevdir,html_index_file)); write(format("[<a href=%s%s>prev</a>] ",prevdir,html_index_file));
write(format("[<a href=/%s>root</a>]",html_index_file)); write(format("[<a href=/%s>root</a>] ",html_index_file));
} else if(curlib.name==undefined && user.files_downloaded) {
write("<th align=right>"+hdr_font+"Downloaded:<th align=left>"+dat_font);
write(format("%s bytes in %u files",kbytes(user.bytes_downloaded),user.files_downloaded));
} }
write("</h4>");
write("\r\n");
write("</table>\r\n");
/* Table Attributes */ /* Table Attributes */
var hdr_background="white"; var hdr_background="white";
...@@ -52,67 +110,59 @@ var cell_spacing=""; //"cellspacing=2 cellpadding=2"; ...@@ -52,67 +110,59 @@ var cell_spacing=""; //"cellspacing=2 cellpadding=2";
/* Directory Listing */ /* Directory Listing */
if(dir.length) { if(dir.length) {
write("<table border=0 nowrap " + cell_spacing + " width=50%>\r\n"); write("<br><table border=0 " + cell_spacing + " width=50%>\r\n");
/* header */ /* header */
write("<thead>"); write("<thead>");
write("<tr bgcolor=" + hdr_background + ">"); write("<tr bgcolor=" + hdr_background + ">");
write("<th>" + hdr_font + "Directory"); write("<th>" + hdr_font + "Directory");
write("<th>" + hdr_font + "Description"); write("<th>" + hdr_font + "Description");
if(curlib.name!=undefined)
write("<th>" + hdr_font + "Files");
write("</thead>"); write("</thead>");
/* body */ /* body */
write("\r\n<tbody>\r\n"); write("\r\n<tbody>\r\n");
for(i in dir) { for(i in dir) {
write("<TR>\r\n"); write("<tr>\r\n");
/* filename */ /* filename */
write("<TD>" + dat_font + format("<A HREF=%s", dir[i].link) + ">" write("<th nowrap align=left>" + dat_font + format("<A HREF=%s", dir[i].link) + ">"
+ dir[i].name +"</A>"); + dir[i].name +"</A>");
write("<TD>" + dat_font + dir[i].description); write("<td nowrap>" + dat_font + dir[i].description);
}
write("</TABLE>\r\n");
write("<BR>\r\n");
}
function date(time)
{
var mon=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
var d=new Date(time*1000);
return(format("<TT>%s %02d %d %02d:%02d"
,mon[d.getUTCMonth()]
,d.getUTCDate()
,d.getUTCFullYear()
,d.getUTCHours()
,d.getUTCMinutes()));
}
function bytes(nbytes) if(curlib.name!=undefined) {
{ write("<td align=right><font color=black>" + dat_font + dir[i].size);
return(Math.round(nbytes/1024)+"k"); write("<th>" + dat_font + (dir[i].misc&DIR_FREE ? "FREE":""));
}
}
write("</table>\r\n");
} }
/* File Listing */ /* File Listing */
if(file.length) { if(file.length) {
var show_ext_desc=true; /* show extended descriptions */ var show_ext_desc; /* show extended descriptions */
var total_bytes=0; var total_bytes=0;
var total_downloads=0; var total_downloads=0;
var most_recent=0; var most_recent=0;
if (curdir.name==undefined) if (curdir.name==undefined)
show_ext_desc=false; /* aliased files have no ext desc */ show_ext_desc=false; /* aliased files have no ext desc */
else
show_ext_desc=user.settings&EXTDESC;
write("<table border=0 nowrap " + cell_spacing + " width=100%>\r\n"); write("<br><table border=0 nowrap " + cell_spacing + " width=100%>\r\n");
/* header */ /* header */
write("<thead>"); write("<thead>");
write("<tr bgcolor=" + hdr_background + ">"); write("<tr bgcolor=" + hdr_background + ">");
write("<th>" + hdr_font + "File"); write("<th>" + hdr_font + "File");
write("<th>" + hdr_font + "Size"); if(curdir.misc!=undefined && !(curdir.misc&DIR_FREE))
write("<th>" + hdr_font + "Credits");
else
write("<th>" + hdr_font + "Size");
write("<th>" + hdr_font + "Description"); write("<th>" + hdr_font + "Description");
write("<th>" + hdr_font + "Date/Time"); write("<th>" + hdr_font + "Date/Time");
if(curdir.name!=undefined) { /* not valid for aliased files in root */ if(curdir.name!=undefined) { /* not valid for aliased files in root */
...@@ -125,7 +175,6 @@ if(file.length) { ...@@ -125,7 +175,6 @@ if(file.length) {
write("\r\n<tbody>\r\n"); write("\r\n<tbody>\r\n");
for(i in file) { for(i in file) {
total_bytes+=file[i].size;
total_downloads+=file[i].times_downloaded; total_downloads+=file[i].times_downloaded;
if(file[i].time>most_recent) if(file[i].time>most_recent)
most_recent=file[i].time; most_recent=file[i].time;
...@@ -133,11 +182,25 @@ if(file.length) { ...@@ -133,11 +182,25 @@ if(file.length) {
write("<TR>\r\n"); write("<TR>\r\n");
/* filename */ /* filename */
write("<TD valign=top>" + dat_font + "<A HREF=" + file[i].name + ">" write("<th valign=top align=left>" + dat_font);
+ file[i].name +"</A>"); if(curdir.misc!=undefined
&& !(curdir.misc&DIR_FREE)
&& !(user.exemptions&UFLAG_D)
&& file[i].credits > (user.credits+user.free_credits)
)
write(file[i].name);
else
write("<A HREF=" + file[i].name + ">" + file[i].name +"</A>");
/* size */ /* size */
write("<TD valign=top align=right>" + dat_font + "<font color=black>" + bytes(file[i].size)); write("<TD valign=top align=right>" + dat_font + "<font color=black>");
if(curdir.misc!=undefined && !(curdir.misc&DIR_FREE)) {
write(kbytes(file[i].credits));
total_bytes+=file[i].credits;
} else {
write(kbytes(file[i].size));
total_bytes+=file[i].size;
}
/* description */ /* description */
write("<TD valign=top>"); write("<TD valign=top>");
...@@ -151,7 +214,7 @@ if(file.length) { ...@@ -151,7 +214,7 @@ if(file.length) {
/* date/time */ /* date/time */
write("<TD valign=top align=center nowrap>" + dat_font + "<font color=black>" write("<TD valign=top align=center nowrap>" + dat_font + "<font color=black>"
+ date(file[i].time)); + "<TT>"+ date(file[i].time));
if(curdir.name!=undefined) { /* not valid for aliased files in root */ if(curdir.name!=undefined) { /* not valid for aliased files in root */
/* uploader */ /* uploader */
...@@ -172,10 +235,10 @@ if(file.length) { ...@@ -172,10 +235,10 @@ if(file.length) {
/* Footer (with totals) */ /* Footer (with totals) */
write("<tfoot>\r\n"); write("<tfoot>\r\n");
write(format("<TR bgcolor=%s><TH>%s%lu files" + write(format("<TR bgcolor=%s><TH>%s%lu files" +
"<TH align=right>%s%s<TH>%s-<TH>%s<font color=black>%s" "<TH align=right>%s%s<TH>%s-<TH>%s<font color=black><TT>%s"
,hdr_background ,hdr_background
,hdr_font, file.length ,hdr_font, file.length
,hdr_font, bytes(total_bytes) ,hdr_font, kbytes(total_bytes)
,hdr_font ,hdr_font
,dat_font, date(most_recent) ,dat_font, date(most_recent)
)); ));
...@@ -187,13 +250,15 @@ if(file.length) { ...@@ -187,13 +250,15 @@ if(file.length) {
)); ));
write("</TABLE>\r\n"); write("</TABLE>\r\n");
write("<BR>\r\n");
} }
if(!file.length && !dir.length) if(!file.length && !dir.length)
write("No Files.<br>"); write("<br><b>No Files.</b><br>");
/* Footer */ /* Footer */
write("<BR><font size='-2'>Problems? Ask ");
write(format("<a href=mailto:sysop@%s>%s</a>.",system.inetaddr,system.operator));
write("<BR><font size='-2'>Dynamically generated by "); write("<BR><font size='-2'>Dynamically generated by ");
write("<A HREF=http://www.synchro.net>" + system.version + "</A>"); write("<A HREF=http://www.synchro.net>" + system.version + "</A>");
write("<BR>" + Date() + "</font>\r\n"); write("<BR>" + Date() + "</font>\r\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment