Updates
This commit is contained in:
parent
ca54c9a9a8
commit
1df808eb77
@ -10,7 +10,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// 1660392804
|
// 1660727162
|
||||||
var bitmaskDescArr = [];
|
var bitmaskDescArr = [];
|
||||||
|
|
||||||
function dec2bin(dec) {
|
function dec2bin(dec) {
|
||||||
@ -107,40 +107,40 @@ function parseBitmask() {
|
|||||||
tbl.style="border: 1px solid black; width: 100%";
|
tbl.style="border: 1px solid black; width: 100%";
|
||||||
var tbdy = document.createElement('tbody');
|
var tbdy = document.createElement('tbody');
|
||||||
|
|
||||||
dec = document.getElementById("decimal").value;
|
binarybitmask=dec2bin(document.getElementById("decimal").value);
|
||||||
binary=dec2bin(document.getElementById("decimal").value);
|
if(!binarybitmask){binarybitmask = parseInt(0);}
|
||||||
if(!binary){binary = parseInt(0);}
|
console.log("binarybitmask: "+binarybitmask);
|
||||||
if(!dec ){dec = parseInt(0);}
|
|
||||||
var param = document.getElementById("paramSelect").value;
|
var param = document.getElementById("paramSelect").value;
|
||||||
|
|
||||||
for (var bit = 0; bit < bitmaskDescArr[param].length; bit++) {
|
for (var option= 0; option < bitmaskDescArr[param].length; option++) {
|
||||||
var val = binary[bit];
|
|
||||||
|
var bit = parseInt(bitmaskDescArr[param][option].split(":",1)); //extract the first number before : of description
|
||||||
|
var enabled = binarybitmask[bit]; // check if it is enabled
|
||||||
|
if(!enabled){enabled=0};
|
||||||
|
var singleBitDecvalue = Math.pow(2,bit); // convert the bit to a decimal
|
||||||
|
|
||||||
var tr = document.createElement('tr');
|
var tr = document.createElement('tr');
|
||||||
|
|
||||||
var td = document.createElement('td');
|
var td = document.createElement('td');
|
||||||
td.style="border: 1px solid black;";
|
td.style="border: 1px solid black;";
|
||||||
var singleBitDecvalue = Math.pow(2,bit); // convert the bit to a decimal
|
|
||||||
var checkbox = document.createElement('input');
|
var checkbox = document.createElement('input');
|
||||||
checkbox.type = "checkbox";
|
checkbox.type = "checkbox";
|
||||||
checkbox.name = "name";
|
|
||||||
checkbox.value = "checked";
|
|
||||||
checkbox.id = singleBitDecvalue;
|
checkbox.id = singleBitDecvalue;
|
||||||
checkbox.setAttribute("onclick","bitbox("+singleBitDecvalue+")");
|
checkbox.setAttribute("onclick","bitbox("+singleBitDecvalue+")");
|
||||||
|
|
||||||
if (val == "1"){
|
if (enabled == "1"){
|
||||||
checkbox.checked = true;
|
checkbox.checked = true;
|
||||||
}else{
|
}else{
|
||||||
checkbox.checked = false;
|
checkbox.checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.appendChild(checkbox);
|
td.appendChild(checkbox);
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
|
|
||||||
|
|
||||||
var td = document.createElement('td');
|
var td = document.createElement('td');
|
||||||
td.appendChild(document.createTextNode(bitmaskDescArr[param][bit]));
|
td.appendChild(document.createTextNode(bitmaskDescArr[param][option]));
|
||||||
|
if (enabled == "1"){
|
||||||
if (val == "1"){
|
|
||||||
td.style = "border: 1px solid black; color: green";
|
td.style = "border: 1px solid black; color: green";
|
||||||
}else{
|
}else{
|
||||||
td.style = "border: 1px solid black; color: red";
|
td.style = "border: 1px solid black; color: red";
|
||||||
@ -149,7 +149,7 @@ function parseBitmask() {
|
|||||||
|
|
||||||
var td = document.createElement('td');
|
var td = document.createElement('td');
|
||||||
td.style="border: 1px solid black; color: grey";
|
td.style="border: 1px solid black; color: grey";
|
||||||
td.appendChild(document.createTextNode(Math.pow(2,bit)));
|
td.appendChild(document.createTextNode(singleBitDecvalue));
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
|
|
||||||
tbdy.appendChild(tr);
|
tbdy.appendChild(tr);
|
||||||
@ -182,10 +182,9 @@ function parseBitmask() {
|
|||||||
|
|
||||||
_(Many thanks to mfoos for writing this note.)_
|
_(Many thanks to mfoos for writing this note.)_
|
||||||
|
|
||||||
|
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
<p style="font-size:80%; font-style: italic">
|
<p style="font-size:80%; font-style: italic">
|
||||||
Last updated on August 13, 2022. For any questions/feedback,
|
Last updated on October 07, 2022. For any questions/feedback,
|
||||||
email me at <a href="mailto:hi@stavros.io">hi@stavros.io</a>.
|
email me at <a href="mailto:hi@stavros.io">hi@stavros.io</a>.
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user