Sent: Thursday, August 25, 2005 11:11 AM
Subject: Re: [Javascript] Iframe Permission Denied
> Am I right in thinking that JavaScript prevents two frames which are
> displaying content from different domains from interacting?
>
> It wuld seem to be a reasonable security limitation if so.
>
> Matt
>
>
>
> SkyScanner wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > When running the above, the Yahoo page loads into my Iframe OK, but
after
> > clicking on the alert, instead of the Google page loading, I get an
error
> > 'Permission denied'.
> >
> > How can I fix this, please?
> >
> > Tim in Ireland
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> > --
> > This email has been verified as Virus free
> > Virus Protection and more available at http://www.plus.net
> >
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
From javascript at mattbarton.org Thu Aug 25 08:55:00 2005
From: javascript at mattbarton.org (Matt Barton)
Date: Thu, 25 Aug 2005 14:55:00 +0100
Subject: [Javascript] Iframe Permission Denied
In-Reply-To: <002901c5a978$df6a9140$e9522ec2@ic7g>
References: <712824a90508250055449248c3@mail.gmail.com><000d01c5a95c$bea99f80$d56bdac3@ic7g><430D993D.1070906@mattbarton.org>
<002901c5a978$df6a9140$e9522ec2@ic7g>
Message-ID: <430DCDB4.5000508@mattbarton.org>
Well, it strikes me that you really ought to be able to do that, but I'm
afraid I don't know for definate that you can.
I'd normally have a little investigation into something like that, but
I'm far too busy with work and listening to Test Match Special to fit it
in, sorry.
Matt
SkyScanner wrote:
> So is there no way for javascript to load a new page into an Iframe? I am
> already displaying a page from a remote site in my Iframe.
>
> http://www.mapability.com/ei8ic/aprs/ireland/ei_aprs.html
>
> It is the table, lower down the page. Here is the initial link:
>
>
>
> I need to load a new page from the same remote site into that Iframe when a
> form button has been clicked and some javascript has constructed the new
> URL.
>
> Tim in Ireland.
>
> ----- Original Message -----
> From: "Matt Barton"
> To: "[JavaScript List]"
> Sent: Thursday, August 25, 2005 11:11 AM
> Subject: Re: [Javascript] Iframe Permission Denied
>
>
>
>>Am I right in thinking that JavaScript prevents two frames which are
>>displaying content from different domains from interacting?
>>
>>It wuld seem to be a reasonable security limitation if so.
>>
>>Matt
>>
>>
>>
>>SkyScanner wrote:
>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>When running the above, the Yahoo page loads into my Iframe OK, but
>
> after
>
>>>clicking on the alert, instead of the Google page loading, I get an
>
> error
>
>>>'Permission denied'.
>>>
>>>How can I fix this, please?
>>>
>>>Tim in Ireland
>>>
>>>_______________________________________________
>>>Javascript mailing list
>>>Javascript at LaTech.edu
>>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>>--
>>>This email has been verified as Virus free
>>>Virus Protection and more available at http://www.plus.net
>>>
>>
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> --
> This email has been verified as Virus free
> Virus Protection and more available at http://www.plus.net
>
From wdlists at triche-osborne.com Thu Aug 25 09:10:11 2005
From: wdlists at triche-osborne.com (Triche Osborne)
Date: Thu, 25 Aug 2005 09:10:11 -0500
Subject: [Javascript] Comparing Strings
In-Reply-To: <712824a90508250326488d5eba@mail.gmail.com>
References: <712824a90508250055449248c3@mail.gmail.com> <3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk>
<712824a90508250326488d5eba@mail.gmail.com>
Message-ID: <430DD143.4010505@triche-osborne.com>
Timothy White wrote:
>
> So what should I use instead of innerHTML?
>
Kinda depends on how your XHTML is structured, but let's say you have a
DIV, thus:
Text to be replaced.
You'd do something like:
var replacementText = "Hi there!";
var theNode = document.getElementById(nodeId);
theNode.firstChild.data = replacementText;
Triche
From weirdit at gmail.com Thu Aug 25 09:25:36 2005
From: weirdit at gmail.com (Timothy White)
Date: Thu, 25 Aug 2005 22:25:36 +0800
Subject: [Javascript] Comparing Strings
In-Reply-To: <430DD143.4010505@triche-osborne.com>
References: <712824a90508250055449248c3@mail.gmail.com>
<3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk>
<712824a90508250326488d5eba@mail.gmail.com>
<430DD143.4010505@triche-osborne.com>
Message-ID: <712824a90508250725749e3d3@mail.gmail.com>
On 8/25/05, Triche Osborne wrote:
> Timothy White wrote:
> >
> > So what should I use instead of innerHTML?
> >
>
> Kinda depends on how your XHTML is structured, but let's say you have a
> DIV, thus:
>
> Text to be replaced.
>
> You'd do something like:
>
> var replacementText = "Hi there!";
> var theNode = document.getElementById(nodeId);
> theNode.firstChild.data = replacementText;
Hmmm. Well that doesn't work cause I want to put HTML in there.
Is there any other way for HTML? Or is it just InnerHTML?
Otherwise I might try formatting the data differently.
Thanks
Tim
From wdlists at triche-osborne.com Thu Aug 25 09:38:37 2005
From: wdlists at triche-osborne.com (Triche Osborne)
Date: Thu, 25 Aug 2005 09:38:37 -0500
Subject: [Javascript] Comparing Strings - Correction
In-Reply-To: <430DD143.4010505@triche-osborne.com>
References: <712824a90508250055449248c3@mail.gmail.com> <3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk> <712824a90508250326488d5eba@mail.gmail.com>
<430DD143.4010505@triche-osborne.com>
Message-ID: <430DD7ED.8000600@triche-osborne.com>
Oops! I had this in a testing function and forgot to replace the passed
variable with its literal.
This line:
> var theNode = document.getElementById(nodeId);
Should read:
var theNode = document.getElementById("replaceThis");
The corrected version would look like this:
Text to be replaced.
var replacementText = "Hi there!";
var theNode = document.getElementById("replaceThis");
theNode.firstChild.data = replacementText;
Sorry for the confusion!
Triche
From Travis.Falls at thehartford.com Thu Aug 25 10:02:13 2005
From: Travis.Falls at thehartford.com (Falls, Travis D (HTSC, CASD))
Date: Thu, 25 Aug 2005 11:02:13 -0400
Subject: [Javascript] Change Extensions
Message-ID: <951967FCF5C4D211B0610008C75D2AA12C2E83DC@ct01excmb01.thehartford.com>
I am trying to write a javascript method that will use regular expressions
to figure out the file extension of a file name (String) and change it.
Basically I need to find ".*" and replace it with ".working" I don't know
how to write this regular expression though. Can someone explain how to do
this? (not just send over the regular expression I want to learn how to do
this). Thanks.
Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 |
travis.falls at thehartford.com
*************************************************************************
PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information. If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited. If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************
From wdlists at triche-osborne.com Thu Aug 25 10:17:03 2005
From: wdlists at triche-osborne.com (Triche Osborne)
Date: Thu, 25 Aug 2005 10:17:03 -0500
Subject: [Javascript] Comparing Strings
In-Reply-To: <712824a90508250725749e3d3@mail.gmail.com>
References: <712824a90508250055449248c3@mail.gmail.com> <3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk> <712824a90508250326488d5eba@mail.gmail.com> <430DD143.4010505@triche-osborne.com>
<712824a90508250725749e3d3@mail.gmail.com>
Message-ID: <430DE0EF.3050506@triche-osborne.com>
Timothy White wrote:
>
> Hmmm. Well that doesn't work cause I want to put HTML in there.
> Is there any other way for HTML? Or is it just InnerHTML?
> Otherwise I might try formatting the data differently.
>
That depends on how consistently formatted your replacement stuff is, or
how easily you can get at the formatting. For example, if you want to
replace the text in this DIV:
Text to be replaced.
With this:
"Hi there!"
It requires something like this:
var replacementText = document.createTextNode("Hi there!");
var newP = document.createElement('p');
var theNode = document.getElementById("replaceThis");
theNode.removeChild(theNode.firstChild);
newP.appendChild(replacementText);
theNode.appendChild(newP);
If your formatting is inconsistent--different elements, some with class
codes, etc.--you could store it in array form and use the array elements
to build the replacement. For instance, you might have:
var replacements = new Array();
replacements[0] = ("Hi there!/span");
replacements[1] = ("Bonjour!/"p","span"/"error");
. . . where the slash and comma provide split markers, or you can use a
multi-dim array instead. You can create your own schema for it. As long
as it's consistent, it will give you something to hang your hat on when
you're processing.
Triche
From skyscanner at eircom.net Thu Aug 25 10:32:17 2005
From: skyscanner at eircom.net (SkyScanner)
Date: Thu, 25 Aug 2005 16:32:17 +0100
Subject: [Javascript] Iframe Permission Denied
References: <712824a90508250055449248c3@mail.gmail.com><000d01c5a95c$bea99f80$d56bdac3@ic7g><430D993D.1070906@mattbarton.org><002901c5a978$df6a9140$e9522ec2@ic7g>
<430DCDB4.5000508@mattbarton.org>
Message-ID: <001201c5a98a$39fba020$496bdac3@ic7g>
Found the answer in the end:
window.frames['iFrame_name'].location = new_url;
Thanks for everyone's help.
Tim in Ireland.
----- Original Message -----
From: "Matt Barton"
To: "[JavaScript List]"
Sent: Thursday, August 25, 2005 2:55 PM
Subject: Re: [Javascript] Iframe Permission Denied
> Well, it strikes me that you really ought to be able to do that, but I'm
> afraid I don't know for definate that you can.
>
> I'd normally have a little investigation into something like that, but
> I'm far too busy with work and listening to Test Match Special to fit it
> in, sorry.
>
> Matt
>
> SkyScanner wrote:
> > So is there no way for javascript to load a new page into an Iframe? I
am
> > already displaying a page from a remote site in my Iframe.
> >
> > http://www.mapability.com/ei8ic/aprs/ireland/ei_aprs.html
> >
> > It is the table, lower down the page. Here is the initial link:
> >
> >
> >
> > I need to load a new page from the same remote site into that Iframe
when a
> > form button has been clicked and some javascript has constructed the new
> > URL.
> >
> > Tim in Ireland.
> >
> > ----- Original Message -----
> > From: "Matt Barton"
> > To: "[JavaScript List]"
> > Sent: Thursday, August 25, 2005 11:11 AM
> > Subject: Re: [Javascript] Iframe Permission Denied
> >
> >
> >
> >>Am I right in thinking that JavaScript prevents two frames which are
> >>displaying content from different domains from interacting?
> >>
> >>It wuld seem to be a reasonable security limitation if so.
> >>
> >>Matt
> >>
> >>
> >>
> >>SkyScanner wrote:
> >>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>When running the above, the Yahoo page loads into my Iframe OK, but
> >
> > after
> >
> >>>clicking on the alert, instead of the Google page loading, I get an
> >
> > error
> >
> >>>'Permission denied'.
> >>>
> >>>How can I fix this, please?
> >>>
> >>>Tim in Ireland
> >>>
> >>>_______________________________________________
> >>>Javascript mailing list
> >>>Javascript at LaTech.edu
> >>>https://lists.LaTech.edu/mailman/listinfo/javascript
> >>>--
> >>>This email has been verified as Virus free
> >>>Virus Protection and more available at http://www.plus.net
> >>>
> >>
> >>_______________________________________________
> >>Javascript mailing list
> >>Javascript at LaTech.edu
> >>https://lists.LaTech.edu/mailman/listinfo/javascript
> >>
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> > --
> > This email has been verified as Virus free
> > Virus Protection and more available at http://www.plus.net
> >
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
From wdlists at triche-osborne.com Thu Aug 25 12:06:19 2005
From: wdlists at triche-osborne.com (Triche Osborne)
Date: Thu, 25 Aug 2005 12:06:19 -0500
Subject: [Javascript] Comparing Strings
In-Reply-To: <430DE0EF.3050506@triche-osborne.com>
References: <712824a90508250055449248c3@mail.gmail.com> <3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk> <712824a90508250326488d5eba@mail.gmail.com> <430DD143.4010505@triche-osborne.com> <712824a90508250725749e3d3@mail.gmail.com>
<430DE0EF.3050506@triche-osborne.com>
Message-ID: <430DFA8B.7010509@triche-osborne.com>
Triche Osborne wrote:
>
> var replacements = new Array();
> replacements[0] = ("Hi there!/span");
> replacements[1] = ("Bonjour!/"p","span"/"error");
>
Nice. That last should have been:
replacements[1] = ("Bonjour!/p,span/error");
Sorry. I've been a bit distracted by a pet emergency for a couple of
days. But since you're a seasoned programmer (even if not JS), I expect
you get my drift about use of the array despite the quote error.
Triche
From shawn.milo at gmail.com Thu Aug 25 12:46:40 2005
From: shawn.milo at gmail.com (Shawn Milo)
Date: Thu, 25 Aug 2005 13:46:40 -0400
Subject: [Javascript] Change Extensions
In-Reply-To: <951967FCF5C4D211B0610008C75D2AA12C2E83DC@ct01excmb01.thehartford.com>
References: <951967FCF5C4D211B0610008C75D2AA12C2E83DC@ct01excmb01.thehartford.com>
Message-ID: <2dc0c81b050825104662aeaec2@mail.gmail.com>
On 8/25/05, Falls, Travis D (HTSC, CASD) wrote:
> I am trying to write a javascript method that will use regular expressions
> to figure out the file extension of a file name (String) and change it.
> Basically I need to find ".*" and replace it with ".working" I don't know
> how to write this regular expression though. Can someone explain how to do
> this? (not just send over the regular expression I want to learn how to do
> this). Thanks.
Travis,
You want a regex that says:
"Find the last period, then remember everything after that."
In regex syntax, a period is a reserved character, so you have to
"escape" it with
a backslash (so it would be \. instead of .).
So you have: /\./ (A regex is put inside forward slashes.)
Now, you want to make sure it's the last period. Easy. The special
character '.' (the period) matches any character. The asterisk (*)
matches zero or more. So look for zero or more characters followed by
a period.
/.*\./ (Note that due to "greedy matching," the .* will match any
and all periods up to the last, so you don't have to worry about it
stopping early.)
Now, you want to find everything after the last period. Easy, another '.*'.
/.*\..*/
Surround the part you want to replace with parenthesis.
/.*\.(.*)/
Use good clean syntax, and specify the beginning of line (^) and end
of line ($).
/^.*\.(.*)$/
So if you want to remember what it was before you replace it, you can
reference it like this:
oldExt = = strng.replace(/^.*\.(.*)$/, '$1') ($1 refers to
whatever is in the first set of parenthesis.
Change the position of the parenthesis to capture the filename minus
the extention:
/^(.*\.).*$/
newName = strng.replace(/^(.*\.).*$/, '$1.working') (The period
needn't be escaped here.)
Use a better regex, and match both:
/^(.*\.)(.*)$/
oldExt = = strng.replace(/^(.*\.)(.*)$/, '$2')
newName = strng.replace(/^(.*\.)(.*)$/, '$1.working')
Please let me know if you have any questions. I just typed all of this
off of the top of my head, so it's possible there will be a syntax
error or something. But I'll help you work through any problems (yours
or mine).
Shawn
From Travis.Falls at thehartford.com Thu Aug 25 13:22:52 2005
From: Travis.Falls at thehartford.com (Falls, Travis D (HTSC, CASD))
Date: Thu, 25 Aug 2005 14:22:52 -0400
Subject: [Javascript] Change Extensions
Message-ID: <951967FCF5C4D211B0610008C75D2AA12C2E83E9@ct01excmb01.thehartford.com>
Shawn,
That was an amazing explanation; thank you for taking the time to write that
up. I am sure you have gotten me far enough to figure out the rest. I will
post the final solution. You really are a regular expression guru.
Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 |
travis.falls at thehartford.com
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Shawn Milo
Sent: Thursday, August 25, 2005 1:47 PM
To: [JavaScript List]
Subject: Re: [Javascript] Change Extensions
On 8/25/05, Falls, Travis D (HTSC, CASD)
wrote:
> I am trying to write a javascript method that will use regular expressions
> to figure out the file extension of a file name (String) and change it.
> Basically I need to find ".*" and replace it with ".working" I don't know
> how to write this regular expression though. Can someone explain how to
do
> this? (not just send over the regular expression I want to learn how to do
> this). Thanks.
Travis,
You want a regex that says:
"Find the last period, then remember everything after that."
In regex syntax, a period is a reserved character, so you have to
"escape" it with
a backslash (so it would be \. instead of .).
So you have: /\./ (A regex is put inside forward slashes.)
Now, you want to make sure it's the last period. Easy. The special
character '.' (the period) matches any character. The asterisk (*)
matches zero or more. So look for zero or more characters followed by
a period.
/.*\./ (Note that due to "greedy matching," the .* will match any
and all periods up to the last, so you don't have to worry about it
stopping early.)
Now, you want to find everything after the last period. Easy, another '.*'.
/.*\..*/
Surround the part you want to replace with parenthesis.
/.*\.(.*)/
Use good clean syntax, and specify the beginning of line (^) and end
of line ($).
/^.*\.(.*)$/
So if you want to remember what it was before you replace it, you can
reference it like this:
oldExt = = strng.replace(/^.*\.(.*)$/, '$1') ($1 refers to
whatever is in the first set of parenthesis.
Change the position of the parenthesis to capture the filename minus
the extention:
/^(.*\.).*$/
newName = strng.replace(/^(.*\.).*$/, '$1.working') (The period
needn't be escaped here.)
Use a better regex, and match both:
/^(.*\.)(.*)$/
oldExt = = strng.replace(/^(.*\.)(.*)$/, '$2')
newName = strng.replace(/^(.*\.)(.*)$/, '$1.working')
Please let me know if you have any questions. I just typed all of this
off of the top of my head, so it's possible there will be a syntax
error or something. But I'll help you work through any problems (yours
or mine).
Shawn
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
*************************************************************************
PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information. If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited. If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************
From shawn.milo at gmail.com Thu Aug 25 13:36:05 2005
From: shawn.milo at gmail.com (Shawn Milo)
Date: Thu, 25 Aug 2005 14:36:05 -0400
Subject: [Javascript] Change Extensions
In-Reply-To: <951967FCF5C4D211B0610008C75D2AA12C2E83E9@ct01excmb01.thehartford.com>
References: <951967FCF5C4D211B0610008C75D2AA12C2E83E9@ct01excmb01.thehartford.com>
Message-ID: <2dc0c81b05082511361df3b387@mail.gmail.com>
Travis,
What can I say? I love regexes. =o)
You're welcome. E-mail me through the list or privately if you
would like any more regex help.
Shawn
--
Shawn Milochik
The Freelance Pen
FreelancePen.com
610-621-2648
From paul at novitskisoftware.com Thu Aug 25 13:42:55 2005
From: paul at novitskisoftware.com (Paul Novitski)
Date: Thu, 25 Aug 2005 11:42:55 -0700
Subject: [Javascript] Change Extensions
In-Reply-To: <2dc0c81b050825104662aeaec2@mail.gmail.com>
References: <951967FCF5C4D211B0610008C75D2AA12C2E83DC@ct01excmb01.thehartford.com>
<2dc0c81b050825104662aeaec2@mail.gmail.com>
Message-ID: <6.2.0.14.2.20050825112550.05103870@spamarrest.com>
Shawn,
I'd make a couple of minor amendments to your regular expression:
/^.*\.(.*)$/
First, this:
/^.+\.(.+)$/
...replacing the asterisks ("0 or more instances") with pluses ("1 or
more"). Without this change, I think your pattern would test true on all
of these strings:
file.ext
file.
.ext
.
What would happen in the replace operation if the file name or its
extension had zero length?
Also, I'd change it to accommodate querystrings:
http://something.net/folder/file.ext?arg=val
/^.+\.(.+)($|\?)/
...terminating at either end-of-string or a question mark.
Also, do you think we need to worry about period characters in the
querystring? I know they wouldn't be there in any properly URLencoded URL,
but if they were typed there by a forgetful human then this might work:
/^.+\.([^?]+)($|\?)/
replacing (.+) with ([^\?]+) meaning "any characters except the question
mark." (I recall that characters in a [list] don't need to be escaped with \.)
I'm not totally confident in greedy matching, so I'd also exclude the
period from that:
/^.+\.([^?.]+)($|\?)/
How'm I doing?
Paul
At 10:46 AM 8/25/2005, Shawn Milo wrote:
>On 8/25/05, Falls, Travis D (HTSC, CASD) wrote:
> > I am trying to write a javascript method that will use regular expressions
> > to figure out the file extension of a file name (String) and change it.
> > Basically I need to find ".*" and replace it with ".working" I don't know
> > how to write this regular expression though. Can someone explain how to do
> > this? (not just send over the regular expression I want to learn how to do
> > this). Thanks.
>
>
>Travis,
>
>You want a regex that says:
>"Find the last period, then remember everything after that."
>
>In regex syntax, a period is a reserved character, so you have to
>"escape" it with
>a backslash (so it would be \. instead of .).
>
>So you have: /\./ (A regex is put inside forward slashes.)
>
>Now, you want to make sure it's the last period. Easy. The special
>character '.' (the period) matches any character. The asterisk (*)
>matches zero or more. So look for zero or more characters followed by
>a period.
>
> /.*\./ (Note that due to "greedy matching," the .* will match any
>and all periods up to the last, so you don't have to worry about it
>stopping early.)
>
>Now, you want to find everything after the last period. Easy, another '.*'.
>
> /.*\..*/
>
>Surround the part you want to replace with parenthesis.
>
> /.*\.(.*)/
>
>Use good clean syntax, and specify the beginning of line (^) and end
>of line ($).
>
> /^.*\.(.*)$/
>
>So if you want to remember what it was before you replace it, you can
>reference it like this:
>
>oldExt = = strng.replace(/^.*\.(.*)$/, '$1') ($1 refers to
>whatever is in the first set of parenthesis.
>
>Change the position of the parenthesis to capture the filename minus
>the extention:
>
>/^(.*\.).*$/
>newName = strng.replace(/^(.*\.).*$/, '$1.working') (The period
>needn't be escaped here.)
>
>Use a better regex, and match both:
>
>/^(.*\.)(.*)$/
>oldExt = = strng.replace(/^(.*\.)(.*)$/, '$2')
>newName = strng.replace(/^(.*\.)(.*)$/, '$1.working')
>
>Please let me know if you have any questions. I just typed all of this
>off of the top of my head, so it's possible there will be a syntax
>error or something. But I'll help you work through any problems (yours
>or mine).
>
>Shawn
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
From weirdit at gmail.com Thu Aug 25 22:39:39 2005
From: weirdit at gmail.com (Timothy White)
Date: Fri, 26 Aug 2005 11:39:39 +0800
Subject: [Javascript] Comparing Strings
In-Reply-To: <430DFA8B.7010509@triche-osborne.com>
References: <712824a90508250055449248c3@mail.gmail.com>
<3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk>
<712824a90508250326488d5eba@mail.gmail.com>
<430DD143.4010505@triche-osborne.com>
<712824a90508250725749e3d3@mail.gmail.com>
<430DE0EF.3050506@triche-osborne.com>
<430DFA8B.7010509@triche-osborne.com>
Message-ID: <712824a9050825203933e5d9b0@mail.gmail.com>
On 8/26/05, Triche Osborne wrote:
> Triche Osborne wrote:
> >
> > var replacements = new Array();
> > replacements[0] = ("Hi there!/span");
> > replacements[1] = ("Bonjour!/"p","span"/"error");
> >
> Nice. That last should have been:
> replacements[1] = ("Bonjour!/p,span/error");
>
> Sorry. I've been a bit distracted by a pet emergency for a couple of
> days. But since you're a seasoned programmer (even if not JS), I expect
> you get my drift about use of the array despite the quote error.
Lol. yes I get your drift. i didn't even notice that someone had
posted an error earlier on. I just coded it without the error without
thinking.
Unfortunately I think there is to much formatting for me to do it like
that. I basically get a large chunk of html, which is already
formatted, and place it in the div. And that html changes every once
in a while (currently a line is removed, and a new one is added on the
end). This is a sample of the contents of the div.[1] One of the lines
that starts with a timestamp span would be missing in the new html,
and a new on one the end. and the topic div sometimes changes. Now I
think about it I /could/ do this with javascript, load up an initial
'template' and fill in the values, remove first child nodes, and
append new nodes... I was doing this for an initial working solution
before i started working on it more.
Also, while we are talking about it. Is there a way to scroll the
container div to the bottom? Initially my idea was to not remove the
top line, just keep appending (the topic floats over the top via CSS)
lines and have it scroll to the bottom automatically. I'd probably
want something that checked if they had manually scrolled up to read
previous lines, and only scroll if there were at the bottom (or close
to it).
Just for the curious. This is all for a project I've been working on
for a while. Feel free to look at it. I'm using the AJAX to replace
the object's that auto refresh every x seconds and cause of that they
'flicker'. The objects will be the fall back, and AJAX for those who
can use it.
http://ihcc.sf.net/demo for the 'released' version.
http://members.plug.org.au/~linuxalien/public/talk/dev/ for the
developing version (not the bleeding edge version, that's still on my
comp, and until i get the AJAX working I won't upload it.)
Thanks
Tim
[1]
(25/08/05 21:32:38)
Weirdo: lots or random sayings!
(26/08/05 11:06:02)
Weirdo: more random text
(26/08/05 11:06:06)
Weirdo: and more
(26/08/05 11:06:08)
Weirdo: and more
From wdlists at triche-osborne.com Fri Aug 26 09:10:48 2005
From: wdlists at triche-osborne.com (Triche Osborne)
Date: Fri, 26 Aug 2005 09:10:48 -0500
Subject: [Javascript] Comparing Strings
In-Reply-To: <712824a9050825203933e5d9b0@mail.gmail.com>
References: <712824a90508250055449248c3@mail.gmail.com> <3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk> <712824a90508250326488d5eba@mail.gmail.com> <430DD143.4010505@triche-osborne.com> <712824a90508250725749e3d3@mail.gmail.com> <430DE0EF.3050506@triche-osborne.com> <430DFA8B.7010509@triche-osborne.com>
<712824a9050825203933e5d9b0@mail.gmail.com>
Message-ID: <430F22E8.7000004@triche-osborne.com>
Timothy White wrote:
> Now I
> think about it I /could/ do this with javascript, load up an initial
> 'template' and fill in the values, remove first child nodes, and
> append new nodes... I was doing this for an initial working solution
> before i started working on it more.
>
That sounds feasible. Cool little app. I tried out the demo version.
> Also, while we are talking about it. Is there a way to scroll the
> container div to the bottom?
When I looked at the demo version it was scrolled to the bottom already,
and when I added a line, it was still scrolled so that the added line
was visible. Perhaps I'm misunderstanding what you're saying?
Triche
From weirdit at gmail.com Fri Aug 26 18:39:18 2005
From: weirdit at gmail.com (Timothy White)
Date: Sat, 27 Aug 2005 07:39:18 +0800
Subject: [Javascript] Comparing Strings
In-Reply-To: <430F22E8.7000004@triche-osborne.com>
References: <712824a90508250055449248c3@mail.gmail.com>
<3366.193.195.164.58.1124958501.squirrel@www.easilymail.co.uk>
<712824a90508250326488d5eba@mail.gmail.com>
<430DD143.4010505@triche-osborne.com>
<712824a90508250725749e3d3@mail.gmail.com>
<430DE0EF.3050506@triche-osborne.com>
<430DFA8B.7010509@triche-osborne.com>
<712824a9050825203933e5d9b0@mail.gmail.com>
<430F22E8.7000004@triche-osborne.com>
Message-ID: <712824a90508261639777c66f2@mail.gmail.com>
> > Also, while we are talking about it. Is there a way to scroll the
> > container div to the bottom?
>
> When I looked at the demo version it was scrolled to the bottom already,
> and when I added a line, it was still scrolled so that the added line
> was visible. Perhaps I'm misunderstanding what you're saying?
The 'stable' demo that you tried out was the one that uses an object
(similar to iframe, but IIRC the one to use when you want an iframe).
Unfortunately the same code doesn't work for the div I use in the
unstable ajax version.
When I get more of the AJAX working I'll update the dev demo so people
can see the scroll problem
Tim
From Travis.Falls at thehartford.com Tue Aug 30 15:20:05 2005
From: Travis.Falls at thehartford.com (Falls, Travis D (HTSC, CASD))
Date: Tue, 30 Aug 2005 16:20:05 -0400
Subject: [Javascript] Change Extensions
Message-ID: <951967FCF5C4D211B0610008C75D2AA12C2E8409@ct01excmb01.thehartford.com>
Hey Shawn,
Another programmer on this list sent in an example that expanded on your
file.extention reg exp example. I delete his example by mistake... can you
send that over to me... once I finish combining the two I will send back the
reg exp so everyone on the list can have it. thanks.
Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 |
travis.falls at thehartford.com
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Shawn Milo
Sent: Thursday, August 25, 2005 1:47 PM
To: [JavaScript List]
Subject: Re: [Javascript] Change Extensions
On 8/25/05, Falls, Travis D (HTSC, CASD)
wrote:
> I am trying to write a javascript method that will use regular expressions
> to figure out the file extension of a file name (String) and change it.
> Basically I need to find ".*" and replace it with ".working" I don't know
> how to write this regular expression though. Can someone explain how to
do
> this? (not just send over the regular expression I want to learn how to do
> this). Thanks.
Travis,
You want a regex that says:
"Find the last period, then remember everything after that."
In regex syntax, a period is a reserved character, so you have to
"escape" it with
a backslash (so it would be \. instead of .).
So you have: /\./ (A regex is put inside forward slashes.)
Now, you want to make sure it's the last period. Easy. The special
character '.' (the period) matches any character. The asterisk (*)
matches zero or more. So look for zero or more characters followed by
a period.
/.*\./ (Note that due to "greedy matching," the .* will match any
and all periods up to the last, so you don't have to worry about it
stopping early.)
Now, you want to find everything after the last period. Easy, another '.*'.
/.*\..*/
Surround the part you want to replace with parenthesis.
/.*\.(.*)/
Use good clean syntax, and specify the beginning of line (^) and end
of line ($).
/^.*\.(.*)$/
So if you want to remember what it was before you replace it, you can
reference it like this:
oldExt = = strng.replace(/^.*\.(.*)$/, '$1') ($1 refers to
whatever is in the first set of parenthesis.
Change the position of the parenthesis to capture the filename minus
the extention:
/^(.*\.).*$/
newName = strng.replace(/^(.*\.).*$/, '$1.working') (The period
needn't be escaped here.)
Use a better regex, and match both:
/^(.*\.)(.*)$/
oldExt = = strng.replace(/^(.*\.)(.*)$/, '$2')
newName = strng.replace(/^(.*\.)(.*)$/, '$1.working')
Please let me know if you have any questions. I just typed all of this
off of the top of my head, so it's possible there will be a syntax
error or something. But I'll help you work through any problems (yours
or mine).
Shawn
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
*************************************************************************
PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information. If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited. If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************
From shawn at milochik.com Wed Aug 31 07:52:46 2005
From: shawn at milochik.com (Shawn Milochik)
Date: Wed, 31 Aug 2005 08:52:46 -0400
Subject: [Javascript] Change Extensions
In-Reply-To: <951967FCF5C4D211B0610008C75D2AA12C2E8409@ct01excmb01.thehartford.com>
References: <951967FCF5C4D211B0610008C75D2AA12C2E8409@ct01excmb01.thehartford.com>
Message-ID: <4315A81E.5030101@milochik.com>
Falls, Travis D (HTSC, CASD) wrote:
>Hey Shawn,
>Another programmer on this list sent in an example that expanded on your
>file.extention reg exp example. I delete his example by mistake... can you
>send that over to me... once I finish combining the two I will send back the
>reg exp so everyone on the list can have it. thanks.
>
>
Travis,
I hope this is what you were looking for.
Shawn
---------------------------
Paul Novitski wrote:
---------------------------
Shawn,
I'd make a couple of minor amendments to your regular expression:
/^.*\.(.*)$/
First, this:
/^.+\.(.+)$/
...replacing the asterisks ("0 or more instances") with pluses ("1 or
more"). Without this change, I think your pattern would test true on
all of these strings:
file.ext
file.
.ext
.
What would happen in the replace operation if the file name or its
extension had zero length?
Also, I'd change it to accommodate querystrings:
http://something.net/folder/file.ext?arg=val
/^.+\.(.+)($|\?)/
...terminating at either end-of-string or a question mark.
Also, do you think we need to worry about period characters in the
querystring? I know they wouldn't be there in any properly URLencoded
URL, but if they were typed there by a forgetful human then this might
work:
/^.+\.([^?]+)($|\?)/
replacing (.+) with ([^\?]+) meaning "any characters except the question
mark." (I recall that characters in a [list] don't need to be escaped
with \.)
I'm not totally confident in greedy matching, so I'd also exclude the
period from that:
/^.+\.([^?.]+)($|\?)/
How'm I doing?
Paul