Skip to content

Commit

Permalink
Merge pull request #14 from davwheat/patch-1
Browse files Browse the repository at this point in the history
Reverse journey list properly and use proper local time
  • Loading branch information
t5r7 committed Jun 5, 2023
2 parents 9c331c3 + d273a37 commit 7c799eb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
9 changes: 9 additions & 0 deletions common.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ section {
padding: 1em;
}

ol.reversed {
display: flex;
flex-direction: column-reverse;
}

ol.reversed li {
flex: 0 0 auto;
}

/* mobile rules */
@media screen and (max-width: 720px) {
header nav {
Expand Down
3 changes: 2 additions & 1 deletion js/1find-station.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const stationList = document.getElementById("station-list");
const departureStation = document.getElementById("departure-station");
const date = document.getElementById("date");

date.value = new Date().toISOString().slice(0, 16);
// remove last char
date.value = new Date(Date.now() + (-1 * new Date().getTimezoneOffset() * 60000)).toISOString().slice(0, 16);

departureStation.addEventListener("input", stepOneinputsChange);
date.addEventListener("input", stepOneinputsChange);
Expand Down
17 changes: 8 additions & 9 deletions js/localstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ if (journeys.length === 0) alert("I couldn't find any journeys in localStorage!

console.log(journeys.length);

let index = 0;
let outputHTML = "";

for (const j of journeys.reverse()) {
for (const i in journeys) {
const j = journeys[i];

// thank you, chatgpt:
// "edit this piece of javascript so that all of the
// "included ${} bits are 'Unset' if the variable doesnt exist"
Expand All @@ -22,15 +23,13 @@ for (const j of journeys.reverse()) {
<p><span>${j.incomplete ? 'INCOMPLETE' : ''}${j.uploaded ? 'ON RAILMILES' : ''}</span><span class="id">${j.identity ? j.identity : "Identity Missing"}</span> from <b>${j.origin}</b> to <b>${j.destination}</b> (${j.route})</p>
<p><span>${j.departureTimeActual}</span> - <span>${j.arrivalTimeActual}</span></p>
<button onclick="location.href = 'addedit.html?operation=edit&index=${index}'"><span class="emoji-icon">✏️</span> Edit this Journey</button>
<button onclick="location.href = 'addedit.html?operation=edit&index=${index}&quickset=dep'"><span class="emoji-icon">⌚</span> Quick Set Departure to Now</button>
<button onclick="location.href = 'addedit.html?operation=edit&index=${index}&quickset=arr'"><span class="emoji-icon">⌚</span> Quick Set Arrival to Now</button>
${j.uploaded ? "<!--" : ""}<button onclick="location.href = 'addedit.html?operation=upload&index=${index}'"><span class="emoji-icon">☁️</span> Upload to RailMiles</button>${j.uploaded ? "-->" : ""}
<button onclick="location.href = 'addedit.html?operation=edit&index=${index}&delete=true'"><span class="emoji-icon">❌</span> Delete this Journey</button>
<button onclick="location.href = 'addedit.html?operation=edit&index=${i}'"><span class="emoji-icon">✏️</span> Edit this Journey</button>
<button onclick="location.href = 'addedit.html?operation=edit&index=${i}&quickset=dep'"><span class="emoji-icon">⌚</span> Quick Set Departure to Now</button>
<button onclick="location.href = 'addedit.html?operation=edit&index=${i}&quickset=arr'"><span class="emoji-icon">⌚</span> Quick Set Arrival to Now</button>
${j.uploaded ? "<!--" : ""}<button onclick="location.href = 'addedit.html?operation=upload&index=${i}'"><span class="emoji-icon">☁️</span> Upload to RailMiles</button>${j.uploaded ? "-->" : ""}
<button onclick="location.href = 'addedit.html?operation=edit&index=${i}&delete=true'"><span class="emoji-icon">❌</span> Delete this Journey</button>
</li>
`;

index++;
}
out.innerHTML = outputHTML;

Expand Down
2 changes: 1 addition & 1 deletion localstorage.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h2>Manage Journeys</h2>
</section>

<section>
<ol id="out">
<ol id="out" class="reversed">

</ol>
</section>
Expand Down

0 comments on commit 7c799eb

Please sign in to comment.