Foros del Web » Programando para Internet » Javascript »

buscador

Estas en el tema de buscador en el foro de Javascript en Foros del Web. Buenas noches: Estoy usando un buscador q encontre en la net, funciona bien, me ofrece resultados de palabras en minúsculas y mayúsculas, solo que intente ...
  #1 (permalink)  
Antiguo 18/02/2013, 22:14
Avatar de horizon  
Fecha de Ingreso: septiembre-2012
Mensajes: 9
Antigüedad: 11 años, 7 meses
Puntos: 0
buscador

Buenas noches:

Estoy usando un buscador q encontre en la net, funciona bien, me ofrece resultados de palabras en minúsculas y mayúsculas, solo que intente buscar 2 palabras y no me arroja ningun resultado, agradeceria si alguien me puede ayudar con este problema, desde ya muchas gracias a tds p su tiempo.



*/
window.onload = function() {
$("#arrowPrevious").click(function() {
$("#section" + currentPaginator).hide();
currentPaginator--;
$("#section" + currentPaginator).show();
$("#paginator span").html("Página " + currentPaginator + " de: " + totalPages);
if (currentPaginator === 1) {
$("#arrowPrevious").hide();
}
if (currentPaginator < totalPages) {
$("#arrowNext").show();
}
});

$("#arrowNext").click(function() {
$("#section" + currentPaginator).hide();
currentPaginator++;
$("#section" + currentPaginator).show();
$("#paginator span").html("Página " + currentPaginator + " de: " + totalPages);
if (totalPages == currentPaginator) {
$("#arrowNext").hide();
}
if (currentPaginator > 1) {
$("#arrowPrevious").show();
}
});

$("#wrapper, #found, #paginator").css("display", "block");
setTimeout(function() {
$("#wrapper").addClass("initWeb&quo t;);
}, 500);

};
var items = [];
var itemsFound = [];
function addItem(title, link, description) {
items.push({"title": title, "link": link, "description": description});
}

function search() {
itemsFound = [];
removeClass(document.getElementById("paginato r"), "initWeb");
removeClass(document.getElementById("found&qu ot;), "initWeb");
addClass(document.getElementById("logo") , "closeLogo");
setTimeout(function() {
var matchString = document.forms.searchForm.search.value;
for (var k in items) {
if (items[k].link.toLowerCase().indexOf(matchString.toLowerCas e()) !== -1)
itemsFound.push(items[k]);

if (k == (items.length - 1))
appendElements(itemsFound);
}
}, 1000);
}

function appendElements(itemsFound) {
document.getElementById("found").innerHT ML = "";
resetPaginator();
var totalData = itemsFound.length;
var show = 10;
var amountToSee = (totalData / show);
amountToSee = amountToSee.toString();
amountToSee = amountToSee.split(".");
console.log(amountToSee);
if (amountToSee[1]) {
if (amountToSee[0] == 0) {
$("#arrowNext").hide();
} else {
addClass(document.getElementById("paginator&q uot;), "initWeb");
}
amountToSee = amountToSee[0];
amountToSee++;
totalPages = amountToSee;

} else {
if (amountToSee[0] == 0) {
$.error = $(\
<div class="alert">\
No se han encontrado resultados. Por favor inserte una nueva palabra\
</div>\
);
$("#found").append($.error);
addClass(document.getElementById("found" ), "initWeb");
} else {
if (amountToSee[0] == 1) {
$("#arrowNext").hide();
}
totalPages = amountToSee;
}

}

var current = 0;
for (var s = 1; s <= amountToSee; s++) {
$.createDiv = $(<div id="section + s + " class="itemResult"></div>);
$("#found").append($.createDiv);
for (var i = (current * show); i <= ((show * s) - 1); i++) {
if (itemsFound[i]) {
$.result = $(\
<div class="itemResultado">\
<a href= + itemsFound[i].link + > + itemsFound[i].title + </a>\
<div class="linkGreen"> + itemsFound[i].link + </div>\
<div> + itemsFound[i].description + </div><br/>\
</div>\
);
$("#section" + s).append($.result);
if (i == ((show * s) - 1)) {
current++;
}
}

}
if (amountToSee == s) {
$("#paginator span").html("Página " + currentPaginator + " de: " + totalPages);
addClass(document.getElementById("found" ), "initWeb");
addClass(document.getElementById("paginator&q uot;), "initWeb");
$(".itemResultado").hover(
function() {
$(this).css("background", "#faf7f7");
},
function() {
$(this).css("background", "transparent");
}
);
}

}

}

function resetPaginator() {
totalPages = 0;
currentPaginator = 1;
$("#arrowPrevious").hide();
$("#paginator span").html("Página " + currentPaginator);
$("#arrowNext").show();
}

function hasClass(ele, cls) {
return ele.className.match(new RegExp((\\s|^) + cls + (\\s|$)));
}

function addClass(ele, cls) {
if (!this.hasClass(ele, cls))
ele.className += cls;
}

function removeClass(ele, cls) {
if (hasClass(ele, cls)) {
var reg = new RegExp((\\s|^) + cls + (\\s|$));
ele.className = ele.className.replace(reg, );
}
}
  #2 (permalink)  
Antiguo 19/02/2013, 09:32
Avatar de ipraetoriux  
Fecha de Ingreso: abril-2010
Ubicación: ipraetoriux.com
Mensajes: 1.125
Antigüedad: 14 años
Puntos: 155
Respuesta: buscador

...es que si pones asi el codigo, nadie te va a ayudar, porque no se entiende NADA...
  #3 (permalink)  
Antiguo 19/02/2013, 19:30
Avatar de horizon  
Fecha de Ingreso: septiembre-2012
Mensajes: 9
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: buscador

Código:
/* */
window.onload = function() {
    $("#arrowPrevious").click(function() {
        $("#section" + currentPaginator).hide();
        currentPaginator--;
        $("#section" + currentPaginator).show();
        $("#paginator span").html("Página " + currentPaginator + " de: " + totalPages);
        if (currentPaginator === 1) {
            $("#arrowPrevious").hide();
        }
        if (currentPaginator < totalPages) {
            $("#arrowNext").show();
        }
    });

    $("#arrowNext").click(function() {
        $("#section" + currentPaginator).hide();
        currentPaginator++;
        $("#section" + currentPaginator).show();
        $("#paginator span").html("P&aacute;gina " + currentPaginator + " de: " + totalPages);
        if (totalPages == currentPaginator) {
            $("#arrowNext").hide();
        }
        if (currentPaginator > 1) {
            $("#arrowPrevious").show();
        }
    });

    $("#wrapper, #found, #paginator").css("display", "block");
    setTimeout(function() {
        $("#wrapper").addClass("initWeb");
    }, 500);

};
var items = [];
var itemsFound = [];
function addItem(title, link, description) {
    items.push({"title": title, "link": link, "description": description});
}

function search() {
    itemsFound = [];
    removeClass(document.getElementById("paginator"), "initWeb");
    removeClass(document.getElementById("found"), "initWeb");
    addClass(document.getElementById("logo"), "closeLogo");
    setTimeout(function() {
        var matchString = document.forms.searchForm.search.value;
        for (var k in items) {
            if (items[k].link.toLowerCase().indexOf(matchString.toLowerCase()) !== -1)
                itemsFound.push(items[k]);

            if (k == (items.length - 1))
                appendElements(itemsFound);
        }
    }, 1000);
}

function appendElements(itemsFound) {
    document.getElementById("found").innerHTML = "";
    resetPaginator();
    var totalData = itemsFound.length;
    var show = 10;
    var amountToSee = (totalData / show);
    amountToSee = amountToSee.toString();
    amountToSee = amountToSee.split(".");
    console.log(amountToSee);
    if (amountToSee[1]) {
        if (amountToSee[0] == 0) {
            $("#arrowNext").hide();
        } else {
            addClass(document.getElementById("paginator"), "initWeb");
        }
        amountToSee = amountToSee[0];
        amountToSee++;
        totalPages = amountToSee;

    } else {
        if (amountToSee[0] == 0) {
            $.error = $('\
                                    <div class="alert">\
                                        No se han encontrado resultados. Por favor inserte una nueva palabra\
                                    </div>\
                                    ');
            $("#found").append($.error);
            addClass(document.getElementById("found"), "initWeb");
        } else {
            if (amountToSee[0] == 1) {
                $("#arrowNext").hide();
            }
            totalPages = amountToSee;
        }

    }

    var current = 0;
    for (var s = 1; s <= amountToSee; s++) {
        $.createDiv = $('<div id="section' + s + '" class="itemResult"></div>');
        $("#found").append($.createDiv);
        for (var i = (current * show); i <= ((show * s) - 1); i++) {
            if (itemsFound[i]) {
                $.result = $('\
				<div class="itemResultado">\
                                        <a href=' + itemsFound[i].link + '>' + itemsFound[i].title + '</a>\
                                        <div class="linkGreen">' + itemsFound[i].link + '</div>\
                                        <div>' + itemsFound[i].description + '</div><br/>\
				</div>\
				');
                $("#section" + s).append($.result);
                if (i == ((show * s) - 1)) {
                    current++;
                }
            }

        }
        if (amountToSee == s) {
            $("#paginator span").html("P&aacute;gina " + currentPaginator + " de: " + totalPages);
            addClass(document.getElementById("found"), "initWeb");
            addClass(document.getElementById("paginator"), "initWeb");
            $(".itemResultado").hover(
                    function() {
                        $(this).css("background", "#faf7f7");
                    },
                    function() {
                        $(this).css("background", "transparent");
                    }
            );
        }

    }

}

function resetPaginator() {
    totalPages = 0;
    currentPaginator = 1;
    $("#arrowPrevious").hide();
    $("#paginator span").html("P&aacute;gina " + currentPaginator);
    $("#arrowNext").show();
}

function hasClass(ele, cls) {
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}

function addClass(ele, cls) {
    if (!this.hasClass(ele, cls))
        ele.className += cls;
}

function removeClass(ele, cls) {
    if (hasClass(ele, cls)) {
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
        ele.className = ele.className.replace(reg, '');
    }
}

Etiquetas: buscador, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:06.