Show
Ignore:
Timestamp:
09/05/08 01:05:33 (3 months ago)
Author:
drry
Message:
  • fixed an undefined property zindex.
  • et cetera.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/search_autopagerize_site.user.js

    r18857 r18863  
    2020 
    2121(function(){ 
    22     if(!window.Minibuffer) return;    
     22    if(!window.Minibuffer) return; 
    2323 
    2424    var SITEINFOURL = 'http://wedata.net/databases/AutoPagerize/items.json'; 
     
    2626    var _switch = false; 
    2727    var _updated = false; 
    28      
    29     var SearchUrl = function(info){  
     28 
     29    var SearchUrl = function(info){ 
    3030        if(_switch){ 
    3131            var oldnode = document.getElementById('SAS_SiteInfoCheck'); 
    3232            document.body.removeChild(oldnode); 
    33         }         
    34         for(var i=0;i<info.length;i++){ 
    35             var loc = location.href.match(info[i].data.url) 
    36             if(loc != null && info[i].data.url != '^https?://.'){ 
    37                 Keeper = info[i]; 
    38                 var self = document.createElement("div"); 
    39                 self.setAttribute("id","SAS_SiteInfoCheck"); 
    40                 self.innerHTML = '&lt;wedata&gt;'; 
    41                 with (self.style) { 
    42                     textAlign  = 'left' 
    43                     background = '#cccccc' 
    44                     fontSize   = '10px' 
    45                     position   = 'fixed' 
    46                     padding    = '0 5px 0 5px' 
    47                     top        = '30px' 
    48                     right      = '0px' 
    49                     width      = 'auto' 
    50                     height     = 'auto' 
    51                     border     = '0px' 
    52                     zindex     = '257' 
    53                 };  
    54                 document.body.appendChild(self); 
    55                 self.addEventListener('mouseover',changeStatusView,false);  
    56                 self.addEventListener('mouseout',changeStatusClose,false); 
    57                 changeStatusClose('mouseout');  
    58                 _switch = true; 
    59                 return; 
     33        } 
     34        info.some(function(item){ 
     35            var loc = location.href.match(item.data.url); 
     36            if(loc == null || item.data.url == '^https?://.'){ 
     37                return false; 
    6038            } 
    61         } 
     39            Keeper = item; 
     40            var self = document.createElement("div"); 
     41            self.setAttribute("id","SAS_SiteInfoCheck"); 
     42            self.innerHTML = '&lt;wedata&gt;'; 
     43            with(self.style){ 
     44                textAlign  = 'left' 
     45                background = '#cccccc' 
     46                fontSize   = '10px' 
     47                position   = 'fixed' 
     48                padding    = '0 5px' 
     49                top        = '30px' 
     50                right      = '0px' 
     51                width      = 'auto' 
     52                height     = 'auto' 
     53                border     = '0px' 
     54                zIndex     = '257' 
     55            } 
     56            document.body.appendChild(self); 
     57            self.addEventListener('mouseover',changeStatusView,false); 
     58            self.addEventListener('mouseout',changeStatusClose,false); 
     59            changeStatusClose('mouseout'); 
     60            return (_switch = true); 
     61        }); 
    6262    }; 
    63      
     63 
    6464    var setMinibuffer = function(){ 
    6565        window.Minibuffer.addCommand({ 
    6666            name: 'SITEINFO::View-AutoPagerize', 
    67             command: function(){  
    68                 window.Minibuffer.status('Siteinfochecker','Checked', 1000);  
     67            command: function(){ 
     68                window.Minibuffer.status('Siteinfochecker','Checked', 1000); 
    6969                setTimeout(checkData,1000); 
    70             },  
    71         });  
    72          
     70            }, 
     71        }); 
     72 
    7373        window.Minibuffer.addShortcutkey({ 
    7474            key: 'c', 
     
    7777                window.Minibuffer.execute('SITEINFO::View-AutoPagerize'); 
    7878            } 
    79         });  
    80     } 
    81      
     79        }); 
     80    }; 
     81 
    8282    var changeStatusClose = function(e){ 
    83         var self = document.getElementById("SAS_SiteInfoCheck");  
     83        var self = document.getElementById("SAS_SiteInfoCheck"); 
    8484        var style = document.defaultView.getComputedStyle(self, ''); 
    8585        var changeStyle = ['top', 'left', 'height', 'width'].map(function(i) { 
     
    8888           e.clientY < changeStyle[0] || e.clientY > (changeStyle[0] + changeStyle[2])){ 
    8989            self.innerHTML = '&lt;wedata&gt;'; 
    90             with (self.style) { 
     90            with(self.style){ 
    9191                background = '#cccccc' 
    9292                fontSize   = '10px' 
    93                 padding    = '0 5px 0 5px' 
     93                padding    = '0 5px' 
    9494                border     = '0px' 
    9595            } 
    9696        } 
    9797    }; 
    98      
     98 
    9999    var changeStatusView = function(){ 
    100         var self = document.getElementById("SAS_SiteInfoCheck");  
     100        var self = document.getElementById("SAS_SiteInfoCheck"); 
    101101        var regularBG = 'background:#ccffcc;font-size:11px;text-indent:1em;'; 
    102         self.innerHTML = '*pageElement<div style="' + regularBG + '">' + Keeper.data.pageElement + '</div>';  
     102        self.innerHTML = '*pageElement<div style="' + regularBG + '">' + Keeper.data.pageElement + '</div>'; 
    103103        self.innerHTML += '*url<div style="' + regularBG + '">' + Keeper.data.url + '</div>'; 
    104104        self.innerHTML += '*nextLink<div style="' + regularBG + '">' + Keeper.data.nextLink + '</div>'; 
    105         with (self.style) { 
     105        with(self.style){ 
    106106            background = 'white' 
    107107            fontSize   = '11px' 
    108108            padding    = '5px' 
    109109            border     = '1px solid #cccccc' 
    110         }  
     110        } 
    111111    }; 
    112      
     112 
    113113    var viewPopRemove = function(){ 
    114114        if(_switch){ 
     
    119119            checkData(); 
    120120        } 
    121     } 
    122      
     121    }; 
     122 
    123123    var setCache = function(info){ 
    124124        GM_setValue('cacheInfo',info); 
    125125    }; 
    126      
     126 
    127127    var getCache = function(){ 
    128128        return eval(GM_getValue('cacheInfo','[]')); 
    129129    }; 
    130      
     130 
    131131    var clearCache = function(){ 
    132132        GM_setValue('cacheInfo','[]'); 
    133     } 
    134      
     133    }; 
     134 
    135135    var checkData = function(){ 
    136136        var info = getCache(); 
    137137        if(info.length > 0){ 
    138             SearchUrl(info);             
     138            SearchUrl(info); 
    139139        }else{ 
    140140            var opt = { 
     
    146146        } 
    147147    }; 
    148      
     148 
    149149    var getJson = function(res){ 
    150150        clearCache(); 
     
    153153        SearchUrl(info); 
    154154    }; 
    155      
     155 
    156156    GM_registerMenuCommand("SiteInfo View(AutoPagerize) - Check", checkData); 
    157157    GM_registerMenuCommand("SiteInfo View(AutoPagerize) - Clear Cache", clearCache); 
    158158    GM_registerMenuCommand("SiteInfo View(AutoPagerize) - Close/Open ", viewPopRemove); 
    159     setMinibuffer();  
     159    setMinibuffer(); 
    160160})();