favicon2 #15
5 changed files with 31 additions and 5 deletions
|
@ -2,7 +2,7 @@ FROM python:slim
|
||||||
|
|
||||||
RUN pip install flask
|
RUN pip install flask
|
||||||
COPY /beer/beer.py /beer.py
|
COPY /beer/beer.py /beer.py
|
||||||
COPY /beer/static /static
|
COPY /beer/templates /templates
|
||||||
COPY /beer/static /static
|
COPY /beer/static /static
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
|
|
16
beer/beer.py
16
beer/beer.py
|
@ -27,9 +27,19 @@ def index(hours=None, minutes=None):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@app.route('/favicon.ico')
|
@app.route('/favicon.ico')
|
||||||
def favicon():
|
def default_favicon():
|
||||||
""" serve the favicon """
|
""" serve default favicon """
|
||||||
return send_from_directory('static', 'favicon.ico')
|
return send_from_directory('static', 'clock-icon.png')
|
||||||
|
|
||||||
|
@app.route('/favicon/<mode>')
|
||||||
|
def favicon(mode):
|
||||||
|
""" serve the favicon according to the timer """
|
||||||
|
if mode == 'beer':
|
||||||
|
filename = 'beer-icon.png'
|
||||||
|
else:
|
||||||
|
filename = 'clock-icon.png'
|
||||||
|
|
||||||
|
return send_from_directory('static', filename)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main func """
|
""" main func """
|
||||||
|
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
BIN
beer/static/clock-icon.png
Normal file
BIN
beer/static/clock-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
|
@ -44,8 +44,23 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// Update the count down every 1 second
|
|
||||||
|
|
||||||
|
const changeFavicon = link => {
|
||||||
|
let $favicon = document.querySelector('link[rel="icon"]')
|
||||||
|
// If a <link rel="icon"> element already exists,
|
||||||
|
// change its href to the given link.
|
||||||
|
if ($favicon !== null) {
|
||||||
|
$favicon.href = link
|
||||||
|
// Otherwise, create a new element and append it to <head>.
|
||||||
|
} else {
|
||||||
|
$favicon = document.createElement("link")
|
||||||
|
$favicon.rel = "icon"
|
||||||
|
$favicon.href = link
|
||||||
|
document.head.appendChild($favicon)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the count down every 1 second
|
||||||
var x = setInterval(function() {
|
var x = setInterval(function() {
|
||||||
|
|
||||||
// Get today's date and time
|
// Get today's date and time
|
||||||
|
@ -70,6 +85,7 @@ var x = setInterval(function() {
|
||||||
if (distance < 0) {
|
if (distance < 0) {
|
||||||
clearInterval(x);
|
clearInterval(x);
|
||||||
document.getElementById("demo").innerHTML = "<blink>BEER TIME !</blink>";
|
document.getElementById("demo").innerHTML = "<blink>BEER TIME !</blink>";
|
||||||
|
changeFavicon('/favicon/beer')
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue