CC ticker now uses top cities in state and has forecast
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 8.4 KiB |
|
@ -1,3 +1,4 @@
|
||||||
|
var foreMarqueeDay = ""
|
||||||
function GroupDataManager() {
|
function GroupDataManager() {
|
||||||
var locationx = {};
|
var locationx = {};
|
||||||
var locations =
|
var locations =
|
||||||
|
@ -31,14 +32,21 @@ function GroupDataManager() {
|
||||||
|
|
||||||
|
|
||||||
// check the expiration
|
// 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 : '';
|
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 += ';'
|
||||||
|
});
|
||||||
|
|
||||||
|
url += '&language=en-US&units=e&format=json&apiKey='+ api_key
|
||||||
// woeid is the id for the location to pull data for
|
} else {
|
||||||
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
|
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);
|
pullData(url);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,13 +60,18 @@ function GroupDataManager() {
|
||||||
|
|
||||||
if ( !location.hasOwnProperty('woeid') ) {
|
if ( !location.hasOwnProperty('woeid') ) {
|
||||||
locationx.woeid = locationx.data.id;
|
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 {
|
} else {
|
||||||
$span = $('#marquee-now>span#' + locationx.woeid);
|
$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
|
// 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());
|
$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
|
// set the expiration date/time
|
||||||
|
@ -73,4 +86,3 @@ function GroupDataManager() {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
var groupDataManager = new GroupDataManager;
|
|
||||||
|
|
|
@ -1,15 +1,34 @@
|
||||||
|
var mainstate
|
||||||
function WeatherManager() {
|
function WeatherManager() {
|
||||||
|
|
||||||
var mainloc
|
var mainloc;
|
||||||
var mainMap, miniMap, slides,
|
var mainMap, miniMap, slides,
|
||||||
dataMan, loops, //weatherAudio,
|
dataMan, loops, //weatherAudio,
|
||||||
that = this;
|
that = this;
|
||||||
|
var marqueeforecasttype = 'now';
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
||||||
// init marquees
|
// init marquees
|
||||||
|
|
||||||
function refreshMarquee () {
|
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-container')
|
||||||
.marquee('destroy')
|
.marquee('destroy')
|
||||||
.marquee({speed: 200, pauseOnHover:true, delayBeforeStart:3000})
|
.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) {
|
$.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] );
|
dataMan = createDataManager( data.location.latitude[0]+','+data.location.longitude[0] );
|
||||||
mainloc = data.location.city[0]
|
mainloc = data.location.city[0]
|
||||||
|
mainstate = data.location.adminDistrict[0]
|
||||||
|
groupDataManager = new GroupDataManager;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -62,6 +83,8 @@ function WeatherManager() {
|
||||||
$.getJSON("http://ip-api.com/json/?callback=?", function(data) {
|
$.getJSON("http://ip-api.com/json/?callback=?", function(data) {
|
||||||
dataMan = createDataManager( data.lat+','+data.lon );
|
dataMan = createDataManager( data.lat+','+data.lon );
|
||||||
mainloc = data.city
|
mainloc = data.city
|
||||||
|
mainstate = data.regionName
|
||||||
|
groupDataManager = new GroupDataManager;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|