DmitrMakeev
commited on
Update buil_json_m.html
Browse files- buil_json_m.html +47 -0
buil_json_m.html
CHANGED
@@ -85,6 +85,20 @@
|
|
85 |
</div>
|
86 |
<button id="addMenu">Добавить меню</button>
|
87 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
<div id="jsoneditor"></div>
|
89 |
|
90 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.js"></script>
|
@@ -103,6 +117,7 @@
|
|
103 |
"menu": []
|
104 |
};
|
105 |
editor.set(menuData);
|
|
|
106 |
document.getElementById('addMenu').addEventListener('click', function() {
|
107 |
const title1 = document.getElementById('title1').value;
|
108 |
const link1 = document.getElementById('link1').value;
|
@@ -110,6 +125,7 @@
|
|
110 |
const link2 = document.getElementById('link2').value;
|
111 |
const title3 = document.getElementById('title3').value;
|
112 |
const title4 = document.getElementById('title4').value;
|
|
|
113 |
if (title1 && link1 && title2 && link2 && title3 && title4) {
|
114 |
menuData.menu = [
|
115 |
{ "title": title1, "link": link1 },
|
@@ -122,6 +138,37 @@
|
|
122 |
alert('Please fill in all menu fields.');
|
123 |
}
|
124 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
});
|
126 |
</script>
|
127 |
</body>
|
|
|
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>
|
97 |
+
<button id="addSubmenu">Добавить подменю</button>
|
98 |
+
</div>
|
99 |
+
<div>
|
100 |
+
<button id="saveToClipboard">Сохранить в буфер обмена</button>
|
101 |
+
</div>
|
102 |
<div id="jsoneditor"></div>
|
103 |
|
104 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.js"></script>
|
|
|
117 |
"menu": []
|
118 |
};
|
119 |
editor.set(menuData);
|
120 |
+
|
121 |
document.getElementById('addMenu').addEventListener('click', function() {
|
122 |
const title1 = document.getElementById('title1').value;
|
123 |
const link1 = document.getElementById('link1').value;
|
|
|
125 |
const link2 = document.getElementById('link2').value;
|
126 |
const title3 = document.getElementById('title3').value;
|
127 |
const title4 = document.getElementById('title4').value;
|
128 |
+
|
129 |
if (title1 && link1 && title2 && link2 && title3 && title4) {
|
130 |
menuData.menu = [
|
131 |
{ "title": title1, "link": link1 },
|
|
|
138 |
alert('Please fill in all menu fields.');
|
139 |
}
|
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 = [];
|
152 |
+
}
|
153 |
+
menuItem.submenu.push({ "title": submenuTitle, "link": submenuLink });
|
154 |
+
editor.set(menuData);
|
155 |
+
} else {
|
156 |
+
alert('Menu item not found.');
|
157 |
+
}
|
158 |
+
} else {
|
159 |
+
alert('Please fill in all submenu fields.');
|
160 |
+
}
|
161 |
+
});
|
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) {
|
169 |
+
console.error('Could not copy text: ', err);
|
170 |
+
});
|
171 |
+
});
|
172 |
});
|
173 |
</script>
|
174 |
</body>
|