Code Duplication    Length = 96-96 lines in 2 locations

admin.php 1 location

@@ 259-354 (lines=96) @@
256
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
257
				}
258
259
				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
260
261
				
262
263
264
265
				var win = $(window);
266
				var lastPostId = "<?php echo $lastPostId; ?>";
267
				var view = "<?php echo $view; ?>"
268
				var old_lastPostId = "";
269
				var morePostsAvailable = true;
270
271
				if(window.location.hash)
272
				{
273
					var hash = window.location.hash.slice(1);
274
275
					if(!$("article[id='"+ hash +"']").length)
276
					{
277
						for (var i = 5; i >= 0; i--)
278
						{
279
							if(!$("article[id='"+ hash +"']").length)
280
							{
281
								$.ajax({
282
									url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
283
									dataType: 'html',
284
									async: false,
285
									success: function(html) {
286
										var div = document.createElement('div');
287
										div.innerHTML = html;
288
										var elements = div.childNodes;
289
										old_lastPostId = lastPostId;
290
										lastPostId = elements[3].textContent;
291
										lastPostId = lastPostId.replace(/\s+/g, '');
292
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
293
										if(lastPostId == old_lastPostId) {
294
											
295
											//morePostsAvailable = false;
296
										}
297
										else {
298
											//alert(elements[3].textContent);
299
											$('#posts').append(elements[1].innerHTML);
300
											$('#posts').hide().show(0);
301
										}
302
										$('#loading').hide();
303
									}
304
								});
305
306
								$('.jodel > content').Emoji();
307
							}
308
							
309
						}
310
						scrollToAnchor(hash);
311
312
					}						
313
				}
314
315
				// Each time the user scrolls
316
				win.scroll(function() {
317
318
319
					// End of the document reached?
320
					if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) {
321
						$('#loading').show();
322
323
						
324
						
325
						$.ajax({
326
							url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
327
							dataType: 'html',
328
							async: false,
329
							success: function(html) {
330
								var div = document.createElement('div');
331
								div.innerHTML = html;
332
								var elements = div.childNodes;
333
								old_lastPostId = lastPostId;
334
								lastPostId = elements[3].textContent;
335
								lastPostId = lastPostId.replace(/\s+/g, '');
336
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
337
								if(lastPostId == old_lastPostId)
338
								{
339
									
340
									//morePostsAvailable = false;
341
								}
342
								else
343
								{
344
									//alert(elements[3].textContent);
345
									$('#posts').append(elements[1].innerHTML);
346
								}
347
								$('#loading').hide();
348
							}
349
						});
350
351
						$('.jodel > content').Emoji();
352
					}
353
				});
354
			<?php } ?>
355
			});	
356
357
		</script>

index.php 1 location

@@ 452-547 (lines=96) @@
449
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
450
				}
451
452
				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
453
454
				
455
456
457
458
				var win = $(window);
459
				var lastPostId = "<?php echo $lastPostId; ?>";
460
				var view = "<?php echo $view; ?>"
461
				var old_lastPostId = "";
462
				var morePostsAvailable = true;
463
464
				if(window.location.hash)
465
				{
466
					var hash = window.location.hash.slice(1);
467
468
					if(!$("article[id='"+ hash +"']").length)
469
					{
470
						for (var i = 5; i >= 0; i--)
471
						{
472
							if(!$("article[id='"+ hash +"']").length)
473
							{
474
								$.ajax({
475
									url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
476
									dataType: 'html',
477
									async: false,
478
									success: function(html) {
479
										var div = document.createElement('div');
480
										div.innerHTML = html;
481
										var elements = div.childNodes;
482
										old_lastPostId = lastPostId;
483
										lastPostId = elements[3].textContent;
484
										lastPostId = lastPostId.replace(/\s+/g, '');
485
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
486
										if(lastPostId == old_lastPostId) {
487
											
488
											//morePostsAvailable = false;
489
										}
490
										else {
491
											//alert(elements[3].textContent);
492
											$('#posts').append(elements[1].innerHTML);
493
											$('#posts').hide().show(0);
494
										}
495
										$('#loading').hide();
496
									}
497
								});
498
499
								$('.jodel > content').Emoji();
500
							}
501
							
502
						}
503
						scrollToAnchor(hash);
504
505
					}						
506
				}
507
508
				// Each time the user scrolls
509
				win.scroll(function() {
510
511
512
					// End of the document reached?
513
					if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) {
514
						$('#loading').show();
515
516
						
517
						
518
						$.ajax({
519
							url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
520
							dataType: 'html',
521
							async: false,
522
							success: function(html) {
523
								var div = document.createElement('div');
524
								div.innerHTML = html;
525
								var elements = div.childNodes;
526
								old_lastPostId = lastPostId;
527
								lastPostId = elements[3].textContent;
528
								lastPostId = lastPostId.replace(/\s+/g, '');
529
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
530
								if(lastPostId == old_lastPostId)
531
								{
532
									
533
									//morePostsAvailable = false;
534
								}
535
								else
536
								{
537
									//alert(elements[3].textContent);
538
									$('#posts').append(elements[1].innerHTML);
539
								}
540
								$('#loading').hide();
541
							}
542
						});
543
544
						$('.jodel > content').Emoji();
545
					}
546
				});
547
			<?php } ?>
548
			});	
549
550
		</script>