www.webdeveloper.com
Results 1 to 8 of 8

Thread: Newbie in need of help

  1. #1
    Join Date
    Feb 2010
    Posts
    4

    Question Newbie in need of help

    I want the results of this script to be sorted alphabetically.
    Would appreciate some help.
    Thanks in advance.

    <div id="container">
    <h2>my bookmarks</h2>
    </div>

    <script type="text/javascript"
    src="http://del.icio.us/feeds/json/glante?count=20"></script>

    <script type="text/javascript">
    function showImage(img){ return (function(){ img.style.display='inline'; }) }

    var ul = document.createElement('ul')
    for (var i=0, post; post = Delicious.posts[i]; i++) {
    var li = document.createElement('li')
    var a = document.createElement('a')
    a.style.marginLeft = '20px'
    var img = document.createElement('img')
    img.style.position = 'absolute'
    img.style.display = 'none'
    img.height = img.width = 16
    img.src = post.u.split('/').splice(0,3).join('/')+'/favicon.ico'
    img.onload = showImage(img);
    a.setAttribute('href', post.u)
    a.appendChild(document.createTextNode(post.d))
    li.appendChild(img)
    li.appendChild(a)
    ul.appendChild(li)
    }
    document.getElementById('container').appendChild(ul)
    </script>

  2. #2
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    This should do the trick:

    Code:
    <div id="container">
    <h2>my bookmarks</h2>
    </div>
    
    <script type="text/javascript"
    src="http://del.icio.us/feeds/json/glante?count=20"></script>
    
    <script type="text/javascript">
    function showImage(img){ return (function(){ img.style.display='inline'; }) }
    
    Delicious.posts.sort(function(a, b){ return a.d.toUpperCase() > b.d.toUpperCase() });
    
    var ul = document.createElement('ul')
    for (var i=0, post; post = Delicious.posts[i]; i++) {
    var li = document.createElement('li')
    var a = document.createElement('a')
    a.style.marginLeft = '20px'
    var img = document.createElement('img')
    img.style.position = 'absolute'
    img.style.display = 'none'
    img.height = img.width = 16
    img.src = post.u.split('/').splice(0,3).join('/')+'/favicon.ico'
    img.onload = showImage(img);
    a.setAttribute('href', post.u)
    a.appendChild(document.createTextNode(post.d))
    li.appendChild(img)
    li.appendChild(a)
    ul.appendChild(li)
    }
    document.getElementById('container').appendChild(ul)
    </script>
    grts

  3. #3
    Join Date
    Feb 2010
    Posts
    4

    Sort alphabetically

    I want the results of this script to be sorted alphabetically.
    Thanks in advance.

    Code:
    <div id="container">
    <h2>my bookmarks</h2>
    </div>
    
    <script type="text/javascript"
    src="http://del.icio.us/feeds/json/glante?count=20"></script>
    
    <script type="text/javascript">
    function showImage(img){ return (function(){ img.style.display='inline'; }) }
    
    var ul = document.createElement('ul')
    for (var i=0, post; post = Delicious.posts[i]; i++) {
    var li = document.createElement('li')
    var a = document.createElement('a')
    a.style.marginLeft = '20px'
    var img = document.createElement('img')
    img.style.position = 'absolute'
    img.style.display = 'none'
    img.height = img.width = 16
    img.src = post.u.split('/').splice(0,3).join('/')+'/favicon.ico'
    img.onload = showImage(img);
    a.setAttribute('href', post.u)
    a.appendChild(document.createTextNode(post.d))
    li.appendChild(img)
    li.appendChild(a)
    ul.appendChild(li)
    }
    document.getElementById('container').appendChild(ul)
    </script>

  4. #4
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    already replied on your earlier thread (http://www.webdeveloper.com/forum/sh...d.php?t=224538)

  5. #5
    Join Date
    Feb 2010
    Posts
    4
    Thank you, Gozzy82!

    I read the forum guidelines after my 1st post, so I created a new one, just to find out I couldn't delete the previous one.

    Anyway, it seems your suggestion doesn't work.
    My Delicious Bookmarks still sort on creation date.

    Thanks anyway for your rapid answer!

  6. #6
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    hmm weird i guess your using internet explorer because it does work in firefox.

    ( http://www.webdevout.net/test?0M )

  7. #7
    Join Date
    Feb 2010
    Posts
    4
    Oh, thanks - I use Safari at the moment.
    Confirmed that it works in FF.
    Is there a simple way to make it work in more browsers?

  8. #8
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    im looking into it...

    its pretty weird that firefox is the only one understanding this sort function

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles