You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Ben Kim <bk...@coe.tamu.edu> on 2005/11/18 19:08:47 UTC

javascript variables in embperl tag


This may be a basic question, but is there a way to manipulate javascript
functions and variables within embperl syntax? (Would it be possible to
add this if it does not exist?)

For example, let's say I populated a large javascript array/hash from a
database call, and want to resort, rearrange or filter out at will from
the client side only without further making a database call.

I might use javascript's document.write, but I wonder if it's possible in
embperl space (maybe a new tag?), like

<script>var myarray=new Array(1,3,4,7);</script>
[=myarray[0]=] instead of document.write

which will do the same as
[-my @myarray=(1,3,4,7)-]
[+$myarray[0]+]

It can be used with Data::JavaScript::Anon, or even Ajax like things, I
suppose. 

Or, what is the best practice, if the same data need to be resorted /
filtered?


Regards,

Ben Kim
Developer
http://benix.tamu.edu


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Handling conditional-gets in embperl

Posted by Gerald Richter <ri...@ecos.de>.
> 	$req_rec->update_mtime($mod_time);
> 	$req_rec->set_last_modified($mod_time);
> 
> 	if ((my $rc = $req_rec->meets_conditions) != 200) { # 
> we can give up
> 		$req_rec->status($rc);
> 		print STDERR "got here b\n";
> 		#exit;

Try 

exit ($rc) ;

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Handling conditional-gets in embperl

Posted by Carl Eklof <ca...@yahoo.com>.
Hey Guys,

I can see from google searches, that I'm re-hashing an
issue, but it wasn't solved in any of the posts and/or
doesn't work in the 2.0.0 embperl that I'm using.

I started out with the a frequently-referenced posting
from December 2000, by Gerald:
http://www2.ecos.de/~mailarc/embperl/2000-12/msg00001.html

I modified it to statically declare that everything
changes once a day (for testing)

I was doing ok setting the %http_headers_out, but once
I started trying to use the apache calls, nothing
seemed to work. The method calls don't actually set
the headers, and setting the status-code didn't set
the status-code. Handling conditional-get is a very
small piece of code. Has anybody gotten this to work
with 2.x?

Much appreciated,

-Carl

[!
	use POSIX qw(strftime);
	use Apache2::Response ();
	use Apache2::RequestRec;

	use Time::HiRes qw(gettimeofday tv_interval );
!]
[-

##########################################################################
	# Check, set expr date

##########################################################################
	my $do = GOB::DateRanges->new();

	# Always indicate that the page has changed every day
at 5am
	my $mod_time = $do->get_cday_begin();
	$mod_time += (3600 * 5); # add 5 hours

	my $expr_time = $mod_time + (3600 * 24); # expires
tomorrow morning
	my @etps = gmtime($expr_time);
	my $edate_str = strftime "%a, %d %b %Y %I:%M:00 GMT",
@etps;

	$http_headers_out{Expires} = $edate_str;

	print STDERR "got here a\n";

	$req_rec->update_mtime($mod_time);
	$req_rec->set_last_modified($mod_time);

	if ((my $rc = $req_rec->meets_conditions) != 200) { #
we can give up
		$req_rec->status($rc);
		print STDERR "got here b\n";
		#exit;
	}
-]


Carl Eklof 
President 
Bee Software LLC 
See us in action at:http://beethere.net/
p: 917.464.3529 
f: 801.439.4213
carl@beesw.com


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: javascript variables in embperl tag

Posted by Derrick Spell <de...@cdmplus.com>.
Well, I'm certainly not a javascript expert, but it seems to me that  
the issue here is how to make data pulled by embperl on the server  
side available to the javascript on the client side.

I assume that there is a way to access submitted form data from  
javascript.  You can put the data into %fdat and then it will be  
available to the javascript as though it was submitted from a form.   
The javascript can then sort/format and display.

-Derrick

"Perl's grammar can not be reduced to BNF.
The work of parsing perl is distributed between
yacc, the lexer, smoke and mirrors.''
-Chaim Frenkel


On Nov 18, 2005, at 1:08 PM, Ben Kim wrote:

>
>
> This may be a basic question, but is there a way to manipulate  
> javascript
> functions and variables within embperl syntax? (Would it be  
> possible to
> add this if it does not exist?)
>
> For example, let's say I populated a large javascript array/hash  
> from a
> database call, and want to resort, rearrange or filter out at will  
> from
> the client side only without further making a database call.
>
> I might use javascript's document.write, but I wonder if it's  
> possible in
> embperl space (maybe a new tag?), like
>
> <script>var myarray=new Array(1,3,4,7);</script>
> [=myarray[0]=] instead of document.write
>
> which will do the same as
> [-my @myarray=(1,3,4,7)-]
> [+$myarray[0]+]
>
> It can be used with Data::JavaScript::Anon, or even Ajax like  
> things, I
> suppose.
>
> Or, what is the best practice, if the same data need to be resorted /
> filtered?
>
>
> Regards,
>
> Ben Kim
> Developer
> http://benix.tamu.edu
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: javascript variables in embperl tag

Posted by Gerald Richter <ri...@ecos.de>.
> 
> I might use javascript's document.write, but I wonder if it's 
> possible in embperl space (maybe a new tag?), like
> 
> <script>var myarray=new Array(1,3,4,7);</script> 
> [=myarray[0]=] instead of document.write
> 
> which will do the same as
> [-my @myarray=(1,3,4,7)-]
> [+$myarray[0]+]
> 

You cannot directly put JavaScript inside a HTML Page, like you can do it
with Embperl. You have to use document.write or xxx.innerHTML or
GetElementByID('xxx').value to update things in a page, so it will not be
easy to auto generate such code.

In case you develope some JavaScript code that does what you need, than you
can create (and maybe share) an new Embperl::Syntax to get it easy done if
Embperl 

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org