ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to display JavaScript's values in ConTeXt
@ 2006-09-05  4:56 Zhichu Chen
  2006-09-05  9:42 ` Peter Rolf
  0 siblings, 1 reply; 6+ messages in thread
From: Zhichu Chen @ 2006-09-05  4:56 UTC (permalink / raw)


Hello everybody,

    I want to add a clock which shows the system time to a pdf file.
And I have read the ``art-calc.pdf'' and ``mwidget-p.pdf'' to find
some approaches but failed shamely. I am indeed new at ConTeXt and
JavaScript. Before I'm shocked by ConTeXt, I used LaTeX for about 2
years, so I'm confused with the conventions between ConTeXt and LaTeX.
My code is here:

----------------------------------------------------------------------------------
\setupinteraction[state=start]

\startJSpreamble functions used now
  function do_digit(d)
    { Stack[Level] += String(d);
      do_refresh(Level) }
\stopJSpreamble

\startJScode{digit}
  do_digit(JS_S_1);
\stopJScode

\definefield[Stack.1][line][Results][][

\setupfield
  [Results]
  [horizontal,frame]
  [width=fit,
   height=2cm,
   frame=on]
  [height=18pt,width=80pt,align=middle,frame=off]
  [height=18pt,width=80pt,color=red,align=right,style=type,frame=off]

\setupbuttons [background=infobutton]

\starttext

Click \button{7}[JS(digit{7})] will get
\field[Stack.1]

\stoptext
--------------------------------------------------------------------------------

I only copied these codes from "art-calc.pdf" so there must be some
other critical concepts that I haven't realized. Please point them to
me. Thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to display JavaScript's values in ConTeXt
  2006-09-05  4:56 How to display JavaScript's values in ConTeXt Zhichu Chen
@ 2006-09-05  9:42 ` Peter Rolf
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Rolf @ 2006-09-05  9:42 UTC (permalink / raw)


Zhichu Chen wrote:
> Hello everybody,
> 
>     I want to add a clock which shows the system time to a pdf file.
> And I have read the ``art-calc.pdf'' and ``mwidget-p.pdf'' to find
> some approaches but failed shamely. I am indeed new at ConTeXt and
> JavaScript. Before I'm shocked by ConTeXt, I used LaTeX for about 2
> years, so I'm confused with the conventions between ConTeXt and LaTeX.
> My code is here:
>
I don't have the time right now for more than this short tip. If you
work with JavaScript you should open the JaveScript Debugger (CTRL-J in
Acrobat; in the Adobe Reader hit CTRL-K and check "Show console on
errors and messages" in the JavaScript categorie) to see the warnings
and error messages. You also should insert some log messages in your
code. For example

console.println("do_digit("+d+") at page "+[this.pageNum]);

at the start of your function do_digit. This helps a lot to see what is
going on.

Greetings, Peter

> ----------------------------------------------------------------------------------
> \setupinteraction[state=start]
> 
> \startJSpreamble functions used now
>   function do_digit(d)
>     { Stack[Level] += String(d);
>       do_refresh(Level) }
> \stopJSpreamble
> 
> \startJScode{digit}
>   do_digit(JS_S_1);
> \stopJScode
> 
> \definefield[Stack.1][line][Results][][
> 
> \setupfield
>   [Results]
>   [horizontal,frame]
>   [width=fit,
>    height=2cm,
>    frame=on]
>   [height=18pt,width=80pt,align=middle,frame=off]
>   [height=18pt,width=80pt,color=red,align=right,style=type,frame=off]
> 
> \setupbuttons [background=infobutton]
> 
> \starttext
> 
> Click \button{7}[JS(digit{7})] will get
> \field[Stack.1]
> 
> \stoptext
> --------------------------------------------------------------------------------
> 
> I only copied these codes from "art-calc.pdf" so there must be some
> other critical concepts that I haven't realized. Please point them to
> me. Thanks
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to display JavaScript's values in ConTeXt
@ 2006-09-07  0:49 Zhichu Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Zhichu Chen @ 2006-09-07  0:49 UTC (permalink / raw)


It's so kind of you. Your example really helps me 'cause I can learn
javascript and ConTeXt by books but there are few materials about how
to associate them.

Still, I'm sorry I have to open a new thread. I don't know how to
reply under you, it's sad.



---------- Forwarded message ----------
From: Peter Rolf <indiego@gmx.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Date: Wed, 06 Sep 2006 12:06:02 +0200
Subject: Re: [NTG-context] How to display JavaScript's values in ConTeXt
Zhichu Chen wrote:
>  . . .
First thing to say: I'm also a javascript beginner (used it only once!),
so don't expect too much from me :)

In the following code the missing vars and function are added
(javascript debugger), but still the initialisation ('undefined' text)
and the reset for the result field are missing (and who knows what
else). But it's a 'working' starting point.

\startJSpreamble functions used now
 function do_digit(d)
   {console.println("do_digit("+d+") at page "+[this.pageNum]);
    Stack[Level] += String(d);
    do_refresh(Level) }

 var Stack = new Array();
 var Level = 1 ;

 function do_refresh (i) { vv = this.getField("Stack.".concat(i)) ;
 if (vv) { vv.value = Stack[i] ;
 vv.readonly = (i!=Level) ;
 this.dirty = false } }
\stopJSpreamble

>  . . .
>
I have not used text fields before (so no example code) and this is all
I have about JavaScript:

http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/


from http://partners.adobe.com/public/developer/pdf/topic_js.html:

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJS.pdf
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSGuide.pdf
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSRefErrata.pdf

BUT MOST IMPORTANT:

http://partners.adobe.com/public/developer/en/pdf/debugger.js

Description:
"Use this file to enable the JavaScript Debugger in Adobe Reader, as
described in the Acrobat JavaScript Scripting Guide."

Hope that helps,

Peter

>  . . .
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to display JavaScript's values in ConTeXt
  2006-09-06  2:01 Zhichu Chen
@ 2006-09-06 10:06 ` Peter Rolf
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Rolf @ 2006-09-06 10:06 UTC (permalink / raw)


Zhichu Chen wrote:
> Thank you very much Peter.
> 
> I've inserted these code and when I open my pdf file in Acrobat
> Reader, it crashed :(. But this is not a big deal, I modified it and
> it's working, but it only tells me that:
> do_digit(7) at page 0

First thing to say: I'm also a javascript beginner (used it only once!),
so don't expect too much from me :)

In the following code the missing vars and function are added
(javascript debugger), but still the initialisation ('undefined' text)
and the reset for the result field are missing (and who knows what
else). But it's a 'working' starting point.

\startJSpreamble functions used now
  function do_digit(d)
    {console.println("do_digit("+d+") at page "+[this.pageNum]);
     Stack[Level] += String(d);
     do_refresh(Level) }

  var Stack = new Array();
  var Level = 1 ;

  function do_refresh (i) { vv = this.getField("Stack.".concat(i)) ;
  if (vv) { vv.value = Stack[i] ;
  vv.readonly = (i!=Level) ;
  this.dirty = false } }
\stopJSpreamble

> and the field never changes. I guess I have to specify some link
> between the JavaScript variant and the ConTeXt. Can you give me just
> one simplest example that shows JavaScript code
> var tempstring = "Yes";
> in pdf file? Or you could think I'm very boring so can you just
> suggest some materials that I can find these techniques?
>
I have not used text fields before (so no example code) and this is all
I have about JavaScript:

http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/


from http://partners.adobe.com/public/developer/pdf/topic_js.html:

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJS.pdf
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSGuide.pdf
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSRefErrata.pdf

BUT MOST IMPORTANT:

http://partners.adobe.com/public/developer/en/pdf/debugger.js

Description:
"Use this file to enable the JavaScript Debugger in Adobe Reader, as
described in the Acrobat JavaScript Scripting Guide."

Hope that helps,

Peter

> From: Peter Rolf <indiego@gmx.net>
> To: mailing list for ConTeXt users <ntg-context@ntg.nl>
> Date: Tue, 05 Sep 2006 11:42:44 +0200
> Subject: Re: [NTG-context] How to display JavaScript's values in ConTeXt
> Zhichu Chen wrote:
>> Hello everybody,
>>
>>     I want to add a clock which shows the system time to a pdf file.
>> And I have read the ``art-calc.pdf'' and ``mwidget-p.pdf'' to find
>> some approaches but failed shamely. I am indeed new at ConTeXt and
>> JavaScript. Before I'm shocked by ConTeXt, I used LaTeX for about 2
>> years, so I'm confused with the conventions between ConTeXt and LaTeX.
>> My code is here:
>>
> I don't have the time right now for more than this short tip. If you
> work with JavaScript you should open the JaveScript Debugger (CTRL-J in
> Acrobat; in the Adobe Reader hit CTRL-K and check "Show console on
> errors and messages" in the JavaScript categorie) to see the warnings
> and error messages. You also should insert some log messages in your
> code. For example
> 
> console.println("do_digit("+d+") at page "+[this.pageNum]);
> 
> at the start of your function do_digit. This helps a lot to see what is
> going on.
> 
> Greetings, Peter
> 
>> ----------------------------------------------------------------------------------
>> \setupinteraction[state=start]
>>
>> \startJSpreamble functions used now
>>   function do_digit(d)
>>     { Stack[Level] += String(d);
>>       do_refresh(Level) }
>> \stopJSpreamble
>>
>> \startJScode{digit}
>>   do_digit(JS_S_1);
>> \stopJScode
>>
>> \definefield[Stack.1][line][Results][][
>>
>> \setupfield
>>   [Results]
>>   [horizontal,frame]
>>   [width=fit,
>>    height=2cm,
>>    frame=on]
>>   [height=18pt,width=80pt,align=middle,frame=off]
>>   [height=18pt,width=80pt,color=red,align=right,style=type,frame=off]
>>
>> \setupbuttons [background=infobutton]
>>
>> \starttext
>>
>> Click \button{7}[JS(digit{7})] will get
>> \field[Stack.1]
>>
>> \stoptext
>> --------------------------------------------------------------------------------
>>
>> I only copied these codes from "art-calc.pdf" so there must be some
>> other critical concepts that I haven't realized. Please point them to
>> me. Thanks
>> _______________________________________________
>> ntg-context mailing list
>> ntg-context@ntg.nl
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>
>>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to display JavaScript's values in ConTeXt
@ 2006-09-06  2:02 Zhichu Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Zhichu Chen @ 2006-09-06  2:02 UTC (permalink / raw)


Thank you very much Peter.

I've inserted these code and when I open my pdf file in Acrobat
Reader, it crashed :(. But this is not a big deal, I modified it and
it's working, but it only tells me that:
do_digit(7) at page 0
and the field never changes. I guess I have to specify some link
between the JavaScript variant and the ConTeXt. Can you give me just
one simplest example that shows JavaScript code
var tempstring = "Yes";
in pdf file? Or you could think I'm very boring so can you just
suggest some materials that I can find these techniques?


From: Peter Rolf <indiego@gmx.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Date: Tue, 05 Sep 2006 11:42:44 +0200
Subject: Re: [NTG-context] How to display JavaScript's values in ConTeXt
Zhichu Chen wrote:
> Hello everybody,
>
>     I want to add a clock which shows the system time to a pdf file.
> And I have read the ``art-calc.pdf'' and ``mwidget-p.pdf'' to find
> some approaches but failed shamely. I am indeed new at ConTeXt and
> JavaScript. Before I'm shocked by ConTeXt, I used LaTeX for about 2
> years, so I'm confused with the conventions between ConTeXt and LaTeX.
> My code is here:
>
I don't have the time right now for more than this short tip. If you
work with JavaScript you should open the JaveScript Debugger (CTRL-J in
Acrobat; in the Adobe Reader hit CTRL-K and check "Show console on
errors and messages" in the JavaScript categorie) to see the warnings
and error messages. You also should insert some log messages in your
code. For example

console.println("do_digit("+d+") at page "+[this.pageNum]);

at the start of your function do_digit. This helps a lot to see what is
going on.

Greetings, Peter

> ----------------------------------------------------------------------------------
> \setupinteraction[state=start]
>
> \startJSpreamble functions used now
>   function do_digit(d)
>     { Stack[Level] += String(d);
>       do_refresh(Level) }
> \stopJSpreamble
>
> \startJScode{digit}
>   do_digit(JS_S_1);
> \stopJScode
>
> \definefield[Stack.1][line][Results][][
>
> \setupfield
>   [Results]
>   [horizontal,frame]
>   [width=fit,
>    height=2cm,
>    frame=on]
>   [height=18pt,width=80pt,align=middle,frame=off]
>   [height=18pt,width=80pt,color=red,align=right,style=type,frame=off]
>
> \setupbuttons [background=infobutton]
>
> \starttext
>
> Click \button{7}[JS(digit{7})] will get
> \field[Stack.1]
>
> \stoptext
> --------------------------------------------------------------------------------
>
> I only copied these codes from "art-calc.pdf" so there must be some
> other critical concepts that I haven't realized. Please point them to
> me. Thanks
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to display JavaScript's values in ConTeXt
@ 2006-09-06  2:01 Zhichu Chen
  2006-09-06 10:06 ` Peter Rolf
  0 siblings, 1 reply; 6+ messages in thread
From: Zhichu Chen @ 2006-09-06  2:01 UTC (permalink / raw)


Thank you very much Peter.

I've inserted these code and when I open my pdf file in Acrobat
Reader, it crashed :(. But this is not a big deal, I modified it and
it's working, but it only tells me that:
do_digit(7) at page 0
and the field never changes. I guess I have to specify some link
between the JavaScript variant and the ConTeXt. Can you give me just
one simplest example that shows JavaScript code
var tempstring = "Yes";
in pdf file? Or you could think I'm very boring so can you just
suggest some materials that I can find these techniques?

From: Peter Rolf <indiego@gmx.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Date: Tue, 05 Sep 2006 11:42:44 +0200
Subject: Re: [NTG-context] How to display JavaScript's values in ConTeXt
Zhichu Chen wrote:
> Hello everybody,
>
>     I want to add a clock which shows the system time to a pdf file.
> And I have read the ``art-calc.pdf'' and ``mwidget-p.pdf'' to find
> some approaches but failed shamely. I am indeed new at ConTeXt and
> JavaScript. Before I'm shocked by ConTeXt, I used LaTeX for about 2
> years, so I'm confused with the conventions between ConTeXt and LaTeX.
> My code is here:
>
I don't have the time right now for more than this short tip. If you
work with JavaScript you should open the JaveScript Debugger (CTRL-J in
Acrobat; in the Adobe Reader hit CTRL-K and check "Show console on
errors and messages" in the JavaScript categorie) to see the warnings
and error messages. You also should insert some log messages in your
code. For example

console.println("do_digit("+d+") at page "+[this.pageNum]);

at the start of your function do_digit. This helps a lot to see what is
going on.

Greetings, Peter

> ----------------------------------------------------------------------------------
> \setupinteraction[state=start]
>
> \startJSpreamble functions used now
>   function do_digit(d)
>     { Stack[Level] += String(d);
>       do_refresh(Level) }
> \stopJSpreamble
>
> \startJScode{digit}
>   do_digit(JS_S_1);
> \stopJScode
>
> \definefield[Stack.1][line][Results][][
>
> \setupfield
>   [Results]
>   [horizontal,frame]
>   [width=fit,
>    height=2cm,
>    frame=on]
>   [height=18pt,width=80pt,align=middle,frame=off]
>   [height=18pt,width=80pt,color=red,align=right,style=type,frame=off]
>
> \setupbuttons [background=infobutton]
>
> \starttext
>
> Click \button{7}[JS(digit{7})] will get
> \field[Stack.1]
>
> \stoptext
> --------------------------------------------------------------------------------
>
> I only copied these codes from "art-calc.pdf" so there must be some
> other critical concepts that I haven't realized. Please point them to
> me. Thanks
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-09-07  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-05  4:56 How to display JavaScript's values in ConTeXt Zhichu Chen
2006-09-05  9:42 ` Peter Rolf
2006-09-06  2:01 Zhichu Chen
2006-09-06 10:06 ` Peter Rolf
2006-09-06  2:02 Zhichu Chen
2006-09-07  0:49 Zhichu Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).