Code Duplication    Length = 16-41 lines in 2 locations

index.php 2 locations

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