ajaxWDwx.js - RELEASE V9.13DESCRIPTION:This alternative
ajaxWDwx.js script has been heavily modified and has many new ajax tags.
Setup has been simplified and many new features have been added (see history below).
Weather website templates similar to the above available at: Saratoga-Weather.orgEXAMPLE:Go to:
Bronberg Weather StationMAJOR ADDITIONS:o UOM switching button for METRIC and ENGLISH (imperial).
o RESTART button to resume updates without having to reload the page.
o External SETTINGS script file which should simplify upgrading to newer versions.
o Webcam image update and management.
o Swapping of current conditions icon with your webcam during day/night and vice-versa.
o Easier management of icon sets (current / wind / FWI / UV etc.).
o Dynamic
cloud height graphic implementation.
o Simplified Unit-of-Measure management.
o Tag for acurate moon phase picture (black & white background).
o Alert if "clientraw.txt" can not be found.
o Loading of "clientrawextra.txt" for history like rain.
o Packed version of "ajaxWDwx.js" i.e "ajaxWDwx-packed.js" for smaller file size.
For the packed version you'll need to use "ajaxWDwx-settings.js" for your configuration.
o ... and many additional "ajaxtags".
For all the available "ajaxtags" see the next post on this page.
HOW TO IMPLEMENT EXTERNAL SETTINGS:If you want to implement the separate external settings file "ajaxWDwx-settings.js"
then you need to add the following line to your "top.php" file:
<script type="text/javascript" src="ajaxWDwx-settings.js"></script>right below this line in "top.php":
<script type="text/javascript" src="ajaxWDwx.js"></script>For completely striped down version of the external settings file have a look at mine here:
http://www.bashewa.com/ajaxWDwx-settings-bws.jsHOW TO HAVE YOUR SCRIPT LOAD FASTER:If you have implemented the external settings script above then you
can use the packed version of this script i.e. "ajaxWDwx-packed.js".
Upload this file to your server and then replace the following line in your "top.php" file:
<script type="text/javascript" src="ajaxWDwx.js"></script>with this one:
<script type="text/javascript" src="ajaxWDwx-packed.js"></script>HOW TO IMPLEMENT UOM SWITCHING:For implementation see:
http://www.bashewa.com/ajax-dashboard.php?sce=viewAdd the following code somewhere into your "ajax-dashboard.php":
<div onClick="javascript:ajax_changeUnits();" style="cursor: pointer"><b>
<span id="uomM" style="color: gray;">METRIC</span> |
<span id="uomE" style="color: blue;">IMPERIAL</span></b>
</div>Or even better is to replace the top row in the table in "ajax-dashboard.php" which will make it look like in the picture above:
<!-- TOP TABLE ROW - FOR UPDATED HEADER & UOM SWITCHING -->
<?php // get last update time from testtags.php
$tagsInterval = 5; // testtags.php upload interval in minutes
$updTime = mktime($time_hour,$time_minute,0,$date_month,$date_day,$date_year);
$nextUpd = mktime($time_hour,$time_minute+$tagsInterval,0,$date_month,$date_day,$date_year);
?>
<tr align="center">
<td>
<div onClick="javascript:ajax_changeUnits();" style="cursor: pointer;" title="Toggle units-of-measure & restart"><b>
<span id="uomM" style="color: gray;"><?php langtrans('METRIC'); ?></span> |
<span id="uomE" style="color: blue;"><?php langtrans('IMPERIAL'); ?></span></b>
</div>
</td>
<td class="data1" colspan="3" style="text-align: center">
<span class="ajax" id="ajaxindicator"><?php langtrans('Updated'); ?>:</span>
<span class="ajax" id="ajaxdate@">
<noscript>
<?php echo date("j/n/Y @ h:ia",$updTime).' - '.langtransstr('next update at').' '.date("h:ia",$nextUpd); ?>
</noscript>
<script type="text/javascript"><!--
document.write("<?php echo $date.' @ '.$time; ?>");
//--></script>
</span>
<span class="ajax" id="ajaxntimess"> </span>
<script type="text/javascript"><!--
document.write(' <small><i>(<span id="ajaxcounter">0</span> <?php langtrans('sec ago'); ?>)</i></small>');
//--></script>
</td>
</tr>You need to enclose your static fields in "ajax-dashboard.php", i.e. fields that don't have an "ajaxtag" which
you want to have converted during UOM switching, with one of the following corresponding <span> classes:
----------------------------------------------------------
<span class="convTemp">82.7°F</span> ...for temp
<span class="convWind"> 2.7 mph</span> ...for wind
<span class="convBaro">30.30 inHg</span> ...for baro
<span class="convRain"> 1.04 in</span> ...for rain
<span class="convSnow"> 12.4 in</span> ...for snow
<span class="convAlti"> 2793 ft</span> ...for altitude
<span class="convDist"> 15 miles</span> ...for distance
<span class="convDate">20-10-2009</span> ...for dates
<span class="convTime"> 15:32:27</span> ...for times
----------------------------------------------------------NOTE: the value in the span must include the units-of-measure for them to be converted.
If you need CSS styling on the same field then you can specify it in the same class tag like this for instance:
<span class="convRain rainStyle">171.4 mm</span>You'll also need the modified
thermometer.php script that supports UOM switching.
I HAVE PROBLEMS - I DON'T SEE THE AJAX UPDATES:Have you pressed
CTRL-F5 to refresh your browser?
Your browser caches javascript and stylesheets and you might still be seeing the old versions.
Make sure all your other scripts that you have included on your page don't have
javascript errors.
If this happens the javascript engine grinds to a complete halt and then this script might not run.
Also make sure you have not made any mistakes in your "ajaxWDwx-settings.js" file which will cause
javascript errors.
Check your FIREFOX "
Javascript Error Console" for possible errors please before reporting any problems.
Alternatively you can implement the following code on your pages:
Javascript Error Dialog Boxwhich will inform you of onpage Javascript errors.
ADDITIONAL SCRIPTS:Additional scripts you might be interested in.
Cloud Base GraphicGradient ThermometerMobile / Cellphone / iPhone Safari ScriptADDITIONAL ICONS & GRAPHICS:Additional graphics you might be interested in.
Make sure to unzip into your root folder with "use folder names" ticked when unzipping them.
If you do so it will leave your current graphics intact.
-------------------------------------------------------------------------------------------
All of the icons below: http://www.bashewa.com/downloads/bws-iconsets.zip (2.5mb)
------------------------------------------------------------------------------------------- ---------FOLDER----------
Current conditions icons: http://www.bashewa.com/downloads/bws-icons-current.zip (269kb) "./ajax-images/icon/...."
Moon pictures x28: http://www.bashewa.com/downloads/bws-icons-moon.zip (188kb) "./ajax-images/moon/...."
Fire Weather Index: http://www.bashewa.com/downloads/bws-icons-fire.zip (291kb) "./ajax-images/fire/...."
Wind Rose icons: http://www.bashewa.com/downloads/bws-icons-wind.zip (822kb) "./ajax-images/wind/...."
UV icons: http://www.bashewa.com/downloads/bws-icons-uv.zip ( 20kb) "./ajax-images/uv/......"
Forcast icons: http://www.bashewa.com/downloads/bws-icons-forecast.zip (1.1mb) "./forecast/images/1/..."
Sun/Moon bg, Moon ph x4: http://www.bashewa.com/downloads/bws-icons-moonphase.zip ( 19kb) "./....................."
------------------------------------------------------------------------------------------- -------------------------
VERSION HISTORY:
Version 9.00 - 15-Apr-2009
Added...... fetching of "clientrawextra.txt" for history data (e.g. rain etc.).
Added...... tag "ajaxrainSun" ...... for last Sunday's rain
..thru..
"ajaxrainSat" ...... for last Saturday's rain
Added...... tag "ajaxwinddeg" ...... for wind in degrees e.g. 334°
Added...... tag "ajaxsnowDepth" .... for current snow depth
"ajaxsnowToday" .... for todays snow
"ajaxsnowMonth" .... for this months snow
"ajaxsnowSeason" ... for this seasons snow
Added...... tag "ajaxwebcamimg" .... for webcam image support
Added...... tag "ajaxmoonimg" ...... for moon image support
Added...... tag "ajaxmoonphase" .... for current phase e.g. "First Quarter"
Added...... tag "ajaxmoonpct" ...... for current moon illumination e.g. 24%
Added...... tag "ajaxcloudheightimg" for cloud height graphic
Added...... tag "ajaxuvimg" ........ for UV graphic (current UV)
Added...... tag "ajaxuvburnrate" ... for UV skin burn rate (in minutes)
Added...... "REFRESH" hyperlink to "Updates paused" for restarting ajax script.
Added...... window.onload function to prevent early ajax loading.
Added...... support for UOM switching [ metric | english ].
Added...... support for UOM switching on static field values.
Modified... thermometer.php to support UOM switching and different styles.
Modified... UV color words to official web colors as specified by WHO, WMO & UNEP.
Modified... overall settings setup for easier configuration.
Modified... UOM conversions and added functions convertSnow & convertDist.
Version 9.01 - 05-Jan-2010
Fixed...... problem with Moon Phase.
Version 9.02 - 07-Jan-2010
Added...... Webster Weather modifications (v2.80, v3.00, v4.10)
Version 9.03 - 10-Jan-2010
Added...... tag "ajaxRcdRain" ......... rain record (record all-time daily rain)
Added...... tag "ajaxRcdRainTime" ..... rain record time
Added...... tag "ajaxRcdRainDate" ..... rain record date
Added...... tag "ajaxRcdRainHr" ....... rain record Hr (record all-time daily rain in 1 hour)
Added...... tag "ajaxRcdRainHrTime" ... rain record Hr time
Added...... tag "ajaxRcdRainHrDate" ... rain record Hr date
Added...... tag "ajaxDaysRain" ........ rain days (MTD)
Added...... tag "ajaxDaysNoRain" ...... rain absent days
Version 9.04 - 10-Jan-2010
Implemented Webcam support for useCamAtNight and delayDayNight
Version 9.05 - 10-Jan-2010
Fixed...... problem with "number_format" function not showing correct decimal value.
Added...... ALERT when "clientraw.txt" file can not be found (error 404)
Removed.... ajaxLoaderInBody - can no longer be supported i.e. <body onload="ajaxLoader(...)">
You need to remove all references to the "ajaxLoader" in your scripts i.e.
you need to replace it with <body> only.
Added...... ClientRawExtra file will now always be loaded on startup as well.
Implemented external "ajaxWDwx-settings.js" for separate setup outside of this script.
Version 9.06 - 12-Jan-2010
Fixed...... problem with incorrect language translations.
Added...... modified "language-??.js" files to installation zip.
Added...... tag "ajaxVPleaf" ... VP leaf wetness
Added...... alert to your visitors if you have Weather Station problems.
Simplified. the setup in the external settings file "ajaxWDwx-settings.js".
Version 9.07 - 13-Jan-2010
Added...... support to use English Windrose images only (for Multilingual Systems).
Simplified. the setup in the external settings file "ajaxWDwx-settings.js" even more.
Your external settings file will now be compatible with all future versions of the script.
Version 9.08 - 17-Jan-2010
Fixed ...... problem with dates when time format is set to 12h clock (AM/PM) in WDisplay.
Version 9.09 - 17-Jan-2010
Fixed ...... problem with JS Date function showing 00:15pm instead of 12:15pm
Version 9.10 - 19-Jan-2010
Fixed ...... problem with dates showing 19:00pm instead of 07:00pm when switching UOM.
Version 9.11 - 19-Jan-2010
Added ...... code for displaying JavaScript errors on page ... see Javascript Error Dialog Box.
a) ...... changed UV to float value to show decimal point.
...... added ajaxdate2 = ajaxdate@ for W3C validation.
Version 9.12 - 19-Jan-2010
Added ...... classes "convDate" and "convTime" for static field UOM switching.
Removed .... Bashewa icon nameing convention function i.e. ajax_getIconName2().
Implemented. Icon Nr specification on icon names eg. "{0NR}-{PIC}.gif" = "01-nskc.gif"
Version 9.13 - 16-Jan-2011
Fixed ...... fixed Moon Phase data (Thanks goes to Ken True, Ken True - Saratoga-weather.org)
TODO LIST / DEVELOPMENT IN PROGRESS: 1. Tag for WDLive "
Input Daily Weather"
-> "
Weather Warning Forecast Input" and/or "
Davis VP Forecast/Warning Text" ... tag:
ajaxforecastwarning 2. Tag for Davis VP and WMR200 forecast (from forecast icon) ... tag:
ajaxforecastmsg 3. Tag for Radar picture with frequent update (minutes settable) ... tag:
ajaxradarimg 4. Tag for Chandler Burning Index ... tag:
ajaxCBI & ajaxCBIimg 5. Tag for Tide image/graph ... tag:
ajaxtideimg 6. Tag for Sun Position image/graph ... tag:
ajaxsunposimg 7. Tag for Sun Path image/graph ... tag:
ajaxsunpathimg 8. Tag for Wind Direction Plot Graph ... tag:
ajaxwinddirplotimg 9. Tag for any kind of imaginable image or graph with optional update frequency.
10. Class tags for converting time/date between US/EURO formats when switching UOM ... tag:
convTime & convDate11. Prevent script from starting unless settings have been loaded.
12. Load "ajaxWDws-settings.js" dynamically from within script in case it's not declared in "top.php".
13. Simplyfy adding of new "ajaxTags" by setting them up in a "tagList" to be loaded during initialization.
CREDITS:Credits go to the following persons who all had a part in making this script:
Matthew Romer .. http://wawaweather.net/
Kevin Reed ..... http://www.tnetweather.com
Pinto .......... http://www.joske-online.be
Tom ............ http://CarterLake.org
Ken True ....... v2.00 http://Saratoga-weather.org
Mike Challis ... http://www.carmosaic.com/weather/
FourOhFour ..... http://skigod.us (at wxforum.net)
Jim ............ http://jcweather.us
Scott .......... v3.00 http://www.WebsterWeatherLIVE.com
Rainer ......... v9.00 http://www.bashewa.com (myself)
DOWNLOAD: ajaxWDwx.js (82kb) (NOTE: see Clientraw Parser for available data)PS: When doing upgrades do not copy over your current settings file.
To prevent this I recommend you name your settings file to something like this: "ajaxWDwx-settings-mws.js" (or similar)PS: Why all of a sudden the jump to version 9.00?
Well, it makes it easier to follow which developer made which changes and for other developers to "steal" each others changes.
I suggest that each developer sticks to one major version for his development i.e. my range would be 9.00-9.99 and I suggest
Scott to use 3.00-3.99 and Ken to stick to the 2.00-2.99 range. Myself and Ken have agreed on this (see his post below).
This will make life mush easier in tracking modifications.