Source: nntp.x.perl.org/rss/perl.javascript.rdf

perl.javascript
...


Re: Access from perl to a JavaScript function result by S...
Basically you can`t do this.<br/>Or try to use
http://search.cpan.org/~claesjac/JavaScript-1.11/lib/JavaScript.pm
Before you need cut Javascript from HTML, and maybe cleanup it, for better
usage.


2009/2/23 Amel Kapetanovic <a.kapetanovic@hispeed.ch>

> Hi,
>
> I am trying to access from perl to HTML documents (LWP), and I want to
> get the result of some JavaScript functions, which are in the HTML page,
> simply like
>
> document.write('hello');
>
> Could someone please help me?
>
> Thanks,
> Amel
>
>
>


--
Sergey Andreev



Access from perl to a JavaScript function result by Amel ...
Hi,

I am trying to access from perl to HTML documents (LWP), and I want to
get the result of some JavaScript functions, which are in the HTML page,
simply like

document.write('hello');

Could someone please help me?

Thanks,
Amel




Re: Problems with JavaScript 1.04 by Claes Jakobsson
In order to make installation of JavaScript.pm a lot easier I'm
planning of bundling a suitable SpiderMonkey 1.7 or later and
integrate that into the build process like DBD::SQLite does. It will
still be possible to build against your own SpiderMonkey if you want
that.

At the same time I will also drop support for pre-1.7 SpiderMonkey
since they cause me headache. These are the plans for 1.1 so far.

/Claes


On 18 nov 2007, at 18.06, Jesse Thompson wrote:

> To back up Claes' point here, I had the smoothest install experience
> when I
> built the JavaScript.pm package against a fresh download of the
> newest copy
> of spidermonkey, at that time 1.6.


Re: Problems with JavaScript 1.04 by Jesse Thompson
To back up Claes' point here, I had the smoothest install experience when I
built the JavaScript.pm package against a fresh download of the newest copy
of spidermonkey, at that time 1.6.

On Nov 18, 2007 8:23 AM, Claes Jakobsson &lt;claes@surfar.nu> wrote:

> Hi,
>
> On 18 nov 2007, at 03.06, Gary Bruce wrote:
>
> > I'm having problems using JavaScript 1.04. I downloaded, unpacked
> > and made
> > the tar file from the CPAN site.
> >
> > The make and installation was somewhat problematic. The module would
> > not make using the CPAN module. The version downloaded by CPAN was
> > 1.03 not
> > 1.04.
> >
> > After some investigation into this list I set the JS_INC and JS_LIB
> > environment variables as directed. I was able to get a clean "perl
> > Makefile.PL" and "make". "make test" failed 30 out of 32 tests, but
> > the
> > "make install" seemed to do OK.
> >
> > I cut and pasted the "99 bottles of beer" sample program from the
> > man page.
> > Upon running it as "perl javatest.pl" I get the following error:
> >
> > /libexec/ld-elf.so.1: /usr/local/lib/libnspr4.so.1: Undefined symbol
> > "pthread_condattr_init"
> >
> > I'm running on FreeBSD 6.2 on an i386 32 bit platform.
> >
> > Anyone have any ideas?
> >
> > Thanks,
> > Gary
>
> This looks like a problem with the SpiderMonkey and NSPR libraries you
> have installed on your machine and not a problem with JavaScript.pm.
>
> What spidermonkey libs are you building against?
>
> /Claes
>



Re: Problems with JavaScript 1.04 by Claes Jakobsson
Hi,

On 18 nov 2007, at 03.06, Gary Bruce wrote:

> I'm having problems using JavaScript 1.04. I downloaded, unpacked
> and made
> the tar file from the CPAN site.
>
> The make and installation was somewhat problematic. The module would
> not make using the CPAN module. The version downloaded by CPAN was
> 1.03 not
> 1.04.
>
> After some investigation into this list I set the JS_INC and JS_LIB
> environment variables as directed. I was able to get a clean "perl
> Makefile.PL" and "make". "make test" failed 30 out of 32 tests, but
> the
> "make install" seemed to do OK.
>
> I cut and pasted the "99 bottles of beer" sample program from the
> man page.
> Upon running it as &quot;perl javatest.pl" I get the following error:
>
> /libexec/ld-elf.so.1: /usr/local/lib/libnspr4.so.1: Undefined symbol
> "pthread_condattr_init"
>
> I'm running on FreeBSD 6.2 on an i386 32 bit platform.
>
> Anyone have any ideas?
>
> Thanks,
> Gary

This looks like a problem with the SpiderMonkey and NSPR libraries you
have installed on your machine and not a problem with JavaScript.pm.

What spidermonkey libs are you building against?

/Claes


Problems with JavaScript 1.04 by Gary Bruce
I'm having problems using JavaScript 1.04. I downloaded, unpacked and made
the tar file from the CPAN site.

The make and installation was somewhat problematic. The module would
not make using the CPAN module. The version downloaded by CPAN was 1.03 not
1.04.

After some investigation into this list I set the JS_INC and JS_LIB
environment variables as directed. I was able to get a clean "perl
Makefile.PL" and "make". "make test" failed 30 out of 32 tests, but the
"make install" seemed to do OK.

I cut and pasted the "99 bottles of beer" sample program from the man page.
Upon running it as "perl javatest.pl" I get the following error:

/libexec/ld-elf.so.1: /usr/local/lib/libnspr4.so.1: Undefined symbol
"pthread_condattr_init"

I'm running on FreeBSD 6.2 on an i386 32 bit platform.

Anyone have any ideas?

Thanks,
Gary



JS and HEX Validation by Grzegorz Mi¶kiewicz
Hi to all,

I'm trying to validate is string is hex:

function validate_mac (mac) {
var wzor = ^0[xX]([0-9a-fA-F]+)$;
var wynik = mac.match(wzor);
if(wynik == null) return false;
return true;
}

and use this function in this:

function validate_form_komputery ( form )
{
var msg = '';
if((form.ip1.value=='') || (form.ip2.value=='') || (form.ip3.value=='') ||
(form.ip4.value=='')) msg = '* Podany adres IP jest nieprawid³owy\n';
if((form.mac1.value=='') || (form.mac2.value=='') || (form.mac3.value=='')
|| (form.mac4.value=='') || (form.mac5.value=='') || (form.mac6.value==''))
msg += '* Pope³ni³e¶ b³±d przy adresie MAC\n';

if(form.nazwa.value=='') msg += '* Nazwa hosta jest nieprawid³owa\n';
if(validate_mac(form.mac1.value)==false) msg += &#39;* Podany adres mac nie
jest prawid³owy';
if(msg!=='') { alert (a.value+'\n'+msg); return false; }
}

and it not work at all, when i comment line:
if(validate_mac(form.mac1.value)==false) msg += '* Podany adres mac nie
jest prawid³owy';
rest of code work.

Where i have made a mistake ??

Best Regards,
Gregory Miskiewicz




Re: JS context serialization? by Jesse Thompson
Ok. Re-reading my original post on "JS context serialization" I
believe it may have been too rambling. Let me try to be more concise.

In a web browser, Javascript runs interactively. When you first reach
a page, javascript starts up and js files get loaded, functions get
defined, etc. You create an environment.

Next, the user interacts with that environment. They click a button,
they type in some text. The environment records what they do and it
reacts to the user. The environment slowly changes over time.

In theory, using JavaScript.pm we should be able to do this server
side too. We should be able to re-use a majority of our client side
javascript code and pretend the server is a very slow part of the
client. This is faboo for handicapped web browsers like Konquerer. But
there is one major hurdle.

When the client accesses a server side page, JavaScript.pm starts up.
Js files get loaded, functions get defined. We have a new environment,
just like in client side. Except.... Once we pass control back to the
client we are in trouble. When the client presses a button or enters
some text it emits a brand new page request to the server, and there
is no way we can still have the "environment" we created the first
time around ready to handle the user's request. The environment cannot
survive from one page load to the next. It cannot be stateful.

What we need is a way to "serialize" an environment. That is just a
fancy way of saying we freeze dry the entire Javascript universe we
created into a string so it can be stored into a database for future
retrieval. Then, we "unserialize" or thaw out the data on the next
page request from the same user.

Does Javascript.pm have a way to serialize and unserialize an entire
context, for this and similar uses?

Thanks. :)<br/>
- - Jesse Thompson
http://www.webformix.com/


JS context serialization? by Jesse Thompson
Say, would anyone know if it would be possible or easy to serialize a
JavaScript runtime environment or context into a string, to save state
as to all the data in that environment? I don't fully understand how
the "compile" option works so I can't say if that is comparable.

What I am thinking is, my project would like to be able to run scripts
in the browser when the browser is compatible with the JS
requirements, and run them on the server otherwise. Doing this rises a
ton of technical challenges that I am addressing, but among them is
the fact that the JS on client is stateful.

When you click something to interact with it, the JS handles the
request, and the state of the web page and of all the JS data remains
intact awaiting your next request.

If you try emulating this server side however, the server first serves
you the page (and emulates whatever JS initialization there is) and
then sends you the page state at that point. If I could serialize the
JS context at this point and store it, then after the user clicks to
interact with something I could retrieve the serial and restore it as
a context in order to continue servicing the request. A restored
context would remember all of the JS information, and in my workflow
the page state is stored as a dom or e4x object so that is saved as
well.

Is that something that "compile" already does by chance, or if not is
there any other functionality that could accomplish it?

Thanks for your consideration. :)

- - Jesse Thompson
Webformix


Re: Perl exceptions from bound JS constructors do not pro...
Hi Jesse.

On 6 apr 2007, at 10.35, Jesse Thompson wrote:

> Am I approaching this the wrong way, or is this perhaps something
> to report
> in rt?
>
> It looks like when I bind a class and throw an error (such as a die()
> statement or a failed DB connect) from within a static or object
> method, it
> bubbles beautifully through JS as an exception.
>
> However when I bind a class and register some perl sub as a
> *constructor*,
> any dies or errors from there seem to make the constructor abort
> silently
> instead.

Yes, this seems to be a bug. I think the problem lies within this
piece of code from PJS_construct_perl_object (in JavaScript.xs)

if (SvROK(pcls->cons)) {
SV *rsv;
SV *pkg = newSVpv(pcls->pkg, 0);
perl_call_sv_with_jsvals_rsv(cx, obj,
pcls->cons, pkg,
argc, argv, &rsv);<br/>
SvREFCNT_inc(rsv);

JS_SetPrivate(cx, obj, (void *) rsv);
}

return JS_TRUE;

perl_call_sv_with_jsvals_rsv returns JS_FALSE if it throws an
exception so we should also return JS_FALSE.

Please report this as an bug in RT and I'll fix it in the next release.

Thanks,
Claes


Newsfeed display by CaRP

Software: Java
See Software in Open Directory
Find related sites in Open Directory

Return to News Feeds Home Page
My Sites