Learn how to use jQuery at the Blog

DLdisco « visit

  • Added 7 months ago
  • 179 Lines of Code shown
  • 0 Links of Interest
http://dldisco.com
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to DLdisco - http://dldisco.com

$(document).ready(function() {
	$('#overview').load('overview.htm');
	$('#search').focus();
	alterList();
	
	$('.menu a').click(function() {
		var loadFile = $(this).attr('href').substr(1) + ".htm";
		$('#overview object').remove();
		
		$('#overview').fadeOut('slow', function() {
			$('#overview').load(loadFile).fadeIn('slow', function() {
				$('#feedback_send_link').click(function() {
					if($('#feedback_text').val() != "") {
						var right = $(this).parent();
						var theFeedback = $('#feedback_text').val();
						right.html('Sending...');
						
						$.post("com/feedback.php", { text : theFeedback }, function(data) {
							right.html(data);
						});
					} else {
						alert('How about some Text?!');
					}
				});
			});
			
			$('#search').focus();
		});
	});
	
	$('#search').keydown(function(e) {
		if(e.keyCode == 13) {
			loadDiscography($(this).val());
		}
	});
	
	function loadDiscography(artist) {
		$('.loader img').fadeIn('slow');
		
		$.get("com/discography.php", { search:artist }, function(data) {
			$('.loader img').fadeOut('slow', function() {
				$('#result').html(data);
				
				scrollTop();
				$('.formats #Album').attr('checked', '1');
				filterResults('Album');
				commonFormats();
				alterList();
				
				$('#common').click(function() {
					commonFormats();
					$('#all').removeClass('current');
					$(this).addClass('current');
				});
				
				$('#all').click(function() {
					allFormats();
					$('#common').removeClass('current');
					$(this).addClass('current');
				});

				$('.formats ul li input').click(function() {
					filterResults($(this).attr('id'));
					scrollTop();
				});

				$('#result_search').keyup(function(e) {
					if($(this).val()) {
						findResults($(this).val());
						scrollTop();
					}
				});
				
				$('.links ul li a').click(function() {
					var lia = $(this);
					
					$(this).css('background', 'url(images/load.gif) no-repeat');
					$(this).css('background-position', '20px');

					$.get("com/rapidshare.php", { artist: $('#search').val(), title: $(this).attr('id') }, function(data) {
						lia.parent().append(data);
						lia.unbind('click');
						lia.css('background', 'none');
						
						bindLog();
					});
				});
			});
		});
	}
	
	function scrollTop() {
		$('html').animate({
			scrollTop: 419
		}, 'slow');
	}
	
	function filterResults(filter) {
		$('.links ul li').each(function() {
			if($(this).attr('id').indexOf(filter) != -1) {
				$(this).show();
			} else {
				$(this).hide();
			}
		});
		
		$('.links ul li ol li').show();
		$('#releasedas').text("Titles released as '" + filter + "'");
		alterList();
	}
	
	function findResults(filter) {
		$('.links ul li a').each(function() {
			if($(this).text().toLowerCase().indexOf(filter.toLowerCase()) != -1) {
				$(this).parent().show();
			} else {
				$(this).parent().hide();
			}
		});
		
		$('.links ul li ol li').show();
		$('#releasedas').text("Search results for '" + filter + "'");
		alterList();
	}
	
	function allFormats() {
		$('.formats ul li').each(function() {
			$(this).show();
		});
	}
	
	function commonFormats() {
		$('.formats ul li input').each(function() {
			if($(this).attr('id') == "Album" ||
			   $(this).attr('id') == "CD" ||
			   $(this).attr('id') == "CDr" ||
			   $(this).attr('id') == "Maxi" ||
			   $(this).attr('id') == "Single" ||
			   $(this).attr('id') == "LP" ||
			   $(this).attr('id') == "EP" ||
			   $(this).attr('id') == "MP3" ||
			   $(this).attr('id') == "Smplr") {
				$(this).parent().show();
			} else {
				$(this).parent().hide();
			}
		});
	}
	
	function alterList() {
		var odd = true;
		
		$('.links ul > li').each(function() {
			if($(this).css('display') != 'none') {
				$(this).removeClass('alt');
				
				if(odd) {
					$(this).addClass('alt');
					odd = false;
				} else {
					odd = true;
				}
			}
		});
	}
	
	function bindLog() {
		$('.links ul li ol li a').each(function() {
			$(this).unbind('click');
			
			$(this).click(function() {
				var artistText = $('h1 span').next().text();
				
				$.get('com/log.php', { artist: artistText, rLink: $(this).attr('href') });
				$.get('com/ping.php', { artist: artistText, rLink : $(this).attr('href') });
			});
		});
	}
});