Advertisement
Guest User

Untitled

a guest
Dec 7th, 2009
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.85 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <style>
  4.             body {
  5.                 font-family: verdana;
  6.                 font-size: 10pt;
  7.             }
  8.             .folder {
  9.                 border: solid 1px silver;
  10.                 -moz-border-radius: 5px;
  11.                 padding: 0.5em;
  12.                 padding-left: 1em;
  13.                 margin: 0.5em;
  14.             }
  15.             .folder h3 {
  16.                 font-family: verdana;
  17.                 font-size: 10pt;
  18.                 margin: 0;
  19.                 padding: 0;
  20.             }
  21.         </style>
  22.     </head>
  23.     <body>
  24.         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  25.         <script type="text/javascript">
  26.             $.fn.buildDivs = function (options) {
  27.                 var options = $.extend({
  28.                     spaces: 0,
  29.                     parentDiv: document.body
  30.                 }, options);
  31.                 return this.each(function () {
  32.                     if (2 == options.spaces) {
  33.                         //console.log(new Array(options.spaces*3+1).join(' '), this, this.title, typeof(this.children), this.id);
  34.                     }
  35.                     if (this.title && typeof(this.children) == 'object') {
  36.                         var addDiv = '<div class="folder" id="bm_'+this.id+'"><h3>'+this.title+'</h3></div>';
  37.                         $(options.parentDiv).append(addDiv);
  38.                         var myDiv = $(options.parentDiv).children('div#bm_'+this.id);
  39.                         if (2 == options.spaces) {
  40.                             //console.log(myDiv, addDiv);
  41.                             //return;
  42.                         }
  43.                     } else if (this.type == 'text/x-moz-place-separator') {
  44.                         var myDiv = $(options.parentDiv).append('<hr>');
  45.                     } else {
  46.                         var myDiv = $(options.parentDiv).append('<a href="'+this.uri+'">'+this.title+'</a><br>');
  47.                     }
  48.                     if (typeof(this.children) == 'object') {
  49.                         $(this.children).buildDivs({
  50.                             spaces: options.spaces+1,
  51.                             parentDiv: myDiv
  52.                         });
  53.                     }
  54.                 });
  55.             }
  56.             $(document).ready(function() {
  57.                 var data = $.ajax({
  58.                     url: 'bookmarks-2009-11-26.json',
  59.                     success: function(msg){
  60.                         //console.log(msg);
  61.                         eval("msg ="+msg);
  62.                         $(msg).buildDivs();
  63.                     }
  64.                 });
  65.             });
  66.         </script>
  67.     </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement