Skip to content

Commit

Permalink
Merge pull request #34 from bladefistx2/main
Browse files Browse the repository at this point in the history
Add filtering by active/inactive plans and added conditional formatting
  • Loading branch information
Chizkiyahu authored Jan 8, 2025
2 parents 200c81f + f22acdb commit da7f527
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
3 changes: 3 additions & 0 deletions docs/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ footer {
color: var(--best-plan-text);
}

.inactive-plan {
background-color: #d3d3d3; /* Light gray background for inactive plans */
}

@media screen and (max-width: 768px) {
.header {
Expand Down
51 changes: 26 additions & 25 deletions docs/data/plans.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [23, 0, 1, 2, 3, 4, 5, 6],
"discount": [20],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -15,7 +15,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [14, 15, 16, 17, 18, 19, 20],
"discount": [20],
"plan_active": false
"plan_active": "לא"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -24,7 +24,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [14, 15, 16, 17, 18, 19, 20],
"discount": [18],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -33,7 +33,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [22, 23, 0, 1, 2, 3, 4, 5, 6],
"discount": [18],
"plan_active": false
"plan_active": "לא"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -42,7 +42,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [23, 0, 1, 2, 3, 4, 5, 6],
"discount": [20],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -51,7 +51,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [22, 23, 0, 1, 2, 3, 4, 5, 6],
"discount": [20],
"plan_active": false
"plan_active": "לא"
},
{
"company_name": "פרטנר חשמל",
Expand All @@ -60,7 +60,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [0, 1, 2, 3, 4, 5],
"discount": [20],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "בזק חשמל",
Expand All @@ -69,7 +69,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [23, 0, 1, 2, 3, 4, 5, 6],
"discount": [20],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "הוט אנרג'י",
Expand All @@ -78,7 +78,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [23, 0, 1, 2, 3, 4, 5, 6],
"discount": [20],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -87,7 +87,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"discount": [15],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "פרטנר חשמל",
Expand All @@ -96,7 +96,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [8, 9, 10, 11, 12, 13, 14, 15, 16],
"discount": [15],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "בזק חשמל",
Expand All @@ -105,7 +105,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"discount": [15],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "הוט אנרג'י",
Expand All @@ -114,7 +114,7 @@
"days_of_week": [0, 1, 2, 3, 4],
"applicable_hours": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"discount": [15],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "פזגז חשמל",
Expand All @@ -123,7 +123,7 @@
"days_of_week": [5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [10],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "אלקטרה פאוור",
Expand All @@ -132,7 +132,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"discount": [8, 9, 10],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "פזגז חשמל",
Expand All @@ -141,7 +141,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "בזק חשמל",
Expand All @@ -150,7 +150,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "אמישראגז חשמל",
Expand All @@ -159,7 +159,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [6.5],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "אלקטרה פאוור",
Expand All @@ -168,7 +168,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [5, 6, 7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "סלקום אנרג'י",
Expand All @@ -177,7 +177,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [5, 6, 7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "פרטנר חשמל",
Expand All @@ -186,7 +186,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [5, 6, 7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "הוט אנרג'י",
Expand All @@ -195,7 +195,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [5, 6, 7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "הוט אנרג'י",
Expand All @@ -204,7 +204,7 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [7],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "הוט אנרג'י",
Expand All @@ -213,14 +213,15 @@
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [10],
"plan_active": true
"plan_active": "כן"
},
{
"company_name": "הוט אנרג'י",
"plan_description": "חוסכים קבוע NEXT",
"plan_link": "https://www.hot.net.il/heb/hotenergy/",
"days_of_week": [0, 1, 2, 3, 4, 5, 6],
"applicable_hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"discount": [6]
"discount": [6],
"plan_active": "כן"
}
]
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ <h2 class="text-lg font-semibold">אפשרויות סינון</h2>
<option value="2">שנה שלישית</option>
</select>
</div>

<div class="my-4">
<label for="showInactivePlans" class="block text-sm">הצג תוכניות לא פעילות</label>
<input type="checkbox" id="showInactivePlans" class="form-checkbox h-5 w-5 text-blue-600 rounded" />
</div>
</section>

<div id="bestPlan" class="p-4 border border-gray-200 mt-4 rounded-lg">
Expand Down
11 changes: 8 additions & 3 deletions docs/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ document.getElementById("startDate").addEventListener("change", applyFiltersAuto
document.getElementById("endDate").addEventListener("change", applyFiltersAutomatically);
document.querySelectorAll("#dayFilters label input").forEach((input) => input.addEventListener("change", applyFiltersAutomatically));
document.getElementById("yearSelection").addEventListener("change", applyFiltersAutomatically);
document.getElementById("showInactivePlans").addEventListener("change", applyFiltersAutomatically);

function processData(csvData, isInitialLoad) {
const lines = csvData.split("\n");
Expand Down Expand Up @@ -250,7 +251,11 @@ async function calculateBestPlan(hourlyDataPerDay) {
const yearSelection = document.getElementById("yearSelection").value; // Get the selected year index
const selectedYearIndex = parseInt(yearSelection, 10); // Ensure it's an integer

let totalKwhFreePerPlan = plans.map((plan) => ({ ...plan, totalKwhFree: 0 }));
const showInactivePlans = document.getElementById("showInactivePlans").checked;

let totalKwhFreePerPlan = plans
.filter(plan => showInactivePlans || plan.plan_active != "לא")
.map((plan) => ({ ...plan, totalKwhFree: 0 }));

// Iterate over each day of the week
for (let dayOfWeek in hourlyDataPerDay) {
Expand Down Expand Up @@ -300,9 +305,9 @@ function displayPlanResults(totalKwhFreePerPlan) {
</tr>`;

totalKwhFreePerPlan.forEach((plan, index) => {
const rowClass = index === 0 ? ' class="best-plan"' : "";
const rowClass = index === 0 ? 'best-plan' : plan.plan_active === "לא" ? 'inactive-plan' : "";

tableHTML += `<tr${rowClass}>
tableHTML += `<tr class="${rowClass}">
<td>${index + 1}</td>
<td>${plan.plan_active}</td>
<td>${plan.company_name}</td>
Expand Down

0 comments on commit da7f527

Please sign in to comment.