OS Detection

Discussion about forum rules, new moderators, website content, website layout, VideoLAN artwork etc..
Forum rules
Please read the forum's rules carefully before posting. This forum should not be used to post VLC usage related questions.
nikola23
Cone that earned his stripes
Cone that earned his stripes
Posts: 115
Joined: 03 Feb 2009 07:25
VLC version: 1.2 pre3
Operating System: Win7\Ubuntu 10.10

OS Detection

Postby nikola23 » 10 Jun 2009 08:07

I added some code to the script on the front side that detects your OS.. currently it only detects that your running os x. I added a little code to have it check which version you're running so that when 1.0.0 comes out everyone running 10.4 wont be downloading an incompatible version... I could only test it on os x 10.4, 10.5 and windows vista though so someone might want to double check the logic.

Code: Select all

<script type="text/javascript"><!-- if ( navigator.platform.indexOf("Win32") != -1 ) { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9/win32/vlc-0.9.9-win32.exe">Download Now</a> for Windows (16 MB)</p>'); } else if( navigator.platform.indexOf("BeOS") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-beos.html">Download Now</a> for BeOS</p>'); } else if( navigator.platform.indexOf("Linux") != -1 ) { if( navigator.userAgent.indexOf("Ubuntu") != -1 || navigator.userAgent.indexOf("ubuntu") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-ubuntu.html">Download Now</a> for Ubuntu Linux</p>'); } else if( navigator.userAgent.indexOf("Fedora") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-fedora.html">Download Now</a> for Fedora Linux</p>');} else if( navigator.userAgent.indexOf("SUSE") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-suse.html">Download Now</a> for Suse Linux</p>'); } else if( navigator.userAgent.indexOf("Debian") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-debian.html">Download Now</a> for Debian GNU/Linux</p>'); } else if( navigator.userAgent.indexOf("Mandriva") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-mandriva.html">Download Now</a> for Mandriva Linux</p>'); } else if( navigator.userAgent.indexOf("Red Hat") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-redhat.html">Download Now</a> for RedHat Linux</p>'); } else if( navigator.userAgent.indexOf("gentoo") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-gentoo.html">Download Now</a> for Gentoo Linux</p>'); } else { document.writeln( '<p><a class="download" href="/vlc/">Download Now</a> for Linux and other OSes</p>'); } } else if( navigator.userAgent.indexOf("freebsd") != -1 || navigator.userAgent.indexOf("FreeBSD") != -1 ) { document.writeln( '<p><a class="download" href="/vlc/download-freebsd.html">Download Now</a> for FreeBSD</p>'); } else if( navigator.userAgent.indexOf("Mac OS X") != -1 ||navigator.userAgent.indexOf("MSIE 5.2") != -1 ||( navigator.userAgent.indexOf("Mac") && navigator.userAgent.indexOf("Opera") ) ) { if ( navigator.oscpu.indexOf("10.1") != -1 ) { document.writeln( '<p><a class="download" href="http://download.videolan.org/pub/videolan/vlc/0.7.0/macosx/vlc-0.7.0.dmg">Download Now</a> for Mac OS X 10.1 (7.3 MB)</p>');} else if ( navigator.oscpu.indexOf("10.2") != -1 ) { document.writeln( '<p><a class="download" href="http://download.videolan.org/pub/videolan/vlc/0.8.4a/macosx/vlc-0.8.4a.dmg">Download Now</a> for Mac OS X 10.2 (13 MB)</p>');} else if ( navigator.oscpu.indexOf("10.3") != -1 ) { document.writeln( '<p><a class="download" href="http://download.videolan.org/pub/videolan/vlc/0.8.6i/macosx/vlc-0.8.6i-powerpc.dmg">Download Now</a> for Mac OS X 10.3 (14.2 MB)</p>');} else if ( navigator.oscpu.indexOf("10.4") != -1 ) { if( navigator.platform.indexOf("MacPPC") != -1|| navigator.platform.indexOf("PowerPC") != -1 ) { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-powerpc.dmg">Download Now</a> for Mac OS X PowerPC (19 MB)</p>'); } else if( navigator.platform.indexOf("Intel") != -1 ) { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-intel.dmg">Download Now</a> for Mac OS X Intel (19 MB)</p>');} else { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-powerpc.dmg">Download Now</a> for Mac OS X PowerPC (19 MB)</p>');document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-intel.dmg">Download Now</a> for Mac OS X Intel (19 MB)</p>'); } } else if ( navigator.oscpu.indexOf("10.5") != -1 ) { if( navigator.platform.indexOf("MacPPC") != -1|| navigator.platform.indexOf("PowerPC") != -1 ) { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-powerpc.dmg">Download Now</a> for Mac OS X PowerPC (19 MB)</p>'); } else if( navigator.platform.indexOf("Intel") != -1 ) { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-intel.dmg">Download Now</a> for Mac OS X Intel (19 MB)</p>');} else { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-powerpc.dmg">Download Now</a> for Mac OS X PowerPC (19 MB)</p>');document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-intel.dmg">Download Now</a> for Mac OS X Intel (19 MB)</p>'); } } } else if( navigator.platform.indexOf("Mac") != -1 ) { document.writeln( "<p>Haha Mac OS 9 is dead! (if you\\\'re not using Mac OS 9 ... please write us a mail so we can fix this OS detection script)</p>'" ); } else { document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9/win32/vlc-0.9.9-win32.exe">Download Now</a> for Windows (16 MB)</p>');document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-powerpc.dmg">Download Now</a> for Mac OS X PowerPC (19 MB)</p>');document.writeln( '<p><a class="download" href="/mirror-geo.php?file=vlc/0.9.9a/macosx/vlc-0.9.9a-intel.dmg">Download Now</a> for Mac OS X Intel (19 MB)</p>'); } --></script>

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: OS Detection

Postby Jean-Baptiste Kempf » 10 Jun 2009 13:02

Can you send a patch against the website code?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

nikola23
Cone that earned his stripes
Cone that earned his stripes
Posts: 115
Joined: 03 Feb 2009 07:25
VLC version: 1.2 pre3
Operating System: Win7\Ubuntu 10.10

Re: OS Detection

Postby nikola23 » 10 Jun 2009 18:34

http://pastebin.com/m643e4204 That's just against the original script itself... hopefully it's more readable because its all tabbed out and such this time.

nikola23
Cone that earned his stripes
Cone that earned his stripes
Posts: 115
Joined: 03 Feb 2009 07:25
VLC version: 1.2 pre3
Operating System: Win7\Ubuntu 10.10

Re: OS Detection

Postby nikola23 » 11 Jun 2009 21:41

Is that more along the lines of what you were asking for?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: OS Detection

Postby Jean-Baptiste Kempf » 12 Jun 2009 00:06

No, I have no time for this.

Please patch source code of website:
http://svn.videolan.org/listing.php?rep ... deolan.org_
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Arite
Big Cone-huna
Big Cone-huna
Posts: 2478
Joined: 26 Jun 2007 20:40
VLC version: 3.0.20
Operating System: Debian Testing|Win10

Re: OS Detection

Postby Arite » 12 Jun 2009 02:59

@nikola23: This is probably the file you want to patch (in addition to index.php perhaps):
http://svn.videolan.org/filedetails.php ... ecific.php

Arite.
Don't use PMs for support questions.


Return to “Forum, Website and Artwork discussion”

Who is online

Users browsing this forum: No registered users and 5 guests