Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16113
| From | Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Searching local pages for visible text |
| Date | 2012-09-21 21:35 +0100 |
| Organization | Home |
| Message-ID | <sv9UilHS+MXQFwEn@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <LKKNb4LHe6VQFwz7@invalid.uk.co.demon.merlyn.invalid> <2b9f3ead-7e38-429e-ba00-bd90794f43d4@o8g2000yqm.googlegroups.com> <ayRJl+GlehWQFwaN@invalid.uk.co.demon.merlyn.invalid> <b678b685-d200-47f6-9a04-684bda9c0b90@t4g2000vba.googlegroups.com> |
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>.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web