Create buil_json_m.html
Browse files- buil_json_m.html +128 -0
buil_json_m.html
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Menu JSON Editor</title>
|
7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.css" />
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: Arial, sans-serif;
|
11 |
+
text-align: center;
|
12 |
+
background-color: #f0f0f0;
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
}
|
16 |
+
h1 {
|
17 |
+
background-color: #4CAF50;
|
18 |
+
color: white;
|
19 |
+
padding: 20px;
|
20 |
+
margin: 0;
|
21 |
+
border-bottom: 2px solid #388E3C;
|
22 |
+
}
|
23 |
+
.input-row {
|
24 |
+
display: flex;
|
25 |
+
justify-content: center;
|
26 |
+
gap: 10px;
|
27 |
+
margin-top: 20px;
|
28 |
+
}
|
29 |
+
.input-row input {
|
30 |
+
padding: 10px;
|
31 |
+
font-size: 16px;
|
32 |
+
border: 1px solid #ccc;
|
33 |
+
border-radius: 5px;
|
34 |
+
}
|
35 |
+
#jsoneditor {
|
36 |
+
width: 50%;
|
37 |
+
height: 300px;
|
38 |
+
margin: 20px auto;
|
39 |
+
}
|
40 |
+
button {
|
41 |
+
color: white;
|
42 |
+
background-color: #4CAF50;
|
43 |
+
border: none;
|
44 |
+
cursor: pointer;
|
45 |
+
padding: 10px 20px;
|
46 |
+
font-size: 16px;
|
47 |
+
border-radius: 5px;
|
48 |
+
margin-top: 20px;
|
49 |
+
}
|
50 |
+
button:hover {
|
51 |
+
background-color: #388E3C;
|
52 |
+
}
|
53 |
+
.jsoneditor-menu {
|
54 |
+
background-color: #4CAF50 !important;
|
55 |
+
border-bottom: 1px solid #388E3C !important;
|
56 |
+
}
|
57 |
+
.jsoneditor {
|
58 |
+
border: 1px #4CAF50 !important;
|
59 |
+
border-bottom: 2px solid #388E3C !important;
|
60 |
+
}
|
61 |
+
</style>
|
62 |
+
</head>
|
63 |
+
<body>
|
64 |
+
<h1>Редактор JSON для меню</h1>
|
65 |
+
<div>
|
66 |
+
<div class="input-row">
|
67 |
+
<label for="title1">Название 1:</label>
|
68 |
+
<input type="text" id="title1" placeholder="Главная">
|
69 |
+
<label for="link1">Ссылка 1:</label>
|
70 |
+
<input type="text" id="link1" placeholder="https://example.com">
|
71 |
+
</div>
|
72 |
+
<div class="input-row">
|
73 |
+
<label for="title2">Название 2:</label>
|
74 |
+
<input type="text" id="title2" placeholder="Контакты">
|
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 |
+
</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 id="jsoneditor"></div>
|
89 |
+
|
90 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.js"></script>
|
91 |
+
<script>
|
92 |
+
document.addEventListener('DOMContentLoaded', function() {
|
93 |
+
const container = document.getElementById('jsoneditor');
|
94 |
+
const options = {
|
95 |
+
mode: 'code',
|
96 |
+
modes: ['code', 'tree'],
|
97 |
+
onError: function(err) {
|
98 |
+
alert(err.toString());
|
99 |
+
}
|
100 |
+
};
|
101 |
+
const editor = new JSONEditor(container, options);
|
102 |
+
let menuData = {
|
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;
|
109 |
+
const title2 = document.getElementById('title2').value;
|
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 },
|
116 |
+
{ "title": title2, "link": link2 },
|
117 |
+
{ "title": title3, "link": "#link" },
|
118 |
+
{ "title": title4, "link": "#link" }
|
119 |
+
];
|
120 |
+
editor.set(menuData);
|
121 |
+
} else {
|
122 |
+
alert('Please fill in all menu fields.');
|
123 |
+
}
|
124 |
+
});
|
125 |
+
});
|
126 |
+
</script>
|
127 |
+
</body>
|
128 |
+
</html>
|