eliminate results

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas 'PointedEars' Lahn

    #16
    Re: eliminate results

    Piperita wrote:
    >I only see one `for' loop here. What would be the second one?
    >
    I think the first is needed to generate temp, the second is the one
    inside the function body.
    Am I wrong?
    How you fill `temp' is rather irrelevant to the solution. Suppose it
    contains the results of the database query as you suggested, then you would
    initialize `temp' with those results through a server-side script that
    generates the constructor call or initializer literal.

    However, if you are to increase efficiency, you would have the server-side
    script generate the initializer appropriately using the presented algorithm
    and no client-side script to filter for the maximum number of displayed
    items. But then it might not even be a JS solution that is needed.

    Please do not remove the attribution line.


    PointedEars

    Comment

    • Piperita

      #17
      Re: eliminate results

      On 29 Lug, 01:26, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
      wrote:
      >
      However, if you are to increase efficiency, you would have the server-side
      script generate the initializer appropriately using the presented algorithm
      and no client-side script to filter for the maximum number of displayed
      items.  But then it might not even be a JS solution that is needed.


      I can't change the server-side: it serves data for many different
      clients (JS, Flash, other) and by changing the server-side script, you
      must update all the clients. This is not possible.

      Comment

      • Thomas 'PointedEars' Lahn

        #18
        Re: eliminate results

        Piperita wrote:
        Thomas 'PointedEars' Lahn wrote:
        >However, if you are to increase efficiency, you would have the server-side
        >script generate the initializer appropriately using the presented algorithm
        >and no client-side script to filter for the maximum number of displayed
        >items. But then it might not even be a JS solution that is needed.
        >
        I can't change the server-side: it serves data for many different
        clients (JS, Flash, other) and by changing the server-side script, you
        must update all the clients. This is not possible.
        Still, I do not see the second loop you are talking about. Either the
        server-side script generates the client-side array, then you have one `for'
        loop to iterate over it; or you retrieve the records in chunks from the
        server, then you append only those to your target array that fit the
        condition for almost equal distribution. The latter would require you to
        know how many records there are in total, though.


        PointedEars
        --
        Prototype.js was written by people who don't know javascript for people
        who don't know javascript. People who don't know javascript are not
        the best source of advice on designing systems that use javascript.
        -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

        Comment

        • Piperita

          #19
          Re: eliminate results

          Thomas 'PointedEars' Lahn wrote:
          Still, I do not see the second loop you are talking about.


          I think the function presumes you have built the array temp (passed as
          an argument).
          I built that array inside another for loop.

          I get from the server all the records, I must filter them, considered
          the fact that:
          1. I can show (print) a certain number of items;
          2. The "unprinted" ones must represent themselves as "undefined"
          elements inside an array;
          3. The undefined element must appear "equally" between printed items;
          There's no other specification, except for the fact that the first and
          the last elements must never be undefined.
          That array (temp) is very important because the rest of the program
          uses it in many ways.
          The fact is that the bug in the code I first posted has been
          discovered late.
          Thanks for your precious and patient help.

          Comment

          Working...