DmitrMakeev commited on
Commit
8a3698d
·
verified ·
1 Parent(s): e2b526a

Update buil_json_m.html

Browse files
Files changed (1) hide show
  1. buil_json_m.html +13 -13
buil_json_m.html CHANGED
@@ -77,20 +77,20 @@
77
  </div>
78
  <div class="input-row">
79
  <label for="title3">Название 3:</label>
80
- <input type="text" id="title3" placeholder="Уроки курса">
81
  </div>
82
  <div class="input-row">
83
  <label for="title4">Название 4:</label>
84
- <input type="text" id="title4" placeholder="Доп. материалы курса">
85
  </div>
86
  <button id="addMenu">Добавить меню</button>
87
  </div>
88
  <div>
89
  <div class="input-row">
90
- <label for="menuId">ID меню:</label>
91
- <input type="text" id="menuId" placeholder="id_уроки_курса">
92
  <label for="submenuTitle">Название подменю:</label>
93
- <input type="text" id="submenuTitle" placeholder="Урок_1">
94
  <label for="submenuLink">Ссылка подменю:</label>
95
  <input type="text" id="submenuLink" placeholder="https://example.com">
96
  </div>
@@ -128,10 +128,10 @@
128
 
129
  if (title1 && link1 && title2 && link2 && title3 && title4) {
130
  menuData.menu = [
131
- { "id": "id_главная", "title": title1, "link": link1 },
132
- { "id": "id_уроки_курса", "title": title3, "link": "#link" },
133
- { "id": "id_доп_материалы_курса", "title": title4, "link": "#link" },
134
- { "id": "id_контакты", "title": title2, "link": link2 }
135
  ];
136
  editor.set(menuData);
137
  } else {
@@ -140,12 +140,12 @@
140
  });
141
 
142
  document.getElementById('addSubmenu').addEventListener('click', function() {
143
- const menuId = document.getElementById('menuId').value;
144
  const submenuTitle = document.getElementById('submenuTitle').value;
145
  const submenuLink = document.getElementById('submenuLink').value;
146
 
147
- if (menuId && submenuTitle && submenuLink) {
148
- const menuItem = menuData.menu.find(item => item.id === menuId);
149
  if (menuItem) {
150
  if (!menuItem.submenu) {
151
  menuItem.submenu = [];
@@ -162,7 +162,7 @@
162
 
163
  document.getElementById('saveToClipboard').addEventListener('click', function() {
164
  const json = editor.get();
165
- const jsonString = JSON.stringify(json); // Убираем параметры отступов
166
  navigator.clipboard.writeText(jsonString).then(function() {
167
  alert('JSON saved to clipboard!');
168
  }, function(err) {
 
77
  </div>
78
  <div class="input-row">
79
  <label for="title3">Название 3:</label>
80
+ <input type="text" id="title3" placeholder="Мега-меню">
81
  </div>
82
  <div class="input-row">
83
  <label for="title4">Название 4:</label>
84
+ <input type="text" id="title4" placeholder="Подменю">
85
  </div>
86
  <button id="addMenu">Добавить меню</button>
87
  </div>
88
  <div>
89
  <div class="input-row">
90
+ <label for="menuTitle">Название меню:</label>
91
+ <input type="text" id="menuTitle" placeholder="Мега-меню">
92
  <label for="submenuTitle">Название подменю:</label>
93
+ <input type="text" id="submenuTitle" placeholder="Раздел 1">
94
  <label for="submenuLink">Ссылка подменю:</label>
95
  <input type="text" id="submenuLink" placeholder="https://example.com">
96
  </div>
 
128
 
129
  if (title1 && link1 && title2 && link2 && title3 && title4) {
130
  menuData.menu = [
131
+ { "title": title1, "link": link1 },
132
+ { "title": title3, "link": "#link" },
133
+ { "title": title4, "link": "#link" },
134
+ { "title": title2, "link": link2 }
135
  ];
136
  editor.set(menuData);
137
  } else {
 
140
  });
141
 
142
  document.getElementById('addSubmenu').addEventListener('click', function() {
143
+ const menuTitle = document.getElementById('menuTitle').value;
144
  const submenuTitle = document.getElementById('submenuTitle').value;
145
  const submenuLink = document.getElementById('submenuLink').value;
146
 
147
+ if (menuTitle && submenuTitle && submenuLink) {
148
+ const menuItem = menuData.menu.find(item => item.title === menuTitle);
149
  if (menuItem) {
150
  if (!menuItem.submenu) {
151
  menuItem.submenu = [];
 
162
 
163
  document.getElementById('saveToClipboard').addEventListener('click', function() {
164
  const json = editor.get();
165
+ const jsonString = JSON.stringify(json, null, 2);
166
  navigator.clipboard.writeText(jsonString).then(function() {
167
  alert('JSON saved to clipboard!');
168
  }, function(err) {