Learn how to use jQuery at the Blog

Microjobs « visit

  • Added 9 months ago
  • 76 Lines of Code shown
  • 2 Links of Interest
http://microjobs.ro
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 Microjobs - http://microjobs.ro

$(document).ready(function() { 
	
	$('#tab1').attr("href", "javascript:tab(1);");
	$('#tab2').attr("href", "javascript:tab(2);");
	$('#tab3').attr("href", "javascript:tab(3);");
	$('#more').attr("href", "");
	
	$('#search').submit(function() {
								 
		if($("input:first").val() != '') {

			$('#tab1').removeClass("selected");
			$('#tab2').removeClass("selected");
			$('#tab3').removeClass("selected");
			
			document.title = 'Rezultatele cautarii pentru: ' + $("input:first").val() + ' - Microjobs: Joburi de pe Twitter';
			$('#continut').html('<div class="loading"><img src="images/ajax-loader.gif" alt="loading" /></div>');
			$.ajax({
			  type: "POST",
			  url: "inc/ajax.php",
			  data: "cmd=cauta&val=" + $("input:first").val(),
			  success: function(msg){
				$('#continut').hide();
				$('#continut').html(msg);
				$('#continut').fadeIn();
			  }
			});
		}
		return false;

    });
	
});

/* more action*/
function more(ofs) { 
	var next = ofs + 10;
	$('#more_host'+ofs).html('<div style="min-height: 400px; margin: 0 auto; margin-top: 50px; width: 43px;"><img src="images/ajax-loader.gif" alt="loading" /></div>');
	var cmd = '1';
	if($('#tab2').hasClass("selected")) cmd = '2';
	if($('#tab3').hasClass("selected")) cmd = '3';
	if($("input:first").val() != '' ) cmd = 'cauta';
	
	$.ajax({
	  type: "POST",
	  url: "inc/ajax.php",
	  data: "cmd=" + cmd + "&val=" + $("input:first").val() + "&ofs=" + ofs + "&next=" + next,
	  success: function(msg){
		$('#more_host'+ofs).html(msg);
	  }
	});
	return false;
}

function tab(id) {
	$('#tab1').removeClass("selected");
	$('#tab2').removeClass("selected");
	$('#tab3').removeClass("selected");
	$('#tab' + id).addClass("selected");
	
	document.title = $('#tab' + id + ' span.mare').html() + ' - Microjobs: Joburi de pe Twitter';
	
	$('#continut').html('<div class="loading"><img src="images/ajax-loader.gif" alt="loading" /></div>');
	
	$.ajax({
	  type: "POST",
	  url: "inc/ajax.php",
	  data: "cmd=" + id,
	  success: function(msg){
		$('#continut').hide();
		$('#continut').html(msg);
		$('#continut').fadeIn();
	  }
	});
	
}