CC ticker now uses top cities in state and has forecast

This commit is contained in:
BuildTools 2021-08-31 19:44:27 -04:00
parent a3b063e9d2
commit 9aa91db6e2
10 changed files with 47 additions and 12 deletions

BIN
webroot/images/fri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
webroot/images/monarrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
webroot/images/satarrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
webroot/images/sunarrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
webroot/images/thuarrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
webroot/images/tuearrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
webroot/images/wedarrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -1,3 +1,4 @@
var foreMarqueeDay = ""
function GroupDataManager() {
var locationx = {};
var locations =
@ -31,14 +32,21 @@ function GroupDataManager() {
// check the expiration
var url = 'https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes='
woeid = location.hasOwnProperty('woeid') ? location.woeid : '';
$.getJSON("https://examples.opendatasoft.com/api/records/1.0/search/?dataset=largest-us-cities&q=&sort=population&facet=city&facet=state&refine.state=" + mainstate, function(data) {
if (data !== undefined && data.records.length != 0) {
data.records.forEach((city, i) => {
url += (city.fields.coordinates).replace(';',',');
url += ';'
});
// woeid is the id for the location to pull data for
var url = 'https://api.weather.com/v3/aggcommon/v3-wx-observations-current;v3-location-point?geocodes=41.881832,-87.623177;44.986656,-93.258133;33.427204,-111.939896;46.877186,-96.789803;34.187042,-118.381256;33.660057,-117.998970;36.114647,-115.172813;21.315603,-157.858093;28.538336,-81.379234;43.0,-75.0;&language=en-US&units=e&format=json&apiKey='+ api_key
pullData(url);
url += '&language=en-US&units=e&format=json&apiKey='+ api_key
} else {
url = 'https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes=41.881832,-87.623177;44.986656,-93.258133;33.427204,-111.939896;46.877186,-96.789803;34.187042,-118.381256;33.660057,-117.998970;36.114647,-115.172813;21.315603,-157.858093;28.538336,-81.379234;43.0,-75.0;&language=en-US&units=e&format=json&apiKey='+ api_key
}
pullData(url);
});
}
@ -52,13 +60,18 @@ function GroupDataManager() {
if ( !location.hasOwnProperty('woeid') ) {
locationx.woeid = locationx.data.id;
$span = $("<span id='" + locationx.woeid + "'></span>").appendTo('#marquee-now');
$span = $("<span class=marquee-now id='" + locationx.woeid + "'></span>").appendTo('#marquee-now');
$spanfor = $("<span class=marquee-fore id='" + locationx.woeid + "'></span>").appendTo('#marquee-now');
} else {
$span = $('#marquee-now>span#' + locationx.woeid);
}
var marqueeidx = 1;
if (locationx.data['v3-wx-forecast-daily-5day'].daypart[0].daypartName[0] == undefined) {marqueeidx = 2;};
if (locationx.data['v3-wx-forecast-daily-5day'].daypart[0].daypartName[marqueeidx] == "Tonight") {foreMarqueeDay = 'tonight';} else {foreMarqueeDay = (locationx.data['v3-wx-forecast-daily-5day'].dayOfWeek[1].substring(0,3)).toLowerCase()};
// display the current info
$span.text(locationx.data['v3-location-point'].location.displayName + ': ' + Math.round(parseInt(locationx.data['v3-wx-observations-current'].temperature)) + ' ' + (locationx.data['v3-wx-observations-current'].wxPhraseLong).toLowerCase());
$spanfor.css('display','none')
$spanfor.text(locationx.data['v3-location-point'].location.displayName + ': ' + Math.round(parseInt(locationx.data['v3-wx-forecast-daily-5day'].daypart[0].temperature[marqueeidx])) + ' ' + (locationx.data['v3-wx-forecast-daily-5day'].daypart[0].wxPhraseLong[marqueeidx]).toLowerCase());
// set the expiration date/time
@ -73,4 +86,3 @@ function GroupDataManager() {
}
var groupDataManager = new GroupDataManager;

View File

@ -1,15 +1,34 @@
var mainstate
function WeatherManager() {
var mainloc
var mainloc;
var mainMap, miniMap, slides,
dataMan, loops, //weatherAudio,
that = this;
var marqueeforecasttype = 'now';
$(function(){
// init marquees
function refreshMarquee () {
if (marqueeforecasttype == 'now') {
marqueeforecasttype = 'forecast'
$('#arrow-img').attr("src",'/images/' + foreMarqueeDay + 'arrow.png');
$('.marquee-fore').each(function(i, item) {
item.style.display = ''
});$('.marquee-now').each(function(i, item) {
item.style.display = 'none'
});
} else {
marqueeforecasttype = 'now'
$('#arrow-img').attr("src",'/images/now.png');
$('.marquee-fore').each(function(i, item) {
item.style.display = 'none'
});
$('.marquee-now').each(function(i, item) {
item.style.display = ''
});
}
$('#marquee-container')
.marquee('destroy')
.marquee({speed: 200, pauseOnHover:true, delayBeforeStart:3000})
@ -55,6 +74,8 @@ function WeatherManager() {
$.getJSON("https://api.weather.com/v3/location/search?query="+queryString.split("?")[1]+"&language=en-US&format=json&apiKey=" + api_key, function(data) {
dataMan = createDataManager( data.location.latitude[0]+','+data.location.longitude[0] );
mainloc = data.location.city[0]
mainstate = data.location.adminDistrict[0]
groupDataManager = new GroupDataManager;
});
} else {
@ -62,6 +83,8 @@ function WeatherManager() {
$.getJSON("http://ip-api.com/json/?callback=?", function(data) {
dataMan = createDataManager( data.lat+','+data.lon );
mainloc = data.city
mainstate = data.regionName
groupDataManager = new GroupDataManager;
});
}