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

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