<!--#include file="Links_Fun.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<%=sitepath%>css/bootstrap.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/font-awesome.min.css" rel="stylesheet">
<link href="<%=sitepath%>plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/animate.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/style.min.css" rel="stylesheet">
<link href="<%=sitepath&adminPath%>css/adminstyle.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../../inc/webuploader/css/webuploader.css" />
<link rel="stylesheet" type="text/css" href="../../inc/webuploader/css/style.css" />
<script src="<%=sitepath%>js/jquery.min.js"></script>
<script src="<%=sitepath&adminPath%>js/adminjs.js"></script>
<!--[if lte IE 9]>
<script src="<%=sitepath%>js/respond.min.js"></script>
<script src="<%=sitepath%>js/html5.js"></script>
<![endif]-->
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="row row-lg">
<div class="col-md-6">
							<div class="panel">
								<div class="panel-heading">
									<h3 class="panel-title">友情链接</h3>
									<div class="panel-aj">
										<button type="button" class="btn-toggle-collapse"><i class="fa fa-chevron-down"></i></button>
										<button type="button" class="btn-remove"><i class="fa fa-times"></i></button>
									</div>
								</div>
<div class="panel-body">
<div class="panel-body no-padding">		
<div class="ibox-content">

<div class="col-sm-12">
          <div class="col-sm-3">
            <button id="add" class="btn  btn-primary" type="button"><i class="fa fa-plus"></i> 添加</button>
            <button onClick="location.reload()" class="btn btn-primary1" type="button"><i class="fa fa-refresh"></i> 刷新</button>
            <!--<button onClick="closetab()" class="btn" type="button"><i class="fa fa-reply"></i> 关闭</button>-->
          </div>
         
            <div class="col-sm-4">
              <input type="text" name="SlideImg" id="pic"  value="" placeholder="图片上传后复制地址到对应的链接图片位置" class="form-control">
            </div>
             <div class="col-sm-2"><div id="link_upload">上传</div> </div>
            <div class="col-sm-2"><img src="" height="30" id="img_pic"></div>
         
          <FORM name="" action="" id="sortlist" method="post" class="form-horizontal">
            <table id="table"
           data-toggle="table"
           data-pagination="true"
           data-show-toggle="true"
           data-show-columns="true"          
           data-id-field="id"       
           data-id-table="advancedTable"
           data-page-size="10"
           data-page-list="[20,50,100]" >
              <thead>
                <tr>
                  <th class="tableid" data-field="id"  data-sortable="true">ID</th>
                  <th class="tablename" data-field="title"  data-sortable="true">名称</th>
                  <th class="tabletype" data-field="Ltype" data-sortable="true">类型</th>
                  <th class="tabletype" data-field="cid" data-sortable="true">分组</th>
                  <th class="tabletitle" data-field="pic" data-sortable="true">图片</th>
                  <th class="tableurl" data-field="url" data-sortable="true">地址</th>
                  <!--<th class="tableonoff" data-field="onoff" >状态</th>-->
                  <th class="tableorder" data-field="order" data-sortable="true">排序</th>
                  <th class="tableedit" data-field="edit" class="text-right">编辑</th>
                </tr>
              </thead>
              <%sql="select * from [dbpre]links order by L_order asc, LID asc"
			Dim rs,check1,check2,navicon,i,selected
			set rs=dbsqlr1(sql)
			do while not rs.eof 	
				check1=""
				check2=""
				navicon=""
				
				for i=1 to 4
				if rs("L_CID")=i then selected="selected" else selected=""
				navicon=navicon&"<option value='"&i&"' "&selected&">"&i&"组"
				next
				
				if rs("L_type")="pic" then 
				check1="selected" 
				else
				check2="selected" 
				end if
		echo"<tr>"&vbcrlf& _	
				"<td>"&rs("LID")&"</td>"&vbcrlf& _	
				"<td><input type='text' class='title' id='L_Name-"&rs("LID")&"'  placeholder='"&rs("L_Name")&"' value='"&rs("L_Name")&"'></td>"&vbcrlf& _	
				"<td><select placeholder='"&rs("L_type")&"' id='L_type-"&rs("LID")&"'><option value='text' "&check2&">文本</option><option value='pic' "&check1&">图片</option></select></td>"&vbcrlf& _	
				"<td><select placeholder='"&rs("L_cid")&"' id='L_cid-"&rs("LID")&"'>"&navicon&"</select></td>"&vbcrlf& _	
				"<td><input type='text' class='title' id='L_pic-"&rs("LID")&"' placeholder='"&rs("L_pic")&"' value='"&rs("L_pic")&"'></td>"&vbcrlf& _	
				"<td><input type='text' class='title' id='L_URL-"&rs("LID")&"' placeholder='"&rs("L_URL")&"' value='"&rs("L_URL")&"'></td>"&vbcrlf& _									
				" "&vbcrlf& _	
				"<td><input type='number' name='Orders' class='order'  min='0' max='99' id='L_order-"&rs("LID")&"'   placeholder='"&rs("L_order")&"' value="&rs("L_order")&"></td>"&vbcrlf& _	
			   	"<td><button type='button' class='btn btn-info dim' onclick=save('"&rs("LID")&"')><i class='fa fa fa-check'></i></button>　<button type='button'  onclick=dellinks('"&rs("LID")&"')  class='btn btn-danger dim'><i class='fa fa-times'></i></button></td>"&vbcrlf& _
			"</tr>"&vbcrlf 
			    '<td><button type='button'  onclick=setlinks('L_OnOff','"&rs("LID")&"') class='btn btn-"&rs("L_OnOff")&" dim'><i class='fa fa-toggle-on'></i></i></button></td> 		
		 rs.movenext
		 Loop
		closers rs%>
            </table>
          </FORM>
        </div>

</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<script type="text/javascript" src="../../inc/webuploader/js/webuploader.js"></script> 
<script type="text/javascript" charset="utf-8" src="../../inc/webuploader/config.asp"></script> 
<script type="text/javascript" src="../../inc/webuploader/js/oneupload.js"></script> 
<script>
$(function () {
	fileuploader("link_upload","image","link","pic","{pinyin}")
})
$("#add").click(function(){$('#table').bootstrapTable('insertRow',{
	index: 1, 
	row: {
		title:"<input type='text' class='title' id='title99' required value=''>",
		Ltype:"<select id='Ltype99'><option value='text' selected>文本</option><option value='pic'>图片</option></select>",	
		cid:"<input type='number' class='order' min='0' max='5' id='cid99' value='1'>",
		order:"<input type='number' class='order' min='0' max='99' id='order99' value='9'>",
		url:"<input type='text' class='title'  id='url99'  value='' required>",
		pic:"<input type='text' class='title'  id='pic99'  value=''>",
		edit:"<button type='button' class='btn btn-info dim' onclick='addnew(99)'><i class='fa fa fa-check'></i></button>"
		}
	})
	})


function addnew(id){
	var title=$("#title"+id).val()
	if(title==""){alert("名称不能为空");return false;}
	var Ltype=$("#Ltype"+id).val()	
	var order=$("#order"+id).val()
	var pic=$("#pic"+id).val()
	var url=$("#url"+id).val()
	if(url==""){alert("地址不能为空");return false;}
	var cid=$("#cid"+id).val()
	{$.post("links_Fun.asp?act=addnew",{"title":title,"Ltype":Ltype,"pic":pic,"url":url,"cid":cid,"order":order,"id":id}, function(data) {
		layer.msg('添加成功');
		location.reload();		
		});}
	}
$("#table").on("blur", "input,select", function() {
    var colval = $(this).val();
    var colplace = $(this).attr('placeholder')
    var colid = $(this).attr('id').split("-")[1];
    var colname = $(this).attr('id').split("-")[0];
    if (colid>0 && colval != colplace) {
        $(this).attr('placeholder', colval);
        $.post("links_Fun.asp?act=saveid",{"colval":colval,"colid":colid,"colname":colname},function(data){layer.msg('保存成功');});
    }
});
</script> 
<script src="<%=sitepath%>js/klorofil-common.js"></script>
<script src="<%=sitepath%>js/bootstrap.min.js"></script> 
<script src="<%=sitepath%>plugins/bootstrap-table/bootstrap-table.min.js"></script> 
<script src="<%=sitepath%>plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script> 
<script src="<%=sitepath%>plugins/layer/layer.min.js"></script>
</body>
</html>
