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

Fix bugs in multi-column (>10) program listings (JS numbers are floats by

default).
parent 1200efb4
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ const XtrnProgLstUnderline =382 ...@@ -16,6 +16,8 @@ const XtrnProgLstUnderline =382
const XtrnProgLstFmt =383 const XtrnProgLstFmt =383
const WhichXtrnProg =384 const WhichXtrnProg =384
var multicolumn = true;
while(bbs.online) { while(bbs.online) {
if(user.security.restrictions&UFLAG_X) { if(user.security.restrictions&UFLAG_X) {
...@@ -61,34 +63,33 @@ while(bbs.online) { ...@@ -61,34 +63,33 @@ while(bbs.online) {
else { else {
printf(bbs.text(XtrnProgLstHdr),xtrn_area.sec_list[xsec].name); printf(bbs.text(XtrnProgLstHdr),xtrn_area.sec_list[xsec].name);
write(bbs.text(XtrnProgLstTitles)); write(bbs.text(XtrnProgLstTitles));
if(xtrn_area.sec_list[xsec].prog_list.length >= 10) { if(multicolumn && xtrn_area.sec_list[xsec].prog_list.length >= 10) {
write(" "); write(" ");
write(bbs.text(XtrnProgLstTitles)); write(bbs.text(XtrnProgLstTitles));
} }
console.crlf(); console.crlf();
write(bbs.text(XtrnProgLstUnderline)); write(bbs.text(XtrnProgLstUnderline));
if(xtrn_area.sec_list[xsec].prog_list.length >= 10) { if(multicolumn && xtrn_area.sec_list[xsec].prog_list.length >= 10) {
write(" "); write(" ");
write(bbs.text(XtrnProgLstUnderline)); write(bbs.text(XtrnProgLstUnderline));
} }
console.crlf(); console.crlf();
var n; var n;
if(xtrn_area.sec_list[xsec].prog_list.length >= 10) if(multicolumn && xtrn_area.sec_list[xsec].prog_list.length >= 10)
n=(xtrn_area.sec_list[xsec].prog_list.length/2)+(xtrn_area.sec_list[xsec].prog_list.length&1); n=Math.floor(xtrn_area.sec_list[xsec].prog_list.length/2)+(xtrn_area.sec_list[xsec].prog_list.length&1);
else else
n=xtrn_area.sec_list[xsec].prog_list.length; n=xtrn_area.sec_list[xsec].prog_list.length;
var i; var i,j;
for(i=0;i<n;i++) { for(i=0;i<n;i++) {
printf(bbs.text(XtrnProgLstFmt),i+1 printf(bbs.text(XtrnProgLstFmt),i+1
,xtrn_area.sec_list[xsec].prog_list[i].name ,xtrn_area.sec_list[xsec].prog_list[i].name
,xtrn_area.sec_list[xsec].prog_list[i].cost); ,xtrn_area.sec_list[xsec].prog_list[i].cost);
if(xtrn_area.sec_list[xsec].prog_list.length>=10) { if(multicolumn
j=(xtrn_area.sec_list[xsec].prog_list.length/2)+i+(xtrn_area.sec_list[xsec].prog_list.length&1); && xtrn_area.sec_list[xsec].prog_list.length>=10) {
j=Math.floor(xtrn_area.sec_list[xsec].prog_list.length/2)+i+(xtrn_area.sec_list[xsec].prog_list.length&1);
if(j<xtrn_area.sec_list[xsec].prog_list.length) { if(j<xtrn_area.sec_list[xsec].prog_list.length) {
log(format("%d %d",j,xtrn_area.sec_list[xsec].prog_list.length));
log(xtrn_area.sec_list[xsec].prog_list[j]);
write(" "); write(" ");
printf(bbs.text(XtrnProgLstFmt),j+1 printf(bbs.text(XtrnProgLstFmt),j+1
,xtrn_area.sec_list[xsec].prog_list[j].name ,xtrn_area.sec_list[xsec].prog_list[j].name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment