function autoLoadConf() {
$.ajax({
url: "../nav/conf/links.xml",
dataType: 'xml',
type: 'GET',
timeout: 2000,
error: function(xml)
{
alert("读取配置文件失败!");
},
success: function(xml)
{
var jqueryObject = $(xml);
var onlineArray = readXml(jqueryObject,"websites","online_websites","online_website");
addLiContent($("#onlineLinkUl"),onlineArray);
var weiArray = readXml(jqueryObject,"websites","wei_websites","wei_website");
addLiContent($("#weiLinkUl"),weiArray);
var neiArray = readXml(jqueryObject,"websites","nei_websites","nei_website");
addLiContent($("#neiLinkUl"),neiArray);
}
});
}
function readXml(jqueryObject,f1,f2,f3){
var arrayObject = new Array();
jqueryObject.find(f1).find(f2).find(f3).each(function(i){
var online = new Object();
online.title = $(this).find("title").text();
online.link = $(this).find("link").text();
arrayObject.push(online);
});
console.log(arrayObject);
return arrayObject;
}
function addLiContent(ulObject,arrayObject){
for(var i = 0;i<arrayObject.length;i++){
var hrefValue = arrayObject[i].link;
var titleValue = arrayObject[i].title;
var liHtml="<li class='item s"+((i+1)%9+1)+"' id=\"btn-in1\">"+
"<a href='"+hrefValue+"' target='_blank'>"+
"<p class=\"pic\"><span class=\"fa fa-database fa-5x\"></span></p>"+
"<p class=\"name\">"+titleValue+"</p><p><button class='btn-in in1' style=\"color: rgb(255, 255, 255); background: transparent;\">进入</button></p>"+
"</a></li>";
ulObject.append(liHtml);
}
}