From 6e4b0f41b4cb636164d040133f434db44e568a9e Mon Sep 17 00:00:00 2001 From: suVene Date: Sun, 28 Dec 2008 21:09:43 +0000 Subject: add notifier/subject_wassr.js mod libly.js bugfix. etc. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27534 d0d07461-0603-4401-acd4-de1884942a52 --- notifier/subject_wassr.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 notifier/subject_wassr.js (limited to 'notifier') diff --git a/notifier/subject_wassr.js b/notifier/subject_wassr.js new file mode 100755 index 0000000..5e70752 --- /dev/null +++ b/notifier/subject_wassr.js @@ -0,0 +1,72 @@ +/*** BEGIN LICENSE BLOCK {{{ + Copyright (c) 2008 suVene + + distributable under the terms of an MIT-style license. + http://www.opensource.jp/licenses/mit-license.html +}}} END LICENSE BLOCK ***/ +// PLUGIN_INFO//{{{ +var PLUGIN_INFO = + + {NAME} + Wassr change notice. + Wassr変更通知。 + suVene + 0.1.0 + MIT + 2.0pre + 2.0pre + http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_wassr.js +; +//}}} +(function() { + +var notifier = liberator.plugins.notifier; +if (!notifier) return; + +var libly = notifier.libly; +var $U = libly.$U; +var logger = $U.getLogger('subject_wassr'); + +var URL = 'http://api.wassr.jp/statuses/friends_timeline.json?id='; + +notifier.subject.register(notifier.SubjectHttp, { + interval: 60, + method: 'POST', + options: { + url: '', + headers: null, + extra: {} + }, + preInitialize: function() { + [username, password] = $U.getUserAndPassword('http://wassr.jp', 'http://wassr.jp'); + this.options.url = URL + username + '&page=4'; + this.options.extra.username = username; + this.options.extra.password = password; + logger.log(username + ':' + password); + return (username && password) ? true : false; + }, + parse: function(res) { + if (this.count == 0) return []; // for debug + return $U.evalJson(res.responseText) || []; + }, + diff: function(cache, parsed) + parsed.filter(function(item) + !cache.some(function(c) c.html == item.html)), + buildMessages: function(diff) { + return diff.map($U.bind(this, function(d) { + var html =
+ {d.reply_status_url ?

{'> ' + d.reply_message + ' by ' + d.reply_user_nick}

: ''} +

+ {d.user_login_id} + {d.photo_thumbnail_url ? : ''} + {d.html || ''} +

+
.toString(); + return new notifier.Message('Wassr', html, d.link) + })); + } +}); + +})(); +// vim: set fdm=marker sw=4 ts=4 sts=0 et: + -- cgit v1.2.3