Changeset 13701

Show
Ignore:
Timestamp:
05/12/08 09:24:09 (6 months ago)
Author:
ttrenka
Message:

Fixes to get QuickTime? version information in Opera without entirely killing the browser. I love race conditions. !strict.

Location:
dojox/trunk/embed
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dojox/trunk/embed/Quicktime.js

    r13642 r13701  
    162162        if(!dojo.isIE){ 
    163163                // FIXME: Opera does not like this at all for some reason, and of course there's no event references easily found. 
    164                 qtVersion = { major: 0, minor: 0, rev: 0 }; 
     164                qtVersion = dojox.embed._quicktime.version = { major: 0, minor: 0, rev: 0 }; 
    165165                var o = qtMarkup({ path: testMovieUrl, width:4, height:4 }); 
    166                 if(!dojo._initFired){ 
    167                         var s='<div style="top:0;left:0;width:1px;height:1px;overflow:hidden;position:absolute;" id="-qt-version-test">' 
    168                                 + o.markup 
    169                                 + '</div>'; 
    170                         document.write(s); 
    171                 } else { 
    172                         var n = document.createElement("div"); 
    173                         n.id="-qt-version-test"; 
    174                         n.style.cssText = "top:0;left:0;width:1px;height:1px;overflow:hidden;position:absolute;"; 
    175                         dojo.body().appendChild(n); 
    176                         n.innerHTML = o.markup; 
    177                 } 
    178  
    179                 function qtGetInfo(){ 
    180                         var qt=document[o.id], n=dojo.byId("-qt-version-test"), v = [ 0, 0, 0 ]; 
     166 
     167                function qtInsert(){ 
     168                        if(!dojo._initFired){ 
     169                                var s='<div style="top:0;left:0;width:1px;height:1px;;overflow:hidden;position:absolute;" id="-qt-version-test">' 
     170                                        + o.markup 
     171                                        + '</div>'; 
     172                                document.write(s); 
     173                        } else { 
     174                                var n = document.createElement("div"); 
     175                                n.id="-qt-version-test"; 
     176                                n.style.cssText = "top:0;left:0;width:1px;height:1px;overflow:hidden;position:absolute;"; 
     177                                dojo.body().appendChild(n); 
     178                                n.innerHTML = o.markup; 
     179                        } 
     180                } 
     181 
     182                function qtGetInfo(mv){ 
     183                        var qt, n, v = [ 0, 0, 0 ]; 
     184                        if(mv){ 
     185                                qt=mv, n=qt.parentNode; 
     186                        } else { 
     187                                qtInsert(); 
     188                                if(!dojo.isOpera){ 
     189                                        setTimeout(function(){ qtGetInfo(document[o.id]); }, 50); 
     190                                } else { 
     191                                        var fn=function(){  
     192                                                setTimeout(function(){ qtGetInfo(document[o.id]) }, 50);  
     193                                        }; 
     194                                        if(!dojo._initFired){ 
     195                                                dojo.addOnLoad(fn); 
     196                                        } else { 
     197                                                dojo.connect(document[o.id], "onload", fn); 
     198                                        } 
     199                                } 
     200                                return; 
     201                        } 
     202 
    181203                        if(qt){ 
    182204                                try { 
     
    196218                        } 
    197219 
    198                         // dojo.body().removeChild(n); 
    199                 } 
    200  
    201                 if(dojo.isOpera){ 
    202                         setTimeout(qtGetInfo, 50); 
    203                 } else { 
    204                         qtGetInfo(); 
    205                 } 
    206         } 
    207          
    208         if(dojo.isIE && installed){ 
     220                        try { 
     221                                if(!mv){ 
     222                                        dojo.body().removeChild(n); 
     223                                } 
     224                        } catch(e){ } 
     225                } 
     226 
     227                qtGetInfo(); 
     228        } 
     229        else if(dojo.isIE && installed){ 
    209230                dojox.embed._quicktime.onInitialize(); 
    210231        } 
     
    238259                //              Returns a reference to the HTMLObject/HTMLEmbed that is created to  
    239260                //              place the movie in the document.  You can use this either with or 
    240                 //              without the new operator.  Note that if the QuickTime engine isn't 
    241                 //              available yet, this will throw an Error. 
     261                //              without the new operator.  Note that with any other DOM manipulation, 
     262                //              you must wait until the document is finished loading before trying 
     263                //              to use this. 
    242264                // 
    243265                //      example: 
     
    257279                //      |       }, myWrapperNode); 
    258280 
    259                 if(dojox.embed._quicktime.initialized){ 
    260                         return dojox.embed._quicktime.place(kwArgs, node);      //      HTMLObject 
    261                 } 
    262                 throw new Error("dojox.embed.Quicktime:: you must wait for the Quicktime engine to be initialized."); 
     281                return dojox.embed._quicktime.place(kwArgs, node);      //      HTMLObject 
    263282        }; 
    264283})(); 
  • dojox/trunk/embed/tests/quicktime.html

    r13276 r13701  
    1111                        dojo.require("dojox.embed.Quicktime"); 
    1212                         
    13                         var v=dojox.embed._quicktime.version; 
    14                         console.log("while loading: ", v); 
    15  
    16                         dojo.addOnLoad(function(){ 
     13                        function getVersion(){ 
    1714                                var v=dojox.embed._quicktime.version || { major: 0, minor: 0, rev: 0 }; 
    1815                                dojo.byId("results").innerHTML = v.major 
    1916                                        + '.' + v.minor 
    2017                                        + '.' + v.rev; 
    21                         }); 
     18                        }; 
    2219                </script> 
    2320        </head> 
     
    2724                        This page is testing the base QuickTime movie generator.  See the Firebug log for details. 
    2825                </p> 
    29                 <p>Note that at this time, version detection before load in Opera is not supported.</p>  
     26                <input type="submit" value="Get Quicktime Version" onclick="getVersion()" />     
    3027                <p>Installed QuickTime version: <span id="results"></span></p> 
    3128        </body>