Webtags (preserving history): Difference between revisions

m
Line 695: Line 695:


If you are using the api in a context where it does not matter if decimal commas or decimal points are in the api, simply omit the '''rc''' as first item, and just include tag names separated by ampersands.
If you are using the api in a context where it does not matter if decimal commas or decimal points are in the api, simply omit the '''rc''' as first item, and just include tag names separated by ampersands.
=== JavaScript example ===
I have a script that works with the standard log editor in the admin interface to calculate (and recalculate after any edit) the derived fields from the source fields.  To make these calculations work for anyone, I need to find out what units the Cumulus MX user is using. Here is the code:
<pre>/*    Some new variables connected with new api call (MX 3.7.0)  */
var tempLetter;  // C or F
var rainUnit; // mm or in
var windUnit; // any units in style allowed by Cumulus
/*  The one extra api request included to obtain the units used for temperature, rainfall, and wind speed */
$.get('./api/tags/process.json?tempunitnodeg&rainunit&windunit', "limit=1", callUnits);
function callUnits(unitsObject)
{
tempLetter = unitsObject.tempunitnodeg;
rainUnit = unitsObject.rainunit;
windUnit = unitsObject.windunit;
console.log("new api", tempLetter, rainUnit,windUnit);
}</pre>


== "POST" approach ==
== "POST" approach ==
5,838

edits