It is currently March 28th, 2024, 2:42 pm

Using IfMatchActions to show/hide meter

Get help with creating, editing & fixing problems with skins
User avatar
qwerky
Posts: 182
Joined: April 10th, 2014, 12:31 am
Location: Canada

Using IfMatchActions to show/hide meter

Post by qwerky »

Hi. Using WebParser on a weather site, and depending on the time of day (day/night), there may or may not be an icon for the first day. In the measure, I tried using IfMatchActions to show/hide the meter:

Code: Select all

[msrGraphic1Icon]
Measure=WebParser
URL=#SiteURL#[msrGraphicGroup]
StringIndex=#GraphicIndexIcon#
Download=1
IfMatch=(?i)^.+$
IfMatchAction=[!ShowMeter mtrDay1Icon]
IfNotMatchAction=[!HideMeter mtrDay1Icon]
With the meter:

Code: Select all

[mtrDay1Icon]
Meter=Image
MeasureName=msrGraphic1Icon
X=#cell1Icon#
Y=#iconY#
W=#iconWidth#
H=#iconHeight#
SolidColor=#colorIconBG#
This works, but when the skin refreshes, the meter is always hidden for about a second before becoming visible (as opposed to the remaining icon meters, which show immediately). I've tried adding IfMatchMode=1 with the same results. I've tried reversing the test/actions (matching an empty string) with the same results. Can this be overcome?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfMatchActions to show/hide meter

Post by balala »

qwerky wrote: February 3rd, 2019, 10:10 pm This works, but when the skin refreshes, the meter is always hidden for about a second before becoming visible (as opposed to the remaining icon meters, which show immediately). I've tried adding IfMatchMode=1 with the same results. I've tried reversing the test/actions (matching an empty string) with the same results. Can this be overcome?
Yep, because at the very first moment the WebParser measures don't return values, being empty. These measures are always needing time to get their values. But while this goes on, the [mtrDay1Icon] meter is hidden, according to the IfNotMatchAction option set into the [msrGraphic1Icon] measure.
If you would like to have the meter not hidden, you probably have to create an image which will be shown while the measure doesn't return a value. For example you'll name that image as Nothing.png and will place it into the @Resources folder.
Now replace the IfMatch options set of the [msrGraphic1Icon] measure with the following ones:

Code: Select all

[msrGraphic1Icon]
...
RegExpSubstitute=1
Substitute="^$":"#@#Nothing.png"
This way while the measure doesn't return anything, its empty value is replaced by the path and name of the previously created image and the Image meter shows that image. But when the measure gets a value, the Image meter shows up that image, because the substitution doesn't occur any more.
User avatar
qwerky
Posts: 182
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Using IfMatchActions to show/hide meter

Post by qwerky »

balala wrote: February 4th, 2019, 2:33 pm Yep, because at the very first moment the WebParser measures don't return values, being empty. These measures are always needing time to get their values. But while this goes on, the [mtrDay1Icon] meter is hidden, according to the IfNotMatchAction option set into the [msrGraphic1Icon] measure.
Oh, that's a good explanation. But please help me to understand. There are seven icons in a row. Only the first has the show/hide conditions, because it is the only one that can be absent; and only the first displays this problem.

But when, with the mouse, the skin is right-clicked and 'Refresh' chosen, does that cause all measures and meters to update? And if that is the case, shouldn't it take that same small amount of time for all the web measures to be parsed, and should not all of the icons disappear briefly?

Since they do not all disappear, obviously my previous paragraph is not correct, so where is the error in that reasoning? :???:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfMatchActions to show/hide meter

Post by balala »

qwerky wrote: February 4th, 2019, 8:05 pm But when, with the mouse, the skin is right-clicked and 'Refresh' chosen, does that cause all measures and meters to update? And if that is the case, shouldn't it take that same small amount of time for all the web measures to be parsed, and should not all of the icons disappear briefly?

Since they do not all disappear, obviously my previous paragraph is not correct, so where is the error in that reasoning? :???:
If the images were once downloaded, they are kept where they have been downloaded. Then on the second (or any later) refresh, the existing images are displayed immediately. On the first time you've loaded the skin, they were not, but probably you didn't notice this.
If you look for the downloaded images and remove them, you'll see what am I talking about. If on the WebParser measures which download the images you don't have set a DownloadFile option, you can set them, to easier can find the images and can remove them.
User avatar
qwerky
Posts: 182
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Using IfMatchActions to show/hide meter

Post by qwerky »

balala wrote: February 4th, 2019, 8:15 pm If the images were once downloaded, they are kept where they have been downloaded. Then on the second (or any later) refresh, the existing images are displayed immediately. On the first time you've loaded the skin, they were not, but probably you didn't notice this.
If you look for the downloaded images and remove them, you'll see what am I talking about. If on the WebParser measures which download the images you don't have set a DownloadFile option, you can set them, to easier can find the images and can remove them.
Sorry, I couldn't get "DownloadedFile" option to work; but that's okay--I went to the Windows Temp folder, and deleted them. The instant they were deleted, the icons in the skin went blank, and stayed blank until the skin was refreshed. But as soon as it was refreshed, the icons appeared instantly. (These are seven very small .gif's, so download time is probably insignificant.)

But I'm still trying to understand this. When refresh occurs, do all measures and meters update? And are you saying that when refreshed, the icon measures do in fact have a null value, but it is so short that one cannot see the icons disappear? But if the icons refresh that quickly, shouldn't the IfMatch operations be just as quick? Sorry, still quite confused on this one. :?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfMatchActions to show/hide meter

Post by balala »

qwerky wrote: February 4th, 2019, 9:11 pm When refresh occurs, do all measures and meters update?
Yes, they are.
qwerky wrote: February 4th, 2019, 9:11 pm And are you saying that when refreshed, the icon measures do in fact have a null value, but it is so short that one cannot see the icons disappear? But if the icons refresh that quickly, shouldn't the IfMatch operations be just as quick?
In fact all measures get a nul value when the skin is refreshed. The more a WebParser measure, which needs a while to connect and get the required information.
On the [msrGraphic1Icon] measure you've set the IfMatch to hide the icon while the measure returns nothing and show it up when the measure gets the value. So, when the skin is refreshed, and while the measure didn't succeeded getting the value, the meter is hidden.
User avatar
qwerky
Posts: 182
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Using IfMatchActions to show/hide meter

Post by qwerky »

balala wrote: February 4th, 2019, 9:28 pm Yes, they are.

In fact all measures get a nul value when the skin is refreshed.
Thanks for clarifying that.
The more a WebParser measure, which needs a while to connect and get the required information.
On the [msrGraphic1Icon] measure you've set the IfMatch to hide the icon while the measure returns nothing and show it up when the measure gets the value. So, when the skin is refreshed, and while the measure didn't succeeded getting the value, the meter is hidden.
This is clear. But, why does it take so much longer for the first icon to be shown (the hidden attribute removed), than it does for the other icons to be shown, since they also start with a null value at refresh?

And so, how to remedy it?
User avatar
qwerky
Posts: 182
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Using IfMatchActions to show/hide meter

Post by qwerky »

Actually, I've been watching the skin, and realized that the brief (undesired) hiding of the icon only occurs when the skin is manually refreshed, but not when the skin updates. So that makes the issue much less critical, though of course a solution is always desirable. :Whistle
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfMatchActions to show/hide meter

Post by balala »

qwerky wrote: February 4th, 2019, 9:48 pm This is clear. But, why does it take so much longer for the first icon to be shown (the hidden attribute removed), than it does for the other icons to be shown, since they also start with a null value at refresh?

And so, how to remedy it?
First please do post a complete code of the WebParser measures involved, including the URL and RegExp of the parent measure. I'd like to check what is going on.
qwerky wrote: February 4th, 2019, 10:21 pm Actually, I've been watching the skin, and realized that the brief (undesired) hiding of the icon only occurs when the skin is manually refreshed, but not when the skin updates. So that makes the issue much less critical, though of course a solution is always desirable. :Whistle
This is somehow obvious, I think. An once shown icon (image meter) isn't hidden while the WebParser measure updates.
User avatar
qwerky
Posts: 182
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Using IfMatchActions to show/hide meter

Post by qwerky »

balala wrote: February 5th, 2019, 2:31 pm First please do post a complete code of the WebParser measures involved, including the URL and RegExp of the parent measure. I'd like to check what is going on.
The URL's are:
SiteURL=https://weather.gc.ca and
PageURL=https://weather.gc.ca/city/pages/on-143_metric_e.html
from which you can go to any (Canadian) city you like. But I've been using some downloaded pages for testing, since I didn't want to be hitting that site with great frequency, and also because I wanted some static pages with known data. So I wanted to check the live data before responding, and had to wait for both daytime and night hours, to test each.

Here are the relevant sections of code:

Code: Select all

; regexBase strings:  1 Header, 2 Current Conditions, 3 Forecast Issue Time, 4 Graphic Forecast, 5 Detailed Forecast, 6 Normals, 7 Averages, 8 Yesterday
regexBase=(?siU)property="mainContentOfPage"(.*)</ul>(.*)<h2>Forecast.*Forecast(.*)>(.*)Detailed Forecast(.*)Normals:(.*)<h2>Averages(.*)<h2>Yesterday(.*)</details>

; regexHeader strings:  1 City, 2 Province, 3 Province Abbreviation, 4 Alert Name, 5 Alert URL, 6 Alert Text, 7 Past24URL
regexHeader=(?siU).*property="name">(.*), <abbr title="(.*)">(.*)</abbr>.*<a href="(.*)">(?(?=<).*</div>.*class.*>)(.*)</.*href="(.*)">Past

; regexCurrent strings:  1 Current Icon, 2 Rounded Temperature, 3 Observed Time, 4 Condition, 5 Pressure, 6 Tendency, 7 Precise Temperature, 8 Dew Point, 9 Humidity, 10 Wind Direction, 11 Wind Speed, 12 Wind Gust, 13 Wind Chill/Heat Index Label, 14 Wind Chill/Heat Index Unit, 15 Visibility
regexCurrent=(?siU).*<img.*src="(.*)".*<span.*>(.*)<.*<dt>Date:(.*)</dl>.*<dt>Condition:.*class.*>(.*)<.*<dt>Pressure:.*class.*>(.*)<.*<dt>Tendency:.*class.*>(.*)<.*<dt>Temperature:.*class.*>(.*)<.*<dt>Dew point:.*class.*>(.*)<.*<dt>Humidity:.*class.*>(.*)<.*<dt>Wind:.*class.*>(?(?=\R).*title.*>(.*)<.*>(.*)<(?(?=br).*>(.*)<).*href=".*>(.*)<.*class.*>(.*)<).*<dt>Visibility.*class.*>(.*)<

;regexObserved strings:  1 Hour(12), 2 Minute, 3 AM/PM, 4 Timezone, 5 Weekday, 6 Date, 7 Month, 8 Year
regexObserved=(?siU).*class.*>(.*):(.*) (.*) (.*) (.*) (.*) (.*) (.*)</dd>

;regexIssued strings:  1 Hour(12), 2 Minute, 3 AM/PM, 4 Timezone, 5 Weekday, 6 Date, 7 Month, 8 Year
regexIssued=(?siU).*issued: (.*):(.*) (.*) (.*) (.*) (.*) (.*) (.*)</span

; regexGraphic strings:  Day 1:   1 Weekday,  2 Date,  3 Month,  4 Icon,  5 High Temperature,  6 Day POP,   7 Day Text,  8 Low Temperature,  9 Night POP, 10 Night Text
                         Day 2:  11 Weekday, 12 Date, 13 Month, 14 Icon, 15 High Temperature, 16 Day POP,  17 Day Text, 18 Low Temperature, 19 Night POP, 20 Night Text
                         Day 3:  21 Weekday, 22 Date, 23 Month, 24 Icon, 25 High Temperature, 26 Day POP,  27 Day Text, 28 Low Temperature, 29 Night POP, 30 Night Text
                         Day 4:  31 Weekday, 32 Date, 33 Month, 34 Icon, 35 High Temperature, 36 Day POP,  37 Day Text, 38 Low Temperature, 39 Night POP, 40 Night Text
                         Day 5:  41 Weekday, 42 Date, 43 Month, 44 Icon, 45 High Temperature, 46 Day POP,  47 Day Text, 48 Low Temperature, 49 Night POP, 50 Night Text
                         Day 6:  51 Weekday, 52 Date, 53 Month, 54 Icon, 55 High Temperature, 56 Day POP,  57 Day Text, 58 Low Temperature, 59 Night POP, 60 Night Text
                         Day 7:  61 Weekday, 62 Date, 63 Month, 64 Icon, 65 High Temperature, 66 Day POP,  67 Day Text
regexGraphNight=.*div-row4.*title="min">(.*)<.*<p class=".*"(?(?= title).*>.*>(.*)<).*<p class.*>(.*)<
regexGraphDay=.*title="(.*)".*br>(\d+)[^\d].*title="(.*)".*<img.*src="(.*)".*title="max">(.*)<.*<p class=".*"(?(?= title).*>.*>(.*)<).*<p class.*>(.*)<
regexGraphic=(?siU).*div-row1 div-row-head(?(?=")#regexGraphDay#)#regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay#

; regexDetailed strings:  1 Day1, 2 Night1, 3 Day2, 4 Night2, 5 Day3, 6 Night3, 7 Day4, 8 Night4, 9 Day5, 10 Night5, 11 Day6, 12 Night6, 13 Day7
regexDetailDay=.*title.*<td>(.*)</td>
regexDetailed=(?siU).*title.*>(?(?=Today).*<td>(.*)</td>.*title).*<td>(.*)</td>#regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay##regexDetailDay#

; regexNormals strings:  1 Normal High, 2 Normal Low, 3 Sunrise, 4 Sunset
regexNormals=(?siU).*title="max">(.*)<.*title="min">(.*)<.*Sunrise.*<dd>([\d:]+)[^\d:].*Sunset.*<dd>([\d:]+)[^\d:]

; regexYesterday strings:  1 High, 2 Low, 3 Precipitation
regexYesterday=(?siU).*Maximum.*class.*>(.*)<.*Minimum.*class.*>(.*)<.*Precipitation.*class.*>(.*)<

; Main Site
; --------------------------------------

[msrSite]
Measure=WebParser
URL=#PageURL#
RegExp=#regexBase#
UpdateRate=#SiteUpdateRate#

; Graphic Forecast
; --------------------------------------

[msrGraphicGroup]
Measure=WebParser
URL=[msrSite]
RegExp=#regexGraphic#
StringIndex=#IndexGrahpic#

[msrGraphic1Icon]
Measure=WebParser
URL=#SiteURL#[msrGraphicGroup]
StringIndex=#GraphicIndexIcon#
Download=1
IfMatch=(?i)^.+$
IfMatchAction=[!ShowMeter mtrDay1Icon]
IfNotMatchAction=[!HideMeter mtrDay1Icon]

[msrGraphic2Icon]
Measure=WebParser
URL=#SiteURL#[msrGraphicGroup]
StringIndex=(#GraphicIndexIcon#+#GraphicIndexTotal#)
Download=1

[msrGraphic3Icon]
Measure=WebParser
URL=#SiteURL#[msrGraphicGroup]
StringIndex=(#GraphicIndexIcon#+(#GraphicIndexTotal#*2))
Download=1

; Display the Graphic Forecast.
; --------------------------------------

; Display the icon row.

[mtrDay1Icon]
Meter=Image
MeasureName=msrGraphic1Icon
X=#cell1Icon#
Y=#iconY#
W=#iconWidth#
H=#iconHeight#
SolidColor=#colorIconBG#

[mtrDay2Icon]
Meter=Image
MeasureName=msrGraphic2Icon
X=#cellWidth#r
Y=#iconY#
W=#iconWidth#
H=#iconHeight#
SolidColor=#colorIconBG#
The icons themselves don't look very nice when on a coloured background, so I set the skin icon backgrounds to white (SolidColor=#colorIconBG#).

It turns out, after testing live, that the same delayed hiding/showing didn't appear to be there, but feel free to test for yourself.

For my static testing pages, I used Save Page As... in a Firefox browser, on the above site. Firefox saves the page itself, and creates a same-named directory in which it saves all associated data, such as icons, etc. You can save some pages from there using your browser, if you'd like to test that.

Whether using live pages or saved pages, the displayed data is correct. The only issue is as discussed above in this thread. But as noted, I didn't see that issue on the live data, only on the saved pages. So in that respect, it is a non-issue, though I have no idea what causes it. :? :???: :confused:
Post Reply