Os paso el script a ver si me podéis decir donde está el fallo.
Código PHP:
var APKs = new Array();
var num_items = 1000;
function importXML(){
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open("GET","info.xml",false);
xmlhttp.send();
var xmlDoc=xmlhttp.responseXML;
return xmlDoc;
}
function loadRepository(){
var xmlDoc = importXML();
if(xmlDoc != null){
var apps = xmlDoc.documentElement.getElementsByTagName('package');
var app;
for(var i = 0; i < apps.length; i++){
app = apps.item(i);
addAPK(app);
}
quicksort(APKs, 0, APKs.length - 1);
}
}
function addAPK(app){
var attributes = app.childNodes;
var apk = new Array();
apk['name'] = attributes[0].textContent;
apk['path'] = attributes[1].textContent;
apk['version'] = attributes[2].textContent;
apk['vercode'] = attributes[3].textContent;
apk['apkid'] = attributes[4].textContent;
apk['icon'] = attributes[5].textContent;
apk['fecha'] = attributes[6].textContent;
APKs[APKs.length] = apk;
}
function print(word, first, limit, search){
var container = document.getElementById("app_list");
var content = "";
var apk = new Array();
var name;
var source;
var version;
var icon;
var date;
var fecha;
var apkid;
var vercode;
if(limit > APKs.length || (search && word!="")){
limit = APKs.length;
}
for(var i = first; i < limit; i++){
apk = APKs[i];
name = apk['name'].substring(0,30);
source = apk['path'];
icon = apk['icon'];
vercode = apk['vercode'];
apkid = apk['apkid'];
fecha = apk['fecha'];
version = apk['version'].substring(0,30);
if (apk['name'].toLowerCase().charAt(0) == 'b'){
if(apk['name'].toLowerCase().indexOf(word.toLowerCase()) >= 0 || word == ""){
content += "<div class='resultList'><span><a href='http://repo2.altmarket.mobi/"+source+"' class='result' style='text-decoration: none;' title="+name+"><span><img src='http://repo2.altmarket.mobi/"+icon+"' onerror='this.src=\"images/android_icon.png\"' class='icon'><span class='appSnippet'><span class='appTitle'>"+name+"</span><span class='dev'>Version: "+version+"</span><span class='snippet'>Fecha: "+fecha+"</span></span><span class='clear'></span></span></a></span></div>";
}
}
}
if(limit != APKs.length){
first = limit;
limit += num_items;
content += "<div class='more_items' onclick='this.style.display=\"none\"; print(\"\","+first+", "+ limit +", false);'><img class='more_items' src='images/more.gif' </div>";
}
if(search){
container.innerHTML = content;
}else{
container.innerHTML += content;
}
}
function set(list, pos, limit)
{
var i;
var pivot;
var pivot_value;
var temp;
pivot = pos;
pivot_value = list[pivot];
for (i=pos+1; i<=limit; i++){
if ((list[i]['name'].toLowerCase() < pivot_value['name'].toLowerCase()) || (list[i]['name'].toLowerCase() == pivot_value['name'].toLowerCase() && list[i]['version'] > pivot_value['version'])){
pivot++;
temp=list[i];
list[i]=list[pivot];
list[pivot]=temp;
}
}
temp=list[pos];
list[pos]=list[pivot];
list[pivot]=temp;
return pivot;
}
function quicksort(list, pos, limit)
{
var pivot;
if(pos < limit){
pivot=set(list, pos, limit);
quicksort(list, pos, pivot-1);
quicksort(list, pivot+1, limit);
}
}