Alternative ajaxWDwx.js Script v 9.14

What browser are you using?
Get Firefox which will report the errors to you line for line.

You messed up some more … double quotes this time:
moonImg.src = imgDir+""moon/{BG}/{NS}-moon{AGE}.gif";

BTW: index.php and index2.php are using the same javascript.

PS: Guys check your FIREFOX “Javascript Error Console” and make sure you’ve not messed up your settings file before reporting errors like these to me … PLEEEEASE!

Can’t be done at this time … the “gen_difference()” function in ajax-dashboard.php needs to be rewritten to cater for this scenario … and that’s another days work. It currently generates differences for temp, humidity and baro and therefore needs to cater for each one differently (… it’s a little late … can’t think straight at this time).

Before anybody asks:
I messed up with the new release of ajaxWDwx-settings.js.
Delete or comment out the tideImg. stuff in your settings.

PS: Guys check your FIREFOX "Javascript Error Console" and make sure you've not messed up your settings file before reporting errors like these to me .... PLEEEEASE!

Sorry didn’t know it existed…all fixed now. Thanks.

Jack

Steve (mighty3503) has pointed out an error with the date routine.
When UOM switching the dates were showing 19:00pm instead of 07:00pm.

This has been fixed and v9.10 is available on the [b][color=blue]front page[/color][/b] for download.

Many thanks to Steve.


Hi Jack and everybody else,

Here’s a piece of Javascript code I’ve knocked together that will trap and alert you of any “Javascript Errors”
you may have. It reports them at the top of your pages or in the “wxStation.useTag” tagname eg. “ajaxindicator”.
It reports the line number, a descriptive error message and the JS file that the error occurred in.

JAVASCRIPT ERROR TRAPPER ALERT BOX
Put the following code into your top.php: (or if standalone into top of page before all other javascript)


<!-- JavaScript Error Dialog Box: start -->
<style type="text/css">
.errordialog{ position:absolute; width:100%; border-bottom:1px solid black; background:lightyellow; left:0; top:0; padding: 7px; text-indent: 5px; font: normal 11px Verdana; }
</style>
<script type="text/javascript">
var jserrNr  = null;
var jserrors = '<div align="center" style="font: 12px Arial Black; color: red;">JAVASCRIPT STARTUP ERRORS</div>';
var dialog   = document.createElement("div");
var errordialog = function(msg, url, linenumber) {
    jserrors+= msg
             + ' at line number '+linenumber
             + ' in <i style="color:blue">'+url+'</i>
';
    if (document.body) {
       dialog.className = 'errordialog';
       dialog.innerHTML = jserrors+'<b>... please inform your webmaster.</b>';
       document.body.appendChild(dialog);
       jserrNr  = 0;
       jserrors = '<div align="center" style="font: 12px Arial Black; color: red;">JAVASCRIPT RUNTIME ERRORS</div>';
    } else jserrNr++;
    return false;
};
window.onerror = function(msg, url, linenumber) { return errordialog(msg, url, linenumber) };
</script>
<!-- JavaScript Error Dialog Box: end -->

NOTE:
The code needs to be before all other Javascript includes. Probably just below this line in top.php:

Here are some examples of the output you get:
[color=blue][b]Example 1[/b][/color] (click the UOM switching button on this one to see another error)
[color=blue][b]Example 2[/b][/color] (Please wait for examples to load until after their first ajax update to be able to see the errors)

Download v9.11 on [color=blue][b]front page[/b][/color] to make the above possible.

Here's a piece of Javascript code I've knocked together that will inform you at the top of the page or in the "wxStation.useTag" tagname when you get "Javascript Errors". It indicates the line number, a descriptive error message and the JS file that the error occurred in.

Thanks, I’ll implement it tonight.

BTW the packed version along with the settings js are awesome, there is a noticible speed difference. The UOM switching is nice too, I added to MTH’s change to your thermometer.php and it now works with the UOM switching, see here…http://discourse.weather-watch.com.msg358153.html#new if anybody is interested. It allows for one less thing to think about when the seasons change!

Jack

I like the Javascript error box… One small item though in relation to my page.

I do DL a weather radar image on my front page from google, which obviously has an error someplace. When I implement the JavaScript error script, placed 1st thing right after the tag, it errors then literally closes the page down completely and will not allow a refresh. Having said that, is there another radar image similiar to what I have available that I can replace with or is there an updated version of this code anyone is aware of?

Just a question, In version 9.10, shouldn’t there be a “var” at the start of the uvImg section in the java script?
In Version 9.11, it’s back in front of uvImg but it’s missing in front of wrImg on line 355

//------------------------------------------------------------------------------
// WIND ROSE: optional settings for the Wind Rose graphic
// tag: "ajaxwindiconwr"
// e.g. graphic name: "./ajax-images/wr-SSE.gif"  or  "./ajax-images/wr-nl-SSE.gif"
// .... grab the wind rose icons here: http://www.bashewa.com/downloads/bws-icons-wind.zip
wrImg =
   {src   : imgDir+"wr-{LANG}{DIR}.png"  // where {DIR} will = wind dir (e.g. NNW), {LANG} = wrImg.lang
   ,width : 58 ,height: 58 ,hspace: 0 ,vspace: 0 ,border: 0
   ,style : ""
   ,align : "" // [ left | right | top | bottom | middle | texttop | absbottom | absmiddle ]
   ,lang  : ""     // with trailing dash (e.g. "nl-" will result in graphic name: "./ajax-images/wr-nl-SSE.gif")
   ,calm  : "calm" // substitution for {DIR} (e.g "wr-calm.gif") ... specify "" if not to be shown or not available
   ,xlate : true   // translate wind direction for icon names (multilingual system)
   ,useTag: "ajaxwindiconwr" // ajax tagname to use where the windrose icon should be placed
   };

Also, in the UV code line 1951 you are making the uv reading an INTEGER always. With that, isn’t it impossible to then display 1.5 with the optional decimal point set at 1 in lines 491 and 508 of version 9.11 of ajaxWDwx.js and the settings file? Hope that makes some sense.

// UV Index
      ;;;set_ajax_obs('ajaxProgress',rand+'uv','in UV');
      uv = parseInt(clientraw[79]);
      set_ajax_obs("ajaxuv"   ,uv.toFixed(dp.UV));
      set_ajax_obs("ajaxuvNoD",uv.toFixed(0));
      set_ajax_obs("gizmouv"  ,uv.toFixed(dp.UV)) ;

var imperialDP = // decimal places
   { Temp:1 ,Wind:1 ,Baro:2 ,Rain:2 ,Snow:2 ,Alti:0 ,Dist:2 ,UV:0 };

Just to be clear, I haven’t been able to test version 9.11 yet as I’m at work and it may all work fine but as of this morning when I tested with 9.10 it was still a bit of an issue for me.

Would it be possible to rename ajaxdate@ on line 1634 to ajaxdate2 or something so that it does not casue a failure when validating the code? The @ symbol is not allowed to be used that way for the code to validate.

      // current date and time of observation in clientraw.txt
      set_ajax_obs("ajaxdatetime", WDdt.date(uom.dateFmt+' '+uom.timeFmt)); // 16/4/2009 02:37:07pm
      set_ajax_obs("ajaxdate@"   , WDdt.date(uom.dateFmt) + ' @ '); // 6/4/2009 @
      set_ajax_obs("ajaxdate"    , WDdt.date(uom.dateFmt)); // 16/4/2009
 

Thanks

Scott

I understand and appreciate your continued script improvem,ents. They have been extremely useful.

Is this something, down the road you may tackle? I am not asking you to jump on this right away as it is not all that important but can see this being a useful fix down the road when time allows.

I bet you NEVER dreamed your updated ajaxWDwx.js et al would blossom to the headache it has! I speak for myself and I believe numerious others that your gracious additions has been greatly appreciated and it only helps to better the worldwide weather community as a whole.

+1

Hi Scott,
Thanks for spotting those problems … much appreciated.
Without the communities help this script will not become stable … thanks again.

I have addressed the var, UV and ajaxdate@ problems in the latest release v9.11a for you.
You now can use “ajaxdate2” instead of “ajaxdate@” as well.

Much appreciated!! Thanks

Try placing the Google script above the “JavaScript Error Dialog Box” code.
I don’t know if that’s going to help but give it a try anyway.
Otherwise you’ll have to remove the code.

I’ll tackle this next … hopefully I’ll have the “gen_difference()” function ready later tonight together with the “convDate” and “convTime” data classes (v9.12).

PS: make that tomorrow!!

Unfortunately I cannot place the script aboved the error checking simply because the placement of the script is what places the GoogleMap also. If someone knows of a more reliable script where I can place an animated radar image, of similiar or better visual quality I would be happy to utilize it. Unfortunately this script seems outdated and I am constantly receiving errors on it. So I want to replace with a comparable radar image if there is one.

<!-- 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 &amp; 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">&nbsp;</span>
      <script type="text/javascript"><!--
         document.write(' <small><i>(<span id="ajaxcounter">0</span>&nbsp;<?php langtrans('sec ago'); ?>)</i></small>');
      //--></script>
   </td>
</tr>

ok, where exactly and what code am I supposed to replace in my ajax-dashboard.php file? I have tried several times and every time I get a blank page after the header and top warning displays. Also, I have my settings file set for E but it is displaying in Metric.

James

It looks like you are using HometownZone’s (Scott) “Alternative Dashboard Script” so you may want to look here for his latest release…http://discourse.weather-watch.com/t/38674

Also open up your ajaxWDwx-settings.js and go to line 118 remove one of the first quotes around the word moon (its an error in the downloaded package).

Jack

I just uploaded it and have the same result. If I look at the source, it stops processing at the following:

      <table width="100%" border="0" cellpadding="2" cellspacing="1" style="border:solid; border-color: #CCCCCC;">
<tr align="center">
   <td>
      <div onclick="javascript:ajax_changeUnits();" style="cursor: pointer;" title="Toggle units-of-measure &amp; restart"><b>
         <span id="uomM" style="color: blue;">

??? Update: I am getting the following error; Fatal error: Call to undefined function langtrans() in /home/content/j/j/m/jjmcnelly/html/ajax-dashboard.php on line 370

Your ajaxWDwx.js still has the double quote error…

moonImg.src   = imgDir+""moon/{BG}/{NS}-moon{AGE}.gif";