1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
| // ce code va vérifier la disponibilité du Nom de fichier SOURCE (attention le statut est associé au fichier)
//on pourra avoir deux meme noms de fichiers source mais le statut sera différent
//adaptation au form edition : si le statut est modifier lupload est obligatoire sinon il est facultatif
var bUpload = false;
function req_NomFichierSource(NomFichierSource) {
//XMLHttpRequest est supporté par Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0 / Firefox, Netscape 7
if (document.all)
var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); // Internet
// Explorer
else
var XhrObj = new XMLHttpRequest(); // Mozilla
// content = document.getElementById("NomFichierSource_check"); //zone
// d'affichage
var content = document.getElementById("NomFichierSource_check"); // zone
// d'affichage
var srcFile = document.getElementById("NomFichierSource");
var statut = document.getElementById("StatutCorpus");
// fichierSON
var fichierSON = document.getElementById("fichierSON");
var fichierTRS = document.getElementById("fichierTRS");
XhrObj.open("POST", "../verif_modif_js/verif_StatutCorpus.php");
// XhrObj.open("POST", "verif_NomFichierSource.php", false);
// Ok pour la page cible
XhrObj.onreadystatechange = function() {
if (XhrObj.readyState == 4 && XhrObj.status == 200) {
if (XhrObj.responseText == 'OK') {
content.innerHTML = '<img src="../css/images/accepter.png" alt=""/><br><label>Upload obligatoire</label>';
// ok nouveau pseudo
// =================================verification champs
// parcourir non vide=====================================//
$.fn.copyTo = function(to) {
var to = $(to);
for ( var i = 1; i < arguments.length; i++)
to.set(arguments[i], this.get(0)[arguments[i]]);
return this;
};
new function() {
// $.fn.validate = validate() {};
$.fn.validate = {
init : function(o) {
if (o.name == 'fichierSON') {
this.fichierSON(o)
}
;
if (o.name == 'fichierTRS') {
this.fichierTRS(o)
}
;
},
///fichierSON
fichierSON : function(o) {
var fichierSON = "^.{2,}(.wav|.mp3|.wma)$";
if (o.value.match(fichierSON)) {
bUpload =true;
doSuccess(o);
} else {
bUpload = false;
doError(o,
'<label>Joindre un fichier son correct !</label>');
}
;
},
fichierTRS : function(o) {
var fichierTRS = "^.{2,}(.trs|.doc|.txt)$";
if (o.value.match(fichierTRS)) {
bUpload =true;
doSuccess(o);
} else {
bUpload = false;
doError(o,
'<label>Joindre un fichier transcription correct !</label>');
}
;
}
};
function doSuccess(o) {
$('#' + o.id + '_img')
.html(
'<img src="../css/images/accept.gif" border="0" style="float:left;" />');
$('#' + o.id + '_li').removeClass("error");
$('#' + o.id + '_msg').html("");
$('#' + o.id + '_li').addClass("success");
}
function doError(o, m) {
$('#' + o.id + '_img')
.html(
'<img src="../css/images/exclamation.gif" border="0" style="float:left;" />');
$('#' + o.id + '_li').addClass("error");
$('#' + o.id + '_msg').html(m);
$('#' + o.id + '_li').removeClass("success");
}
//private helper, validates each type after check
function doValidate(o) {
$('#' + o.id + '_img')
.html(
'<img src="../css/images/loading.gif" border="0" style="float:left;" />');
$.post('ajax.php', {
id : o.id,
value : o.value
}, function(json) {
eval("var args = " + json);
if (args.success == true) {
doSuccess(args);
} else {
doError(args, args.msg);
}
});
}
;
};
$(document).ready( function() {
$("//[@class=validated]/input").blur( function() {
$(this).validate.init(this);
});
// This Used To Be HOVER, But I.E. Didnt Like It
// $(".form
// li").hover(function(){$(this).addClass("selected");},function(){$(this).removeClass("selected");});
$(".form li").mouseover( function() {
$(this).addClass("selected");
});
$(".form li").mouseout( function() {
$(this).removeClass("selected");
});
});
// ==============================fin de la vérification des
// champs====================================//
} else {
content.innerHTML = '<img src="../css/images/refuser.png" alt=""/><br><label>Upload facultatif</label>';
bUpload = true; // erreur pseudo déjà existant
}
}
}
XhrObj
.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
// XhrObj.send('p='+encodeURIComponent(NomFichierSource));
XhrObj.send('p=' + encodeURIComponent(srcFile.value) + '&s='
+ encodeURIComponent(statut.value));
}
///A METTRE DANS LE ON SUBMIT AVEC LES CONDITIONS VALABLES
function testUpload(f) {
if (!bUpload) {
alert('Joindre le fichier son et/ou transcription!!');
return false;
}
return true;
} |
Partager