Show
Ignore:
Timestamp:
12/24/07 13:32:19 (13 months ago)
Author:
cho45
Message:

lang/javascript/userchrome/editonfavorite.uc.js:

Object での管理から Array での管理に変更 (ハッシュアクセスが必要なくなってた)
監視する必要がなくなったら clearInterval するように

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userchrome/editonfavorite.uc.js

    r3518 r3519  
    3232                } 
    3333 
    34                 self.watching = {}; 
     34                self.watching = []; 
    3535        }, 
    3636 
     
    6464                        args.unshift("-a", "Vim"); 
    6565                        ps.run(false, args, args.length); 
    66                         self.watching[file.path] = { 
     66                        self.watching.push({ 
    6767                                file: file, 
    6868                                time: (new Date()).getTime(), 
    6969                                doc: e.target.ownerDocument, 
    7070                                target: e.target 
    71                         }; 
     71                        }); 
    7272                        if (!self.watcher) { 
    7373                                self.watcher = setInterval(function () { 
    7474                                        self.watch(); 
    7575                                }, 1000); 
     76                                log("start watcher thread. "+self.watcher); 
    7677                        } 
    7778                } 
     
    8182                log("unload"+e.originalTarget); 
    8283                var self = this; 
    83                 for (var k in self.watching) { 
    84                         if (!self.watching.hasOwnProperty(k)) continue; 
    85                         var w = self.watching[k]; 
     84                for (var i = 0; i < self.watching.length; i++) { 
     85                        var w = self.watching[i]; 
    8686                        log(w.doc == e.originalTarget); 
    8787                        if (w.doc == e.originalTarget) { 
    88                                 log("unwatch: "+w.file.path); 
     88                                log("unwatch: "+w.file.path+" len:"+self.watching.length); 
    8989                                w.file.remove(false); 
    90                                 delete self.watching[k]; 
     90                                self.watching.splice(i, 1); 
     91                                if (!self.watching.length) { 
     92                                        log("end watcher thread. "+self.watcher); 
     93                                        clearInterval(self.watcher); 
     94                                        self.watcher = null; 
     95                                } 
    9196                        } 
    9297                } 
     
    95100        watch : function () { 
    96101                var self = this; 
    97                 for (var k in self.watching) { 
    98                         if (!self.watching.hasOwnProperty(k)) continue; 
    99                         var w = self.watching[k]; 
     102                for (var i = 0; i < self.watching.length; i++) { 
     103                        var w = self.watching[i]; 
    100104                        if (w.time < w.file.lastModifiedTime) { 
    101105                                log("changed:"+w.file.path);