Skip to content

Instantly share code, notes, and snippets.

@buzamahmooza
Created October 12, 2018 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buzamahmooza/a82d46d18e525b153c84f5713fa7bad7 to your computer and use it in GitHub Desktop.
Save buzamahmooza/a82d46d18e525b153c84f5713fa7bad7 to your computer and use it in GitHub Desktop.
A bookmarklet or browser script to allow for easy input on the 32x8.com kmap website. rather then ticking radio buttons one by one, this script takes on string and ticks all the radio buttons for you.
JavaScript:(function(){
if(!/www\.32x8\.com/.test(location.href)){ alert("This script only works on 32x8.com"); return; }
stringInput(prompt("Enter the minterms/maxterms in order from top to bottom (0,1,x):", "1 x 1 0 1 0 x 0"));
function stringInput(inputStr) {
const rows = Array.from(document.querySelectorAll('body > form > table > tbody tr')).slice(2, -1);
const terms = inputStr.match(/(1|0|x)/gmi);
console.log('terms:', terms);
for(let i=0; i<terms.length; i++){
if(i>=terms.length || i>=rows.length) break;
var idx=0;
switch(terms[i].toLowerCase()) {
case "0": idx=0; break;
case "1": idx=1; break;
case "x": idx=2; break;
}
const radioBtn = rows[i].querySelectorAll('input')[idx];
radioBtn.click();
}
}
alert("The inputs have been entered.\nAuthor: Faris Hijazi www.github.com/buzamahmooza");
})();
@buzamahmooza
Copy link
Author

What is it?

This script takes one long string of minterms/maxterms ordered from the smallest to the largest. Example: x001 will have minterm 3 only.

Installation

Install as a bookmarklet

Simply select the code and drag it to your browser's bookmarks tab, and then click the bookmark to run it.
Then just click the bookmark to use it at any time.

Run the code in the console

Another way is to just copy the code and then paste it in your browser's console (use F12)

Usage

You will be prompted and asked to enter the minterms/maxterms as 1, 0, or X, the code will parse your input
The script will exclude any invalid characters so you won't have to worry about any errors, it will simply skip them.
You may separate the characters or leave them stuck together, the script will work either way, as well as the case of the "x" won't matter.

Please report any problems you face.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment