Noob Webdialog/Javascript question

Hi everyone ! I was wondering, is there a way to create an HTML file with a Javascript button which would then launch a sequence of actions whithin SketchUp? The idea is the following:

  • The user clicks on the button
  • A prompt saying he’ll quit SketchUp appears (In the WebDialog or in SketchUp, I don’t care)
  • If he confirms, the WebDialog closes, the user is taken to a specific page in his default browser (Let’s say here he is taken to http://example.com) and SketchUp quits. (Hopefully it does not Force Quit)

Does it have to be a webdialog? A messagebox doesn’t work for this?

Here is an example. But what happens when any open model has been modified, is that the webbrowser gets the focus displaying the website,… and SketchUp does not close (behind the browser window) because it is displaying a modal “Save file ?” messagebox.

Yes this is not a WebDialog example, but a webdialog callback can just as eaily call the “command()” method:

module SomeAuthor::SomePlugin

  extend self
  
  @@loaded ||= false
  PROMPT = "Quit SketchUp and open a website ?"
  BUTTONTEXT = "Quit Example"

  def quit_responce?()
    # A prompt saying he'll quit SketchUp appears
    # (In the WebDialog or in SketchUp, I don't care)
    responce = UI::messagebox(PROMPT,MB_YESNO)
    responce == IDYES ? true : false
  end

  def display_page(
    url = "http://extensions.sketchup.com"
  )
    # If he confirms, ..., the user is taken to a specific
    #  page in his default browser
    UI::openURL(url)
  end

  def command()
    if quit_responce?
      display_page()
      # and SketchUp quits, first prompting user to save work:
      Sketchup::quit()
    end
  end

  if !@@loaded
    UI.menu("Plugins").add_item(BUTTONTEXT) {
      # The user clicks on the button
      command()
    }
    @@loaded = true
  end

end

I want it to show that there’s an update only when there’s an update, so I need to be connected to a webpage/address/whatever…

Yeah I did know it would do just that, but still, I didn’t want the user to be left with no option to save. He’ll be informed in the dialog that if there are any unsaved model, he’ll have to go back to save his models.