Skip to content

Commit

Permalink
Attempted at Issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
crashdemons committed Apr 11, 2017
1 parent b384b28 commit e996de4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script src="js/xlate.format.js"></script>
<script src="js/xlate.js"></script>
<script>
if(typeof addcredits == 'function') addcredits("jxlate.html",2.3,"crashdemons","JavaScript Binary Translator UI.")
if(typeof addcredits == 'function') addcredits("jxlate.html",2.4,"crashdemons","JavaScript Binary Translator UI.")
</script>
</head>
<body class="monospace bw" onload="xlate_init()">
Expand Down
9 changes: 6 additions & 3 deletions js/xlate.format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(typeof addcredits == 'function') addcredits("xlate.format.js",11,"crashdemons","Numeral System formatting functions")
if(typeof addcredits == 'function') addcredits("xlate.format.js",12,"crashdemons","Numeral System formatting functions")

//preformatter function that changes and splits the text to an array of single units for array_base2base to translate.
//non-numeral strings and encodings tend to have just a single item.
Expand All @@ -8,9 +8,11 @@ function input2buffer(s,base){
}else if(base=="ue" || base=="ucs2" || base=="utf8"){
return [s];//urlencode is handled all was 1 item passed to a function
}else if(base==2){
return s.replace(/ /g,'').match(/.{1,8}/g);//strip spaces and split into 8-bit entries for binary.
return s.replace(/\s/g,'').match(/.{1,8}/g);//strip spaces and split into 8-bit entries for binary.
//return s.replace(/ /g,'').match(/.{1,8}/g);//strip spaces and split into 8-bit entries for binary.
}else if(base==16){
return s.toUpperCase().replace(/ /g,'').match(/.{1,2}/g);//strip spaces and split into 2-digit entries for hex
return s.toUpperCase().replace(/\s/g,'').match(/.{1,2}/g);//strip spaces and split into 2-digit entries for hex
//return s.toUpperCase().replace(/ /g,'').match(/.{1,2}/g);//strip spaces and split into 2-digit entries for hex
}else if(base=="32r" ||base=="32h" ||base=="32c"){
return [s.replace(/\s/g, '').toUpperCase()];//strip spaces spaces and uppercase as a single item for Base32 decoding.
}else if(base==64){
Expand All @@ -21,6 +23,7 @@ function input2buffer(s,base){
if(s.substr(-2,2)!="~>") s+="~>";
return [s];//single item to pass to decoder.
}
s=s.replace(/\s+/g, ' ');
return s.toUpperCase().split(" ");//all other items are split by spaces.
}

Expand Down

0 comments on commit e996de4

Please sign in to comment.