JavaScript Headaches

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!!!

“JavaScript Headaches” seems redundant…

(Sorry, just had to. :slight_smile: )

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.

[quote=353810:@Kem Tekinay]“JavaScript Headaches” seems redundant…

(Sorry, just had to. :slight_smile: )[/quote]

Could be worse… Could be PHP hahaha

[quote=353812:@Maurizio Rossi]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.[/quote]

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

[quote=353810:@Kem Tekinay]“JavaScript Headaches” seems redundant…

(Sorry, just had to. :slight_smile: )[/quote]

Brakets and semicolon indigestion ?

Indeed :wink:

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

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

Actually, I like JavaScript and C but I thoroughly dislike Objective C :wink:

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

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): [code]if AssetDataListBox.RowCount < 1 then //if no assets…
Me.HTML = “

No Assets Availible…


me.HTML = me.html + “<a href=”""+App.HelpUrl+""“target=”"_blank"">Learn More"
else
me.HTML = me.HTML + “” //end JavaScript

end[/code]

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

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

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

[quote=353982:@Tim Parnell]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[/quote]
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…

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