Web Viewer Encoding issue, google maps, php, javascirpt

4 messages Options
Embed this post
Permalink
janis rough-3

Web Viewer Encoding issue, google maps, php, javascirpt

Reply Threaded More More options
Print post
Permalink
I'm having an ongoing issue with the Web Viewer :-) I'd like to resolve. I can send you the view in the WV layout.  You can see the encoding in the wv layout window, but I can't send an attachment to the list.

 I have this javascript form in the web viewer:
-----js_form_gt---------
!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>untitled</title>
    <meta name="generator" content="TextMate http://macromates.com/">
    <meta name="author" content="jrough">
    <!-- Date: 2009-11-02 -->

    <script type ="text/javascript">
    var q ="#q";
    alert(document.forms['pgform'].elements['q'].value);
   
    </script>
    </head>
    <body onload="
     var frm = document.forms['pgform'];
     frm.elements['q'].value = q;
     document.forms['pgform'].submit();
    ">

    <form name="pgform" action="http://janisrough.dyndns.biz/phooglemapPC.php" method="post">

    <input type ="hidden" name ="q" value="q"/>

    <input type="submit" value="show map"/>

    </form>
    </body>
    </html>

directly in the web viewer I have a calc that substitutes the #q for a serialized & encoded address list.
----calc in wv-------
"data:text/html"& Substitute(address::js_form_gt;"#q";address:serializedLIst)
---------
This should work.  I have 2 test scripts and a test file. One I encode the serialized list [var q]  and one script I don't encode the serialized list.  Custom functions cfURLEncode, cfSerializeData, Trim4.
I create a ¶ delimited URLencoded address list and trimmed trailing and ending ¶'s.

Script 1:I know the web viewer is encoding the javascript form, so i tried not encoding the serialized list .  When I run that script, the form gets cut off in the web viewer output starting in the middle of the address list and gets cut off.  I'm pretty sure it needs to be urlEncoded:
-------gets cut off and stops processing javascript----------
Lancaster, CA, 93534";i:1;s:34:"3537 3rd St, Ridgefield, WA, 98642";i:2;s:40:"931 Alabama St, san francisco, CA, 94110";}";
    alert(document.forms['pgform'].elements['q'].value);
   
    </script>
    </head>
    <body onload="
     var frm = document.forms['pgform'];
     frm.elements['q'].value = q;
     document.forms['pgform'].submit();
    ">

    <form name="pgform" action="http://janisrough.dyndns.biz/phooglemapPC.php" method="post">

    <input type ="hidden" name ="q" value="q"/>

    <input type="submit" value="show map"/>

    </form>
    </body>
    </html>
Script 2----------
When I run it with the address list encoded the form doesn't process and I get a blank in the WEb viewer but in layout mode I can see my form that is encoded and the encoded address list in the web viewer.  As I said above I can send you the pdf picture.  It looks okay to me.

This is a direct POST in the Web Viewer on a PC running FM9 or greater.
It only works on the PC to do a direct post and it has to be 9 or greater.
I have this form running already on a Mac but it is a GET to a POST conversion so its different in that the url is sent to a local path as a GET then converted to a POST.  I would love to get the PC version running.

I have this all set up on a test FM 9 Server.  If you want to log in as guest and help me figure out this issue you can have the php page so you can print a google map yourself.   fmnet:/janisrough.dyndns.biz/map_4.fp7

I can't see why this doesn't work. 


hellpp!
Janis L. Rough

C:415.550.8550


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/FileMaker/Browse/
Manage your subscription: http://www.ListSearch.com/FileMaker/


Winfried Huslik

Re: Web Viewer Encoding issue, google maps, php, javascirpt

Reply Threaded More More options
Print post
Permalink
Janis,

What is #q, a text constant?

I doubt that a "#" can be used in a hash key.


Winfried
www.fmdiff.com


On 2009-11-04, at 17:46, Janis Rough wrote:

>     <script type ="text/javascript">
>     var q ="#q";
>     alert(document.forms['pgform'].elements['q'].value);


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/FileMaker/Browse/
Manage your subscription: http://www.ListSearch.com/FileMaker/


janis rough-3

Re: Web Viewer Encoding issue, google maps, php, javascirpt

Reply Threaded More More options
Print post
Permalink
Hi Winfried
By hash key  you mean the value that gets replaced in the substitute?  It does get replaced by the serialized address because I can see it encoded with the address numbers in the web viewer.  All unsafe chars in the string get encoded in the wv.  But why is it getting encoding because in this case the javascript is posting it?  It isn't a get method it is a post so I guess it still gets encoded in the wv.  The string param is passed from the web viewer js form to php in a serialized list for the web.  It isn't a constant it is dynamic depending on the selection by the user.

I have encoded the address string before it was serialized delimited by a ¶.  It seems like it must be passed from Filemaker to Javascript serialized. It can't take a ¶ list.  So the #q value is replaced in the form and everything is encoded in the wv.  I'm afraid it is getting encoded twice but like I say when I don't encode it, it gets cut off before the javascript processes it.

If you log in to my example the first layout shows the results in the wv that doesn't process.  The second layout shows the form where it gets cut off on an address but probably what happens is it is counting the chars in the serialized string and one of the encoding is wrong so it stops there.  I think the address must need to be encoded and then serialized but like I say then does the web viewer encode it again.  The address list is  encoded and serialized in FM with the custom function.  Then in the web viewer again.

Filemaker in the web viewer url.  I can see  the replaced serialized encoded value in the middle of the web viewer
var %20 q%20=%22a:3:%7Bi0;s:35%2244502%20Loneoak,%20Lancaster,%20CA,%2093534%22;i:1;s:34:%223537%203rd%20St,%20Ridgefield,%20WA,%2098642%20%22;i:2;s:40:%22931%20alabama%20St,%20san%20francisco,%20CA,%2094110%22;%77D%22;%OD%20%20%20
Which is weird now I look at it.  The %0D at the end is a carriage return.  I don't know if it needs quotes around this value but I would think so?  Maybe I need encoded quotes? So filemaker has quotes around the substituted value but it still needs quotes to be passed to the javascript form?  I'll try that.

Janis L. Rough

C:415.550.8550


--- On Thu, 11/5/09, Winfried Huslik <[hidden email]> wrote:

> From: Winfried Huslik <[hidden email]>
> Subject: Re: Web Viewer Encoding issue, google maps, php, javascirpt
> To: "FileMaker Talk" <[hidden email]>
> Date: Thursday, November 5, 2009, 4:44 AM
> Janis,
>
> What is #q, a text constant?
>
> I doubt that a "#" can be used in a hash key.
>
>
> Winfried
> www.fmdiff.com
>
>
> On 2009-11-04, at 17:46, Janis Rough wrote:
>
> >     <script type
> ="text/javascript">
> >     var q ="#q";
> > 
>    alert(document.forms['pgform'].elements['q'].value);
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/FileMaker/Browse/
> Manage your subscription: http://www.ListSearch.com/FileMaker/
>
>
>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/FileMaker/Browse/
Manage your subscription: http://www.ListSearch.com/FileMaker/


janis rough-3

Re: Web Viewer Encoding issue, google maps, php, javascirpt

Reply Threaded More More options
Print post
Permalink
In reply to this post by Winfried Huslik
I solved the issue.  In case someone can benefit from my struggles.  It turns out the form  below was too complicated.  It didn't like the ""'s around the #q.  It encoded those quotes into the string passed to php.  Instead I used a <textarea>#q</textarea> to  substitute the serialized string in. The Textarea didn't get encoded. I got rid of the frm.elements and just used the hidden text input. By the way you have to remember to escape all "'s in the web viewer.  But the biggest key was to add a trailing " on the end of the string in Filemaker.  I can't explain why.  It just worked.

 
   <script type ="text/javascript">
    var q ="#q";
   
    </script>
    </head>
    <body onload="
     var frm = document.forms[pgform];
     frm.elements[q'.value] = q;
     document.forms[pgform].submit();
    ">

    <form name="pgform" action="http://janisrough.dyndns.biz/phooglemapPC.php" method="post">

    <input type ="hidden" name ="q" value="q"/>

    <input type="submit" value="show map"/>
Janis L. Rough


--- On Thu, 11/5/09, Winfried Huslik <[hidden email]> wrote:

> From: Winfried Huslik <[hidden email]>
> Subject: Re: Web Viewer Encoding issue, google maps, php, javascirpt
> To: "FileMaker Talk" <[hidden email]>
> Date: Thursday, November 5, 2009, 4:44 AM
> Janis,
>
> What is #q, a text constant?
>
> I doubt that a "#" can be used in a hash key.
>
>
> Winfried
> www.fmdiff.com
>
>
> On 2009-11-04, at 17:46, Janis Rough wrote:
>
> >     <script type
> ="text/javascript">
> >     var q ="#q";
> > 
>    alert(document.forms['pgform'].elements['q'].value);
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/FileMaker/Browse/
> Manage your subscription: http://www.ListSearch.com/FileMaker/
>
>
>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/FileMaker/Browse/
Manage your subscription: http://www.ListSearch.com/FileMaker/