local (folder = "internal:apps:webstar:colorSampler:", f)
local (ctcolors = sizeof (system.verbs.colors)) «140
local (forecolorsperpage = 7) «must divide 140 evenly
local (backcolorsperpage = 10) «ditto
local (htmltext = "", indent = 0)
on add (s)
s = string.filledstring ('\t', indent) + s + "\r"
htmltext = htmltext + s
on oneTable (f, startforecolor, endforecolor, startbackcolor, endbackcolor, cellwidth=75, cellheight=40, nextlink="")
local (fname = file.filefrompath (f))
htmltext = ""
indent = 0
add ("<html>"); indent++
add ("<head>"); indent++
add ("<title>" + fname + "</title>")
add ("</head>\r"); indent--
add ("<body bgcolor=\"#FFFFFF\">"); indent++
add ("<h4>" + fname + "</h4>")
local (fc, bc)
add ("<blockquote>"); indent++
add ("<br>")
add ("<table border=1 cellspacing=0 cellpadding=3>"); indent++
bundle «add row of foreground color labels
add ("<tr>"); indent++
add ("<td> </td>")
for fc = startforecolor to endforecolor
add ("<td><center><code><i>" + nameof (system.verbs.colors [fc]) + "</i></code></center></td>")
add ("</tr>"); indent--
for bc = startbackcolor to endbackcolor
local (namebackcolor = nameof (system.verbs.colors [bc]))
add ("<tr>"); indent++
add ("<td valign=top><code><i>" + nameof (system.verbs.colors [bc]) + "</i></code></center></td>")
for fc = startforecolor to endforecolor
local (nameforecolor = nameof (system.verbs.colors [fc]))
add ("<td width=" + cellwidth + " height=" + cellheight + " bgcolor=\"" + namebackcolor + "\">"); indent++
add ("<font color=\"" + nameforecolor + "\">"); indent++
add ("<center>" + nameforecolor + "</center>")
add ("</font>"); indent--
add ("</td>\r"); indent--
add ("</tr>"); indent--
add ("</table>"); indent--
add ("</blockquote>"); indent--
if nextlink != ""
add ("<p><a href=\"" + nextlink + "\">Next</a>")
add ("<p><code>" + clock.now () + "</code>")
add ("</body>"); indent--
add ("</html>"); indent--
toys.writeWholeFile (f, htmltext, 'TEXT', 'MSIE', clock.now ())
return (true)
on getfname (num)
return ("ColorTable" + toys.padwithzeros (num, 3) + ".html")
file.sureFolder (folder)
fileloop (f in folder)
file.delete (f)
local (fc = 1, bc = 1, fserialnum = 1)
loop «build all the sub-pages
local (f = folder + getfname (fserialnum++))
msg (f)
oneTable (f, fc, fc + forecolorsperpage - 1, bc, bc + backcolorsperpage - 1, nextlink:getfname (fserialnum))
bc = bc + backcolorsperpage
if bc > ctcolors
bc = 1
fc = fc + forecolorsperpage
if fc > ctcolors
break
bundle «build the home page
local (title = "Color Sampler Site", i)
htmltext = ""
indent = 0
add ("<html>"); indent++
add ("<head>"); indent++
add ("<title>" + title + "</title>")
add ("</head>\r"); indent--
add ("<body bgcolor=\"#FFFFFF\">"); indent++
add ("<h4>" + title + "</h4>")
add ("<blockquote><code>"); indent++
for i = 1 to (ctcolors * ctcolors) / (forecolorsperpage * backcolorsperpage)
if (i % 20) == 1
add ("<p>")
add ("<a href=\"" + getfname (i) + "\">" + toys.padwithzeros (i, 3) + "</a>")
add ("</code></blockquote>"); indent--
add ("<p><code>" + clock.now () + "</code>")
add ("</body>"); indent--
add ("</html>"); indent--
toys.writeWholeFile (folder + "default.html", htmltext, 'TEXT', 'MSIE', clock.now ())