Skip to content

Business intelligence made simple

Removed jQuery from checks page [skip ci]

Andrew Kaneb4c6701e166d
diff --git a/app/assets/javascripts/blazer/application.js b/app/assets/javascripts/blazer/application.js
index aa01779c..895a6175 100644
--- a/app/assets/javascripts/blazer/application.js
+++ b/app/assets/javascripts/blazer/application.js
@@ -81,3 +81,10 @@ function preventBackspaceNav() {
preventBackspaceNav()
+function toggle(element, found) {
+ if (found) {
+ element.classList.remove("hide")
+ } else {
+ element.classList.add("hide")
+ }
+}
diff --git a/app/views/blazer/checks/index.html.erb b/app/views/blazer/checks/index.html.erb
index 557bba38..662abe7e 100644
--- a/app/views/blazer/checks/index.html.erb
+++ b/app/views/blazer/checks/index.html.erb
@@ -20,7 +20,7 @@
</div>
</div>
- <input id="search" type="text" placeholder="Start typing a query or state" style="width: 300px; display: inline-block;" class="search form-control" />
+ <input id="search" type="text" placeholder="Start typing a query or state" style="width: 300px; display: inline-block;" class="search form-control" autofocus />
</div>
<table id="checks" class="table">
@@ -60,10 +60,12 @@
</table>
<%= javascript_tag nonce: true do %>
- $("#search").on("keyup", function() {
- var value = $(this).val().toLowerCase()
- $("#checks tbody tr").filter( function() {
- $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
- })
- }).focus()
+ document.getElementById("search").addEventListener("input", function() {
+ var value = this.value.toLowerCase()
+ var checks = document.querySelectorAll("#checks tbody tr")
+ for (var i = 0; i < checks.length; i++) {
+ var check = checks[i]
+ toggle(check, check.textContent.toLowerCase().indexOf(value) > -1)
+ }
+ })
<% end %>
diff --git a/app/views/blazer/queries/schema.html.erb b/app/views/blazer/queries/schema.html.erb
index baaafccc..cc4988e4 100644
--- a/app/views/blazer/queries/schema.html.erb
+++ b/app/views/blazer/queries/schema.html.erb
@@ -29,14 +29,6 @@
<% end %>
<%= javascript_tag nonce: true do %>
- function toggle(element, found) {
- if (found) {
- element.classList.remove("hide")
- } else {
- element.classList.add("hide")
- }
- }
-
document.getElementById("search").addEventListener("input", function() {
var value = this.value
var schemaTables = document.querySelectorAll(".schema-table")