Allow users to edit the station itself when clicking a station (description, etc). Humanize refill/empty date/time formats. Remove last
updated line on the popup. On the select city page only show the add new city section and heading when logged in, adjust the login link based on logged-in status, and say click to update on each city button when logged in.
This commit is contained in:
@@ -194,7 +194,7 @@
|
||||
<div class="loading">Loading cities...</div>
|
||||
</div>
|
||||
|
||||
<div class="add-city-form">
|
||||
<div class="add-city-form" id="addCitySection" style="display: none;">
|
||||
<h3>Add New City</h3>
|
||||
<form id="addCityForm">
|
||||
<div class="form-group">
|
||||
@@ -227,12 +227,31 @@
|
||||
const data = await response.json();
|
||||
user = data.user;
|
||||
|
||||
if (!user) {
|
||||
document.getElementById('addCityForm').style.display = 'none';
|
||||
}
|
||||
updateUIBasedOnAuth();
|
||||
} catch (error) {
|
||||
console.error('Auth check failed:', error);
|
||||
document.getElementById('addCityForm').style.display = 'none';
|
||||
updateUIBasedOnAuth();
|
||||
}
|
||||
}
|
||||
|
||||
function updateUIBasedOnAuth() {
|
||||
const addCitySection = document.getElementById('addCitySection');
|
||||
const authLinks = document.querySelector('.auth-links');
|
||||
|
||||
if (user) {
|
||||
addCitySection.style.display = 'block';
|
||||
authLinks.innerHTML = `
|
||||
<a href="/dashboard">Dashboard</a>
|
||||
<span>|</span>
|
||||
<a href="/city/salem">View Salem (Default)</a>
|
||||
`;
|
||||
} else {
|
||||
addCitySection.style.display = 'none';
|
||||
authLinks.innerHTML = `
|
||||
<a href="/login">Login</a>
|
||||
<span>|</span>
|
||||
<a href="/city/salem">View Salem (Default)</a>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,10 +275,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const clickText = user ? 'Click to update' : 'Click to view';
|
||||
cityList.innerHTML = cities.map(city => `
|
||||
<div class="city-item" onclick="selectCity('${city.name}')">
|
||||
<div class="city-name">${city.display_name}</div>
|
||||
<div class="city-stats">Click to view</div>
|
||||
<div class="city-stats">${clickText}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user