<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>项目管理 - <!--#include project_name--></title>
<link type="text/css" href="/css/base.css" rel="stylesheet" />	
<script src="/jquery/jquery.min.js" type="text/javascript"></script>
<script src="/jquery/jquery-ui.min.js" type="text/javascript"></script>
<script src="/jquery/common.min.js" type="text/javascript"></script>

<script type="text/javascript">
	function get_language_code(src, tar)
	{
		var text;
		switch(src){
			case 1: text = "英"; break;
			case 2: text = "中"; break;
			case 3: text = "日"; break;
			case 4: text = "西"; break;
			case 5: text = "法"; break;
			case 6: text = "俄"; break;
			case 7: text = "韩"; break;
			case 8: text = "德"; break;
			default: text = "?"; break;
		  }
		switch(tar){
			case 1: text += "英"; break;
			case 2: text += "中"; break;
			case 3: text += "日"; break;
			case 4: text += "西"; break;
			case 5: text += "法"; break;
			case 6: text += "俄"; break;
			case 7: text += "韩"; break;
			case 8: text += "德"; break;
			default: text += "?"; break;
		  }
		return text;
	}
	function get_mt_list()
	{
		$.ajax({
			type: "GET",
			async: false,
			url: "/project/" + current_group + "/mt_list",
			dataType: "json",
			success: function(data){
				var html_text = "";
				$.each(data, function(row_index, row){
					html_text += "<tr><td>";
					html_text += get_language_code(row["src"], row["tar"]);
					html_text += "</td><td><a href='";
					html_text += "/project/" + current_group + "/browse_mt?type=1&src=" + row["src"] + "&tar=" + row["tar"] + "'>";
					html_text += row["reviewed"];
					html_text += "</a></td><td><a href='";
					html_text += "/project/" + current_group + "/browse_mt?type=0&src=" + row["src"] + "&tar=" + row["tar"] + "'>";
					html_text += row["not_reviewed"];
					html_text += "</a></td></tr>";
				  });
				$("#mt_list tbody").html(html_text);
			  }
		  });
	}
	function get_tm_list()
	{
		$.ajax({
			type: "GET",
			async: false,
			url: "/project/" + current_group + "/tm_list",
			dataType: "json",
			success: function(data){
				var html_text = "";
				$.each(data, function(row_index, row){
					html_text += "<tr><td>";
					html_text += get_language_code(row["src"], row["tar"]);
					html_text += "</td><td><a href='";
					html_text += "/project/" + current_group + "/browse_tm?type=1&src=" + row["src"] + "&tar=" + row["tar"] + "'>";
					html_text += row["reviewed"];
					html_text += "</a></td><td><a href='";
					html_text += "/project/" + current_group + "/browse_tm?type=0&src=" + row["src"] + "&tar=" + row["tar"] + "'>";
					html_text += row["not_reviewed"];
					html_text += "</a></td></tr>";
					html_text += "<tr><td>";
					html_text += get_language_code(row["tar"], row["src"]);
					html_text += "</td><td><a href='";
					html_text += "/project/" + current_group + "/browse_tm?type=1&src=" + row["tar"] + "&tar=" + row["src"] + "'>";
					html_text += row["reviewed"];
					html_text += "</a></td><td><a href='";
					html_text += "/project/" + current_group + "/browse_tm?type=0&src=" + row["tar"] + "&tar=" + row["src"] + "'>";
					html_text += row["not_reviewed"];
					html_text += "</a></td></tr>";
				  });
				$("#tm_list tbody").html(html_text);
			  }
		  });
	}

	$(function(){
		// note: 1em = 16px, 100%, 12pt
		var work_height = $(window).height()-32-28-8;
		$("#navigator").height(work_height + "px");
		$("#content").height(work_height + "px");

		// disable cache
		$.ajaxSetup({cache: false});

		// function to resize content areas when window is resized
		$(window).resize(function(){
			var work_height = $(window).height()-32-28-8;
			$("#navigator").height(work_height + "px");
			$("#content").height(work_height + "px");
	    });

		// load navigator
		$("#navigator").load("/navigator?id=2");
		$("#user").load("/user_panel", function(){$("#login").click(function(){login();});$("#logout").click(function(){logout();});});
		
		$("#collapse").click(function(){
			var $nav = $("#navigator");
			var $link = $("#collapse a");
			if ($nav.is(":visible")){
				$nav.hide();
				$link.html("&gt;&gt;&gt;").attr("title","展开导航窗口");
			  }else{
				$nav.show();
				$link.html("&lt;&lt;&lt;").attr("title","折叠导航窗口");
			  }
			return false;
		});

		<!--#include init_variables-->

		// initialize button
		if (is_admin){
			$("div#mt_button").html("<button id='new_mt'>新建术语库</button>");
			$("div#tm_button").html("<button id='new_tm'>新建记忆库</button>");
		  }

		// buttons
		$("button", ".button_panel").button();
		$("#new_tm").click(function(){
			// get language
			$("#dialog").dialog({
				modal: true,
				resizable:false,
				title: "建立记忆库",
				buttons:{
					"确定": function(){
						$.ajax({
							type: "GET",
		   					async: false,
	   						data: {src:$("#dialog #language").val(), tar:2},
							url: "/project/" + current_group + "/new_tm_database",
							dataType: "json",
							success: function(data){
								var ret = data["ret"];
								if (ret == 1){
									window.location.reload();
								  }else if (ret != 0){
									alert("无法新建记忆库。");
								  }else{
									// close window
									$("#dialog").dialog("destroy");
								  }
							  },
   							error: function(){
								alert("无法新建记忆库。");
						   	}
					  	});
					  }
				},
				open: function(){
					$(this).empty();
					$(this).html("<form><fieldset><div><label for='language'>语言:</label><select id='language'><option selected value='1'>英中</option><option value='3'>日中</option><option value='4'>西中</option><option value='5'>法中</option><option value='6'>俄中</option><option value='7'>韩中</option><option value='8'>德中</option></select></div></fieldset></form>");
					$("#dialog #language").focus();
				}
			});
		});
		$("#new_mt").click(function(){
			// get language
			$("#dialog").dialog({
				modal: true,
				resizable:false,
				title: "建立术语库",
				buttons:{
					"确定": function(){
						var direction = $("#dialog #language").val();
						var tar = direction % 10;
						var src = (direction - tar) / 10;
						$.ajax({
							type: "GET",
		   					async: false,
	   						data: {src:src, tar:tar},
							url: "/project/" + current_group + "/new_mt_database",
							dataType: "json",
							success: function(data){
								var ret = data["ret"];
								if (ret == 1){
									window.location.reload();
								  }else if (ret != 0){
									alert("无法新建术语库。");
								  }else{
									// close window
									$("#dialog").dialog("destroy");
								  }
							  },
   							error: function(){
								alert("无法新建术语库。");
						   	}
					  	});
					  }
				},
				open: function(){
					$(this).empty();
					$(this).html("<form><fieldset><div><label for='language'>语言:</label><select id='language'><option selected value='12'>英中</option><option value='21'>中英</option><option value='32'>日中</option><option value='23'>中日</option><option value='42'>西中</option><option value='24'>中西</option><option value='52'>法中</option><option value='25'>中法</option><option value='62'>俄中</option><option value='26'>中俄</option><option value='72'>韩中</option><option value='27'>中韩</option><option value='82'>德中</option><option value='28'>中德</option></select></div></fieldset></form>");
					$("#dialog #language").focus();
				}
			});
		});

		// get info
		get_mt_list();
		get_tm_list();
	});
</script>
<style type="text/css">
	html,body{margin:0; padding:0;}
	html{overflow:visible;}
	body{font-size:11pt; min-width:500px;overflow-y:hidden !important; overflow-x:auto !important;}
	
	#banner #logo{font:200% 黑体; float:left; padding:3px 5px 0}
	#banner #user{font:80% 宋体; float:right; padding:5px 8px}

	#user a{text-decoration:none;}
	#user span{margin:2px 0 0 5px;}

	#menubar{background-color:#555; clear:both; height:28px}
	#menubar #collapse{padding:3px 0 0 0; float:left; color:#fff;}
	#menubar a:link, #menubar a:visited{color:white; text-decoration:none; vertical-align:middle;}
	#menubar a:hover{color:red;}
	#menubar #collapse a{font-weight:bold;}
	#menubar ul{padding:3px 10px 3px 5px; margin:0; text-align: right}
	#menubar li{padding:0 5px; font:90% "黑体"; color:#fff; display:inline}
	
	#navigator{font:宋体; width:160px; float:left; margin:5px; padding:5px;}
	#navigator a{display:block; width:125px; word-break:keep-all; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin:2.5px;}
	#navigator a:link, #navigator a:visited{font:80% "宋体";padding:0;}
	
	#content{font-size:80%;padding:0 5px; margin:0;overflow:auto;}
	
	.button_panel{font:80% 宋体; margin: 5px 2px; float: left; clear: both;}

	.ui-dialog-title{font-size:80%;padding:0;}
	.ui-dialog fieldset { padding:0; border:0; margin-top:10px; }
	.ui-dialog form div { margin:5px 0;}
	.ui-dialog .ui-dialog-buttonpane{margin:0.2em 0 0; padding:0.2em 1em 0.1em 0.4em;}
	.ui-dialog .ui-dialog-buttonpane button{margin:0.2em 0.4em 0.1em 0; padding:0;}
	.ui-widget .ui-widget{ font-size: 0.7em;}

	#content table{border-top: 1px solid #aaa;clear:both;}
	#content thead th{font-weight:normal;line-height:1.6em;border-bottom: 1px solid #aaa;background-color:#eee;}
	#content td{border-bottom:1px dotted #aaa;padding-top: 3px;padding-bottom: 3px;text-align:center;}
	#content tbody tr:hover{background-color:#f8f8f8;}
	#content tbody a{text-decoration:none;color:#000;}
	#content tbody .op a{color:#00c;}
	
	#content h2{margin-bottom:2px;margin-top:8px;}

	#dialog{font-size:70%;margin:0}
	#dialog label{ float:left; width:5em; text-align:right; margin-right:5px;margin-top:2px;}
	#dialog input, select{ padding:1px 1px; border:1px solid #ccc; width:65%;}
</style>
</head>
<body id="home">
<div id="banner">
	<div id="logo">雪人CAT网络协同翻译平台</div>
	<div id="user">
	</div>
</div>
<div id="menubar">
	<ul>
		<li id="collapse"><a href="#" title="折叠导航窗口">&lt;&lt;&lt;</a></li>
		<li><a href="/index.htm" id="homepage">首页</a></li>
		<li><a href="/project.htm" id="project">项目</a></li>
		<li><a href="/articles/all/list" id="document">文档</a></li>
		<li><a href="/forum.htm" id="discuss">论坛</a></li>
		<li><a href="/message.htm" id="message">通讯</a></li>
		<li><a href="/help.htm" id="help">帮助</a></li>
	</ul>
</div>
<div class="ui-widget ui-state-default ui-corner-all" id="navigator"></div>
<div id="content">
	<h2>术语库</h2>
	<table cellpadding="0" cellspacing="0" border="0" class="display" id='mt_list'>
		<thead>
			<tr>
				<th width="120px">语言</th>
				<th width="150px">项目术语</th>
				<th width="150px">未审核术语</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
	<div class='button_panel' id='mt_button'></div>
	<div style='clear:both;'>
	<br/>
	<h2>记忆库</h2>
	<table cellpadding="0" cellspacing="0" border="0" class="display" id='tm_list'>
		<thead>
			<tr>
				<th width="120px">语言</th>
				<th width="150px">项目记忆库</th>
				<th width="150px">未审核记忆库</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
	<div class='button_panel' id='tm_button'></div>
</div>
<div id="dialog"></div>
</body>
</html>
