Create buol_json.html
Browse files- buol_json.html +71 -0
buol_json.html
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Video List Editor</title>
|
7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.css" />
|
8 |
+
<style>
|
9 |
+
#jsoneditor {
|
10 |
+
width: 100%;
|
11 |
+
height: 400px;
|
12 |
+
}
|
13 |
+
</style>
|
14 |
+
</head>
|
15 |
+
<body>
|
16 |
+
<h1>Video List Editor</h1>
|
17 |
+
<div>
|
18 |
+
<label for="title">Title:</label>
|
19 |
+
<input type="text" id="title" placeholder="Enter video title">
|
20 |
+
<label for="file">File URL:</label>
|
21 |
+
<input type="text" id="file" placeholder="Enter video file URL">
|
22 |
+
<button id="addVideo">Add Video</button>
|
23 |
+
<button id="saveToClipboard">Save to Clipboard</button>
|
24 |
+
</div>
|
25 |
+
<div id="jsoneditor"></div>
|
26 |
+
|
27 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.js"></script>
|
28 |
+
<script>
|
29 |
+
|
30 |
+
document.addEventListener('DOMContentLoaded', function() {
|
31 |
+
const container = document.getElementById('jsoneditor');
|
32 |
+
const options = {
|
33 |
+
mode: 'code',
|
34 |
+
modes: ['code', 'tree'],
|
35 |
+
onError: function(err) {
|
36 |
+
alert(err.toString());
|
37 |
+
}
|
38 |
+
};
|
39 |
+
const editor = new JSONEditor(container, options);
|
40 |
+
|
41 |
+
let videoList = [];
|
42 |
+
editor.set(videoList);
|
43 |
+
|
44 |
+
document.getElementById('addVideo').addEventListener('click', function() {
|
45 |
+
const title = document.getElementById('title').value;
|
46 |
+
const file = document.getElementById('file').value;
|
47 |
+
if (title && file) {
|
48 |
+
videoList.push({ title, file });
|
49 |
+
editor.set(videoList);
|
50 |
+
document.getElementById('title').value = '';
|
51 |
+
document.getElementById('file').value = '';
|
52 |
+
} else {
|
53 |
+
alert('Please fill in both title and file URL.');
|
54 |
+
}
|
55 |
+
});
|
56 |
+
|
57 |
+
document.getElementById('saveToClipboard').addEventListener('click', function() {
|
58 |
+
const json = editor.get();
|
59 |
+
const jsonString = JSON.stringify(json, null, 2);
|
60 |
+
navigator.clipboard.writeText(jsonString).then(function() {
|
61 |
+
alert('JSON saved to clipboard!');
|
62 |
+
}, function(err) {
|
63 |
+
console.error('Could not copy text: ', err);
|
64 |
+
});
|
65 |
+
});
|
66 |
+
});
|
67 |
+
|
68 |
+
|
69 |
+
</script>
|
70 |
+
</body>
|
71 |
+
</html>
|