summaryrefslogtreecommitdiff
path: root/share/www/database.html
blob: c540972f67d65b8c662cba1d3ffeea7727cff1a9 (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<!--

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License.  You may obtain a copy of the
License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.  See the License for the
specific language governing permissions and limitations under the License.

-->
<html lang="en">
  <head>
    <title>Browse Database</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <link rel="stylesheet" href="style/layout.css?0.9.0" type="text/css">
    <script src="script/json2.js"></script>
    <script src="script/jquery.js?1.2.6"></script>
    <script src="script/jquery.cookies.js?0.9.0"></script>
    <script src="script/jquery.couch.js?0.9.0"></script>
    <script src="script/jquery.dialog.js?0.9.0"></script>
    <script src="script/jquery.resizer.js?0.9.0"></script>
    <script src="script/jquery.suggest.js?0.9.0"></script>
    <script src="script/futon.js?0.9.0"></script>
    <script src="script/futon.browse.js?0.9.0"></script>
    <script src="script/futon.format.js?0.9.0"></script>
    <script>
      var page = new $.futon.CouchDatabasePage();

      $.futon.navigation.ready(function() {
        this.addDatabase(page.db.name);
        this.updateSelection(location.pathname, "?" + page.db.name);
      });

      $(function() {
        $("h1 strong").text(page.db.name);
        $("#viewcode span").click(function() {
          $("#viewcode").toggleClass("collapsed");
        });
        $("#viewcode button.run").click(function() {
          page.updateDocumentListing();
        });
        $("#viewcode button.revert").click(function() {
          page.revertViewChanges();
        });
        $("#viewcode button.save").click(function() {
          page.saveViewChanges();
        });
        $("#viewcode button.saveas").click(function() {
          page.saveViewAs();
        });
        $("#viewcode textarea").makeResizable({
          always: true,
          grippie: $("#viewcode .bottom"),
          vertical: true
        });
        $("#viewcode td.map").makeResizable({
          always: true,
          grippie: $("#viewcode td.splitter"),
          horizontal: true
        });

        // Restore preferences/state from cookies
        var query = $.cookies.get(page.db.name + ".query");
        if (query) $("#viewcode_map").val(query);
        var desc = $.cookies.get(page.db.name + ".desc");
        if (desc) $("#documents thead th.key").addClass("desc");
        var rowsPerPage = $.cookies.get(page.db.name + ".perpage");
        if (rowsPerPage) $("#perpage").val(rowsPerPage);

        page.populateViewsMenu();
        page.populateViewEditor();
        if (!page.isTempView) {
          page.updateDocumentListing();
        } else {
          $("#viewcode").show().removeClass("collapsed").find("textarea")[0].focus();
          $("#documents").hide();
        }

        $("#switch select").change(function() {
          var viewName = $(this).val();
          if (!viewName) $.cookies.remove(page.db.name + ".view");
          location.href = "?" + encodeURIComponent(page.db.name) +
            (viewName ? "/" + encodeURIComponent(viewName)  : "");
        });
        $("#documents thead th.key").click(function() {
          $(this).toggleClass("desc");
          page.updateDocumentListing();
        });
        $("#perpage").change(function() {
          page.updateDocumentListing();
          $.cookies.set(page.db.name + ".perpage", this.value);
        });
        $("#toolbar button.add").click(page.addDocument);
        $("#toolbar button.compact").click(page.compactDatabase);
        $("#toolbar button.delete").click(page.deleteDatabase);
      });
    </script>
  </head>

  <body><div id="wrap">
    <h1>
      <a href="index.html">Overview</a>
      <strong>?</strong>
    </h1>
    <div id="content">
      <div id="switch">
        <label>Select view: <select autocomplete="false">
          <option value="_all_docs">All documents</option>
          <option value="_design_docs">Design documents</option>
          <option value="_slow_view">Custom query…</option>
        </select></label>
      </div>
      <ul id="toolbar">
        <li><button class="add">Create Document …</button></li>
        <li><button class="compact">Compact Database</button></li>
        <li><button class="delete">Delete Database</button></li>
      </ul>

      <div id="viewcode" class="collapsed" style="display: none">
        <div class="top">
          <a id="designdoc-link"></a>
          <span id="view-toggle">View Code</span>
        </div>
        <table summary="View functions" cellspacing="0"><tr>
          <td class="code map">
            <label for="viewcode_map">Map Function:</label>
            <textarea id="viewcode_map" class="map" rows="5" cols="20" spellcheck="false" wrap="off">function(doc) {
  emit(null, doc);
}</textarea>
          </td>
          <td class="splitter"></td>
          <td class="code reduce">
            <label for="viewcode_reduce">Reduce Function (optional):</label>
            <textarea id="viewcode_reduce" class="reduce" rows="5" cols="20" spellcheck="false" wrap="off"></textarea>
          </td>
        </tr></table>
        <div class="bottom">
          <button class="save" type="button" disabled>Save</button>
          <button class="saveas" type="button">Save As…</button>
          <button class="revert" type="button" disabled>Revert</button>
          <button class="run" type="button">Run</button>
        </div>
      </div>

      <table id="documents" class="listing" cellspacing="0">
        <caption>Documents</caption>
        <thead>
          <tr>
            <th class="key"><div>Key</div></th>
            <th class="value">Value</th>
          </tr>
        </thead>
        <tbody class="content">
        </tbody>
        <tbody class="footer">
          <tr>
            <td colspan="4">
              <div id="paging">
                <a class="prev">← Previous Page</a> |
                <label>Rows per page: <select id="perpage">
                  <option selected>10</option>
                  <option>25</option>
                  <option>50</option>
                  <option>100</option>
                </select></label> |
                <a class="next">Next Page →</a>
              </div>
              <span></span>
            </td>
          </tr>
        </tbody>
      </table>

    </div>
  </div></body>
</html>