diff options
| author | suVene | 2008-12-07 22:52:49 +0000 | 
|---|---|---|
| committer | suVene | 2008-12-07 22:52:49 +0000 | 
| commit | cc6d860ff13ec4ba88cd29b4182076c24539a99d (patch) | |
| tree | 7fb94c8e50e3d3e0d818500dac38c2365191e9aa /notifier | |
| parent | c7ecf6edd5a67cac55a9313827886b40ee42bf52 (diff) | |
| download | vimperator-plugins-cc6d860ff13ec4ba88cd29b4182076c24539a99d.tar.bz2 | |
*libty.js bug fix.
*それに伴うmulti_requester.jsの修正
*subject_test.js rename to subject_hatelabo_bottle.js(途中)
*etc.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26085 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'notifier')
| -rw-r--r-- | notifier/observer_growl.js | 4 | ||||
| -rw-r--r-- | notifier/subject_hatelabo_bottle.js | 77 | ||||
| -rw-r--r-- | notifier/subject_test.js | 52 | 
3 files changed, 79 insertions, 54 deletions
diff --git a/notifier/observer_growl.js b/notifier/observer_growl.js index 2875909..166e1ab 100644 --- a/notifier/observer_growl.js +++ b/notifier/observer_growl.js @@ -17,8 +17,8 @@  var notifier = liberator.plugins.notifier;  if (!notifier) return; -var lib = notifier.lib; -var $U = lib.$U; +var libly = notifier.libly; +var $U = libly.$U;  var logger = $U.getLogger('observer_growl');  var Growl = function() {//{{{ diff --git a/notifier/subject_hatelabo_bottle.js b/notifier/subject_hatelabo_bottle.js new file mode 100644 index 0000000..9c4914d --- /dev/null +++ b/notifier/subject_hatelabo_bottle.js @@ -0,0 +1,77 @@ +/** + * notifier.js plugin subject + * @name            subject_hatena_bottle.js + * @description     notify if hatena bottle changed. + * @description-ja  はてなボトルの変更通知。 + * @author          suVene suvene@zeromemory.info + * @version         0.1.0 + * Last Change:     08-Dec-2008. + */ +(function() { + +var notifier = liberator.plugins.notifier; +if (!notifier) return; + +var libly = notifier.libly; +var $U = libly.$U; +var logger = $U.getLogger('subject_hatelabo_bottle'); + +var URL = 'http://bottle.hatelabo.jp'; + +notifier.subject.register({ +    interval: 30, +    initialize: function() { +        this.count = 0; +        this.initialized = false; +        this.cache; + +        var req = new libly.Request(URL); +        req.addEventListener('onSuccess', $U.bind(this, function(res) { +            logger.log('initialized'); +            this.cache = this.parse(res); +            if (this.cache) +                this.initialized = true; +        })); +        req.get(); +    }, +    parse: function(res) { + +        var ret, dom; + +        if (!res.isSuccess() || res.responseText == '') return ret; + +        dom = res.getHTMLDocument('id("body")//div[contains(concat(" ", @class, " "), " entry ")]'); +        if (!dom) return ret; + +        ret = []; +        for (let i = 0, len < dom.childNodes.length; i < len; i++) { +            ret.push(dom.childNodes[i]); +        } + +        return ret; +    }, +    check: function() { + +        if (!this.initialized) return; + +        this.count++; +        logger.log('check'); +        var req = new libly.Request(URL); +        req.addEventListener('onSuccess', $U.bind(this, function(res) { +            var text = res.responseText; +            logger.log('success!! '); +            var message = new notifier.Message('TEST', text); +            this.notify(message); + +            if (this.count == 5) { +                notifier.subject.unregister(this); +                this.count = 0; +            } +        })); +        req.get(); +    } +}); + +})(); +// vim: set fdm=marker sw=4 ts=4 sts=0 et: + diff --git a/notifier/subject_test.js b/notifier/subject_test.js deleted file mode 100644 index b5689c6..0000000 --- a/notifier/subject_test.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * notifier.js plugin subject - * @name            subject_test.js - * @description     notify if ... - * @description-ja  ... の時ポップアップ通知。 - * @author          suVene suvene@zeromemory.info - * @version         0.1.0 - * Last Change:     07-Dec-2008. - */ -(function() { - -var notifier = liberator.plugins.notifier; -if (!notifier) return; - -var lib = notifier.lib; -var $U = lib.$U; -var logger = $U.getLogger('subject_test'); - -notifier.subject.register({ -    interval: 3, -    initialize: function() { -        logger.log('initialize'); -        this.count = 0; -    }, -    check: function() { -        this.count++; -        logger.log('check'); -        var req = new lib.Request( -            'http://localhost:8080/index.html', -            null,  // headers {} -            { -                encode: 'shift_jis' -            } -        ); -        req.addEventListener('onSuccess', $U.bind(this, function(res) { -            var text = res.responseText; -            logger.log('success!! '); -            var message = new notifier.Message('TEST', text); -            this.notify(message); - -            if (this.count == 5) { -                notifier.subject.unregister(this); -                this.count = 0; -            } -        })); -        req.get(); -    } -}); - -})(); -// vim: set fdm=marker sw=4 ts=4 sts=0 et: -  | 
