DmitrMakeev commited on
Commit
ae60dd2
·
verified ·
1 Parent(s): 0f5ea6b

Update pages.html

Browse files
Files changed (1) hide show
  1. pages.html +48 -52
pages.html CHANGED
@@ -474,6 +474,33 @@ z-index: 1000; /* Убедитесь, что кнопка находится п
474
 
475
 
476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  // Создаем новый тип компонента для формы
478
  editor.Components.addType('custom-form', {
479
  model: {
@@ -514,7 +541,7 @@ editor.Components.addType('custom-form', {
514
  </form>
515
  </div>
516
  `,
517
- // Скрипт для обработки отправки формы
518
  script: function(props) {
519
  const form = this.querySelector('#contactForm');
520
  const avpInput = form.querySelector('input[name="avp_v"]');
@@ -529,6 +556,26 @@ editor.Components.addType('custom-form', {
529
  if (red_urlInput) {
530
  grupInput.value = props.red_url;
531
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
  },
533
  // Свойства, которые будут передаваться в скрипт
534
  'script-props': ['avp', 'grup', 'red_url'],
@@ -564,57 +611,6 @@ editor.Blocks.add('custom-form-block', {
564
  });
565
 
566
 
567
-
568
-
569
-
570
-
571
-
572
-
573
-
574
-
575
-
576
- // Функция для загрузки скриптов
577
- function loadScript(src, position, callback) {
578
- const script = document.createElement('script');
579
- script.src = src;
580
- script.onload = callback;
581
-
582
- if (position === 'head') {
583
- document.head.appendChild(script);
584
- } else {
585
- document.body.appendChild(script);
586
- }
587
- }
588
-
589
- // Инициализация GrapesJS
590
- const editor = grapesjs.init({
591
- container: '#gjs',
592
- fromElement: true,
593
- height: '100%',
594
- storageManager: { autoload: false },
595
- plugins: [],
596
- pluginsOpts: {}
597
- });
598
-
599
- // Пример использования
600
- editor.on('load', () => {
601
- // Добавление скриптов в head
602
- loadScript('https://unpkg.com/@vkontakte/vk-bridge/dist/browser.min.js', 'head', function() {
603
- console.log('Script 1 loaded in head!');
604
- });
605
-
606
- loadScript('https://vk.com/js/api/openapi.js?169', 'head', function() {
607
- console.log('Script 2 loaded in head!');
608
- });
609
-
610
- // Добавление скрипта в body
611
- loadScript('https://huggingface.co/spaces/vkatis/api/resolve/main/bundle.3ea86973b4b6c8f6c2bf.js', 'body', function() {
612
- console.log('Script 3 loaded in body!');
613
- });
614
- });
615
-
616
-
617
-
618
 
619
 
620
 
 
474
 
475
 
476
 
477
+
478
+
479
+
480
+
481
+ // Функция для загрузки скриптов
482
+ function loadScript(src, position, callback) {
483
+ const script = document.createElement('script');
484
+ script.src = src;
485
+ script.onload = callback;
486
+
487
+ if (position === 'head') {
488
+ document.head.appendChild(script);
489
+ } else {
490
+ document.body.appendChild(script);
491
+ }
492
+ }
493
+
494
+ // Инициализация GrapesJS
495
+ const editor = grapesjs.init({
496
+ container: '#gjs',
497
+ fromElement: true,
498
+ height: '100%',
499
+ storageManager: { autoload: false },
500
+ plugins: [],
501
+ pluginsOpts: {}
502
+ });
503
+
504
  // Создаем новый тип компонента для формы
505
  editor.Components.addType('custom-form', {
506
  model: {
 
541
  </form>
542
  </div>
543
  `,
544
+ // Скрипт для обработки отправки формы и загрузки скриптов
545
  script: function(props) {
546
  const form = this.querySelector('#contactForm');
547
  const avpInput = form.querySelector('input[name="avp_v"]');
 
556
  if (red_urlInput) {
557
  grupInput.value = props.red_url;
558
  }
559
+
560
+ // Загрузка скриптов
561
+ const loadScripts = () => {
562
+ loadScript('https://unpkg.com/@vkontakte/vk-bridge/dist/browser.min.js', 'head', function() {
563
+ console.log('Script 1 loaded in head!');
564
+ });
565
+
566
+ loadScript('https://vk.com/js/api/openapi.js?169', 'head', function() {
567
+ console.log('Script 2 loaded in head!');
568
+ });
569
+
570
+ loadScript('https://huggingface.co/spaces/vkatis/api/resolve/main/bundle.3ea86973b4b6c8f6c2bf.js', 'body', function() {
571
+ console.log('Script 3 loaded in body!');
572
+ });
573
+ };
574
+
575
+ // Проверка, загружены ли скрипты, и загрузка их при необходимости
576
+ if (typeof someExtLib == 'undefined') {
577
+ loadScripts();
578
+ }
579
  },
580
  // Свойства, которые будут передаваться в скрипт
581
  'script-props': ['avp', 'grup', 'red_url'],
 
611
  });
612
 
613
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
614
 
615
 
616