diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 000000000..13566b81b
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/coffee-project.iml b/.idea/coffee-project.iml
new file mode 100644
index 000000000..d6ebd4805
--- /dev/null
+++ b/.idea/coffee-project.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 000000000..639900d13
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 000000000..f1ac7fff6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 000000000..35eb1ddfb
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/index.html b/index.html
index 0d5208117..8b8158f9c 100644
--- a/index.html
+++ b/index.html
@@ -1,34 +1,64 @@
-
+
+
+
+
+
- Coffee!
+
+
Coffee!
+
+
+
+
+
-
diff --git a/main.js b/main.js
index 043b24824..2c72fa8da 100644
--- a/main.js
+++ b/main.js
@@ -1,18 +1,17 @@
"use strict"
function renderCoffee(coffee) {
- var html = '';
- html += '| ' + coffee.id + ' | ';
- html += '' + coffee.name + ' | ';
- html += '' + coffee.roast + ' | ';
+ let html = '
';
+ html += `| ${coffee.id} | `;
+ html += `${coffee.name} | `;
+ html += `${coffee.roast} | `;
html += '
';
-
return html;
}
function renderCoffees(coffees) {
- var html = '';
- for(var i = coffees.length - 1; i >= 0; i--) {
+ let html = '';
+ for (let i = coffees.length - 1; i >= 0; i--) {
html += renderCoffee(coffees[i]);
}
return html;
@@ -20,18 +19,32 @@ function renderCoffees(coffees) {
function updateCoffees(e) {
e.preventDefault(); // don't submit the form, we just want to update the data
- var selectedRoast = roastSelection.value;
- var filteredCoffees = [];
- coffees.forEach(function(coffee) {
+ const selectedRoast = roastSelection.value;
+ const filteredCoffees = [];
+ coffees.forEach(coffee => {
if (coffee.roast === selectedRoast) {
filteredCoffees.push(coffee);
+ } else if (selectedRoast === 'all') {
+ filteredCoffees.push(coffee);
}
});
tbody.innerHTML = renderCoffees(filteredCoffees);
}
+function updateSearchCoffees(e) {
+ e.preventDefault(); // don't submit the form, we just want to update the data
+ var updateSearchCoffee = document.getElementById('search-text').value.toLowerCase()
+ var updateSearchCoffees = [];
+ coffees.forEach(function (searchInput) {
+ if (searchInput.name.toLowerCase().includes(updateSearchCoffee)) {
+ updateSearchCoffees.push(searchInput);
+ }
+ });
+ tbody.innerHTML = renderCoffees(updateSearchCoffees);
+}
+
// from http://www.ncausa.org/About-Coffee/Coffee-Roasts-Guide
-var coffees = [
+const coffees = [
{id: 1, name: 'Light City', roast: 'light'},
{id: 2, name: 'Half City', roast: 'light'},
{id: 3, name: 'Cinnamon', roast: 'light'},
@@ -48,10 +61,13 @@ var coffees = [
{id: 14, name: 'French', roast: 'dark'},
];
-var tbody = document.querySelector('#coffees');
-var submitButton = document.querySelector('#submit');
-var roastSelection = document.querySelector('#roast-selection');
+const tbody = document.querySelector('#coffees');
+const submitButton = document.querySelector('#submit');
+const roastSelection = document.querySelector('#roast-selection');
+const searchText = document.querySelector('#search-text');
tbody.innerHTML = renderCoffees(coffees);
submitButton.addEventListener('click', updateCoffees);
+searchText.addEventListener('keyup', updateSearchCoffees)
+document.getElementById("roast-selection").addEventListener('click', updateCoffees)
\ No newline at end of file
diff --git a/style.css b/style.css
index cd051aae3..529c12269 100644
--- a/style.css
+++ b/style.css
@@ -7,3 +7,7 @@ td, th {
border: 1px solid black;
padding: 5px 10px;
}
+#roast-heading {
+ position: relative;
+ top: 10px;
+}
diff --git a/up-down-arrows.html b/up-down-arrows.html
new file mode 100644
index 000000000..96b16af47
--- /dev/null
+++ b/up-down-arrows.html
@@ -0,0 +1,45 @@
+
+
+
+
+ Title
+
+
+use strict;
+
+$(document).ready(function () {
+window.displayBoxIndex = -1;
+$('#cityresults').on('click', 'a', function () {
+$('#city').val($(this).text());
+$('#cityresults').hide('');
+$('#citygeonameid').val($(this).parent().attr('data-id'));
+return false;
+});
+var Navigate = function (diff) {
+displayBoxIndex += diff;
+var oBoxCollection = $("#cityresults ul li a");
+if (displayBoxIndex >= oBoxCollection.length) {
+displayBoxIndex = 0;
+}
+if (displayBoxIndex < 0) {
+displayBoxIndex = oBoxCollection.length - 1;
+}
+var cssClass = "display_box_hover";
+oBoxCollection.removeClass(cssClass).eq(displayBoxIndex).addClass(cssClass);
+}
+$(document).on('keypress keyup', function (e) {
+if (e.keyCode == 13 || e.keyCode == 32) {
+$('.display_box_hover').trigger('click');
+return false;
+}
+if (e.keyCode == 40) {
+//down arrow
+Navigate(1);
+}
+if (e.keyCode == 38) {
+//up arrow
+Navigate(-1);
+}
+});
+
+
\ No newline at end of file