index.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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:center"> General Information</h3>
  64. <div id="dat_details" class='x-ui-layout'>
  65. <div class="column-one" style="width:50%;float:left">
  66. {{ html_links | safe }}
  67. {% for iso in isos_names %}
  68. {{ iso }} (Document not available)<br>
  69. {% endfor %}
  70. </div>
  71. <div class="column-two" style="width:50%;float:right">
  72. {{ html_general | safe }}
  73. </div>
  74. </div>
  75. <div id="measurements">
  76. <font >
  77. <form>
  78. <table>
  79. <tr>
  80. <td style="text-align:center"><h3>Key Value</h3></td>
  81. <td style="text-align:center"><h3>Target Value</h3></td>
  82. <td style="text-align:center"><h3>Actual Value</h3></td>
  83. <td style="text-align:center"><h3>Relevant Isos</h3></td>
  84. </tr>
  85. {{ text | safe}}
  86. </table>
  87. </form>
  88. </font>
  89. </div>
  90. </ui-area>
  91. </ui-content>
  92. </ui-rest>
  93. <script>
  94. function log(){
  95. console.log("test");
  96. }
  97. function set_redis(key, value) {
  98. $.ajax({
  99. type: "POST",
  100. url: "/redis/set/" + key,
  101. data: JSON.stringify({ value: value }),
  102. dataType: "json",
  103. contentType: "json",
  104. success: function(data)
  105. {
  106. (data.GET);
  107. }
  108. });
  109. }
  110. function get_redis(key) {
  111. $.ajax({
  112. type: "GET",
  113. url: "redis/get/" + key,
  114. data: "format=json",
  115. dataType: "text",
  116. success: function(data)
  117. {
  118. $("#result").text(data.GET);
  119. }
  120. });
  121. }
  122. function split_string(string) {
  123. var string = str.split(" ",2);
  124. return string;
  125. };
  126. </script>
  127. <script>
  128. $(document).ready(function(){
  129. $("input[type=number]").on("change keyup input", function(){
  130. var array_value = [];
  131. array_value[0] = $(this).attr('name');
  132. array_value[1] = $(this).val();
  133. var key = 'last' + "_" +'{{og_filename}}';
  134. //console.log({{ dim }});
  135. set_redis(key, array_value);
  136. });
  137. $("input[type=checkbox]").change(function(){
  138. // Print entered value in a div box
  139. $("#result").text($(this).attr('name'));
  140. var key1 = 'last' + "_" +'{{og_filename}}';
  141. var array_value1 = [];
  142. if ($(this).is(':checked')) {
  143. console.log($(this).attr('name') + ' is now checked');
  144. array_value1[0] = 'relevant.' + $(this).attr('name');
  145. array_value1[1] = true;
  146. } else {
  147. console.log($(this).attr('name') + ' is now unchecked');
  148. array_value1[0] = $(this).attr('name');
  149. array_value1[1] = false;
  150. }
  151. set_redis(key1, array_value1);
  152. });
  153. $("input[type=number]").focus(function(){
  154. // highlight values, does not work so far
  155. var number = $(this).attr('name');
  156. var coords = $(this).attr('data-coords');
  157. highlight_areas(coords, "red");
  158. var detail = $(this).attr('data-details');
  159. console.log(detail, "green");
  160. highlight_details(detail, "green");
  161. });
  162. $("input[type=number]").blur(function(){
  163. $("div").removeClass("red");
  164. $("div").removeClass("green");
  165. });
  166. function highlight_areas(coords, color){
  167. let w = {{w}}
  168. let h = {{h}}
  169. let pos = $("#drawing").position();
  170. let drawing_x = pos.left;
  171. let drawing_y = pos.top;
  172. let array_coords = coords.split(",");
  173. let coords_x = parseFloat(array_coords[0]);
  174. let coords_xmax = parseFloat(array_coords[2]);
  175. let coords_y = parseFloat(array_coords[1]);
  176. let coords_ymax = parseFloat(array_coords[3]);
  177. let coords_width = (coords_xmax - coords_x);
  178. let coords_height = (coords_ymax - coords_y);
  179. let width = $("#drawing").width();
  180. let height = $("#drawing").height();
  181. let rel_width = coords_width/h*width*1.4;
  182. let rel_height = coords_height/w*height*1.4;
  183. let x = width*(coords_x*height/width/w);
  184. let y = height*(coords_y*width/height/h);
  185. console.log(w, h, rel_width, rel_height,x,y);
  186. 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});
  187. $(".images").append($point1);
  188. };
  189. function highlight_details(coords, color){
  190. let w = {{w}}
  191. let h = {{h}}
  192. let pos = $("#drawing").position();
  193. let drawing_x = pos.left;
  194. let drawing_y = pos.top;
  195. let array_coords = coords.split(",");
  196. let coords_x = parseFloat(array_coords[0]);
  197. let coords_y = parseFloat(array_coords[1]);
  198. let width_div = (parseFloat(array_coords[2]) - parseFloat(array_coords[0]));
  199. let height_div = (parseFloat(array_coords[3]) - parseFloat(array_coords[1]));
  200. let width = $("#drawing").width();
  201. let rel_width = width_div/h*width;
  202. let height = $("#drawing").height();
  203. let rel_height = height*height_div/w;
  204. let x = width*(coords_x*height/width/w);
  205. let y= height*(coords_y*width/height/h);
  206. console.log(rel_width, rel_height);
  207. if (array_coords[3] > 10000) {
  208. rel_height = height - y;
  209. }
  210. 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'});
  211. $(".images").append($point);
  212. };
  213. });
  214. </script>
  215. </body>
  216. </html>