From c1fb471d265b0c7f6b70efda530cfec248ac54a0 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 29 Nov 2017 12:16:44 +0000 Subject: [PATCH] detect the gpu (kinda) --- ...ouWillNotGetAutoUpdatedHelpForYourUsers.js | 272 ++++++++++++++++++ detect_gpu.html | 72 +++++ index.nginx-debian.html | 37 ++- official_webgl_troubleshooting.html | 87 ++++++ 4 files changed, 464 insertions(+), 4 deletions(-) create mode 100644 DoNotCopyOrLinkThisFileElseYouWillNotGetAutoUpdatedHelpForYourUsers.js create mode 100644 detect_gpu.html create mode 100644 official_webgl_troubleshooting.html diff --git a/DoNotCopyOrLinkThisFileElseYouWillNotGetAutoUpdatedHelpForYourUsers.js b/DoNotCopyOrLinkThisFileElseYouWillNotGetAutoUpdatedHelpForYourUsers.js new file mode 100644 index 0000000..1481fc5 --- /dev/null +++ b/DoNotCopyOrLinkThisFileElseYouWillNotGetAutoUpdatedHelpForYourUsers.js @@ -0,0 +1,272 @@ +/* Do not copy this file. Instead, do something like this in your + own code. + + if (!window.WebGLRenderingContext) { + // Browser has no idea what WebGL is. Suggest they + // get a new browser by presenting the user with link to + // http://get.webgl.org + return; + } + + gl = canvas.getContext("webgl"); + if (!gl) { + // Browser could not initialize WebGL. User probably needs to + // update their drivers or get a new browser. Present a link to + // http://get.webgl.org/troubleshooting + return; + } + +*/ + +var BrowserDetect = { + init: function () { + var info = this.searchString(this.dataBrowser) || {identity:"unknown"} + this.browser = info.identity; + this.version = this.searchVersion(navigator.userAgent) + || this.searchVersion(navigator.appVersion) + || "an unknown version"; + this.platformInfo = this.searchString(this.dataPlatform) || this.dataPlatform["unknown"]; + this.platform = this.platformInfo.identity; + var browserInfo = this.urls[this.browser]; + if (!browserInfo) { + browserInfo = this.urls["unknown"]; + } else if (browserInfo.platforms) { + var info = browserInfo.platforms[this.platform]; + if (info) { + browserInfo = info; + } + } + this.urls = browserInfo; + }, + searchString: function (data) { + for (var i = 0; i < data.length; i++){ + var info = data[i]; + var dataString = info.string; + var dataProp = info.prop; + this.versionSearchString = info.versionSearch || info.identity; + if (dataString) { + if (dataString.indexOf(info.subString) != -1) { + var shouldExclude = false; + if (info.excludeSubstrings) { + for (var ii = 0; ii < info.excludeSubstrings.length; ++ii) { + if (dataString.indexOf(info.excludeSubstrings[ii]) != -1) { + shouldExclude = true; + break; + } + } + } + if (!shouldExclude) + return info; + } + } else if (dataProp) { + return info; + } + } + }, + searchVersion: function (dataString) { + var index = dataString.indexOf(this.versionSearchString); + if (index == -1) { + return; + } + return parseFloat(dataString.substring( + index + this.versionSearchString.length + 1)); + }, + dataBrowser: [ + { string: navigator.userAgent, + subString: "Chrome", + excludeSubstrings: ["OPR/", "Edge/"], + identity: "Chrome" + }, + { string: navigator.userAgent, + subString: "OmniWeb", + versionSearch: "OmniWeb/", + identity: "OmniWeb" + }, + { string: navigator.vendor, + subString: "Apple", + identity: "Safari", + versionSearch: "Version" + }, + { string: navigator.vendor, + subString: "Opera", + identity: "Opera" + }, + { string: navigator.userAgent, + subString: "Android", + identity: "Android" + }, + { string: navigator.vendor, + subString: "iCab", + identity: "iCab" + }, + { string: navigator.vendor, + subString: "KDE", + identity: "Konqueror" + }, + { string: navigator.userAgent, + subString: "Firefox", + identity: "Firefox" + }, + { string: navigator.vendor, + subString: "Camino", + identity: "Camino" + }, + {// for newer Netscapes (6+) + string: navigator.userAgent, + subString: "Netscape", + identity: "Netscape" + }, + { string: navigator.userAgent, + subString: "Edge/", + identity: "Edge" + }, + { string: navigator.userAgent, + subString: "MSIE", + identity: "Explorer", + versionSearch: "MSIE" + }, + { // for IE11+ + string: navigator.userAgent, + subString: "Trident", + identity: "Explorer", + versionSearch: "rv" + }, + { string: navigator.userAgent, + subString: "Gecko", + identity: "Mozilla", + versionSearch: "rv" + }, + { // for older Netscapes (4-) + string: navigator.userAgent, + subString: "Mozilla", + identity: "Netscape", + versionSearch: "Mozilla" + } + ], + dataPlatform: [ + { string: navigator.platform, + subString: "Win", + identity: "Windows", + browsers: [ + {url: "http://www.mozilla.com/en-US/firefox/new/", name: "Mozilla Firefox"}, + {url: "http://www.opera.com/", name: "Opera"}, + {url: "http://www.google.com/chrome/", name: "Google Chrome"}, + {url: "http://www.microsoft.com/en-us/windows/windows-10-upgrade ", name: "Edge"}, + {url: "http://www.microsoft.com/ie", name: "Internet Explorer"} + ] + }, + { string: navigator.platform, + subString: "Mac", + identity: "Mac", + browsers: [ + {url: "http://www.mozilla.com/en-US/firefox/new/", name: "Mozilla Firefox"}, + {url: "http://www.google.com/chrome/", name: "Google Chrome"}, + {url: "http://www.opera.com/", name: "Opera"}, + {url: "http://www.webkit.org/", name: "WebKit Developer Builds"} + ] + }, + { string: navigator.userAgent, + subString: "iPhone", + identity: "iPhone/iPod", + browsers: [ + {url: "http://www.mozilla.com/en-US/firefox/new/", name: "Mozilla Firefox"} + ] + }, + { string: navigator.platform, + subString: "iPad", + identity: "iPad", + browsers: [ + {url: "http://www.mozilla.com/en-US/firefox/new/", name: "Mozilla Firefox"} + ] + }, + { string: navigator.userAgent, + subString: "Android", + identity: "Android", + browsers: [ + {url: "https://market.android.com/details?id=org.mozilla.firefox", name: "Mozilla Firefox"}, + {url: "https://market.android.com/details?id=com.opera.browser", name: "Opera Mobile"} + ] + }, + { string: navigator.platform, + subString: "Linux", + identity: "Linux", + browsers: [ + {url: "http://www.mozilla.com/en-US/firefox/new/", name: "Mozilla Firefox"}, + {url: "http://www.google.com/chrome/", name: "Google Chrome"}, + {url: "http://www.opera.com/", name: "Opera"} + ] + }, + { string: "unknown", + subString: "unknown", + identity: "unknown", + browsers: [ + {url: "http://www.mozilla.com/en-US/firefox/new/", name: "Mozilla Firefox"}, + {url: "http://www.google.com/chrome/", name: "Google Chrome"}, + {url: "http://www.opera.com/", name: "Opera"}, + {url: "http://www.webkit.org/", name: "WebKit Developer Builds"} + ] + } + ], + /* + upgradeUrl: Tell the user how to upgrade their browser. + troubleshootingUrl: Help the user. + platforms: Urls by platform. See dataPlatform.identity for valid platform names. + */ + urls: { + "Chrome": { + upgradeUrl: "http://www.google.com/support/chrome/bin/answer.py?answer=95346", + troubleshootingUrl: "http://www.google.com/support/chrome/bin/answer.py?answer=1220892" + }, + "Firefox": { + upgradeUrl: "http://www.mozilla.com/en-US/firefox/new/", + troubleshootingUrl: "https://support.mozilla.com/en-US/kb/how-do-i-upgrade-my-graphics-drivers" + }, + "Opera": { + platforms: { + "Android": { + upgradeUrl: "https://market.android.com/details?id=com.opera.browser", + troubleshootingUrl: "http://www.opera.com/support/" + } + }, + upgradeUrl: "http://www.opera.com/", + troubleshootingUrl: "http://www.opera.com/support/" + }, + "Android": { + upgradeUrl: null, + troubleshootingUrl: null + }, + "Safari": { + platforms: { + "iPhone/iPod": { + upgradeUrl: "http://www.apple.com/ios/", + troubleshootingUrl: "http://www.apple.com/support/iphone/" + }, + "iPad": { + upgradeUrl: "http://www.apple.com/ios/", + troubleshootingUrl: "http://www.apple.com/support/ipad/" + }, + "Mac": { + upgradeUrl: "http://www.webkit.org/", + troubleshootingUrl: "https://support.apple.com/kb/PH21426" + } + }, + upgradeUrl: "http://www.webkit.org/", + troubleshootingUrl: "https://support.apple.com/kb/PH21426" + }, + "Explorer": { + upgradeUrl: "http://www.microsoft.com/ie", + troubleshootingUrl: "http://msdn.microsoft.com/en-us/library/ie/bg182648(v=vs.85).aspx" + }, + "Edge": { + upgradeUrl: "http://www.microsoft.com/en-us/windows/windows-10-upgrade", + troubleshootingUrl: "http://msdn.microsoft.com/en-us/library/ie/bg182648(v=vs.85).aspx" + }, + "unknown": { + upgradeUrl: null, + troubleshootingUrl: null + } + } +}; + + + diff --git a/detect_gpu.html b/detect_gpu.html new file mode 100644 index 0000000..5cf6871 --- /dev/null +++ b/detect_gpu.html @@ -0,0 +1,72 @@ + + Banner + + + + + +

All objects in canvas.getContext('webgl')

+ + +
+ +

All objects in gl.getExtension('WEBGL_debug_renderer_info')

+ + +
+ + diff --git a/index.nginx-debian.html b/index.nginx-debian.html index 6a9faf4..f012b6f 100644 --- a/index.nginx-debian.html +++ b/index.nginx-debian.html @@ -15,10 +15,30 @@

-Your web browser is: +Your web browser is:

@@ -41,6 +61,7 @@ document.write(navigator.appName + "

"); java test1
java test2
java test3
+dump javascript webgl info
dump javascript info

@@ -49,6 +70,13 @@ document.write(navigator.appName + "

"); onChange= "alert('changing this will cause an alert')"> +
+Official Mozilla Window Object documentation
+Official webgl troubleshooting site
+Official webgl troubleshooting site (local copy)
+
+ +

All objects in window.navigator

+ + + + + + + + + +
+
+
+
+ +
+
+
+
+ +