diff --git a/app.py b/app.py index d85eea5..e1e5711 100644 --- a/app.py +++ b/app.py @@ -16,12 +16,12 @@ def hello_world(): rawdata = datapull.grabber() airport = {"name": "", "icao": "", "iata": ""} for flight in rawdata: - # Source Airport naming + # Source Airport naming : airport["name"] = flight["origin"]["name"] airport["icao"] = flight["origin"]["code_icao"] airport["iata"] = flight["origin"]["code_iata"] - # Converting departures time from UTC to local time + # Converting departures time from UTC to local time : origintimezone = flight["origin"]["timezone"] from_zone = tz.gettz('UTC') to_zone = tz.gettz(origintimezone) @@ -29,7 +29,13 @@ def hello_world(): utctime = utctime.replace(tzinfo=from_zone) flight["scheduled_off"] = utctime.astimezone(to_zone).strftime(localformat) - # Calculating Delays in human readable ways + # Adding the secondary flight numbers : + flightnr = flight["ident"] + flight["ident"] = [] + flight["ident"].append(flightnr) + for otherrefs in flight["codeshares"]: + flight["ident"].append(otherrefs) + # Calculating Delays in human readable ways : negative = False delay = flight["departure_delay"] if delay != 0: @@ -45,9 +51,3 @@ def hello_world(): if negative: flight["departure_delay"] = ("-" + str(flight["departure_delay"])) return render_template('screen.html', len=len(rawdata), airport=airport, flight=rawdata) - - -@app.route("/style.css") -def style(): - with open("static/style.css", "r") as f: - return f.read(), 200, {'Content-Type': 'text/css; charset=utf-8'} diff --git a/static/animation.css b/static/animation.css new file mode 100644 index 0000000..7b7c247 --- /dev/null +++ b/static/animation.css @@ -0,0 +1,24 @@ +/* Style for the container of the carousel */ +.carousel-container { + width: 70px; + height: 15px; + overflow: hidden; + position: relative; +} + +/* Style for the list inside the carousel */ +.carousel-list { + list-style: none; + padding: 0; + margin: 0; + position: absolute; + top: 0; + transition: top 1s ease-in-out; +} + +/* Style for individual items in the carousel */ +.carousel-item { + height: 15px; /* Adjust height as needed */ + line-height: 15px; /* Adjust line-height to vertically center text */ + /*border-bottom: 1px solid #ccc; /* Optional: Add border between items */ +} \ No newline at end of file diff --git a/static/scroll.js b/static/scroll.js new file mode 100644 index 0000000..b949390 --- /dev/null +++ b/static/scroll.js @@ -0,0 +1,47 @@ +// JavaScript for autoscrolling all carousels simultaneously +const carouselContainers = document.querySelectorAll('.carousel-container'); +const carousels = []; + +carouselContainers.forEach(container => { + const carouselList = container.querySelector('.carousel-list'); + const items = carouselList.getElementsByClassName('carousel-item'); + const itemHeight = items[0].offsetHeight; + const totalItems = items.length; + let currentIndex = 0; + let isResetting = false; + + // Push each carousel object into an array + carousels.push({ + carouselList, + itemHeight, + totalItems, + currentIndex, + isResetting + }); +}); + +function scrollAllCarousels() { + carousels.forEach(carousel => { + carousel.currentIndex++; + if (carousel.currentIndex === carousel.totalItems) { + carousel.isResetting = true; + carousel.currentIndex = 0; + carousel.carouselList.style.transition = 'top 0.5s ease-in-out'; // Enable transition for smooth scrolling + carousel.carouselList.style.top = `${-carousel.itemHeight}px`; // Start scroll animation + } + if (carousel.isResetting && carousel.currentIndex === 0) { + // If resetting and back to the top, reset the top position instantly without animation + carousel.isResetting = false; + carousel.carouselList.style.transition = 'none'; // Disable transition for instant reset + carousel.carouselList.style.top = '0px'; // Reset to the top instantly + setTimeout(() => { + carousel.carouselList.style.transition = ''; // Re-enable transition + }, 50); // Add a slight delay before re-enabling transition to ensure it takes effect + } + const displacement = -carousel.currentIndex * carousel.itemHeight; + carousel.carouselList.style.top = `${displacement}px`; + }); +} + +// Set interval for autoscrolling all carousels simultaneously +setInterval(scrollAllCarousels, 3000); diff --git a/templates/screen.html b/templates/screen.html index ad80571..dcc3d3c 100644 --- a/templates/screen.html +++ b/templates/screen.html @@ -2,7 +2,9 @@ - + + + {{ airport["icao"] }} Departure Schedule @@ -34,47 +36,56 @@ - {% for i in range(0,len) %} - {% if i%2 == 0 %} - - {% else %} - + {% for i in range(0,len) %} + {% if i%2 == 0 %} + + {% else %} + {% endif %} - {{ flight[i]["ident"] }} - {{ flight[i]["scheduled_off"] }} - {% if flight[i]["departure_delay"] %} - {{ flight[i]["departure_delay"] }} - {% else %} - {% endif %} - - {{ flight[i]["operator"] }} - - {% if flight[i]["destination"]["name"] %} + + + + {{ flight[i]["scheduled_off"] }} + {% if flight[i]["departure_delay"] %} + {{ flight[i]["departure_delay"] }} + {% else %} + {% endif %} + + {{ flight[i]["operator"] }} + + {% if flight[i]["destination"]["name"] %} {{ flight[i]["destination"]["name"] }} {{ flight[i]["destination"]["code_icao"] }} / {{ flight[i]["destination"]["code_iata"] }} - {% else %} - {% endif %} - + {% else %} + {% endif %} + {% if flight[i]["status"] != "Scheduled" %} - {% if flight[i]["cancelled"] %} - - {{ flight[i]["status"] }} - {% elif flight[i]["blocked"] %} - - {{ flight[i]["status"] }} - {% else %} - - {{ flight[i]["status"] }} - {% endif %} - {% else %} - - {% endif %} - + {% if flight[i]["cancelled"] %} + + {{ flight[i]["status"] }} + {% elif flight[i]["blocked"] %} + + {{ flight[i]["status"] }} + {% else %} + + {{ flight[i]["status"] }} + {% endif %} + {% else %} + + {% endif %} + {% endfor %} + \ No newline at end of file