Author Topic: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard  (Read 1980 times)

0 Members and 1 Guest are viewing this topic.

Offline Breezy

  • Indian Trail Weather
  • Senior Contributor
  • ****
  • Posts: 244
    • Indian Trail Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #25 on: September 23, 2017, 02:24:47 PM »
Quote
Dennis,

I'm trying to install the script following the notes in Jerry's thread as included here. I'll post to this thread as I make progress. Testing will be conducted at
http://indiantrailweather.com/indextest.php

Jeff

Update: As soon as I edited "common.php" my page went blank. Too much for me. I'll be sticking with my current version.

Jeff

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 1770
    • SouthEast Lincoln, NE Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #26 on: September 23, 2017, 02:38:24 PM »
Update: As soon as I edited "common.php" my page went blank. Too much for me. I'll be sticking with my current version.

Jeff
Unless you are using the sunlight pie chart in your menubar, and I see you're not, you DON'T need to modify 'common.php'.  Just add the two functions to the 'function' section of your 'ajax-dashboard6.php' instead.  They will be read in as needed by your dashboard.

Here are the relevant functions in my 'ajax-dashboard6.php':
Code: [Select]
// -----------------------------------------------------------------------------
// The following functions were added by SE Lincoln Weather as part of ajax-dashboard69x
// -----------------------------------------------------------------------------
// Keep images fresh
// Adds timestamp to image making it unique
// -----------------------------------------------------------------------------
if (!function_exists('getUniqueImageURL')) {
function getUniqueImageURL($image_url){
$timestamp = time();
if(strpos($image_url, '?')){
$image_url = str_replace('?', "?$timestamp&", $image_url);
}
else{
$image_url .= "?$timestamp";
}
return $image_url;
}
}
// end of getUniqueImageURL
//
// -----------------------------------------------------------------------------
// CHANGE IN DAYLENGTH FUNCTION:  computes length of yesterday, today,  & tomorrow
//   and then the change in day length from yesterday to today
// Written by SE Lincoln Weather                                                           .
// -----------------------------------------------------------------------------
// Alternate $changeinday routine that finds $changeinday2
if (!function_exists('get_changeinday')) { // Avoid fatally re-declaring this!!!
function get_changeinday() {
$hrsOfSunLight = array();
global $SITE;

$t = time()-86400; // Yesterday

for ($i=0; $i<(2+($displayTomorrow?1:0)); $i++) { // Only loop twice if no $displayTomorrow
$sun = date_sun_info($t, $SITE['latitude' ], $SITE["longitude"]);
$srise  = $sun["sunrise"];
$sset  = $sun["sunset"];
$sunhrs[$i] = $sset - $srise;   // $sunhrs is time between sunrise and sunset
$sh[$i] = floor($sunhrs[$i]/3600); // Sun Hours
$sm[$i] = floor((($sunhrs[$i]/3600)-$sh[$i])*60); // Sun Minutes
$ss[$i] = round(((((($sunhrs[$i]/3600)-$sh[$i])*60)-$sm[$i])*60),0); // Sun Seconds
$hrsOfSunLight[$i] = $sh[$i].':'.$sm[$i].':'.$ss[$i]; // Assemble strings in array
$t+=86400; // Next Day
}

$cindsign = (($sunhrs[1]-$sunhrs[0])>0)?'+':'-'; // Change IN Day sign

$shdiff = ($cindsign=='-'?($sh[0] - $sh[1]):($sh[1] - $sh[0])); // Difference in hours
$smdiff = ($cindsign=='-'?($sm[0] - $sm[1]):($sm[1] - $sm[0])); // Difference in minutes
$ssdiff = ($cindsign=='-'?($ss[0] - $ss[1]):($ss[1] - $ss[0])); // Difference in seconds
if ($ssdiff<0) { // negative number of seconds?
$smdiff -= 1; // borrow
$ssdiff += 60; // and carry
}
if ($smdiff<0) { // negative number of minutes?
$shdiff -=1; // borrow
$smdiff += 60; // and carry
}
$changeinday2 = $cindsign.$shdiff.':'.$smdiff.':'.$ssdiff; // Assemble cind string
$result = array($changeinday2,$hrsOfSunLight);
return $result;
}
}
// end of changeinday()

« Last Edit: September 23, 2017, 02:44:46 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@inebraska.com

Offline Breezy

  • Indian Trail Weather
  • Senior Contributor
  • ****
  • Posts: 244
    • Indian Trail Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #27 on: September 24, 2017, 09:53:01 AM »
I've added the functions in the dashboard and now need to get the php scripting correct in the dashboard.  ](*,) http://indiantrailweather.com/indextest.php It would probably behoove me to take a PHP scripting course 101 ...  :idea: