Changeset 27459

Show
Ignore:
Timestamp:
12/26/08 22:20:40 (4 years ago)
Author:
suVene
Message:

wedata local cache.
etc.

Location:
lang/javascript/vimperator-plugins/trunk
Files:
3 modified

Legend:

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

    r27457 r27459  
    524524        if (store && store.get('data') && new Date(store.get('expire')) > new Date()) { 
    525525            logger.log('return cache. '); 
    526             store.get('data').forEach(function(item) itemCallback(item)); 
    527             finalCallback(true, store.get('data')); 
     526            store.get('data').forEach(function(item) { if (typeof itemCallback == 'function') itemCallback(item); }); 
     527            if (typeof finalCallback == 'function')  
     528                finalCallback(true, store.get('data')); 
    528529            return; 
    529530        } 
     
    532533            if (cache) { 
    533534                logger.log('return cache. -> ' + msg); 
    534                 cache.forEach(function(item) itemCallback(item)); 
    535                 finalCallback(true, cache); 
     535                cache.forEach(function(item) { if (typeof itemCallback == 'function') itemCallback(item); }); 
     536                if (typeof finalCallback == 'function')  
     537                    finalCallback(true, cache); 
    536538            } else { 
    537                 finalCallback(false, msg); 
     539                if (typeof finalCallback == 'function') 
     540                    finalCallback(false, msg); 
    538541            } 
    539542        } 
     
    554557            store.set('data', json); 
    555558            store.save(); 
    556             json.forEach(function(item) itemCallback(item)); 
    557             finalCallback(true, json); 
     559            json.forEach(function(item) { if (typeof itemCallback == 'function') itemCallback(item); }); 
     560            if (typeof finalCallback == 'function') 
     561                finalCallback(true, json); 
    558562        })); 
    559563        req.addEventListener('onFailure', function() errDispatcher('onFailure')); 
  • lang/javascript/vimperator-plugins/trunk/multi_requester.js

    r27456 r27459  
    1919    <detail><![CDATA[ 
    2020== Needs Library == 
    21 - _libly.js(ver.0.1.11) 
     21- _libly.js(ver.0.1.15) 
    2222  @see http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/_libly.js 
    2323 
  • lang/javascript/vimperator-plugins/trunk/nextlink.js

    r27241 r27459  
    1212    <description lang="ja">AutoPagerize 用の XPath より "[[", "]]" をマッピングします。</description> 
    1313    <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author> 
    14     <version>0.2.9</version> 
     14    <version>0.2.10</version> 
    1515    <license>MIT</license> 
    1616    <minVersion>1.2</minVersion> 
     
    1919    <detail><![CDATA[ 
    2020== Needs Library == 
    21 - _libly.js(ver.0.1.11) 
     21- _libly.js(ver.0.1.15) 
    2222  @see http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/_libly.js 
    2323 
     
    7878    initialize: function(pager) { 
    7979 
    80         this.WEDATA_AUTOPAGERIZE = 'http://wedata.net/databases/AutoPagerize/items.json'; 
    8180        this.initialized = false; 
    8281        this.isCurOriginalMap = true; 
     
    8786        this.is2_0later = config.autocommands.some(function ([k, v]) k == 'DOMLoad'); // toriaezu 
    8887 
    89         var req = new libly.Request(this.WEDATA_AUTOPAGERIZE); 
    90         req.addEventListener('onSuccess', $U.bind(this, 
    91             function(res) { 
    92                 var json = $U.evalJson(res.responseText); 
    93                 if (!json) return; 
    94                 this.siteinfo = json.map(function(item) item.data) 
     88        var wedata = new libly.Wedata('AutoPagerize'); 
     89        wedata.getItems(24 * 60 * 60 * 1000, null, 
     90            $U.bind(this, function(isSuccess, data) { 
     91                if (!isSuccess) return; 
     92                this.siteinfo = data.map(function(item) item.data) 
    9593                                .sort(function(a, b) b.url.length - a.url.length); // sort url.length desc 
    9694                this.initialized = true; 
    97             } 
    98         )); 
    99         req.get(); 
     95            }) 
     96        ); 
    10097        // for debug 
    10198        /*