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

    Is mac set_html working, again?

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 2 Posters 2.1k Views 2 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

      maybe it's only fixed on Mountain Lion...
      do any of them work; I assume you switched to a local image, no offence intended.
      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
      • thomthomT Offline
        thomthom
        last edited by

        Yea, I replaced the path to a file on my desktop. I checked it was found by Ruby by File.exist?

        What Safari version do you have?
        Mine is Versjon 5.0.6 (5533.22.3)

        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

          actually, I added file:/// and they still all work, do these or the others run on a pc?

          html=<<SETHTML
          <img src="file;////Users/johns_iMac/Desktop/400px-Lion_Rampant.png" alt="test image" title="my test1" >
          SETHTML
          dlg1 = UI;;WebDialog.new("it works again1", true,"img", 250, 250, 150, 150, true);
          dlg1.set_html(html)
          dlg1.show_modal
          #----------------------------------------------------------------------------------------------------
          dlg2 = UI;;WebDialog.new("it works again2", true,"img", 250, 250, 400, 150, true);
          dlg2.set_html(%q(<img src="file;////Users/johns_iMac/Desktop/400px-Lion_Rampant.png" alt="test image" title="my test2" >))
          dlg2.show_modal
          #----------------------------------------------------------------------------------------------------
          
          dlg3 = UI;;WebDialog.new("it works again3", true,"img", 250, 250, 650, 150, true);
          dlg3.set_html(%Q(<img src="file;////Users/johns_iMac/Desktop/400px-Lion_Rampant.png" alt="test image" title="my test2" >))
          dlg3.show_modal
          #----------------------------------------------------------------------------------------------------
          imgPath="/Users/johns_iMac/Desktop/400px-Lion_Rampant.png"
          html1=<<SETHTML
          <img src="file;///
          SETHTML
          html2=<<SETHTML2
          " alt="test image" title="my test1" >
          SETHTML2
          html=(html1 + imgPath + html2)
          dlg4 = UI;;WebDialog.new("it works again4", true,"img", 250, 250, 900, 150, true);
          dlg4.set_html(html)
          dlg4.show_modal
          #----------------------------------------------------------------------------------------------------
          
          imgPath=(File.expand_path("~/Desktop/400px-Lion_Rampant.png"))
          html1=<<SETHTML
          <img src="file;///
          SETHTML
          html2=<<SETHTML2
          " alt="test image" title="my test1" >
          SETHTML2
          html=(html1 + imgPath + html2)
          dlg5 = UI;;WebDialog.new("it works again5", true,"img", 250, 250, 1150, 150, true);
          dlg5.set_html(html)
          dlg5.show_modal
          #----------------------------------------------------------------------------------------------------
          

          incase you need a rampant lion for your desktop

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

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

            @driven said:

            actually, I added file:/// and they still all work, do these or the others run on a pc?

            Yes. With and without file:///

            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

              @thomthom said:

              Yea, I replaced the path to a file on my desktop. I checked it was found by Ruby by File.exist?

              What Safari version do you have?
              Mine is Versjon 5.0.6 (5533.22.3)

              WebDialog is using
              %(#004080)[Browser
              Unknown Mozilla
              Browser Version 5.0
              Operating System
              Apple OS X
              User Agent String Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko)]Safari is using
              %(#008000)[Browser
              Apple Safari
              Browser Version 6.0
              Operating System
              Apple OS X
              User Agent String Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.17 (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17]
              they are quite different things, as I keep telling people...
              easiest way to confirm...

               wwhdlg = UI;;WebDialog.new("wot_works_here", true, "wwh", 739, 641, 50, 50, true);
               wwhdlg.set_url "http://www.findmebyip.com"
               wwhdlg.show_modal
               wwhdlg.navigation_buttons_enabled=true
              

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

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

                /AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)
                

                or you can paste this in Web Inspector

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

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

                  Browser
                  Unknown Mozilla
                  Browser Version 5.0
                  Operating System
                  Apple OS X
                  User Agent String Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.50.2 (KHTML, like Gecko)

                  /AppleWebKit/([\d.]+)/.exec(navigator.userAgent)
                  ["AppleWebKit/534.50.2", "534.50.2"]

                  Is it a different version in WebDialogs due to compatibility reasons?

                  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

                    Safari is an Application and Apple keeps it ahead by keeping WebCore and WebKit at least one step behind, I test SU things in Safari for 'future proofing' rather then current state, I have a simple browser I built to the Webdialog spec for 'current state' external testing, but it's easiest inside SU with Web Inspector.

                    I 'think' that if you can update WebKit manually, but I'd need to look it up...
                    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
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Well, I was about to just update my OSX - seeing how it's obsolete...

                      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

                        I split off the conversation about upgrading OSX to a separate topic: http://sketchucation.com/forums/viewtopic.php?f=180&t=49371&p=443690#p443690

                        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

                          the other part of set_html that was broken, was XMLHttpRequest
                          here an almost functioning test... at the moment you need to use a link with a full href to get the css etc...
                          or adding the links to your header might work. Bit odd but works

                          #----------------------------------------------------------------------------------------------------
                          
                          imgPath=(File.expand_path("~/Desktop/400px-Lion_Rampant.png"))
                          html1=<<SETHTML
                          <html>
                          <head>
                          <script>
                          function requestIt() {
                              var req = new XMLHttpRequest();
                              req.open('GET', 'http://www.sketchup.com/index.html');
                              req.onreadystatechange = function (evt) {
                                    /* readyState 4 indicates the transaction is complete; status 200 indicates "OK" */
                                    if (req.readyState == 4 && req.status == 200) {
                                        var log = document.getElementById('log');
                                        log.innerHTML = req.responseText;
                                  }
                          
                              };
                              req.send(null);
                          }
                          </script>
                          <style> body {background; url("file;///#{imgPath}") no-repeat center center fixed;
                          	-webkit-background-size; cover;}</style>
                          </head>
                          <body>
                              <button onclick="requestIt();">Click to Request</button>
                              <div id="log"></div>
                          </body>
                          </html>
                          SETHTML
                          
                          html=(html1)
                          dlg6 = UI;;WebDialog.new("it works again6", true,"img", 850, 850, 150, 450, true);
                          dlg6.set_html(html)
                          dlg6.allow_actions_from_host("")
                          dlg6.navigation_buttons_enabled = true
                          dlg6.show_modal
                          #----------------------------------------------------------------------------------------------------
                          
                          

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

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

                            I nicked this from the other thread, because thought it was appropiate to something I wanted to say...
                            @thomthom said:

                            @jolran said:

                            So doing like that and putting in an image for button like below would work on Mac?

                            It used to work, then it didn't. Then it might be working for some. But not me.
                            I wouldn't rely on it.

                            I agree, for now, for general release plugins, but I like using set_html with Heredoc for simple short scripts, like toolbar buttons.

                            If your on the 'evil' WebKit version you could use the same basics but write to file the use set_file

                            I'll dig up the unix call to check webkit version, then a conditional could do either/or
                            thoughts...
                            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
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement