320
edits
m (Tried to correct all typos) |
NeilThomas (talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 20: | Line 20: | ||
# The comma at the end of the line I have used as an example is there because another parameter is defined on the next line. | # The comma at the end of the line I have used as an example is there because another parameter is defined on the next line. | ||
# The whole object definition, of all the variables in the file, (not seen in single line extract above) is enclosed in brackets "{" to "}" | # The whole object definition, of all the variables in the file, (not seen in single line extract above) is enclosed in brackets "{" to "}" | ||
=How the file is used= | =How the file is used= | ||
Line 37: | Line 27: | ||
MX has to be told to convert that to a data file. There is a full explanation of what is meant by 'Cumulus processing any template' [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|here]]. In this case, MX will, while processing the template, generate a data file that is stored as "CumulusMX/web/websitedata.json". This data file is still coded as JavaScript file, but now the tags have gone as they have been replaced by values. | MX has to be told to convert that to a data file. There is a full explanation of what is meant by 'Cumulus processing any template' [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|here]]. In this case, MX will, while processing the template, generate a data file that is stored as "CumulusMX/web/websitedata.json". This data file is still coded as JavaScript file, but now the tags have gone as they have been replaced by values. | ||
The data file is used with the [[New Default Web Site Information|Web Pages]] supplied in the [[Webfiles folder|'''webfiles''']] sub-folder of the MX distribution from release 3.10.1 onwards. On your web server, each HTML page will call another JavaScript file "/CumulusMX/webfiles/js/setpagedata.js" (after uploading this file once to web site), it is that script that will both read the uploaded data file, and insert the relevant value into HTML pages in a span which has the "cmxdata" attribute, with a value for that attribute set to the appropriate variable name for the relevant JSON object. | The data file is used with the [[New Default Web Site Information|Web Pages]] supplied in the [[Webfiles folder|'''webfiles''']] sub-folder of the MX distribution from release 3.10.1 onwards. On your web server, each HTML page will call another JavaScript file "/CumulusMX/webfiles/js/setpagedata.js" (after uploading this file once to web site), it is that script that will both read the uploaded data file, and insert the relevant value into HTML pages in a span which has the "cmxdata" attribute, with a value for that attribute set to the appropriate variable name for the relevant JSON object. Note that "js/setpagedata.js" uses a querystring for adding the current time to make the request unique, that just ensures a fresh copy is loaded each time, preventing your browser thinking because you have loaded the file before it can reuse the copy it cached. | ||
In the HTML, <code><span data-cmxdata="recordsbegandateISO"></span></code> would be found and then processed in the "setpagedata.js" script. The HTML as displayed by the browser will then have a date within that span element. As explained at the start of this Wiki page, that date originated from MX processing a web tag in the template file. | |||
In the tables below, that explain the data represented by various lines in the template file, there are multiple columns: | In the tables below, that explain the data represented by various lines in the template file, there are multiple columns: | ||
* Cumulus tag name (including whether any input/output modification parameters) | * Cumulus tag name (including whether any input/output modification parameters) | ||
* JSON object variable name | * JSON object variable name | ||
* The span sequence used in HTML file to relate to | * The span sequence used in HTML file to relate to this variable | ||
The | * A description | ||
The tables show the tag name and the JSON variable name because these might not agree. The tables show the span sequence because you might be looking at the HTML file and use what you see there as a starting point for working back to either the description or the Cumulus tag name (or the [[Webtags/Parameters|input/output modification parameter]]). | |||
''Please note for simplicity, not every line in the file is explained, sometimes just one example is given representing multiple lines, this is enough to show you the format (with or without parameters), and whether the tag name and JSON object variable name do match.'' | |||
=File details= | =File details= | ||
{{TOCright}} | {{TOCright}} | ||
This file is designed to work with the MX default web pages (that you upload just once from the '''webfiles''' sub-folder of your MX installation) | * This file is designed to work with the MX default web pages (that you upload just once from the '''webfiles''' sub-folder of your MX installation). | ||
* This template file lists all the JSON variables that those pages require to be uploaded to your web server so the default HTML pages can be used as a background structure to permit displaying your weather data. As explained above, a JavaScript file on your web site loads the file with JSON data and inserts the data in appropriate places on the web page. | |||
* The file has to cater for the majority of people using the default web site, and assumes use of a Davis weather station, therefore its content might not be optimised for your use. | |||
* The default web pages, can only display JSON variables that are defined in this file (as per tables below) and formats for content are fixed. | |||
Note that the variables included in this file represent the degree symbol <sup>o</sup> in two different ways: | |||
# As an HTML encoded entity <nowiki>&deg;</nowiki> that always translates to ° if you are using in HTML web page | # As an HTML encoded entity <nowiki>&deg;</nowiki> that always translates to ° if you are using in HTML web page | ||
# As a binary character (equates to decimal 176), that only translates to ° if you are using UTF-8 encoding '''(select this on ''Internet Settings'' → ''Web/FTP Settings'' → ''General Settings'' → tick ''UTF-8 encoding'')''' to create this file with that encoding (to match the [[Reports_folder#Encoding|encoding]] used by the [[New_Default_Web_Site_Information#Installing_the_new_template_for_new_users|web pages]] included in ''webfiles'' folder) | # As a binary character (equates to decimal 176), that only translates to ° if you are using UTF-8 encoding '''(select this on ''Internet Settings'' → ''Web/FTP Settings'' → ''General Settings'' → tick ''UTF-8 encoding'')''' to create this file with that encoding (to match the [[Reports_folder#Encoding|encoding]] used by the [[New_Default_Web_Site_Information#Installing_the_new_template_for_new_users|web pages]] included in ''webfiles'' folder) | ||
==Tailoring the file== | ==Tailoring the file== | ||
If you | If you have experience with how JSON files are coded, you can choose to use a different file to that provided with MX. | ||
To avoid loss of you file when you are upgrading to a new MX release, best practice would be to create a template file with a different name, and/or in a different folder, and use the '''Extra Web Files''' settings to get your tailored template [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|processed]] and uploaded at your preferred interval to become "webbsitedata.json" on your web server and disable the settings that get the default file processed and uploaded. | |||
If the remote file setting on the extra web files uses the same "webbsitedata.json" name, then "js/setpagedata.js" will load it (<code>$.getJSON('websitedata.json?_=' + Date.now(),</code>, here the plus sign is used to indicate concatenation within the query-string (bit prefixed by question mark)) and process whatever object names it finds, so all you need to do is edit the HTML file to use span definitions that match the object names. | |||
If you have even more experience, you can also edit "js/setpagedata.js", perhaps so it can process multiple JSON files, so you can upload data that is static (see tables) or only changes when day changes at EOD in extra web files settings, and reduce the size of upload at your real-time interval. Of course you might even consider adding extra JavaScript that takes two json objects and outputs the difference between them, or you might make use of [[PHP]] that can also do a simple calculation or a much more complex one. | |||
==Options== | ==Options== | ||
There are 3 fixed pieces of information conveyed by this file | There are 3 fixed pieces of information conveyed by this file (referring to Cumulus web tags for defining options): | ||
# "useApparent" = whether Apparent Temperature or Feels Like temperature is required | # "useApparent" = whether Apparent Temperature or Feels Like temperature is required | ||
# "showSolar" = whether a solar sensor is providing solar information or not | # "showSolar" = whether a solar sensor is providing solar information or not | ||
Line 208: | Line 201: | ||
|<#moonphase> | |<#moonphase> | ||
|"moonphase" | |"moonphase" | ||
| <nowiki><span data-cmxdata=moonphase"></nowiki> | | <nowiki><span data-cmxdata="moonphase"></nowiki> | ||
|Current [[Lunar phase|phase of the moon]] in words, eg "New Moon" etc. The names used can be altered in [[Strings.ini#Moon_Phases|strings.ini]]. | |Current [[Lunar phase|phase of the moon]] in words, eg "New Moon" etc. The names used can be altered in [[Strings.ini#Moon_Phases|strings.ini]]. | ||
|- | |- | ||
|<#longlocation> | |<#longlocation> | ||
|"longlocation" | |"longlocation" | ||
| <nowiki><span data-cmxdata=longlocation"></nowiki> | | <nowiki><span data-cmxdata="longlocation"></nowiki> | ||
|(Static information) Longer description of your location as entered in Settings | |(Static information) Longer description of your location as entered in Settings | ||
|- | |- |
edits