Commit 6f31cbf3 authored by jkerr's avatar jkerr
Browse files

Untangled awful code, General Clean up

parent 9c448d14
Pipeline #3003 failed with stage
in 0 seconds
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" serverName="Sapphire" showDialogOnRemoteDnD="false">
<serverData>
<paths name="Sapphire">
<serverdata>
<mappings>
<mapping deploy="/" local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<option for="true" />
<option maxerr="50" />
<option multivar="true" />
<option globals="$, console, SetBooking, L, FilterSites" />
<option globals="$, console, SetBooking, L, FilterSites, alert, FilterSites" />
<option this="true" />
<option white="true" />
</component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebServers">
<option name="servers">
<webServer id="f29594d2-3299-43f2-a88c-485451ed1409" name="Sapphire" url="https://dev212.otago.ac.nz:8443/jkerr/projects/assignments/">
<fileTransfer host="sapphire.otago.ac.nz" port="22" rootFolder="/devel/jkerr/projects/assignments" accessType="SFTP">
<advancedOptions>
<advancedOptions dataProtectionLevel="Private" passiveMode="true" shareSSLContext="true" />
</advancedOptions>
<option name="port" value="22" />
</fileTransfer>
</webServer>
</option>
</component>
</project>
\ No newline at end of file
......@@ -2,7 +2,21 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="cccfd40b-d5c2-4431-bcfd-f34d25764049" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/deployment.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/webServers.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jsLinters/jslint.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/jsLinters/jslint.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/admin.php" beforeDir="false" afterPath="$PROJECT_DIR$/admin.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/data/._campsites.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/data/bookings.json" beforeDir="false" afterPath="$PROJECT_DIR$/ServerStorage/bookings.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/data/campsites.json" beforeDir="false" afterPath="$PROJECT_DIR$/ServerStorage/campsites.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/filterSites.js" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/filterSites.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/getbookings.js" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/getbookings.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/reviews.js" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/reviews.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/setbooking.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/switchbooking.js" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/switchbooking.js" afterDir="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" />
<option name="SHOW_DIALOG" value="false" />
......@@ -16,7 +30,53 @@
</execution>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="18" lean-forward="true" selection-start-line="27" selection-start-column="18" selection-end-line="27" selection-end-column="18" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/scripts/filterSites.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="96">
<caret line="32" column="13" lean-forward="true" selection-start-line="32" selection-start-column="13" selection-end-line="32" selection-end-column="13" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/getbookings.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="6" lean-forward="true" selection-start-line="17" selection-start-column="6" selection-end-line="17" selection-end-column="6" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/reviews.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="54" selection-start-line="10" selection-start-column="54" selection-end-line="10" selection-end-column="54" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/scripts/switchbooking.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="8" lean-forward="true" selection-start-line="15" selection-start-column="8" selection-end-line="15" selection-end-column="8" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
......@@ -30,12 +90,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>border</find>
<find>submit</find>
<find>searchpushed</find>
<find>searchPushed</find>
<find>click</find>
<find>console.lo</find>
<find>log</find>
<find>json</find>
<find>map.js:51 You clicked the map at LatLng</find>
......@@ -46,7 +100,6 @@
<find>conso</find>
<find>consol</find>
<find>console</find>
<find>console.log</find>
<find>setup</find>
<find>section</find>
<find>var</find>
......@@ -54,6 +107,19 @@
<find>max-w</find>
<find>this</find>
<find>in</find>
<find>cbook</find>
<find>button</find>
<find>console.log</find>
<find>click(</find>
<find>tableadd</find>
<find>setbooking</find>
<find>searchpushed</find>
<find>updatebuttons</find>
<find>site</find>
<find>get</find>
<find>getbookin</find>
<find>displaybooking</find>
<find>display</find>
</findStrings>
<replaceStrings>
<replace>console</replace>
......@@ -86,19 +152,21 @@
<option value="$PROJECT_DIR$/scripts/data/campsites.json" />
<option value="$PROJECT_DIR$/scripts/data/reviews.json" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/scripts/map.js" />
<option value="$PROJECT_DIR$/admin.php" />
<option value="$PROJECT_DIR$/style/style.css" />
<option value="$PROJECT_DIR$/scripts/switchbooking.js" />
<option value="$PROJECT_DIR$/scripts/setbooking.js" />
<option value="$PROJECT_DIR$/scripts/filterSites.js" />
<option value="$PROJECT_DIR$/scripts/getbookings.js" />
<option value="$PROJECT_DIR$/scripts/map.js" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/scripts/reviews.js" />
<option value="$PROJECT_DIR$/scripts/switchbooking.js" />
<option value="$PROJECT_DIR$/scripts/getbookings.js" />
<option value="$PROJECT_DIR$/scripts/filterSites.js" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1308" />
<option name="width" value="1289" />
<option name="height" value="1347" />
</component>
<component name="ProjectLevelVcsManager">
......@@ -119,7 +187,7 @@
<path>
<item name="assignment-1" type="b2602c69:ProjectViewProjectNode" />
<item name="assignment-1" type="462c0819:PsiDirectoryNode" />
<item name="style" type="462c0819:PsiDirectoryNode" />
<item name="scripts" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
......@@ -145,6 +213,7 @@
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/ServerStorage" />
<recent name="$PROJECT_DIR$/scripts" />
<recent name="$PROJECT_DIR$" />
</key>
......@@ -182,6 +251,8 @@
<workItem from="1566445705210" duration="26954000" />
<workItem from="1566474940263" duration="23000" />
<workItem from="1566527472195" duration="5334000" />
<workItem from="1569800535689" duration="4935000" />
<workItem from="1569890472324" duration="4869000" />
</task>
<task id="LOCAL-00001" summary="First Commit">
<created>1565679239864</created>
......@@ -323,16 +394,24 @@
<option name="project" value="LOCAL" />
<updated>1566533665226</updated>
</task>
<option name="localTasksCounter" value="21" />
<task id="LOCAL-00021" summary="Changed to .php">
<created>1569800606731</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1569800606731</updated>
</task>
<option name="localTasksCounter" value="22" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="82228000" />
<option name="totallyTimeSpent" value="92032000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1202" height="1347" extended-state="0" />
<frame x="0" y="23" width="1289" height="1347" extended-state="0" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19741379" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1499599" />
<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" />
......@@ -347,6 +426,7 @@
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32988048" />
<window_info anchor="bottom" id="Terminal" order="10" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
<window_info anchor="bottom" id="File Transfer" order="12" weight="0.32988048" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
......@@ -371,7 +451,8 @@
<MESSAGE value="V1.0 Push" />
<MESSAGE value="Cleaned up code" />
<MESSAGE value="Final Commit." />
<option name="LAST_COMMIT_MESSAGE" value="Final Commit." />
<MESSAGE value="Changed to .php" />
<option name="LAST_COMMIT_MESSAGE" value="Changed to .php" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/scripts/data/cabinInfo.html">
......@@ -397,9 +478,7 @@
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/leaflet/leafletAjax.js" />
<entry file="file://$PROJECT_DIR$/scripts/data/._campsites.json">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/._campsites.json" />
<entry file="file://$PROJECT_DIR$/scripts/data/tentInfo.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
......@@ -414,55 +493,62 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/POI.json">
<entry file="file://$PROJECT_DIR$/style/style.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="750">
<caret line="50" column="19" lean-forward="true" selection-start-line="50" selection-start-column="19" selection-end-line="50" selection-end-column="19" />
<state relative-caret-position="659">
<caret line="242" column="17" selection-start-line="242" selection-start-column="17" selection-end-line="242" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/campsites.json">
<entry file="file://$PROJECT_DIR$/admin.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="30" column="50" selection-start-line="30" selection-start-column="50" selection-end-line="30" selection-end-column="50" />
<state relative-caret-position="150">
<caret line="10" column="46" lean-forward="true" selection-start-line="10" selection-start-column="46" selection-end-line="10" selection-end-column="46" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/bookings.json">
<entry file="file://$PROJECT_DIR$/ServerStorage/bookings.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="911">
<caret line="75" column="25" selection-start-line="75" selection-start-column="25" selection-end-line="75" selection-end-column="42" />
<state relative-caret-position="495">
<caret line="33" column="34" selection-start-line="33" selection-start-column="34" selection-end-line="33" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/data/reviews.json">
<entry file="file://$PROJECT_DIR$/ServerStorage/campsites.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="27" selection-start-line="3" selection-start-column="27" selection-end-line="3" selection-end-column="27" />
<state relative-caret-position="450">
<caret line="30" column="50" selection-start-line="30" selection-start-column="50" selection-end-line="30" selection-end-column="50" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/admin.html">
<entry file="file://$PROJECT_DIR$/scripts/data/POI.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="8" lean-forward="true" selection-start-line="10" selection-start-column="8" selection-end-line="10" selection-end-column="8" />
<state relative-caret-position="750">
<caret line="50" column="19" lean-forward="true" selection-start-line="50" selection-start-column="19" selection-end-line="50" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/filterSites.js">
<entry file="file://$PROJECT_DIR$/scripts/data/reviews.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="28" lean-forward="true" selection-start-line="22" selection-start-column="28" selection-end-line="22" selection-end-column="28" />
<state relative-caret-position="45">
<caret line="3" column="27" selection-start-line="3" selection-start-column="27" selection-end-line="3" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/getbookings.js">
<entry file="file://$PROJECT_DIR$/scripts/setbooking.js">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="18" lean-forward="true" selection-start-line="27" selection-start-column="18" selection-end-line="27" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/jquery-3.3.1.min.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" lean-forward="true" selection-start-line="2" selection-end-line="2" />
<caret line="2" selection-start-line="2" selection-end-line="2" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
......@@ -478,38 +564,31 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/reviews.js">
<entry file="file://$PROJECT_DIR$/scripts/getbookings.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" lean-forward="true" selection-start-line="6" selection-end-line="6" />
<state relative-caret-position="255">
<caret line="17" column="6" lean-forward="true" selection-start-line="17" selection-start-column="6" selection-end-line="17" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/setbooking.js">
<entry file="file://$PROJECT_DIR$/scripts/reviews.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="16" column="45" lean-forward="true" selection-start-line="16" selection-start-column="45" selection-end-line="16" selection-end-column="45" />
<state relative-caret-position="150">
<caret line="10" column="54" selection-start-line="10" selection-start-column="54" selection-end-line="10" selection-end-column="54" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/switchbooking.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="8" selection-start-line="20" selection-start-column="8" selection-end-line="20" selection-end-column="8" />
<state relative-caret-position="225">
<caret line="15" column="8" lean-forward="true" selection-start-line="15" selection-start-column="8" selection-end-line="15" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="6" column="25" lean-forward="true" selection-start-line="6" selection-start-column="25" selection-end-line="6" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/style/style.css">
<entry file="file://$PROJECT_DIR$/scripts/filterSites.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3195">
<caret line="213" column="1" selection-start-line="213" selection-start-column="1" selection-end-line="213" selection-end-column="1" />
<state relative-caret-position="96">
<caret line="32" column="13" lean-forward="true" selection-start-line="32" selection-start-column="13" selection-end-line="32" selection-end-column="13" />
</state>
</provider>
</entry>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
......@@ -17,7 +16,6 @@
</div>
</header>
<main id="admin">
<div id="bookingBox">
<table id="bookings">
......@@ -29,23 +27,4 @@
</tr>
</table>
</div>
<figure id="photo"><img src=""></figure>
</main>
<section id="palette">
<section id="black"></section>
<section id="darkblue"></section>
<section id="medblue"></section>
<section id="lightblue"></section>
<section id="white"></section>
<p id="lato">Lato Text</p>
<p id="opensans">Opensans text</p>
<p id="quicksand">Quicksand text</p>
<p id="ubuntu">Ubuntu text</p>
</section>
</body>
</html>
\ No newline at end of file
</main>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QuickCamp</title>
<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>
<script src="scripts/setbooking.js"></script>
<script src="scripts/switchbooking.js"></script>
<script src="scripts/reviews.js"></script>
<link rel="stylesheet" href="scripts/leaflet/leaflet.css"/>
......@@ -23,9 +21,6 @@
<h2 class="bookType">Book Tent Site</h2>
</div>
</header>
<main>
<article id="infoContainer">
<h2>Welcome:</h2>
......@@ -39,7 +34,7 @@
<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="any" hidden>
<input id="siteType" name="siteType' type='text" value="any" hidden><label for="siteType"></label>
</form>
<div id="foundBox">
<table id="found">
......
var FilterSites = (function () {
"use strict";
var pub = {};
/**
* Saves a booking to localstorage, and displays it above the table
* **/
function setBooking() {
var nameField = $("#name");
var checkInField = $("#checkIn");
var checkOutField = $("#checkOut");
var booking = {};
booking.siteId = $(this).parent().parent().find("td")[0].textContent;
booking.name = nameField.val();
booking.checkIn = checkInField.val();
booking.checkOut = checkOutField.val();
localStorage.removeItem("savedQuickCampBooking");
localStorage.setItem("savedQuickCampBooking", JSON.stringify(booking));
/** 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 class='bookButton' type='button' value='Book'></td>"+
"</tr>");
var currBooking = JSON.parse(localStorage.getItem("savedQuickCampBooking"));
if (!$.isEmptyObject(booking)) {
var bookingText = "";
if (currBooking.name !== "") {
nameField.val(currBooking.name);
}
bookingText += (currBooking.siteId !== "" ? "<span><b>Site:</b> " + currBooking.siteId + "</span>" : "");
if (currBooking.checkIn !== "") {
bookingText += "<span><b>| Check In:</b> " + currBooking.checkIn + "</span>";
checkInField.val(currBooking.checkIn);
}
if (currBooking.checkOut !== "") {
bookingText += "<span><b>| Check Out:</b> " + currBooking.checkOut + "</span>";
checkOutField.val(currBooking.checkOut);
}
bookingText = "<p id='bookingDisplay'><span>" + bookingText + "</span></p>";
$("#bookingDisplay").remove();
$("form").after(bookingText);
}
}
/** When the search button is pushed**/
function searchPushed() {
/** Get data from fields **/
/**
* When the search button is pushed, gets info from form and calls tableAdd
* to add all relevant booking options to the table
* **/
pub.searchPushed = function() {
/* Get data from fields */
var checkIn = $("#checkIn").val().replace(new RegExp("-", "g"), "");
var checkOut = $("#checkOut").val().replace(new RegExp("-", "g"), "");
var type = $("#siteType").val();
var takenSites = [];
/** Get bookings **/
/* Get bookings **/
var address = "scripts/data/bookings.json";
$.ajax({
type: "GET",
url: address,
cache: false,
success: function(data) {
/** Add each site is already booked between the given dates to takenSites **/
success: function (data) {
/* Add the ID of each site booked between given dates to takenSites **/
var aBookings = data.bookings.booking;
var cBook,cInDay,cInMonth,cInYear,cInDate,cOutDay,cOutMonth,cOutYear,cOutDate,i;
var cBook, cInDate, cOutDate, i;
for (i = 0; i < aBookings.length; i += 1) {
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;
cInDate = cBook.checkin.year
+ cBook.checkin.month.padStart(2, "0")
+ cBook.checkin.day.padStart(2, "0");
cOutDate = cBook.checkin.year
+ cBook.checkout.month.padStart(2, "0")
+ cBook.checkout.day.padStart(2, "0");
if (!((cOutDate <= checkIn) || (checkOut <= cInDate))) {
takenSites.push(cBook.number);
}
}
},
error: function () {
console.log("Ajax error when retrieving "+address);
console.log("Ajax error when retrieving " + address);
}
});
/** Clear all sites from table **/
$("#found tr").not("#tableHead").remove();
/** Get sites **/
/* Get sites **/
address = "scripts/data/campsites.json";
$.ajax({
type: "GET",
url: address,
cache: false,
success: function(data) {
/** Call tableAdd on unbooked sites **/
/* Clear all sites from table **/
$("#found tr").not("#tableHead").remove();
/* Add available sites to table **/
var sites = data.campSites.site;
var i;
for (i = 0; i < sites.length; i += 1) {
if (sites[i].siteType.toLowerCase() === type || type === "any") {
if (!takenSites.includes(sites[i].number)) {
tableAdd(sites[i]);
}