Update pages.html
Browse files- pages.html +90 -94
pages.html
CHANGED
@@ -706,35 +706,40 @@ editor.on('load', function() {
|
|
706 |
// Функция для показа/скрытия приложения
|
707 |
document.addEventListener('DOMContentLoaded', () => {
|
708 |
// Функция для тестовой кнопки
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
<
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
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 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|