JavaScript Headaches

  1. 2 weeks ago

    To keep this brief, I am trying to do mapping with an open source, JavaScript system called "Polymaps". Currently, I have an HTMLViewer that on an open event would, optimistically, have the multiline JavaScript executing...

    I have tried this and searched Google for decent examples of people getting JavaScript to work on Xojo, but haven't found it to be of much help.

    Could someone help me walk through getting multiline JavaScript to actually execute?

    Thanks!!!

  2. Kem T

    Oct 11 Pre-Release Testers, Xojo Pro New York

    "JavaScript Headaches" seems redundant...

    (Sorry, just had to. :) )

  3. Maurizio R

    Oct 11 Pre-Release Testers, Xojo Pro

    To use Polymaps you use the WebSDK to create a custom WebControl that embed the Polymaps javascript library and creates a control using the javascript as documented in the Polymaps.org site.

    The docs for WebSDK is in the "Extras\WebSDK" folder contained in the Xojo installation directory.
    The final result depends on your knowledge about javascript and html.

  4. @Kem T "JavaScript Headaches" seems redundant...

    (Sorry, just had to. :) )

    Could be worse... Could be PHP hahaha

  5. @Maurizio R To use Polymaps you use the WebSDK to create a custom WebControl that embed the Polymaps javascript library and creates a control using the javascript as documented in the Polymaps.org site.

    The docs for WebSDK is in the "Extras\WebSDK" folder contained in the Xojo installation directory.
    The final result depends on your knowledge about javascript and html.

    Oh jeez. Just looked at the documentation. Looks like this is going to be a long project!

  6. Michel B

    Oct 11 Pre-Release Testers, Xojo Pro
    Edited 2 weeks ago by Michel B

    @Kem T "JavaScript Headaches" seems redundant...

    (Sorry, just had to. :) )

    Brakets and semicolon indigestion ?

    @M L Could be worse... Could be PHP hahaha

    Indeed ;)

  7. Tim H

    Oct 11 Pre-Release Testers Portland, OR USA

    You guys probably don't like C, either. It's a beautiful thing to create a work of pure elegance and inscrutability.

  8. Kem T

    Oct 11 Pre-Release Testers, Xojo Pro New York

    perl, baby, when you want fast and thoroughly unreadable.

  9. Michel B

    Oct 11 Pre-Release Testers, Xojo Pro

    @Tim H You guys probably don't like C, either. It's a beautiful thing to create a work of pure elegance and inscrutability.

    Actually, I like JavaScript and C but I thoroughly dislike Objective C ;)

    I did a lot of perl back in the nineties, but I rather use Php today.

  10. @Tim H You guys probably don't like C, either. It's a beautiful thing to create a work of pure elegance and inscrutability.

    C is okay; C++ is the love of my life.

    Getting back to the matter at hand... I played around with it a lot and it is only making me feel stupid (which, I contend that, I am not).

    Where I am thus far:

    I made a WebControlWrapper titled "HTMLArea" with the following...
    JavascriptNamespace as (Constant) String = Mapping
    HTML as (Computed) String
    Get = //empty
    Set = mHTML = value if ControlAvailableInBrowser() then ExecuteJavaScript("Xojo.get('" + me.ControlID + "').innerHTML = '" + value + "';") end
    mHTML as (Private) String
    Event Handlers:
    SetupCSS = Styles(0).Value("visibility") = "visible"
    SetupHTML = Return "<div id=""" + self.ControlID + """>" + html + "</div>"

    In my appropriately named "MainWindow", I have the following...
    "MappingHTMLArea" (Super = "HTMLArea")
    Open (event handler): if AssetDataListBox.RowCount < 1 then //if no assets... Me.HTML = "<center><h1>No Assets Availible...</h1></center>" me.HTML = me.html + "<center><a href="""+App.HelpUrl+"""target=""_blank"">Learn More</a></center>" else me.HTML = me.HTML + "<script>" //begin JavaScript //JS goes here??? me.HTML = me.HTML + "</script>" //end JavaScript end

    Am I on the right track or did I already screw up?

  11. Tim P

    Oct 12 Pre-Release Testers, Xojo Pro ⭐️

    Is it not working?
    By the way, I made a little tool that helps make empty WebControlWrappers so that you don't miss anything important: http://webgen.timi.me

  12. Greg O

    Oct 12 Xojo Inc Somewhere near Raleigh, NC

    ML, did you follow the QuickStart in the WebSDK docs? They actually show you how to set up a basic HTMLArea Control.

  13. Edited 2 weeks ago by M L

    @Tim P Is it not working?
    By the way, I made a little tool that helps make empty WebControlWrappers so that you don't miss anything important: http://webgen.timi.me

    No sir, it is not working... I am going for their "Nasa" style map pictured at this link:

    Instead, I got a whole lot of white...

    @Greg OLone ML, did you follow the QuickStart in the WebSDK docs? They actually show you how to set up a basic HTMLArea Control.

    I followed it to a point (see above)... Where it started veering off of my objectives for the code, I began varying the code.

or Sign Up to reply!