From dead0e4f05896a5c3954331c197f66df6fda891f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= <jonas.havelka@volny.cz>
Date: Wed, 5 Mar 2025 15:06:45 +0100
Subject: [PATCH] =?UTF-8?q?Definitivn=C3=AD=20zbaven=C3=AD=20se=20opraf.js?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 korektury/static/korektury/opraf.js           | 46 -------------------
 .../korektury/korekturovatko/__oprava.html    | 46 +++++++++++++++++++
 .../korektury/korekturovatko/htmlstrana.html  |  1 -
 3 files changed, 46 insertions(+), 47 deletions(-)
 delete mode 100644 korektury/static/korektury/opraf.js

diff --git a/korektury/static/korektury/opraf.js b/korektury/static/korektury/opraf.js
deleted file mode 100644
index 3963c49c..00000000
--- a/korektury/static/korektury/opraf.js
+++ /dev/null
@@ -1,46 +0,0 @@
-const W_SKIP = 10;
-const H_SKIP = 5;
-const POINTER_MIN_H = 30;
-
-function place_comments_one_div(img_id, comments)
-{
-	const img = document.getElementById("img-"+img_id);
-	if( img == null ) return;
-    const comments_sorted = comments.sort((a, b) => a.y - b.y);
-
-	const par = img.parentNode;
-	const w = img.clientWidth;
-
-	let bott_max = 0;
-	for (const oprava of comments_sorted) {
-		const x = oprava.x;
-		const y = oprava.y;
-        const htmlElement = oprava.htmlElement;
-		const pointer = oprava.pointer;
-
-		par.appendChild(pointer);
-		par.appendChild(htmlElement);
-
-		const delta_y = (y > bott_max) ?  0: bott_max - y + H_SKIP;
-
-		pointer.style.left = x;
-		pointer.style.top = y;
-		pointer.style.width = w - x + W_SKIP;
-		pointer.style.height = POINTER_MIN_H + delta_y;
-
-		htmlElement.style.left = w + W_SKIP;
-		htmlElement.style.top = y + delta_y;
-
-		bott_max = Math.max(bott_max, htmlElement.offsetTop + htmlElement.offsetHeight + H_SKIP); // FIXME nemám páru, proč +H_SKIP funguje, ale opravuje to bug, že nově vytvořené korektury za sebou neměly mezeru
-	}
-
-	if (par.offsetHeight < bott_max) par.style.height = bott_max;
-}
-
-function place_comments() {
-    for (let [img_id, opravy] of Object.entries(comments)) {
-	    place_comments_one_div(img_id, opravy)
-    }
-}
-
-
diff --git a/korektury/templates/korektury/korekturovatko/__oprava.html b/korektury/templates/korektury/korekturovatko/__oprava.html
index fdee6921..4ea0011e 100644
--- a/korektury/templates/korektury/korekturovatko/__oprava.html
+++ b/korektury/templates/korektury/korekturovatko/__oprava.html
@@ -186,4 +186,50 @@
       this.pointer.remove();
     }
   }
+
+  // Umisťování korektur
+  const W_SKIP = 10;
+  const H_SKIP = 5;
+  const POINTER_MIN_H = 30;
+
+  function place_comments_one_div(img_id, comments)
+  {
+    const img = document.getElementById("img-"+img_id);
+    if( img == null ) return;
+    const comments_sorted = comments.sort((a, b) => a.y - b.y);
+
+    const par = img.parentNode;
+    const w = img.clientWidth;
+
+    let bott_max = 0;
+    for (const oprava of comments_sorted) {
+      const x = oprava.x;
+      const y = oprava.y;
+      const htmlElement = oprava.htmlElement;
+      const pointer = oprava.pointer;
+
+      par.appendChild(pointer);
+      par.appendChild(htmlElement);
+
+      const delta_y = (y > bott_max) ?  0: bott_max - y + H_SKIP;
+
+      pointer.style.left = x;
+      pointer.style.top = y;
+      pointer.style.width = w - x + W_SKIP;
+      pointer.style.height = POINTER_MIN_H + delta_y;
+
+      htmlElement.style.left = w + W_SKIP;
+      htmlElement.style.top = y + delta_y;
+
+      bott_max = Math.max(bott_max, htmlElement.offsetTop + htmlElement.offsetHeight + H_SKIP); // FIXME nemám páru, proč +H_SKIP funguje, ale opravuje to bug, že nově vytvořené korektury za sebou neměly mezeru
+    }
+
+    if (par.offsetHeight < bott_max) par.style.height = bott_max;
+  }
+
+  function place_comments() {
+    for (let [img_id, opravy] of Object.entries(comments)) {
+      place_comments_one_div(img_id, opravy)
+    }
+  }
 </script>
diff --git a/korektury/templates/korektury/korekturovatko/htmlstrana.html b/korektury/templates/korektury/korekturovatko/htmlstrana.html
index f27657c9..025be8ee 100644
--- a/korektury/templates/korektury/korekturovatko/htmlstrana.html
+++ b/korektury/templates/korektury/korekturovatko/htmlstrana.html
@@ -5,7 +5,6 @@
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}?version=2" />
   <link href="{% static 'css/rozliseni.css' %}?version=2" rel="stylesheet">
-  <script src="{% static "korektury/opraf.js"%}?version=2"></script>
   <title>Korektury {{korekturovanepdf.nazev}}</title>
 </head>
 <body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ korekturovanepdf.status }}">