index.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <!--
  2. This file is part of centurio.work/edi.
  3. centurio.work/edi is free software: you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the Free
  5. Software Foundation, either version 3 of the License, or (at your option) any
  6. later version.
  7. centurio.work/edi is distributed in the hope that it will be useful, but
  8. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. centurio.work/edi (file COPYING in the main directory). If not, see
  13. <http://www.gnu.org/licenses/>.
  14. -->
  15. <!DOCTYPE html>
  16. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  19. <title>Resources</title>
  20. <!-- libs, do not modify. When local than load local libs. -->
  21. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/jquery.min.js') }}"></script>
  22. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/jquery.browser.js') }}"></script>
  23. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/jquery.svg.min.js') }}"></script>
  24. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/jquery.svgdom.min.js') }}"></script>
  25. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/vkbeautify.js') }}"></script>
  26. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/util.js') }}"></script>
  27. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/printf.js') }}"></script>
  28. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs//strftime.min.js') }}"></script>
  29. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/parsequery.js') }}"></script>
  30. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/underscore.min.js') }}"></script>
  31. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/jquery.caret.min.js') }}"></script>
  32. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/jquery.cookie.js') }}"></script>
  33. <script type="text/javascript" src="{{ url_for('static', filename='js/js_libs/ui.js') }}"></script>
  34. <link rel="stylesheet" href="{{ url_for('static', filename='js/js_libs/ui.css') }}" type="text/css"/>
  35. <link rel="stylesheet" href="{{ url_for('static', filename='js/js_libs/cdp_ui.css') }}" type="text/css"/>
  36. <!--<link rel="stylesheet" href="{{ url_for('static', filename='js/js_libs/css/ui.css') }}" type="text/css"/>-->
  37. <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css"/>
  38. <link rel="stylesheet" href="{{ url_for('static', filename='css/layout.css') }}" type="text/css"/>
  39. <body is="x-ui">
  40. <ui-rest id="main">
  41. <ui-content>
  42. <ui-area id='datacolumn'>
  43. <!-- <ui-rest id="sub"> with this the content does not work for other tabs -->
  44. <ui-tabbar>
  45. <ui-before>
  46. <a class="logo" href="/"> </a>
  47. </ui-before>
  48. <ui-tab class="default" data-tab="drawing" >Drawing
  49. </ui-tab>
  50. <ui-behind ></ui-behind>
  51. </ui-tabbar>
  52. <!--</ui-rest>-->
  53. <ui-content>
  54. <ui-area data-belongs-to-tab="drawing" >
  55. <div class="images">
  56. <img class="optcontent" id="drawing" src="{{ url_for('send_file', filename=filename) }}" alt="Drawing">
  57. </div>
  58. </ui-area>
  59. </ui-content>
  60. </ui-area>
  61. <ui-resizehandle data-label="drag to resize"></ui-resizehandle>
  62. <ui-area id="detailcolumn1" data-minsize="20em">
  63. <h3 style="text-align:left"> Regulatory Documents</h3>
  64. <div id="dat_details" class='x-ui-layout'>
  65. <table style='text-align:left'>
  66. <tr>
  67. {{ html_links | safe }}
  68. </tr>
  69. {% for iso in isos_names %}
  70. <tr>
  71. <td style='text-align:left'> {{ iso }}</td>
  72. </tr>
  73. {% endfor %}
  74. </table>
  75. </div>
  76. <div id="measurements">
  77. <font >
  78. <form>
  79. <table>
  80. <tr>
  81. <td style="text-align:center"><h3>Key Value</h3></td>
  82. <td style="text-align:center"><h3>Target Value</h3></td>
  83. <td style="text-align:center"><h3>Actual Value</h3></td>
  84. <td style="text-align:center"><h3>Relevant Isos</h3></td>
  85. </tr>
  86. {{ text | safe}}
  87. </table>
  88. </form>
  89. </font>
  90. </div>
  91. </ui-area>
  92. </ui-content>
  93. </ui-rest>
  94. <script>
  95. function log(){
  96. console.log("test");
  97. }
  98. function set_redis(key, value) {
  99. $.ajax({
  100. type: "POST",
  101. url: "/redis/set/" + key,
  102. data: JSON.stringify({ value: value }),
  103. dataType: "json",
  104. contentType: "json",
  105. success: function(data)
  106. {
  107. (data.GET);
  108. }
  109. });
  110. }
  111. function get_redis(key) {
  112. $.ajax({
  113. type: "GET",
  114. url: "redis/get/" + key,
  115. data: "format=json",
  116. dataType: "text",
  117. success: function(data)
  118. {
  119. $("#result").text(data.GET);
  120. }
  121. });
  122. }
  123. function split_string(string) {
  124. var string = str.split(" ",2);
  125. return string;
  126. };
  127. </script>
  128. <script>
  129. $(document).ready(function(){
  130. $("input[type=number]").on("change keyup input", function(){
  131. var array_value = [];
  132. array_value[0] = $(this).attr('name');
  133. array_value[1] = $(this).val();
  134. var key = 'last' + "_" +'{{og_filename}}';
  135. //console.log({{ dim }});
  136. set_redis(key, array_value);
  137. });
  138. $("input[type=checkbox]").change(function(){
  139. // Print entered value in a div box
  140. $("#result").text($(this).attr('name'));
  141. var key1 = 'last' + "_" +'{{og_filename}}';
  142. var array_value1 = [];
  143. if ($(this).is(':checked')) {
  144. console.log($(this).attr('name') + ' is now checked');
  145. array_value1[0] = 'relevant.' + $(this).attr('name');
  146. array_value1[1] = true;
  147. } else {
  148. console.log($(this).attr('name') + ' is now unchecked');
  149. array_value1[0] = $(this).attr('name');
  150. array_value1[1] = false;
  151. }
  152. set_redis(key1, array_value1);
  153. });
  154. $("input[type=number]").focus(function(){
  155. // highlight values, does not work so far
  156. var number = $(this).attr('name');
  157. var coords = $(this).attr('data-coords');
  158. highlight_areas(coords, "red");
  159. var detail = $(this).attr('data-details');
  160. console.log(detail, "green");
  161. highlight_details(detail, "green");
  162. });
  163. $("input[type=number]").blur(function(){
  164. $("div").removeClass("red");
  165. $("div").removeClass("green");
  166. });
  167. function highlight_areas(coords, color){
  168. let w = {{w}}
  169. let h = {{h}}
  170. let pos = $("#drawing").position();
  171. let drawing_x = pos.left;
  172. let drawing_y = pos.top;
  173. let array_coords = coords.split(",");
  174. let coords_x = parseFloat(array_coords[0]);
  175. let coords_xmax = parseFloat(array_coords[2]);
  176. let coords_y = parseFloat(array_coords[1]);
  177. let coords_ymax = parseFloat(array_coords[3]);
  178. let coords_width = (coords_xmax - coords_x);
  179. let coords_height = (coords_ymax - coords_y);
  180. let width = $("#drawing").width();
  181. let height = $("#drawing").height();
  182. let rel_width = coords_width/h*width*1.4;
  183. let rel_height = coords_height/w*height*1.4;
  184. let x = width*(coords_x*height/width/w);
  185. let y = height*(coords_y*width/height/h);
  186. console.log(w, h, rel_width, rel_height,x,y);
  187. let $point1 = jQuery("<div class="+color+"/>").css({top: (drawing_y + y -5) + 'px', left: (drawing_x + x-5) + 'px', width: rel_width , height: rel_height});
  188. $(".images").append($point1);
  189. };
  190. function highlight_details(coords, color){
  191. let w = {{w}}
  192. let h = {{h}}
  193. let pos = $("#drawing").position();
  194. let drawing_x = pos.left;
  195. let drawing_y = pos.top;
  196. let array_coords = coords.split(",");
  197. let coords_x = parseFloat(array_coords[0]);
  198. let coords_y = parseFloat(array_coords[1]);
  199. let width_div = (parseFloat(array_coords[2]) - parseFloat(array_coords[0]));
  200. let height_div = (parseFloat(array_coords[3]) - parseFloat(array_coords[1]));
  201. let width = $("#drawing").width();
  202. let rel_width = width_div/h*width;
  203. let height = $("#drawing").height();
  204. let rel_height = height*height_div/w;
  205. let x = width*(coords_x*height/width/w);
  206. let y= height*(coords_y*width/height/h);
  207. console.log(rel_width, rel_height);
  208. if (array_coords[3] > 10000) {
  209. rel_height = height - y;
  210. }
  211. let $point = jQuery("<div class="+color+"/>").css({top: (drawing_y + y) + 'px', left: (drawing_x + x) + 'px', width: (rel_width) + 'px', height: (rel_height) + 'px'});
  212. $(".images").append($point);
  213. };
  214. });
  215. </script>
  216. </body>
  217. </html>