Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15938 > unrolled thread

Searching local pages for visible text

Started byDr J R Stockton <reply1237@merlyn.demon.co.uk.invalid>
First post2012-09-17 23:43 +0100
Last post2012-09-23 19:49 +0100
Articles 7 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  Searching local pages for visible text Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> - 2012-09-17 23:43 +0100
    Re: Searching local pages for visible text David Mark <dmark.cinsoft@gmail.com> - 2012-09-17 21:01 -0700
      Re: Searching local pages for visible text Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> - 2012-09-19 20:06 +0100
        Re: Searching local pages for visible text David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 17:09 -0700
          Re: Searching local pages for visible text Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> - 2012-09-21 21:35 +0100
            Re: Searching local pages for visible text David Mark <dmark.cinsoft@gmail.com> - 2012-09-21 16:33 -0700
              Re: Searching local pages for visible text Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> - 2012-09-23 19:49 +0100

#15938 — Searching local pages for visible text

FromDr J R Stockton <reply1237@merlyn.demon.co.uk.invalid>
Date2012-09-17 23:43 +0100
SubjectSearching local pages for visible text
Message-ID<LKKNb4LHe6VQFwz7@invalid.uk.co.demon.merlyn.invalid>
I can search the source files of my site in various ways, and for
example that finds 61 copies of the string "center".  That should occur
in HTML, in CSS, and in the display of a page section on spelling, only.

One way is my LINXCHEK.HTM, which spiders the local master copy of the
site, and so only sees what is actually in my site, and ignores other
files.  The search itself uses

function ReadText(DOC) { var Cnt, Txt
  Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8
  if (Txt) { if (WebPage.Name == "$.htm") alert(66)
    if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
      Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
      WebPage.Shibs = Cnt } } }

where DOC refers to the content of an iframe.

That searches the source text of the pages.

What I want now is to search the text which the browser displays in the
iframe into which the spidered pages are read.  There are too many pages
for it to be easy to display them in a browser and use its ordinary
Ctrl-F search.

Above, "center" is just an example; I actually want to search for "left"
and "right", of which there are many more, to consider whether I'm
describing parts of my pages in a way that is inappropriate for blind
readers.

There is no need to consider words which JavaScript has computed for
display, or whether a word is currently in a hidden element, etc.

Any suggestions?

-- 
 (c) John Stockton, nr London, UK.  For Mail, see Home Page.  Turnpike, WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.

[toc] | [next] | [standalone]


#15958

FromDavid Mark <dmark.cinsoft@gmail.com>
Date2012-09-17 21:01 -0700
Message-ID<2b9f3ead-7e38-429e-ba00-bd90794f43d4@o8g2000yqm.googlegroups.com>
In reply to#15938
On Sep 17, 6:44 pm, Dr J R Stockton
<reply1...@merlyn.demon.co.uk.invalid> wrote:
> I can search the source files of my site in various ways, and for
> example that finds 61 copies of the string "center".  That should occur
> in HTML, in CSS, and in the display of a page section on spelling, only.

Can you rephrase that?

>
> One way is my LINXCHEK.HTM, which spiders the local master copy of the
> site, and so only sees what is actually in my site, and ignores other
> files.  The search itself uses
>
> function ReadText(DOC) { var Cnt, Txt
>   Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8

Txt = DOC.body.textContent || DOC.body.innerText || '' // latter for
IE8-

>   if (Txt) { if (WebPage.Name == "$.htm") alert(66)
>     if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
>       Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
>       WebPage.Shibs = Cnt } } }
>
> where DOC refers to the content of an iframe.

I really hate your style, doc. :(

>
> That searches the source text of the pages.

If you say so.

>
> What I want now is to search the text which the browser displays in the
> iframe into which the spidered pages are read.  There are too many pages
> for it to be easy to display them in a browser and use its ordinary
> Ctrl-F search.

I sort of understood that.

>
> Above, "center" is just an example; I actually want to search for "left"
> and "right", of which there are many more, to consider whether I'm
> describing parts of my pages in a way that is inappropriate for blind
> readers.

Okay.

>
> There is no need to consider words which JavaScript has computed for
> display, or whether a word is currently in a hidden element, etc.

JS computed for display? Do you mean CSS?

>
> Any suggestions?
>

Not at this time (would just be guesswork at this point).

[toc] | [prev] | [next] | [standalone]


#16020

FromDr J R Stockton <reply1237@merlyn.demon.co.uk.invalid>
Date2012-09-19 20:06 +0100
Message-ID<ayRJl+GlehWQFwaN@invalid.uk.co.demon.merlyn.invalid>
In reply to#15958
In comp.lang.javascript message <2b9f3ead-7e38-429e-ba00-bd90794f43d4@o8
g2000yqm.googlegroups.com>, Mon, 17 Sep 2012 21:01:41, David Mark
<dmark.cinsoft@gmail.com> posted:

>On Sep 17, 6:44 pm, Dr J R Stockton
><reply1...@merlyn.demon.co.uk.invalid> wrote:
>> I can search the source files of my site in various ways, and for
>> example that finds 61 copies of the string "center".  That should occur
>> in HTML, in CSS, and in the display of a page section on spelling, only.
>
>Can you rephrase that?

Yes, but I write only for those who can read English, the language still
spoken in England.  Dutch and Danes, in particular, are very good at it.
See /via/ <http://www.merlyn.demon.co.uk/quotings.htm#FredHoyle>.


>> One way is my LINXCHEK.HTM, which spiders the local master copy of the
>> site, and so only sees what is actually in my site, and ignores other
>> files.  The search itself uses
>>
>> function ReadText(DOC) { var Cnt, Txt
>>   Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8
>
>Txt = DOC.body.textContent || DOC.body.innerText || '' // latter for
>IE8-

Well, that's an improvement; but not a very useful one.  It reminds me
of a DOS clone which had an error in comment - but not in code -
concerning the behaviour in the year AD 2400.  The code was written
after I replaced IE7.  Implemented, tested, for public release later
this evening.


>>   if (Txt) { if (WebPage.Name == "$.htm") alert(66)
>>     if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
>>       Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
>>       WebPage.Shibs = Cnt } } }
>>
>> where DOC refers to the content of an iframe.

H'mmm - I wonder what that alert was for ... especially as it does not
get called when $.htm is used, and that's the only case-independent
"$.htm" in the file, and the local $.htm is really $.HTM.


>I really hate your style, doc. :(
>
>>
>> That searches the source text of the pages.
>
>If you say so.

Proven to my continued satisfaction by test.


>> What I want now is to search the text which the browser displays in the
>> iframe into which the spidered pages are read.  There are too many pages
>> for it to be easy to display them in a browser and use its ordinary
>> Ctrl-F search.
>
>I sort of understood that.
>
>>
>> Above, "center" is just an example; I actually want to search for "left"
>> and "right", of which there are many more, to consider whether I'm
>> describing parts of my pages in a way that is inappropriate for blind
>> readers.
>
>Okay.
>
>>
>> There is no need to consider words which JavaScript has computed for
>> display, or whether a word is currently in a hidden element, etc.
>
>JS computed for display? Do you mean CSS?

No; CSS!=JS.  I mean words such as appear because of the likes of
        document.write(new Date())
or
        document.getElementById("DM").innerText =
          new Date().getMonth()-1 ? "Feb" : "notFeb"


>> Any suggestions?
>>
>
>Not at this time (would just be guesswork at this point).

Well, here's an approximately legal Web page :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><TITLE>JRS</TITLE></HEAD>
<BODY><center>centre</center></BODY>
</HTML>

With that loaded into <iframe ID=Z></iframe>, I have code which will see
one "centre" and two "center".  I want alternative code which will see
one "centre" and zero "center".

-- 
 (c) John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.
   Web  <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
 Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
 Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

[toc] | [prev] | [next] | [standalone]


#16025

FromDavid Mark <dmark.cinsoft@gmail.com>
Date2012-09-19 17:09 -0700
Message-ID<b678b685-d200-47f6-9a04-684bda9c0b90@t4g2000vba.googlegroups.com>
In reply to#16020
On Sep 19, 3:06 pm, Dr J R Stockton
<reply1...@merlyn.demon.co.uk.invalid> wrote:
> In comp.lang.javascript message <2b9f3ead-7e38-429e-ba00-bd90794f43d4@o8
> g2000yqm.googlegroups.com>, Mon, 17 Sep 2012 21:01:41, David Mark
> <dmark.cins...@gmail.com> posted:
>
> >On Sep 17, 6:44 pm, Dr J R Stockton
> ><reply1...@merlyn.demon.co.uk.invalid> wrote:
> >> I can search the source files of my site in various ways, and for
> >> example that finds 61 copies of the string "center".  That should occur
> >> in HTML, in CSS, and in the display of a page section on spelling, only.
>
> >Can you rephrase that?
>
> Yes, but I write only for those who can read English, the language still
> spoken in England.  Dutch and Danes, in particular, are very good at it.

You always say that, yet it adds nothing to the discussion. Bully for
the Dutch (and you). Still, if you want my help you are going to have
to clarify your introduction.

> See /via/ <http://www.merlyn.demon.co.uk/quotings.htm#FredHoyle>.
>
> >> One way is my LINXCHEK.HTM, which spiders the local master copy of the
> >> site, and so only sees what is actually in my site, and ignores other
> >> files.  The search itself uses
>
> >> function ReadText(DOC) { var Cnt, Txt
> >>   Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8
>
> >Txt = DOC.body.textContent || DOC.body.innerText || '' // latter for
> >IE8-
>
> Well, that's an improvement; but not a very useful one.

Isn't it? Your original code would evaluate to - undefined - for
elements bereft of text. Pardon me for trying, but I think '' is a
preferable result. Also, it's good to be accurate with your
commentary. You are the one (and safe to say the only one) that will
revisit it in the future.

> It reminds me
> of a DOS clone which had an error in comment - but not in code -
> concerning the behaviour in the year AD 2400.  The code was written
> after I replaced IE7.  Implemented, tested, for public release later
> this evening.

That's fascinating, but what does it have to do with... anything?

>
> >>   if (Txt) { if (WebPage.Name == "$.htm") alert(66)
> >>     if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
> >>       Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
> >>       WebPage.Shibs = Cnt } } }
>
> >> where DOC refers to the content of an iframe.
>
> H'mmm - I wonder what that alert was for ... especially as it does not
> get called when $.htm is used, and that's the only case-independent
> "$.htm" in the file, and the local $.htm is really $.HTM.

Who are you asking? I don't know what you were thinking when you wrote
this apparent nonsense.

>
> >I really hate your style, doc. :(
>
> >> That searches the source text of the pages.
>
> >If you say so.
>
> Proven to my continued satisfaction by test.

Test results prove *nothing* in this business. Either your logic is
correct or it isn't. We've been over this.

>
>
>
>
>
>
>
>
>
> >> What I want now is to search the text which the browser displays in the
> >> iframe into which the spidered pages are read.  There are too many pages
> >> for it to be easy to display them in a browser and use its ordinary
> >> Ctrl-F search.
>
> >I sort of understood that.
>
> >> Above, "center" is just an example; I actually want to search for "left"
> >> and "right", of which there are many more, to consider whether I'm
> >> describing parts of my pages in a way that is inappropriate for blind
> >> readers.
>
> >Okay.
>
> >> There is no need to consider words which JavaScript has computed for
> >> display, or whether a word is currently in a hidden element, etc.
>
> >JS computed for display? Do you mean CSS?
>
> No; CSS!=JS.  I mean words such as appear because of the likes of
>         document.write(new Date())
> or
>         document.getElementById("DM").innerText =
>           new Date().getMonth()-1 ? "Feb" : "notFeb"

Okay.

>
> >> Any suggestions?
>
> >Not at this time (would just be guesswork at this point).
>
> Well, here's an approximately legal Web page :

*groan*

>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <HTML>
> <HEAD><TITLE>JRS</TITLE></HEAD>
> <BODY><center>centre</center></BODY>
> </HTML>
>
> With that loaded into <iframe ID=Z></iframe>, I have code which will see
> one "centre" and two "center".  I want alternative code which will see
> one "centre" and zero "center".

Well why didn't you say so? That's a horse of another color. :)

As you are using textContent/innerText (as opposed to innerHTML),
there's no reason your code should see the two CENTER tags.

Please rewrite your example without the alerts (and other extraneous
nonsense) and resubmit.

[toc] | [prev] | [next] | [standalone]


#16113

FromDr J R Stockton <reply1237@merlyn.demon.co.uk.invalid>
Date2012-09-21 21:35 +0100
Message-ID<sv9UilHS+MXQFwEn@invalid.uk.co.demon.merlyn.invalid>
In reply to#16025
In comp.lang.javascript message <b678b685-d200-47f6-9a04-684bda9c0b90@t4
g2000vba.googlegroups.com>, Wed, 19 Sep 2012 17:09:57, David Mark
<dmark.cinsoft@gmail.com> posted:

>On Sep 19, 3:06 pm, Dr J R Stockton
><reply1...@merlyn.demon.co.uk.invalid> wrote:
>> In comp.lang.javascript message <2b9f3ead-7e38-429e-ba00-bd90794f43d4@o8
>> g2000yqm.googlegroups.com>, Mon, 17 Sep 2012 21:01:41, David Mark
>> <dmark.cins...@gmail.com> posted:
>>
>> >On Sep 17, 6:44 pm, Dr J R Stockton
>> ><reply1...@merlyn.demon.co.uk.invalid> wrote:
>> >> I can search the source files of my site in various ways, and for
>> >> example that finds 61 copies of the string "center".  That should occur
>> >> in HTML, in CSS, and in the display of a page section on spelling, only.
>>
>> >Can you rephrase that?
>>
>> Yes, but I write only for those who can read English, the language still
>> spoken in England.  Dutch and Danes, in particular, are very good at it.
>
>You always say that, yet it adds nothing to the discussion. Bully for
>the Dutch (and you). Still, if you want my help you are going to have
>to clarify your introduction.
>
>> See /via/ <http://www.merlyn.demon.co.uk/quotings.htm#FredHoyle>.

I don't suppose you did.  The recommended method is good advice for
Russians, and futile (but valid) for Americans.


>> >> One way is my LINXCHEK.HTM, which spiders the local master copy of the
>> >> site, and so only sees what is actually in my site, and ignores other
>> >> files.  The search itself uses
>>
>> >> function ReadText(DOC) { var Cnt, Txt
>> >>   Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8
>>
>> >Txt = DOC.body.textContent || DOC.body.innerText || '' // latter for
>> >IE8-
>>
>> Well, that's an improvement; but not a very useful one.
>
>Isn't it? Your original code would evaluate to - undefined - for
>elements bereft of text. Pardon me for trying, but I think '' is a
>preferable result. Also, it's good to be accurate with your
>commentary. You are the one (and safe to say the only one) that will
>revisit it in the future.

On closer inspection, I see that your suggestion amounts to more than
just altering "IE8" to "IE8-" - so it will need more thought.

But DOC is a reference to a document - the current document, which is
definitely not bereft of text, or that of another Web page, which,
should contain text.  Except, that is, for the local page $.htm, which
is a zero-byte file.  The only need, for a text-free page, is that the
page-handling code should reach the usual exit.  Which it will, as the
rest of the function starts with   if (Txt)   .  So no change needed.


>> It reminds me
>> of a DOS clone which had an error in comment - but not in code -
>> concerning the behaviour in the year AD 2400.  The code was written
>> after I replaced IE7.  Implemented, tested, for public release later
>> this evening.
>
>That's fascinating, but what does it have to do with... anything?

It should amuse (slightly) those with a sense of humour.


>> >>   if (Txt) { if (WebPage.Name == "$.htm") alert(66)
>> >>     if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
>> >>       Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
>> >>       WebPage.Shibs = Cnt } } }
>>
>> >> where DOC refers to the content of an iframe.
>>
>> H'mmm - I wonder what that alert was for ... especially as it does not
>> get called when $.htm is used, and that's the only case-independent
>> "$.htm" in the file, and the local $.htm is really $.HTM.
>
>Who are you asking? I don't know what you were thinking when you wrote
>this apparent nonsense.

It tells you.  And the absence of any question mark implies the absence
of any question, at least in English.


>> >> That searches the source text of the pages.
>>
>> >If you say so.
>>
>> Proven to my continued satisfaction by test.
>
>Test results prove *nothing* in this business. Either your logic is
>correct or it isn't. We've been over this.

Test results can certainly prove that something, however plausible,  is
wrong.  Consider the Pascal program, on an HP286/12 :
                begin writeln(sqrt(2)) end.
which looks fairly infallible.  It is a simplification of a very much
larger program, which had been working well and then failed.  The
failure continued when the program was reduced to the above.

The actual cause was a quad serial port card with a faulty address
decoder, which interfered with conversations between the CPU and the
FPU, then separate ICs.

Test results can prove a lot.


>> >> What I want now is to search the text which the browser displays in the
>> >> iframe into which the spidered pages are read.  There are too many pages
>> >> for it to be easy to display them in a browser and use its ordinary
>> >> Ctrl-F search.
>>
>> >I sort of understood that.
>>
>> >> Above, "center" is just an example; I actually want to search for "left"
>> >> and "right", of which there are many more, to consider whether I'm
>> >> describing parts of my pages in a way that is inappropriate for blind
>> >> readers.
>>
>> >Okay.
>>
>> >> There is no need to consider words which JavaScript has computed for
>> >> display, or whether a word is currently in a hidden element, etc.
>>
>> >JS computed for display? Do you mean CSS?
>>
>> No; CSS!=JS.  I mean words such as appear because of the likes of
>>         document.write(new Date())
>> or
>>         document.getElementById("DM").innerText =
>>           new Date().getMonth()-1 ? "Feb" : "notFeb"
>
>Okay.
>
>>
>> >> Any suggestions?
>>
>> >Not at this time (would just be guesswork at this point).
>>
>> Well, here's an approximately legal Web page :
>
>*groan*

The W3 tester, called by Opera, gave it a reluctant green.

>>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <HTML>
>> <HEAD><TITLE>JRS</TITLE></HEAD>
>> <BODY><center>centre</center></BODY>
>> </HTML>
>>
>> With that loaded into <iframe ID=Z></iframe>, I have code which will see
>> one "centre" and two "center".  I want alternative code which will see
>> one "centre" and zero "center".
>
>Well why didn't you say so? That's a horse of another color. :)
>
>As you are using textContent/innerText (as opposed to innerHTML),
>there's no reason your code should see the two CENTER tags.

That sounds plausible, and falsely indicates a potential explanation.
But, since I want to be able both to find and to not find "center" in
tags, the implication is that my question needs to be reversed.

That has unveiled a bug in Google Translate : it claims to be able to
translate into English, but currently it translates into American
instead.  One page, therefore, did contain a visible but incorrect
"center".

Also, I think, that textContent/innerText includes the content of
<script> elements, which are liable to use "center" to set element
styles.


Progress is being made, even if sometimes only in an entirely different
direction.


Probably

function ReadText(DOC) { var Cnt, Txt
  Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8-
  if (Txt) { if (WebPage.Name == "$.htm") alert(66)
    if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
      Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
      WebPage.Shibs = Cnt }
    if (WkDy) DayCheck3(Txt, WebPage.Name) } }

needs to have its body replaced by something which CAN use textContent
(in order to scan in script strings and comment, for example) and which
CAN traverse the entire DOM tree and examine with ShibRE only elements
of types currently desired.  That would, for example, permit scanning
the scripts, only, of the page set for "case" or "pound".  DayCheck3
should always use the full text content.


-- 
 (c) John Stockton, nr London, UK.  For Mail, see Home Page.  Turnpike, WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.

[toc] | [prev] | [next] | [standalone]


#16115

FromDavid Mark <dmark.cinsoft@gmail.com>
Date2012-09-21 16:33 -0700
Message-ID<6cfbd1b7-f5fa-4df5-9a4a-f82b573210db@u9g2000vbm.googlegroups.com>
In reply to#16113
On Sep 21, 4:35 pm, Dr J R Stockton
<reply1...@merlyn.demon.co.uk.invalid> wrote:
> In comp.lang.javascript message <b678b685-d200-47f6-9a04-684bda9c0b90@t4
> g2000vba.googlegroups.com>, Wed, 19 Sep 2012 17:09:57, David Mark
> <dmark.cins...@gmail.com> posted:
>
>
>
>
>
>
>
>
>
> >On Sep 19, 3:06 pm, Dr J R Stockton
> ><reply1...@merlyn.demon.co.uk.invalid> wrote:
> >> In comp.lang.javascript message <2b9f3ead-7e38-429e-ba00-bd90794f43d4@o8
> >> g2000yqm.googlegroups.com>, Mon, 17 Sep 2012 21:01:41, David Mark
> >> <dmark.cins...@gmail.com> posted:
>
> >> >On Sep 17, 6:44 pm, Dr J R Stockton
> >> ><reply1...@merlyn.demon.co.uk.invalid> wrote:
> >> >> I can search the source files of my site in various ways, and for
> >> >> example that finds 61 copies of the string "center".  That should occur
> >> >> in HTML, in CSS, and in the display of a page section on spelling, only.
>
> >> >Can you rephrase that?
>
> >> Yes, but I write only for those who can read English, the language still
> >> spoken in England.  Dutch and Danes, in particular, are very good at it.
>
> >You always say that, yet it adds nothing to the discussion. Bully for
> >the Dutch (and you). Still, if you want my help you are going to have
> >to clarify your introduction.
>
> >> See /via/ <http://www.merlyn.demon.co.uk/quotings.htm#FredHoyle>.
>
> I don't suppose you did.  The recommended method is good advice for
> Russians, and futile (but valid) for Americans.

Whatever.

>
>
>
>
>
>
>
>
>
> >> >> One way is my LINXCHEK.HTM, which spiders the local master copy of the
> >> >> site, and so only sees what is actually in my site, and ignores other
> >> >> files.  The search itself uses
>
> >> >> function ReadText(DOC) { var Cnt, Txt
> >> >>   Txt = DOC.body.textContent || DOC.body.innerText // latter for IE8
>
> >> >Txt = DOC.body.textContent || DOC.body.innerText || '' // latter for
> >> >IE8-
>
> >> Well, that's an improvement; but not a very useful one.
>
> >Isn't it? Your original code would evaluate to - undefined - for
> >elements bereft of text. Pardon me for trying, but I think '' is a
> >preferable result. Also, it's good to be accurate with your
> >commentary. You are the one (and safe to say the only one) that will
> >revisit it in the future.
>
> On closer inspection, I see that your suggestion amounts to more than
> just altering "IE8" to "IE8-" - so it will need more thought.

There's a bit more code too, but I see where you are headed.

>
> But DOC is a reference to a document - the current document, which is
> definitely not bereft of text, or that of another Web page, which,
> should contain text.

Should.

> Except, that is, for the local page $.htm, which
> is a zero-byte file.

That would be one case, but certainly not the only case.

> The only need, for a text-free page, is that the
> page-handling code should reach the usual exit.  Which it will, as the
> rest of the function starts with   if (Txt)   .  So no change needed.

If all you use Txt for is that boolean conversion test and whatever it
wraps (which I may well have missed in all of the alerts) then fine.
Logically But such awkwardness needs a comment for sure. A variable
called "Txt" should be expected to be a string (if lowercase "txt"
anyway, your "Txt" looks like a constructor function).

>
> >> It reminds me
> >> of a DOS clone which had an error in comment - but not in code -
> >> concerning the behaviour in the year AD 2400.  The code was written
> >> after I replaced IE7.  Implemented, tested, for public release later
> >> this evening.
>
> >That's fascinating, but what does it have to do with... anything?
>
> It should amuse (slightly) those with a sense of humour.

I think you've gone to the DOS clock well one too many times myself. :
\

>
> >> >>   if (Txt) { if (WebPage.Name == "$.htm") alert(66)
> >> >>     if (HasShib) { Cnt =  (Txt.match(ShibRE) || "").length
> >> >>       Form.TA2.value += SpcsTo(Cnt, 4) + " shibboleths\n"
> >> >>       WebPage.Shibs = Cnt } } }
>
> >> >> where DOC refers to the content of an iframe.
>
> >> H'mmm - I wonder what that alert was for ... especially as it does not
> >> get called when $.htm is used, and that's the only case-independent
> >> "$.htm" in the file, and the local $.htm is really $.HTM.
>
> >Who are you asking? I don't know what you were thinking when you wrote
> >this apparent nonsense.
>
> It tells you.  And the absence of any question mark implies the absence
> of any question, at least in English.

Well, you pontificated.

>
> >> >> That searches the source text of the pages.
>
> >> >If you say so.
>
> >> Proven to my continued satisfaction by test.
>
> >Test results prove *nothing* in this business. Either your logic is
> >correct or it isn't. We've been over this.
>
> Test results can certainly prove that something, however plausible,  is
> wrong.  Consider the Pascal program, on an HP286/12 :
>                 begin writeln(sqrt(2)) end.

I should have said *positive* test results (like yours) prove nothing.
A negative result certainly proves that a script is fallible in at
least one environment, so something must be wrong with its logic. But
test fifty browsers and you still haven't proven the logic is correct.

> which looks fairly infallible.  It is a simplification of a very much
> larger program, which had been working well and then failed.  The
> failure continued when the program was reduced to the above.

Yes...

>
> The actual cause was a quad serial port card with a faulty address
> decoder, which interfered with conversations between the CPU and the
> FPU, then separate ICs.



>
> Test results can prove a lot.

They can't prove that scripts "work", which is what you were satisfied
you had proven with your positive test results.


>
>
>
>
>
>
>
>
>
> >> >> What I want now is to search the text which the browser displays in the
> >> >> iframe into which the spidered pages are read.  There are too many pages
> >> >> for it to be easy to display them in a browser and use its ordinary
> >> >> Ctrl-F search.
>
> >> >I sort of understood that.
>
> >> >> Above, "center" is just an example; I actually want to search for "left"
> >> >> and "right", of which there are many more, to consider whether I'm
> >> >> describing parts of my pages in a way that is inappropriate for blind
> >> >> readers.
>
> >> >Okay.
>
> >> >> There is no need to consider words which JavaScript has computed for
> >> >> display, or whether a word is currently in a hidden element, etc.
>
> >> >JS computed for display? Do you mean CSS?
>
> >> No; CSS!=JS.  I mean words such as appear because of the likes of
> >>         document.write(new Date())
> >> or
> >>         document.getElementById("DM").innerText =
> >>           new Date().getMonth()-1 ? "Feb" : "notFeb"
>
> >Okay.
>
> >> >> Any suggestions?
>
> >> >Not at this time (would just be guesswork at this point).
>
> >> Well, here's an approximately legal Web page :
>
> >*groan*
>
> The W3 tester, called by Opera, gave it a reluctant green.

Fair enough.

>
>
>
>
>
>
>
>
>
>
>
> >> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> >> "http://www.w3.org/TR/html4/loose.dtd">
> >> <HTML>
> >> <HEAD><TITLE>JRS</TITLE></HEAD>
> >> <BODY><center>centre</center></BODY>
> >> </HTML>
>
> >> With that loaded into <iframe ID=Z></iframe>, I have code which will see
> >> one "centre" and two "center".  I want alternative code which will see
> >> one "centre" and zero "center".
>
> >Well why didn't you say so? That's a horse of another color. :)
>
> >As you are using textContent/innerText (as opposed to innerHTML),
> >there's no reason your code should see the two CENTER tags.
>
> That sounds plausible, and falsely indicates a potential explanation.
> But, since I want to be able both to find and to not find "center" in
> tags, the implication is that my question needs to be reversed.
>
> That has unveiled a bug in Google Translate : it claims to be able to
> translate into English, but currently it translates into American
> instead.  One page, therefore, did contain a visible but incorrect
> "center".

I'm losing interest now. Time constraints. Good luck with it.

[toc] | [prev] | [next] | [standalone]


#16133

FromDr J R Stockton <reply1237@merlyn.demon.co.uk.invalid>
Date2012-09-23 19:49 +0100
Message-ID<Y1w50WJkm1XQFwTD@invalid.uk.co.demon.merlyn.invalid>
In reply to#16115
In comp.lang.javascript message <6cfbd1b7-f5fa-4df5-9a4a-f82b573210db@u9
g2000vbm.googlegroups.com>, Fri, 21 Sep 2012 16:33:54, David Mark
<dmark.cinsoft@gmail.com> posted:

>On Sep 21, 4:35 pm, Dr J R Stockton
><reply1...@merlyn.demon.co.uk.invalid> wrote:
>> In comp.lang.javascript message <b678b685-d200-47f6-9a04-684bda9c0b90@t4
>> g2000vba.googlegroups.com>, Wed, 19 Sep 2012 17:09:57, David Mark
>> <dmark.cins...@gmail.com> posted:

>> >> >> One way is my LINXCHEK.HTM, which spiders the local master copy of the
>> >> >> site, and so only sees what is actually in my site, and ignores other
>> >> >> files.  The search itself uses

>> But DOC is a reference to a document - the current document, which is
>> definitely not bereft of text, or that of another Web page, which,
>> should contain text.
>
>Should.
>
>> Except, that is, for the local page $.htm, which
>> is a zero-byte file.
>
>That would be one case, but certainly not the only case.

The files will, $.htm apart, all be local master copies of Web pages; in
the most important case (mine) those copies will all have passed the
most important test at all - that their display is not blank, and
contains at least some text of pure HTML origin.


>> The only need, for a text-free page, is that the
>> page-handling code should reach the usual exit.  Which it will, as the
>> rest of the function starts with   if (Txt)   .  So no change needed.
>
>If all you use Txt for is that boolean conversion test and whatever it
>wraps (which I may well have missed in all of the alerts) then fine.
>Logically

Essentially, the function counts appearances of a shibboleth and also
checks the validity of all standard-form instances of 'Date DoW'.  Empty
Txt can contain neither.


>> >> >> That searches the source text of the pages.
>>
>> >> >If you say so.
>>
>> >> Proven to my continued satisfaction by test.
>>
>> >Test results prove *nothing* in this business. Either your logic is
>> >correct or it isn't. We've been over this.

>> Test results can prove a lot.
>
>They can't prove that scripts "work", which is what you were satisfied
>you had proven with your positive test results.

"Proofs" do not prove anything, until the arguments have been reviewed
carefully by several independent experts.  Euler got an Easter algorithm
from Clavius - and needed a second attempt years later to get it right.
Andrew Wiles' initial FLT proof took a year or two to fix, too : see
book by Simon Singh (recommended).

Otherwise, testing is more reliable.



>I'm losing interest now. Time constraints. Good luck with it.

When you solve that problem, please explain how!

-- 
 (c) John Stockton, nr London, UK.  Mail via homepage.  Turnpike v6.05  MIME.
  Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
  Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web