Code Duplication    Length = 96-96 lines in 2 locations

admin.php 1 location

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

index.php 1 location

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