ika-core.org Ikariam Tools

Next generation Ikariam search and addons script

当前为 2015-01-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name	ika-core.org Ikariam Tools
// @namespace	ika-core
// @description	Next generation Ikariam search and addons script
// @license     Creative Commons Attribution License
// $icon	http://www.ika-core.org/git/icon48.png
// @include	http://s*.ikariam.gameforge.com/*
// @include	http://m*.ikariam.gameforge.com/*
// @exclude http://support.*.ikariam.gameforge.com/*
// @run-at	document-start
// @require	https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @resource	css http://www.ika-core.org/git/ika-core.css
// @resource	lic http://www.ika-core.org/git/licencemsg.txt
// @version	1.5
// @grant	GM_addStyle
// @grant	GM_getValue
// @grant	GM_setValue
// @grant	GM_getResourceText
// @grant	GM_openInTab
// @grant	GM_xmlhttpRequest
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
var lang = (navigator.language) ? navigator.language : navigator.userLanguage;
var ufo = unsafeWindow, game, log, ikariam, screen, server,player,ally,selectedcity,island,islandx,islandy,citybuildings,islandcities,realHour,nmb,resman,worlddraw,worldmap,transload=false;
var goods={0:'<img src="skin/resources/icon_wood.png"/>',1:'<img src="skin/resources/icon_wine.png"/>',2:'<img src="skin/resources/icon_marble.png"/>',3:'<img src="skin/resources/icon_glass.png"/>',4:'<img src="skin/resources/icon_sulfur.png"/>'};
var buildings=["townHall","shipyard","port","glassblowing","branchOffice","barracks","academy","warehouse","palace","palaceColony","tavern","museum","workshop","wall","dump","vineyard","pirateFortress","safehouse","embassy","stonemason","carpentering","forester","winegrower","alchemist","optician","fireworker","architect","temple","blackMarket"];	
//http://s1-gr.ikariam.gameforge.com/index.php?action=WorldMap&function=getJSONIsland&x=64&y=48
String.prototype.strip=function(){
	return this.replace(/<.*?[^>]>/g,'');
};
String.prototype.digits = function(){
	var d=this.replace(/\D/g, '');
	if (d=='') return 0;
	return d;
};
if (localStorage.getItem('debug')=='y'){
	var deb=ufo.console.log.bind(console);
}else { deb=function(){};}
exportFunction(parser, unsafeWindow.console, {defineAs: "log"});
document.addEventListener('beforescriptexecute', function(e) {
	if (e.target.innerHTML.search(/console\s=/) != -1 ) {
		e.stopPropagation();
		e.preventDefault();		
		window.removeEventListener(e.type, arguments.callee, true);
	}}, true);
document.onreadystatechange = function() {
	if (document.readyState == "complete") {		
		main();
		GM_addStyle( GM_getResourceText('css'));
	}
};

function view(name,title,content,oversize){
	var tobj = {"boxId":name,"headerElem":title,"contentElem":content,"sidebarEls":{"0":{},"length":1,"prevObject":{"0":{},"context":{},"length":1},"context":{},"selector":"div.dynamic"},"oversized":true,"replaceBox":true,"keepSidebars":true,"minisized":false};
	ufo.tobj = cloneInto(tobj, ufo);
	ikariam.createTemplateView(ufo.tobj);
}

function viewhandler(s) {
	if (!s.hasOwnProperty("ici")) {
		if(jQuery.inArray(s["boxId"], buildings)!==-1)	{
			s["sidebarEls"]["ici"]=s["boxId"];			
		}
	}
}
function bar(g,mg){
	var w=g*100/mg;
	return '<div class="barBg" title="'+nmb(w)+'%"><div class="ikbar" style="width:'+w+'%"></div></div>';
}
function CreateSlot(menu,n,bg,bgl,name,desc,fn){
	menu.append('<li class="expandable slot'+n+'" style="display: inline-block; width: 53px;" onclick=""><div class="image image_friends" style="background:url('+bg+') repeat scroll '+bgl+' transparent;height:34px;width:32px;"></div><div class="name"><span class="namebox">'+name+'</br><small>'+desc+'</small></span></div></li>')
	.find('.slot'+n)
	.hover(function(){
		$(this).animate({width : "199px"}, 300, "swing").parent().parent().css('z-index','120000');
	},function(){
		$(this).animate({width : "53px"}, 300, "swing").parent().parent().css('z-index','65');;
	}).click(fn);
}
function loadcitybuildings(){
	var l=[];
	var d=JSON.parse(localStorage.getItem(player+'_cities'));
	for (k in d){
		if (d[k].hasOwnProperty("relationship")){
			if (d[k]["relationship"]=="ownCity"){
				l.push(JSON.parse(localStorage.getItem(player+'_'+k+'_buildings')));
			}
		}
	}
	return l;
}
function parser(s) {
	if (typeof s == "object") {
		game = s;
		datahandler();
		if (s.hasOwnProperty("boxId")) {
			viewhandler(s);
		}
		if (s.hasOwnProperty("ici")) {
			deb("fetch:"+s["ici"]);
			resman=s["ici"];				
		}
		if ((s.hasOwnProperty("link")&&resman)||(s.hasOwnProperty("selectedCity")&&resman)) {
			var r=$('#sidebar .resources');
			if (r.length){
				var wood=r.find('.wood').contents(':not(span)').text().digits();
				var wine=r.find('.wine').contents(':not(span)').text().digits();
				var marble=r.find('.marble').contents(':not(span)').text().digits();
				var glass=r.find('.glass').contents(':not(span)').text().digits();
				var sulfur=r.find('.sulfur').contents(':not(span)').text().digits();
				var time=r.find('.time').contents(':not(span)').text();
				var level=$('#sidebar .actions .showLevel').contents(':not(span)').text().digits();
				var bres={"0":wood,"1":wine,"2":marble,"3":glass,"4":sulfur,"time":time,"level":level};
				localStorage.setItem(player+'_'+selectedcity+'_br_'+resman, JSON.stringify(bres));
				deb("fetch-for-"+resman+"_level"+level.digits()+":"+JSON.stringify(bres));			
			}
		}
		if (s.hasOwnProperty("contentElem")) {
			var obj = s["contentElem"];
			s["contentElem"] = '';
			deb("c:" + JSON.stringify(s));
			s["contentElem"] = obj;			
		} else {
			deb("o:" + JSON.stringify(s));
		}		
	} else {
		deb(s);
	}
}
function datahandler() {
	var gm=game;
	if (gm.hasOwnProperty('backgroundView') ){
		screen=gm['backgroundView'];
		deb("view:" + screen);
	} 
	if (gm.hasOwnProperty('gameName') ){
		deb("player:" + gm['avatarId']);
		player=gm['avatarId'];
		deb("ally:" + gm['avatarAllyId']);
		ally=gm['avatarAllyId'];
		realHour=gm['realHour'];
	}
	if (gm.hasOwnProperty('serverName') ){
		deb("server:" + gm['serverName']);	
		server=gm['serverName'];
	}
	if (gm.hasOwnProperty("bgViewData")){
		deb("island:" + gm['bgViewData']['currentIslandId']);
		island=gm['bgViewData']['currentIslandId'];
	}
	if (gm.hasOwnProperty("islandId")){
		deb("island2:" + gm['islandId']);
		island=gm['islandId'];
	}
	if (gm.hasOwnProperty("islandXCoord")){
		deb("island2x:" + gm['islandXCoord']);
		deb("island2y:" + gm['islandYCoord']);
		islandx=gm['islandXCoord'];
		islandx=gm['islandYCoord'];		
	}		

	//city list
	if (gm.hasOwnProperty("relatedCityData")){
		//deb("citylist:" + JSON.stringify(gm['relatedCityData']));
		selectedcity=gm['relatedCityData']['selectedCity'];
		deb("selectedcity:" + selectedcity);
		localStorage.setItem(player+'_cities', JSON.stringify(gm['relatedCityData']));
	}
	if (gm.hasOwnProperty("cityDropdownMenu")){
		//deb("citylist-dropdown:" + JSON.stringify(gm['cityDropdownMenu']));		
			selectedcity=gm['cityDropdownMenu']['selectedCity'];
		deb("selectedcity:" + selectedcity);
		localStorage.setItem(player+'_cities', JSON.stringify(gm['cityDropdownMenu']));
	}
	if (gm.hasOwnProperty("isOwnCity")||gm.hasOwnProperty("relatedCity")){
		var cityres={'currentResources':gm['currentResources'],
					'maxResources':gm['maxResources'],
					'resourceProduction':gm['resourceProduction'],
					'tradegoodProduction':gm['tradegoodProduction'],
					'wineSpendings':gm['wineSpendings'],
					'wineTickInterval':gm['wineTickInterval'],
					'producedTradegood':gm['producedTradegood'],
					'dt':new Date().getTime()};
		localStorage.setItem(player+'_'+selectedcity+'_prod', JSON.stringify(cityres));
		if (transload) transporterload(true);
	}
	if (gm.hasOwnProperty("relatedCity")){
		if (gm["relatedCity"].hasOwnProperty("owncity")){
			if(gm["relatedCity"]["owncity"]==1){
			var cityres={'currentResources':gm['currentResources'],
						'maxResources':gm['maxResources'],
						'resourceProduction':gm['resourceProduction'],
						'tradegoodProduction':gm['tradegoodProduction'],
						'wineSpendings':gm['wineSpendings'],
						'wineTickInterval':gm['wineTickInterval'],
						'producedTradegood':gm['producedTradegood'],
						'dt':new Date().getTime()};
			//deb(player+'_'+selectedcity+'_prod:'+JSON.stringify(cityres));
			localStorage.setItem(player+'_'+selectedcity+'_prod', JSON.stringify(cityres));
			if (transload) transporterload(true);
			}
		}
	}
	if (gm.hasOwnProperty("backgroundData")){
		citybuildings=JSON.stringify(gm['backgroundData']);
		localStorage.setItem(player+'_city_'+gm['backgroundData']['id']+'_buildings', citybuildings);
		rendercity();
	}
	if (screen=='city' && gm.hasOwnProperty("phase") &&gm["ownerId"]==player){
		citybuildings=JSON.stringify(gm);
		localStorage.setItem(player+'_city_'+gm['id']+'_buildings', citybuildings);
		rendercity();
	}
	if (screen=='island' && gm.hasOwnProperty("cities")){
		islandcities=gm;
		localStorage.setItem(player+'_island_'+gm['id']+'', JSON.stringify(gm));
		renderisland();
	}
}

function renderisland(){
	var m=$('#cities');
	var ic=islandcities['cities'];
	for (var k=0;k<ic.length;k++){
		if (ic[k]["type"]=="city"){
			var b=m.find('#cityLocation'+k+' a.island_feature_img');
			b.find('.blevel').remove();
			b.append('<div class="blevel">'+ic[k]['level']+'</div>');
			var b=m.find('#cityLocation'+k+'Scroll div.center');
			b.find('.infotip').remove();
			b.append('<span class="infotip">'+ic[k]['ownerName']+'</span>');
		}
	}
}

function rendercity(){
	var lc=JSON.parse(localStorage.getItem(player+'_'+selectedcity+'_buildings'));
	var lcp=lc['position'];
	var m=$('#locations');	
	var bl=loadcitybuildings();
	for (var k=0;k<lcp.length;k++){
		var p=m.find('#position'+k);
		p.find('.blevel,.linfo,.binfo').remove();
		if (lcp[k].hasOwnProperty("name")){
			p.append('<div class="blevel" data="'+lcp[k]['level']+'">'+lcp[k]['level']+'</div><div data="'+lcp[k]['building'].replace(' constructionSite','')+'" class="linfo"></div><div class="binfo" data="'+lcp[k]['building'].replace(' constructionSite','')+'"></div>');
		}
	}
	m.find('.blevel').click(function(){
		$(this).parent().find('.hoverable').click();
	}).hover(function(){
		var p=$(this).parent().css('z-index',10000);
		
		//binfo - resource info for building upgrade
		var g=p.find('.binfo');
		var bres=JSON.parse(localStorage.getItem(player+'_'+selectedcity+'_br_'+g.attr('data')));
		if (bres){
			var ht=(bres[0]?'<span>'+goods[0]+' '+nmb(bres[0])+'</span>':'')+
			(bres[1]?'<span>'+goods[1]+' '+nmb(bres[1])+'</span>':'')+
			(bres[2]?'<span>'+goods[2]+' '+nmb(bres[2])+'</span>':'')+
			(bres[3]?'<span>'+goods[3]+' '+nmb(bres[3])+'</span>':'')+
			(bres[4]?'<span>'+goods[4]+' '+nmb(bres[4])+'</span>':'')+
			bres['time'];
			g.html(ufo.BubbleTips.createTooltip(ht,'100px'));			
		}
		// others cities same buildings
		var e=p.find('.linfo');
		var bname=e.attr('data');
		if (bname=='palace') bname='palaceColony';
		if (bname!='fetched'){
			e.attr('data','fetched');
			var txt='';
			for (var b=0;b<bl.length;b++){
				var cnm=bl[b]['name'];
				if (cnm!=lc['name']){
					var bp=bl[b]['position'];
					for (var p=0;p<bp.length;p++){
						var lbname=bp[p]['building'];
						var hl='';
						if (lbname.indexOf('constructionSite')>0){
							lbname=lbname.replace(' constructionSite','');
							hl=' class="red"';
						} else {
							hl='';
						}							
						if (lbname=='palace') lbname='palaceColony';
						if (lbname==bname){
							txt+='<span '+hl+'>'+cnm+' '+bp[p]['level']+'</span>';
						}
					}
				}
			}
			e.html(ufo.BubbleTips.createTooltip(txt,'100px'));
		}
		if (e.html()) e.show();
		if (g.html()) g.show();
	},function(){
		$(this).parent().css('z-index','').find('.linfo,.binfo').hide();
	});
}

function searchview(){	
	view("searchika","Search for players",'<iframe name="isearch" src="http://www.ika-core.org/" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" width="100%" height="100%"></iframe>',true);
}
function buildingsview(){
	var bp,o,i,j,busy,link;
	var bl=loadcitybuildings();
	var s='<table class=\"table01 left clearfloat\" style=\"width:100%;margin:0;\"><tbody><tr>\
		<th width=\"20%\"><img src=\"skin/icons/livingspace_24x24.png\"\/><\/th>';
	for (i=0;i<buildings.length;i++){
		s+='<th width=\"3%\" title=\"'+buildings[i]+'\"><img src=\"skin/buildings/x40_y40/'+buildings[i]+'.png\" width=\"40\"/><\/th>';
	}	
	s+='<\/tr>';
	var alt='';
	//s+=JSON.stringify(bl);
	for (i=0;i<bl.length;i++){
		bp=bl[i]['position'];
		o=[];
		busy=[];
		link=[];
		for (j=0;j<bp.length;j++){
			var ind=jQuery.inArray(bp[j]['building'].replace(' constructionSite',''), buildings);
			o[ind]=bp[j]['level'];
			busy[ind]=(bp[j]['building'].indexOf('constructionSite')>0?true:false);
			link[ind]='?view='+bp[j]['building'].replace(' constructionSite','')+'&cityId='+bl[i]['id']+'&position='+j;
		}
		s+='<tr class="'+alt+'"><td title=\"'+bl[i]['name']+'\">'+bl[i]['name']+'<\/td>';
		for (j=0;j<buildings.length;j++){
			if (o[j]) {
				s+='<td title=\"'+buildings[j]+(busy[j]?' upgrading':'')+' Level: '+o[j]+'\" class=\"point right'+(busy[j]?' red bold blink':'')+'\" onclick=\"ajaxHandlerCall(\''+link[j]+'\');return false;\">'+o[j]+'<\/td>';
			} else {
				s+='<td title=\"'+buildings[j]+' Does not exist'+'\" class=\"right\">-<\/td>';				
			}
		}
		s+='<\/tr>';
		if (alt=='') {alt='alt';} else {alt='';};
	}	
	s+='<\/tbody><\/table><iframe src="http://www.ika-core.org/ikariam-new.html" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" width="100%" height="115px"></iframe>';
	view("buildingsika","Buildings View",s,true);
}

function mapislands(islands,data){
		var l = data.data;
        var q = data.request;
		for (var m = q.x_min; m <= q.x_max; m++) {
			for (var o = q.y_min; o <= q.y_max; o++) {
				if (!islands[m]) {
					islands[m] = new Array()
				}
				if (l[m] && l[m][o]) {
					islands[m][o] = l[m][o];
				} else {
					islands[m][o] = "ocean"
				}
			}
		}
}

function worldviewprepare(){
	$.getJSON( "/","action=WorldMap&function=getJSONArea&x_min=0&x_max=101&y_min=0&y_max=101", function(data) {
		var islands=[];
		var l = data.data;
        var q = data.request;
		for (var m = q.x_min; m <= q.x_max; m++) {
			for (var o = q.y_min; o <= q.y_max; o++) {
				if (!islands[m]) {
					islands[m] = new Array()
				}
				if (l[m] && l[m][o]) {
					islands[m][o] = l[m][o];
				} else {
					islands[m][o] = "ocean"
				}
			}
		}
		worldview(islands);
	});
}

function worldview(i){
	var tg=["wood","wine","marble","glass","sulfur"];
	var s='<table id="worldmap_2d">',x,y;
	for (y=0;y<101;y++){
		s+='<tr>'
		for (x=0;x<101;x++){
			var ci=i[x][y];
			if (ci != "ocean") {
				s+='<td id="is'+ci[0]+'" class="isle" title="'+ci[1]+'['+x+':'+y+'] wood:'+ci[6]+' '+tg[ci[2]]+'"></td>';
			} else {
				s+='<td class="ocean"></td>';
			}
		}
		s+='</tr>';
	}
	s+='</table>';
	view("worldika","World Map",s,false);
	$('#is'+island).addClass('isleown');
}
function transporterload(force){
	t=$('#iTrans');
	if (t.is(':hidden')=='true') return;
	if (!transload||force){
		transload=true;		
		var s='<table class="table01 left clearfloat" style="width:100%;margin:0;"><tbody><tr>\
			<th width="20%"><img src="skin/icons/livingspace_24x24.png"/></th>\
			<th width="13%">'+goods[0]+'</th>\
			<th width="13%">'+goods[1]+'</th>\
			<th width="13%">'+goods[2]+'</th>\
			<th width="13%">'+goods[3]+'</th>\
			<th width="13%">'+goods[4]+'</th>\
			<th width="15%"><img src="skin/interface/btn_max.png"/></th>\
			</tr>';
		var d=JSON.parse(localStorage.getItem(player+'_cities'));		
		var alt='';
		var ar=$('#js_ChangeCityActionRequest').val();
		var tg=[0,0,0,0,0];var pr=[0,0,0,0,0];
		var dt=new Date().getTime();
		for (k in d){
			if (d[k].hasOwnProperty("relationship")){
				if (d[k]["relationship"]=="ownCity"){
					var cr=JSON.parse(localStorage.getItem(player+'_city_'+d[k]['id']+'_prod'));
					//deb('tr:'+JSON.stringify(cr));
					try{
						var woodprod=(cr['resourceProduction']==0)?'':' <span style="font-size:0.8em">(+'+nmb(cr['resourceProduction']*realHour)+'/h)</span>';
						var goodprod=(cr['tradegoodProduction']==0)?'':' <span style="font-size:0.8em">(+'+nmb(cr['tradegoodProduction']*realHour)+'/h)</span>';
						var trgood=cr['producedTradegood'];
						var delta=(dt-cr['dt'])/3600000;
						cr['currentResources']['resource']+=delta*cr['resourceProduction']*realHour;
						var winecon;						
						if (trgood==1){
							cr['currentResources'][1]+=delta*(cr['tradegoodProduction']*realHour-cr['wineSpendings']);
							winecon=(cr['tradegoodProduction']*realHour-cr['wineSpendings']);
							winecon=(winecon==0)?'':' <span style="font-size:0.8em">('+((winecon>0)?'+':'-')+nmb(winecon)+'/h)</span>';
						}else {
							winecon=(cr['wineSpendings']==0)?'':' <span style="font-size:0.8em">(-'+nmb(cr['wineSpendings'])+'/h)</span>';
							cr['currentResources'][trgood]+=delta*cr['tradegoodProduction']*realHour;
						}
						pr[0]+=cr['resourceProduction']*realHour;
						pr[trgood]+=cr['tradegoodProduction']*realHour;
						pr[1]-=cr['wineSpendings'];
						tg[0]+=cr['currentResources']['resource'];
						tg[1]+=cr['currentResources'][1];
						tg[2]+=cr['currentResources'][2];
						tg[3]+=cr['currentResources'][3];
						tg[4]+=cr['currentResources'][4];
						s+='<tr class="'+alt+'"><td class="city bold"><a title="Popuplation '+nmb(cr['currentResources']['citizens'])+'('+nmb(cr['currentResources']['population'])+')" href="#" onclick="$(\'#js_cityIdOnChange\').val(\''+d[k]['id']+'\').parent().submit();">'+goods[d[k]['tradegood']]+' '+d[k]['coords']+' '+d[k]['name']+'</a></td>'+
						'<td class="right">'+nmb(cr['currentResources']['resource'])+woodprod+bar(cr['currentResources']['resource'],cr['maxResources']['resource'])+'</td>'+
						'<td class="right" title="'+((trgood==1)?nmb(cr['tradegoodProduction']*realHour):'')+'-'+nmb(cr['wineSpendings'])+'">'+nmb(cr['currentResources']['1'])+winecon+bar(cr['currentResources'][1],cr['maxResources'][1])+'</td>'+
						'<td class="right">'+nmb(cr['currentResources'][2])+((trgood==2)?goodprod:'')+bar(cr['currentResources'][2],cr['maxResources'][2])+'</td>'+
						'<td class="right">'+nmb(cr['currentResources'][3])+((trgood==3)?goodprod:'')+bar(cr['currentResources'][3],cr['maxResources'][3])+'</td>'+
						'<td class="right">'+nmb(cr['currentResources'][4])+((trgood==4)?goodprod:'')+bar(cr['currentResources'][4],cr['maxResources'][4])+'</td>'+
						'<td class="center actions">'+(('city_'+d[k]['id']==selectedcity)?'':
							'<a href="?view=transport&amp;destinationCityId='+d[k]['id']+'&amp;backgroundView='+screen+'&amp;currentIslandId='+island+'&amp;templateView=cityDetails&amp;actionRequest='+ar+'" onclick="ajaxHandlerCall(this.href);return false;" id="itranslinkt'+d[k]['id']+'"><img width="32" height="22" src="skin/interface/mission_transport.png" alt="Transport" class="vertical_middle"></a>'+
							'<a href="?view=deployment&amp;deploymentType=army&amp;destinationCityId='+d[k]['id']+'&amp;backgroundView='+screen+'&amp;currentIslandId='+island+'&amp;templateView=cityDetails&amp;actionRequest='+ar+'" onclick="ajaxHandlerCall(this.href);return false;" id="itranslinkt'+d[k]['id']+'"><img width="32" height="22" src="skin/interface/mission_deployarmy.png" alt="Army" class="vertical_middle"></a>'+
							'<a href="?view=deployment&amp;deploymentType=fleet&amp;destinationCityId='+d[k]['id']+'&amp;backgroundView='+screen+'&amp;currentIslandId='+island+'&amp;templateView=cityDetails&amp;actionRequest='+ar+'" onclick="ajaxHandlerCall(this.href);return false;" id="itranslinkt'+d[k]['id']+'"><img width="32" height="22" src="skin/interface/mission_deployfleet.png" alt="Army" class="vertical_middle"></a>')+
						'</td></tr>';
					} catch(e){
						//deb('tr-catch:'+e);
						s+='<tr class="'+alt+'"><td class="city bold"><a href="#" onclick="$(\'#js_cityIdOnChange\').val(\''+d[k]['id']+'\').parent().submit();">'+goods[d[k]['tradegood']]+' '+d[k]['coords']+' '+d[k]['name']+'</a></td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>';							
					}																					
				}
			}
			if (alt=='') {alt='alt';} else {alt='';};
		}
		s+='<tr class="'+alt+' total"><td class="city bold right">Total</td><td class="right">'+nmb(tg[0])+' <span style="font-size:0.8em">('+nmb(pr[0])+'/h)</span></td><td class="right">'+nmb(tg[1])+' <span style="font-size:0.8em">('+nmb(pr[1])+'/h)</span></td><td class="right">'+nmb(tg[2])+' <span style="font-size:0.8em">('+nmb(pr[2])+'/h)</span></td><td class="right">'+nmb(tg[3])+' <span style="font-size:0.8em">('+nmb(pr[3])+'/h)</span></td><td class="right">'+nmb(tg[4])+' <span style="font-size:0.8em">('+nmb(pr[4])+'/h)</span></td><td></td></tr>';
		t.html(s+'</table><iframe src="http://www.ika-core.org/ikariam-new.html" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" width="100%" height="115px"></iframe>');
	}	
}

function transporter(){	
	var t=$('body #container').append('<div id="iTrans"></div>').find('#iTrans').mouseleave(function(){$(this).hide();});
	var tr=$('<span class="white"> > </span><a id="iTransport" class="yellow" title="Transporter" href="#"><img class="vertical_middle" width="20" height="16" alt="Transport" src="skin/interface/mission_transport.png"> Transporter </a>');
	var trans=(screen=='city')?tr.insertAfter('#js_cityBread'):$('#breadcrumbs').append(tr);
	trans.mouseenter(function(){
		transporterload();
		t.css('left',$('#iTransport').offset().left+'px').show();
	});
}
function rendersidebar(){
	var lm=$('#leftMenu');
	if (lm.length==0){
		lm=$('#container').append('<div id="leftMenu"><div class="slot_menu city_menu" id="js_viewCityMenu" style="z-index: 65;"><ul class="menu_slots"></ul></div></div>');
	} 
	var menu=lm.find('.menu_slots');
	CreateSlot(menu,8,'http://gf1.geo.gfsrv.net/cdn00/0aa3bb98504af3b7f3d779bf46b82b.ico','-1px 1px','Search','Find players,islands,cities',searchview);
	CreateSlot(menu,9,'skin/layout/btn_world.jpg','-28px -1px','World','Show the mini Wolrd Map',worldviewprepare);
	CreateSlot(menu,10,'skin/buildings/x40_y40/forester.png','-1px 1px','Buildings','Show buidings overview',buildingsview);		
}
function main(){
	try {
		//localStorage.clear(); 
		ikariam = ufo.ikariam;
		nmb=ufo.ikariam.Model.locaNumberFormat;		
		rendersidebar();
		transporter();
		deb("stub finish.");
	} catch(e){alert('catch:'+e);}
}