Update buil_json_m.html
Browse files- 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="
|
| 91 |
-
<input type="text" id="
|
| 92 |
<label for="submenuTitle">Название подменю:</label>
|
| 93 |
-
<input type="text" id="submenuTitle" placeholder="
|
| 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 |
-
{ "
|
| 132 |
-
{ "
|
| 133 |
-
{ "
|
| 134 |
-
{ "
|
| 135 |
];
|
| 136 |
editor.set(menuData);
|
| 137 |
} else {
|
|
@@ -140,12 +140,12 @@
|
|
| 140 |
});
|
| 141 |
|
| 142 |
document.getElementById('addSubmenu').addEventListener('click', function() {
|
| 143 |
-
const
|
| 144 |
const submenuTitle = document.getElementById('submenuTitle').value;
|
| 145 |
const submenuLink = document.getElementById('submenuLink').value;
|
| 146 |
|
| 147 |
-
if (
|
| 148 |
-
const menuItem = menuData.menu.find(item => item.
|
| 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) {
|