Ajout de convertIn pour convertBinaryText
This commit is contained in:
parent
57df1c0172
commit
4b92a728ae
@ -59,6 +59,9 @@ header {
|
||||
width: 25% !important;
|
||||
display: inline;
|
||||
}
|
||||
#convertIn {
|
||||
width: 6.7em;
|
||||
}
|
||||
.table {
|
||||
color: white;
|
||||
}
|
||||
|
@ -184,18 +184,19 @@ $(function () {
|
||||
$("#submitConvertBinaryText").click(function()
|
||||
{
|
||||
let binaryTextValue = $('#binaryTextValue').val();
|
||||
let convertIn = $("#convertIn option:selected").text();
|
||||
let isBinaryValue = isStringBin(binaryTextValue);
|
||||
|
||||
if(isEmptyValue(binaryTextValue)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else if (isBinaryValue === true) {
|
||||
else if (isBinaryValue === true && convertIn === 'Texte') {
|
||||
// Le replace enlève les espaces
|
||||
let textResult = binToUtf8(binaryTextValue.replace(/\s/g,''));
|
||||
|
||||
$('.results').html(textResult);
|
||||
}
|
||||
else if (isBinaryValue === false) {
|
||||
else if (isBinaryValue === false && convertIn === 'Binaire') {
|
||||
// Les 2 replace permettent de rajouter un espace tout les 8 bits
|
||||
let binaryResult = utf8ToBin(binaryTextValue);
|
||||
binaryResult = binaryResult.replace(/(\d{8})/g, '$1 ').replace(/(^\s+|\s+$)/,'');
|
||||
|
@ -12,8 +12,14 @@
|
||||
<label for="binaryTextValue">Entrez votre chaîne de caractères ou du binaire :</label>
|
||||
<textarea name="binaryTextValue" type="text" id="binaryTextValue" placeholder="(e.g : 'Salut' ou '01010011 01100001')" class="form-control"></textarea>
|
||||
<br>
|
||||
<label for="convertIn">Convertir en : </label> <br>
|
||||
<select id="convertIn">
|
||||
<option value="Binaire">Binaire</option>
|
||||
<option value="Texte">Texte</option>
|
||||
</select>
|
||||
<div class="form-row text-center">
|
||||
<div class="col-12">
|
||||
<br>
|
||||
<button type="submit" id="submitConvertBinaryText" class="btn btn-dark text-center">Envoyer</button>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user