beagle r4679 - trunk/beagle/firefox-extension/chrome/content



Author: taofei
Date: Thu Apr 10 14:01:42 2008
New Revision: 4679
URL: http://svn.gnome.org/viewvc/beagle?rev=4679&view=rev

Log:
It works for firefox 3 
Need to find a way to make it work for both firefox 2 and firefox 3


Modified:
   trunk/beagle/firefox-extension/chrome/content/indexBookmark3.js

Modified: trunk/beagle/firefox-extension/chrome/content/indexBookmark3.js
==============================================================================
--- trunk/beagle/firefox-extension/chrome/content/indexBookmark3.js	(original)
+++ trunk/beagle/firefox-extension/chrome/content/indexBookmark3.js	Thu Apr 10 14:01:42 2008
@@ -8,33 +8,38 @@
 function flat(node)
 {
     var list = [];
+    var children = node.children;
     for (var i=0; i<children.length; i++) {
-        if(children.type == 'bookmark')
+        var child = children[i];
+        if(child.type == 'bookmark')
         {
-            list.push(children);
+            list.push(child);
         }
-        else if (children.type == 'folder')
+        else if (child.type == 'folder')
         {
-           list.concat(flat(children)); 
+           list.concat(flat(child)); 
         }
     }
     return list;
 }
 
+try{
+
 var bookmarkIndexer = {
    
     bmsvc : Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
-                .getService (Components.interfaces.nsINavBookmarksService);
-
+                .getService (Components.interfaces.nsINavBookmarksService),
+/*
     init : function()
     {
         this.bmsvc.addObserver(this, false);
-    }
+    },
 
     onItemAdded: function(id, folder, index)
     {
         //how to getBookarkById ?
-    }
+    },
+*/
     /**
      * get the bookmark  one by one 
      * if filter(bookmark) == true do action(bookmark)
@@ -45,7 +50,7 @@
         var num = 0;
         for (var i = 0; i< bms.length; i++)
         {
-            if(filter(bms))
+            if(filter(bms[i]))
             {
                 action(bms[i]);
                 num ++;
@@ -70,9 +75,9 @@
             "t:dc:description=" + bookmark.description,
             "t:fixme:keyword=" + bookmark.keyword,
         ];
-        beagle.writeRawMetadata(meta,beagle.getMetaPath(bookmark.URL,"bookmark"));
+        beagle.writeRawMetadata(meta,beagle.getMetaPath(bookmark.uri.spec, "bookmark"));
         // a little hack , write empty content to content file
-        beagle.writeRawMetadata([],beagle.getContentPath(bookmark.URL,"bookmark"));
+        beagle.writeRawMetadata([],beagle.getContentPath(bookmark.uri.spec, "bookmark"));
     },
    
     /**
@@ -81,16 +86,23 @@
     getAllBookmarks:function()
     {
         return flat(Application.bookmarks.menu);
-    }
+    },
    
     /**
      * check if bookmark is modified since last index
      */
     isModified : function(bookmark, lastIndexDate)
     {
-        var lastModified = this.bmsvc.getItemLastModified(bookmark.id);
-        return lastModified > lastInexDate;
-    }
+        try{
+            var lastModified = this.bmsvc.getItemLastModified(bookmark.id);
+            return lastModified > lastIndexDate;
+        }
+        catch(e){
+            alert(e);
+            return false;
+        }
+
+    },
 
     /**
      * Index the modifled (or new ) bookmarks.
@@ -102,7 +114,7 @@
         var bms = this.getAllBookmarks(); 
         var lastIndexDate = beaglePref.get("beagle.bookmark.last.indexed.date");
         var num = this.walk(
-            root,
+            bms,
             function(bookmark){return _this.isModified(bookmark, lastIndexDate);},
             _this.indexBookmark
         );
@@ -110,8 +122,12 @@
         if(report)
            alert(_f("beagle_index_bookmark_finish",[num]));
         log(_f("beagle_index_bookmark_finish",[num]));
-    }
+    },
 
 }
-
+}
+catch(e)
+{
+    //not firefox 3
+}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]