<!DOCTYPE html> <html> <!-- CertainTrust Demonstrator in JavaScript Demonstrates some capabilities of the CertainTrust SDK using a Java applet that interactively calculates AND and OR of two CertainTrust data objects and visually displays both the input objects and the output. @author Florian Volk <florian.volk@cased.de> --> <head> <meta charset="utf-8" /> <title>CertainTrust Demonstrator in JavaScript</title> <style type="text/css"> h1, p, td:nth-child(2n) { text-align: center; } table { margin: 50px 0; } </style> <!-- include these two scripts and the CSS to enable both CertainTrust and the HTI --> <script type="text/javascript" src="CertainTrust.js"></script> <script type="text/javascript" src="certainTrustHTI.js"></script> <link rel="stylesheet" type="text/css" href="certainTrustHTI.css"/> </head> <body> <h1>Demonstrator for CertainTrust</h1> <p>CertainTrust provides a means for the evaluation of propositional logic terms under uncertainty.</p> <table> <!-- Demonstrator for CertainTrust.AND --> <tr> <td id="and-operand1"></td> <td>AND</td> <td id="and-operand2"></td> <td>=</td> <td id="and-result"></td> </tr> <!-- Demonstrator for CertainTrust.OR --> <tr> <td id="or-operand1"></td> <td>OR</td> <td id="or-operand2"></td> <td>=</td> <td id="or-result"></td> </tr> </table> <script type="text/javascript"> // create an Array to hold the CertainTrust objects var CT_objects = []; var N = 10; var CT_names = ['and-operand1', 'and-operand2', 'and-result', 'or-operand1', 'or-operand2', 'or-result']; // ANDObserver is used for the AND calculation var ANDObserver = { update: function() { // calculate the CertainTrust.AND for both values var CT_result = CT_objects['and-operand1'].AND(CT_objects['and-operand2']); // update the HTI which displays the result CT_objects['and-result'].setF(CT_result.getF()); CT_objects['and-result'].setTC(CT_result.getT(), CT_result.getC()); } }; // ORObserver is used for the OR calculation var ORObserver = { update: function() { // calculate the CertainTrust.OR for both values var CT_result = CT_objects['or-operand1'].OR(CT_objects['or-operand2']); // update the HTI which displays the result CT_objects['or-result'].setF(CT_result.getF()); CT_objects['or-result'].setTC(CT_result.getT(), CT_result.getC()); } }; // create the CertainTrust objects and the associated HTIs for (var i = 0, element; element = CT_names[i]; ++i) { var CT_object = new CertainTrust(N); // the result HTIs should be read-only var isResultHTI = (-1 !== element.indexOf('-result')); var HTI = new CertainTrustHTI(CT_object, {domParent: element, readonly: isResultHTI}); // register our observers for the calculation if (!isResultHTI) { var isOR = (0 === element.indexOf('or-')); CT_object.addObserver((isOR) ? ORObserver : ANDObserver); } // store the created objects for easy access in the Arrays CT_objects[element] = CT_object; } // trigger initial update to the result HTIs ANDObserver.update(); ORObserver.update(); </script> <p> <img src="logo_tudarmstadt.png" alt="Technische Universit�t Darmstadt" width="176" height="73" /> <img src="logo_softwarecluster.png" alt="Software-Cluster" width="212" height="73" /> </p> </body> </html>