Hello and welcome to our community! Is this your first visit?
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
    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!


  • #2
    Senior Coder
    Join Date
    Sep 2005
    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:

    (taking just the first bit)

    you could get your code to output this as

    or even more simply
    and have your code know that a = version (and so on).

    this could be shortened a litle bit further as:

    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