enmi12/glossaire/js/form.js
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 17:39:30 +0200
changeset 7 cf61fcea0001
parent 0 d970ebf37754
permissions -rwxr-xr-x
resynchronize code repo with production

$('.commentSection form').click(function(event){
	event.stopPropagation();

});

$('.commentSection input').focus(function(event){

	event.stopPropagation();
	console.log($(this).val() + '   ' + values[returnOldValue($(this).attr('name'))]);
	if($(this).val() == values[returnOldValue($(this).attr('name'))]){
		$(this).val(($(this).attr('name') == 'twitter') ?'@':'');
		$(this).css('color', '#000');
	}
});

$('.commentInput').focus(function(event){

	event.stopPropagation();
	
	if($(this).val() == values[returnOldValue($(this).attr('name'))]){
		$(this).val('');
		$(this).css('color', '#000');
	}
});

var pseudo = 'nom/pseudo';
var mail = 'mail';
var twitter = 'twitter';
var comment = 'votre commentaire';
var values = [pseudo, mail, twitter, comment];

$('.commentSection input').focusout(function(event){
	event.stopPropagation();
	if($(this).val().length	== 0 || $(this).val() == '@'){
		$(this).val(values[returnOldValue($(this).attr('name'))]);
		$(this).css('color', '#b7b7b7');
	}
});

$('.commentInput').focusout(function(event){
	event.stopPropagation();
	console.log(isThisEqual($(this).val().length, 0));
	if($(this).val().length == 0 || $(this).val().length == '@'){
		$(this).val(values[returnOldValue($(this).attr('name'))]);
		$(this).css('color', '#b7b7b7');
	}
});

function isThisEqual(un, deux){
	console.log(un + '//' + deux);
	if(un == deux){
		return true;
	}
	return false;
}

function returnOldValue(attribut)
{
	switch(attribut)
	{
		case 'pseudo':
		return 0
		break;
		
		case 'mail' :
		return 1
		break;
		
		case 'twitter' :
		return 2
		break;
		
		case 'comment' :
		return 3
		break;
	}
}