...

View Full Version : Streamlining code and variable passing...



fkatzenb
08-04-2007, 04:54 PM
First off, thanks for having a nice easy to read coding forums. Greatly appreciated.

My web based program can be seen here: http://www.squirrelpf.com/~turbocalc/beta/

Having never really programmed much in php, javascript, or mysql, this was quite the challenging task and has taken me a few weeks.

As you can see, I allow people to hot link either their configuration or the image that is generated on the fly. Of course it uses an insanely long URL because I pass all the data thru it. What is worse, is the series of strings I wrote just to write that data to those fields.

So how can I streamline that part? I would love to have that entire thing down to a short burst of data. Is that possible and worth it? Would it require a large bit of recoding?

Also if anyone sees any suggestions for streamlining my javascript, I would be very happy!


Frank

GJay
08-04-2007, 05:40 PM
one method would be to store saved configs in a database table, along with a unique id, and use that id as the request-parameter, performing a lookup on the database to pull out the values.

Another method would be to compress the key-value pairs in some way that makes them shorter, but in such a way to can reverse the compression when re-populating the form. Rather than:
?version=4&target_peak_power=450&engine_disp=2.4&engine_disp_factor=0

(taking just the first bit)

you could get your code to output this as
?v=4&tpp=450&ed=2&edf=0

or even more simply
?a=4&b=450&c=2&d=0
and have your code know that a = version (and so on).

this could be shortened a litle bit further as:
?q=4|450|2|0

and your code would split the param on |, and know that the first one is the version, the second the power (and so on).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum