SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Angry Slide show advise needed

    Hai guys,
    i have 1500 images in a ftp folder.
    image names are like :

    apple
    banana
    mango
    parrot
    ...

    Now i need to randomly load theis images in to the slide show which is written in basic JS.

    plse tell me how to do this.

    the slide show can be paused and resume at any time.
    Last edited by afridy; Aug 9, 2008 at 09:49.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Use a server-side script to dump an array of those names into the page.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks pmw57

    my plan is like this,
    in db the data are as flollws for each image,

    ID | picpath | description | date_capture

    Now my plane is to generate a randam no and load the picture and detals using php & ajax for each image. so for each image, an ajax xmlhttprequest is made. is this ok?
    Last edited by afridy; Aug 10, 2008 at 23:03.

  4. #4
    SitePoint Enthusiast kceleb9's Avatar
    Join Date
    Jun 2008
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yikes - do NOT DUMP THOSE ARRAYS to your page with a server side script... that is sheer nonsense. You will create a nice bloated page. If you must leave the names the same on the server - then at least put an array in a separate .js file - and set chaching so it is downloaded once (if you need version control use the folder).

    A better solution is to RENAME the images on the server - im0, im2, im3, im4. If they are different file types then at most you can store or deliver a compact array with the file types only - and the rest of the file name can be automatically constructed by JS on your page...
    - PM me to start building fair link exchanges automatically -

    LnkPro.com - Link Exchanges for Professionals

  5. #5
    SitePoint Enthusiast kceleb9's Avatar
    Join Date
    Jun 2008
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your number of requests should not be a big deal via AJAX - provided your slide show is operating at a reasonable speed. The issue will be having a reasonably fast loading page - which is why i recommend changing the file names if you can.

    An alternative is to have the client be unaware of the file names at all. You will need to maintain some sort of a LIFO buffer or similar structure on the server with the images - keep track of ther order handed out (use a cursor or other variable in your HTTP request) - and then simply have the client make a request like "get next 10 images" or next 5 or whatever you want... whenever the slideShow gets within a range of the end of the images fetched in the last request.

    In that case your client does not even need to know the file names it is requesting. Just return a JSON array of URLs to the images from the server.
    - PM me to start building fair link exchanges automatically -

    LnkPro.com - Link Exchanges for Professionals

  6. #6
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks kceleb9 for the explanation. any problem ill come back.

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    I agree, that's a much better technique.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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