show_image_old_working.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <!doctype html>
  2. <head>
  3. <title>Dimension Extraction</title>
  4. <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"/>
  5. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  6. <script src="https://unpkg.com/pdfjs-dist@latest/build/pdf.min.js"></script>
  7. </head>
  8. <body>
  9. <!--<div class="split left">-->
  10. <div class="container">
  11. <div class="column column-one">
  12. <h1>Drawing</h1>
  13. <p> <a href="http://localhost:5000/"> Upload another drawing </a> </p>
  14. {% if filename %}
  15. <div class="images">
  16. <img id="drawing" src="{{ url_for('send_file', filename=filename) }}">
  17. </div>
  18. <!-- <input type="file" id="pdf-upload"/>
  19. <hr/>
  20. <canvas class="frame"></canvas>-->
  21. {% else %}
  22. <h1>no image for whatever reason</h1>
  23. {% endif %}
  24. </div>
  25. <!--<div class="split middle">-->
  26. <div class="column column-two" id="measurements">
  27. <h1>Extracted Measurements</h1>
  28. <font size="3" face="Courier New" >
  29. <form>
  30. <table>
  31. <tr>
  32. <td style="text-align:center"><h3>Key Value</h3></td>
  33. <td style="text-align:center"><h3>Target Value</h3></td>
  34. <td style="text-align:center"><h3>Actual Value</h3></td>
  35. </tr>
  36. {{ text | safe}}
  37. <!-- {% for key in dims %}
  38. <td><h4> {{key}} </h4></td>
  39. {% for d in dims[key] %}
  40. <tr>
  41. <td style="text-align:center"><input type="checkbox" name="relevant[]" value="checked"></td>
  42. <td style="text-align:center"> {{ d }}</td>
  43. <td style="text-align:center"><input type="text" name="{{ d }}" size="10"></td>
  44. </tr>
  45. {% endfor %}
  46. {% endfor %}-->
  47. </table>
  48. </form>
  49. </font>
  50. <div id="result">Result {{ number }}</div>
  51. </div>
  52. <!--<div class="split right">-->
  53. <div class="column column-three">
  54. <h1>Additional Infos</h1>
  55. <table>
  56. {% for k in isos %}
  57. <tr>
  58. <td><a href="{{ url_for('generate', name=k) }}" > {{ k }} </a> </td>
  59. </tr>
  60. {% endfor %}
  61. </table>
  62. </div>
  63. </div>
  64. <script>
  65. function set_redis(key, value) {
  66. $.ajax({
  67. type: "POST",
  68. url: "/redis/set/" + key,
  69. data: JSON.stringify({ value: value }),
  70. dataType: "json",
  71. contentType: "json",
  72. success: function(data)
  73. {
  74. (data.GET);
  75. }
  76. });
  77. }
  78. function get_redis(key) {
  79. $.ajax({
  80. type: "GET",
  81. url: "redis/get/" + key,
  82. data: "format=json",
  83. dataType: "text",
  84. success: function(data)
  85. {
  86. $("#result").text(data.GET);
  87. }
  88. });
  89. }
  90. </script>
  91. <script>
  92. $(document).ready(function(){
  93. $("input[type=number]").on("change keyup input", function(){
  94. var array_value = [];
  95. array_value[0] = $(this).attr('name');
  96. array_value[1] = $(this).val();
  97. var key = 'last' + "_" +'{{og_filename}}';
  98. console.log(array_value);
  99. set_redis(key, array_value);
  100. });
  101. $("input[type=checkbox]").on("change keyup input", function(){
  102. // Print entered value in a div box
  103. $("#result").text($(this).attr('name'));
  104. set_redis(key, value);
  105. });
  106. $("input[type=number]").focus(function(){
  107. // highlight values, does not work so far
  108. var number = $(this).attr('name');
  109. var coords = $(this).attr('data-coords');
  110. highlight_areas(coords);
  111. });
  112. $("input[type=number]").blur(function(){
  113. $("div").removeClass("red");
  114. });
  115. function highlight_areas(coords){
  116. let pos = $("#drawing").position();
  117. let drawing_x = pos.left;
  118. let drawing_y = pos.top;
  119. let array_coords = coords.split(",");
  120. let coords_x = parseFloat(array_coords[0]);
  121. let coords_y = parseFloat(array_coords[1]);
  122. let width = $("#drawing").width();
  123. let height = $("#drawing").height();
  124. let x = width*(coords_x/595)-60;
  125. let y = height*(coords_y/842)+10;
  126. console.log(width, height);
  127. let $point = jQuery("<div class='red'/>").css({top: (drawing_y + y) + 'px', left: (drawing_x + x) + 'px'})
  128. $(".images").append($point);
  129. };
  130. });
  131. </script>
  132. </body>