News for hackers. Stuff that matters.
Re:Poll: Do you have Silverlight installed? by reitzensteinm on Monday October 04, 2010 @03:24AM (#1754903)
I do not understand what's going through the mind of a developer who makes a site to display a software version number and does not have a special case for not installed. Incredible.
Re:Poll: Do you have Silverlight installed? by StavrosK on Monday October 04, 2010 @04:10AM (#1754988)
It's Microsoft software. Who would not have it?! Clearly adding the code branch is an unnecessary waste of time.
Re:Poll: Do you have Silverlight installed? by thebigshane on Monday October 04, 2010 @10:49AM (#1755786)

        function doit(){
            var parts = Array("ver-major", "ver-minor", "ver-build", "ver-revision");
            
            //try firefox/non-IE version.
            var nav = navigator.plugins["Silverlight Plug-In"];
            if (nav) {
                for (var i = 0; i < 4; i++) {
                    document.getElementById(parts[i]).innerHTML = parseInt(nav.description.split(".")[i]).toString();   //getControl().isVersionSupported("2.0"); 
                }
            } else {
                //try the IE one now.
                try {
                    var control = new ActiveXObject('AgControl.AgControl');
                    //the following would be faster with a binary search, but this is "fast enough" for now. 
                    var vers = Array(1, 0, 0, 0);
                    loopMatch(control, vers, 0, 1);
                    loopMatch(control, vers, 1, 1);
                    loopMatch(control, vers, 2, 10000);
                    loopMatch(control, vers, 2, 1000);
                    loopMatch(control, vers, 2, 100);
                    loopMatch(control, vers, 2, 10);
                    loopMatch(control, vers, 2, 1);
                    loopMatch(control, vers, 3, 1);
                    for (var i = 0; i < 4; i++) {
                        document.getElementById(parts[i]).innerHTML = vers[i].toString();
                    }
                } catch (e) {
                    document.getElementById("vers-discrete").innerHTML = "Silverlight not installed.";
                }
            }
        }
        function loopMatch(control, vers, idx, inc) {
            while(IsSupported(control, vers)){
                vers[idx]+=inc;
            }
            vers[idx] -= inc;
        }
        function IsSupported(control, ver){
            return control.isVersionSupported(ver[0]+ "."+ ver[1] + "." + ver[2] + "." + ver[3]);
        }
        
        doit(); 
All I can say is... "interesting"

EDIT: that is the code they are using as of this posting

Re:Poll: Do you have Silverlight installed? by boomhauer on Monday October 04, 2010 @12:45PM (#1756322)
hey, you found my crappy little site ;) the IE version will correctly state "not installed" but apparently the FF/Non-IE is returning a non-null nav object, thus printing the zeros. btw- the reason for creating this site- extracting the exact version number is not straightforward, for some reason. MS decided to let us have isVersionSupported(), instead of a simple getVersion() or similiar. Thus, loop it.
Re:Poll: Do you have Silverlight installed? by thebigshane on Tuesday October 05, 2010 @11:43AM (#1760152)
Yea, I thought your approach was interesting (as is typical in most code reviews) but I was also amazed at the non-straightforwardness of getting said version number.

EDIT: Also, a lot of commenters here are just making jokes (funny ones, sure) but not actually looking at or considering the code required to get the version number.

Re:Poll: Do you have Silverlight installed? by hx on Monday October 04, 2010 @06:48AM (#1755245)
No, they have a special case for not installed...you just need silverlight to display it.
Re:Poll: Do you have Silverlight installed? by Hexstream on Monday October 04, 2010 @02:11PM (#1756642)
No keyboard detected.

Press any key to continue.

Re:Poll: Do you have Silverlight installed? by RK on Monday October 04, 2010 @06:53PM (#1757867)
Taking a page from the myriad of sites that require cookies and when cookies are not enabled throw up some horribly cryptic error unrelated to cookies or fail completely.
Re:Poll: Do you have Silverlight installed? by pan69 on Monday October 04, 2010 @04:10AM (#1754986)
I guess he was making a site to get the Silverlight version, not whether it was installed or not.
Re:Poll: Do you have Silverlight installed? by gruseom on Monday October 04, 2010 @04:45AM (#1755040)
Perhaps he is a Javascript programmer who thinks that zero means no.
Re:Poll: Do you have Silverlight installed? by aerique on Monday October 04, 2010 @07:11AM (#1755279)
You have zero cakes. Can you give me one?
Re:Poll: Do you have Silverlight installed? by mseebach on Monday October 04, 2010 @08:58AM (#1755487)
You have $0 in your account. Do you exist?