sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Show webdialog quicker?

    Scheduled Pinned Locked Moved Developers' Forum
    24 Posts 6 Posters 450 Views 6 Watching
    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.
    • D Offline
      driven
      last edited by

      an onDomReady event call might be worth looking at.

      there are plain vanila js versions out there, but he's some food for thought http://developer.yahoo.com/yui/examples/event/event-timing.html
      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
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        what does the code for the splashscreen html look like?

        Are you using an IMG element, or just setting the background of the BODY and HTML elements to the graphic file ?

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          This is the entire html page

          <html>
          <body>
          
          <img border="0" src="./logo_image.jpg" alt="Pulpit rock" width="800" height="600" />
          
          </body>
          </html>
          
          

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Windows and OSX loads WebDialogs differently. OSX loads the content immediately when you use set_html or set_file, while Windows defer it until .show. )From the top of my heard I cannot remember if Windows reloaded the content on each .show either...)

            But as mentioned, the DOM ready event is the first event you can get when the HTML structure is loaded. jQuery makes this easy cross platform.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @chris fullmer said:

              This is the entire html page

              <html>
              > <body>
              > 
              > <img border="0" src="./logo_image.jpg" alt="Pulpit rock" width="800" height="600" />
              > 
              > </body>
              > </html>
              > 
              

              And this takes some times 5 seconds to load?

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                I think SU just doesn't let the html page load. Here is the extent of my ruby. Perhaps there is some way to write this better so it lets the webpage load?

                	splash_path = File.join( Install.base_path, "assets", "splash.html" )
                	@@spalsh_wd = UI;;WebDialog.new("MyProject", true, myproject_splash", 800, 600, 200, 200, true);
                	@@spalsh_wd.set_url splash_path
                	@@spalsh_wd.show
                
                

                Then here's some optional code I use to test if it loads if I pause ruby. Running the while loop for 5 seconds does nothing. Popping up the UI.messagebox though works like a charm. But I don't want to pop open the messagebox. sleep will pause the system, but does not let the webdialog load.

                
                	UI.messagebox ""
                or
                	time_mark = ( Time.now + 1 )
                	while time_mark > Time.now
                	end
                or
                	sleep 5.0
                
                

                EDIT: And of course I close it after my script loads with

                @@spalsh_wd.close
                

                So any thoughts? Am I just loading the webdialog wrong?

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • A Offline
                  Aerilius
                  last edited by

                  If you do heavy calculations, then the webdialog freezes or doesn't update. In one of my plugins I wanted to display a waiting animation with execute_script and then loop over thousands of entities. When I paused ruby with sleep(5), it didn't help, it worked only with:
                  webdlg.execute_script("startProcess()") UI.start_timer(0.1, false){self.process()}

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    I don't understand what that self.process in the block does.

                    But I tried to implement it and no luck.

                    Oh well, if I don't close it, then it will eventually load the image once SU has completed loading all the other scripts. Then the user will have to close the splash screen themselves. 😞

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      how about writing the image file in a .set_html.
                      AdamB does it in Goldilocks .rb and it's doing other stuff at the same time

                      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
                      • jolranJ Offline
                        jolran
                        last edited by

                        A long shot. Saw something like this earlier today..

                        One cannot use a body onload? Like <body onload="jsFunction()">.
                        A <div> in the <body> with an ID.

                        Then a jsfunction in the script tag that grabs the div's ID and set the HTML inside?

                        Excuse my interuption, just wondering about this as well..

                        1 Reply Last reply Reply Quote 0
                        • Chris FullmerC Offline
                          Chris Fullmer
                          last edited by

                          OK, Aerilius got me on the right track, just took a little digging around on my part.

                          Here is what is working for me (sorry it looks hard to read in this little code box. Its only 4 lines of code, much of it being my html string.):

                          	splash_path = File.join( Install.base_path, "assets")
                          	@@splash_wd = UI;;WebDialog.new("MyProgram", true, "my_splash", 800, 600, 200, 200, true);
                          	UI.start_timer(0.1, false){@@splash_wd.show;@@splash_wd.set_html "<html><body><img border='0' src='#{splash_path}/logo_image.jpg' alt='Pulpit rock' width='800' height='600' /></body></html>"}
                          	UI.start_timer(2, false){@@splash_wd.close}
                          

                          I open the webdialog, and set_html within the UI_time procedure. That is all it takes to get it to completely show everything. Then I use another timer to close the window after the splash has been on for a little while.

                          I'm guessing I don't even need to pass the html in as a string. It will probably load the file this way as well. i'll test.

                          Thanks everyone!

                          Lately you've been tan, suspicious for the winter.
                          All my Plugins I've written

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            driven
                            last edited by

                            chris, is it meant to work on macs?

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

                            1 Reply Last reply Reply Quote 0
                            • Chris FullmerC Offline
                              Chris Fullmer
                              last edited by

                              ok, even a little cleaner. This way I can use set_file to set a file to point to, instead of an html string.

                              	splash_path = File.join( Install.base_path, "assets", "splash.html")
                              	@@splash_wd = UI;;WebDialog.new("MultiFlux", true, "multiflux_splash", 800, 600, 200, 200, true);
                              	@@splash_wd.set_file splash_path
                              	UI.start_timer(0.1, false){@@splash_wd.show;}
                              	UI.start_timer(3, false){@@splash_wd.close}
                              

                              It is just the webdlg.show that needs to inside the UI.start_timer procedure. Now it all loads and displays as desired.

                              Lately you've been tan, suspicious for the winter.
                              All my Plugins I've written

                              1 Reply Last reply Reply Quote 0
                              • Chris FullmerC Offline
                                Chris Fullmer
                                last edited by

                                At this point, no unfortunately. It is not a Mac plugin. HOWEVER, I'm trying hard to mac it close to MAC friendly so we can get it up and running on Mac's someday.

                                Are all the methods I've used so far Mac friendly?

                                Lately you've been tan, suspicious for the winter.
                                All my Plugins I've written

                                1 Reply Last reply Reply Quote 0
                                • thomthomT Offline
                                  thomthom
                                  last edited by

                                  @chris fullmer said:

                                  Are all the methods I've used so far Mac friendly?

                                  If you want the WebDialog to stay on top of the SketchUp window you want to use .show_modal under OSX. Under OSX that method doesn't produce a modal window like under Windows.

                                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    driven
                                    last edited by

                                    and .set_html has a problem with local files... 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
                                    • Chris FullmerC Offline
                                      Chris Fullmer
                                      last edited by

                                      Oh, ok. I'll put in the set_modal for future use. And I'll stick with my .set_file method then. Its cleaner in my ruby code and there is no reason at this point to load the html as a string.

                                      Thanks guys!,

                                      Chris

                                      Lately you've been tan, suspicious for the winter.
                                      All my Plugins I've written

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        driven
                                        last edited by

                                        it all works on the mac with set file.

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

                                        1 Reply Last reply Reply Quote 0
                                        • Dan RathbunD Offline
                                          Dan Rathbun
                                          last edited by

                                          @chris fullmer said:

                                          Oh, ok. I'll put in the set_modal for future use.

                                          But not on PC...

                                             splash_path = File.join( Install.base_path, "assets", "splash.html")
                                             @@splash_wd = UI;;WebDialog.new("MultiFlux", true, "multiflux_splash", 800, 600, 200, 200, true);
                                             @@splash_wd.set_file splash_path
                                             UI.start_timer(0.1, false){
                                               RUBY_PLATFORM =~ /(darwin)/ ? @@splash_wd.show_modal() ; @@splash_wd.show();
                                             }
                                             UI.start_timer(3, false){@@splash_wd.close}
                                          

                                          I'm not here much anymore.

                                          1 Reply Last reply Reply Quote 0
                                          • Chris FullmerC Offline
                                            Chris Fullmer
                                            last edited by

                                            Interesting, I would have just put it as modal for both. Modal just means it stays on top of all windows?

                                            Lately you've been tan, suspicious for the winter.
                                            All my Plugins I've written

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

                                            Advertisement