DmitrMakeev
commited on
Update buil_json.html
Browse files- buil_json.html +23 -44
buil_json.html
CHANGED
@@ -75,19 +75,19 @@
|
|
75 |
<label for="link2">Ссылка 2:</label>
|
76 |
<input type="text" id="link2" placeholder="https://example.com">
|
77 |
</div>
|
78 |
-
<button id="addMenu">Добавить меню</button>
|
79 |
-
</div>
|
80 |
-
<div>
|
81 |
<div class="input-row">
|
82 |
-
<label for="
|
83 |
-
<input type="text" id="
|
84 |
-
<label for="
|
85 |
-
<input type="text" id="
|
86 |
</div>
|
87 |
-
<
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
91 |
</div>
|
92 |
<div id="jsoneditor"></div>
|
93 |
|
@@ -113,44 +113,23 @@
|
|
113 |
const link1 = document.getElementById('link1').value;
|
114 |
const title2 = document.getElementById('title2').value;
|
115 |
const link2 = document.getElementById('link2').value;
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
document.getElementById('title1').value = '';
|
121 |
-
document.getElementById('link1').value = '';
|
122 |
-
document.getElementById('title2').value = '';
|
123 |
-
document.getElementById('link2').value = '';
|
124 |
-
} else {
|
125 |
-
alert('Please fill in all menu fields.');
|
126 |
-
}
|
127 |
-
});
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
menuData.menu[1].submenu.push({ "title": submenuTitle, "link": submenuLink });
|
137 |
editor.set(menuData);
|
138 |
-
document.getElementById('submenuTitle').value = '';
|
139 |
-
document.getElementById('submenuLink').value = '';
|
140 |
} else {
|
141 |
-
alert('Please fill in
|
142 |
}
|
143 |
});
|
144 |
-
|
145 |
-
document.getElementById('saveToClipboard').addEventListener('click', function() {
|
146 |
-
const json = editor.get();
|
147 |
-
const jsonString = JSON.stringify(json, null, 2);
|
148 |
-
navigator.clipboard.writeText(jsonString).then(function() {
|
149 |
-
alert('JSON saved to clipboard!');
|
150 |
-
}, function(err) {
|
151 |
-
console.error('Could not copy text: ', err);
|
152 |
-
});
|
153 |
-
});
|
154 |
});
|
155 |
</script>
|
156 |
</body>
|
|
|
75 |
<label for="link2">Ссылка 2:</label>
|
76 |
<input type="text" id="link2" placeholder="https://example.com">
|
77 |
</div>
|
|
|
|
|
|
|
78 |
<div class="input-row">
|
79 |
+
<label for="title3">Название 3:</label>
|
80 |
+
<input type="text" id="title3" placeholder="Мега-меню">
|
81 |
+
<label for="link3">Ссылка 3:</label>
|
82 |
+
<input type="text" id="link3" placeholder="#link">
|
83 |
</div>
|
84 |
+
<div class="input-row">
|
85 |
+
<label for="title4">Название 4:</label>
|
86 |
+
<input type="text" id="title4" placeholder="Подменю">
|
87 |
+
<label for="link4">Ссылка 4:</label>
|
88 |
+
<input type="text" id="link4" placeholder="#link">
|
89 |
+
</div>
|
90 |
+
<button id="addMenu">Добавить меню</button>
|
91 |
</div>
|
92 |
<div id="jsoneditor"></div>
|
93 |
|
|
|
113 |
const link1 = document.getElementById('link1').value;
|
114 |
const title2 = document.getElementById('title2').value;
|
115 |
const link2 = document.getElementById('link2').value;
|
116 |
+
const title3 = document.getElementById('title3').value;
|
117 |
+
const link3 = document.getElementById('link3').value;
|
118 |
+
const title4 = document.getElementById('title4').value;
|
119 |
+
const link4 = document.getElementById('link4').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
if (title1 && link1 && title2 && link2 && title3 && link3 && title4 && link4) {
|
122 |
+
menuData.menu = [
|
123 |
+
{ "title": title1, "link": link1 },
|
124 |
+
{ "title": title2, "link": link2 },
|
125 |
+
{ "title": title3, "link": link3 },
|
126 |
+
{ "title": title4, "link": link4 }
|
127 |
+
];
|
|
|
128 |
editor.set(menuData);
|
|
|
|
|
129 |
} else {
|
130 |
+
alert('Please fill in all menu fields.');
|
131 |
}
|
132 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
});
|
134 |
</script>
|
135 |
</body>
|