• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Webdialog and ActiveXObject

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 4 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    bomastudio
    last edited by 19 Aug 2015, 20:52

    I want to use some ActiveXObject features...it seems that IE has window.ActiveXObject but creating a new Word.Application is impossibile.... do you know something about this stuff?

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 19 Aug 2015, 23:52

      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'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • B Offline
        bomastudio
        last edited by 20 Aug 2015, 07:27

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

        1 Reply Last reply Reply Quote 0
        • B Offline
          bomastudio
          last edited by 20 Aug 2015, 10:09

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

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 20 Aug 2015, 15:59

            Do not use UI.messagebox for debugging. They can fail silently if the string is invalid.

            Use puts "test string" or puts object.inspect and read output in the Ruby Console.


            You cannot send such large data via the URL protocol.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 20 Aug 2015, 16:05

              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".

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • B Offline
                bomastudio
                last edited by 20 Aug 2015, 16:41

                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?

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 20 Aug 2015, 23:09

                  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.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 21 Aug 2015, 18:13

                    @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.

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      Aerilius
                      last edited by 21 Aug 2015, 18:24

                      @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).
                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by 21 Aug 2015, 19:01

                        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

                        learn from the mistakes of others, you may not live long enough to make them all yourself...

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        1 / 1
                        • First post
                          2/11
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement