Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 108 additions & 2 deletions fleet/templates/timetable_add.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,59 @@ <h3>Generate Departures</h3>
</div>
</div>

<!-- Step 3: Stop Offsets -->
<!-- Rush Hour Section -->
<div class="config-card">
<div class="card-header">
<span class="step-number">3</span>
<h3>Rush Hour (Optional)</h3>
</div>
<div class="card-body">
<!-- AM Rush Hour -->
<div class="form-group">
<label>AM Rush Hour</label>
<div class="form-row triple">
<div class="form-group">
<label>Start Time</label>
<input type="time" id="rush-am-start" value="">
</div>
<div class="form-group">
<label>End Time</label>
<input type="time" id="rush-am-end" value="">
</div>
<div class="form-group">
<label>Every (mins)</label>
<input type="number" id="rush-am-interval" min="1" value="10">
</div>
</div>
</div>

<!-- PM Rush Hour -->
<div class="form-group">
<label>PM Rush Hour</label>
<div class="form-row triple">
<div class="form-group">
<label>Start Time</label>
<input type="time" id="rush-pm-start" value="">
</div>
<div class="form-group">
<label>End Time</label>
<input type="time" id="rush-pm-end" value="">
</div>
<div class="form-group">
<label>Every (mins)</label>
<input type="number" id="rush-pm-interval" min="1" value="10">
</div>
</div>
</div>

<button type="button" class="btn btn-primary btn-block" onclick="applyRushHours()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
Apply Rush Hours
</button>
</div>
</div>

<!-- Step 4: Stop Offsets -->
<div class="config-card">
<div class="card-header">
<span class="step-number">3</span>
Comment on lines +148 to 151
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the step number inconsistency.

The Journey Times section still shows step number "3", but it should be "4" since Rush Hour is now step 3.

🔢 Proposed fix
-        <!-- Step 4: Stop Offsets -->
         <div class="config-card">
           <div class="card-header">
-            <span class="step-number">3</span>
+            <span class="step-number">4</span>
             <h3>Journey Times</h3>
           </div>
🤖 Prompt for AI Agents
In @fleet/templates/timetable_add.html around lines 148 - 151, The step number
in the Journey Times/Stop Offsets card is wrong: update the span with class
"step-number" inside the card header (the <div class="config-card"> / <div
class="card-header"> block) to display "4" instead of "3" so the steps read
sequentially after Rush Hour (which is now step 3).

Expand Down Expand Up @@ -425,6 +477,60 @@ <h3>Timetable Preview</h3>
generateStopTimesJSON();
}

function applyRushHours() {
const amStart = document.getElementById("rush-am-start").value;
const amEnd = document.getElementById("rush-am-end").value;
const amInterval = parseInt(document.getElementById("rush-am-interval").value, 10);

const pmStart = document.getElementById("rush-pm-start").value;
const pmEnd = document.getElementById("rush-pm-end").value;
const pmInterval = parseInt(document.getElementById("rush-pm-interval").value, 10);

const timesInput = document.querySelector('.departure-times');
let existingTimes = timesInput.value.split(',').map(t => t.trim()).filter(Boolean);

// Helper function to generate times for a rush period
function generateRushTimes(start, end, interval) {
if (!start || !end || !interval || interval <= 0) return [];

const times = [];
let [startHour, startMin] = start.split(":").map(Number);
const [endHour, endMin] = end.split(":").map(Number);

while (startHour < endHour || (startHour === endHour && startMin <= endMin)) {
times.push(`${String(startHour).padStart(2, "0")}:${String(startMin).padStart(2, "0")}`);
startMin += interval;
if (startMin >= 60) {
startHour += Math.floor(startMin / 60);
startMin = startMin % 60;
}
}

return times;
}

// Generate AM rush times
const amTimes = generateRushTimes(amStart, amEnd, amInterval);

// Generate PM rush times
const pmTimes = generateRushTimes(pmStart, pmEnd, pmInterval);

// Merge all times and remove duplicates
const allTimes = [...existingTimes, ...amTimes, ...pmTimes];

// Sort times and remove duplicates
const uniqueTimes = [...new Set(allTimes)].sort((a, b) => {
const [aH, aM] = a.split(':').map(Number);
const [bH, bM] = b.split(':').map(Number);
return (aH * 60 + aM) - (bH * 60 + bM);
});

timesInput.value = uniqueTimes.join(", ");
generateStopTimesJSON();

alert(`Added ${amTimes.length} AM rush trips and ${pmTimes.length} PM rush trips.`);
}

function autoFillOffsets() {
const offset = parseInt(document.getElementById("offset-fill").value, 10);
if (isNaN(offset) || offset < 0) {
Expand Down Expand Up @@ -1358,4 +1464,4 @@ <h3>Timetable Preview</h3>
align-items: flex-end;
}
</style>
{% endblock %}
{% endblock %}