| @@ 322-337 (lines=16) @@ | ||
| 319 | </article> |
|
| 320 | ||
| 321 | <article> |
|
| 322 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
| 323 | <h2>Comment on Jodel</h2> |
|
| 324 | <form method="POST"> |
|
| 325 | <input type="hidden" name="ancestor" value="<?php echo $_GET['postID'];?>" /> |
|
| 326 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
|
| 327 | <br /> |
|
| 328 | <input type="submit" value="SEND" /> |
|
| 329 | </form> |
|
| 330 | <?php } else { ?> |
|
| 331 | <h2>New Jodel</h2> |
|
| 332 | <form method="POST"> |
|
| 333 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
|
| 334 | <br /> |
|
| 335 | <input type="submit" value="SEND" /> |
|
| 336 | </form> |
|
| 337 | <?php } ?> |
|
| 338 | ||
| 339 | </article> |
|
| 340 | </aside> |
|
| @@ 359-399 (lines=41) @@ | ||
| 356 | $(this).addClass('selected'); |
|
| 357 | }); |
|
| 358 | ||
| 359 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 360 | $(document).ready(function() { |
|
| 361 | var win = $(window); |
|
| 362 | var lastPostId = "<?php echo $lastPostId; ?>"; |
|
| 363 | var old_lastPostId = ""; |
|
| 364 | var morePostsAvailable = true; |
|
| 365 | // Each time the user scrolls |
|
| 366 | win.scroll(function() { |
|
| 367 | // End of the document reached? |
|
| 368 | if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) { |
|
| 369 | $('#loading').show(); |
|
| 370 | ||
| 371 | ||
| 372 | ||
| 373 | $.ajax({ |
|
| 374 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId, |
|
| 375 | dataType: 'html', |
|
| 376 | async: true, |
|
| 377 | success: function(html) { |
|
| 378 | var div = document.createElement('div'); |
|
| 379 | div.innerHTML = html; |
|
| 380 | var elements = div.childNodes; |
|
| 381 | old_lastPostId = lastPostId; |
|
| 382 | lastPostId = elements[3].textContent; |
|
| 383 | lastPostId = lastPostId.replace(/\s+/g, ''); |
|
| 384 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
|
| 385 | if(lastPostId == old_lastPostId) { |
|
| 386 | ||
| 387 | //morePostsAvailable = false; |
|
| 388 | } |
|
| 389 | else { |
|
| 390 | //alert(elements[3].textContent); |
|
| 391 | $('#posts').append(elements[1].innerHTML); |
|
| 392 | } |
|
| 393 | $('#loading').hide(); |
|
| 394 | } |
|
| 395 | }); |
|
| 396 | } |
|
| 397 | }); |
|
| 398 | }); |
|
| 399 | <?php } ?> |
|
| 400 | </script> |
|
| 401 | ||
| 402 | </body> |
|