123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <!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>
- <!-- Demonstrator for CertainTrust.cFusion -->
- <tr>
- <td id="cf-operand1"></td>
- <td>cFusion</td>
- <td id="cf-operand2"></td>
- <td>=</td>
- <td id="cf-result"></td>
- </tr>
- <!-- Demonstrator for CertainTrust.wFusion -->
- <tr>
- <td id="wf-operand1"></td>
- <td>wFusion</td>
- <td id="wf-operand2"></td>
- <td>=</td>
- <td id="wf-result"></td>
- </tr>
- </table>
- <script type="text/javascript">
- // create an Array to hold the CertainTrust objects
- var CT_objects = [];
- var N = 10;
- var cweight = [1,1];
- var wweight = [1,1];
- var doc = 0.2;
- var CT_names = ['and-operand1', 'and-operand2', 'and-result',
- 'or-operand1', 'or-operand2', 'or-result',
- 'cf-operand1','cf-operand2','cf-result',
- 'wf-operand1','wf-operand2','wf-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 CertainTrustSimple(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-'));
- var isAND = (0 === element.indexOf('and-'));
- var isCF = (0 === element.indexOf('cf-'));
- var isWF = (0 === element.indexOf('wf-'));
-
- if(isOR){
- CT_object.addObserver(ORObserver);
- }
- else {
- CT_object.addObserver(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>
|