Re: JavaScript 'lisp' calls

2012-10-12 Thread Alexander Burger
On Fri, Oct 12, 2012 at 08:30:40AM +0200, Alexander Burger wrote:
>...
>(cons 'onload
>   (text
>  "navigator.geolocation.getCurrentPosition(function(pos) {
> lisp('@1!setLocation',
>\"+\" + -pos.coords.latitude * 1,
>\"+\" + -pos.coords.longitude * 1);
>  } )"
>...

Oops, the '-' signs in front of the 'pos' values were just for testing
purpuses.

The two lines should actually be

   \"+\" + pos.coords.latitude * 1,
   \"+\" + pos.coords.longitude * 1);

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: JavaScript 'lisp' calls

2012-10-11 Thread Alexander Burger
On Thu, Oct 11, 2012 at 02:49:04PM -0400, Rick Lyman wrote:
> Since an external (database) symbol starts with dash ('-'), a number
> should be prefixed with '+', so a negative number could be specified
> with "+-1234567".

Thanks Rick!

Right. Sorry, we discussed that about a month ago, and I forgot it
meanwhile. The JS 'lisp' calls are not really usable in this way.

Because of the URL encoding, there is no optimal solution.

I took out the encodeURIComponent() calls in 'lisp' in "lib/form.js", so
it is up to the application's JS code to properly encode the arguments
(or encode them not, like in the case of numbers).


The previous example would become with that:

   ...
   (cons 'onload
  (text
 "navigator.geolocation.getCurrentPosition(function(pos) {
lisp('@1!setLocation',
   \"+\" + -pos.coords.latitude * 1,
   \"+\" + -pos.coords.longitude * 1);
 } )"
   ...

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: JavaScript 'lisp' calls

2012-10-11 Thread Rick Lyman
Note:

>From my location the browser does: GET
http://127.0.0.1:8081/!setLocation?39.7670160001&-86.156255

Per Alex:
Since an external (database) symbol starts with dash ('-'), a number
should be prefixed with '+', so a negative number could be specified
with "+-1234567".

Otherwise:

 (de setLocation (Lat Lon)
  (msg Lat)
  (msg Lon)  )

returns: 39.76... and NIL; instead of 39.76... & -86.15...

-rl
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: JavaScript 'lisp' calls

2012-10-11 Thread Alexander Burger
Hi Jon,

> In the upper part of the CHANGES file of the ongoing development
> version, there's a line saying "JavaScript 'lisp' calls. Can you
> explain what this is about?

Yes, this allows you to call a Lisp function on the server from
JavaScript on the client.

I used it to experiment with the Geolocation API, e.g.:


(app)

(de setLocation @
   (msg (rest)) )

(action
   (html 0 "Geolocation" "@lib.css"
  (list
 (cons 'onload
(text
   "navigator.geolocation.getCurrentPosition(function(pos) {
  lisp('@1!setLocation', pos.coords.latitude, 
pos.coords.longitude);
   } )"
   *SesId ) ) )
  (form NIL
 (gui '(+Button) "Location") ) ) )


This calls the function 'setLocation' whenever the button is pressed (or
the page is reloaded), effectively printing the coordinates on the
server side.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


JavaScript 'lisp' calls

2012-10-11 Thread Jon Kleiser

Hi Alex,

In the upper part of the CHANGES file of the ongoing development 
version, there's a line saying "JavaScript 'lisp' calls. Can you explain 
what this is about?


/Jon
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe