Changeset 26646

Show
Ignore:
Timestamp:
12/14/08 03:49:06 (4 years ago)
Author:
drry
Message:
  • @suVene バグごめんなさい。
  • 正規表現を削減・修正しました。
  • ほか。
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/nextlink.js

    r26642 r26646  
    9696            this.siteinfo = [ 
    9797                { 
    98                     url: '^http:\\/\\/192\\.168\\.', 
    99                     nextLink: 'id("next")', 
    100                     pageElement: '//*' 
    101                 }, 
    102                 { 
    103                     url: '^http:\\/\\/localhost', 
     98                    url: '^https?://(?:192\\.168(?:\\.\\d+){2}|localhost)(?::\\d+)?/', 
    10499                    nextLink: 'id("next")', 
    105100                    pageElement: '//*' 
     
    131126 
    132127            for (let i = 0, len = this.siteinfo.length; i < len; i++) { 
    133                 if (url.match(this.siteinfo[i].url) && !/^\^https\?:\/\/\.$/.test(this.siteinfo[i].url)) { 
     128                if (url.match(this.siteinfo[i].url) && this.siteinfo[i].url != '^https?://.') { 
    134129                    this.setCache(url, 
    135130                            ['doc', 'xpath', 'siteinfo'], 
     
    187182        removeMap: function(cmd) { 
    188183            try { 
    189                 if (mappings.hasMap(this.browserModes, cmd)) {; 
     184                if (mappings.hasMap(this.browserModes, cmd)) { 
    190185                    mappings.remove(this.browserModes, cmd); 
    191186                } 
     
    243238                    if (cache.curPage == 1) { 
    244239                        return; 
     240                    } else if (--cache.curPage == 1) { 
     241                        window.content.scrollTo(0, 0); 
    245242                    } else { 
    246                         cache.curPage--; 
    247                         if (cache.curPage == 1) { 
    248                             window.content.scrollTo(0, 0); 
    249                         } else { 
    250                             this.focusPagenavi(context, url, cache.curPage); 
    251                         } 
     243                        this.focusPagenavi(context, url, cache.curPage); 
    252244                    } 
    253245                }), 
     
    270262                    } 
    271263                    if (cache.loadedURLs[reqUrl]) { 
    272                         cache.curPage++; 
    273                         this.focusPagenavi(context, url, cache.curPage); 
     264                        this.focusPagenavi(context, url, ++cache.curPage); 
    274265                        return; 
    275266                    } 
     
    399390            $U.getNodesFromXPath(cache.xpath, doc, function(item) elem = item, this); 
    400391 
    401             var nextUrl = $U.pathToURL(elem, doc); 
    402             var prev = $U.getNodesFromXPath('//a[@rel="prev"] | //link[@rel="prev"]', doc); 
     392            var nextURL = $U.pathToURL(elem, doc); 
     393            var xpath = ['a', 'link'].map(function(e) '//' + e + '[translate(normalize-space(@rel), "EPRV", "eprv")="prev"]') 
     394                                     .join(' | '); 
     395            var prev = $U.getNodesFromXPath(xpath, doc); 
    403396            if (prev.length) { 
    404397                context.setCache(url, 'prev', prev[0]); 
    405398            } 
    406             context.setCache(nextUrl, 'prev', url); 
     399            context.setCache(nextURL, 'prev', url); 
    407400            context.setCache(url, 'next', elem); 
    408401        },