mejoras en la api

This commit is contained in:
humano 2017-11-06 16:29:33 -05:00
parent 9b9d3ed8d2
commit 919fd5e05a
3 changed files with 77 additions and 69 deletions

View File

@ -405,7 +405,10 @@ if ($variable !=''){
<link rel='stylesheet' type='text/css' href='librerias/slick/style.css'> <link rel='stylesheet' type='text/css' href='librerias/slick/style.css'>
<script src='manup.js'></script> <script src='manup.js'></script>
"; ";
$librerias_cabeza ="$presentacion_cabeza $librerias_galeria"; $librerias_cabeza ="$presentacion_cabeza $librerias_galeria
";
$librerias_pie ="$aplicacion_pie $librerias_pie ="$aplicacion_pie
<!-- <script> <!-- <script>
if('serviceWorker' in navigator) { if('serviceWorker' in navigator) {
@ -414,30 +417,67 @@ if('serviceWorker' in navigator) {
.then(function() { console.log('Service Worker Registered'); }); .then(function() { console.log('Service Worker Registered'); });
} }
</script> --> </script> -->
<script>
document.getElementById('scroll-content').addEventListener('scroll', function (event) {
var newDiv = document.createElement('div'); <script type = 'text/javascript' >
newDiv.innerHTML = 'my awesome new div'; $(document).ready(function() {
document.getElementById('scroll-content').appendChild(newDiv);
loadArticle(1);
loadArticle(2);
loadArticle(3);
loadArticle(4);
loadArticle(5);
loadArticle(6);
loadArticle(7);
var count = 8;
$('div').scroll(function() {
var offset = $('#scroll-content div').length;
var \$this = $(this);
var height = this.scrollHeight - \$this.height(); // Get the height of the div
var scroll = \$this.scrollTop(); // Get the vertical scroll position
var isScrolledToEnd = (scroll >= height);
$('.scroll-pos').text(scroll);
$('.scroll-height').text(height);
if (isScrolledToEnd) {
loadArticle(count);
count++;
}
});
}); });
var checkForNewDiv = function () { function loadArticle(pageNumber) {
var lastDiv = document.querySelector('#scroll-content > div:last-child');
var maindiv = document.querySelector('#scroll-content'); var newDiv = document.createElement('div');
var lastDivOffset = lastDiv.offsetTop + lastDiv.clientHeight; //newDiv.setAttribute('class', 'container');
var pageOffset = maindiv.offsetTop + maindiv.clientHeight; // var contenido ='Hola mundo '+ pageNumber;
if (pageOffset > lastDivOffset - 10) { // newDiv.innerHTML = contenido;
var newDiv = document.createElement('div');
newDiv.innerHTML = 'my awesome new div'; //newDiv.innerHTML.append(html);
document.getElementById('scroll-content').appendChild(newDiv); document.getElementById('scroll-content').appendChild(newDiv);
checkForNewDiv();
} $.ajax({
}; //url: 'get-post.php?variable='+(offset),
url: 'milfs/api.php?id=$form&tipo=simple&formato=li&plantilla=landingpage&registros=1&pagina=' + pageNumber,
type: 'POST',
dataType: 'html',
success: function(html) {
// $('#scroll-contentx').append(html);
var contenido = html;
newDiv.innerHTML = contenido;
}
});
}
checkForNewDiv();
</script> </script>
"; ";
$registros = aplicacion_carrusel("$form",'10','','embebido','',"carousel"); $registros = aplicacion_carrusel("$form",'10','','embebido','',"carousel");
@ -517,9 +557,15 @@ checkForNewDiv();
<section id='mapa'> <section id='mapa'>
$mapa $mapa
</section> </section>
<section id='listado' class='scrollable'> <section id='listado' class='' >
<div class='container-fluid'>
<div id='scroll-content' style='overflow-y: scroll; overflow-x: hidden; max-height: calc(100vh - 50px);
min-height: calc(100vh - 50px); '>
</div>
</div>
</section> </section>
</div> </div>
</div>$footer"; </div>$footer";
@ -1352,15 +1398,10 @@ $(document).ready(function() {
<style> <style>
#scroll-content > div {
background: #c0c0c0;
height: 40px;
margin-bottom: 5px;
}
#scroll-content #scroll-content
{ {
height:300px;
overflow:auto;
} }
</style> </style>

View File

@ -36,49 +36,16 @@
if (isScrolledToEnd) { if (isScrolledToEnd) {
loadArticle(count); loadArticle(count);
// var additionalContent = GetMoreContent(); // Get the additional content
//alert("hola");
count++; count++;
document.getElementById("paginas").innerHTML=count;
/*
var newDiv = document.createElement("div");
newDiv.setAttribute("class", "container");
$.ajax({
//url: 'get-post.php?variable='+(offset),
url: '../milfs/api.php?id=74&tipo=simple&formato=li&registros=1&pagina='+offset,
dataType: 'html',
success: function(html) {
// $('#scroll-contentx').append(html);
var contenido = html;
// $('#loading').hide();
newDiv.innerHTML = contenido;
//newDiv.innerHTML.append(html);
} }
}); });
document.getElementById("scroll-content").appendChild(newDiv);
document.getElementById("paginas").innerHTML=offset;
// checkForNewDiv();
*/
// $this.append(additionalContent); // Append the additional content
}
});
}); });
function loadArticle(pageNumber){ function loadArticle(pageNumber){
var newDiv = document.createElement("div"); var newDiv = document.createElement("div");
newDiv.setAttribute("class", "container"); // newDiv.setAttribute("class", "container");
// var contenido ="Hola mundo "+ pageNumber; // var contenido ="Hola mundo "+ pageNumber;
// newDiv.innerHTML = contenido; // newDiv.innerHTML = contenido;
@ -112,11 +79,11 @@ appendScroll: $('#scroll-content')
<body> <body>
<div class='container' style="overflow-y: scroll; overflow-x: hidden; height: 400px; border: 1px solid red;"> <div class='container' style="overflow-y: scroll; overflow-x: hidden; height: 400px; border: 1px solid red;">
<div id="wrapper">
<div id="scroll-content"> <div id="scroll-content">
<div id='posts'></div>
</div>
</div> </div>
</div> </div>
<div id='paginas'>las paginas</div> <div id='paginas'>las paginas</div>
Scroll Height: <span class="scroll-height"></span> <br/> Scroll Height: <span class="scroll-height"></span> <br/>

View File

@ -32,7 +32,7 @@ if(!isset($_REQUEST['formato'])) {
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json($datos); echo json($datos);
}else{ }else{
echo "$datos[pagina] ".consultar_contenido_formulario("$datos[id]","$datos[registros]","$datos[pagina]","$datos[formato]",'',"$datos[plantilla]"); echo "<br><br><div class='container-fluid '>".consultar_contenido_formulario("$datos[id]","$datos[registros]","$datos[pagina]","$datos[formato]",'',"$datos[plantilla]")."</div>";
} }
//echo "hola /// $_REQUEST[id] // " ; //echo "hola /// $_REQUEST[id] // " ;