<html>
        <head>
                <meta content="text/html; charset={{ charset }}" http-equiv="Content-Type" />
                <title>{{ servicename }}</title>
				<script src="/webservice/rpc_static/js/json2.js" type="text/javascript"></script>
				<script src="/webservice/rpc_static/js/jsonwspclient.js" type="text/javascript"></script>
				<script src="/webservice/rpc_static/js/jquery.js" type="text/javascript"></script>
<style>

    body { margin: 0px; padding: 0px; font-family: verdana; font-size: 12pt; background-color: #FCFCFC; }

    div.service-header {
        height: 34px;
        font-weight: bold; padding: 10px; font-size: 30px; color: white; border-bottom: 1px solid black; background: #70803C;
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#A0B06C', endColorstr='#70803C'); background: -webkit-gradient(linear, left top, left bottom, from(#A0B06C), to(#70803C)); background: -moz-linear-gradient(top,  #A0B06C,  #70803C);
        text-shadow: #555555 2px 3px 3px;
    }
    div.service-header div.service-title {position: relative; float:left}
    div.service-header .skin-selector {padding-top: 8px; margin-bottom: 0; position:relative; float: right; font-size: 12pt;}

    div.service-overview {
        float: right; margin: 20px; width: 200px;
        -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; background-color: #F6F6F6; border: 1px solid #E6E6E6; border-collapse: separate; font-size: 11px; padding: 10px; margin-right: 20px;
        -moz-box-shadow: 2px 2px 4px #555; -webkit-box-shadow: 2px 2px 4px #555; box-shadow: 2px 2px 4px #555;
    }

    div.service-overview div.headline { font-weight: bold; font-size: 18px; }
    div.service-overview div.title { font-weight: bold; margin: 4px; font-size: 1.2em; }
    div.service-overview ul.list { padding: 0px; margin: 0px; margin-left: 15px; list-style-type: none; }
    div.service-overview ul.list li { font-size: 1.1em; }

    div.service-description { padding: 15px; padding-bottom: 0px; }
    div.service-description div.title { font-weight: bold; font-size: 1.2em; }
    div.service-description p.doc-lines { font-size: 0.8em; }
    div.service-description p.url { font-size: 0.8em; font-style: italic; }
    div.service-description p.url span.url-title { font-weight: bold; }

    div.service-interfaces { padding: 15px; padding-bottom: 0px;  }
    div.service-interfaces div.title { font-weight: bold; font-size: 1.2em; }
    div.service-interfaces ul.list { font-size: 0.8em; }
    div.service-interfaces ul.list li { padding: 4px; }

    div.service-api { padding: 15px; padding-bottom: 0px;  }
    div.service-api div.methods div.title { font-weight: bold; font-size: 1.2em; } 
    div.service-api div.methods ul.list { font-size: 0.9em; list-style-type: none; } 
    div.service-api div.methods ul.list li.entry {
        -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; background-color: #F6F6F6; border: 1px solid #E6E6E6; 
        border-collapse: separate; font-size: 0.8em; padding: 10px; margin-right: 20px;
        -moz-box-shadow: 2px 2px 5px #555; -webkit-box-shadow: 2px 2px 5px #555; box-shadow: 2px 2px 5px #555;
        margin-bottom: 16px;
    } 
    div.service-api div.methods ul.list li.entry div.declaration {
        font-size: 1.5em;
    } 
    div.service-api div.methods ul.list li.entry div.declaration span.name { color: #881a1a; } 
    div.service-api div.methods ul.list li.entry span.param-type { color: #68387f; } 
    div.service-api div.methods ul.list li.entry span.param-name {} 
    div.service-api div.methods ul.list li.entry p.doc-lines { font-size: 1.2em; color: #276d11; } 
    div.service-api div.methods ul.list li.entry ul.params p.doc-lines { margin-top:0;margin-bottom:6px; font-size: 1.0em; color: #276d11; } 

    div.service-api div.types div.title { font-weight: bold; font-size: 1.2em; } 
    div.service-api div.types ul.list { font-size: 0.9em; list-style-type: none; } 
    div.service-api div.types ul.list li.entry {
        -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; background-color: #F6F6F6; border: 1px solid #E6E6E6; 
        border-collapse: separate; font-size: 0.8em; padding: 10px; margin-right: 20px;
        -moz-box-shadow: 2px 2px 5px #555; -webkit-box-shadow: 2px 2px 5px #555; box-shadow: 2px 2px 5px #555;
        margin-bottom: 16px;
    } 
    div.service-api div.types ul.list li.entry div.definition {
        font-size: 1.5em;
    } 
    div.service-api div.types ul.list li.entry div.definition span.name { color: #881a1a; } 
    div.service-api div.types ul.list li.entry span.param-type { color: #68387f; } 
    div.service-api div.types ul.list li.entry span.param-name {} 
    div.service-api div.types ul.list li.entry p.doc-lines { margin-top:0;margin-bottom:6px; font-size: 1.0em; color: #276d11; } 

    div.service-footer { font-size: 0.8em; text-align: center; font-style: italic; padding-top: 10px; padding-bottom: 10px; }

    a:link { color: #00732F; text-decoration: none }
    a:visited { color: #00732F; text-decoration: none }
    a:hover { color: #00732F; text-decoration: underline }

 .ret_value { background-color:#E0E0E0}
 .code_div { display:none;}
        </style>
		
<script language="JavaScript">
function getUrlParam(name){

	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	var r = window.location.search.substr(1).match(reg); //匹配目标参数
	if (r != null) 
		return unescape(r[2]);
	return null; //返回参数值
}
m_debug = getUrlParam('debug');
var debug =false;
if (m_debug=='1'){
	debug = true;
}
var m_client = null;


function do_method(name){
		$("#ret_" + name).val('');
		m_params = m_client.jsonrpc_desc.methods[name].params;
		args = {};
		$("input[id^='"+name+"']").each(function(){
			m_id = $(this).attr('id');
			m_nk = m_id.split("@")
			if (m_nk[0] == name) {
				para_name = m_nk[1];
				m_val = $(this).val();
				m_type = m_params[para_name].type;
				if (typeof(m_type) == 'string' && m_type == 'string') {
					//alert('string');
					m_val = m_val;
				}
				else 
					if (typeof(m_type) == 'string' && m_type == 'number') {
						//alert('number');
						m_val = Number(m_val)
					}
					else 
						if (typeof(m_type) == 'string' && m_type == 'boolean') {
							//alert('boolean');
							m_val = Boolean(m_val);
						}
						else {
							//alert('object');
							try {
								m_val = JSON.parse(m_val);
							} 
							catch (e) {
								alert("参数格式不正确");
								return;
							}
						}
				//alert(m_param+m_val);
				args[para_name] = m_val;
			}
		})
	    m_client[name](args,
	    null,
	    function(result,reflection,res) {
			if (res.fault) {
				alert("执行失败,原因: "+res.fault.string);
			}
			else {
				$("#ret_" + name).val(result);
			}
	    })
}

function do_action(name){
	
    if (m_client == null) {
        m_client = new JSONWSPClient();
        m_client.loadDescription("jsonwsp/description",
        function() {
			do_method(name);
        });
    }else{
		do_method(name);
	}
}
</script>
		
		
        </head>
        <body>
		<div class="service-header">
			<div class="service-title">{{ servicename }}</div>
		</div>
		<div class="service-overview">
			<div class="headline">大纲 </div>
					&nbsp;&nbsp;&nbsp;&nbsp;-><a href="/webservice/rpc/">返回首页</a><br>
					<script language="JavaScript">
						if (debug){
							window.document.write('&nbsp;&nbsp;&nbsp;&nbsp;-><a href="?debug=0">关闭调试</a>');
						}else{
							window.document.write('&nbsp;&nbsp;&nbsp;&nbsp;-><a href="?debug=1">开启调试</a>');
						}
					</script>
			<div class="title">方法</div>
			<ul class="list">
{% for method in methods %}
				<li>
					<a href="#{{ method.methodname }}"><span class="entry">{{ method.methodname }}</span></a>
					( )
				</li>
{% endfor %}
			</ul>
			<div class="title">类型</div>
			<ul class="list">
{% for type in types %}
				<li>
					<a href="#{{ type.name }}"><span class="entry">{{ type.name }}</span></a>
				</li>
{% endfor %}
			</ul>
		</div>

		<div class="service-description">
			<div class="title">描述</div>
			<p class="doc-lines">
				{{ doc_lines|join('\\n') }}
			</p>
		</div>
		<div class="service-interfaces">
			<div class="title">接口</div>
			<ul class="list">
{% for interface in interfaces %}
				<li>{{ interface }} [ <a href="{{ interface }}">url</a> <a href="{{ interface }}/description">description</a> ]</li>
{% endfor %}
			</ul>
			<ul class="list">
				<a href="/webservice/rpc_static/js_demo.jpg">Javascrip调用示例</a> | <a href="/webservice/rpc_static/java_demo.jpg">Java调用示例</a> | <a href="/webservice/rpc_static/tool_demo.jpg">SOAP调用工具示例</a> | <a href="/webservice/rpc_static/WebServiceStudio.zip">调试工具下载</a>
			</ul>
		</div>
		<div class="service-api">
			<div class="methods">
				<div class="title">方法</div>
				<ul class="list">
	{% for method in methods %}
					<li class="entry">
						<div class="declaration">
							<a name="{{ method.methodname }}"></a><span class="name">{{ method.methodname }}</span>
							(
		{% set sep = '' %}
		{% for param in method.params %}
							{{ sep }} 
							<span class="param-type">
			{% if param.ladontype %}
								<a href="#{{ param.ladontype }}">{{ param.type }}</a>
			{% else %}
								{{ param.type }}
			{% endif %}
							</span> 
							<span class="param-name">{{ param.name }}</span>
			{% set sep = ',' %}
		{% endfor %}
							)
						</div>
						<p class="doc-lines">
							{{ method.doc_lines|join('\\n') }}
						</p>
		{% for param in method.params %}
			{% if loop.first %}
						<div class="params-title">Parameters</div>
						<ul class="params">
			{% endif %}
							<li>
								<span class="param-name">{{ param.name }}</span>: <span class="param-type">
			{% if param.ladontype %}
									<a href="#{{ param.ladontype }}">{{ param.type }}</a>
			{% else %}
									{{ param.type }}
			{% endif %}
			<script>
				if (debug){
					window.document.write('<input type="text" name="{{ method.methodname }}@{{ param.name }}" id="{{ method.methodname }}@{{ param.name }}"/>');
				}
			</script>
								</span>
			{% if param.optional %}
								[ default: {{ param.default }} ]
			{% endif %}
								<br/>
								<p class="doc-lines">
									{{ param.doc_lines|join('\\n') }}
								</p>
							</li> 
			{% if loop.last %}
						</ul>
			{% endif %}
		{% endfor %}
						<div class="return-type-title">Return value</div>
						<div class="return-type">
							<span class="param-type">
		{% if method.returns.ladontype %}
								<a href="#{{ method.returns.ladontype }}">{{ method.returns.type }}</a>
		{% else %}
								{{ method.returns.type }}
		{% endif %}
			<script>
				if (debug){
					window.document.write('<input type="text" readonly="readonly" class="ret_value" name="ret_{{ method.methodname }}" id="ret_{{ method.methodname }}"/>');
				}
			</script>
							</span>
							<p class="doc-lines">
								<script>
									if (debug){
										window.document.write('<button onclick="do_action(\'{{ method.methodname }}\')">执行</button>');
									}
								</script>
								{{ method.returns.doc_lines|join('\\n') }}
							</p>
						</div>
						<div class="code_div"><a href="#" onclick="switch_code()">Javascript</a> | <a href="#" onclick="switch_code()">Java</a> | <a href="#" onclick="switch_code()">Python</a></div>
						<div id="js_code" class="code_div">
							test for Javascript code
						</div>
						<div id="java_code" class="code_div">
							test for Java code
						</div>
						<div id="python_code" class="code_div">
							test for Python code
						</div>
					</li>
	{% endfor %}
				</ul>
			</div>
			<div class="types">
				<div class="title">类型</div>
				<ul class="list">
	{% for type in types %}
					<li class="entry">
						<div class="definition">
							<a name="{{ type.name }}"></a><span class="name">{{ type.name }}</span>
						</div>
						<div class="attributes-title">Attributes</div>
						<ul class="attributes">
		{% for k,v in type.attributes.items() %}
							<li>
								<span class="param-name">{{ k }}</span>:
								<span class="param-type">
			{% if v.ladontype %}
									<a href="#{{v.ladontype}}">{{ v.type }}</a>
			{% else %}
									{{ v.type }}
			{% endif %}
								</span>
			{% set prefix = '[' %}
			{% set suffix = '' %}
			{% if 'nullable' in v.props and v.props.nullable==True %}
								{{ prefix }} Nullable
				{% set prefix = ' |' %}
				{% set suffix = ' ]' %}
			{% endif %}
			{% if 'default' in v.props %}
								{{ prefix }} default: {{ v.props.default }}
				{% set prefix = ' | ' %}
				{% set suffix = ' ]' %}
			{% endif %}
			{{ suffix }}
			{% if 'doc' in v.props %}
								<br/>
								<p class="doc-lines">
									{{ v.props.doc|join('\\n') }}
								</p>
			{% endif %}
							</li>
		{% endfor %}
						</ul>
					</li>
	{% endfor %}
				</ul>
			</div>
		</div>
		<div class="service-footer">Powered by Jone @2013 for Mole</div>
	</body>
</html>
