PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/rel/overlay/share/www/database.html

http://github.com/cloudant/bigcouch
HTML | 267 lines | 241 code | 12 blank | 14 comment | 0 complexity | 7e71e8fb0ab1a09f8f0ab6b932a524f4 MD5 | raw file
Possible License(s): Apache-2.0
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed
  8. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  9. CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. specific language governing permissions and limitations under the License.
  11. -->
  12. <html lang="en">
  13. <head>
  14. <title>Browse Database</title>
  15. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  16. <link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css">
  17. <script src="script/json2.js"></script>
  18. <script src="script/sha1.js"></script>
  19. <script src="script/jquery.js?1.4.2"></script>
  20. <script src="script/jquery.couch.js?0.11.0"></script>
  21. <script src="script/jquery.dialog.js?0.11.0"></script>
  22. <script src="script/futon.js?0.11.0"></script>
  23. <script src="script/jquery.resizer.js?0.11.0"></script>
  24. <script src="script/jquery.suggest.js?0.11.0"></script>
  25. <script src="script/futon.browse.js?0.11.0"></script>
  26. <script src="script/futon.format.js?0.11.0"></script>
  27. <script>
  28. var page = new $.futon.CouchDatabasePage();
  29. $.futon.navigation.ready(function() {
  30. this.addDatabase(page.db.name);
  31. this.updateSelection(location.pathname, "?" + page.db.name);
  32. });
  33. $(function() {
  34. if (page.redirecting) return;
  35. $("h1 strong").text(page.db.name);
  36. var viewPath = page.viewName || "_all_docs";
  37. if (viewPath != "_temp_view" && viewPath != "_design_docs") {
  38. viewPath = $.map(viewPath.split("/"), function (part) {
  39. return encodeURIComponent(part);
  40. }).join("/");
  41. $("h1 a.raw").attr("href", "/" + encodeURIComponent(page.db.name) +
  42. "/" + viewPath);
  43. }
  44. $("#viewcode span").click(function() {
  45. $("#viewcode").toggleClass("collapsed");
  46. });
  47. $("#viewcode button.run").click(function() {
  48. page.updateDocumentListing();
  49. });
  50. $("#viewcode button.revert").click(function() {
  51. page.revertViewChanges();
  52. });
  53. $("#viewcode button.save").click(function() {
  54. page.saveViewChanges();
  55. });
  56. $("#viewcode button.saveas").click(function() {
  57. page.saveViewAs();
  58. });
  59. $("#viewcode textarea").makeResizable({
  60. always: true,
  61. grippie: $("#viewcode .bottom"),
  62. vertical: true
  63. });
  64. $("#viewcode td.map").makeResizable({
  65. always: true,
  66. grippie: $("#viewcode td.splitter"),
  67. horizontal: true
  68. });
  69. // Restore preferences/state
  70. $("#documents thead th.key").toggleClass("desc", !!$.futon.storage.get("desc"));
  71. var reduce = !!$.futon.storage.get("reduce");
  72. $("#reduce :checkbox")[0].checked = reduce;
  73. $("#grouplevel select").val(parseInt($.futon.storage.get("group_level")));
  74. $("#grouplevel").toggleClass("disabled", !reduce).find("select").each(function() {
  75. this.disabled = !reduce;
  76. });
  77. $("#perpage").val(parseInt($.futon.storage.get("per_page")));
  78. var staleViews = !!$.futon.storage.get("stale");
  79. $("#staleviews :checkbox")[0].checked = staleViews;
  80. page.populateViewsMenu();
  81. page.populateViewEditor();
  82. if (page.isTempView) {
  83. $("#viewcode").show().removeClass("collapsed").find("textarea")[0].focus();
  84. $("#documents").hide();
  85. }
  86. $("#switch select").change(function() {
  87. var viewName = $(this).val();
  88. if (!viewName) $.futon.storage.del("view");
  89. location.href = "?" + encodeURIComponent(page.db.name) +
  90. (viewName ? "/" + viewName : "");
  91. });
  92. $("#staleviews :checkbox").click(function() {
  93. $.futon.storage.set("stale", this.checked);
  94. });
  95. $("#documents thead th.key span").click(function() {
  96. $(this).closest("th").toggleClass("desc");
  97. page.updateDocumentListing();
  98. });
  99. $("#grouplevel select").change(function() {
  100. page.updateDocumentListing();
  101. $.futon.storage.set("group_level", this.value);
  102. });
  103. $("#reduce :checkbox").click(function() {
  104. page.updateDocumentListing();
  105. var cb = this;
  106. $("#grouplevel").toggleClass("disabled", !cb.checked).find("select").each(function() {
  107. this.disabled = !cb.checked;
  108. });
  109. $.futon.storage.set("reduce", this.checked);
  110. });
  111. $("#perpage").change(function() {
  112. page.updateDocumentListing();
  113. $.futon.storage.set("per_page", this.value);
  114. });
  115. $("#toolbar button.add").click(page.newDocument);
  116. $("#toolbar button.compact").click(page.compactAndCleanup);
  117. $("#toolbar button.delete").click(page.deleteDatabase);
  118. $("#toolbar button.security").click(page.databaseSecurity);
  119. $('#jumpto input').suggest(function(text, callback) {
  120. page.db.allDocs({
  121. limit: 10, startkey: text, endkey: text + 'zzz',
  122. success: function(docs) {
  123. var matches = [];
  124. for (var i = 0; i < docs.rows.length; i++) {
  125. if (docs.rows[i].id.indexOf(text) == 0) {
  126. matches[i] = docs.rows[i].id;
  127. }
  128. }
  129. callback(matches);
  130. }
  131. });
  132. }).keypress(function(e) {
  133. if (e.keyCode == 13) {
  134. page.jumpToDocument($(this).val());
  135. }
  136. });
  137. });
  138. </script>
  139. </head>
  140. <body><div id="wrap">
  141. <h1>
  142. <a href="index.html">Overview</a>
  143. <strong>?</strong>
  144. <a class="raw" title="Raw view"></a>
  145. </h1>
  146. <div id="content">
  147. <div id="staleviews">
  148. <label>Stale views
  149. <input name="staleviews" type="checkbox" />
  150. </label>
  151. </div>
  152. <div id="switch">
  153. <label>View: <select autocomplete="false">
  154. <option value="_all_docs">All documents</option>
  155. <option value="_design_docs">Design documents</option>
  156. <option value="_temp_view">Temporary view</option>
  157. </select></label>
  158. </div>
  159. <div id="jumpto">
  160. <label>Jump to:
  161. <input type="text" name="docid" placeholder="Document ID" autocomplete="off" />
  162. </label>
  163. </div>
  164. <ul id="toolbar">
  165. <li><button class="add">New Document</button></li>
  166. <li><button class="security">Security</button></li>
  167. <li><button class="compact">Compact &amp; Cleanup</button></li>
  168. <li><button class="delete">Delete Database</button></li>
  169. </ul>
  170. <div id="viewcode" class="collapsed" style="display: none">
  171. <div class="top">
  172. <a id="designdoc-link"></a>
  173. <span id="view-toggle">View Code</span>
  174. </div>
  175. <table summary="View functions" cellspacing="0"><tr>
  176. <td class="code map">
  177. <label for="viewcode_map">Map Function:</label>
  178. <textarea id="viewcode_map" class="map" rows="5" cols="20" spellcheck="false" wrap="off"></textarea>
  179. </td>
  180. <td class="splitter"></td>
  181. <td class="code reduce">
  182. <label for="viewcode_reduce">Reduce Function (optional):</label>
  183. <textarea id="viewcode_reduce" class="reduce" rows="5" cols="20" spellcheck="false" wrap="off"></textarea>
  184. </td>
  185. </tr></table>
  186. <div class="bottom">
  187. <button class="save" type="button" disabled>Save</button>
  188. <button class="saveas" type="button">Save As</button>
  189. <button class="revert" type="button" disabled>Revert</button>
  190. <button class="run" type="button">Run</button>
  191. <label>Language: <select id="language"></select></label>
  192. </div>
  193. </div>
  194. <p id="tempwarn">
  195. <strong>Warning</strong>: Please note that temporary views are not
  196. suitable for use in production, as they are really slow for any
  197. database with more than a few dozen documents. You can use a temporary
  198. view to experiment with view functions, but switch to a permanent view
  199. before using them in an application.
  200. </p>
  201. <table id="documents" class="listing" cellspacing="0">
  202. <caption>Documents</caption>
  203. <thead>
  204. <tr>
  205. <th class="key">
  206. <label id="grouplevel">
  207. Grouping: <select>
  208. <option value="0">none</option>
  209. <option value="1">level 1</option>
  210. <option value="2">level 2</option>
  211. <option value="3">level 3</option>
  212. <option value="4">level 4</option>
  213. <option value="5">level 5</option>
  214. <option value="6">level 6</option>
  215. <option value="7">level 7</option>
  216. <option value="8">level 8</option>
  217. <option value="9">level 9</option>
  218. <option value="100" selected>exact</option>
  219. </select>
  220. </label>
  221. <span>Key</span>
  222. </th>
  223. <th class="value">
  224. <label id="reduce"><input type="checkbox" autocomplete="off" checked> Reduce</label>
  225. Value
  226. </th>
  227. </tr>
  228. </thead>
  229. <tbody class="content">
  230. </tbody>
  231. <tbody class="footer">
  232. <tr>
  233. <td colspan="4">
  234. <div id="paging">
  235. <a class="prev"> Previous Page</a> |
  236. <label>Rows per page: <select id="perpage">
  237. <option selected>10</option>
  238. <option>25</option>
  239. <option>50</option>
  240. <option>100</option>
  241. </select></label> |
  242. <a class="next">Next Page </a>
  243. </div>
  244. <span></span>
  245. </td>
  246. </tr>
  247. </tbody>
  248. </table>
  249. </div>
  250. </div></body>
  251. </html>