window.onload = function() {
var request,
url = "examples.xml",
section = document.getElementsByTagName('section')[0],
categories = [],
iPad = navigator.userAgent.match(/iPad/i) != null,
retina = window.devicePixelRatio >= 2 ? true : false,
icon = (retina) ? (iPad) ? 'icon@144.png' : 'icon@2x.png' : (iPad) ? 'icon@72.png' : 'icon.png',
category, item, ul, element, ln, i, j;
try
{
// Firefox, Opera 8.0+, Safari
request=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
}
request.open('GET', url, false);
request.send(null);
if (request.status === 200) {
var xml=request.responseXML;
//获得根节点
var topNod=xml.documentElement;
element = document.createElement('header');
element.innerHTML = topNod.getElementsByTagName("itemName")[0].firstChild.data;
section.appendChild(element);
ln = topNod.getElementsByTagName("item");
for(i=0;i<ln.length;i++) {
ul = document.createElement('ul');
element = document.createElement('li');
element.innerHTML = [
'<a href="' + url + '">',
'<img src="' + topNod.getElementsByTagName("item")[i].getElementsByTagName("typeImg")[0].firstChild.data + '" />',
'<h3>' + topNod.getElementsByTagName("item")[i].getElementsByTagName("title")[0].firstChild.data + '</h3>',
'<p>' + topNod.getElementsByTagName("item")[i].getElementsByTagName("time")[0].firstChild.data + '</p>',
'</a>'
].join('');
ul.appendChild(element);
section.appendChild(ul);
}
document.getElementById('wrapper').style.opacity = 1;
}
};
var request,
url = "examples.xml",
section = document.getElementsByTagName('section')[0],
categories = [],
iPad = navigator.userAgent.match(/iPad/i) != null,
retina = window.devicePixelRatio >= 2 ? true : false,
icon = (retina) ? (iPad) ? 'icon@144.png' : 'icon@2x.png' : (iPad) ? 'icon@72.png' : 'icon.png',
category, item, ul, element, ln, i, j;
try
{
// Firefox, Opera 8.0+, Safari
request=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
}
request.open('GET', url, false);
request.send(null);
if (request.status === 200) {
var xml=request.responseXML;
//获得根节点
var topNod=xml.documentElement;
element = document.createElement('header');
element.innerHTML = topNod.getElementsByTagName("itemName")[0].firstChild.data;
section.appendChild(element);
ln = topNod.getElementsByTagName("item");
for(i=0;i<ln.length;i++) {
ul = document.createElement('ul');
element = document.createElement('li');
element.innerHTML = [
'<a href="' + url + '">',
'<img src="' + topNod.getElementsByTagName("item")[i].getElementsByTagName("typeImg")[0].firstChild.data + '" />',
'<h3>' + topNod.getElementsByTagName("item")[i].getElementsByTagName("title")[0].firstChild.data + '</h3>',
'<p>' + topNod.getElementsByTagName("item")[i].getElementsByTagName("time")[0].firstChild.data + '</p>',
'</a>'
].join('');
ul.appendChild(element);
section.appendChild(ul);
}
document.getElementById('wrapper').style.opacity = 1;
}
};