Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Streamlining code and variable passing...

    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

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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).
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •