Text Converter: Add padding to binary output (#4398)
* Add padding to binary. * add right margin to dropdown labels * Refactor.master
parent
cd0871b9f4
commit
11d144a6dd
|
@ -19,6 +19,11 @@
|
|||
/*
|
||||
* The text converter controls
|
||||
*/
|
||||
|
||||
.zci--text_converter .js_convert--select--wrap label {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.zci--text_converter #controls {
|
||||
margin: 1em 0 0.3em 0;
|
||||
}
|
||||
|
@ -55,7 +60,7 @@
|
|||
.is-mobile .zci--text_converter .js_convert--select--wrap label {
|
||||
width: 25%;
|
||||
display: inline-block;
|
||||
margin-left: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.is-mobile .zci--text_converter .js_convert--select--wrap .frm__select {
|
||||
|
|
|
@ -78,17 +78,20 @@ DDH.text_converter = DDH.text_converter || {};
|
|||
* Binary Converter
|
||||
********************************************
|
||||
*
|
||||
* zeroPad: text --> padded text
|
||||
* toBinary: text --> binary
|
||||
* binaryToText: binary --> text
|
||||
*
|
||||
*/
|
||||
toBinary: function( text ) {
|
||||
var binary = "";
|
||||
zeroPad: function( number ) {
|
||||
return "00000000".slice(String(number).length) + number
|
||||
},
|
||||
|
||||
for (var i=0; i < text.length; i++) {
|
||||
binary += text[i].charCodeAt(0).toString(2) + " ";
|
||||
}
|
||||
return binary
|
||||
toBinary: function( text ) {
|
||||
return text.replace(/[\s\S]/g, function( str ) {
|
||||
var octet = TextConverter.zeroPad(str.charCodeAt().toString(2));
|
||||
return octet + " ";
|
||||
});
|
||||
},
|
||||
|
||||
binaryToText: function( text ) {
|
||||
|
|
Loading…
Reference in New Issue