• R/O
  • SSH
  • HTTPS

tsubuyakiticker: コミット


コミットメタ情報

リビジョン16 (tree)
日時2013-03-23 19:43:52
作者mshio

ログメッセージ

bug fix: a) condition of ending loop to write tweets b) miss type of method name

変更サマリ

差分

--- tsubuyakiticker/js/tsubuyakiTicker.js (revision 15)
+++ tsubuyakiticker/js/tsubuyakiTicker.js (nonexistent)
@@ -1,897 +0,0 @@
1-// Generated by CoffeeScript 1.6.2
2-(function() {
3- var Browser, DateFormatter, ListManager, TickerAnimation, TickerData, TickerDomBuilder, TickerDomUtil, TickerDomWriter, TickerSetting, TickerTimer, Tweet, TweetCollector, TweetTextReplacer, checkSwitch, run, tweets, _pub;
4-
5- Browser = (function() {
6- function Browser() {
7- if (window) {
8- this.userAgent = window.navigator.userAgent;
9- }
10- this.names = Browser.names;
11- }
12-
13- Browser.prototype.name = function() {
14- var nm, ua, _i, _len, _ref;
15-
16- if (!this.userAgent) {
17- return 'other';
18- }
19- ua = this.userAgent.toLowerCase();
20- _ref = this.names;
21- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
22- nm = _ref[_i];
23- if ((ua.indexOf(nm)) !== -1) {
24- return nm;
25- }
26- }
27- return 'other';
28- };
29-
30- Browser.prototype.canAcceptIntrinsicWidth = function() {
31- return this.name() === 'chrome';
32- };
33-
34- return Browser;
35-
36- })();
37-
38- Browser.names = ['ie', 'chrome', 'safari', 'gecko', 'opera'];
39-
40- DateFormatter = (function() {
41- function DateFormatter() {
42- this.scenario = [];
43- }
44-
45- DateFormatter.prototype.apply = function(text) {
46- var buf, d, j, r, s, _i, _j, _len, _ref, _ref1;
47-
48- r = [];
49- d = new Date(text);
50- _ref = this.scenario;
51- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
52- s = _ref[_i];
53- if (s[0] === 'put') {
54- r.push(s[1]);
55- } else {
56- if (s[0]) {
57- buf = d[s[0]]();
58- }
59- for (j = _j = 1, _ref1 = s.length; 1 <= _ref1 ? _j < _ref1 : _j > _ref1; j = 1 <= _ref1 ? ++_j : --_j) {
60- if (s[j]) {
61- buf = this[s[j]](buf);
62- }
63- }
64- r.push(buf);
65- }
66- }
67- return r.join('');
68- };
69-
70- DateFormatter.prototype.plus = function(value) {
71- return (parseInt(value)) + 1;
72- };
73-
74- DateFormatter.prototype.fmtZero = function(value) {
75- if ((String(value)).length === 1) {
76- return "0" + value;
77- } else {
78- return value;
79- }
80- };
81-
82- DateFormatter.prototype.getDblFig = function(value) {
83- var s;
84-
85- s = String(value);
86- return s.substring(s.length - 2);
87- };
88-
89- DateFormatter.prototype.compile = function(format) {
90- var c, changeStatus, i, map, p, start, status, _i, _ref;
91-
92- p = [];
93- status = 'normal';
94- start = 0;
95- map = {
96- 'M': 'getMonth',
97- 'D': 'getDate',
98- 'h': 'getHours',
99- 'm': 'getMinutes',
100- 's': 'getSeconds'
101- };
102- changeStatus = function(i) {
103- var len, m;
104-
105- len = i - start;
106- if (status !== c) {
107- switch (status) {
108- case 'normal':
109- if (i !== 0) {
110- p.push(['put', format.substring(start, i)]);
111- }
112- break;
113- case 'Y':
114- if (len === 2) {
115- p.push(['getYear', 'getDblFig']);
116- } else if (len === 4) {
117- p.push(['getFullYear']);
118- } else {
119- p.push(['put', format.substring(start, i)]);
120- }
121- break;
122- default:
123- m = map[status];
124- if (len === 1) {
125- if (status === 'M') {
126- p.push([m, 'plus']);
127- } else {
128- p.push([m]);
129- }
130- } else if (len === 2) {
131- if (status === 'M') {
132- p.push([m, 'plus', 'fmtZero']);
133- } else {
134- p.push([m, 'fmtZero']);
135- }
136- } else {
137- p.push(['put', format.substring(start, i)]);
138- }
139- }
140- return start = i;
141- }
142- };
143- c = null;
144- for (i = _i = 0, _ref = format.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
145- c = format.charAt(i);
146- if (!(c === 'Y' || c === 'M' || c === 'D' || c === 'h' || c === 'm' || c === 's')) {
147- c = 'normal';
148- }
149- changeStatus(i);
150- status = c;
151- }
152- c = '';
153- changeStatus(format.length);
154- return this.scenario = p;
155- };
156-
157- return DateFormatter;
158-
159- })();
160-
161- ListManager = (function() {
162- function ListManager(numUser, _public) {
163- this.numUser = numUser;
164- this._ = _public;
165- this.counter = 0;
166- this.timer = new TickerTimer(this, 'execCheck', 10);
167- this.writer = _public.tickerDomWriter;
168- this.setting = _public.setting;
169- }
170-
171- ListManager.prototype.check = function() {
172- var data, failure, failureCount, i, k, list, num, size, t;
173-
174- data = this._.tickerData;
175- list = data.tweetList;
176- num = data.tweetNum;
177- failure = data.failure;
178- failureCount = (function() {
179- var k, r, v;
180-
181- r = 0;
182- for (k in failure) {
183- v = failure[k];
184- if (v) {
185- r++;
186- }
187- }
188- return r;
189- })();
190- size = 0;
191- for (k in list) {
192- t = list[k];
193- size++;
194- }
195- if (size !== this.numUser - failureCount) {
196- return false;
197- }
198- i =  0;
199- for (k in list) {
200- t = list[k];
201- if (t.length !== num[k]) {
202- return false;
203- }
204- }
205- for (k in failure) {
206- t = failure[k];
207- data.failure[k] = false;
208- }
209- return true;
210- };
211-
212- ListManager.prototype.execCheck = function() {
213- if (!this.check()) {
214- if (++this.counter < 200) {
215- return this.timer.restart(10);
216- } else {
217- return this.writer.generateList(this.setting.responseFailureMessage);
218- }
219- } else {
220- this.writer.cleanup();
221- return this.writer.generateList(null);
222- }
223- };
224-
225- return ListManager;
226-
227- })();
228-
229- TickerAnimation = (function() {
230- function TickerAnimation(span, target, _) {
231- this.span = span;
232- this.target = target;
233- this._ = _;
234- this.interval = this._.setting.interval;
235- this.movingQuantity = this._.setting.movingQuantity;
236- this.speeddown = 0;
237- this.prepare = false;
238- this.timer = new TickerTimer(this, 'move', this.interval);
239- }
240-
241- TickerAnimation.prototype.move = function() {
242- var auto, node, v, w, x, _i, _len, _ref;
243-
244- x = parseInt(this.span.style.left);
245- w = this.span.offsetWidth;
246- if (this.speeddown !== 0) {
247- this.speeddown += this.speeddown;
248- }
249- v = this.movingQuantity - this.speeddown;
250- auto = checkSwitch(this._.setting.autoReload);
251- if (v > 0) {
252- x -= v;
253- if (x < -w) {
254- x = this.target.style.width ? parseInt(this.target.style.width) : this.target.offsetWidth;
255- if (this.span.prepare) {
256- _ref = this.span.prepare;
257- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
258- node = _ref[_i];
259- this.span.appendChild(node);
260- }
261- }
262- this.span.prepare = false;
263- } else if (auto && !this.prepare && x < -w + 250) {
264- this.getTweetsInBackground();
265- }
266- this.span.style.left = x + (this.span.measure || 'px');
267- return this.timer.restart(this.interval);
268- } else {
269- return this.timer.abort();
270- }
271- };
272-
273- TickerAnimation.prototype.getTweetsInBackground = function() {
274- var c, i, l, n, _i, _ref;
275-
276- l = this._.tickerData.userList;
277- n = this._.setting.numberOfRecord;
278- this.prepare = true;
279- c = new TweetCollector(this.target, this._);
280- for (i = _i = 0, _ref = l.length; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
281- c.setCaller(l[i], n, c._numberCode(i));
282- }
283- return new ListManager(l.length);
284- };
285-
286- return TickerAnimation;
287-
288- })();
289-
290- TickerData = (function() {
291- function TickerData(setting) {
292- this.userList = this._makeUserListFrom(setting);
293- this.failure = {};
294- this.tweetList = {};
295- this.tweetNum = {};
296- this.animation = null;
297- this.dateFormatter = null;
298- }
299-
300- TickerData.prototype._makeUserListFrom = function(setting) {
301- var e, it, items, list, s, _i, _len;
302-
303- list = [];
304- s = setting.users;
305- if (!s || s === '') {
306- return [];
307- }
308- items = (s.substring(0, 160)).split(/,\s*/);
309- try {
310- for (_i = 0, _len = items.length; _i < _len; _i++) {
311- it = items[_i];
312- list.push(encodeURI(it));
313- }
314- } catch (_error) {
315- e = _error;
316- }
317- return list;
318- };
319-
320- return TickerData;
321-
322- })();
323-
324- /*
325- TickerDomBuilder
326- --------------------------------------------------
327- A class to make up a DIV element for the tsubuyaki ticker.
328-
329- [usage]
330- STEP 1. get an instance.
331- b = new TickerDomBuilder element, browser
332-
333- STEP 2. add a span with the no-wrap style
334- b.addNoWrapElement()
335- */
336-
337-
338- TickerDomBuilder = (function() {
339- function TickerDomBuilder(target, browser) {
340- this.target = target;
341- this.browser = browser;
342- this.target.style.overflow = 'hidden';
343- this.currentTarget = this.target;
344- }
345-
346- TickerDomBuilder.prototype.addNoWrapElement = function() {
347- var elem, k, style, util, v;
348-
349- util = TickerDomUtil;
350- style = {
351- whiteSpace: 'pre',
352- position: 'relative',
353- left: util.spanLeft(this.target)
354- };
355- elem = null;
356- if (this.browser.canAcceptIntrinsicWidth()) {
357- elem = document.createElement('div');
358- style['width'] = 'intrinsic';
359- } else {
360- elem = document.createElement('span');
361- }
362- for (k in style) {
363- v = style[k];
364- if (v) {
365- elem.style[k] = v;
366- }
367- }
368- this.currentTarget.appendChild(elem);
369- return this.currentTarget = elem;
370- };
371-
372- TickerDomBuilder.prototype.addTextNode = function(text) {
373- var t;
374-
375- t = document.createTextNode(text);
376- return this.currentTarget.appendChild(t);
377- };
378-
379- return TickerDomBuilder;
380-
381- })();
382-
383- TickerDomUtil = {
384- measureOf: function(element) {
385- var reg, w;
386-
387- reg = /^[0-9\.]+\s*([a-zA-Z]+)$/;
388- w = element.style.width;
389- if (w && w.match(reg)) {
390- return w.replace(reg, '$1');
391- } else {
392- return null;
393- }
394- },
395- widthOf: function(element) {
396- var s;
397-
398- s = element.style;
399- if (s.width) {
400- return parseInt(s.width);
401- } else {
402- return element.offsetWidth;
403- }
404- },
405- spanLeft: function(element) {
406- var m, u, w;
407-
408- u = TickerDomUtil;
409- m = u.measureOf(element);
410- w = u.widthOf(element);
411- return w + (m ? m : 'px');
412- }
413- };
414-
415- TickerDomWriter = (function() {
416- function TickerDomWriter(target, _public) {
417- this.target = target;
418- this._ = _public;
419- this.setting = this._.setting;
420- this.tickerData = this._.tickerData;
421- }
422-
423- TickerDomWriter.prototype.cleanup = function() {
424- var nd, nds, nm, _i, _len, _results;
425-
426- nds = this.target.childNodes;
427- _results = [];
428- for (_i = 0, _len = nds.length; _i < _len; _i++) {
429- nd = nds[_i];
430- nm = nd ? nd.tagName : null;
431- if (nm && (nm === 'script' || nm === 'SCRIPT')) {
432- _results.push(this.target.removeChild(nd));
433- } else {
434- _results.push(void 0);
435- }
436- }
437- return _results;
438- };
439-
440- TickerDomWriter.prototype.generateList = function(errorMessage) {
441- var d, node, nodes, _i, _len;
442-
443- nodes = this._listNodes(errorMessage);
444- d = this.target.childNodes[0];
445- if (d.childNodes.length > 0) {
446- return d.prepare = nodes;
447- } else {
448- for (_i = 0, _len = nodes.length; _i < _len; _i++) {
449- node = nodes[_i];
450- d.appendChild(node);
451- }
452- return this.tickerData.animation = new TickerAnimation(d, this.target, this._);
453- }
454- };
455-
456- TickerDomWriter.prototype._listNodes = function(errorMessage) {
457- var list, nodes, showDate, showUser;
458-
459- nodes = null;
460- if (errorMessage) {
461- nodes = this._errorLine(errorMessage);
462- } else {
463- showUser = checkSwitch(this.setting.displayUserID);
464- showDate = checkSwitch(this.setting.displayDateTime);
465- list = this._unitedList();
466- if (list.length > 0) {
467- nodes = this.makeupTweetLine(list, showDate, showUser);
468- } else {
469- nodes = this._errorLine(this.setting.notFoundMessage);
470- }
471- }
472- return nodes;
473- };
474-
475- TickerDomWriter.prototype._errorList = function(errorMessage) {
476- var span, text;
477-
478- span = document.createElement('span');
479- span.setAttribute("class", "tsubu-error");
480- text = document.createTextNode(errorMessage);
481- span.appendChild(text);
482- return [span];
483- };
484-
485- TickerDomWriter.prototype._unitedList = function() {
486- var k, l, t, v, _i, _len, _ref;
487-
488- l = [];
489- _ref = this.tickerData.tweetList;
490- for (k in _ref) {
491- v = _ref[k];
492- for (_i = 0, _len = v.length; _i < _len; _i++) {
493- t = v[_i];
494- l.push(t);
495- }
496- }
497- l.sort(function(a, b) {
498- return b.id - a.id;
499- });
500- return l;
501- };
502-
503- TickerDomWriter.prototype._tweetSpan = function(list) {
504- var span;
505-
506- span = document.createElement('span');
507- span.setAttribute('class', 'tsubu-tweet');
508- span.setAttribute('lang', list.lang);
509- span.innerHTML = list.text;
510- return span;
511- };
512-
513- TickerDomWriter.prototype._datetimeSpan = function(list) {
514- var span, text;
515-
516- span = document.createElement('span');
517- span.setAttribute('class', 'tsubu-datetime');
518- text = document.createTextNode(this._toDateFmt(list.date));
519- span.appendChild(text);
520- return span;
521- };
522-
523- TickerDomWriter.prototype._userSpan = function(list) {
524- var span, text;
525-
526- span = document.createElement('a');
527- span.setAttribute('class', 'tsubu-user');
528- span.setAttribute('href', "http://twitter.com/" + list.user);
529- span.setAttribute('target', '_blank');
530- text = document.createTextNode(list.user);
531- span.appendChild(text);
532- return span;
533- };
534-
535- TickerDomWriter.prototype._intervalSpan = function() {
536- var diams, i, span, _i;
537-
538- span = document.createElement('span');
539- span.setAttribute('class', 'tsubu-sep');
540- diams = [];
541- for (i = _i = 0; _i <= 4; i = ++_i) {
542- diams.push('&nbsp;');
543- }
544- span.innerHTML = diams.join('&diams;');
545- return span;
546- };
547-
548- TickerDomWriter.prototype.makeupTweetLine = function(list, showDatetime, showUser) {
549- var n, nodes, _i, _ref;
550-
551- nodes = [];
552- for (n = _i = 0, _ref = this.tickerData.tweetNum[list[0].user]; 0 <= _ref ? _i <= _ref : _i >= _ref; n = 0 <= _ref ? ++_i : --_i) {
553- nodes.push(this._tweetSpan(list[n]));
554- if (showDatetime || showUser) {
555- nodes.push(document.createTextNode(' ('));
556- }
557- if (showDatetime) {
558- nodes.push(this._datetimeSpan(list[n]));
559- }
560- if (showDatetime && showUser) {
561- nodes.push(document.createTextNode(' '));
562- }
563- if (showUser) {
564- nodes.push(this._userSpan(list[n]));
565- }
566- if (showDatetime || showUser) {
567- nodes.push(document.createTextNode(')'));
568- }
569- if (n !== this.tickerData.tweetNum[list[0].user] - 1) {
570- nodes.push(this._intervalSpan());
571- nodes.push(document.createTextNode(' '));
572- }
573- }
574- return nodes;
575- };
576-
577- TickerDomWriter.prototype._toDateFmt = function(text) {
578- if (!this.tickerData.dateFormatter) {
579- this.tickerData.dateFormatter = new DateFormatter();
580- this.tickerData.dateFormatter.compile(this.setting.dateFormat);
581- }
582- return this.tickerData.dateFormatter.apply(text);
583- };
584-
585- return TickerDomWriter;
586-
587- })();
588-
589- TickerSetting = (function() {
590- function TickerSetting(userSetting) {
591- var k, s, v;
592-
593- s = this._mergeUserSetting(userSetting);
594- for (k in s) {
595- v = s[k];
596- this[k] = v;
597- }
598- }
599-
600- TickerSetting.prototype._mergeUserSetting = function(setting) {
601- var k, s, v;
602-
603- s = TickerSetting.defaultSetting;
604- for (k in s) {
605- v = s[k];
606- setting[k] = setting[k] || s[k];
607- }
608- return setting;
609- };
610-
611- return TickerSetting;
612-
613- })();
614-
615- TickerSetting.defaultSetting = {
616- users: null,
617- numberOfRecord: 5,
618- interval: 100,
619- movingQuantity: 7,
620- dateFormat: 'YYYY/MM/DD hh:mm',
621- displayUserID: 'on',
622- displayDateTime: 'on',
623- autoReload: 'off',
624- notFoundMessage: '[INFO] NO TWEET WAS FOUND',
625- responseFailureMessage: '[TIMEOUT] SOME RESPONSES WERE NOT RETURNED'
626- };
627-
628- TickerTimer = (function() {
629- function TickerTimer(target, method, timeout) {
630- this.target = target;
631- this.method = method;
632- this.id = this.setTimer(timeout);
633- }
634-
635- TickerTimer.prototype.abort = function() {
636- return clearTimeout(this.id);
637- };
638-
639- TickerTimer.prototype.restart = function(timeout) {
640- return this.id = this.setTimer(timeout);
641- };
642-
643- TickerTimer.prototype.setTimer = function(timeout) {
644- var f, m, t;
645-
646- t = this.target;
647- m = this.method;
648- f = function() {
649- if (t[m]()) {
650- return t[m];
651- }
652- };
653- return setTimeout(f, timeout);
654- };
655-
656- return TickerTimer;
657-
658- })();
659-
660- _pub = null;
661-
662- tweets = function(result, code) {
663- var d, l, r, rec, _i, _len, _results;
664-
665- d = _pub.tickerData;
666- r = result.results;
667- if (r.length > 0) {
668- d.tweetList[r[0].from_user] = [];
669- d.tweetNum[r[0].from_user] = r.length;
670- l = d.tweetList[r[0].from_user];
671- _results = [];
672- for (_i = 0, _len = r.length; _i < _len; _i++) {
673- rec = r[_i];
674- _results.push(l.push(new Tweet(rec.from_user, rec.text, rec.id, rec.created_at, rec.iso_language_code)));
675- }
676- return _results;
677- } else {
678- return d.failure[code] = true;
679- }
680- };
681-
682- checkSwitch = function(value) {
683- return value.toLowerCase() !== 'off';
684- };
685-
686- run = function() {
687- var b, browser, c, target;
688-
689- browser = new Browser();
690- target = document.getElementById('tsubuyakiTicker');
691- b = new TickerDomBuilder(target, browser);
692- b.addNoWrapElement();
693- _pub = window.TsubuyakiTicker;
694- _pub.tickerDomWriter = new TickerDomWriter(target, _pub);
695- c = new TweetCollector(target, _pub);
696- c.collect();
697- return new ListManager(_pub.tickerData.userList.length, _pub);
698- };
699-
700- if (window) {
701- window.TsubuyakiTicker = function(setting) {
702- _pub = window.TsubuyakiTicker;
703- _pub.tweets =  tweets;
704- _pub.callbacks = {};
705- _pub.setting = new TickerSetting(setting);
706- return _pub.tickerData = new TickerData(_pub.setting);
707- };
708- if (window.addEventListener) {
709- window.addEventListener('load', run, false);
710- } else if (window.attachEvent) {
711- window.attachEvent('onload', run);
712- }
713- }
714-
715- Tweet = (function() {
716- function Tweet(user, text, id, date, lang) {
717- this.user = user;
718- this.id = id;
719- this.date = date;
720- this.lang = lang;
721- this.text = this._linkedText(text);
722- }
723-
724- Tweet.prototype._linkedText = function(text) {
725- var k, keys, replacer, v, _i, _len, _ref;
726-
727- keys = [];
728- _ref = TweetTextReplacer.REGEXPS;
729- for (k in _ref) {
730- v = _ref[k];
731- keys.push(k);
732- }
733- replacer = new TweetTextReplacer;
734- for (_i = 0, _len = keys.length; _i < _len; _i++) {
735- k = keys[_i];
736- text = replacer[k](text);
737- }
738- return text;
739- };
740-
741- return Tweet;
742-
743- })();
744-
745- TweetTextReplacer = (function() {
746- function TweetTextReplacer() {
747- this.reg = TweetTextReplacer.REGEXPS;
748- }
749-
750- TweetTextReplacer.prototype.linkTag = function(href, content) {
751- return "<a href=\"" + href + "\" target=\"_blank\">" + content + "</a>";
752- };
753-
754- TweetTextReplacer.prototype.link = function(text) {
755- return text.replace(this.reg['link'], this.linkTag('$1', '$1'));
756- };
757-
758- TweetTextReplacer.prototype.account0 = function(text) {
759- var href;
760-
761- href = "http://twitter.com/$2";
762- return text.replace(this.reg['account0'], "$1" + (this.linkTag(href, '$2')));
763- };
764-
765- TweetTextReplacer.prototype.account1 = function(text) {
766- var href;
767-
768- href = "http://twitter.com/$1";
769- return text.replace(this.reg['account1'], this.linkTag(href, '$1'));
770- };
771-
772- TweetTextReplacer.prototype.hash0 = function(text) {
773- var href;
774-
775- href = "http://twitter.com/search?q=$2";
776- return text.replace(this.reg['hash0'], "$1" + (this.linkTag(href, '$2')));
777- };
778-
779- TweetTextReplacer.prototype.hash1 = function(text) {
780- var href;
781-
782- href = "http://twitter.com/search?q=$1";
783- return text.replace(this.reg['hash1'], this.linkTag(href, '$1'));
784- };
785-
786- return TweetTextReplacer;
787-
788- })();
789-
790- TweetTextReplacer.REGEXPS = {
791- link: /(http:\/\/[0-9A-Za-z\.\/_\?&\~\-\=\#\:%]+)/g,
792- account0: /(\s|[^a-zA-Z0-9])(@[a-zA-Z0-9_]+)/g,
793- account1: /^(@[a-zA-Z0-9_]+)/,
794- hash0: /(\s)(\#[a-zA-Z0-9_]+)/g,
795- hash1: /^(\#[a-zA-Z0-9_]+)/
796- };
797-
798- TweetCollector = (function() {
799- function TweetCollector(target, _) {
800- this.target = target;
801- this._ = _;
802- }
803-
804- TweetCollector.prototype.collect = function() {
805- var i, num, user, _i, _len, _ref, _results;
806-
807- i = -1;
808- num = this._.setting.numberOfRecord;
809- _ref = this._.tickerData.userList;
810- _results = [];
811- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
812- user = _ref[_i];
813- _results.push(this.setCallerAndCallback(++i, num));
814- }
815- return _results;
816- };
817-
818- TweetCollector.prototype.setCallerAndCallback = function(index, numberOfRecord) {
819- var c, _;
820-
821- c = this._numberCode(index);
822- _ = this._;
823- this._.tickerData.failure[c] = false;
824- this._.callbacks[c] = (function() {
825- var p;
826-
827- p = c;
828- return function(r) {
829- return _.tweets(r, p);
830- };
831- })();
832- return this.setCaller(this._.tickerData.userList[index], numberOfRecord, c);
833- };
834-
835- TweetCollector.prototype.setCaller = function(account, numOfRec, numCode) {
836- var s;
837-
838- s = document.createElement('script');
839- s.type = 'text/javascript';
840- s.src = this._makeupAPIURL({
841- query: "from%3A" + account,
842- numberOfRecord: numOfRec,
843- callback: "TsubuyakiTicker.callbacks." + numCode
844- });
845- return this.target.appendChild(s);
846- };
847-
848- TweetCollector.prototype._makeupAPIURL = function(paramSetting) {
849- var params, s;
850-
851- s = TweetCollector.setting;
852- params = this._queryString(paramSetting, s.paramKeys);
853- return "" + s.host + s.restAPI + "?" + params;
854- };
855-
856- TweetCollector.prototype._queryString = function(paramSetting, keys) {
857- var items, k, v;
858-
859- items = [];
860- for (k in paramSetting) {
861- v = paramSetting[k];
862- items.push("" + keys[k] + "=" + v);
863- }
864- return items.join('&');
865- };
866-
867- TweetCollector.prototype._numberCode = function(num) {
868- var n, s, v;
869-
870- n = num;
871- s = [];
872- while (true) {
873- v = n % 10;
874- n = (n - v) / 10;
875- s.push(String.fromCharCode(v + 0x61));
876- if (n <= 0) {
877- break;
878- }
879- }
880- return s.join('');
881- };
882-
883- return TweetCollector;
884-
885- })();
886-
887- TweetCollector.setting = {
888- host: "http://search.twitter.com/",
889- restAPI: "search.json",
890- paramKeys: {
891- query: "q",
892- numberOfRecord: "rpp",
893- callback: "callback"
894- }
895- };
896-
897-}).call(this);
--- tsubuyakiticker/js/tsubuyakiTicker.mini.js (revision 15)
+++ tsubuyakiticker/js/tsubuyakiTicker.mini.js (nonexistent)
@@ -1,23 +0,0 @@
1-(function(){var r,x,s,y,z,A,t,B,u,v,C,n,p,q,w,D,k;r=function(){function b(){window&&(this.userAgent=window.navigator.userAgent);this.names=b.names}b.prototype.name=function(){var a,c,d,b,e;if(!this.userAgent)return"other";c=this.userAgent.toLowerCase();e=this.names;d=0;for(b=e.length;d<b;d++)if(a=e[d],-1!==c.indexOf(a))return a;return"other"};b.prototype.canAcceptIntrinsicWidth=function(){return"chrome"===this.name()};return b}();r.names=["ie","chrome","safari","gecko","opera"];x=function(){function b(){this.scenario=
2-[]}b.prototype.apply=function(a){var c,d,b,e,g,h,k,m,l;b=[];a=new Date(a);m=this.scenario;g=0;for(k=m.length;g<k;g++)if(e=m[g],"put"===e[0])b.push(e[1]);else{e[0]&&(c=a[e[0]]());d=h=1;for(l=e.length;1<=l?h<l:h>l;d=1<=l?++h:--h)e[d]&&(c=this[e[d]](c));b.push(c)}return b.join("")};b.prototype.plus=function(a){return parseInt(a)+1};b.prototype.fmtZero=function(a){return 1===String(a).length?"0"+a:a};b.prototype.getDblFig=function(a){a=String(a);return a.substring(a.length-2)};b.prototype.compile=function(a){var c,
3-d,b,e,g,h,k,m,l;g=[];k="normal";h=0;e={M:"getMonth",D:"getDate",h:"getHours",m:"getMinutes",s:"getSeconds"};d=function(d){var b,f;b=d-h;if(k!==c){switch(k){case "normal":0!==d&&g.push(["put",a.substring(h,d)]);break;case "Y":2===b?g.push(["getYear","getDblFig"]):4===b?g.push(["getFullYear"]):g.push(["put",a.substring(h,d)]);break;default:f=e[k],1===b?"M"===k?g.push([f,"plus"]):g.push([f]):2===b?"M"===k?g.push([f,"plus","fmtZero"]):g.push([f,"fmtZero"]):g.push(["put",a.substring(h,d)])}return h=d}};
4-c=null;b=m=0;for(l=a.length;0<=l?m<l:m>l;b=0<=l?++m:--m)c=a.charAt(b),"Y"===c||("M"===c||"D"===c||"h"===c||"m"===c||"s"===c)||(c="normal"),d(b),k=c;c="";d(a.length);return this.scenario=g};return b}();s=function(){function b(a,c){this.numUser=a;this._=c;this.counter=0;this.timer=new v(this,"execCheck",10);this.writer=c.tickerDomWriter;this.setting=c.setting}b.prototype.check=function(){var a,c,d,b,e,g,h;a=this._.tickerData;b=a.tweetList;e=a.tweetNum;c=a.failure;var k;h=0;for(g in c)(k=c[g])&&h++;
5-g=0;for(d in b)g++;if(g!==this.numUser-h)return!1;for(d in b)if(h=b[d],h.length!==e[d])return!1;for(d in c)a.failure[d]=!1;return!0};b.prototype.execCheck=function(){return this.check()?(this.writer.cleanup(),this.writer.generateList(null)):200>++this.counter?this.timer.restart(10):this.writer.generateList(this.setting.responseFailureMessage)};return b}();y=function(){function b(a,c,d){this.span=a;this.target=c;this._=d;this.interval=this._.setting.interval;this.movingQuantity=this._.setting.movingQuantity;
6-this.speeddown=0;this.prepare=!1;this.timer=new v(this,"move",this.interval)}b.prototype.move=function(){var a,c,d,b,e;b=parseInt(this.span.style.left);d=this.span.offsetWidth;0!==this.speeddown&&(this.speeddown+=this.speeddown);c=this.movingQuantity-this.speeddown;a=q(this._.setting.autoReload);if(0<c){b-=c;if(b<-d){b=this.target.style.width?parseInt(this.target.style.width):this.target.offsetWidth;if(this.span.prepare){e=this.span.prepare;c=0;for(d=e.length;c<d;c++)a=e[c],this.span.appendChild(a)}this.span.prepare=
7-!1}else a&&(!this.prepare&&b<-d+250)&&this.getTweetsInBackground();this.span.style.left=b+(this.span.measure||"px");return this.timer.restart(this.interval)}return this.timer.abort()};b.prototype.getTweetsInBackground=function(){var a,c,d,b,e,g;d=this._.tickerData.userList;b=this._.setting.numberOfRecord;this.prepare=!0;a=new n(this.target,this._);c=e=0;for(g=d.length;0<=g?e<=g:e>=g;c=0<=g?++e:--e)a.setCaller(d[c],b,a._numberCode(c));return new s(d.length)};return b}();z=function(){function b(a){this.userList=
8-this._makeUserListFrom(a);this.failure={};this.tweetList={};this.tweetNum={};this.dateFormatter=this.animation=null}b.prototype._makeUserListFrom=function(a){var c,b,f,e;b=[];a=a.users;if(!a||""===a)return[];a=a.substring(0,160).split(/,\s*/);try{f=0;for(e=a.length;f<e;f++)c=a[f],b.push(encodeURI(c))}catch(g){}return b};return b}();A=function(){function b(a,c){this.target=a;this.browser=c;this.target.style.overflow="hidden";this.currentTarget=this.target}b.prototype.addNoWrapElement=function(){var a,
9-c,b,f;b={whiteSpace:"pre",position:"relative",left:t.spanLeft(this.target)};this.browser.canAcceptIntrinsicWidth()?(a=document.createElement("div"),b.width="intrinsic"):a=document.createElement("span");for(c in b)(f=b[c])&&(a.style[c]=f);this.currentTarget.appendChild(a);return this.currentTarget=a};b.prototype.addTextNode=function(a){a=document.createTextNode(a);return this.currentTarget.appendChild(a)};return b}();t={measureOf:function(b){var a;a=/^[0-9\.]+\s*([a-zA-Z]+)$/;return(b=b.style.width)&&
10-b.match(a)?b.replace(a,"$1"):null},widthOf:function(b){var a;a=b.style;return a.width?parseInt(a.width):b.offsetWidth},spanLeft:function(b){var a,c;c=t;a=c.measureOf(b);return c.widthOf(b)+(a?a:"px")}};B=function(){function b(a,c){this.target=a;this._=c;this.setting=this._.setting;this.tickerData=this._.tickerData}b.prototype.cleanup=function(){var a,c,b,f,e,g;c=this.target.childNodes;g=[];f=0;for(e=c.length;f<e;f++)(b=(a=c[f])?a.tagName:null)&&("script"===b||"SCRIPT"===b)?g.push(this.target.removeChild(a)):
11-g.push(void 0);return g};b.prototype.generateList=function(a){var c,b,f,e;b=this._listNodes(a);a=this.target.childNodes[0];if(0<a.childNodes.length)return a.prepare=b;f=0;for(e=b.length;f<e;f++)c=b[f],a.appendChild(c);return this.tickerData.animation=new y(a,this.target,this._)};b.prototype._listNodes=function(a){var c,b;a?a=this._errorLine(a):(b=q(this.setting.displayUserID),c=q(this.setting.displayDateTime),a=this._unitedList(),a=0<a.length?this.makeupTweetLine(a,c,b):this._errorLine(this.setting.notFoundMessage));
12-return a};b.prototype._errorList=function(a){var c;c=document.createElement("span");c.setAttribute("class","tsubu-error");a=document.createTextNode(a);c.appendChild(a);return[c]};b.prototype._unitedList=function(){var a,c,b,f,e,g,h;c=[];h=this.tickerData.tweetList;for(a in h){f=h[a];e=0;for(g=f.length;e<g;e++)b=f[e],c.push(b)}c.sort(function(a,c){return c.id-a.id});return c};b.prototype._tweetSpan=function(a){var c;c=document.createElement("span");c.setAttribute("class","tsubu-tweet");c.setAttribute("lang",
13-a.lang);c.innerHTML=a.text;return c};b.prototype._datetimeSpan=function(a){var c;c=document.createElement("span");c.setAttribute("class","tsubu-datetime");a=document.createTextNode(this._toDateFmt(a.date));c.appendChild(a);return c};b.prototype._userSpan=function(a){var c;c=document.createElement("a");c.setAttribute("class","tsubu-user");c.setAttribute("href","http://twitter.com/"+a.user);c.setAttribute("target","_blank");a=document.createTextNode(a.user);c.appendChild(a);return c};b.prototype._intervalSpan=
14-function(){var a,c,b;c=document.createElement("span");c.setAttribute("class","tsubu-sep");a=[];for(b=0;4>=b;++b)a.push("&nbsp;");c.innerHTML=a.join("&diams;");return c};b.prototype.makeupTweetLine=function(a,c,b){var f,e,g,h;e=[];f=g=0;for(h=this.tickerData.tweetNum[a[0].user];0<=h?g<=h:g>=h;f=0<=h?++g:--g)e.push(this._tweetSpan(a[f])),(c||b)&&e.push(document.createTextNode(" (")),c&&e.push(this._datetimeSpan(a[f])),c&&b&&e.push(document.createTextNode(" ")),b&&e.push(this._userSpan(a[f])),(c||b)&&
15-e.push(document.createTextNode(")")),f!==this.tickerData.tweetNum[a[0].user]-1&&(e.push(this._intervalSpan()),e.push(document.createTextNode(" ")));return e};b.prototype._toDateFmt=function(a){this.tickerData.dateFormatter||(this.tickerData.dateFormatter=new x,this.tickerData.dateFormatter.compile(this.setting.dateFormat));return this.tickerData.dateFormatter.apply(a)};return b}();u=function(){function b(a){var c,b;a=this._mergeUserSetting(a);for(c in a)b=a[c],this[c]=b}b.prototype._mergeUserSetting=
16-function(a){var c,d;d=b.defaultSetting;for(c in d)a[c]=a[c]||d[c];return a};return b}();u.defaultSetting={users:null,numberOfRecord:5,interval:100,movingQuantity:7,dateFormat:"YYYY/MM/DD hh:mm",displayUserID:"on",displayDateTime:"on",autoReload:"off",notFoundMessage:"[INFO] NO TWEET WAS FOUND",responseFailureMessage:"[TIMEOUT] SOME RESPONSES WERE NOT RETURNED"};v=function(){function b(a,c,b){this.target=a;this.method=c;this.id=this.setTimer(b)}b.prototype.abort=function(){return clearTimeout(this.id)};
17-b.prototype.restart=function(a){return this.id=this.setTimer(a)};b.prototype.setTimer=function(a){var b,d;d=this.target;b=this.method;return setTimeout(function(){if(d[b]())return d[b]},a)};return b}();k=null;D=function(b,a){var c,d,f,e,g,h;c=k.tickerData;d=b.results;if(0<d.length){c.tweetList[d[0].from_user]=[];c.tweetNum[d[0].from_user]=d.length;c=c.tweetList[d[0].from_user];h=[];e=0;for(g=d.length;e<g;e++)f=d[e],h.push(c.push(new C(f.from_user,f.text,f.id,f.created_at,f.iso_language_code)));return h}return c.failure[a]=
18-!0};q=function(b){return"off"!==b.toLowerCase()};w=function(){var b,a;b=new r;a=document.getElementById("tsubuyakiTicker");(new A(a,b)).addNoWrapElement();k=window.TsubuyakiTicker;k.tickerDomWriter=new B(a,k);(new n(a,k)).collect();return new s(k.tickerData.userList.length,k)};window&&(window.TsubuyakiTicker=function(b){k=window.TsubuyakiTicker;k.tweets=D;k.callbacks={};k.setting=new u(b);return k.tickerData=new z(k.setting)},window.addEventListener?window.addEventListener("load",w,!1):window.attachEvent&&
19-window.attachEvent("onload",w));C=function(){function b(a,b,d,f,e){this.user=a;this.id=d;this.date=f;this.lang=e;this.text=this._linkedText(b)}b.prototype._linkedText=function(a){var b,d,f,e,g;d=[];f=p.REGEXPS;for(b in f)d.push(b);f=new p;e=0;for(g=d.length;e<g;e++)b=d[e],a=f[b](a);return a};return b}();p=function(){function b(){this.reg=b.REGEXPS}b.prototype.linkTag=function(a,b){return'<a href="'+a+'" target="_blank">'+b+"</a>"};b.prototype.link=function(a){return a.replace(this.reg.link,this.linkTag("$1",
20-"$1"))};b.prototype.account0=function(a){return a.replace(this.reg.account0,"$1"+this.linkTag("http://twitter.com/$2","$2"))};b.prototype.account1=function(a){return a.replace(this.reg.account1,this.linkTag("http://twitter.com/$1","$1"))};b.prototype.hash0=function(a){return a.replace(this.reg.hash0,"$1"+this.linkTag("http://twitter.com/search?q=$2","$2"))};b.prototype.hash1=function(a){return a.replace(this.reg.hash1,this.linkTag("http://twitter.com/search?q=$1","$1"))};return b}();p.REGEXPS={link:/(http:\/\/[0-9A-Za-z\.\/_\?&\~\-\=\#\:%]+)/g,
21-account0:/(\s|[^a-zA-Z0-9])(@[a-zA-Z0-9_]+)/g,account1:/^(@[a-zA-Z0-9_]+)/,hash0:/(\s)(\#[a-zA-Z0-9_]+)/g,hash1:/^(\#[a-zA-Z0-9_]+)/};n=function(){function b(a,b){this.target=a;this._=b}b.prototype.collect=function(){var a,b,d,f,e;a=-1;b=this._.setting.numberOfRecord;f=this._.tickerData.userList;e=[];d=0;for(f=f.length;d<f;d++)e.push(this.setCallerAndCallback(++a,b));return e};b.prototype.setCallerAndCallback=function(a,b){var d,f;d=this._numberCode(a);f=this._;this._.tickerData.failure[d]=!1;this._.callbacks[d]=
22-function(){return function(a){return f.tweets(a,d)}}();return this.setCaller(this._.tickerData.userList[a],b,d)};b.prototype.setCaller=function(a,b,d){var f;f=document.createElement("script");f.type="text/javascript";f.src=this._makeupAPIURL({query:"from%3A"+a,numberOfRecord:b,callback:"TsubuyakiTicker.callbacks."+d});return this.target.appendChild(f)};b.prototype._makeupAPIURL=function(a){var c;c=b.setting;a=this._queryString(a,c.paramKeys);return""+c.host+c.restAPI+"?"+a};b.prototype._queryString=
23-function(a,b){var d,f,e;d=[];for(f in a)e=a[f],d.push(""+b[f]+"="+e);return d.join("&")};b.prototype._numberCode=function(a){var b,d;for(b=[];!(d=a%10,a=(a-d)/10,b.push(String.fromCharCode(d+97)),0>=a););return b.join("")};return b}();n.setting={host:"http://search.twitter.com/",restAPI:"search.json",paramKeys:{query:"q",numberOfRecord:"rpp",callback:"callback"}}}).call(this);
--- tsubuyakiticker/src/tickerDomWriter.coffee (revision 15)
+++ tsubuyakiticker/src/tickerDomWriter.coffee (revision 16)
@@ -42,7 +42,7 @@
4242 nodes = this._errorLine @setting.notFoundMessage
4343 return nodes
4444
45- _errorList: (errorMessage) ->
45+ _errorLine: (errorMessage) ->
4646 span = document.createElement 'span'
4747 span.setAttribute "class", "tsubu-error"
4848 text = document.createTextNode errorMessage
@@ -91,7 +91,7 @@
9191
9292 makeupTweetLine: (list, showDatetime, showUser) ->
9393 nodes = []
94- for n in [0..@tickerData.tweetNum[list[0].user]]
94+ for n in [0...@tickerData.tweetNum[list[0].user]]
9595 nodes.push this._tweetSpan list[n]
9696 nodes.push document.createTextNode ' (' if showDatetime or showUser
9797 nodes.push this._datetimeSpan list[n] if showDatetime
旧リポジトリブラウザで表示