Author Topic: Saratoga template minor formatting queries [Resolved]  (Read 914 times)

0 Members and 1 Guest are viewing this topic.

Offline Vasco

  • Forecaster
  • *****
  • Posts: 342
    • PWS
Saratoga template minor formatting queries [Resolved]
« on: November 28, 2022, 02:27:24 PM »
Still on a steep learning curve with Ajax. . . I've managed to change one or two things but I can't find these three:

1. Extra-large space between gizmo Wind: and Calm;

2. Extra-large space between next update time and hyphen for updated (where "Updated" to the left means the 5-minute testtags upload and "updated" to the right means my 20-second Ajax update  :? ); and

3. Unnecessary space before commas in Metar.

Using WD.
« Last Edit: December 02, 2022, 05:16:26 PM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Saratoga template minor formatting queries
« Reply #1 on: November 28, 2022, 03:15:07 PM »
The 1) is only doing that for Calm.  Normally there should be an arrow in there.  I'm guessing there is a blank icon in there, or just white space for no direction.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template minor formatting queries
« Reply #2 on: November 28, 2022, 03:23:37 PM »
For 1) the ajax-gizmo.php has this as the base HTML:
Code: [Select]
    <span class="ajax" id="gizmowindicon"></span>
<span class="ajax" id="gizmowinddir"><?php langtrans($dirlabel); ?></span>&nbsp;
<span class="ajax" id="gizmowind"><?php echo gizmo_strip_units($avgspd) . $uomWind?></span>
The 'Calm' is only done by ajaxWDwx.js code
Code: [Select]
       if (wind > 0.0) {
set_ajax_obs("ajaxwind",wind.toFixed(1) + uomWind);
set_ajax_obs("ajaxwindNoU",wind.toFixed(1));
set_ajax_obs("gizmowind",wind.toFixed(1) + uomWind);
set_ajax_uom("ajaxwinduom",true);
   } else {
set_ajax_obs("ajaxwind",langWindCalm);
set_ajax_obs("ajaxwindNoU",langWindCalm);
set_ajax_obs("gizmowind",langWindCalm);
set_ajax_uom("ajaxwinduom",false);
   }
so the Calm only appears if the wind avgspd is < 0.1 .  The langWindCalm comes from the default (in ajaxWDwx.js) overridden by the language file language-LL.js.  In both cases (for English) is shows just
Code: [Select]
var langWindCalm = 'Calm';
so no extra space there.
This may be a case where the specific browser is inserting padding due to the default styling of the element. 

For 2), I didn't see this on your site using Firefox, but did see it using Chrome browser.

The code generating this in ajax-dashboard.php is
Code: [Select]
        <tr align="center">
          <td class="data1" colspan="4" style="text-align: center">
    <span class="ajax" id="ajaxindicator"><?php langtrans(&#39;Updated&#39;); ?>:</span>&nbsp;@
    <span class="ajax" id="ajaxdate">
    <?php echo fixup_date($date) . &#39; &#39; . fixup_time($time);
  if(isset($timeofnextupdate)) { echo " - " langtransstr(&#39;next update at&#39;) . " " . fixup_time($timeofnextupdate);} ?>

    </span>&nbsp;<span class="ajax" id="ajaxtime"></span>
            <?php if(isset($SITE[&#39;ajaxScript&#39;])) { ?>
            <script type="text/javascript">
<!--
document.write('<b> - <?php langtrans(&#39;updated&#39;); ?> <span id="ajaxcounter"></span>&nbsp;<?php langtrans(&#39;sec ago&#39;); ?></b>');
//-->
            </script>
            <?php // there is a ajaxScript ?>
          </td>
        </tr>

The
Code: [Select]
    <span class="ajax" id="ajaxdate">
    <?php echo fixup_date($date) . &#39; &#39; . fixup_time($time);
  if(isset($timeofnextupdate)) { echo " - " langtransstr(&#39;next update at&#39;) . " " . fixup_time($timeofnextupdate);} ?>

    </span>&nbsp;<span class="ajax" id="ajaxtime"></span>
generates the basic HTML from PHP, and is replaced by ajaxdate and ajaxtime from the ajaxWDwx.js script.  The JavaScript snippet
Code: [Select]
document.write('<b> - <?php langtrans(&#39;updated&#39;); ?> <span id="ajaxcounter"></span>&nbsp;<?php langtrans(&#39;sec ago&#39;); ?></b>'); is inserted into the page and executes (with JavaScript enabled).  Both of those only have 1 space before the '-', so this too may be a browser artifact.

For 3), it's include-metar-display.php that handles the formatting of the data.
For the wind issue at the top, try changing
Code: [Select]
$t = preg_replace('|\((.*)\)|U'," <span class=\"bidi\">, $1</span>",$t); to
Code: [Select]
$t = preg_replace('|\((.*)\)|U',"<span class=\"bidi\">, $1</span>",$t);and for visibility try changing
Code: [Select]
$t = preg_replace('|\((.*)\)|U'," <span class=\"bidi\">, $1</span>",$t); // fix parenthesis issue in RTL language to
Code: [Select]
$t = preg_replace('|\((.*)\)|U',"<span class=\"bidi\">, $1</span>",$t); // fix parenthesis issue in RTL language
Sorry I don't have a definitive answer for 1) or 2).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 342
    • PWS
Re: Saratoga template minor formatting queries
« Reply #3 on: November 28, 2022, 03:29:57 PM »
Wow - thanks, Ken  :-)

I'll report back later. . .
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template minor formatting queries
« Reply #4 on: November 28, 2022, 04:02:30 PM »
The 1) is only doing that for Calm.  Normally there should be an arrow in there.  I'm guessing there is a blank icon in there, or just white space for no direction.
The ajaxWDwx.js replaces the icon with no space or "" in
Code: [Select]
set_ajax_obs("gizmowindicon","");Then rendered content should be no characters or extra space.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 342
    • PWS
Re: Saratoga template minor formatting queries
« Reply #5 on: November 28, 2022, 05:16:06 PM »
For 3), it's include-metar-display.php that handles the formatting of the data.
For the wind issue at the top, try changing . . .

and for visibility try changing . . .

Regret that didn't work. . . but never mind - I'm beginning to realise that random spaces might be important  :-)

Quote
Sorry I don't have a definitive answer for 1) or 2).

No problem. Just glad I hadn't missed anything  :grin:

But I did add a space in lines 160 and 162:

Code: [Select]
if (isset($SITE['uomDistance']) and preg_match('|mi|i',$SITE['uomDistance'])) {
echo "${mtrDistanceM} mi, ";   # added space before mi
        }
echo "${mtrDistanceK} km";     # added space before km
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

 

anything