﻿
/**
 * 投稿者を投稿数でソートして出力する
 * 投稿数0の投稿者は表示しない
 * @param ソースを置き換えるhtmlタグのID
 */
function putAuthors(id){
	var source = '<h2 class="module-header"><img alt="sb_men.gif" src="http://dominodev.bascule.co.jp/home/httpd/html/dominodev/sb_men.gif" width="95" height="14" /></h2><div class="module-content"><ul class="module-list">';
	var authors = new Array();
		authors.push(new Author("ao","ao",0,"ao"));
		authors.push(new Author("atsuhashi","atsuhashi",37,"atsuhashi"));
		authors.push(new Author("boku","boku",0,"boku"));
		authors.push(new Author("faces","FACEs",0,"faces"));
		authors.push(new Author("harayoki","harayoki",0,"harayoki"));
		authors.push(new Author("kamp","kamp",30,"kamp"));
		authors.push(new Author("key","key",26,"key"));
		authors.push(new Author("nakaoka","nakaoka",0,"nakaoka"));
		authors.push(new Author("qubi","qubi",4,"qubi"));
		authors.push(new Author("ryo","ryo",15,"ryo"));
	
	authors.sort(
		function(a,b){
			if(a.getEntryCount()>b.getEntryCount()) return -1;
			if(a.getEntryCount()<b.getEntryCount()) return 1;
			return 0;
		}
	);
	for(var i in authors){
		var author = authors[i];
		if(author.getEntryCount()>0){
			source += '<li class="module-list-item"><a href="'+author.getURL()+'">'+author.getNickName()+'</a> ('+author.getEntryCount()+'件)</li>';
		}else{
		}
	}
	source +='</ul>\n</div>\n';
	document.getElementById(id).innerHTML = source;
}

//authorクラス
function Author(name,nickName,entryCount,url){
	this.name = name;
	this.nickName = nickName;
	this.count = entryCount;
	this.url = url + ".html";
}
Author.prototype.getName = function(){
	return this.name;
}
Author.prototype.getNickName = function(){
	return this.nickName;
}
Author.prototype.getEntryCount = function(){
	return this.count;
}
Author.prototype.getURL = function(){
	return this.url;
}
Author.prototype.toString = function(){
	return this.name+"("+this.nickName+"):"+this.count;
}
