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