FistandanBitus' Fantabulous Script of Dynamic Table Creation

The Gear is deprecated, use the Help forum or CG Wiki.

FistandanBitus' Fantabulous Script of Dynamic Table Creation

Postby JexKerome on Mon Aug 09, 2004 6:15 am

I'm posting this here since the Gear site is down, and some people may find it useful. FistandanBitus, my brother, was kind enough to write this up for me.

This script creates a dynamic table that arranges individual graphics comic page-like. I use it in my site to arrange the panels of each update, as my comic is a graphic novel. The advantage to having your page broken into individual panels is a big one: the update downloads faster as the file sizes are smaller, and your reader is not left sittting there waiting for a monstrous file to download.

Here's the script:
Code: Select all
<script language="JavaScript" type="text/JavaScript">
   
   var tabla = new Array(10);
   
   var panels = X;
   var pagename = "PAGE_ID";
   var path = "http://YOURCOMIC.keenspace.com/images/";
   
   tabla[0] = Y;
   tabla[1] = Y;
   tabla[2] = Y;
   tabla[3] = Y;
   tabla[4] = Y;
   tabla[5] = Y;
   tabla[6] = Y;   

   c=0;

   document.write("<table border='0' cellspacing='0' cellpadding='0' width='100%'>");
   for(a=0;a<10;a++)
   {
      document.write("<tr><td>");
      if(tabla[a] > 1)
         document.write("<table border='0' width='100%' cellspacing='20'>");
      else
         document.write("<table border='0' width='100%'>");
      document.write("<tr valign='top'>");
      for(b=0; b< tabla[a]; b++)
      {
         document.write("<td align='center'><img src='" + path + pagename + String.fromCharCode(97+c) + ".PNG'></td>");
         c++;
      }
      document.write("</tr></table></td></tr>");
      if(c == panels)
         break;
   }
   document.write("</table>");
</script>


Rundown of the script:

The script finds out how many panels to look for in the panels variable. So X is the number of panels on the page. It can go from 1 to as many as you like, but there's no point in using the script for just one panel.

Next, in the variable pagename you tell it the common name in all the panels. If you're gonna use this script, don't name them by the date, but by some convention you like. For example, I name mine by the episode name and the page number, so the 22nd page of the "Cheer" episode is named "Cheer22_". The underscore I added to the panels as I saved them individually, but it is not necessary; we'll get back to the panels' names in a second. For now, in this example I'd put "Cheer22_" instead of "PAGE_ID" in the script.

In the variable aptly named path you put your complete URL path to the images directory. All the panel images are going here from now on. I use the whole path to comply with Kisai's guidelines to do so, and you should too!

The cells for the tabla[#] array each represent a row in the table, from the topmost [0] to the lowermost [as low as you want! the maximum set as default is 10, though]. In the Y value for each of these cells you indicate how many panels go in each row (in effect, how many columns this row has). If you run out of tabla[#] lines, just add more; if you used fewer than the ones shown, there's no need to remove them, the script ignores them.

Now that you've entered all data (to recap: number of panels, ID of said panels, path where the panels are, and how many panels you want on each row of the table) the script can get to work.

What it does is go look for X panels named pagename plus a letter, from "a" to ASCII(X+97), and put them in a table according to the data in the table array. So, you must give each panel file a letter, from "a" (no caps!) to whatever (I've been up to "i"), in the order they are read on the page. So, the fisrt panel of the example above (which would be in the upper right corner) would be "Cheer22_a", while the last one, assuming six panels (and on the lower right corner) would be "Cheer22_f".

So now that we know how the script creates the table, how do you use it?
Well, that's two steps:

1. The images (panels) go to the public_html/images directory.

2. The script, with the info for that particular update, is saved in the YYYYMMDD format, as a .htm file, and goes in the workspace/comics directory. This way, Autokeen automatically puts it in into the index page, and eventually in the archives, without you moving so much as a finger.

Confusing? Don't be! Here's an example using today's update:

Today's page (August 9th, 2004) has eight panels; a big one, six small ones, and a "standard size" one. When I was done with the digital processing, I cut out the eight panels and name them "scramble28_a".PNG, "scramble28_b".PNG, ... up to"scramble28_h".PNG. I want the big panel to got on top alone, the six small ones to go next in pairs, and the last one also to go on its own.

On the script I write:

var panels = 8;
var pagename = "scramble28_";
var path = "http://teoandsara.keenspace.com/images/";

tabla[0] = 1;
tabla[1] = 2;
tabla[2] = 2;
tabla[3] = 2;
tabla[4] = 1;

The rest of the tabla[x] entries I ignore; so will the script.

I save the panels in the images directory, the script in the workspace/comics directory as 20040809.htm, and wait until the next day (or force an update if I'm feeling impatient)...

And voil
Faith is what credulity becomes when it finally achieves escape velocity from the constraints of terrestrial discourse- reasonableness, internal coherence, civility, and candor. Thus, the men who commited the atrocities of September 11 were neither cowards nor lunatics of any sort, but Men of Faith- perfect faith- and this, it must finally be acknowleged, is a terrible thing to be.
JexKerome
Cartoon Hero
 
Posts: 2531
Joined: Wed Apr 21, 2004 5:02 pm

Postby McDuffies on Wed Aug 11, 2004 4:39 pm

Why is there so much female frontal nudity on tv, but not as near many male frontal nudity?
User avatar
McDuffies
Bob was here (Moderator)
Bob was here (Moderator)
 
Posts: 29943
Joined: Fri Jan 01, 1999 4:00 pm
Location: Serbia

Postby JexKerome on Thu Aug 12, 2004 12:45 am

Because this world is still male-dominated.

Any more questions?
Faith is what credulity becomes when it finally achieves escape velocity from the constraints of terrestrial discourse- reasonableness, internal coherence, civility, and candor. Thus, the men who commited the atrocities of September 11 were neither cowards nor lunatics of any sort, but Men of Faith- perfect faith- and this, it must finally be acknowleged, is a terrible thing to be.
JexKerome
Cartoon Hero
 
Posts: 2531
Joined: Wed Apr 21, 2004 5:02 pm


 

Return to Gear



Who is online

Users browsing this forum: No registered users and 1 guest