Commit 4f423545 authored by jkerr's avatar jkerr
Browse files

Added filter

parent 67a847bb
......@@ -2,18 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="cccfd40b-d5c2-4431-bcfd-f34d25764049" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/scripts/leaflet/leafletAjax.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/scripts/map.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/scripts/filterSites.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/scripts/setbooking.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/images/._camperVan.jpg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/images/camperVan.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/images/van.jpg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/data/cabinInfo.html" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/data/cabinInfo.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/data/tentInfo.html" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/data/tentInfo.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/data/vanInfo.html" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/data/vanInfo.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/map.js" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/map.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/switchbooking.js" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/switchbooking.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/style/siteInfoStyle.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/style/style.css" beforeDir="false" afterPath="$PROJECT_DIR$/style/style.css" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
......@@ -32,57 +26,74 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="14" selection-start-column="14" selection-end-column="14" />
<state relative-caret-position="795">
<caret line="53" column="44" selection-start-line="53" selection-start-column="44" selection-end-line="53" selection-end-column="44" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/scripts/leaflet/leafletAjax.js">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/style/style.css">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="9338" selection-start-column="9338" selection-end-column="9338" />
<state relative-caret-position="849">
<caret line="204" column="1" selection-start-line="204" selection-start-column="1" selection-end-line="204" selection-end-column="1" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/style/style.css">
<entry file="file://$PROJECT_DIR$/scripts/switchbooking.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="781">
<caret line="176" column="34" selection-start-line="176" selection-start-column="34" selection-end-line="176" selection-end-column="34" />
<state>
<caret selection-end-line="34" selection-end-column="33" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/map.js">
<entry file="file://$PROJECT_DIR$/scripts/data/campsites.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="56" selection-start-line="12" selection-start-column="56" selection-end-line="12" selection-end-column="56" />
<folding>
<element signature="e#9#15#0" expanded="true" />
</folding>
<state relative-caret-position="75">
<caret line="5" column="18" selection-start-line="5" selection-start-column="18" selection-end-line="5" selection-end-column="18" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/data/campsites.json">
<provider selected="true" editor-type-id="text-editor" />
<entry file="file://$PROJECT_DIR$/scripts/filterSites.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1260">
<caret line="84" column="49" selection-start-line="84" selection-start-column="49" selection-end-line="84" selection-end-column="49" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/data/POI.geojson">
<provider selected="true" editor-type-id="text-editor" />
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/scripts/setbooking.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="28" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/data/bookings.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" selection-start-line="5" selection-end-line="6" />
<state relative-caret-position="360">
<caret line="24" column="18" lean-forward="true" selection-start-line="24" selection-start-column="18" selection-end-line="24" selection-end-column="18" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/map.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="13" column="36" selection-start-line="13" selection-start-column="36" selection-end-line="13" selection-end-column="36" />
<folding>
<element signature="e#9#15#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
......@@ -102,6 +113,8 @@
<component name="FindInProjectRecents">
<findStrings>
<find>border</find>
<find>console.lo</find>
<find>console.log</find>
</findStrings>
</component>
<component name="Git.Settings">
......@@ -116,17 +129,19 @@
<option value="$PROJECT_DIR$/scripts/data/cabinInfo.html" />
<option value="$PROJECT_DIR$/scripts/data/tentInfo.html" />
<option value="$PROJECT_DIR$/scripts/data/vanInfo.html" />
<option value="$PROJECT_DIR$/scripts/switchbooking.js" />
<option value="$PROJECT_DIR$/scripts/leaflet/leafletAjax.js" />
<option value="$PROJECT_DIR$/scripts/map.js" />
<option value="$PROJECT_DIR$/style/style.css" />
<option value="$PROJECT_DIR$/scripts/switchbooking.js" />
<option value="$PROJECT_DIR$/scripts/filterSites.js" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/scripts/leaflet/leafletAjax.js" />
<option value="$PROJECT_DIR$/style/style.css" />
<option value="$PROJECT_DIR$/scripts/setbooking.js" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1189" />
<option name="width" value="1314" />
<option name="height" value="1347" />
</component>
<component name="ProjectLevelVcsManager">
......@@ -137,6 +152,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -149,12 +165,6 @@
<item name="assignment-1" type="462c0819:PsiDirectoryNode" />
<item name="scripts" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="assignment-1" type="b2602c69:ProjectViewProjectNode" />
<item name="assignment-1" type="462c0819:PsiDirectoryNode" />
<item name="scripts" type="462c0819:PsiDirectoryNode" />
<item name="leaflet" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="assignment-1" type="b2602c69:ProjectViewProjectNode" />
<item name="assignment-1" type="462c0819:PsiDirectoryNode" />
......@@ -164,13 +174,13 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="jsx.switch.disabled" value="true" />
<property name="list.type.of.created.stylesheet" value="CSS" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
......@@ -212,7 +222,8 @@
<workItem from="1565927840184" duration="2912000" />
<workItem from="1566271563452" duration="7254000" />
<workItem from="1566278943384" duration="34000" />
<workItem from="1566340107468" duration="6143000" />
<workItem from="1566340107468" duration="6269000" />
<workItem from="1566359872857" duration="14918000" />
</task>
<task id="LOCAL-00001" summary="First Commit">
<created>1565679239864</created>
......@@ -235,17 +246,24 @@
<option name="project" value="LOCAL" />
<updated>1566278967193</updated>
</task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Finished css, made massive progress">
<created>1566346446447</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1566346446447</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="20940000" />
<option name="totallyTimeSpent" value="35984000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1189" height="1347" extended-state="0" />
<frame x="0" y="23" width="1314" height="1347" extended-state="0" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.21883173" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2004717" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -286,17 +304,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/tentInfo.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="6" selection-end-line="4" selection-end-column="6" />
<folding>
<element signature="n#style#0;n#div#0;n#!!top" expanded="true" />
<element signature="n#style#0;n#h2#0;n#div#0;n#!!top" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/cabinInfo.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
......@@ -318,64 +325,78 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/style/siteInfoStyle.css" />
<entry file="file://$PROJECT_DIR$/scripts/leaflet/._leaflet.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="32" lean-forward="true" selection-start-column="32" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/leaflet/leafletAjax.js" />
<entry file="file://$PROJECT_DIR$/scripts/map.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="13" column="36" selection-start-line="13" selection-start-column="36" selection-end-line="13" selection-end-column="36" />
<folding>
<element signature="e#9#15#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/POI.geojson">
<provider selected="true" editor-type-id="text-editor" />
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="840">
<caret line="56" column="25" lean-forward="true" selection-start-line="56" selection-start-column="25" selection-end-line="56" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/bookings.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" selection-start-line="5" selection-end-line="6" />
<state relative-caret-position="360">
<caret line="24" column="18" lean-forward="true" selection-start-line="24" selection-start-column="18" selection-end-line="24" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/switchbooking.js">
<entry file="file://$PROJECT_DIR$/scripts/data/campsites.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="390">
<caret line="26" column="34" selection-start-line="26" selection-start-column="34" selection-end-line="26" selection-end-column="34" />
<state relative-caret-position="75">
<caret line="5" column="18" selection-start-line="5" selection-start-column="18" selection-end-line="5" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/map.js">
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="56" selection-start-line="12" selection-start-column="56" selection-end-line="12" selection-end-column="56" />
<folding>
<element signature="e#9#15#0" expanded="true" />
</folding>
<state relative-caret-position="795">
<caret line="53" column="44" selection-start-line="53" selection-start-column="44" selection-end-line="53" selection-end-column="44" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/style/siteInfoStyle.css">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/style/style.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="781">
<caret line="176" column="34" selection-start-line="176" selection-start-column="34" selection-end-line="176" selection-end-column="34" />
<state relative-caret-position="849">
<caret line="204" column="1" selection-start-line="204" selection-start-column="1" selection-end-line="204" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/campsites.json">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/scripts/leaflet/._leaflet.js">
<entry file="file://$PROJECT_DIR$/scripts/filterSites.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="32" lean-forward="true" selection-start-column="32" selection-end-column="32" />
<state relative-caret-position="1260">
<caret line="84" column="49" selection-start-line="84" selection-start-column="49" selection-end-line="84" selection-end-column="49" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.html">
<entry file="file://$PROJECT_DIR$/scripts/switchbooking.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="14" selection-start-column="14" selection-end-column="14" />
<caret selection-end-line="34" selection-end-column="33" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/leaflet/leafletAjax.js">
<entry file="file://$PROJECT_DIR$/scripts/setbooking.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="9338" selection-start-column="9338" selection-end-column="9338" />
<state relative-caret-position="105">
<caret line="7" column="28" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
</state>
</provider>
</entry>
......
......@@ -6,6 +6,7 @@
<link rel="stylesheet" href="style/style.css">
<script src="scripts/jquery-3.3.1.min.js"></script>
<script src="scripts/switchbooking.js"></script>
<script src="scripts/filterSites.js"></script>
<link rel="stylesheet" href="scripts/leaflet/leaflet.css"/>
<script src="scripts/leaflet/leaflet.js"></script>
......@@ -13,7 +14,7 @@
</head>
<body>
<header>
<h1>QuickCamp</h1>
<h1><a href="index.html">QuickCamp</a></h1>
</header>
<div id="bookingTypes">
<div>
......@@ -27,25 +28,34 @@
<main>
<section id="infoContainer">
<div id="placedInfo">
<h2>Our Cabins:</h2>
<p>All of our cabins include great views, comfortable beds, and best of all hot showers.
If you are looking for a more comfortable camping experience, our luxury cabins are for you.</p>
<h2>Welcome:</h2>
<p>Here at QuickCamp camping ground, we offer only the best cabins, as well as tent and caravan sites.</p>
</div>
</section>
<section id="book">
<h2>Book a Cabin:</h2>
<h2>Book a Site:</h2>
<form>
<input id="submit" name="submit" type="submit">
<input id="submit" name="submit" type="submit" value="Search">
<input id="name" name="name" type="text"><label id="first" for="name">Full Name</label>
<input id="checkIn" name="checkIn" type="date"><label for="checkIn">Check In</label>
<input id="checkOut" name="checkIn" type="date"><label for="checkOut">Check Out</label>
<input id="siteType" name="siteType' type='text" value="cabin" hidden>
<input id="siteType" name="siteType' type='text" value="any">
</form>
</section>
<div id="mapContainer">
<div id="map"></div>
</div>
<figure id="photo"><img src="images/cabin.jpg"></figure>
<div id="foundBox">
<table id="found">
<tr id="tableHead">
<th>Number</th>
<th>Type</th>
<th>Description</th>
<th>Price Per Night</th>
</tr>
</table>
</div>
<figure id="photo"><img src=""></figure>
</main>
......
var FilterSites = (function () {
pub = {};
/** A simple input validator **/
function pad(str) {
if (str.len < 2) {
return str.padStart(2, "0");
}
}
/** When the search button is pushed**/
pub.searchPushed = function() {
fullName = $("#name").val();
checkIn = $("#checkIn").val().replace(new RegExp("-", 'g'), "");
checkOut = $("#checkOut").val().replace(new RegExp("-", 'g'), "");
type = $("#siteType").val();
takenSites = [];
//Gets all bookings
address = "scripts/data/bookings.json";
$.ajax({
type: "GET",
url: address,
cache: false,
success: function(data) {
aBookings = data.bookings.booking;
for (i = 0; i < aBookings.length; i++) {
cBook = aBookings[i];
cInDay = cBook.checkin.day.padStart(2, "0");
cInMonth = cBook.checkin.month.padStart(2, "0");
cInYear = cBook.checkin.year;
cInDate = cInYear+cInMonth+cInDay;
cOutDay = cBook.checkin.day.padStart(2, "0");
cOutMonth = cBook.checkin.month.padStart(2, "0");
cOutYear = cBook.checkin.year;
cOutDate = cOutYear+cOutMonth+cOutDay;
if ((cInDate < checkIn && checkIn < cOutDate) || (cInDate < checkOut && checkOut < cOutDate)) {
continue;
}
//Search for site and add
console.log("Added: "+cBook.number);
takenSites.push(cBook.number);
}
console.log("TakenSites1: "+takenSites);
},
error: function (data) {
alert("ERROR");
}
});
//Clears all sites from table
$("#found tr").not("#tableHead").remove();
//Adds all campsites to table
address = "scripts/data/campsites.json";
$.ajax({
type: "GET",
url: address,
cache: false,
success: function(data) {
sites = data.campSites.site;
console.log("TakenSites2: "+takenSites);
top:
for (i = 0; i < sites.length; i++) {
if (sites[i].siteType.toLowerCase() === type || type === "any") {
if (takenSites.includes(sites[i].number)) {
continue top;
}
tableAdd(sites[i]);
}
}
},
error: function (data) {
alert("ERROR");
}
});
return false;
}
/** Addes a site to the table **/
function tableAdd(site) {
$("#found").append("<tr class='resultRow'>"+
"<td>"+site.number+"</td>"+
"<td>"+site.siteType+"</td>"+
"<td>"+site.description+"</td>"+
"<td>$"+site.pricePerNight+"</td>"+
"<td><input type='button' value='Book'></td>"+
"</tr>");
}
/** Setup function **/
pub.setup = function() {
/** Adds click event for submit button **/
$("#submit").click(pub.searchPushed);
/** Gets all sites from json and adds them to the table**/
address = "scripts/data/campsites.json";
$.ajax({
type: "GET",
url: address,
cache: false,
success: function (data) {
sites = data.campSites.site;
for (i = 0; i < sites.length; i++) {
tableAdd(sites[i]);
}
},
error: function (data) {
alert("ERROR");
}
});
}
return pub;
})();
$(document).ready(FilterSites.setup);
\ No newline at end of file
......@@ -2,7 +2,7 @@ var Map = (function () {
pub = {};
pub.setup = function() {
var map = L.map('map').setView([-45.875, 170.500], 13);
var map = L.map('map').setView([-45.858578, 170.527263], 17.45);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
{
maxZoom: 18,
......@@ -11,16 +11,14 @@ var Map = (function () {
"OpenStreetMap contributors</a> CC-BY-SA"
}).addTo(map);
centralMarker = L.marker([-45.875, 170.500]).addTo(map);
map.on("click", onMapClick);
}
function onMapClick(e) {
alert("You clicked the map at " + e.latlng);
console.log("You clicked the map at " + e.latlng);
}
return pub;
return pub;
})();
......
var changeType = (function () {
pub = {};
return pub;
})();
$(document).ready(changeType.setup);
\ No newline at end of file
var changeType = (function () {
pub = {};
pub.setup = function() {
var i;
buttons = $(".bookType");
for (i = 0; i < buttons.length; i++) {
buttons[i].onclick = changeSiteType;
buttons[i].style.cursor = "pointer";
}
}
/** Changes the desires site type to a given type **/
function changeSiteType(a) {
var siteType;
if (this.innerHTML.toLowerCase().includes("cabin")) {
......@@ -17,11 +11,25 @@ var changeType = (function () {
} else if (this.innerHTML.toLowerCase().includes("tent")) {
siteType = "tent";
}
$("#siteType").val(siteType);
FilterSites.searchPushed();
$("#infoContainer").load("scripts/data/"+ siteType +"Info.html");
$("#siteType")[0].value = siteType;
$("#book h2")[0].innerHTML = "Book For A "+siteType.charAt(0).toUpperCase() + siteType.slice(1);
$("#photo").find("img").attr("src", "images/"+ siteType +".jpg");
}
/** Setup function **/
pub.setup = function() {
/** Sets up booking type buttons at top of page**/
buttons = $(".bookType");
for (i = 0; i < buttons.length; i++) {
buttons[i].onclick = changeSiteType;
buttons[i].style.cursor = "pointer";
}
}
return pub;
})();
$(document).ready(changeType.setup);
\ No newline at end of file
......@@ -61,8 +61,18 @@ header h1 {