| @@ 320-335 (lines=16) @@ | ||
| 317 | </article> |
|
| 318 | ||
| 319 | <article> |
|
| 320 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
| 321 | <h2>Comment on Jodel</h2> |
|
| 322 | <form method="POST"> |
|
| 323 | <input type="hidden" name="ancestor" value="<?php echo $_GET['postID'];?>" /> |
|
| 324 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
|
| 325 | <br /> |
|
| 326 | <input type="submit" value="SEND" /> |
|
| 327 | </form> |
|
| 328 | <?php } else { ?> |
|
| 329 | <h2>New Jodel</h2> |
|
| 330 | <form method="POST"> |
|
| 331 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
|
| 332 | <br /> |
|
| 333 | <input type="submit" value="SEND" /> |
|
| 334 | </form> |
|
| 335 | <?php } ?> |
|
| 336 | ||
| 337 | </article> |
|
| 338 | ||
| @@ 378-418 (lines=41) @@ | ||
| 375 | $(this).addClass('selected'); |
|
| 376 | }); |
|
| 377 | ||
| 378 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 379 | $(document).ready(function() { |
|
| 380 | var win = $(window); |
|
| 381 | var lastPostId = "<?php echo $lastPostId; ?>"; |
|
| 382 | var old_lastPostId = ""; |
|
| 383 | var morePostsAvailable = true; |
|
| 384 | // Each time the user scrolls |
|
| 385 | win.scroll(function() { |
|
| 386 | // End of the document reached? |
|
| 387 | if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) { |
|
| 388 | $('#loading').show(); |
|
| 389 | ||
| 390 | ||
| 391 | ||
| 392 | $.ajax({ |
|
| 393 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId, |
|
| 394 | dataType: 'html', |
|
| 395 | async: true, |
|
| 396 | success: function(html) { |
|
| 397 | var div = document.createElement('div'); |
|
| 398 | div.innerHTML = html; |
|
| 399 | var elements = div.childNodes; |
|
| 400 | old_lastPostId = lastPostId; |
|
| 401 | lastPostId = elements[3].textContent; |
|
| 402 | lastPostId = lastPostId.replace(/\s+/g, ''); |
|
| 403 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
|
| 404 | if(lastPostId == old_lastPostId) { |
|
| 405 | ||
| 406 | //morePostsAvailable = false; |
|
| 407 | } |
|
| 408 | else { |
|
| 409 | //alert(elements[3].textContent); |
|
| 410 | $('#posts').append(elements[1].innerHTML); |
|
| 411 | } |
|
| 412 | $('#loading').hide(); |
|
| 413 | } |
|
| 414 | }); |
|
| 415 | } |
|
| 416 | }); |
|
| 417 | }); |
|
| 418 | <?php } ?> |
|
| 419 | </script> |
|
| 420 | ||
| 421 | </body> |
|