Ajax Heat Color Word - 1.0 Final

I made a new feature for ajaxWDwx.js
This feature is called “Ajax Heat Color Word”
It makes the heatcolor word ajaxed with a color background that changes with the heatcolor, very similar to heatcolourword in WD

See it being used on my ajax dashboard here:
http://www.proweatherstore.com/weather/index.php

To see how it progressed from BETA to Final, see this post.
http://discourse.weather-watch.com/t/32531

This is version 1.00 Final

Here is how to add it:

edit ajax-dashboard.php:
change:


<?php  echo $heatcolourword; ?>

to:


<span class="ajax" id="ajaxheatcolorword"><?php  echo $heatcolourword; ?></span>

edit ajaxWDwx.js:

change:


// -- end of language settings ----------------------------------------------------------

to:


var langHeatWords = new Array (
 'Unknown', 'Extreme Heat Danger', 'Heat Danger', 'Extreme Heat Caution', 'Extremely Hot', 'Uncomfortably Hot',
 'Hot', 'Warm', 'Comfortable', 'Cool', 'Cold', 'Uncomfortably Cold', 'Very Cold', 'Extreme Cold' );

// -- end of language settings ----------------------------------------------------------

change:


// Mike Challis' counter function (adapted by Ken True)

to:


// function to add colored heatColorWord by Mike Challis
// final version 1.00 
function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
 if (temp > 32 && Humidex > 29) {
  if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
  if (Humidex > 45) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
  if (Humidex > 39) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
  if (Humidex > 29) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
 } else if (WindChill < 16 ) {
  if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
  if (WindChill < -9)  { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
  if (WindChill < -1)  { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
  if (WindChill < 8)   { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
  if (WindChill < 16)  { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
 }  else if (WindChill >= 16 && temp <= 32) {
  if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
  if (temp <= 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
  }
  return hcWord;
}

// Mike Challis' counter function (adapted by Ken True)

change:


set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);

to:


set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);

                // # mike challis added heatColorWord feature
                var heatColorWord = heatColor(clientraw[4],clientraw[44],clientraw[45]);
                set_ajax_obs("ajaxheatcolorword",heatColorWord);

Thanks for this nice add-on, really appreciated!

Mario

Nice work Mike. Have it incorporated with no problems. Mike one quick question. To change the range of temps I can just go to the ajaxWDwx.js and edit those settings? My temp range is different due to the fact the area I live in. Colder than avg temps.

Chuck

Yes you can do that, keep in mind that they are celsius regardless of what your site displays.

Yes I am aware of it being Celsius Mike. Thanks for the reminder. I will get to it a little later. Spending time with the spouse.

Chuck

Thanks Mike!

It works fine! It’s easy to adjust the temperature criteria according to the weather conditions on your region! :smiley:

Thanos

Hi Mike

Thank you very much for this new feature in the ajaxWXwd - I have it up and running on my website without any problems. Very easy with your excellent description.

Best regards,

Henrik

Thanks Mike. Works like a charm

Hello Mike:

I’m using the latest beta version…did you make any additional changes from the last beta version to the current version? Just checking to see if I need to make any changes…

Thanks
Ronnie

Yes I think I did.

Thanks Mike…I will make the necessary changes…

Ronnie

Will the changes be incorporated into the “master” set?

Mark

Yes, Ken said he would add them in.

All done… V1.28 of Canada, USA, World templates released.
12-May-2008 ajaxWDwx.js and ajax-dashboard.php with HeatColorWord mod(MChallis), plaintext-parser.php V1.10 fix → arrow (Canada, USA, World)

Thanks Ken :smiley:

It’s very strange, I’ve added/replaced all the text as described, but still only the “normal” text is showing (without the border and colour).

Anyone got any tips?

I also don’t have a footer when you watch the index.php file for some reason… :frowning: Don’t know why, it should be there.

Click my banner for link

The ajaxWDwx.js script appears correct, as does the markup for id=“ajaxheatcolorword” in ajax-dashboard.php

The ajaxWDwx.js script isn’t running however, possibly due to another JavaScript on the page having an error (one failure, and all JavaScript on the page stops running until the page is reloaded).

For the lack of a footer, it appears that your index.php ends with

<div align="center">
        <p><a href="http://www.paulen.no/topsites/"><img src="http://www.paulen.no/topsites/button.php?u=NorwegianMartin" alt="Paulen Top 100 Weatherstation List" border="0" /></a></p>
      </div>

      </p></table></tr>


… maybe there’s a PHP error on the page below that or you’ve included a script that is exiting instead of returning ???

Send me a zipped copy of your index.php and I’ll have a look.

Best regards,
Ken

I have seen this problem before. You have enabled the ajax gizmo on the index page, you cannot do that because it conflicts with the ajax dashboard.

You are probably actually getting a PHP error, but your PHP is not showing it (sometimes PHP is configured that way)
This is probably the error if it would show …

Fatal error: Cannot redeclare gen_difference() (previously declared in ajax-gizmo.php:131) in ajax-dashboard.php on line 692

Edit your index.php and set the gizmo to false
$showGizmo = false; // set to false to exclude the gizmo

Maybe Ken should remove the $showGizmo setting in the wxindex.php, because I have seen this happen before when users configure it from false to true