Learn how to use jQuery at the Blog

Gaza Sderot « visit

  • Added 7 months ago
  • 212 Lines of Code shown
  • 1 Links of Interest
http://gaza-sderot.arte.tv/en/time
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 Gaza Sderot - http://gaza-sderot.arte.tv/en/time

function update_timeline(data,page,lang){
	$('.player').html('<div class="loader"><img src="'+base_url+'img/ajax-loader4.gif" alt="please wait.." /></div>');	
	
	$(".wr_content").animate({
	
	opacity: 'toggle'
	
	}, vitesse, 'swing', function() {
	
		htmlDatas = '';
		jQuery.each(data.datas, function(i,val) {
								   
			htmlDatas += '<div class="time-'+this.twn_smart_name+' content" >';
			
				htmlDatas += '<div id="player-'+this.twn_smart_name+'-'+this.vid_id+'" class="player">';
					htmlDatas += '<div class="loader">';
						htmlDatas += '<img src="'+base_url+'/img/ajax-loader3.gif" alt="please wait.." />';
					htmlDatas += '</div>';
				htmlDatas += '</div>';
				
				htmlDatas += '<div class="wr_content" style="display:none;">';
				if(lang == "en" || lang == "ar" || lang == "he"){
					htmlDatas += '<h2>'+this.vid_date_mois+'-'+this.vid_date_jour+'-'+this.vid_date_annee+'</h2>';
				}else{
					htmlDatas += '<h2>'+this.vid_date_jour+'-'+this.vid_date_mois+'-'+this.vid_date_annee+'</h2>';	
				}
				htmlDatas += '<h3>'+this.chr_first_name+' '+this.chr_name+'</h3>';
				htmlDatas += '<h4>'+this.vdat_place_name+'</h4>';
				
				htmlDatas += '<p>';
					htmlDatas += this.vdat_description;
					htmlDatas += '&nbsp;<a href="'+base_url+''+lang+'/'+this.vid_date_mois+'_'+this.vid_date_jour+'_'+this.vid_date_annee+'_'+this.twn_smart_name+'_'+this.vid_smart_name+'">[more]</a>';
				htmlDatas += '</p>';
				
				htmlDatas += '<div class="more">';
					htmlDatas += '<a href="'+base_url+''+lang+'/'+this.vid_date_mois+'_'+this.vid_date_jour+'_'+this.vid_date_annee+'_'+this.twn_smart_name+'_'+this.vid_smart_name+'#comments">Comment</a>';
					if( this.com_count != null ){
						htmlDatas += '('+this.com_count+')';
					}
					htmlDatas += ' • ';
					htmlDatas += '<a href="'+base_url+''+lang+'/'+this.vid_date_mois+'_'+this.vid_date_jour+'_'+this.vid_date_annee+'_'+this.twn_smart_name+'_'+this.vid_smart_name+'#share">Share</a>';
				htmlDatas += '</div>';
				htmlDatas += '</div>';
				
			htmlDatas += '</div>';
			
			
		});
		$("#page .time").attr({ id: "page"+(page) });
		$('#wrapper_timeline').html(htmlDatas);	
		
		jQuery.each(data.datas, function(i,val) {
			var son = new SWFObject(base_url+"swf/VideoPlayer.swf", "gazavideo", "418", "360", "9.0.115", "#080808");
			son.addParam('allowFullScreen', 'true');
			son.addVariable( "url", data.flvurl+"flv/"+this.twn_smart_name+"/"+this.vid_url );
			son.addVariable( "subtitles", base_url+"subtitles/"+lang+"/"+this.vid_id+".xml" );
			son.addVariable( "image", base_url+"images/videos/575_460/"+this.vid_id+".jpg");
			son.addVariable( "name", this.chr_name );
			son.addVariable( "surname", this.chr_first_name);
			son.addVariable( "place", this.vdat_place_name);
			son.addVariable( "city", this.twn_smart_name);
			if(lang == "en" || lang == "ar" || lang == "he"){
				son.addVariable( "date", this.vid_date_mois+"/"+this.vid_date_jour+"/"+this.vid_date_annee);
			}else{
				son.addVariable( "date", this.vid_date_jour+"/"+this.vid_date_mois+"/"+this.vid_date_annee);
			}
			son.useExpressInstall(base_url+"swf/expressinstall.swf");
			son.write( "player-"+this.twn_smart_name+"-"+this.vid_id );
		});	
		
		$(".wr_content").animate({
		 opacity: 'toggle'
		 }, vitesse, 'swing');
		
		if( page == 1 ){
			$('#next').hide();
		}
		if( page == nbpage ){
			$('#prev').hide();
		}
	
	}
	);
}

function time_page(page,lang,sens){
	if( sens== 1 ){
		page--;	
	}
	if( sens== -1 ){
		page++;	
	}
	
	if( page>=1 && page<=nbpage ){
		
		$.getJSON(base_url + lang + "/basdebit/ajax/?method=getEpisodePage&page="+page+"&callback=?",
				function(data){	
					update_timeline(data,page,lang);
				}
		);
		
	}
	return false;
}

function resizeNav(){
	if($(window).width()<1250){
		$('#prev').width(65);
		$('#next').width(65);
	}else{
		$('#prev').width(165);
		$('#next').width(165);		
	}
}

/***************/

$(document).ready(function() {
	base_url = $("#home").attr("href");
	vitesse = 1600;
	
	resizeNav();
	$(window).resize(resizeNav);
	
	nbpage = $("#page").attr("class");
	indiceDepart = nbpage.lastIndexOf('s')+1;
	indiceArrivee = nbpage.length;
	nbpage = parseInt(nbpage.substring(indiceDepart, indiceArrivee));
	
	//$('#next').hide();
		
	$("#next a").click(function(){	
		$('#prev').show();
		var page = $("#page .time").attr("id");
		indiceDepart = page.lastIndexOf('e')+1;
		indiceArrivee = page.length;
		page = parseInt(page.substring(indiceDepart, indiceArrivee));
		
		lang = $("body").attr("lang");
		time_page(page,lang,1);return false;
		
		return false;
	});
	$("#prev a").click(function(){
		$('#next').show();
		var page = $("#page .time").attr("id");
		indiceDepart = page.lastIndexOf('e')+1;
		indiceArrivee = page.length;
		page = parseInt(page.substring(indiceDepart, indiceArrivee));
		
		lang = $("body").attr("lang");
		time_page(page,lang,-1);return false;
		
		return false;
	});
});



$(document).ready(function() {
						   
	jQuery.each($("#footer ul li.title a"),function() {
				
		title =  $(this).attr("title");
		lang =  $(this).attr("lang");
		$("#footer").before( '<div class="nicetitle '+lang+'">'+title+'</div>' );
				
	});
	
	jQuery.each($("#footer ul li.title a"),function() {
		$(this).mouseover(function(){
								   
			position = $(this).findPos();
			posy = position.y;
			posx = position.x;
				
			lang =  $(this).attr("lang");
			
			if( lang=="he" || lang=="ar" ){
				$(".nicetitle").hide();				   
				$('.'+lang).show();
				
				$(".nicetitle").css({
					left: posx - 300,
					top:posy-40,
					height:18
				})
			}
			
		});	
		
		$(this).mouseout(function(){
				$(".nicetitle").hide();				   
		});	
								   
	});
	
});

//extension jquery pour position d'un element
jQuery.fn.extend({
   findPos : function() {
       obj = $(this).get(0);
       var curleft = obj.offsetLeft || 0;
       var curtop = obj.offsetTop || 0;
       while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                curtop += obj.offsetTop
       }
       return {x:curleft,y:curtop};
   }
});