Miles,
You are welcome. I'll help you as much as I can. I do have two open and demanding projects FYI.
The diagram you drew is ok but at every junction that have one line in and two or more out, you need to say under which condition you take one of the outs.
If you are logging internally to SD card, you can do that in a while loop.
acquire data->log data->check for client connection--(no clients)-->repeat the loop
|--(client connected)-->which file they ask for--(a valid file name found on SD card)->serve the file from SD card->repeat the loop
|--(js1.js)->use sprintf to generate the javascript code and return them to client->repeat the loop
What your client will do is that it will first retrieve the static page such as index.htm. Then as it receives it, it realizes it also needs js1.js That's when it will ask for it. Your arduino will not respond to this until it finishes serving the static page. Then next loop it will find a connection from the client asking for the js1.js and will construct it on the fly with sprintf and send it to the client. Then the client will finish rendering the web page and fill in the blank containers in the static page.
That web server you provided the link to is quite complicated. I started my code with the wifi server sample from arduino. My code is too complicated to be useful to you. It has an interpreter for HTTP requests and will recognize whether a javascript file needs substitution and does substitution according to a rule and sends a modified javascript to client. Here are some pieces useful to you:
Here is where you store client request in memory:
if (client.available())
{
char c = client.read();
Serial.write(c);
//Save character c to a buffer
}
Here is where you can go ahead to determine what was requested:
if (c == '\n' && currentLineIsBlank)
{ // Determine what was requested here and serve it.
}
I don't use String class but if you do, you can do buffer.contains("js1.js") to find if the request is about this file or buffer.contains("index.htm") etc. so you don't have to construct a generic code to allow all files on SD card to be request-able.
For the js1.js:
What the following does is to first find the HTML element by its id "int_temp", then replaces its innerHTML with 25.
document.getElementById("int_temp").innerHTML=25;
So if you have Loading..., then before the js1.js is loaded, Loading... is displayed on the web page. After the js1.js is loaded, 25 will replace Loading...
Then the following arduino code basically uses the entire sentence and replace the 25 with the actual temperature so the spot of 25 is taken by a directive %d, or "replace me with an integer" directive. The value of ABC will replace the %d in final buffer:
sprintf(buffer,"document.getElementById("int_temp").innerHTML=%d;",ABC);
I got rid of int_temp in the above line to reduce confusion. 