Twitter議事録

さっそく最小構成TemplateEngineというかただの変数展開 - 文殊堂を使ってみた。
jQueryAutopagerizeとの併用推奨。
議論参加者の発言をfavoっておいてFavoritesのページから議事録取得をすると良いと思う。


以下のJavaScriptを流すとエントリをクリックして隠せるようになるので、
議論と関係ないエントリをどんどんクリックして隠していく。

(function($){
	$('#container .doing tr.hentry')
		.each(function(){
				$(this).one('click',function(){$(this).hide()});
			});
})(jQuery);

次に、以下のJavaScriptを流すと、
各エントリの内容を無名関数の第二引数で指定した書式で、
画面上に作成したtextareaに出力するので、
貼り付けたいところにコピペする。
(例ははてダの表組み記法)
"close"をクリックするとtextareaを消せる。

(function($,templateStr){
	var MiniTemplate = function(template){
			this.template = eval(['([\'',template.replace(/\$\{([^${}]+)\}/g,'\',{key:\'$1\'},\''),'\'])'].join(''));
		};
	MiniTemplate.prototype.merge = function(context){
		var template = this.template || [];
		var temp = [];
		for(var i = 0; i < template.length; i++){
			if(typeof template[i] == 'string'){
				temp.push(template[i]);
			}else if(typeof template[i] == 'object' && typeof template[i]['key'] == 'string'){
				temp.push(context[ template[i]['key'] ]);
			}
		}
		return 	temp.join('');
	}
	var textarea = $('<textarea/>')
						.attr({'rows':20,'cols':100});
	$('<div/>')
		.append($('<span>close</span>').bind('click',function(){$(this).parent().remove();}))
		.append($('<br/>'))
		.append(textarea)
		.prependTo('body');
	var template = new MiniTemplate(templateStr);
	$( $('#container .doing tr.hentry:visible').get().reverse() ).each(function(){
		var context = {};
		context['userId'] =$(this).find('.content strong a').text();
		context['userName'] =$(this).find('.content strong a').attr('title');
		context['icon'] =$(this).find('.url img').attr('src');
		context['message'] = $.trim($(this).find('.entry-content').text());
		context['url'] = $(this).find('.entry-date').attr('href');
		textarea.val( [textarea.val(),'\n',template.merge(context)].join('') );
	});
	textarea.val( [textarea.val(),'\n'].join('') );
})(jQuery,'|${url}:title=${userId}||${message}|');

このままだと隠したエントリはあるわ、
隠してないエントリはクリックすると隠れるわで気持ち悪いので、
以下のJavaScriptを流して復旧。

(function($){
	$('#container .doing tr.hentry')
		.filter(':visible')
			.each(function(){
					$(this).unbind('click');
				})
			.end()
		.filter(':hidden')
			.each(function(){
					$(this).show();
				})
})(jQuery);

課題

日付も出したいよね