Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
position: fixed;
left: 50%;
bottom: 0;
margin-left: -175px;
width: 350px;
margin-left: -250px;
width: 500px;
height: 50px;
background: #111;
color: #555;
Expand Down Expand Up @@ -156,4 +156,4 @@

#toolbar #list li:hover, #toolbar #list li:active {
background: #ddd;
}
}
3 changes: 3 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ <h1>Tutorial</h1>
<div class="slot" tooltip="Input and output ports">I/O</div>
<div class="slot" tooltip="NOT gate" onmousedown="event.which == 3 ? dialog.truthTable(NOT) : select(NOT)">!</div>
<div class="slot" tooltip="AND gate" onmousedown="event.which == 3 ? dialog.truthTable(AND) : select(AND)">&</div>
<div class="slot" tooltip="NAND gate" onmousedown="event.which == 3 ? dialog.truthTable(NAND) : select(NAND)">!&</div>
<div class="slot" tooltip="OR gate" onmousedown="event.which == 3 ? dialog.truthTable(OR) : select(OR)">|</div>
<div class="slot" tooltip="NOR gate" onmousedown="event.which == 3 ? dialog.truthTable(NOR) : select(NOR)">!|</div>
<div class="slot" tooltip="XOR gate" onmousedown="event.which == 3 ? dialog.truthTable(XOR) : select(XOR)">^</div>
<div class="slot" tooltip="XNOR gate" onmousedown="event.which == 3 ? dialog.truthTable(XNOR) : select(XNOR)">!^</div>
<div class="slot" tooltip="Custom component" onmousedown="select(Custom)"><i class="material-icons">memory</i></div>
<div class="slot" tooltip="Saved components" onmousedown="dialog.savedCustomComponents()"><i class="material-icons">list</i></div>

Expand Down
47 changes: 46 additions & 1 deletion app/js/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ function findComponentsInSelection(
for(let i = 0; i < components.length; ++i) {
const component = components[i];
if(x < component.pos.x + (component.width || 0) - .5 &&
x2 > component.pos.x - .5 &&
x2 > component.pos.x - .5 &&
y2 > component.pos.y - (component.height || 0) + .5 &&
y < component.pos.y +.5) {
result.push(component);
Expand Down Expand Up @@ -1985,6 +1985,21 @@ class AND extends Component {
}
}

class NAND extends Component {
constructor(name, pos) {
super (name, pos, 2, 2, {type: "char", text: "!&"});
this.addInputPort({side: 3, pos: 1});
this.addInputPort({side: 3, pos: 0});
this.addOutputPort({side: 1, pos: 0});
this.function = () => {
if (this.input[0].value & this.input[1].value == 1)
this.output[0].value = 0;
else
this.output[0].value = 1;
}
}
}

class OR extends Component {
constructor(name,pos) {
super(name,pos,2,2,{ type: "char", text: "|" });
Expand All @@ -1997,6 +2012,21 @@ class OR extends Component {
}
}

class NOR extends Component {
constructor(name,pos) {
super(name,pos,2,2,{ type: "char", text: "!|" });
this.addInputPort({ side: 3, pos: 1 });
this.addInputPort({ side: 3, pos: 0 });
this.addOutputPort({ side: 1, pos: 0 });
this.function = function() {
if (this.input[0].value | this.input[1].value)
this.output[0].value = 0;
else
this.output[0].value = 1;
}
}
}

class XOR extends Component {
constructor(name,pos) {
super(name,pos,2,2,{ type: "char", text: "^" });
Expand All @@ -2009,6 +2039,21 @@ class XOR extends Component {
}
}

class XNOR extends Component {
constructor(name,pos) {
super(name,pos,2,2,{ type: "char", text: "!^" });
this.addInputPort({ side: 3, pos: 1 });
this.addInputPort({ side: 3, pos: 0 });
this.addOutputPort({ side: 1, pos: 0 });
this.function = function() {
if (this.input[0].value ^ this.input[1].value)
this.output[0].value = 0;
else
this.output[0].value = 1;
}
}
}

class Button extends Component {
constructor(name,pos) {
super(name,pos,2,1,{ type: "icon", text: "radio_button_checked" });
Expand Down
2 changes: 1 addition & 1 deletion app/js/localStorage2.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getLocalStorage() {
}

const constructors = {
Input,Output,NOT,AND,OR,XOR,
Input,Output,NOT,AND,NAND,OR,NOT,XOR,XNOR,
Button,Constant,Delay,Clock,Debug,
Beep,Counter,LED,Display,
Custom, TimerStart, TimerEnd,
Expand Down