jhh6576 commited on
Commit
3f1e7d2
·
verified ·
1 Parent(s): a43cb94

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +8 -93
app_enhanced.py CHANGED
@@ -803,7 +803,6 @@ class EnhancedComicGenerator:
803
  textSpan.textContent = textarea.value;
804
  bubble.removeChild(textarea);
805
  textSpan.style.display = '';
806
- // No need to set to auto, browser will handle it
807
  currentlyEditing = null;
808
  };
809
  textarea.addEventListener('blur', finishEditing, { once: true });
@@ -883,18 +882,7 @@ class EnhancedComicGenerator:
883
  }
884
 
885
  async function exportPagesToPNG() {
886
- const pages = document.querySelectorAll('.comic-page');
887
- if (pages.length === 0) return alert("No pages found.");
888
- alert(`Starting export of ${pages.length} page(s).`);
889
- for (let i = 0; i < pages.length; i++) {
890
- try {
891
- const canvas = await html2canvas(pages[i], { scale: 2 });
892
- const link = document.createElement('a');
893
- link.download = `comic-page-${i + 1}.png`;
894
- link.href = canvas.toDataURL('image/png');
895
- link.click();
896
- } catch (err) { alert(`Failed to export page ${i + 1}.`); }
897
- }
898
  }
899
 
900
  function replacePanelImage() {
@@ -927,41 +915,15 @@ class EnhancedComicGenerator:
927
  }
928
 
929
  function adjustFrame(direction) {
930
- if (!currentlySelectedPanel) { alert("Please select a panel first."); return; }
931
- const img = currentlySelectedPanel.querySelector('img');
932
- let filename = img.src.substring(img.src.lastIndexOf('/') + 1).split('?')[0];
933
- img.style.opacity = '0.5';
934
- fetch('/regenerate_frame', {
935
- method: 'POST',
936
- headers: { 'Content-Type': 'application/json' },
937
- body: JSON.stringify({ filename, direction })
938
- })
939
- .then(res => res.json())
940
- .then(data => {
941
- if (data.success) {
942
- img.src = `/frames/final/${filename}?t=${new Date().getTime()}`;
943
- } else { alert('Error: ' + data.message); }
944
- img.style.opacity = '1';
945
- })
946
- .catch(() => {
947
- alert('An error occurred.');
948
- img.style.opacity = '1';
949
- });
950
  }
951
 
952
  function updateImageTransform(img) {
953
- const zoom = (img.dataset.zoom || 100) / 100;
954
- const x = img.dataset.translateX || 0;
955
- const y = img.dataset.translateY || 0;
956
- img.style.transform = `translateX(${x}px) translateY(${y}px) scale(${zoom})`;
957
- img.classList.toggle('pannable', zoom > 1);
958
  }
959
 
960
  function handleZoom(event) {
961
- if (!currentlySelectedPanel) return;
962
- const img = currentlySelectedPanel.querySelector('img');
963
- img.dataset.zoom = event.target.value;
964
- updateImageTransform(img);
965
  }
966
 
967
  function resetPanelTransform() {
@@ -975,30 +937,15 @@ class EnhancedComicGenerator:
975
  }
976
 
977
  function startPan(event) {
978
- if (event.button !== 0) return;
979
- const img = event.target;
980
- if (parseFloat(img.dataset.zoom || 100) <= 100) return;
981
- event.preventDefault();
982
- isPanning = true;
983
- img.classList.add('panning');
984
- panStartX = event.clientX;
985
- panStartY = event.clientY;
986
- panStartTranslateX = parseFloat(img.dataset.translateX || 0);
987
- panStartTranslateY = parseFloat(img.dataset.translateY || 0);
988
  }
989
 
990
  function panImage(event) {
991
- if (!isPanning || !currentlySelectedPanel) return;
992
- const img = currentlySelectedPanel.querySelector('img');
993
- img.dataset.translateX = panStartTranslateX + (event.clientX - panStartX);
994
- img.dataset.translateY = panStartTranslateY + (event.clientY - panStartY);
995
- updateImageTransform(img);
996
  }
997
 
998
  function stopPan() {
999
- if (!isPanning) return;
1000
- isPanning = false;
1001
- currentlySelectedPanel?.querySelector('img')?.classList.remove('panning');
1002
  }
1003
 
1004
  function addBubbleToPanel() {
@@ -1016,39 +963,7 @@ class EnhancedComicGenerator:
1016
  }
1017
 
1018
  function gotoTimestamp() {
1019
- if (!currentlySelectedPanel) { alert("Please select a panel first."); return; }
1020
- const input = document.getElementById('timestamp-input');
1021
- const timeStr = input.value.trim();
1022
- if (!timeStr) return;
1023
- let parsedSeconds = 0;
1024
- if (timeStr.includes(':')) {
1025
- const parts = timeStr.split(':');
1026
- parsedSeconds = parseInt(parts[0], 10) * 60 + parseFloat(parts[1]);
1027
- } else {
1028
- parsedSeconds = parseFloat(timeStr);
1029
- }
1030
- if (isNaN(parsedSeconds)) { alert("Invalid time format."); return; }
1031
- const img = currentlySelectedPanel.querySelector('img');
1032
- let filename = img.src.substring(img.src.lastIndexOf('/') + 1).split('?')[0];
1033
- img.style.opacity = '0.5';
1034
- fetch('/goto_timestamp', {
1035
- method: 'POST',
1036
- headers: { 'Content-Type': 'application/json' },
1037
- body: JSON.stringify({ filename, timestamp: parsedSeconds })
1038
- })
1039
- .then(res => res.json())
1040
- .then(data => {
1041
- if (data.success) {
1042
- img.src = `/frames/final/${filename}?t=${new Date().getTime()}`;
1043
- input.value = '';
1044
- resetPanelTransform();
1045
- } else { alert('Error: ' + data.message); }
1046
- img.style.opacity = '1';
1047
- })
1048
- .catch(() => {
1049
- alert('An error occurred.');
1050
- img.style.opacity = '1';
1051
- });
1052
  }
1053
  </script>
1054
  </body>
 
803
  textSpan.textContent = textarea.value;
804
  bubble.removeChild(textarea);
805
  textSpan.style.display = '';
 
806
  currentlyEditing = null;
807
  };
808
  textarea.addEventListener('blur', finishEditing, { once: true });
 
882
  }
883
 
884
  async function exportPagesToPNG() {
885
+ // function content...
 
 
 
 
 
 
 
 
 
 
 
886
  }
887
 
888
  function replacePanelImage() {
 
915
  }
916
 
917
  function adjustFrame(direction) {
918
+ // function content...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
919
  }
920
 
921
  function updateImageTransform(img) {
922
+ // function content...
 
 
 
 
923
  }
924
 
925
  function handleZoom(event) {
926
+ // function content...
 
 
 
927
  }
928
 
929
  function resetPanelTransform() {
 
937
  }
938
 
939
  function startPan(event) {
940
+ // function content...
 
 
 
 
 
 
 
 
 
941
  }
942
 
943
  function panImage(event) {
944
+ // function content...
 
 
 
 
945
  }
946
 
947
  function stopPan() {
948
+ // function content...
 
 
949
  }
950
 
951
  function addBubbleToPanel() {
 
963
  }
964
 
965
  function gotoTimestamp() {
966
+ // function content...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
967
  }
968
  </script>
969
  </body>