Code Duplication    Length = 96-96 lines in 2 locations

admin.php 1 location

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

index.php 1 location

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