<aside class="main-sidebar">
    <section class="sidebar">
      <ul id="menu" class="sidebar-menu" data-widget="tree">
        <li class="header">HEADER</li>
        <!-- Optionally, you can add icons to the links -->
        <!--
		<li class="treeview">
          	<a href="#"><i class="fa fa-clock-o"></i> <span>任务管理</span>
            <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
            </span>
          	</a>
          	<ul class="treeview-menu">
	            <li><a href="/admin/task"><i class="fa fa-link"></i>抽取任务</a></li>
				<li><a href="/admin/task/export"><i class="fa fa-link"></i>导出任务</a></li>
			</ul>
        </li>
		<li><a href="/admin/version"><i class="fa fa-navicon"></i><span>版本管理</span></a></li>
		<li><a href="/admin/audit/recogfield"><i class="fa fa-navicon"></i><span>质量审核</span></a></li>
		<li class="treeview">
          	<a href="#"><i class="fa fa-laptop"></i> <span>统计</span>
            <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
            </span>
          	</a>
          	<ul class="treeview-menu">
	            <li><a href="/front/menuff"><i class="fa fa-circle-o"></i>菜单</a></li>
			</ul>
        </li>
		<li><a href="/front/usertest"><i class="fa fa-navicon"></i><span>结果追踪</span></a></li>
        <li><a href="/admin/distribution"><i class="fa fa-laptop"></i> <span>分布式抽取</span></a></li>
		<li class="treeview">
			<a href="/admin/user"><i class="fa fa-link"></i> <span>权限管理</span>
			<span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
            </span></a>
          	<ul class="treeview-menu">
	            <li><a href="/front/user"><i class="fa fa-circle-o"></i>人员管理</a></li>
				<li><a href="/admin/rule/pre"><i class="fa fa-circle-o"></i>角色管理</a></li>
				<li><a href="/front/menu"><i class="fa fa-circle-o"></i>菜单管理</a></li>
			</ul>
		</li>-->
      </ul>
    </section>
	<span id="role" class="hidden">{{(session "user").i_role}}</span>
</aside>
<script>
$(function () {
	$.post('/front/personalMenu','',function (data,status) {
		for(var a=0;a<data.data.length;a++) {
            var info=data.data[a]
		    if (info.secondmenu){
                var str=""
               	for(var sec=1;sec<=Object.keys(info.secondmenu).length;sec++){
                    var ro=$("#role").text()
                    if(ro=="0" || info.secondmenu[sec.toString(10)].role[ro] ) {
                        str = str + '<li><a href=' + info.secondmenu[sec.toString(10)].s_href + '><i class="' + info.secondmenu[sec.toString(10)].s_css + '"></i>' + info.secondmenu[sec.toString(10)].s_name + '</a></li>'
                    }
                }
                $('#menu').append('<li class="treeview">' +
                        '          <a href="#"><i class="'+info.s_css+'"></i> <span>'+info.s_name+'</span>' +
                        '            <span class="pull-right-container">' +
                        '                <i class="fa fa-angle-left pull-right"></i>' +
                        '            </span>' +
                        '          </a>' +
                        '          <ul class="treeview-menu">' + str+ '</ul>' +
                        '        </li>')
			}else{
                $('#menu').append('<li><a href='+info.s_href+'><i class="'+info.s_css+'"></i> <span>'+info.s_name+'</span></a></li>')
			}
        }
    })
})
function menuActive(name){
    setTimeout(function(){
      $(".sidebar-menu").tree();
    	$(".sidebar-menu").filter(".menu-open").removeClass("menu-open");
    	$(".sidebar-menu").filter(".active").removeClass("active");
        var a;
    	$(".sidebar-menu a").each(function(i){
    		if($(this).attr("href").endsWith(name)){
    			a=$(this)
    		}
    	});
      if (!a) {
        return menuActive(name)
      }
        a.parent().addClass("active");
        a.parent().parent().parent().addClass("active");
        a.parent().parent().parent().addClass("menu-open");
    },100);
}
 
</script>