ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* issue with JavaScript in Acrobat
@ 2019-10-06 19:13 Pablo Rodriguez
  2019-10-07 11:21 ` Peter Rolf
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez @ 2019-10-06 19:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,

I have this minimal sample:

    \setupinteraction[state=start]
    \setupinteractionscreen[option=max]
    \startJSpreamble {varia} used now
    var transitions = [1000,
    2000,
    3000,
    4000,
    5000,
    6000,
    7000,
    8000,
    9000];

    var msecs = 0;

    function step_clock() {
        try { ++msecs ;
        if ((msecs >= (transitions[this.pageNum]/10)) && ( this.pageNum
< this.numPages )) { ++this.pageNum; };
        } catch (e) {}
    }

    advance = app.setInterval ("step_clock()", 1);
    advance.count = 0;
    \stopJSpreamble
    \starttext
    \dorecurse{10}{\startTEXpage[pagestate=start, offset=1em]
        \pagenumber
    \stopTEXpage}
    \stoptext

Acrobat is required. And I have an issue with it

Each slide takes a full second (1000 milliseconds). But the conditional
in step_clock() needs to divide the elements from transitions array by
ten. Otherwise it is ten times slower.

Am I missing something here? Or why is "step_clock()" ten times slower
than it should be?

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: issue with JavaScript in Acrobat
  2019-10-06 19:13 issue with JavaScript in Acrobat Pablo Rodriguez
@ 2019-10-07 11:21 ` Peter Rolf
  2019-10-07 20:16   ` Pablo Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Rolf @ 2019-10-07 11:21 UTC (permalink / raw)
  To: ntg-context

Hi Pablo

Nearly no experience with JavaScript, no working Acrobat version
installed (no testing possible). So take the following with a grain of
salt...

I guess it's just the too small call interval of the "step_clock"
function. Calling it a thousand times per second doesn't seem to work.
If the function is called a hundred times per second only, your clock
counter is also incremented only a hundred times.

I would use a system clock value instead (difference between start time
and current time), so you can limit the call interval to a more
reasonable value (1/10s).


Regards, Peter


Am 06.10.2019 um 21:13 schrieb Pablo Rodriguez:
> Dear list,
>
> I have this minimal sample:
>
>     \setupinteraction[state=start]
>     \setupinteractionscreen[option=max]
>     \startJSpreamble {varia} used now
>     var transitions = [1000,
>     2000,
>     3000,
>     4000,
>     5000,
>     6000,
>     7000,
>     8000,
>     9000];
>
>     var msecs = 0;
>
>     function step_clock() {
>         try { ++msecs ;
>         if ((msecs >= (transitions[this.pageNum]/10)) && ( this.pageNum
> < this.numPages )) { ++this.pageNum; };
>         } catch (e) {}
>     }
>
>     advance = app.setInterval ("step_clock()", 1);
>     advance.count = 0;
>     \stopJSpreamble
>     \starttext
>     \dorecurse{10}{\startTEXpage[pagestate=start, offset=1em]
>         \pagenumber
>     \stopTEXpage}
>     \stoptext
>
> Acrobat is required. And I have an issue with it
>
> Each slide takes a full second (1000 milliseconds). But the conditional
> in step_clock() needs to divide the elements from transitions array by
> ten. Otherwise it is ten times slower.
>
> Am I missing something here? Or why is "step_clock()" ten times slower
> than it should be?
>
> Many thanks for your help,
>
> Pablo
> --
> http://www.ousia.tk
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: issue with JavaScript in Acrobat
  2019-10-07 11:21 ` Peter Rolf
@ 2019-10-07 20:16   ` Pablo Rodriguez
  2019-10-07 20:43     ` Henning Hraban Ramm
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez @ 2019-10-07 20:16 UTC (permalink / raw)
  To: ntg-context

Hi Peter,

many thanks for your explanation.

I’m translating (I mean, I’m trying to translate) a method that worked
perfectly fine with milliseconds in ActionScript 2. This is the main
reason why the transitions are recorded in milliseconds.

The issue that I discovered now is that (even if I call it
“milliseconds”), the time unit variable “msecs” has milliseconds only
when app.setInterval is set to 1.

I don’t know how to use a system clock in JS (or in Acrobat). But this
is only a test to check how it works.

Many thanks for the advice on setting the interval to 10 ms. I realized
that I could divide the transitions by ten and it worked fine. No human
can spot the difference even in 0.1 secs. That simple math operation
wasn’t obvious to me (background in humanities 😅).

Many thanks again for your help,

Pablo


On 10/7/19 1:21 PM, Peter Rolf wrote:
> Hi Pablo
>
> Nearly no experience with JavaScript, no working Acrobat version
> installed (no testing possible). So take the following with a grain of
> salt...
>
> I guess it's just the too small call interval of the "step_clock"
> function. Calling it a thousand times per second doesn't seem to work.
> If the function is called a hundred times per second only, your clock
> counter is also incremented only a hundred times.
>
> I would use a system clock value instead (difference between start time
> and current time), so you can limit the call interval to a more
> reasonable value (1/10s).
>
>
> Regards, Peter
>
>
> Am 06.10.2019 um 21:13 schrieb Pablo Rodriguez:
>> Dear list,
>>
>> I have this minimal sample:
>>
>>     \setupinteraction[state=start]
>>     \setupinteractionscreen[option=max]
>>     \startJSpreamble {varia} used now
>>     var transitions = [1000,
>>     2000,
>>     3000,
>>     4000,
>>     5000,
>>     6000,
>>     7000,
>>     8000,
>>     9000];
>>
>>     var msecs = 0;
>>
>>     function step_clock() {
>>         try { ++msecs ;
>>         if ((msecs >= (transitions[this.pageNum]/10)) && ( this.pageNum
>> < this.numPages )) { ++this.pageNum; };
>>         } catch (e) {}
>>     }
>>
>>     advance = app.setInterval ("step_clock()", 1);
>>     advance.count = 0;
>>     \stopJSpreamble
>>     \starttext
>>     \dorecurse{10}{\startTEXpage[pagestate=start, offset=1em]
>>         \pagenumber
>>     \stopTEXpage}
>>     \stoptext
>>
>> Acrobat is required. And I have an issue with it
>>
>> Each slide takes a full second (1000 milliseconds). But the conditional
>> in step_clock() needs to divide the elements from transitions array by
>> ten. Otherwise it is ten times slower.
>>
>> Am I missing something here? Or why is "step_clock()" ten times slower
>> than it should be?
>>
>> Many thanks for your help,
>>
>> Pablo


--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: issue with JavaScript in Acrobat
  2019-10-07 20:16   ` Pablo Rodriguez
@ 2019-10-07 20:43     ` Henning Hraban Ramm
  2019-10-08 12:56       ` Pablo Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Henning Hraban Ramm @ 2019-10-07 20:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Pablo,
I used JS in Acrobat 7 and still have the documentation and some sample code – I don’t know if Adobe keeps it online.
If you like, I can send it to you off list.

Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: issue with JavaScript in Acrobat
  2019-10-07 20:43     ` Henning Hraban Ramm
@ 2019-10-08 12:56       ` Pablo Rodriguez
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez @ 2019-10-08 12:56 UTC (permalink / raw)
  To: ntg-context

On 10/7/19 10:43 PM, Henning Hraban Ramm wrote:
> Hi Pablo,
> I used JS in Acrobat 7 and still have the documentation and some
> sample code – I don’t know if Adobe keeps it online.
> If you like, I can send it to you off list.

Hi Hraban,

the sample code will be useful to learn.

The documentation I have is:

  * “Developing Acrobat® Applications Using JavaScript™”
  * “JavaScript™ for Acrobat® API Reference”

Of course, I’m interested in other documents from Adobe.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2019-10-08 12:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-06 19:13 issue with JavaScript in Acrobat Pablo Rodriguez
2019-10-07 11:21 ` Peter Rolf
2019-10-07 20:16   ` Pablo Rodriguez
2019-10-07 20:43     ` Henning Hraban Ramm
2019-10-08 12:56       ` Pablo Rodriguez

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).