Saturday, February 7, 2009

Post 7

...and paste the following code just before the </body> tag, and save the template.



<!-- Start post reversal code -->
<script type='text/javascript'>
var Blog1 = document.getElementById('Blog1');
var postContainer = Blog1.childNodes[1];
var first = postContainer.firstChild;
var status = null;
var child = first.nextSibling;
var childNext = null;
var classes = '';

var dateHeaders = false;
while (child != null) {
if (child.className == 'date-header') {
dateHeaders = true;
}
if (child.className == 'status-msg-wrap') {
status = child;
}
child = child.nextSibling;
}

child = first.nextSibling;

while (child != null) {
if (child.className != null) {
if (child.className.match('date-header') != null) {
childNext = child.nextSibling;
postContainer.insertBefore(child, first);
first = child;
child = childNext;
} else if (child.className.match('post hentry') != null) {
childNext = child.nextSibling;
if (!dateHeaders) {
postContainer.insertBefore(child, first);
first = child;
} else {
postContainer.insertBefore(child, first.nextSibling);
}
child = childNext;
} else {
child = child.nextSibling;
}
} else {
child = child.nextSibling;
}
}

if (status != null) {
postContainer.insertBefore(status, first);
}
</script>
<!-- End post reversal code -->


That's it!  You're done!

15 comments:

  1. It works on mozilla, but not for internet explorer...

    Any ideas to correct this, please?

    ReplyDelete
  2. Yes, it works on Firefox but not in IE6

    ReplyDelete
  3. it wouldnt work at first in safari when i tried to edit it there, but if you edit it in another browser and save it there, it'll last when you switch back to your favourite browser.

    ReplyDelete
  4. This is SO GREAT. Thank you! You're a genius.

    ReplyDelete
  5. I have tried this both on Safari & Firefox several
    times no joy yet. Can anyone think what I might be doing wrong?

    ReplyDelete
  6. Didn't work with IE8. I'm crying! Any help out there????

    ReplyDelete
  7. I am using Google Chrome. Is that why it isn't working?

    ReplyDelete
  8. It didn't work for me :( I might have done something wrong but it seems easy and my posts are still in reverse order.

    ReplyDelete
  9. This example doesn't work in Chrome or IE8, so it's not a general solution. It would be so easy for these blogging sites to offer a "reverse" facility, why should we have to mess around with script.

    ReplyDelete
  10. Didn't work in Firefox 12.0. Any other ideas?

    ReplyDelete
  11. It seems the HTML editor doesn't like apostrophes, and changes them to ' when I try to copy and paste it into it. Even when I change the ' to apostrophes and save it, and then go back to it, it changes them back to '. Anyone have the same problem?

    ReplyDelete
  12. Whoops when I typed & # 3 9 ; (remove the spaces between the 5 characters) it auto corrected to an apostrophe. Here's what I meant to say:
    It seems the HTML editor doesn't like apostrophes, and changes them to & # 3 9 ; when I try to copy and paste it into it. Even when I change the & # 3 9 ; to apostrophes and save it, and then go back to it, it changes them back to & # 3 9 ;. Anyone have the same problem?

    ReplyDelete