Webdialog and ActiveXObject
-
ActiveX has been deprecated AFAIK. It has too many security issues. Some browsers even on PC refuse to load ActiveX objects.
Besides the window object is not exposed in web browser control on PC.
What are you trying to do ?
-
I want to save the webdialog content (in a firt moment I load an html template with tables and then I change its conents via jquery) in several format (WORD, EXCEL, PDF, HTML).
I'm thinkin to send the html content of the page back to SU and the use Ruby to export in those fortmats....
-
Ok. I think I'm on the road....but I have at the moment a difficulties with the .add_action_callback
dlgRESULTS.add_action_callback("exportHTML") { |web_dialog, params| begin UI.messagebox("NO ERROR") UI.messagebox(params.to_s) rescue UI.messagebox("ERROR") end }
while in my javascript file
var exportHTML = function(actionName) { query = 'skp;exportHTML@' + actionName.toString(); alert(query) window.location = query; } strHTML = "<html>" + $("html").html() + "</html>" // leggiHTML returns the whole page exportHTML(strHTML.toString())
but this approach doesn't work....I suppose that it's due to the "strHTML" string...may be because it isn't passsed as string but as other type? I can't get any error or warning....I can't understand....
-
Do not use
UI.messagebox
for debugging. They can fail silently if the string is invalid.Use
puts "test string"
orputs object.inspect
and read output in the Ruby Console.
You cannot send such large data via the URL protocol.
-
Use
WebDialog.get_element_value()
to retrieve the contents of the table cells, and store them in a nested array on the ruby side.So you will need to assign Js IDs to each table cell, perhaps "row#-col#", like id="3-4".
-
mmmmm...it's a very long task....
Does .get_element_value works with every DOM elements orr only with input-type?why I can't pass the whole page as string?
-
It's a URI like the address in the browser. There is a limit to the length of the parameters.
Why would you possibly want to pass all that HTML tag junk into Ruby ?
Pass just the data.
-
@bomastudio said:
Does
.get_element_value
works with every DOM elements or only with input-type?It should work with any DOM element that supports id and value properties.
-
@bomastudio said:
but this approach doesn't work....I suppose that it's due to the "strHTML" string...may be because it isn't passsed as string but as other type? I can't get any error or warning....I can't understand....
You are in an (almost) dead end road. You can not pass a whole document over a 'skp:' protocol url, because there are (among more) these issues:
- As soon as the string contains a single quote
'
it does not arrive on the Ruby side, but SketchUp causes a SyntaxError. - any other Unicode characters in urls must be url-encoded. Multiple backslashes can however still be dropped even if properly escaped (!)
- urls in Internet Explorer have a maximum length of 2083 characters (and urls in general in other browser engines are unlikely to support a million characters)
Because this way of transfering data (skp:
with parameters after@
) is so utterly broken, you should not attempt to build your own (probably flawed) workarounds. You will also meet problems and have a lot of bugs in your code with failed parameter parsing/unserialization (because it involves). I strongly recommend to avoid this by using an already designed, proper webdialog communication library, like many developers use. Don't duplicate effort, but re-use. Look at what others use, look at their code. At the moment there is SKUI on github, and I have been working for some months on making the one I use in my plugins standalone and re-usable (soon released).
- As soon as the string contains a single quote
-
Thread Highjack...
@aerilius said:
...I have been working for some months on making the one I use in my plugins standalone and re-usable (soon released).
shoot me a copy if you want any mac testing, i'm not too fond of SKUI, as I prefer a more the native look and feel...
john
Advertisement