Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
2.2 kB
0
Indexable
Never
async function fillInfo(c, regJSON){
	var div, table, row, val_msb, val_lsb, info, collapsed;

	div=c.parentNode;
	val_msb = regJSON["val_msb"];
	val_lsb = regJSON["val_lsb"];
	collapsed = regJSON["collapse"];

	info = document.createElement("div");
	info.state = !collapsed;
	info.style.maxHeight = collapsed ? "0vh" : "none";
	info.setAttribute("class", "cl_pageCollapsibleInfo");

	table = document.createElement("table");
	row = document.createElement("tr");
	createTableCell(row, "Base");
	createTableCell(row, regJSON["base"], 3);
	table.appendChild(row);

	row = document.createElement("tr");
	createTableCell(row, "Offset");
	createTableCell(row, regJSON["offset"], 3);
	table.appendChild(row);

	row = document.createElement("tr");
	createTableCell(row, "Value");
	createTableCell(row, uint64ToHexString(val_lsb, val_msb), 3);
	table.appendChild(row);

	row = document.createElement("tr");
	createTableCell(row, "Field Name", 0, 0, true);
	createTableCell(row, "Bits", 0, 0, true);
	createTableCell(row, "Hex Value", 0, 0, true);
	createTableCell(row, "Decimal Value", 0, 0, true);
	table.appendChild(row);

	for (var i = 0; i < regJSON["fields"].length; i++) {
		var msb, lsb;

		row = document.createElement("tr");
		createTableCell(row, regJSON["fields"][i]["name"]);
		lsb = regJSON["fields"][i]["lsb"];
		msb = regJSON["fields"][i]["msb"];
		createTableCell(row, "<" + msb + ":" + lsb + ">");

		createTableCell(row, uint64FieldExtractToString(val_lsb, val_msb, lsb, msb, true));
		createTableCell(row, uint64FieldExtractToString(val_lsb, val_msb, lsb, msb));
		table.appendChild(row);
	}
	info.appendChild(table);
	div.appendChild(info);
}

async function toggleInfoCollapse(c, regJSON, clsName) {
	await fillInfo(c,regJSON);
	var divs, content;
	divs = c.parentNode.getElementsByClassName("cl_pageCollapsibleInfo");
	console.log(c.parentNode);
	content = c.innerHTML;
	if (!divs[0].state) {
		content = content.replace("+ ", "- ");
		divs[0].style.maxHeight = "none";
	} else {
		content = content.replace("- ", "+ ");
		divs[0].style.maxHeight = "0vh";
	}
	divs[0].state = !divs[0].state;
	c.innerHTML = content;
}
Leave a Comment