Skip to content

Commit

Permalink
v0.1.7 docs
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Aug 14, 2013
1 parent 57da775 commit 2874675
Show file tree
Hide file tree
Showing 8 changed files with 360 additions and 34 deletions.
21 changes: 16 additions & 5 deletions History.html
Expand Up @@ -178,7 +178,18 @@



<h1>v0.1.5 / 2012-06-17</h1>
<h1>0.1.7 / 2013-06-25</h1>
<ul>
<li>Fixed constraint parser to not evaluate functions that have the same name as operators as operators.</li>
<li>Fixed the <code>getMatcher</code> to properly return an equality expression for constraints that do not have an explicit equality</li>
<li>Added new diganosis example</li>
<li>Changed Fibonacci example to support larger number</li>
</ul>
<h1>v0.1.6 / 2012-06-17</h1>
<ul>
<li>Fixed issue with the use of next in async actions</li>
</ul>
<h1>v0.1.5 / 2013-06-17</h1>
<ul>
<li>More Examples</li>
<li>Changed nools compile to transpile to Javascript!</li>
Expand All @@ -189,7 +200,7 @@ <h1>v0.1.5 / 2012-06-17</h1>
</ul>
</li>
</ul>
<h1>v0.1.4 / 2012-05-25</h1>
<h1>v0.1.4 / 2013-05-25</h1>
<ul>
<li>Added new agenda-group (#29)</li>
<li>More documentation<ul>
Expand All @@ -201,15 +212,15 @@ <h1>v0.1.4 / 2012-05-25</h1>
</li>
<li>Cleaned up agenda and made more modular</li>
</ul>
<h1>v0.1.3 / 2012-05-24</h1>
<h1>v0.1.3 / 2013-05-24</h1>
<ul>
<li>Fixed memory leak with FactHashes for the agendas</li>
</ul>
<h1>v0.1.2 / 2012-05-24</h1>
<h1>v0.1.2 / 2013-05-24</h1>
<ul>
<li>Removed unneeded calls to <code>.then</code> to address performance degredation (#30)</li>
</ul>
<h1>v0.1.1 / 2012-05-23</h1>
<h1>v0.1.1 / 2013-05-23</h1>
<ul>
<li>Updated grunt</li>
<li>Fixed nextTick issues for node v0.10 #32</li>
Expand Down
1 change: 1 addition & 0 deletions examples.html
Expand Up @@ -184,6 +184,7 @@ <h2>Examples</h2>
<li><a href="./examples/browser/conways_3d.html">Conways 3D</a></li>
<li><a href="./examples/browser/fibonacci.html">Fibonacci</a></li>
<li><a href="./examples/browser/manners.html">Miss Manners</a></li>
<li><a href="./examples/browser/diagnose.html">Diagnosis</a></li>
</ul>

<hr>
Expand Down
1 change: 1 addition & 0 deletions examples/browser/assets/bignumber.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion examples/browser/assets/conways.css
@@ -1,8 +1,10 @@
@import url(http://fonts.googleapis.com/css?family=Titillium+Web:200);

body {
font-size: 12px;
line-height: 24px;
font-weight: bold;
font-family: 'Londrina Shadow', cursive;
font-family: 'Titillium Web', sans-serif;
width: 100%;
height: 100%;
overflow: hidden;
Expand All @@ -19,6 +21,21 @@ body {
margin: 10px;
}

#fibonacci #results_container {
word-wrap: break-word;
max-width: 100%;
line-height: 50px;
}

#diagnose {
width: 500px;
padding: 10px;
border: 1px solid rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);
}

#manners {
width: 50%;
padding: 10px;
Expand Down
161 changes: 161 additions & 0 deletions examples/browser/diagnose.html
@@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" rel="stylesheet" href="assets/conways.css">
<link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<link href='http://fonts.googleapis.com/css?family=Londrina+Shadow' rel='stylesheet' type='text/css'>
<title>Diagnose Me</title>
</head>
<body>


<div id="diagnose" class="middle">
<h1>Diagnose Me <input type="button" id="edit" value="Edit Rules"/></h1>


<form action="#">
<div class="errors"></div>
<label for="name">Patient Name</label>
<input type="text" id="name"/>
<label for="fever">Fever</label>
<select id="fever">
<option value="">None</option>
<option value="high">High</option>
<option value="mild">Mild</option>
</select>

<div>
<label for="spots">Spots</label>
<input type="checkbox" id="spots"/>
</div>
<div>
<label for="rash">Rash</label>
<input type="checkbox" id="rash"/>
</div>
<div>
<label for="sore_throat">Sore Throat</label>
<input type="checkbox" id="sore_throat"/>
</div>
<div>
<label for="innoculated">Innoculated</label>
<input type="checkbox" id="innoculated"/>
</div>
<input type="submit" value="Diagnose"/>
</form>
<hr/>
<h2>Diagnoses</h2>

<div id="results_container"></div>

</div>

<div id="editor-dialog">
<div id="editor"></div>
</div>

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/0.2.0/ace.js"></script>
<script type="text/javascript" src="../../nools.js"></script>
<script type="text/javascript" src="./src/common.js"></script>
<script type="text/javascript" src="./src/guests.js"></script>
<script type="text/javascript">

$(document).ready(function () {
$.ajax({
url: "./rules/diagnosis.nools"
}).then(function (res) {

var resultsContainer = $("#results_container"),
statsListener = stats(),
flowStr = res,
flow = nools.compile(res, {name: "diagnosis"}),
Patient = flow.getDefined("patient");

function clear() {
$("#fever").val("");
$("#spots").attr("checked", false);
$("#rash").attr("checked", false);
$("#sore_throat").attr("checked", false);
$("#innoculated").attr("checked", false);
$("#name").val("");
}

function createPatient() {
return new Patient({
name: $("#name").val(),
fever: $("#fever").val(),
spots: $("#spots").is(":checked"),
rash: $("#rash").is(":checked"),
soreThroat: $("#sore_throat").is(":checked"),
innoculated: $("#innoculated").is(":checked")
})


}

function run() {
var d, t;
statsListener.listen(flow.getSession(createPatient()))
.on("diagnosis", function (diagnosis) {
d = diagnosis;
})
.on("treatment", function (treatment) {
t = treatment;
})
.match().then(function () {
if (t && d) {
resultsContainer.append($("<div/>", {
text: d.name + "'s diagnosis is " + d.diagnosis + " we recommend " + t.treatment
}))
}
});
}

clear();

$("form").on("submit", function () {
if ($("#name").val()) {
$(".errors").empty();
run();
} else {
$(".errors").append("<div>Patient Name Required</div>");
}
return false;
});

$("#edit").on("click", function () {
$("#editor-dialog").dialog("open");
return false;
});

$("#editor-dialog").dialog({
autoOpen: false,
modal: true,
width: window.innerWidth * 0.9,
height: window.innerHeight * 0.9,
open: function () {
(editor = ace.edit("editor").getSession()).setValue(flowStr);
},
buttons: {
"Save": function () {
$(this).dialog("close");
nools.deleteFlow("diagnosis");
stop();
flow = nools.compile((flowStr = editor.getValue()), {name: "diagnosis"});
},
Cancel: function () {
$(this).dialog("close");
}
}
});

});
})
;
</script>

</body>
</html>

0 comments on commit 2874675

Please sign in to comment.