-
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>
-
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
-
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>
-
-
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!
-
hmm weird i guess your using internet explorer because it does work in firefox.
( http://www.webdevout.net/test?0M )
-
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?
-
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
Forum Rules
|
|
Bookmarks