--- /dev/null
+function form_submit_clean(form) {
+ form_clean(form);
+ form.submit();
+}
+
+function form_clean(form) {
+ var e;
+ for(i=0;i<form.length;i++) {
+ e = form.elements[i];
+ if (e.style.display == "none") continue;
+ if (e.type != "text") continue;
+ e.value = ""
+ }
+}
+
+function form_submit_clean(f) {
+ var i = 0;
+ var url = "";
+ var action = f.getAttribute("action");
+ var method = f.getAttribute("method");
+ if (method != "get") return true;
+
+ for(i=0;i<f.length;i++) {
+ var p = f[i];
+ if (!p.name) continue;
+ if (p.value=="") continue;
+ if (p.value=="undefined") continue;
+ url += (url ? "&" : "?") + encodeURI(p.name) + "=" + encodeURI(p.value);
+ }
+
+ url = (action == "?" ? "" : action) + url;
+
+ window.location = url;
+ return false;
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+
+ for (var e of document.querySelectorAll("form")) {
+ e.onsubmit = function() {
+ return form_submit_clean(this);
+ };
+ }
+ document.getElementById("table").removeAttribute("name");
+ document.getElementById("format").removeAttribute("name");
+
+ for (var e of document.querySelectorAll(".menu select.tables, .menu select.format, .menu select.limit")) {
+ e.onchange = function() {
+ var format = document.getElementById("format").value;
+ if (format == window._dbq["HTML_FORMAT"]) format = "html";
+ window.location = "./" + document.getElementById("table").value + "." + format;
+ return false;
+ };
+ }
+
+ for (var e of document.querySelectorAll(".menu select.limit")) {
+ e.onchange = function() {
+ this.form.submit();
+ return false;
+ };
+ }
+
+ if (document.querySelector(".nav.bottom")) {
+ document.querySelector("table.rows").insertAdjacentHTML("beforebegin","<div class=\"nav top\">"+document.querySelector(".nav.bottom").innerHTML+"</div>");
+ }
+
+});