DmitrMakeev commited on
Commit
b5f2bed
·
verified ·
1 Parent(s): 9849074

Update pages.html

Browse files
Files changed (1) hide show
  1. pages.html +90 -94
pages.html CHANGED
@@ -706,35 +706,40 @@ editor.on('load', function() {
706
  // Функция для показа/скрытия приложения
707
  document.addEventListener('DOMContentLoaded', () => {
708
  // Функция для тестовой кнопки
709
- document.addEventListener('DOMContentLoaded', () => {
710
- document.getElementById('testBtn').addEventListener('click', function() {
711
- console.log('Тестовая кнопка работает!');
712
- const editor = grapesjs.editors[0]; // Предполагается, что у вас есть только один редактор
713
- const htmlContent = editor.getHtml();
714
- const cssContent = editor.getCss();
715
- const fullHtmlContent = `
716
- <!DOCTYPE html>
717
- <html lang="en">
718
- <head>
719
- <meta charset="UTF-8">
720
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
721
- <title>Скачанная HTML-страница</title>
722
- <style>${cssContent}</style>
723
- </head>
724
- <body>
725
- ${htmlContent}
726
- </body>
727
- </html>
728
- `;
729
- const blob = new Blob([fullHtmlContent], { type: 'text/html' });
730
- const link = document.createElement('a');
731
- link.href = URL.createObjectURL(blob);
732
- link.download = 'downloaded_page.html';
733
- document.body.appendChild(link);
734
- link.click();
735
- document.body.removeChild(link);
736
- });
737
- });
 
 
 
 
 
738
  // Функция для показа/скрытия приложения
739
  document.getElementById('toggleAppBtn').addEventListener('click', function() {
740
  const app = document.getElementById('gjs');
@@ -747,71 +752,62 @@ editor.on('load', function() {
747
  });
748
  </script>
749
 
750
-
751
-
752
-
753
-
754
-
755
-
756
-
757
-
758
-
759
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
760
- <script>
761
- document.getElementById('uploadForm').addEventListener('submit', function(event) {
762
- event.preventDefault();
763
- var formData = new FormData(this);
764
- var request = new XMLHttpRequest();
765
- request.open('POST', '/up_page');
766
- request.upload.addEventListener('progress', function(event) {
767
- if (event.lengthComputable) {
768
- var percentComplete = (event.loaded / event.total) * 100;
769
- document.getElementById('progressBar').style.width = percentComplete + '%';
770
- document.getElementById('progressBar').innerText = Math.round(percentComplete) + '%';
771
- }
772
- }, false);
773
- request.addEventListener('load', function(event) {
774
- var response = event.target.responseText;
775
- if (event.target.status === 200) {
776
- var fullUrl = response.split('saved to ')[1];
777
- document.getElementById('imageUrl').innerText = 'Click to copy URL';
778
- document.getElementById('imageUrl').setAttribute('data-url', fullUrl);
779
- Toastify({
780
- text: "File uploaded successfully",
781
- duration: 3000,
782
- gravity: "top",
783
- position: "center",
784
- backgroundColor: "#4CAF50",
785
- }).showToast();
786
- } else if (event.target.status === 409) {
787
- Toastify({
788
- text: "File with this name already exists",
789
- duration: 3000,
790
- gravity: "top",
791
- position: "center",
792
- backgroundColor: "#FF5733",
793
- }).showToast();
794
- }
795
- document.getElementById('progressBar').style.width = '0%';
796
- document.getElementById('progressBar').innerText = '0%';
797
- }, false);
798
- request.send(formData);
799
- });
800
- function copyToClipboard(element) {
801
- var tempInput = document.createElement("input");
802
- tempInput.value = element.getAttribute('data-url');
803
- document.body.appendChild(tempInput);
804
- tempInput.select();
805
- document.execCommand("copy");
806
- document.body.removeChild(tempInput);
807
- Toastify({
808
- text: "URL copied to clipboard",
809
- duration: 3000,
810
- gravity: "top",
811
- position: "center",
812
- backgroundColor: "#4CAF50",
813
- }).showToast();
814
  }
815
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
  </body>
817
  </html>
 
706
  // Функция для показа/скрытия приложения
707
  document.addEventListener('DOMContentLoaded', () => {
708
  // Функция для тестовой кнопки
709
+ document.getElementById('testBtn').addEventListener('click', function() {
710
+ console.log('Тестовая кнопка работает!');
711
+ // Получаем HTML-код из GrapesJS
712
+ const editor = grapesjs.editors[0]; // Предполагается, что у вас есть только один редактор
713
+ const htmlContent = editor.getHtml();
714
+ const cssContent = editor.getCss();
715
+ // Создаем полный HTML-документ
716
+ const fullHtmlContent = `
717
+ <!DOCTYPE html>
718
+ <html lang="en">
719
+ <head>
720
+ <meta charset="UTF-8">
721
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
722
+ <title>Скачанная HTML-страница</title>
723
+ <style>${cssContent}</style>
724
+ </head>
725
+ <body>
726
+ ${htmlContent}
727
+ </body>
728
+ </html>
729
+ `;
730
+ // Создаем Blob с HTML-кодом
731
+ const blob = new Blob([fullHtmlContent], { type: 'text/html' });
732
+ // Создаем ссылку для скачивания
733
+ const link = document.createElement('a');
734
+ link.href = URL.createObjectURL(blob);
735
+ link.download = 'downloaded_page.html';
736
+ // Добавляем ссылку в документ и программно кликаем по ней
737
+ document.body.appendChild(link);
738
+ link.click();
739
+ // Удаляем ссылку из документа
740
+ document.body.removeChild(link);
741
+ });
742
+
743
  // Функция для показа/скрытия приложения
744
  document.getElementById('toggleAppBtn').addEventListener('click', function() {
745
  const app = document.getElementById('gjs');
 
752
  });
753
  </script>
754
 
755
+ <script>
756
+ document.getElementById('uploadForm').addEventListener('submit', function(event) {
757
+ event.preventDefault();
758
+ var formData = new FormData(this);
759
+ var request = new XMLHttpRequest();
760
+ request.open('POST', '/up_page');
761
+ request.upload.addEventListener('progress', function(event) {
762
+ if (event.lengthComputable) {
763
+ var percentComplete = (event.loaded / event.total) * 100;
764
+ document.getElementById('progressBar').style.width = percentComplete + '%';
765
+ document.getElementById('progressBar').innerText = Math.round(percentComplete) + '%';
766
+ }
767
+ }, false);
768
+ request.addEventListener('load', function(event) {
769
+ var response = event.target.responseText;
770
+ if (event.target.status === 200) {
771
+ var fullUrl = response.split('saved to ')[1];
772
+ document.getElementById('imageUrl').innerText = 'Click to copy URL';
773
+ document.getElementById('imageUrl').setAttribute('data-url', fullUrl);
774
+ Toastify({
775
+ text: "File uploaded successfully",
776
+ duration: 3000,
777
+ gravity: "top",
778
+ position: "center",
779
+ backgroundColor: "#4CAF50",
780
+ }).showToast();
781
+ } else if (event.target.status === 409) {
782
+ Toastify({
783
+ text: "File with this name already exists",
784
+ duration: 3000,
785
+ gravity: "top",
786
+ position: "center",
787
+ backgroundColor: "#FF5733",
788
+ }).showToast();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
789
  }
790
+ document.getElementById('progressBar').style.width = '0%';
791
+ document.getElementById('progressBar').innerText = '0%';
792
+ }, false);
793
+ request.send(formData);
794
+ });
795
+
796
+ function copyToClipboard(element) {
797
+ var tempInput = document.createElement("input");
798
+ tempInput.value = element.getAttribute('data-url');
799
+ document.body.appendChild(tempInput);
800
+ tempInput.select();
801
+ document.execCommand("copy");
802
+ document.body.removeChild(tempInput);
803
+ Toastify({
804
+ text: "URL copied to clipboard",
805
+ duration: 3000,
806
+ gravity: "top",
807
+ position: "center",
808
+ backgroundColor: "#4CAF50",
809
+ }).showToast();
810
+ }
811
+ </script>
812
  </body>
813
  </html>