evidences.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. CertainTrust Demonstrator in JavaScript
  5. Demonstrates Trust Evidences in CertainTrust with a Visualization using the HTI.
  6. @author Florian Volk <florian.volk@cased.de>
  7. -->
  8. <head>
  9. <meta charset="utf-8" />
  10. <title>CertainTrust Demonstrator in JavaScript</title>
  11. <style type="text/css">
  12. h1, p { text-align: center; }
  13. button#AddR_Button, button#AddS_Button, button#SetN_Button { float: right; margin-left: 1em; }
  14. div#userControls { float:left; margin-right: 2em; }
  15. </style>
  16. <!-- include these two scripts and the CSS to enable both CertainTrust and the HTI -->
  17. <script type="text/javascript" src="CertainTrust.js"></script>
  18. <script type="text/javascript" src="certainTrustHTI.js"></script>
  19. <link rel="stylesheet" type="text/css" href="certainTrustHTI.css"/>
  20. </head>
  21. <body>
  22. <h1>Trust Visualization with the HTI</h1>
  23. <p>Visualization of Trust Updates with CertainTrust and the Human Trust Interface</p>
  24. <div style="margin:0 auto;width:800px;">
  25. <!-- user controls -->
  26. <div id="userControls">
  27. <div>
  28. Positive&nbsp;experiences:&nbsp;<span id="R_Label">0</span>
  29. <button id="AddR_Button" onclick="AddR_ButtonClick();">Add</button>
  30. </div>
  31. <div style="clear:both">
  32. Negative&nbsp;experiences:&nbsp;<span id="S_Label">0</span>
  33. <button id="AddS_Button" onclick="AddS_ButtonClick();">Add</button>
  34. </div>
  35. <div style="margin-top: 1em;">
  36. <label for="N_Input">Expected amount of evidence:</label>
  37. <input id="N_Input" style="width: 4em;" />
  38. <button id="SetN_Button" onclick="SetN_ButtonClick();">Set</button>
  39. </div>
  40. <div style="clear:both">
  41. <button id="Reset_Button" onclick="Reset_ButtonClick();">Reset</button>
  42. </div>
  43. </div>
  44. <!-- HTI -->
  45. <script type="text/javascript">
  46. // initialize expected amount of evidence with 100
  47. var N = 100;
  48. // instanciate the CertainTrust and Human Trust Interface objects
  49. var ctObject = new CertainTrust(N);
  50. var hti = new CertainTrustHTI(ctObject);
  51. </script>
  52. <!-- connect controls with HTI -->
  53. <script type="text/javascript">
  54. document.getElementById("N_Input").value = "" + N;
  55. // LocalObserver is used to update information on the amount of experiences
  56. // after the user modified the HTI manually
  57. var LocalObserver = {
  58. update: function() {
  59. _updateLabel("R_Label", ctObject.getR());
  60. _updateLabel("S_Label", ctObject.getS());
  61. }
  62. }
  63. ctObject.addObserver(LocalObserver);
  64. function Reset_ButtonClick() {
  65. // reset all internal state of the opinion, set N to last known number
  66. ctObject.setN(N);
  67. ctObject.setRS(0,0);
  68. }
  69. function SetN_ButtonClick() {
  70. // change amount of expected evidence
  71. var newN = parseInt(document.getElementById("N_Input").value);
  72. if (!isNaN(newN)) {
  73. N = newN;
  74. ctObject.setN(N);
  75. }
  76. }
  77. function AddR_ButtonClick() {
  78. // add a positive experience
  79. ctObject.addR(1);
  80. }
  81. function AddS_ButtonClick() {
  82. // add a negative experience
  83. ctObject.addS(1);
  84. }
  85. function _updateLabel(id, value) {
  86. // helper function to nicely format amount of experiences that were made
  87. document.getElementById(id).innerHTML = "" + Math.round(value * 100) / 100;
  88. }
  89. </script>
  90. </div>
  91. <br/>
  92. <p>
  93. <img src="logo_tudarmstadt.png" alt="Technische Universität Darmstadt" width="176" height="73" />
  94. <img src="logo_softwarecluster.png" alt="Software-Cluster" width="212" height="73" />
  95. </p>
  96. </body>
  97. </html>