demonstrator_cfusion.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. CertainTrust Demonstrator in JavaScript
  5. Demonstrates some capabilities of the CertainTrust SDK
  6. using a Java applet that interactively calculates
  7. AND and OR of two CertainTrust data objects and
  8. visually displays both the input objects and the output.
  9. @author Florian Volk <florian.volk@cased.de>
  10. -->
  11. <head>
  12. <meta charset="utf-8" />
  13. <title>CertainTrust Demonstrator in JavaScript</title>
  14. <style type="text/css">
  15. h1, p, td:nth-child(2n) { text-align: center; }
  16. table { margin: 50px 0; }
  17. </style>
  18. <!-- include these two scripts and the CSS to enable both CertainTrust and the HTI -->
  19. <script type="text/javascript" src="CertainTrust.js"></script>
  20. <script type="text/javascript" src="certainTrustHTI.js"></script>
  21. <link rel="stylesheet" type="text/css" href="certainTrustHTI.css"/>
  22. </head>
  23. <body>
  24. <h1>Demonstrator for CertainTrust</h1>
  25. <p>CertainTrust provides a means for the evaluation of propositional logic terms under uncertainty.</p>
  26. <table>
  27. <!-- Demonstrator for CertainTrust.cFusion -->
  28. <tr>
  29. <td id="cf-operand1"></td>
  30. <td>cFusion</td>
  31. <td id="cf-operand2"></td>
  32. <td>=</td>
  33. <td id="cf-result"></td>
  34. </tr>
  35. </table>
  36. <script type="text/javascript">
  37. // create an Array to hold the CertainTrust objects
  38. var CT_objects = [];
  39. var N = 10;
  40. var CT_names = ['cf-operand1','cf-operand2','cf-result'];
  41. // CFObserver is used for the conflicted fusion (cFusion) calculation
  42. var CFObserver = {
  43. update: function() {
  44. var fusTmp = new CertainTrust(5);
  45. var weight = [1,1];
  46. var fusArray = [];
  47. fusArray.push(CT_objects['cf-operand1']);
  48. fusArray.push(CT_objects['cf-operand2']);
  49. //cFusion operation
  50. var CT_result = fusTmp.cFusion(fusArray,weight);
  51. // update the HTI which displays the result
  52. CT_objects['cf-result'].setF(CT_result.getF());
  53. CT_objects['cf-result'].setTC(CT_result.getT(), CT_result.getC());
  54. }
  55. };
  56. // create the CertainTrust objects and the associated HTIs
  57. for (var i = 0, element; element = CT_names[i]; ++i) {
  58. var CT_object = new CertainTrust(N);
  59. // the result HTIs should be read-only
  60. var isResultHTI = (-1 !== element.indexOf('-result'));
  61. var HTI = new CertainTrustHTI(CT_object, {domParent: element, readonly: isResultHTI});
  62. // register our observers for the calculation
  63. if (!isResultHTI) {
  64. var isCF = (0 === element.indexOf('cf-'));
  65. if(isCF){
  66. CT_object.addObserver(CFObserver);
  67. }
  68. }
  69. // store the created objects for easy access in the Arrays
  70. CT_objects[element] = CT_object;
  71. }
  72. // trigger initial update to the result HTIs
  73. CFObserver.update();
  74. </script>
  75. <p>
  76. <img src="logo_tudarmstadt.png" alt="Technische Universität Darmstadt" width="176" height="73" />
  77. <img src="logo_softwarecluster.png" alt="Software-Cluster" width="212" height="73" />
  78. </p>
  79. </body>
  80. </html>