Skip to content

Commit

Permalink
Merge pull request #11 from uriweb/release-2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
bjcfuller authored Jan 9, 2023
2 parents 100642b + 3fbdf81 commit 775a1da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 297 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# URI Tides Widget

Add the `[uri-tides]` shortcode to a page and a tides widget appears.
Add the `[uri-tides]` shortcode to a page and a tides widget appears. Requires the [URI Tides Updater](https://github.com/uriweb/uri-tides-updater) plugin to be installed and activated on at least one site in a multisite network.

The widget pulls in live water temp and tide prediction data from NOAA and graphically displays the current position of the tide. By default, data is pulled from the station at Quonset Point, RI, but a different station or buoy can be set if desired.
## How do I get set up?

1. Install [URI Tides Updater](https://github.com/uriweb/uri-tides-updater). For multisite networks, activate it only on one site (e.g. the homepage) to avoid cron job duplication.
2. Install [URI Tides](https://github.com/uriweb/uri-tides/archive/refs/heads/master.zip) and activate it where you intend to use it. Network-activation may be appropriate.
3. Configure the shortcode to taste.

## Attributes

The tides widget is somewhat configurable by adding attributes to the shortcode:

**`station`** (num)(optional)
The NOAA station ID from which to retrieve data. The default is Quonset Point, RI. (default: `8454049`)
Find a station on NOAA's [tides and currents website](https://tidesandcurrents.noaa.gov/stations.html).

**`height`** (num)(optional)
Set a height in pixels for the tide chart (do not include units). The water temp will scale accordingly. (default: `30`)

Expand All @@ -26,5 +26,5 @@ Set custom CSS class(s) (default: none)
Contributors: Brandon Fuller, John Pennypacker
Tags: widgets
Requires at least: 4.0
Tested up to: 4.9
Stable tag: 1.1.1
Tested up to: 6.0
Stable tag: 2.0
31 changes: 10 additions & 21 deletions js/tides.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

'use strict';

/*
* See CO-OPS JSON API documentation at https://tidesandcurrents.noaa.gov/api/
*/
var parameters = {
'timezone' : 'GMT',
'baseURL' : 'https://tidesandcurrents.noaa.gov/api/datagetter?'
};


// Wait for the window to load...
window.addEventListener('load', function(){
uriTidesInit();
Expand Down Expand Up @@ -95,12 +86,11 @@
'padding' : h * (1/6)
};

// Set the station id
var station = els[i].getAttribute('data-station');

helpers.status(els[i], 'Initiating tide data...');
buildChart(els[i], curve, station, );
};
if ( tides ) {
helpers.status(els[i], 'Initiating tide data...');
buildChart(els[i], curve );
}
}

}

Expand All @@ -109,10 +99,9 @@
* @param el el the tide widget element
* @param curve obj the curve dimensions
*/
function buildChart(el, curve, station) {
function buildChart(el, curve) {

var tideHeight,
output,
var output,
tide = tides.tide.predictions,
temp = tides.temperature.data,
display = {
Expand Down Expand Up @@ -178,9 +167,9 @@
var x = (2 * Math.PI) / m.cycle * m.x;
m.y = Math.sin(x) + 1;

// prepare the date of tide retrieval for display
// prepare the date of tide retrieval for display
var retrieved = new Date(tides.date * 1000);
var options = { year: 'numeric', month: 'short', day: 'numeric', hour: "2-digit", minute: "2-digit" };
var options = { year: 'numeric', month: 'short', day: 'numeric', hour: "2-digit", minute: "2-digit" };

var fillcolor = el.classList.contains('darkmode') ? '#fff' : '#555';

Expand All @@ -193,7 +182,7 @@
output += '</svg>';
output += '</div>';

output += '<div class="uri-tides-source">Source: <a href="https://tidesandcurrents.noaa.gov/stationhome.html?id=' + station + '" title="NOAA Center for Operational Oceanographic Producs and Services; tide data retrieved: ' + retrieved.toLocaleDateString("en-US", options) + '">NOAA/NOS/CO-OPS</a></div>';
output += '<div class="uri-tides-source">Source: <a href="https://tidesandcurrents.noaa.gov/stationhome.html?id=8454049" title="NOAA Center for Operational Oceanographic Producs and Services; tide data retrieved: ' + retrieved.toLocaleDateString("en-US", options) + '">NOAA/NOS/CO-OPS</a></div>';


// Display
Expand Down
Loading

0 comments on commit 775a1da

Please sign in to comment.