140 lines
6.4 KiB
Twig
140 lines
6.4 KiB
Twig
<!doctype html>
|
|
<html lang="en" data-bs-theme="">
|
|
<head>
|
|
<script>
|
|
(() => {
|
|
'use strict'
|
|
|
|
const getStoredTheme = () => localStorage.getItem('theme')
|
|
const setStoredTheme = theme => localStorage.setItem('theme', theme)
|
|
|
|
const getPreferredTheme = () => {
|
|
const storedTheme = getStoredTheme()
|
|
if (storedTheme) {
|
|
return storedTheme
|
|
}
|
|
|
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
}
|
|
|
|
const setTheme = theme => {
|
|
if (theme === 'auto') {
|
|
document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
|
|
} else {
|
|
document.documentElement.setAttribute('data-bs-theme', theme)
|
|
}
|
|
}
|
|
|
|
setTheme(getPreferredTheme())
|
|
|
|
const showActiveTheme = (theme, focus = false) => {
|
|
const themeSwitcher = document.querySelector('#bd-theme')
|
|
|
|
if (!themeSwitcher) {
|
|
return
|
|
}
|
|
|
|
const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)
|
|
|
|
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
|
|
element.classList.remove('active')
|
|
})
|
|
|
|
btnToActive.classList.add('active')
|
|
|
|
if (focus) {
|
|
themeSwitcher.focus()
|
|
}
|
|
}
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
|
const storedTheme = getStoredTheme()
|
|
if (storedTheme !== 'light' && storedTheme !== 'dark') {
|
|
setTheme(getPreferredTheme())
|
|
}
|
|
})
|
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
showActiveTheme(getPreferredTheme())
|
|
|
|
document.querySelectorAll('[data-bs-theme-value]')
|
|
.forEach(toggle => {
|
|
toggle.addEventListener('click', () => {
|
|
const theme = toggle.getAttribute('data-bs-theme-value')
|
|
setStoredTheme(theme)
|
|
setTheme(theme)
|
|
showActiveTheme(theme, true)
|
|
})
|
|
})
|
|
})
|
|
})()
|
|
|
|
</script>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport"
|
|
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Ryobi crawler</title>
|
|
<link href="/templates/css/bootstrap.min.css" rel="stylesheet"/>
|
|
<script src="/templates/js/script.js" defer></script>
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg sticky-top bg-body-tertiary border-bottom border-secondary border-1">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="{{ path('app_home') }}">Crawler</a>
|
|
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
|
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
{% cache "menu_count" ~ listType|default('') %}
|
|
<li class="nav-item">
|
|
<a class="nav-link {% if app.request.pathinfo == path('app_home') %}active shadow-sm bg-body rounded{% endif %}"
|
|
aria-current="page" href="{{ path('app_home') }}">All products <span
|
|
class="badge text-bg-secondary">{{ allCount() }}</span></a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link {% if app.request.pathinfo == path('app_promos') %}active shadow-sm bg-body rounded{% endif %}"
|
|
aria-current="page" href="{{ path('app_promos') }}">Promos <span
|
|
class="badge text-bg-secondary">{{ promosCount() }}</span></a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link {% if app.request.pathinfo == path('app_lowest_price') %}active shadow-sm bg-body rounded{% endif %}"
|
|
aria-current="page" href="{{ path('app_lowest_price') }}">Lowest price <span
|
|
class="badge text-bg-secondary">{{ lowestPriceCount() }}</span></a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link {% if app.request.pathinfo == path('app_new') %}active shadow-sm bg-body rounded{% endif %}"
|
|
aria-current="page" href="{{ path('app_new') }}">New in last 30 days <span
|
|
class="badge text-bg-secondary">{{ newCount() }}</span></a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}"
|
|
aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span
|
|
class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
|
|
</li>
|
|
{% endcache %}
|
|
{# <li class="nav-item dropdown"> #}
|
|
{# #}
|
|
{# </li> #}
|
|
</ul>
|
|
|
|
<form class="form-floating d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
|
<input class="form-control me-2 form-control-sm" type="search" id="floatingInputValue" name="search"
|
|
placeholder="Search term eg. 36v or RCS18X" value="{{ search|default('') }}">
|
|
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
<label for="floatingInputValue">Search term eg. 36v or RCS18X</label>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</nav>
|
|
{% block content %}{% endblock %}
|
|
{{ include('footer.html.twig') }}
|
|
<script src="/templates/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|
|
|