jQuery Grouping Similar Items and Counting When Repeated
Posted
by NessDan
on Stack Overflow
See other posts from Stack Overflow
or by NessDan
Published on 2010-06-15T21:24:50Z
Indexed on
2010/06/15
21:52 UTC
Read the original article
Hit count: 235
So I have this structure setup:
<ul>
<li>http://www.youtube.com/watch?v=dw1Vh9Yzryo</li> (Vid1)
<li>http://www.youtube.com/watch?v=bOF3o8B292U</li> (Vid2)
<li>http://www.youtube.com/watch?v=yAY4vNJd7A8</li> (Vid3)
<li>http://www.youtube.com/watch?v=yAY4vNJd7A8</li>
<li>http://www.youtube.com/watch?v=dw1Vh9Yzryo</li>
<li>http://www.youtube.com/watch?v=bOF3o8B292U</li>
<li>http://www.youtube.com/watch?v=yAY4vNJd7A8</li>
<li>http://www.youtube.com/watch?v=dw1Vh9Yzryo</li>
</ul>
Vid1 is repeated 3 times, Vid2 is repeated 3 times, and Vid3 is repeated 2 times. I want to put them into a structure where I can reference them like this:
Vid1 -> 3 (Repeated), http://www.youtube.com/get_video?video_id=dw1Vh9Yzryo&fmt=36
(Download)
Vid2 -> 3 (Repeated), http://www.youtube.com/get_video?video_id=bOF3o8B292U&fmt=36
(Download)
Vid3 -> 2 (Repeated), http://www.youtube.com/get_video?video_id=yAY4vNJd7A8&fmt=36
(Download)
"This video was repeated " + [Vid1][Repeated] + " times and you can download it here: " + [Vid1][Download];
How can I set this structure up? I think I should be using an array to achieve the above but I'm not sure how I would set it up or how to reference certain things in the array. The other question is how can I get how many times something was repeated? The URL I have no problem with. Can anyone help me out?
© Stack Overflow or respective owner