Created
August 27, 2019 21:38
-
-
Save ftoledo/2d4671b9373e6454607c6346546d6aad to your computer and use it in GitHub Desktop.
cheap filebrowser for synchornet bbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple and cheap file browser for Synchronet BBS | |
* It's use the DDLighbarMenu library and read the file | |
* descriptions from generated FILES.BBS intead to real | |
* filebase, due to lack of jasvascript api to access it. | |
* | |
* usage: | |
* load("ds_file_browser.js"); | |
* browser(); | |
* | |
* you can pass the file directory code as param or null to | |
* get the current user selected library/directory. | |
* | |
* Ragnarok <[email protected]> | |
*/ | |
load("dd_lightbar_menu.js"); | |
function show_list(dir) { | |
var lbMenu = new DDLightbarMenu(1, 3, 80, 18); | |
lbMenu.AddAdditionalQuitKeys(["q", "Q", "x", "X"]); | |
// Generate FILES.BBS in each lib with exec/filelist - -uld -uln | |
filelist = system.exec_dir + "filelist - -uln -uld -ext -dls -+"; | |
system.exec(filelist); | |
if (dir != null) { | |
bbs.curdir = dir; | |
} | |
filename = file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].path + 'FILES.BBS'; | |
dirname = file_area.lib_list[bbs.curlib].name; | |
libname = file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].name; | |
fbbs = new File(filename); | |
fbbs.open("r"); | |
var total_files = 0; | |
//first read | |
var line = fbbs.readln(); | |
while (!fbbs.eof) { | |
if (line != null) { | |
if (line === '') { | |
line = fbbs.readln(); | |
} | |
else { | |
var name = line.substring(0,12); | |
var have_ext_desc = line.substring(12,13); | |
var date = line.substring(14,22); | |
var uploader = line.substring(23,52); | |
var downloads = line.substring(48,53); | |
var desc = line.substring(55,114); | |
var ext_desc = ""; | |
total_files++; | |
if (have_ext_desc == "+") { | |
var end_desc = false; | |
var cnt = 0; | |
while (!end_desc) { | |
line = fbbs.readln(); | |
cnt++; | |
if (line.substring(0,1) === " ") { | |
ext_desc = ext_desc + format("%s\r\n",line); | |
} | |
else { | |
end_desc = true; | |
} | |
} //end_desc | |
} | |
else { | |
//read next | |
line = fbbs.readln(); | |
} | |
item = format("\1h\1Y%s%s %s \1G%-50s", name, have_ext_desc, date, desc); | |
lbMenu.Add(item, name); | |
//if (total_files >100) break; | |
} // vacia | |
} // line is null | |
} //eof | |
fbbs.close(); | |
console.clear(); | |
print(format("\x01N\x01H\x01B " + dirname + " >> " + libname)); | |
print(format("\x01N\x01H\x01G %-12s %-9s %s","File name", "Date", "Description")); | |
console.gotoxy(0,23); | |
print ("Select file and press [ENTER] to see details, [ESC] or X to Exit"); | |
lbMenu.colors.itemColor = "\1n\1w"; | |
lbMenu.colors.itemTextCharHighlightColor = "\1r"; | |
lbMenu.borderEnabled = true; | |
lbMenu.numberedMode = true; | |
// Show the menu and get the chosen item from the user | |
return lbMenu.GetVal(); | |
} | |
function show_file_detail(file) { | |
console.clear(); | |
bbs.list_file_info(file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].number, file, FI_DOWNLOAD); | |
} | |
function browser(dir) { | |
file = true; | |
while (file != null ) { | |
file = show_list(dir); | |
if (file != null) { | |
show_file_detail(file); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment