Skip to content

Commit acc911b

Browse files
author
karu
committed
prerefactor
1 parent ab2a5f5 commit acc911b

File tree

3 files changed

+48
-58
lines changed

3 files changed

+48
-58
lines changed

css/app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ body {
22
font-family: 'Open Sans', sans-serif;
33
}
44

5+
#formula-container {
6+
cursor: pointer;
7+
}
8+
59
#page-container {
610
width: 962px;
711
position: relative;

index.html

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,10 @@ <h1>
2727
<button class="btn btn-primary" onclick="setAppMode(MODE.EVAL)"> <i class="icon-eye-open icon-white"> </i>
2828
Evaluate Formula
2929
</button>
30-
<button class="btn btn-primary" onclick="setAppMode(MODE.TEXT)"> <i class="icon-eye-open icon-white"> </i>
31-
Text mode
32-
</button>
3330
</div>
3431
<div id="app-body">
3532
<div class="panel tab-content">
3633
<div id="edit-pane" class="tab-pane active">
37-
<div id="upload-pane">
38-
<input type="file" id="fileInput" style="display: none;">
39-
<button id="readFileButton"> Upload Model </button>
40-
<pre id="fileContent">
41-
</pre>
42-
</div>
4334
<div class="agent-btns">
4435
Current agent:
4536
<br>
@@ -128,28 +119,6 @@ <h1>
128119
</div>
129120
</div>
130121
<div id="eval-pane" class="tab-pane">
131-
<div class="eval-buttons">
132-
<button class="atom-button" onclick=addText('p',this)>p</button>
133-
<button class="atom-button" onclick=addText('q',this)>q</button>
134-
<button class="atom-button" onclick=addText('r',this)>r</button>
135-
<button class="agent-button" onclick=addText('a',this)>a</button>
136-
<button class="agent-button" onclick=addText('b',this)>b</button>
137-
<button class="agent-button" onclick=addText('c',this)>c</button>
138-
<button class="agent-button" onclick=addText('d',this)>d</button>
139-
<button class="agent-button" onclick=addText('e',this)>e</button>
140-
<button class="monadic-button" onclick=addText('~',this)>¬</button>
141-
<button class="diadic-button" onclick=addText("-&#62;",this)></button>
142-
<button class="diadic-button" onclick=addText('&',this)></button>
143-
<button class="diadic-button" onclick=addText('V',this)></button>
144-
<button class="modal-button" onclick=addText('K',this)>K</button>
145-
<button class="group-button" onclick=addText("C{",this)>C</button>
146-
<button class="group-button" onclick=addText('D{',this)>D</button>
147-
<button onclick=addText('{')>{</button>
148-
<button onclick=addText('}')>}</button>
149-
<button onclick=addText('(')>(</button>
150-
<button onclick=addText(')')>)</button>
151-
<button onclick=addText('delete')>X</button>
152-
</div>
153122
<div class="eval-input">
154123
Enter a formula:
155124
<input type="text" id="formulaInput" placeholder="e.g., (p ->
@@ -238,9 +207,9 @@ <h1>
238207
</div>
239208
<div class="graph">
240209
</div>
241-
<div class="current-formula inactive">
210+
<div class="current-formula inactive" id="formula-container">
242211
</div>
243-
<div class="current-subformula inactive dropdown">
212+
<div class="current-subformula inactive dropdown" id="subformula-container">
244213
<button class="dropbtn"> Dropdown </button>
245214
</div>
246215
</div>

js/app.js

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
* Copyright (c) 2013 Ross Kirsling
77
* Released under the MIT License.
88
*/
9-
10-
// const { index } = require("d3");
11-
12-
// app mode constants
139
var MODE = {
1410
EDIT: 0,
1511
EVAL: 1,
@@ -187,8 +183,8 @@ var varCountButtons = d3.selectAll('#edit-pane .var-count button'),
187183
selectedNodeLabel = d3.select('#edit-pane .selected-node-id'),
188184
evalInput = d3.select('#eval-pane .eval-input'),
189185
evalOutput = d3.select('#eval-pane .eval-output'),
190-
currentFormula = d3.select('#app-body .current-formula');
191-
currentSubFormula = d3.select('#app-body .current-subformula');
186+
currentFormula = d3.select('#app-body .current-formula'),
187+
currentSubformula = d3.select('#app-body .current-subformula'),
192188
btnSubformulae = d3.select('#btn-formulae');
193189

194190
function announceFormula() {
@@ -347,30 +343,38 @@ function evaluateFormula() {
347343
.classed('false', !truthVal);
348344
});
349345

346+
currentFormula
347+
.append("div")
348+
// .attr("class", "dropdown-content")
349+
350350
// display evaluated formula
351351
currentFormula
352352
.html('<strong>Current formula:</strong><br>$' + wff.latex() + '$')
353-
.classed('inactive', false);
353+
.classed('inactive', false)
354+
.on('click', function(event) {
355+
console.log('hola')
356+
});
354357

355-
currentSubFormula.selectAll("*").remove();
358+
currentSubformula.selectAll("*").remove();
356359

357-
//display subformulas
358-
currentSubFormula
360+
currentSubformula
359361
.classed('inactive', false);
360362

361-
currentSubFormula
363+
currentSubformula
362364
.append("button")
363365
.attr("class", "btn btn-primary")
364366
.attr("id", "btn-subformulae")
365367
.html("Subformulas")
366368

367-
currentSubFormula
369+
// currentSubformula
370+
371+
currentSubformula
368372
.append("div")
369373
.attr("class", "dropdown-content")
370374

371-
let dropdownmenu = d3.select('.dropdown-content');
375+
let dropdownmenu = d3.select('.dropdown-content');
372376
subFormulas.forEach((subf, index) =>{
373-
dropdownmenu.append("a")
377+
dropdownmenu.append("a")
374378
.attr("id", `subFormulaRadio_${index}`)
375379
.html("$"+subf.latex()+"$")
376380
.on("click", ()=> {
@@ -379,17 +383,18 @@ function evaluateFormula() {
379383

380384
})
381385

382-
// display truth evaluation
386+
// display true evaluation
383387
var latexTrue = trueStates.length ? '$w_{' + trueStates.join('},$ $w_{') + '}$' : '$\\varnothing$',
384-
latexFalse = falseStates.length ? '$w_{' + falseStates.join('},$ $w_{') + '}$' : '$\\varnothing$';
388+
latexFalse = falseStates.length ? '$w_{' + falseStates.join('},$ $w_{') + '}$' : '$\\varnothing$';
389+
385390
evalOutput
386391
.html('<div class="alert alert-success"><strong>True:</strong><div><div>' + latexTrue + '</div></div></div>' +
387392
'<div class="alert alert-danger"><strong>False:</strong><div><div>' + latexFalse + '</div></div></div>')
388393
.classed('inactive', false);
389394

390395
// re-render LaTeX
391396
MathJax.Hub.Queue(['Typeset', MathJax.Hub, currentFormula.node()]);
392-
MathJax.Hub.Queue(['Typeset', MathJax.Hub, currentSubFormula.node()]);
397+
MathJax.Hub.Queue(['Typeset', MathJax.Hub, currentSubformula.node()]);
393398
MathJax.Hub.Queue(['Typeset', MathJax.Hub, evalOutput.node()]);
394399
}
395400

@@ -620,7 +625,18 @@ function getSingleCurvedSVGPath([x1, y1], [x2, y2], curviness) {
620625
',' + x2 + ' ' + y2;
621626
}
622627

623-
function printGraph(relations){
628+
function printGraphAtoms(){
629+
circle.selectAll('text.atoms')
630+
.text(function(d) {
631+
return propvars
632+
.filter(function(_, i) { return d.vals[i]; })
633+
.join(', ');
634+
})
635+
.attr('y', 5);
636+
}
637+
638+
639+
function printGraphRelations(relations){
624640
//remove groups links
625641
links = links.filter(d => d.agent !== ('g') && d.agent !== ('h'));
626642
relations.forEach(rel => {
@@ -657,7 +673,7 @@ function printGraph(relations){
657673

658674
function resetGraph(){
659675
let rel = model.getAllRelationsOfList(epistemicAgents)
660-
printGraph(rel);
676+
printGraphRelations(rel);
661677
}
662678

663679
function subformulaeGraph(wff){
@@ -683,7 +699,7 @@ function subformulaeGraph(wff){
683699
// For showing other arrows.
684700
//links = links.filter(d => !agents.includes(d.agent));
685701
links = []
686-
printGraph(commonRelations)
702+
printGraphRelations(commonRelations)
687703
}else if (json.dist_start && json.dist_start.group_end && json.dist_start.group_end[0].prop) {
688704
links = []
689705
const agents = json.dist_start.group_end[0].prop.split('');
@@ -692,11 +708,11 @@ function subformulaeGraph(wff){
692708
return { ...rel, agent: 'h' };
693709
});
694710
distRelations=removeDuplicates(distRelations);
695-
printGraph(distRelations)
711+
printGraphRelations(distRelations)
696712

697713
} else {
698714
const relations = model.getAllRelationsOfList(epistemicAgents);
699-
printGraph(relations)
715+
printGraphRelations(relations)
700716
}
701717
MathJax.Hub.Queue(['Typeset', MathJax.Hub, dropbtn]);
702718
}
@@ -1183,9 +1199,10 @@ function setAppMode(newMode) {
11831199
.classed('true', false)
11841200
.classed('false', false);
11851201

1186-
currentFormula.classed('inactive', true);
1187-
currentSubFormula.classed('inactive', true);
1188-
currentSubFormula.selectAll("*").remove();
1202+
currentFormula.classed('inactive', true);
1203+
currentSubformula.classed('inactive', true);
1204+
currentSubformula.selectAll("*").remove();
1205+
11891206
} else if(newMode === MODE.EVAL|| newMode === MODE.TEXT ) {
11901207
// disable listeners (except for I-bar prevention)
11911208
svg.classed('edit', false)

0 commit comments

Comments
 (0)