forked from josdejong/jsoneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
couchdbeditor.html
100 lines (86 loc) · 2.4 KB
/
couchdbeditor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE HTML>
<html>
<head>
<title>CouchDB Document Editor</title>
<meta name="description" content="CouchDB Document Editor">
<meta name="keywords" content="json, editor, couchdb, online, javascript, javascript object notation, treeview, open source, free">
<meta name="author" content="Jos de Jong">
<link rel="shortcut icon" href="../app/web/favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="../jsoneditor/js/jsoneditor.js"></script>
<link rel="stylesheet" type="text/css" href="../jsoneditor/css/jsoneditor.css">
<style type="text/css">
body, html {
font-family: arial, verdana;
font-size: 11pt;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
h1 {
color: gray;
}
input[type=text] {
border: 1px solid gray;
}
</style>
<script>
var editor = null;
function init() {
var container = document.getElementById('jsoneditor');
editor = new JSONEditor(container);
document.getElementById('url').focus();
}
function load() {
var url = document.getElementById("url").value;
$.ajax({
'type': 'GET',
'url': url,
'dataType': 'json',
'success': function (doc) {
editor.set(doc);
}
});
}
function save() {
var doc = editor.get();
var url = document.getElementById("url").value;
$.ajax({
'type': 'PUT',
'url': url,
'data': JSON.stringify(doc),
'success': function (response) {
load();
}
});
}
</script>
</head>
<body onload="init();">
<table align="center" width="790px" height="100%">
<tr>
<td style="height: 50px;"><h1>CouchDB Document Editor</h1></td>
</tr>
<tr>
<td style="height: 30px;">
<table width="100%">
<col width="100px"></col>
<col ></col>
<col width="50px"></col>
<col width="50px"></col>
<tr>
<td>Document Url:</td>
<td><input type="text" id="url" style="width: 100%;" value="http://localhost:5984/test/jos"></td>
<td><input type="button" value="Load" onclick="load();" /></td>
<td><input type="button" value="Save" onclick="save();" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="jsoneditor"></td>
</tr>
</table>
</body>
</html>