├── releasenotes.md ├── logo.jpg ├── scripts ├── sauce-sample.json ├── install.js ├── test.js └── build.sh ├── justrelease.yml ├── bower.json ├── .drone.yml ├── gulpfile.js ├── .drone.sec ├── karma ├── aircover.conf.js ├── local.conf.js └── drone.conf.js ├── .gitignore ├── package.json ├── src ├── vendor │ ├── murmurhash3.js │ ├── fontdetect.js │ ├── deployJava.js │ ├── swfobject.js │ └── ua-parser.js └── client.js ├── specs └── ClientJSpec.js ├── README.md ├── LICENSE └── dist └── client.min.js /releasenotes.md: -------------------------------------------------------------------------------- 1 | ClientJs Release Notes 2 | -------------------------------------------------------------------------------- /logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joshkar/clientjs/HEAD/logo.jpg -------------------------------------------------------------------------------- /scripts/sauce-sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "username": "yourSauceUsername", 3 | "accessKey": "yourSauceAccessKey" 4 | } 5 | -------------------------------------------------------------------------------- /justrelease.yml: -------------------------------------------------------------------------------- 1 | version.update: 2 | - json 3 | create.artifacts: 4 | - npm install 5 | publish: 6 | - github: 7 | - description:releasenotes.md 8 | - attachment:dist/client.min.js -------------------------------------------------------------------------------- /scripts/install.js: -------------------------------------------------------------------------------- 1 | // Creates sauce.json if not yet present after install 2 | var fs = require('fs'); 3 | 4 | if (!fs.existsSync('sauce.json')) { 5 | fs.writeFileSync('sauce.json', fs.readFileSync('./scripts/sauce-sample.json')); 6 | } 7 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clientjs", 3 | "version": "0.1.11", 4 | "main": ["dist/client.min.js"], 5 | "ignore": [ 6 | ".travis.yml", 7 | ".gitignore", 8 | "build", 9 | "grunt.js", 10 | "LICENSE", 11 | "node_modules", 12 | "package.json" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.drone.yml: -------------------------------------------------------------------------------- 1 | build: 2 | image: node:latest 3 | environment: 4 | - SAUCE_USERNAME=$$SAUCE_USERNAME 5 | - SAUCE_ACCESS_KEY=$$SAUCE_ACCESS_KEY 6 | commands: 7 | - export BUILD_NUMBER=$DRONE_BUILD_NUMBER 8 | - npm install --quiet 9 | - npm install --quiet -g karma-cli 10 | - npm test 11 | 12 | publish: 13 | coverage: 14 | token: $$GITHUB_TOKEN 15 | include: jackspirou/clientjs/coverage/lcov.info 16 | when: 17 | branch: master 18 | -------------------------------------------------------------------------------- /scripts/test.js: -------------------------------------------------------------------------------- 1 | var spawn = require('child_process').spawn, karma; 2 | 3 | if (process.env.CI || process.env.DRONE) { 4 | karma = spawn('./node_modules/karma/bin/karma', ['start', 'karma/drone.conf.js']) 5 | } else { 6 | karma = spawn('./node_modules/karma/bin/karma', ['start', 'karma/local.conf.js']) 7 | } 8 | 9 | karma.stdout.on('data', function (data) { 10 | process.stdout.write(data); 11 | }); 12 | 13 | karma.stderr.on('data', function (data) { 14 | process.stdout.write(data); 15 | }); 16 | 17 | karma.on('exit', function (code) { 18 | process.exit(code) 19 | }); 20 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require("gulp"), 2 | closureCompiler = require('gulp-closure-compiler'); 3 | 4 | gulp.task('compress', function() { 5 | gulp.src("src/**/*.js") 6 | .pipe(closureCompiler({ 7 | // compilerPath is optional, since google-closure-compiler is a dependency 8 | // compilerPath: 'bower_components/closure-compiler/lib/vendor/compiler.jar', 9 | fileName: 'client.min.js', 10 | compilerFlags: {compilation_level: 'SIMPLE_OPTIMIZATIONS'} 11 | })) 12 | .pipe(gulp.dest('dist')); 13 | }); 14 | 15 | gulp.task("default", ["compress"], function() {}); 16 | -------------------------------------------------------------------------------- /.drone.sec: -------------------------------------------------------------------------------- 1 | eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.naZ1ZlMpAFxwzNOaGvEKoeNhE3SQOUTvFOYZMVhdGTf1EJc3BwPh4Chs4FtG0jEyZppCP1UkYfVnONWKWVhjcvJ2APLNSX1vFuq6nDv8WM9AnGqB475v9f58Rcl8u6Eqq0NvvPD3M67Bgk3bv5NLwCnYAkhMwl4gmtbL4f_eC2W7YIzsojRPvj4bdoLnmy8KK-D10dsXEpA81ZI9h0fzn9FXc9gEo0vOX40DMiv1TdUJBlItReSVST_2B9F5lSomFZN7DYLsPVHJ7o1FM4DGC4A8qQpUYz5wQme6GhlsXOKXNfmuAbStm3eoUzTGv6CIyf7uUys81y48Stz1FfQkQw.RGma1N7Gg6_suZhs.IgCP4YFRx-Cx6xWw8OunxeVo35MnQ8TI2JJEM0eIPSZH7F8XGte4qQCS7ZyKK81DIIaD_H6W2w8yxSkKhDgyRgss1W7camoy4kZmw3NmWymcfV96vziTRWhZ5bUNnUlDyaShkrD-yJnX5uwYjVlj2-YN2zQpDeUW5N9NZ1v08kq5absuQrI2OBWFouEEC_U6_3BJPnNYIGDMn4Ftm7Px1JwyPyFPJl3JjVMszY-mROu6dcuwl4wsqV0oJges73wyi2-lqW0eBal5MBnCdNsVMHBKmSusxm5LxZyjNgMwgDOYLeNj6A.FwC4gtJGBAXAHBeIzX919w -------------------------------------------------------------------------------- /karma/aircover.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function(config) { 2 | 3 | config.set({ 4 | 5 | // base path that will be used to resolve all patterns (eg. files, exclude) 6 | basePath: '../', 7 | 8 | // frameworks to use 9 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 10 | frameworks: ['jasmine'], 11 | 12 | // list of files / patterns to load in the browser 13 | files: [ 14 | 'src/**/*.js', 15 | 'specs/**/*.js' 16 | ], 17 | 18 | // test results reporter to use 19 | // possible values: 'dots', 'progress' 20 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 21 | reporters: ['progress', 'coverage'], 22 | preprocessors: { 23 | 'src/*.js': ['coverage'] 24 | }, 25 | 26 | browsers: ['PhantomJS'], 27 | 28 | coverageReporter: { 29 | // specify a common output directory 30 | dir: 'coverage', 31 | reporters: [ 32 | // reporters supporting the `file` property, use `subdir` to directly 33 | // output them in the `dir` directory 34 | { type: 'lcovonly', subdir: '.', file: 'lcov.info' } 35 | ] 36 | }, 37 | 38 | singleRun: true 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS FILE HAS BEEN DEPRECATED, MINIFICATIONS ARE DONE NOW VIA GULP. 3 | # 4 | 5 | # 6 | # File: build.sh 7 | # 8 | # This script uses the Google Closure Compiler to build the client.min.js file. 9 | # https://developers.google.com/closure/compiler/ 10 | # 11 | 12 | # 13 | # The Closure Compiler is a tool for making JavaScript download and run faster. 14 | # It is a true compiler for JavaScript. Instead of compiling from a source 15 | # language to machine code, it compiles from JavaScript to better JavaScript. 16 | # It parses your JavaScript, analyzes it, removes dead code and rewrites and 17 | # minimizes what's left. It also checks syntax, variable references, and types, 18 | # and warns about common JavaScript pitfalls. 19 | # 20 | 21 | # 22 | # DEPENDIECIES 23 | # 24 | # 1. You must have the Java JRE installed. 25 | # http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 26 | # 27 | # 2. You must have compiler.jar installed at ~/bin/compiler.jar 28 | # https://code.google.com/p/closure-compiler/downloads/list 29 | # 30 | 31 | # Assume compiler.jar exists in the users $HOME/bin directory. 32 | # Compile using proper settings and include vendor dependiencies. 33 | java -jar ~/bin/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --js=src/vendor/ua-parser.js --js=src/vendor/fontdetect.js --js=src/vendor/swfobject.js --js=src/vendor/murmurhash3.js --js=src/vendor/deployJava.js --js=src/client.js --js_output_file=dist/client.min.js 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## 2 | # DRONE 3 | ## 4 | .secrets.yml 5 | sauce.json 6 | 7 | ## 8 | # NODE 9 | ## 10 | 11 | # Logs 12 | logs 13 | *.log 14 | npm-debug.log* 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | 21 | # Directory for instrumented libs generated by jscoverage/JSCover 22 | lib-cov 23 | 24 | # Coverage directory used by tools like istanbul 25 | coverage 26 | 27 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 28 | .grunt 29 | 30 | # node-waf configuration 31 | .lock-wscript 32 | 33 | # Compiled binary addons (http://nodejs.org/api/addons.html) 34 | build/Release 35 | 36 | # Dependency directory 37 | node_modules 38 | 39 | # Optional npm cache directory 40 | .npm 41 | 42 | # Optional REPL history 43 | .node_repl_history 44 | 45 | ## 46 | # MAC OSX 47 | ## 48 | 49 | .DS_Store 50 | .AppleDouble 51 | .LSOverride 52 | 53 | # Icon must end with two \r 54 | Icon 55 | 56 | 57 | # Thumbnails 58 | ._* 59 | 60 | # Files that might appear in the root of a volume 61 | .DocumentRevisions-V100 62 | .fseventsd 63 | .Spotlight-V100 64 | .TemporaryItems 65 | .Trashes 66 | .VolumeIcon.icns 67 | 68 | # Directories potentially created on remote AFP share 69 | .AppleDB 70 | .AppleDesktop 71 | Network Trash Folder 72 | Temporary Items 73 | .apdisk 74 | 75 | ## 76 | # WINDOWS OS 77 | ## 78 | 79 | # Windows image file caches 80 | Thumbs.db 81 | ehthumbs.db 82 | 83 | # Folder config file 84 | Desktop.ini 85 | 86 | # Recycle Bin used on file shares 87 | $RECYCLE.BIN/ 88 | 89 | # Windows Installer files 90 | *.cab 91 | *.msi 92 | *.msm 93 | *.msp 94 | 95 | # Windows shortcuts 96 | *.lnk 97 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clientjs", 3 | "version": "0.1.11", 4 | "homepage": "https://clientjs.org", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/jackspirou/clientjs.git" 8 | }, 9 | "description": "Device information and digital fingerprinting written in pure JavaScript.", 10 | "keywords": [ 11 | "browser", 12 | "fingerprint", 13 | "client", 14 | "info", 15 | "pure", 16 | "javascript" 17 | ], 18 | "author": "Jack Spirou (http://twitter.com/jack_spirou)", 19 | "contributors": [ 20 | { 21 | "name": "Jack Spirou", 22 | "url": "http://twitter.com/jack_spirou", 23 | "email": "jack@spirou.io" 24 | }, 25 | { 26 | "name": "Daniel Montoya", 27 | "url": "http://twitter.com/dsmontoya", 28 | "email": "dsmontoyam@gmail.com" 29 | } 30 | ], 31 | "bugs": { 32 | "url": "https://github.com/jackspirou/clientjs/issues" 33 | }, 34 | "scripts": { 35 | "postinstall": "node scripts/install.js", 36 | "test": "node scripts/test.js", 37 | "posttest": "./node_modules/karma/bin/karma start karma/aircover.conf.js", 38 | "prepublish": "./node_modules/gulp/bin/gulp.js" 39 | }, 40 | "main": "dist/client.min.js", 41 | "devDependencies": { 42 | "gulp": "^3.9.0", 43 | "gulp-closure-compiler": "^0.4.0", 44 | "jasmine-core": "~2.4.1", 45 | "karma": "^0.13.19", 46 | "karma-chrome-launcher": "~0.2.2", 47 | "karma-coverage": "^0.5.3", 48 | "karma-firefox-launcher": "~0.1.7", 49 | "karma-jasmine": "^0.3.6", 50 | "karma-opera-launcher": "~0.3.0", 51 | "karma-phantomjs-launcher": "^0.2.3", 52 | "karma-safari-launcher": "~0.1.1", 53 | "karma-sauce-launcher": "^0.3.0", 54 | "phantomjs": "^1.9.19" 55 | }, 56 | "license": "Apache-2.0", 57 | "licenses": [ 58 | { 59 | "type": "Apache-2.0", 60 | "url": "http://www.apache.org/licenses/LICENSE-2.0" 61 | } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /karma/local.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Mon Jan 18 2016 21:06:29 GMT-0500 (EST) 3 | 4 | module.exports = function(config) { 5 | config.set({ 6 | 7 | // base path that will be used to resolve all patterns (eg. files, exclude) 8 | basePath: '../', 9 | 10 | // frameworks to use 11 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 12 | frameworks: ['jasmine'], 13 | 14 | // list of files / patterns to load in the browser 15 | files: [ 16 | 'src/**/*.js', 17 | 'specs/**/*.js' 18 | ], 19 | 20 | // list of files to exclude 21 | exclude: [ 22 | ], 23 | 24 | // preprocess matching files before serving them to the browser 25 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 26 | preprocessors: {}, 27 | 28 | // test results reporter to use 29 | // possible values: 'dots', 'progress' 30 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 31 | reporters: ['progress'], 32 | 33 | // web server port 34 | port: 9876, 35 | 36 | // enable / disable colors in the output (reporters and logs) 37 | colors: true, 38 | 39 | // level of logging 40 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 41 | logLevel: config.LOG_INFO, 42 | 43 | 44 | // enable / disable watching file and executing tests whenever any file changes 45 | autoWatch: true, 46 | 47 | // start these browsers 48 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 49 | browsers: ['Chrome', 'Safari', 'Firefox', 'Opera'], 50 | 51 | // Continuous Integration mode 52 | // if true, Karma captures browsers, runs the tests and exits 53 | singleRun: true, 54 | 55 | // Concurrency level 56 | // how many browser should be started simultaneous 57 | concurrency: Infinity 58 | }) 59 | } 60 | -------------------------------------------------------------------------------- /src/vendor/murmurhash3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011) 3 | * 4 | * @author Gary Court 5 | * @see http://github.com/garycourt/murmurhash-js 6 | * @author Austin Appleby 7 | * @see http://sites.google.com/site/murmurhash/ 8 | * 9 | * @param {string} key ASCII only 10 | * @param {number} seed Positive integer only 11 | * @return {number} 32-bit positive integer hash 12 | */ 13 | 14 | function murmurhash3_32_gc(key, seed) { 15 | var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i; 16 | 17 | remainder = key.length & 3; // key.length % 4 18 | bytes = key.length - remainder; 19 | h1 = seed; 20 | c1 = 0xcc9e2d51; 21 | c2 = 0x1b873593; 22 | i = 0; 23 | 24 | while (i < bytes) { 25 | k1 = 26 | ((key.charCodeAt(i) & 0xff)) | 27 | ((key.charCodeAt(++i) & 0xff) << 8) | 28 | ((key.charCodeAt(++i) & 0xff) << 16) | 29 | ((key.charCodeAt(++i) & 0xff) << 24); 30 | ++i; 31 | 32 | k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; 33 | k1 = (k1 << 15) | (k1 >>> 17); 34 | k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; 35 | 36 | h1 ^= k1; 37 | h1 = (h1 << 13) | (h1 >>> 19); 38 | h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; 39 | h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); 40 | } 41 | 42 | k1 = 0; 43 | 44 | switch (remainder) { 45 | case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; 46 | case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; 47 | case 1: k1 ^= (key.charCodeAt(i) & 0xff); 48 | 49 | k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; 50 | k1 = (k1 << 15) | (k1 >>> 17); 51 | k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; 52 | h1 ^= k1; 53 | } 54 | 55 | h1 ^= key.length; 56 | 57 | h1 ^= h1 >>> 16; 58 | h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; 59 | h1 ^= h1 >>> 13; 60 | h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; 61 | h1 ^= h1 >>> 16; 62 | 63 | return h1 >>> 0; 64 | } 65 | -------------------------------------------------------------------------------- /karma/drone.conf.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | module.exports = function(config) { 4 | 5 | // Use ENV vars on Drone and sauce.json locally to get credentials 6 | if (!process.env.SAUCE_USERNAME) { 7 | if (!fs.existsSync('sauce.json')) { 8 | console.log('Create a sauce.json with your credentials based on the sauce-sample.json file.'); 9 | process.exit(1); 10 | } else { 11 | process.env.SAUCE_USERNAME = require('./sauce').username; 12 | process.env.SAUCE_ACCESS_KEY = require('./sauce').accessKey; 13 | } 14 | } 15 | 16 | // Browsers to run on Sauce Labs 17 | var customLaunchers = { 18 | 'SL_Chrome': { 19 | base: 'SauceLabs', 20 | browserName: 'chrome' 21 | }, 22 | 'SL_FireFox': { 23 | base: 'SauceLabs', 24 | browserName: 'firefox', 25 | }, 26 | 'SL_Safari': { 27 | base: 'SauceLabs', 28 | browserName: 'safari', 29 | }, 30 | 'SL_Opera': { 31 | base: 'SauceLabs', 32 | browserName: 'opera', 33 | }, 34 | 'SL_InternetExplorer': { 35 | base: 'SauceLabs', 36 | browserName: 'internet explorer', 37 | version: '10' 38 | }, 39 | 'SL_Edge': { 40 | base: 'SauceLabs', 41 | browserName: 'microsoftedge' 42 | }, 43 | 'SL_IPhone': { 44 | base: 'SauceLabs', 45 | browserName: 'iPhone' 46 | }, 47 | 'SL_Android': { 48 | base: 'SauceLabs', 49 | browserName: 'android' 50 | }, 51 | 'SL_IPad': { 52 | base: 'SauceLabs', 53 | browserName: 'iPad' 54 | } 55 | }; 56 | 57 | config.set({ 58 | 59 | sauceLabs: { 60 | testName: 'ClientJS' 61 | }, 62 | 63 | // base path that will be used to resolve all patterns (eg. files, exclude) 64 | basePath: '../', 65 | 66 | // frameworks to use 67 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 68 | frameworks: ['jasmine'], 69 | 70 | // list of files / patterns to load in the browser 71 | files: [ 72 | 'src/**/*.js', 73 | 'specs/**/*.js' 74 | ], 75 | 76 | // test results reporter to use 77 | // possible values: 'dots', 'progress' 78 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 79 | reporters: ['progress', 'saucelabs'], 80 | 81 | // web server port 82 | port: 9876, 83 | 84 | colors: true, 85 | 86 | // level of logging 87 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 88 | logLevel: config.LOG_INFO, 89 | 90 | captureTimeout: 180000, 91 | customLaunchers: customLaunchers, 92 | 93 | // start these browsers 94 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 95 | browsers: Object.keys(customLaunchers), 96 | singleRun: true 97 | }); 98 | }; 99 | -------------------------------------------------------------------------------- /src/vendor/fontdetect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * JavaScript code to detect available availability of a 3 | * particular font in a browser using JavaScript and CSS. 4 | * 5 | * Author : Lalit Patel 6 | * Website: http://www.lalit.org/lab/javascript-css-font-detect/ 7 | * License: Apache Software License 2.0 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Version: 0.15 (21 Sep 2009) 10 | * Changed comparision font to default from sans-default-default, 11 | * as in FF3.0 font of child element didn't fallback 12 | * to parent element if the font is missing. 13 | * Version: 0.2 (04 Mar 2012) 14 | * Comparing font against all the 3 generic font families ie, 15 | * 'monospace', 'sans-serif' and 'sans'. If it doesn't match all 3 16 | * then that font is 100% not available in the system 17 | * Version: 0.3 (24 Mar 2012) 18 | * Replaced sans with serif in the list of baseFonts 19 | */ 20 | 21 | /** 22 | * Usage: d = new Detector(); 23 | * d.detect('font name'); 24 | */ 25 | var Detector = function() { 26 | // a font will be compared against all the three default fonts. 27 | // and if it doesn't match all 3 then that font is not available. 28 | var baseFonts = ['monospace', 'sans-serif', 'serif']; 29 | 30 | //we use m or w because these two characters take up the maximum width. 31 | // And we use a LLi so that the same matching fonts can get separated 32 | var testString = "mmmmmmmmmmlli"; 33 | 34 | //we test using 72px font size, we may use any size. I guess larger the better. 35 | var testSize = '72px'; 36 | 37 | var h = document.getElementsByTagName("body")[0]; 38 | 39 | // create a SPAN in the document to get the width of the text we use to test 40 | var s = document.createElement("span"); 41 | s.style.fontSize = testSize; 42 | s.innerHTML = testString; 43 | var defaultWidth = {}; 44 | var defaultHeight = {}; 45 | for (var index in baseFonts) { 46 | //get the default width for the three base fonts 47 | s.style.fontFamily = baseFonts[index]; 48 | h.appendChild(s); 49 | defaultWidth[baseFonts[index]] = s.offsetWidth; //width for the default font 50 | defaultHeight[baseFonts[index]] = s.offsetHeight; //height for the defualt font 51 | h.removeChild(s); 52 | } 53 | 54 | function detect(font) { 55 | var detected = false; 56 | for (var index in baseFonts) { 57 | s.style.fontFamily = font + ',' + baseFonts[index]; // name of the font along with the base font for fallback. 58 | h.appendChild(s); 59 | var matched = (s.offsetWidth != defaultWidth[baseFonts[index]] || s.offsetHeight != defaultHeight[baseFonts[index]]); 60 | h.removeChild(s); 61 | detected = detected || matched; 62 | } 63 | return detected; 64 | } 65 | 66 | this.detect = detect; 67 | }; 68 | -------------------------------------------------------------------------------- /specs/ClientJSpec.js: -------------------------------------------------------------------------------- 1 | describe("ClientJS", function(){ 2 | var client; 3 | beforeEach(function(){ 4 | client = new ClientJS(); 5 | }); 6 | 7 | it("should initialize an instance", function(){ 8 | expect(client).not.toBeNull(); 9 | }); 10 | 11 | describe("#getSoftwareVersion", function(){ 12 | it("should be a string", function(){ 13 | expect(client.getSoftwareVersion()).toEqual(jasmine.any(String)) 14 | }); 15 | }); 16 | 17 | describe("browser data", function(){ 18 | var browserData; 19 | beforeEach(function() { 20 | browserData = client.getBrowserData(); 21 | }) 22 | 23 | describe("#getBrowserData", function(){ 24 | it("should return a UAParser result", function(){ 25 | var parser = (new (window.UAParser||exports.UAParser)); 26 | expect(browserData).toEqual(parser.getResult()) 27 | }); 28 | 29 | it("should be something", function(){ 30 | expect(browserData).not.toBeNull() 31 | }) 32 | }); 33 | 34 | describe("#getUserAgent", function(){ 35 | it("should be equal to browserData.ua", function(){ 36 | expect(client.getUserAgent()).toEqual(browserData.ua); 37 | }); 38 | }); 39 | 40 | describe("#getUserAgentLowerCase", function(){ 41 | it("should be equal to client.getUserAgent, but in lower case", function(){ 42 | expect(client.getUserAgentLowerCase()).toEqual(client.getUserAgent().toLowerCase()); 43 | }); 44 | }); 45 | 46 | describe("#getBrowser", function(){ 47 | it("should be equal to browserData.browser.name", function(){ 48 | expect(client.getBrowser()).toEqual(browserData.browser.name); 49 | }); 50 | }); 51 | 52 | describe("#getBrowserVersion", function(){ 53 | it("should be equal to browserData.browser.version", function(){ 54 | expect(client.getBrowserVersion()).toEqual(browserData.browser.version); 55 | }); 56 | }); 57 | 58 | describe("#getBrowserMajorVersion", function(){ 59 | it("should be equal to browserData.browser.major", function(){ 60 | expect(client.getBrowserMajorVersion()).toEqual(browserData.browser.major); 61 | }); 62 | }); 63 | 64 | describe("#isIE|Chrome|Firefox|Safari|Opera", function(){ 65 | it("should return true with the correct browser", function(){ 66 | var browsers = ["IE", "Chrome", "Firefox", "Safari", "Opera"]; 67 | for (var i = 0; i < browsers.length; i++) { 68 | var browser = browsers[i], 69 | isBrowser = client["is" + browser](); 70 | if (client.getBrowser() == browser) { 71 | expect(isBrowser).toBeTruthy() 72 | } else if (client.getBrowser() == "Mobile Safari" && browser == "Safari") { 73 | expect(isBrowser).toBeTruthy() 74 | }else{ 75 | expect(isBrowser).toBeFalsy() 76 | } 77 | } 78 | }); 79 | }); 80 | 81 | describe("#getCanvasPrint", function(){ 82 | it("should return a String", function(){ 83 | expect(client.getCanvasPrint()).toEqual(jasmine.any(String)); 84 | }); 85 | }); 86 | 87 | describe("Fingerprint generators", function(){ 88 | var fingerprint; 89 | beforeEach(function() { 90 | fingerprint = client.getFingerprint(); 91 | }); 92 | 93 | describe("#getFingerPrint", function(){ 94 | it("should return a Number", function(){ 95 | expect(fingerprint).toEqual(jasmine.any(Number)); 96 | }); 97 | }); 98 | 99 | describe("#getCustomFingerprint", function(){ 100 | var customFingerprint; 101 | beforeEach(function() { 102 | customFingerprint = client.getCustomFingerprint("custom", "fingerprint") 103 | }); 104 | 105 | it("should return a Number", function(){ 106 | expect(customFingerprint).toEqual(jasmine.any(Number)); 107 | }); 108 | 109 | it("should not generate the same fingerprint than getCustomFingerprint", function(){ 110 | expect(customFingerprint).not.toEqual(fingerprint); 111 | }); 112 | 113 | //Fix to https://github.com/jackspirou/clientjs/issues/19 114 | it("should not ignore the last argument", function(){ 115 | var newCustomFingerprint = client.getCustomFingerprint("custom", "fingerprint :)"); 116 | expect(customFingerprint).not.toEqual(newCustomFingerprint); 117 | }); 118 | }); 119 | }); 120 | }); 121 | }); 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Sauce Test Status](logo.jpg) 2 | 3 | **Device information and digital fingerprinting written in _pure_ JavaScript.** 4 | 5 | [![Sauce Test Status](https://saucelabs.com/buildstatus/clientjs)](https://saucelabs.com/u/clientjs) [![Build Status](http://beta.drone.io/api/badges/jackspirou/clientjs/status.svg)](http://beta.drone.io/jackspirou/clientjs) [![Aircover Coverage](https://aircover.co/badges/jackspirou/clientjs/coverage.svg)](https://aircover.co/jackspirou/clientjs) [![Kanban board for ClientJS issues at https://huboard.com/jackspirou/clientjs](https://img.shields.io/badge/Hu-Board-7965cc.svg)](https://huboard.com/jackspirou/clientjs) [![Join the chat at https://gitter.im/jackspirou/clientjs](https://badges.gitter.im/jackspirou/clientjs.svg)](https://gitter.im/jackspirou/clientjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 6 | 7 | [![Sauce Test Status](https://saucelabs.com/browser-matrix/clientjs.svg)](https://saucelabs.com/u/clientjs) 8 | 9 | ClientJS is a JavaScript library that makes digital fingerprinting easy, while also exposing all the browser data-points used in generating fingerprints. 10 | 11 | If you want to fingerprint browsers, you are **_probably_** also interested in other client-based information, such as screen resolution, operating system, browser type, device type, and much more. 12 | 13 | Below are some features that make ClientJS different from other fingerprinting libraries: 14 | - It's pure native JavaScript 15 | - It's decently lightweight at ~45 KB 16 | - All user data points are available by design, not just the 32bit integer fingerprint 17 | 18 | ## Documentation and Demos 19 | You can find more documentation and demos on each method at [clientjs.org](https://clientjs.org/). 20 | 21 | ## Installation 22 | To use ClientJS, simply include `dist/client.min.js`. 23 | 24 | ClientJS is available for download via [bower](http://bower.io/search/?q=clientjs) and [npm](https://www.npmjs.com/package/clientjs). 25 | 26 | ### npm 27 | 28 | ```shell 29 | npm install clientjs 30 | ``` 31 | 32 | ### Bower 33 | 34 | ```shell 35 | bower install clientjs 36 | ``` 37 | 38 | ## Fingerprinting 39 | Digital fingerprints are based on device/browser settings. 40 | They allow you to make an "educated guess" about the identify of a new or returning visitor. 41 | By taking multiple data points, combining them, and representing them as a number, you can be surprisingly accurate at recognizing not only browsers and devices, but also individual users. 42 | 43 | This is useful for identifying users or devices without cookies or sessions. 44 | It is not a full proof technique, but it has been shown to be statistically significant at accurately identifying devices. 45 | 46 | Simply create a new ClientJS object. 47 | Then call the `getFingerprint()` method which will return the browser/device fingerprint as a 32bit integer hash ID. 48 | 49 | Below is an example of how to generate and display a fingerprint: 50 | 51 | ```javascript 52 | // Create a new ClientJS object 53 | var client = new ClientJS(); 54 | 55 | // Get the client's fingerprint id 56 | var fingerprint = client.getFingerprint(); 57 | 58 | // Print the 32bit hash id to the console 59 | console.log(fingerprint); 60 | ``` 61 | 62 | The current data-points that used to generate fingerprint 32bit integer hash ID is listed below: 63 | - user agent 64 | - screen print 65 | - color depth 66 | - current resolution 67 | - available resolution 68 | - device XDPI 69 | - device YDPI 70 | - plugin list 71 | - font list 72 | - local storage 73 | - session storage 74 | - timezone 75 | - language 76 | - system language 77 | - cookies 78 | - canvas print 79 | 80 | ## Available Methods 81 | Below is the current list of available methods to find information on a users browser/device. 82 | 83 | You can find documentation on each method at [clientjs.org](https://clientjs.org/). 84 | 85 | ``` 86 | var client = new ClientJS(); 87 | 88 | client.getBrowserData(); 89 | client.getFingerprint(); 90 | client.getCustomFingerprint(...); 91 | 92 | client.getUserAgent(); 93 | client.getUserAgentLowerCase(); 94 | 95 | client.getBrowser(); 96 | client.getBrowserVersion(); 97 | client.getBrowserMajorVersion(); 98 | client.isIE(); 99 | client.isChrome(); 100 | client.isFirefox(); 101 | client.isSafari(); 102 | client.isOpera(); 103 | 104 | client.getEngine(); 105 | client.getEngineVersion(); 106 | 107 | client.getOS(); 108 | client.getOSVersion(); 109 | client.isWindows(); 110 | client.isMac(); 111 | client.isLinux(); 112 | client.isUbuntu(); 113 | client.isSolaris(); 114 | 115 | client.getDevice(); 116 | client.getDeviceType(); 117 | client.getDeviceVendor(); 118 | 119 | client.getCPU(); 120 | 121 | client.isMobile(); 122 | client.isMobileMajor(); 123 | client.isMobileAndroid(); 124 | client.isMobileOpera(); 125 | client.isMobileWindows(); 126 | client.isMobileBlackBerry(); 127 | 128 | client.isMobileIOS(); 129 | client.isIphone(); 130 | client.isIpad(); 131 | client.isIpod(); 132 | 133 | client.getScreenPrint(); 134 | client.getColorDepth(); 135 | client.getCurrentResolution(); 136 | client.getAvailableResolution(); 137 | client.getDeviceXDPI(); 138 | client.getDeviceYDPI(); 139 | 140 | client.getPlugins(); 141 | client.isJava(); 142 | client.getJavaVersion(); 143 | client.isFlash(); 144 | client.getFlashVersion(); 145 | client.isSilverlight(); 146 | client.getSilverlightVersion(); 147 | 148 | client.getMimeTypes(); 149 | client.isMimeTypes(); 150 | 151 | client.isFont(); 152 | client.getFonts(); 153 | 154 | client.isLocalStorage(); 155 | client.isSessionStorage(); 156 | client.isCookie(); 157 | 158 | client.getTimeZone(); 159 | 160 | client.getLanguage(); 161 | client.getSystemLanguage(); 162 | 163 | client.isCanvas(); 164 | client.getCanvasPrint(); 165 | ``` 166 | 167 | ## Shoulders of Giants 168 | It is important to note this project owes much to other pieces great works. 169 | We had the advantage of observing how others had approached this problem. 170 | 171 | Built Upon: 172 | - https:github.com/Valve/fingerprintjs 173 | - http:darkwavetech.com/device_fingerprint.html 174 | - detectmobilebrowsers.com 175 | 176 | ## Vendor Code 177 | All dependencies are included into `client.min.js` when the `build.sh` bash file minifies the project. Vendored dependencies should not be included separately. 178 | 179 | Dependencies Include: 180 | - ua-parser.js 181 | - fontdetect.js 182 | - swfobject.js 183 | - murmurhash3.js 184 | 185 | ## Contributing 186 | Collaborate by [forking](https://help.github.com/articles/fork-a-repo/) this project and sending a Pull Request this way. 187 | 188 | Once cloned, install all dependencies. ClientJS uses [Karma](https://karma-runner.github.io/0.13/index.html) as its testing environment. 189 | 190 | ```shell 191 | # Install dependencies 192 | $ npm install 193 | 194 | # If you want tu run karma from the command line 195 | $ npm install -g karma-cli 196 | ``` 197 | 198 | Run Karma and enjoy coding! 199 | 200 | ```shell 201 | $ karma start 202 | ``` 203 | 204 | Thanks for contributing to ClientJS! Please report any bug [here](https://github.com/jackspirou/clientjs/issues). 205 | 206 | ## LICENSE 207 | This project is using the Apache LICENSE Version 2.0. It is included in the project source code. 208 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/client.js: -------------------------------------------------------------------------------- 1 | // 2 | // ClientJS. An easy to use, simple, and flexible client information library written in JavaScript. 3 | // 4 | // Version: 0.1.11 5 | // 6 | // Original Author: Jack Spirou 7 | // Original Data: 5 Nov 2013 8 | 9 | // ClientJS. Return a JavaScript object containing information collected about a client. 10 | // Return browser/device fingerprint as a 32 bit integer hash ID. 11 | 12 | // BUILT UPON: 13 | // - https://github.com/Valve/fingerprintjs 14 | // - http://darkwavetech.com/device_fingerprint.html 15 | // - detectmobilebrowsers.com JavaScript Mobile Detection Script 16 | 17 | // Dependencies Include: 18 | // - ua-parser.js 19 | // - fontdetect.js 20 | // - swfobject.js 21 | // - murmurhash3.js 22 | 23 | // BROWSER FINGERPRINT DATA POINTS 24 | // - userAgent 25 | // - screenPrint 26 | // - colordepth 27 | // - currentResolution 28 | // - availableResolution 29 | // - deviceXDPI 30 | // - deviceYDPI 31 | // - plugin list 32 | // - font list 33 | // - localStorage 34 | // - sessionStorage 35 | // - timezone 36 | // - language 37 | // - systemLanguage 38 | // - cookies 39 | // - canvasPrint 40 | 41 | // METHOD Naming CONVENTION 42 | // is[MethodName] = return boolean 43 | // get[MethodName] = return int|string|object 44 | 45 | // METHODS 46 | // 47 | // var client = new ClientJS(); 48 | // 49 | // client.getSoftwareVersion(); 50 | // client.getBrowserData(); 51 | // client.getFingerprint(); 52 | // client.getCustomFingerprint(...); 53 | // 54 | // client.getUserAgent(); 55 | // client.getUserAgentLowerCase(); 56 | // 57 | // client.getBrowser(); 58 | // client.getBrowserVersion(); 59 | // client.getBrowserMajorVersion(); 60 | // client.isIE(); 61 | // client.isChrome(); 62 | // client.isFirefox(); 63 | // client.isSafari(); 64 | // client.isMobileSafari(); 65 | // client.isOpera(); 66 | // 67 | // client.getEngine(); 68 | // client.getEngineVersion(); 69 | // 70 | // client.getOS(); 71 | // client.getOSVersion(); 72 | // client.isWindows(); 73 | // client.isMac(); 74 | // client.isLinux(); 75 | // client.isUbuntu(); 76 | // client.isSolaris(); 77 | // 78 | // client.getDevice(); 79 | // client.getDeviceType(); 80 | // client.getDeviceVendor(); 81 | // 82 | // client.getCPU(); 83 | // 84 | // client.isMobile(); 85 | // client.isMobileMajor(); 86 | // client.isMobileAndroid(); 87 | // client.isMobileOpera(); 88 | // client.isMobileWindows(); 89 | // client.isMobileBlackBerry(); 90 | // 91 | // client.isMobileIOS(); 92 | // client.isIphone(); 93 | // client.isIpad(); 94 | // client.isIpod(); 95 | // 96 | // client.getScreenPrint(); 97 | // client.getColorDepth(); 98 | // client.getCurrentResolution(); 99 | // client.getAvailableResolution(); 100 | // client.getDeviceXDPI(); 101 | // client.getDeviceYDPI(); 102 | // 103 | // client.getPlugins(); 104 | // client.isJava(); 105 | // client.getJavaVersion(); 106 | // client.isFlash(); 107 | // client.getFlashVersion(); 108 | // client.isSilverlight(); 109 | // client.getSilverlightVersion(); 110 | // 111 | // client.getMimeTypes(); 112 | // client.isMimeTypes(); 113 | // 114 | // client.isFont(); 115 | // client.getFonts(); 116 | // 117 | // client.isLocalStorage(); 118 | // client.isSessionStorage(); 119 | // client.isCookie(); 120 | // 121 | // client.getTimeZone(); 122 | // 123 | // client.getLanguage(); 124 | // client.getSystemLanguage(); 125 | // 126 | // client.isCanvas(); 127 | // client.getCanvasPrint(); 128 | 129 | // Anonymous auto JavaScript function execution. 130 | (function(scope) { 131 | 'use strict'; 132 | 133 | var browserData; // Global user agent browser object. 134 | var fontDetective; // Global font detective object. 135 | 136 | // ClientJS constructor which sets the browserData object and returs the client object. 137 | var ClientJS = function() { 138 | var parser = new(window.UAParser || exports.UAParser); 139 | browserData = parser.getResult(); 140 | fontDetective = new Detector(); 141 | return this; 142 | }; 143 | 144 | // ClientJS prototype which contains all methods. 145 | ClientJS.prototype = { 146 | 147 | // 148 | // MAIN METHODS 149 | // 150 | 151 | // Get Software Version. Return a string containing this software version number. 152 | getSoftwareVersion: function() { 153 | var version = "0.1.11"; 154 | return version; 155 | }, 156 | 157 | // Get Browser Data. Return an object containing browser user agent. 158 | getBrowserData: function() { 159 | return browserData; 160 | }, 161 | 162 | // Get Fingerprint. Return a 32-bit integer representing the browsers fingerprint. 163 | getFingerprint: function() { 164 | var bar = '|'; 165 | 166 | var userAgent = browserData.ua; 167 | var screenPrint = this.getScreenPrint(); 168 | var pluginList = this.getPlugins(); 169 | var fontList = this.getFonts(); 170 | var localStorage = this.isLocalStorage(); 171 | var sessionStorage = this.isSessionStorage(); 172 | var timeZone = this.getTimeZone(); 173 | var language = this.getLanguage(); 174 | var systemLanguage = this.getSystemLanguage(); 175 | var cookies = this.isCookie(); 176 | var canvasPrint = this.getCanvasPrint(); 177 | 178 | var key = userAgent + bar + screenPrint + bar + pluginList + bar + fontList + bar + localStorage + bar + sessionStorage + bar + timeZone + bar + language + bar + systemLanguage + bar + cookies + bar + canvasPrint; 179 | var seed = 256; 180 | 181 | return murmurhash3_32_gc(key, seed); 182 | }, 183 | 184 | // Get Custom Fingerprint. Take a string of datapoints and eturn a 32-bit integer representing the browsers fingerprint. 185 | getCustomFingerprint: function() { 186 | var bar = '|'; 187 | var key = ""; 188 | for (var i = 0; i < arguments.length; i++) { 189 | key += arguments[i] + bar; 190 | } 191 | return murmurhash3_32_gc(key, 256); 192 | }, 193 | 194 | // 195 | // USER AGENT METHODS 196 | // 197 | 198 | // Get User Agent. Return a string containing unparsed user agent. 199 | getUserAgent: function() { 200 | return browserData.ua; 201 | }, 202 | 203 | // Get User Agent Lower Case. Return a lowercase string containing the user agent. 204 | getUserAgentLowerCase: function() { 205 | return browserData.ua.toLowerCase(); 206 | }, 207 | 208 | // 209 | // BROWSER METHODS 210 | // 211 | 212 | // Get Browser. Return a string containing the browser name. 213 | getBrowser: function() { 214 | return browserData.browser.name; 215 | }, 216 | 217 | // Get Browser Version. Return a string containing the browser version. 218 | getBrowserVersion: function() { 219 | return browserData.browser.version; 220 | }, 221 | 222 | // Get Browser Major Version. Return a string containing the major browser version. 223 | getBrowserMajorVersion: function() { 224 | return browserData.browser.major; 225 | }, 226 | 227 | // Is IE. Check if the browser is IE. 228 | isIE: function() { 229 | return (/IE/i.test(browserData.browser.name)); 230 | }, 231 | 232 | // Is Chrome. Check if the browser is Chrome. 233 | isChrome: function() { 234 | return (/Chrome/i.test(browserData.browser.name)); 235 | }, 236 | 237 | // Is Firefox. Check if the browser is Firefox. 238 | isFirefox: function() { 239 | return (/Firefox/i.test(browserData.browser.name)); 240 | }, 241 | 242 | // Is Safari. Check if the browser is Safari. 243 | isSafari: function() { 244 | return (/Safari/i.test(browserData.browser.name)); 245 | }, 246 | 247 | // Is Mobile Safari. Check if the browser is Safari. 248 | isMobileSafari: function() { 249 | return (/Mobile\sSafari/i.test(browserData.browser.name)); 250 | }, 251 | 252 | // Is Opera. Check if the browser is Opera. 253 | isOpera: function() { 254 | return (/Opera/i.test(browserData.browser.name)); 255 | }, 256 | 257 | // 258 | // ENGINE METHODS 259 | // 260 | 261 | // Get Engine. Return a string containing the browser engine. 262 | getEngine: function() { 263 | return browserData.engine.name; 264 | }, 265 | 266 | // Get Engine Version. Return a string containing the browser engine version. 267 | getEngineVersion: function() { 268 | return browserData.engine.version; 269 | }, 270 | 271 | // 272 | // OS METHODS 273 | // 274 | 275 | // Get OS. Return a string containing the OS. 276 | getOS: function() { 277 | return browserData.os.name; 278 | }, 279 | 280 | // Get OS Version. Return a string containing the OS Version. 281 | getOSVersion: function() { 282 | return browserData.os.version; 283 | }, 284 | 285 | // Is Windows. Check if the OS is Windows. 286 | isWindows: function() { 287 | return (/Windows/i.test(browserData.os.name)); 288 | }, 289 | 290 | // Is Mac. Check if the OS is Mac. 291 | isMac: function() { 292 | return (/Mac/i.test(browserData.os.name)); 293 | }, 294 | 295 | // Is Linux. Check if the OS is Linux. 296 | isLinux: function() { 297 | return (/Linux/i.test(browserData.os.name)); 298 | }, 299 | 300 | // Is Ubuntu. Check if the OS is Ubuntu. 301 | isUbuntu: function() { 302 | return (/Ubuntu/i.test(browserData.os.name)); 303 | }, 304 | 305 | // Is Solaris. Check if the OS is Solaris. 306 | isSolaris: function() { 307 | return (/Solaris/i.test(browserData.os.name)); 308 | }, 309 | 310 | // 311 | // DEVICE METHODS 312 | // 313 | 314 | // Get Device. Return a string containing the device. 315 | getDevice: function() { 316 | return browserData.device.model; 317 | }, 318 | 319 | // Get Device Type. Return a string containing the device type. 320 | getDeviceType: function() { 321 | return browserData.device.type; 322 | }, 323 | 324 | // Get Device Vendor. Return a string containing the device vendor. 325 | getDeviceVendor: function() { 326 | return browserData.device.vendor; 327 | }, 328 | 329 | // 330 | // CPU METHODS 331 | // 332 | 333 | // Get CPU. Return a string containing the CPU architecture. 334 | getCPU: function() { 335 | return browserData.cpu.architecture; 336 | }, 337 | 338 | // 339 | // MOBILE METHODS 340 | // 341 | 342 | // Is Mobile. Check if the browser is on a mobile device. 343 | isMobile: function() { 344 | // detectmobilebrowsers.com JavaScript Mobile Detection Script 345 | var dataString = browserData.ua || navigator.vendor || window.opera; 346 | return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(dataString) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(dataString.substr(0, 4))); 347 | }, 348 | 349 | // Is Mobile Major. Check if the browser is on a major mobile device. 350 | isMobileMajor: function() { 351 | return (this.isMobileAndroid() || this.isMobileBlackBerry() || this.isMobileIOS() || this.isMobileOpera() || this.isMobileWindows()); 352 | }, 353 | 354 | // Is Mobile. Check if the browser is on an android mobile device. 355 | isMobileAndroid: function() { 356 | if (browserData.ua.match(/Android/i)) { 357 | return true; 358 | } 359 | return false; 360 | }, 361 | 362 | // Is Mobile Opera. Check if the browser is on an opera mobile device. 363 | isMobileOpera: function() { 364 | if (browserData.ua.match(/Opera Mini/i)) { 365 | return true; 366 | } 367 | return false; 368 | }, 369 | 370 | // Is Mobile Windows. Check if the browser is on a windows mobile device. 371 | isMobileWindows: function() { 372 | if (browserData.ua.match(/IEMobile/i)) { 373 | return true; 374 | } 375 | return false; 376 | }, 377 | 378 | // Is Mobile BlackBerry. Check if the browser is on a blackberry mobile device. 379 | isMobileBlackBerry: function() { 380 | if (browserData.ua.match(/BlackBerry/i)) { 381 | return true; 382 | } 383 | return false; 384 | }, 385 | 386 | // 387 | // MOBILE APPLE METHODS 388 | // 389 | 390 | // Is Mobile iOS. Check if the browser is on an Apple iOS device. 391 | isMobileIOS: function() { 392 | if (browserData.ua.match(/iPhone|iPad|iPod/i)) { 393 | return true; 394 | } 395 | return false; 396 | }, 397 | 398 | // Is Iphone. Check if the browser is on an Apple iPhone. 399 | isIphone: function() { 400 | if (browserData.ua.match(/iPhone/i)) { 401 | return true; 402 | } 403 | return false; 404 | }, 405 | 406 | // Is Ipad. Check if the browser is on an Apple iPad. 407 | isIpad: function() { 408 | if (browserData.ua.match(/iPad/i)) { 409 | return true; 410 | } 411 | return false; 412 | }, 413 | 414 | // Is Ipod. Check if the browser is on an Apple iPod. 415 | isIpod: function() { 416 | if (browserData.ua.match(/iPod/i)) { 417 | return true; 418 | } 419 | return false; 420 | }, 421 | 422 | // 423 | // SCREEN METHODS 424 | // 425 | 426 | // Get Screen Print. Return a string containing screen information. 427 | getScreenPrint: function() { 428 | return "Current Resolution: " + this.getCurrentResolution() + ", Available Resolution: " + this.getAvailableResolution() + ", Color Depth: " + this.getColorDepth() + ", Device XDPI: " + this.getDeviceXDPI() + ", Device YDPI: " + this.getDeviceYDPI(); 429 | }, 430 | 431 | // Get Color Depth. Return a string containing the color depth. 432 | getColorDepth: function() { 433 | return screen.colorDepth; 434 | }, 435 | 436 | // Get Current Resolution. Return a string containing the current resolution. 437 | getCurrentResolution: function() { 438 | return screen.width + "x" + screen.height; 439 | }, 440 | 441 | // Get Available Resolution. Return a string containing the available resolution. 442 | getAvailableResolution: function() { 443 | return screen.availWidth + "x" + screen.availHeight; 444 | }, 445 | 446 | // Get Device XPDI. Return a string containing the device XPDI. 447 | getDeviceXDPI: function() { 448 | return screen.deviceXDPI; 449 | }, 450 | 451 | // Get Device YDPI. Return a string containing the device YDPI. 452 | getDeviceYDPI: function() { 453 | return screen.deviceYDPI; 454 | }, 455 | 456 | // 457 | // PLUGIN METHODS 458 | // 459 | 460 | // Get Plugins. Return a string containing a list of installed plugins. 461 | getPlugins: function() { 462 | var pluginsList = ""; 463 | 464 | for (var i = 0; i < navigator.plugins.length; i++) { 465 | if (i == navigator.plugins.length - 1) { 466 | pluginsList += navigator.plugins[i].name; 467 | } else { 468 | pluginsList += navigator.plugins[i].name + ", "; 469 | } 470 | } 471 | return pluginsList; 472 | }, 473 | 474 | // Is Java. Check if Java is installed. 475 | isJava: function() { 476 | return navigator.javaEnabled(); 477 | }, 478 | 479 | // Get Java Version. Return a string containing the Java Version. 480 | getJavaVersion: function() { 481 | return deployJava.getJREs().toString(); 482 | }, 483 | 484 | // Is Flash. Check if Flash is installed. 485 | isFlash: function() { 486 | var objPlugin = navigator.plugins["Shockwave Flash"]; 487 | if (objPlugin) { 488 | return true; 489 | } 490 | return false; 491 | }, 492 | 493 | // Get Flash Version. Return a string containing the Flash Version. 494 | getFlashVersion: function() { 495 | if (this.isFlash()) { 496 | objPlayerVersion = swfobject.getFlashPlayerVersion(); 497 | return objPlayerVersion.major + "." + objPlayerVersion.minor + "." + objPlayerVersion.release; 498 | } 499 | return ""; 500 | }, 501 | 502 | // Is Silverlight. Check if Silverlight is installed. 503 | isSilverlight: function() { 504 | var objPlugin = navigator.plugins["Silverlight Plug-In"]; 505 | if (objPlugin) { 506 | return true; 507 | } 508 | return false; 509 | }, 510 | 511 | // Get Silverlight Version. Return a string containing the Silverlight Version. 512 | getSilverlightVersion: function() { 513 | if (this.isSilverlight()) { 514 | var objPlugin = navigator.plugins["Silverlight Plug-In"]; 515 | return objPlugin.description; 516 | } 517 | return ""; 518 | }, 519 | 520 | // 521 | // MIME TYPE METHODS 522 | // 523 | 524 | // Is Mime Types. Check if a mime type is installed. 525 | isMimeTypes: function() { 526 | if (navigator.mimeTypes && navigator.mimeTypes.length) { 527 | return true; 528 | } 529 | return false; 530 | }, 531 | 532 | // Get Mime Types. Return a string containing a list of installed mime types. 533 | getMimeTypes: function() { 534 | var mimeTypeList = ""; 535 | 536 | if(navigator.mimeTypes) { 537 | for (var i = 0; i < navigator.mimeTypes.length; i++) { 538 | if (i == navigator.mimeTypes.length - 1) { 539 | mimeTypeList += navigator.mimeTypes[i].description; 540 | } else { 541 | mimeTypeList += navigator.mimeTypes[i].description + ", "; 542 | } 543 | } 544 | } 545 | return mimeTypeList; 546 | }, 547 | 548 | // 549 | // FONT METHODS 550 | // 551 | 552 | // Is Font. Check if a font is installed. 553 | isFont: function(font) { 554 | return fontDetective.detect(font); 555 | }, 556 | 557 | // Get Fonts. Return a string containing a list of installed fonts. 558 | getFonts: function() { 559 | var fontArray = ["Abadi MT Condensed Light", "Adobe Fangsong Std", "Adobe Hebrew", "Adobe Ming Std", "Agency FB", "Aharoni", "Andalus", "Angsana New", "AngsanaUPC", "Aparajita", "Arab", "Arabic Transparent", "Arabic Typesetting", "Arial Baltic", "Arial Black", "Arial CE", "Arial CYR", "Arial Greek", "Arial TUR", "Arial", "Batang", "BatangChe", "Bauhaus 93", "Bell MT", "Bitstream Vera Serif", "Bodoni MT", "Bookman Old Style", "Braggadocio", "Broadway", "Browallia New", "BrowalliaUPC", "Calibri Light", "Calibri", "Californian FB", "Cambria Math", "Cambria", "Candara", "Castellar", "Casual", "Centaur", "Century Gothic", "Chalkduster", "Colonna MT", "Comic Sans MS", "Consolas", "Constantia", "Copperplate Gothic Light", "Corbel", "Cordia New", "CordiaUPC", "Courier New Baltic", "Courier New CE", "Courier New CYR", "Courier New Greek", "Courier New TUR", "Courier New", "DFKai-SB", "DaunPenh", "David", "DejaVu LGC Sans Mono", "Desdemona", "DilleniaUPC", "DokChampa", "Dotum", "DotumChe", "Ebrima", "Engravers MT", "Eras Bold ITC", "Estrangelo Edessa", "EucrosiaUPC", "Euphemia", "Eurostile", "FangSong", "Forte", "FrankRuehl", "Franklin Gothic Heavy", "Franklin Gothic Medium", "FreesiaUPC", "French Script MT", "Gabriola", "Gautami", "Georgia", "Gigi", "Gisha", "Goudy Old Style", "Gulim", "GulimChe", "GungSeo", "Gungsuh", "GungsuhChe", "Haettenschweiler", "Harrington", "Hei S", "HeiT", "Heisei Kaku Gothic", "Hiragino Sans GB", "Impact", "Informal Roman", "IrisUPC", "Iskoola Pota", "JasmineUPC", "KacstOne", "KaiTi", "Kalinga", "Kartika", "Khmer UI", "Kino MT", "KodchiangUPC", "Kokila", "Kozuka Gothic Pr6N", "Lao UI", "Latha", "Leelawadee", "Levenim MT", "LilyUPC", "Lohit Gujarati", "Loma", "Lucida Bright", "Lucida Console", "Lucida Fax", "Lucida Sans Unicode", "MS Gothic", "MS Mincho", "MS PGothic", "MS PMincho", "MS Reference Sans Serif", "MS UI Gothic", "MV Boli", "Magneto", "Malgun Gothic", "Mangal", "Marlett", "Matura MT Script Capitals", "Meiryo UI", "Meiryo", "Menlo", "Microsoft Himalaya", "Microsoft JhengHei", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Sans Serif", "Microsoft Tai Le", "Microsoft Uighur", "Microsoft YaHei", "Microsoft Yi Baiti", "MingLiU", "MingLiU-ExtB", "MingLiU_HKSCS", "MingLiU_HKSCS-ExtB", "Miriam Fixed", "Miriam", "Mongolian Baiti", "MoolBoran", "NSimSun", "Narkisim", "News Gothic MT", "Niagara Solid", "Nyala", "PMingLiU", "PMingLiU-ExtB", "Palace Script MT", "Palatino Linotype", "Papyrus", "Perpetua", "Plantagenet Cherokee", "Playbill", "Prelude Bold", "Prelude Condensed Bold", "Prelude Condensed Medium", "Prelude Medium", "PreludeCompressedWGL Black", "PreludeCompressedWGL Bold", "PreludeCompressedWGL Light", "PreludeCompressedWGL Medium", "PreludeCondensedWGL Black", "PreludeCondensedWGL Bold", "PreludeCondensedWGL Light", "PreludeCondensedWGL Medium", "PreludeWGL Black", "PreludeWGL Bold", "PreludeWGL Light", "PreludeWGL Medium", "Raavi", "Rachana", "Rockwell", "Rod", "Sakkal Majalla", "Sawasdee", "Script MT Bold", "Segoe Print", "Segoe Script", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", "Segoe UI", "Shonar Bangla", "Showcard Gothic", "Shruti", "SimHei", "SimSun", "SimSun-ExtB", "Simplified Arabic Fixed", "Simplified Arabic", "Snap ITC", "Sylfaen", "Symbol", "Tahoma", "Times New Roman Baltic", "Times New Roman CE", "Times New Roman CYR", "Times New Roman Greek", "Times New Roman TUR", "Times New Roman", "TlwgMono", "Traditional Arabic", "Trebuchet MS", "Tunga", "Tw Cen MT Condensed Extra Bold", "Ubuntu", "Umpush", "Univers", "Utopia", "Utsaah", "Vani", "Verdana", "Vijaya", "Vladimir Script", "Vrinda", "Webdings", "Wide Latin", "Wingdings"]; 560 | var fontString = ""; 561 | 562 | for (var i = 0; i < fontArray.length; i++) { 563 | if (fontDetective.detect(fontArray[i])) { 564 | if (i == fontArray.length - 1) { 565 | fontString += fontArray[i]; 566 | } else { 567 | fontString += fontArray[i] + ", "; 568 | } 569 | } 570 | } 571 | 572 | return fontString; 573 | }, 574 | 575 | // 576 | // STORAGE METHODS 577 | // 578 | 579 | // Is Local Storage. Check if local storage is enabled. 580 | isLocalStorage: function() { 581 | try { 582 | return !!scope.localStorage; 583 | } catch (e) { 584 | return true; // SecurityError when referencing it means it exists 585 | } 586 | }, 587 | 588 | // Is Session Storage. Check if session storage is enabled. 589 | isSessionStorage: function() { 590 | try { 591 | return !!scope.sessionStorage; 592 | } catch (e) { 593 | return true; // SecurityError when referencing it means it exists 594 | } 595 | }, 596 | 597 | // Is Cookie. Check if cookies are enabled. 598 | isCookie: function() { 599 | return navigator.cookieEnabled; 600 | }, 601 | 602 | // 603 | // TIME METHODS 604 | // 605 | 606 | // Get Time Zone. Return a string containing the time zone. 607 | getTimeZone: function() { 608 | var rightNow, myNumber, formattedNumber, result; 609 | rightNow = new Date(); 610 | myNumber = String(-(rightNow.getTimezoneOffset() / 60)); 611 | if (myNumber < 0) { 612 | myNumber = myNumber * -1; 613 | formattedNumber = ("0" + myNumber).slice(-2); 614 | result = "-" + formattedNumber; 615 | } else { 616 | formattedNumber = ("0" + myNumber).slice(-2); 617 | result = "+" + formattedNumber; 618 | } 619 | return result; 620 | }, 621 | 622 | // 623 | // LANGUAGE METHODS 624 | // 625 | 626 | // Get Language. Return a string containing the user language. 627 | getLanguage: function() { 628 | return navigator.language; 629 | }, 630 | 631 | // Get System Language. Return a string containing the system language. 632 | getSystemLanguage: function() { 633 | return navigator.systemLanguage || window.navigator.language; 634 | }, 635 | 636 | // 637 | // CANVAS METHODS 638 | // 639 | 640 | // Is Canvas. Check if the canvas element is enabled. 641 | isCanvas: function() { 642 | 643 | // create a canvas element 644 | var elem = document.createElement('canvas'); 645 | 646 | // try/catch for older browsers that don't support the canvas element 647 | try { 648 | 649 | // check if context and context 2d exists 650 | return !!(elem.getContext && elem.getContext('2d')); 651 | 652 | } catch (e) { 653 | 654 | // catch if older browser 655 | return false; 656 | } 657 | }, 658 | 659 | // Get Canvas Print. Return a string containing the canvas URI data. 660 | getCanvasPrint: function() { 661 | 662 | // create a canvas element 663 | var canvas = document.createElement('canvas'); 664 | 665 | // define a context var that will be used for browsers with canvas support 666 | var ctx; 667 | 668 | // try/catch for older browsers that don't support the canvas element 669 | try { 670 | 671 | // attempt to give ctx a 2d canvas context value 672 | ctx = canvas.getContext('2d'); 673 | 674 | } catch (e) { 675 | 676 | // return empty string if canvas element not supported 677 | return ""; 678 | } 679 | 680 | // https://www.browserleaks.com/canvas#how-does-it-work 681 | // Text with lowercase/uppercase/punctuation symbols 682 | var txt = 'ClientJS,org 1.0'; 683 | ctx.textBaseline = "top"; 684 | // The most common type 685 | ctx.font = "14px 'Arial'"; 686 | ctx.textBaseline = "alphabetic"; 687 | ctx.fillStyle = "#f60"; 688 | ctx.fillRect(125, 1, 62, 20); 689 | // Some tricks for color mixing to increase the difference in rendering 690 | ctx.fillStyle = "#069"; 691 | ctx.fillText(txt, 2, 15); 692 | ctx.fillStyle = "rgba(102, 204, 0, 0.7)"; 693 | ctx.fillText(txt, 4, 17); 694 | return canvas.toDataURL(); 695 | } 696 | }; 697 | 698 | if (typeof module === 'object' && typeof exports !== "undefined") { 699 | module.exports = ClientJS; 700 | } 701 | scope.ClientJS = ClientJS; 702 | })(window); 703 | -------------------------------------------------------------------------------- /src/vendor/deployJava.js: -------------------------------------------------------------------------------- 1 | var deployJava = function() { 2 | var l = { 3 | core: ["id", "class", "title", "style"], 4 | i18n: ["lang", "dir"], 5 | events: ["onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup"], 6 | applet: ["codebase", "code", "name", "archive", "object", "width", "height", "alt", "align", "hspace", "vspace"], 7 | object: ["classid", "codebase", "codetype", "data", "type", "archive", "declare", "standby", "height", "width", "usemap", "name", "tabindex", "align", "border", "hspace", "vspace"] 8 | }; 9 | var b = l.object.concat(l.core, l.i18n, l.events); 10 | var m = l.applet.concat(l.core); 11 | 12 | function g(o) { 13 | if (!d.debug) { 14 | return 15 | } 16 | if (console.log) { 17 | console.log(o) 18 | } else { 19 | alert(o) 20 | } 21 | } 22 | 23 | function k(p, o) { 24 | if (p == null || p.length == 0) { 25 | return true 26 | } 27 | var r = p.charAt(p.length - 1); 28 | if (r != "+" && r != "*" && (p.indexOf("_") != -1 && r != "_")) { 29 | p = p + "*"; 30 | r = "*" 31 | } 32 | p = p.substring(0, p.length - 1); 33 | if (p.length > 0) { 34 | var q = p.charAt(p.length - 1); 35 | if (q == "." || q == "_") { 36 | p = p.substring(0, p.length - 1) 37 | } 38 | } 39 | if (r == "*") { 40 | return (o.indexOf(p) == 0) 41 | } else { 42 | if (r == "+") { 43 | return p <= o 44 | } 45 | } 46 | return false 47 | } 48 | 49 | function e() { 50 | var o = "//java.com/js/webstart.png"; 51 | try { 52 | return document.location.protocol.indexOf("http") != -1 ? o : "http:" + o 53 | } catch (p) { 54 | return "http:" + o 55 | } 56 | } 57 | 58 | function n(p) { 59 | var o = "http://java.com/dt-redirect"; 60 | if (p == null || p.length == 0) { 61 | return o 62 | } 63 | if (p.charAt(0) == "&") { 64 | p = p.substring(1, p.length) 65 | } 66 | return o + "?" + p 67 | } 68 | 69 | function j(q, p) { 70 | var o = q.length; 71 | for (var r = 0; r < o; r++) { 72 | if (q[r] === p) { 73 | return true 74 | } 75 | } 76 | return false 77 | } 78 | 79 | function c(o) { 80 | return j(m, o.toLowerCase()) 81 | } 82 | 83 | function i(o) { 84 | return j(b, o.toLowerCase()) 85 | } 86 | 87 | function a(o) { 88 | if ("MSIE" != deployJava.browserName) { 89 | return true 90 | } 91 | if (deployJava.compareVersionToPattern(deployJava.getPlugin().version, ["10", "0", "0"], false, true)) { 92 | return true 93 | } 94 | if (o == null) { 95 | return false 96 | } 97 | return !k("1.6.0_33+", o) 98 | } 99 | var d = { 100 | debug: null, 101 | version: "20120801", 102 | firefoxJavaVersion: null, 103 | myInterval: null, 104 | preInstallJREList: null, 105 | returnPage: null, 106 | brand: null, 107 | locale: null, 108 | installType: null, 109 | EAInstallEnabled: false, 110 | EarlyAccessURL: null, 111 | oldMimeType: "application/npruntime-scriptable-plugin;DeploymentToolkit", 112 | mimeType: "application/java-deployment-toolkit", 113 | launchButtonPNG: e(), 114 | browserName: null, 115 | browserName2: null, 116 | getJREs: function() { 117 | var t = new Array(); 118 | if (this.isPluginInstalled()) { 119 | var r = this.getPlugin(); 120 | var o = r.jvms; 121 | for (var q = 0; q < o.getLength(); q++) { 122 | t[q] = o.get(q).version 123 | } 124 | } else { 125 | var p = this.getBrowser(); 126 | if (p == "MSIE") { 127 | if (this.testUsingActiveX("1.7.0")) { 128 | t[0] = "1.7.0" 129 | } else { 130 | if (this.testUsingActiveX("1.6.0")) { 131 | t[0] = "1.6.0" 132 | } else { 133 | if (this.testUsingActiveX("1.5.0")) { 134 | t[0] = "1.5.0" 135 | } else { 136 | if (this.testUsingActiveX("1.4.2")) { 137 | t[0] = "1.4.2" 138 | } else { 139 | if (this.testForMSVM()) { 140 | t[0] = "1.1" 141 | } 142 | } 143 | } 144 | } 145 | } 146 | } else { 147 | if (p == "Netscape Family") { 148 | this.getJPIVersionUsingMimeType(); 149 | if (this.firefoxJavaVersion != null) { 150 | t[0] = this.firefoxJavaVersion 151 | } else { 152 | if (this.testUsingMimeTypes("1.7")) { 153 | t[0] = "1.7.0" 154 | } else { 155 | if (this.testUsingMimeTypes("1.6")) { 156 | t[0] = "1.6.0" 157 | } else { 158 | if (this.testUsingMimeTypes("1.5")) { 159 | t[0] = "1.5.0" 160 | } else { 161 | if (this.testUsingMimeTypes("1.4.2")) { 162 | t[0] = "1.4.2" 163 | } else { 164 | if (this.browserName2 == "Safari") { 165 | if (this.testUsingPluginsArray("1.7.0")) { 166 | t[0] = "1.7.0" 167 | } else { 168 | if (this.testUsingPluginsArray("1.6")) { 169 | t[0] = "1.6.0" 170 | } else { 171 | if (this.testUsingPluginsArray("1.5")) { 172 | t[0] = "1.5.0" 173 | } else { 174 | if (this.testUsingPluginsArray("1.4.2")) { 175 | t[0] = "1.4.2" 176 | } 177 | } 178 | } 179 | } 180 | } 181 | } 182 | } 183 | } 184 | } 185 | } 186 | } 187 | } 188 | } 189 | if (this.debug) { 190 | for (var q = 0; q < t.length; ++q) { 191 | g("[getJREs()] We claim to have detected Java SE " + t[q]) 192 | } 193 | } 194 | return t 195 | }, 196 | installJRE: function(r, p) { 197 | var o = false; 198 | if (this.isPluginInstalled() && this.isAutoInstallEnabled(r)) { 199 | var q = false; 200 | if (this.isCallbackSupported()) { 201 | q = this.getPlugin().installJRE(r, p) 202 | } else { 203 | q = this.getPlugin().installJRE(r) 204 | } 205 | if (q) { 206 | this.refresh(); 207 | if (this.returnPage != null) { 208 | document.location = this.returnPage 209 | } 210 | } 211 | return q 212 | } else { 213 | return this.installLatestJRE() 214 | } 215 | }, 216 | isAutoInstallEnabled: function(o) { 217 | if (!this.isPluginInstalled()) { 218 | return false 219 | } 220 | if (typeof o == "undefined") { 221 | o = null 222 | } 223 | return a(o) 224 | }, 225 | isCallbackSupported: function() { 226 | return this.isPluginInstalled() && this.compareVersionToPattern(this.getPlugin().version, ["10", "2", "0"], false, true) 227 | }, 228 | installLatestJRE: function(q) { 229 | if (this.isPluginInstalled() && this.isAutoInstallEnabled()) { 230 | var r = false; 231 | if (this.isCallbackSupported()) { 232 | r = this.getPlugin().installLatestJRE(q) 233 | } else { 234 | r = this.getPlugin().installLatestJRE() 235 | } 236 | if (r) { 237 | this.refresh(); 238 | if (this.returnPage != null) { 239 | document.location = this.returnPage 240 | } 241 | } 242 | return r 243 | } else { 244 | var p = this.getBrowser(); 245 | var o = navigator.platform.toLowerCase(); 246 | if ((this.EAInstallEnabled == "true") && (o.indexOf("win") != -1) && (this.EarlyAccessURL != null)) { 247 | this.preInstallJREList = this.getJREs(); 248 | if (this.returnPage != null) { 249 | this.myInterval = setInterval("deployJava.poll()", 3000) 250 | } 251 | location.href = this.EarlyAccessURL; 252 | return false 253 | } else { 254 | if (p == "MSIE") { 255 | return this.IEInstall() 256 | } else { 257 | if ((p == "Netscape Family") && (o.indexOf("win32") != -1)) { 258 | return this.FFInstall() 259 | } else { 260 | location.href = n(((this.returnPage != null) ? ("&returnPage=" + this.returnPage) : "") + ((this.locale != null) ? ("&locale=" + this.locale) : "") + ((this.brand != null) ? ("&brand=" + this.brand) : "")) 261 | } 262 | } 263 | return false 264 | } 265 | } 266 | }, 267 | runApplet: function(p, u, r) { 268 | if (r == "undefined" || r == null) { 269 | r = "1.1" 270 | } 271 | var t = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"; 272 | var o = r.match(t); 273 | if (this.returnPage == null) { 274 | this.returnPage = document.location 275 | } 276 | if (o != null) { 277 | var q = this.getBrowser(); 278 | if (q != "?") { 279 | if (this.versionCheck(r + "+")) { 280 | this.writeAppletTag(p, u) 281 | } else { 282 | if (this.installJRE(r + "+")) { 283 | this.refresh(); 284 | location.href = document.location; 285 | this.writeAppletTag(p, u) 286 | } 287 | } 288 | } else { 289 | this.writeAppletTag(p, u) 290 | } 291 | } else { 292 | g("[runApplet()] Invalid minimumVersion argument to runApplet():" + r) 293 | } 294 | }, 295 | writeAppletTag: function(r, w) { 296 | var o = "' 322 | } 323 | if (!v) { 324 | q += '' 325 | } 326 | if (x) { 327 | o += (' code="dummy"') 328 | } 329 | o += ">"; 330 | document.write(o + "\n" + q + "\n" + t) 331 | }, 332 | versionCheck: function(p) { 333 | var v = 0; 334 | var x = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$"; 335 | var y = p.match(x); 336 | if (y != null) { 337 | var r = false; 338 | var u = false; 339 | var q = new Array(); 340 | for (var t = 1; t < y.length; ++t) { 341 | if ((typeof y[t] == "string") && (y[t] != "")) { 342 | q[v] = y[t]; 343 | v++ 344 | } 345 | } 346 | if (q[q.length - 1] == "+") { 347 | u = true; 348 | r = false; 349 | q.length-- 350 | } else { 351 | if (q[q.length - 1] == "*") { 352 | u = false; 353 | r = true; 354 | q.length-- 355 | } else { 356 | if (q.length < 4) { 357 | u = false; 358 | r = true 359 | } 360 | } 361 | } 362 | var w = this.getJREs(); 363 | for (var t = 0; t < w.length; ++t) { 364 | if (this.compareVersionToPattern(w[t], q, r, u)) { 365 | return true 366 | } 367 | } 368 | return false 369 | } else { 370 | var o = "Invalid versionPattern passed to versionCheck: " + p; 371 | g("[versionCheck()] " + o); 372 | alert(o); 373 | return false 374 | } 375 | }, 376 | isWebStartInstalled: function(r) { 377 | var q = this.getBrowser(); 378 | if (q == "?") { 379 | return true 380 | } 381 | if (r == "undefined" || r == null) { 382 | r = "1.4.2" 383 | } 384 | var p = false; 385 | var t = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"; 386 | var o = r.match(t); 387 | if (o != null) { 388 | p = this.versionCheck(r + "+") 389 | } else { 390 | g("[isWebStartInstaller()] Invalid minimumVersion argument to isWebStartInstalled(): " + r); 391 | p = this.versionCheck("1.4.2+") 392 | } 393 | return p 394 | }, 395 | getJPIVersionUsingMimeType: function() { 396 | for (var p = 0; p < navigator.mimeTypes.length; ++p) { 397 | var q = navigator.mimeTypes[p].type; 398 | var o = q.match(/^application\/x-java-applet;jpi-version=(.*)$/); 399 | if (o != null) { 400 | this.firefoxJavaVersion = o[1]; 401 | if ("Opera" != this.browserName2) { 402 | break 403 | } 404 | } 405 | } 406 | }, 407 | launchWebStartApplication: function(r) { 408 | var o = navigator.userAgent.toLowerCase(); 409 | this.getJPIVersionUsingMimeType(); 410 | if (this.isWebStartInstalled("1.7.0") == false) { 411 | if ((this.installJRE("1.7.0+") == false) || ((this.isWebStartInstalled("1.7.0") == false))) { 412 | return false 413 | } 414 | } 415 | var u = null; 416 | if (document.documentURI) { 417 | u = document.documentURI 418 | } 419 | if (u == null) { 420 | u = document.URL 421 | } 422 | var p = this.getBrowser(); 423 | var q; 424 | if (p == "MSIE") { 425 | q = '' 426 | } else { 427 | if (p == "Netscape Family") { 428 | q = '' 429 | } 430 | } 431 | if (document.body == "undefined" || document.body == null) { 432 | document.write(q); 433 | document.location = u 434 | } else { 435 | var t = document.createElement("div"); 436 | t.id = "div1"; 437 | t.style.position = "relative"; 438 | t.style.left = "-10000px"; 439 | t.style.margin = "0px auto"; 440 | t.className = "dynamicDiv"; 441 | t.innerHTML = q; 442 | document.body.appendChild(t) 443 | } 444 | }, 445 | createWebStartLaunchButtonEx: function(q, p) { 446 | if (this.returnPage == null) { 447 | this.returnPage = q 448 | } 449 | var o = "javascript:deployJava.launchWebStartApplication('" + q + "');"; 450 | document.write('') 451 | }, 452 | createWebStartLaunchButton: function(q, p) { 453 | if (this.returnPage == null) { 454 | this.returnPage = q 455 | } 456 | var o = "javascript:if (!deployJava.isWebStartInstalled("" + p + "")) {if (deployJava.installLatestJRE()) {if (deployJava.launch("" + q + "")) {}}} else {if (deployJava.launch("" + q + "")) {}}"; 457 | document.write('') 458 | }, 459 | launch: function(o) { 460 | document.location = o; 461 | return true 462 | }, 463 | isPluginInstalled: function() { 464 | var o = this.getPlugin(); 465 | if (o && o.jvms) { 466 | return true 467 | } else { 468 | return false 469 | } 470 | }, 471 | isAutoUpdateEnabled: function() { 472 | if (this.isPluginInstalled()) { 473 | return this.getPlugin().isAutoUpdateEnabled() 474 | } 475 | return false 476 | }, 477 | setAutoUpdateEnabled: function() { 478 | if (this.isPluginInstalled()) { 479 | return this.getPlugin().setAutoUpdateEnabled() 480 | } 481 | return false 482 | }, 483 | setInstallerType: function(o) { 484 | this.installType = o; 485 | if (this.isPluginInstalled()) { 486 | return this.getPlugin().setInstallerType(o) 487 | } 488 | return false 489 | }, 490 | setAdditionalPackages: function(o) { 491 | if (this.isPluginInstalled()) { 492 | return this.getPlugin().setAdditionalPackages(o) 493 | } 494 | return false 495 | }, 496 | setEarlyAccess: function(o) { 497 | this.EAInstallEnabled = o 498 | }, 499 | isPlugin2: function() { 500 | if (this.isPluginInstalled()) { 501 | if (this.versionCheck("1.6.0_10+")) { 502 | try { 503 | return this.getPlugin().isPlugin2() 504 | } catch (o) {} 505 | } 506 | } 507 | return false 508 | }, 509 | allowPlugin: function() { 510 | this.getBrowser(); 511 | var o = ("Safari" != this.browserName2 && "Opera" != this.browserName2); 512 | return o 513 | }, 514 | getPlugin: function() { 515 | this.refresh(); 516 | var o = null; 517 | if (this.allowPlugin()) { 518 | o = document.getElementById("deployJavaPlugin") 519 | } 520 | return o 521 | }, 522 | compareVersionToPattern: function(v, p, r, t) { 523 | if (v == undefined || p == undefined) { 524 | return false 525 | } 526 | var w = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"; 527 | var x = v.match(w); 528 | if (x != null) { 529 | var u = 0; 530 | var y = new Array(); 531 | for (var q = 1; q < x.length; ++q) { 532 | if ((typeof x[q] == "string") && (x[q] != "")) { 533 | y[u] = x[q]; 534 | u++ 535 | } 536 | } 537 | var o = Math.min(y.length, p.length); 538 | if (t) { 539 | for (var q = 0; q < o; ++q) { 540 | if (y[q] < p[q]) { 541 | return false 542 | } else { 543 | if (y[q] > p[q]) { 544 | return true 545 | } 546 | } 547 | } 548 | return true 549 | } else { 550 | for (var q = 0; q < o; ++q) { 551 | if (y[q] != p[q]) { 552 | return false 553 | } 554 | } 555 | if (r) { 556 | return true 557 | } else { 558 | return (y.length == p.length) 559 | } 560 | } 561 | } else { 562 | return false 563 | } 564 | }, 565 | getBrowser: function() { 566 | if (this.browserName == null) { 567 | var o = navigator.userAgent.toLowerCase(); 568 | g("[getBrowser()] navigator.userAgent.toLowerCase() -> " + o); 569 | if ((o.indexOf("msie") != -1) && (o.indexOf("opera") == -1)) { 570 | this.browserName = "MSIE"; 571 | this.browserName2 = "MSIE" 572 | } else { 573 | if (o.indexOf("iphone") != -1) { 574 | this.browserName = "Netscape Family"; 575 | this.browserName2 = "iPhone" 576 | } else { 577 | if ((o.indexOf("firefox") != -1) && (o.indexOf("opera") == -1)) { 578 | this.browserName = "Netscape Family"; 579 | this.browserName2 = "Firefox" 580 | } else { 581 | if (o.indexOf("chrome") != -1) { 582 | this.browserName = "Netscape Family"; 583 | this.browserName2 = "Chrome" 584 | } else { 585 | if (o.indexOf("safari") != -1) { 586 | this.browserName = "Netscape Family"; 587 | this.browserName2 = "Safari" 588 | } else { 589 | if ((o.indexOf("mozilla") != -1) && (o.indexOf("opera") == -1)) { 590 | this.browserName = "Netscape Family"; 591 | this.browserName2 = "Other" 592 | } else { 593 | if (o.indexOf("opera") != -1) { 594 | this.browserName = "Netscape Family"; 595 | this.browserName2 = "Opera" 596 | } else { 597 | this.browserName = "?"; 598 | this.browserName2 = "unknown" 599 | } 600 | } 601 | } 602 | } 603 | } 604 | } 605 | } 606 | g("[getBrowser()] Detected browser name:" + this.browserName + ", " + this.browserName2) 607 | } 608 | return this.browserName 609 | }, 610 | testUsingActiveX: function(o) { 611 | var q = "JavaWebStart.isInstalled." + o + ".0"; 612 | if (typeof ActiveXObject == "undefined" || !ActiveXObject) { 613 | g("[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?"); 614 | return false 615 | } 616 | try { 617 | return (new ActiveXObject(q) != null) 618 | } catch (p) { 619 | return false 620 | } 621 | }, 622 | testForMSVM: function() { 623 | var p = "{08B0E5C0-4FCB-11CF-AAA5-00401C608500}"; 624 | if (typeof oClientCaps != "undefined") { 625 | var o = oClientCaps.getComponentVersion(p, "ComponentID"); 626 | if ((o == "") || (o == "5,0,5000,0")) { 627 | return false 628 | } else { 629 | return true 630 | } 631 | } else { 632 | return false 633 | } 634 | }, 635 | testUsingMimeTypes: function(p) { 636 | if (!navigator.mimeTypes) { 637 | g("[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?"); 638 | return false 639 | } 640 | for (var q = 0; q < navigator.mimeTypes.length; ++q) { 641 | s = navigator.mimeTypes[q].type; 642 | var o = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/); 643 | if (o != null) { 644 | if (this.compareVersions(o[1], p)) { 645 | return true 646 | } 647 | } 648 | } 649 | return false 650 | }, 651 | testUsingPluginsArray: function(p) { 652 | if ((!navigator.plugins) || (!navigator.plugins.length)) { 653 | return false 654 | } 655 | var o = navigator.platform.toLowerCase(); 656 | for (var q = 0; q < navigator.plugins.length; ++q) { 657 | s = navigator.plugins[q].description; 658 | if (s.search(/^Java Switchable Plug-in (Cocoa)/) != -1) { 659 | if (this.compareVersions("1.5.0", p)) { 660 | return true 661 | } 662 | } else { 663 | if (s.search(/^Java/) != -1) { 664 | if (o.indexOf("win") != -1) { 665 | if (this.compareVersions("1.5.0", p) || this.compareVersions("1.6.0", p)) { 666 | return true 667 | } 668 | } 669 | } 670 | } 671 | } 672 | if (this.compareVersions("1.5.0", p)) { 673 | return true 674 | } 675 | return false 676 | }, 677 | IEInstall: function() { 678 | location.href = n(((this.returnPage != null) ? ("&returnPage=" + this.returnPage) : "") + ((this.locale != null) ? ("&locale=" + this.locale) : "") + ((this.brand != null) ? ("&brand=" + this.brand) : "")); 679 | return false 680 | }, 681 | done: function(p, o) {}, 682 | FFInstall: function() { 683 | location.href = n(((this.returnPage != null) ? ("&returnPage=" + this.returnPage) : "") + ((this.locale != null) ? ("&locale=" + this.locale) : "") + ((this.brand != null) ? ("&brand=" + this.brand) : "") + ((this.installType != null) ? ("&type=" + this.installType) : "")); 684 | return false 685 | }, 686 | compareVersions: function(r, t) { 687 | var p = r.split("."); 688 | var o = t.split("."); 689 | for (var q = 0; q < p.length; ++q) { 690 | p[q] = Number(p[q]) 691 | } 692 | for (var q = 0; q < o.length; ++q) { 693 | o[q] = Number(o[q]) 694 | } 695 | if (p.length == 2) { 696 | p[2] = 0 697 | } 698 | if (p[0] > o[0]) { 699 | return true 700 | } 701 | if (p[0] < o[0]) { 702 | return false 703 | } 704 | if (p[1] > o[1]) { 705 | return true 706 | } 707 | if (p[1] < o[1]) { 708 | return false 709 | } 710 | if (p[2] > o[2]) { 711 | return true 712 | } 713 | if (p[2] < o[2]) { 714 | return false 715 | } 716 | return true 717 | }, 718 | enableAlerts: function() { 719 | this.browserName = null; 720 | this.debug = true 721 | }, 722 | poll: function() { 723 | this.refresh(); 724 | var o = this.getJREs(); 725 | if ((this.preInstallJREList.length == 0) && (o.length != 0)) { 726 | clearInterval(this.myInterval); 727 | if (this.returnPage != null) { 728 | location.href = this.returnPage 729 | } 730 | } 731 | if ((this.preInstallJREList.length != 0) && (o.length != 0) && (this.preInstallJREList[0] != o[0])) { 732 | clearInterval(this.myInterval); 733 | if (this.returnPage != null) { 734 | location.href = this.returnPage 735 | } 736 | } 737 | }, 738 | writePluginTag: function() { 739 | var o = this.getBrowser(); 740 | if (o == "MSIE") { 741 | document.write('') 742 | } else { 743 | if (o == "Netscape Family" && this.allowPlugin()) { 744 | this.writeEmbedTag() 745 | } 746 | } 747 | }, 748 | refresh: function() { 749 | navigator.plugins.refresh(false); 750 | var o = this.getBrowser(); 751 | if (o == "Netscape Family" && this.allowPlugin()) { 752 | var p = document.getElementById("deployJavaPlugin"); 753 | if (p == null) { 754 | this.writeEmbedTag() 755 | } 756 | } 757 | }, 758 | writeEmbedTag: function() { 759 | var o = false; 760 | if (navigator.mimeTypes != null) { 761 | for (var p = 0; p < navigator.mimeTypes.length; p++) { 762 | if (navigator.mimeTypes[p].type == this.mimeType) { 763 | if (navigator.mimeTypes[p].enabledPlugin) { 764 | document.write(''); 765 | o = true 766 | } 767 | } 768 | } 769 | if (!o) { 770 | for (var p = 0; p < navigator.mimeTypes.length; p++) { 771 | if (navigator.mimeTypes[p].type == this.oldMimeType) { 772 | if (navigator.mimeTypes[p].enabledPlugin) { 773 | document.write('') 774 | } 775 | } 776 | } 777 | } 778 | } 779 | } 780 | }; 781 | d.writePluginTag(); 782 | if (d.locale == null) { 783 | var h = null; 784 | if (h == null) { 785 | try { 786 | h = navigator.userLanguage 787 | } catch (f) {} 788 | } 789 | if (h == null) { 790 | try { 791 | h = navigator.systemLanguage 792 | } catch (f) {} 793 | } 794 | if (h == null) { 795 | try { 796 | h = navigator.language 797 | } catch (f) {} 798 | } 799 | if (h != null) { 800 | h.replace("-", "_"); 801 | d.locale = h 802 | } 803 | } 804 | return d 805 | }(); 806 | -------------------------------------------------------------------------------- /src/vendor/swfobject.js: -------------------------------------------------------------------------------- 1 | /*! SWFObject v2.2 2 | is released under the MIT License 3 | */ 4 | 5 | var swfobject = function() { 6 | 7 | var UNDEF = "undefined", 8 | OBJECT = "object", 9 | SHOCKWAVE_FLASH = "Shockwave Flash", 10 | SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", 11 | FLASH_MIME_TYPE = "application/x-shockwave-flash", 12 | EXPRESS_INSTALL_ID = "SWFObjectExprInst", 13 | ON_READY_STATE_CHANGE = "onreadystatechange", 14 | 15 | win = window, 16 | doc = document, 17 | nav = navigator, 18 | 19 | plugin = false, 20 | domLoadFnArr = [main], 21 | regObjArr = [], 22 | objIdArr = [], 23 | listenersArr = [], 24 | storedAltContent, 25 | storedAltContentId, 26 | storedCallbackFn, 27 | storedCallbackObj, 28 | isDomLoaded = false, 29 | isExpressInstallActive = false, 30 | dynamicStylesheet, 31 | dynamicStylesheetMedia, 32 | autoHideShow = true, 33 | 34 | /* Centralized function for browser feature detection 35 | - User agent string detection is only used when no good alternative is possible 36 | - Is executed directly for optimal performance 37 | */ 38 | ua = function() { 39 | var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, 40 | u = nav.userAgent.toLowerCase(), 41 | p = nav.platform.toLowerCase(), 42 | windows = p ? /win/.test(p) : /win/.test(u), 43 | mac = p ? /mac/.test(p) : /mac/.test(u), 44 | webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit 45 | ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html 46 | playerVersion = [0,0,0], 47 | d = null; 48 | if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { 49 | d = nav.plugins[SHOCKWAVE_FLASH].description; 50 | if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ 51 | plugin = true; 52 | ie = false; // cascaded feature detection for Internet Explorer 53 | d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); 54 | playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); 55 | playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); 56 | playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; 57 | } 58 | } 59 | else if (typeof win.ActiveXObject != UNDEF) { 60 | try { 61 | var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); 62 | if (a) { // a will return null when ActiveX is disabled 63 | d = a.GetVariable("$version"); 64 | if (d) { 65 | ie = true; // cascaded feature detection for Internet Explorer 66 | d = d.split(" ")[1].split(","); 67 | playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; 68 | } 69 | } 70 | } 71 | catch(e) {} 72 | } 73 | return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; 74 | }(), 75 | 76 | /* Cross-browser onDomLoad 77 | - Will fire an event as soon as the DOM of a web page is loaded 78 | - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ 79 | - Regular onload serves as fallback 80 | */ 81 | onDomLoad = function() { 82 | if (!ua.w3) { return; } 83 | if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically 84 | callDomLoadFunctions(); 85 | } 86 | if (!isDomLoaded) { 87 | if (typeof doc.addEventListener != UNDEF) { 88 | doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); 89 | } 90 | if (ua.ie && ua.win) { 91 | doc.attachEvent(ON_READY_STATE_CHANGE, function() { 92 | if (doc.readyState == "complete") { 93 | doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); 94 | callDomLoadFunctions(); 95 | } 96 | }); 97 | if (win == top) { // if not inside an iframe 98 | (function(){ 99 | if (isDomLoaded) { return; } 100 | try { 101 | doc.documentElement.doScroll("left"); 102 | } 103 | catch(e) { 104 | setTimeout(arguments.callee, 0); 105 | return; 106 | } 107 | callDomLoadFunctions(); 108 | })(); 109 | } 110 | } 111 | if (ua.wk) { 112 | (function(){ 113 | if (isDomLoaded) { return; } 114 | if (!/loaded|complete/.test(doc.readyState)) { 115 | setTimeout(arguments.callee, 0); 116 | return; 117 | } 118 | callDomLoadFunctions(); 119 | })(); 120 | } 121 | addLoadEvent(callDomLoadFunctions); 122 | } 123 | }(); 124 | 125 | function callDomLoadFunctions() { 126 | if (isDomLoaded) { return; } 127 | try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early 128 | var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); 129 | t.parentNode.removeChild(t); 130 | } 131 | catch (e) { return; } 132 | isDomLoaded = true; 133 | var dl = domLoadFnArr.length; 134 | for (var i = 0; i < dl; i++) { 135 | domLoadFnArr[i](); 136 | } 137 | } 138 | 139 | function addDomLoadEvent(fn) { 140 | if (isDomLoaded) { 141 | fn(); 142 | } 143 | else { 144 | domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ 145 | } 146 | } 147 | 148 | /* Cross-browser onload 149 | - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ 150 | - Will fire an event as soon as a web page including all of its assets are loaded 151 | */ 152 | function addLoadEvent(fn) { 153 | if (typeof win.addEventListener != UNDEF) { 154 | win.addEventListener("load", fn, false); 155 | } 156 | else if (typeof doc.addEventListener != UNDEF) { 157 | doc.addEventListener("load", fn, false); 158 | } 159 | else if (typeof win.attachEvent != UNDEF) { 160 | addListener(win, "onload", fn); 161 | } 162 | else if (typeof win.onload == "function") { 163 | var fnOld = win.onload; 164 | win.onload = function() { 165 | fnOld(); 166 | fn(); 167 | }; 168 | } 169 | else { 170 | win.onload = fn; 171 | } 172 | } 173 | 174 | /* Main function 175 | - Will preferably execute onDomLoad, otherwise onload (as a fallback) 176 | */ 177 | function main() { 178 | if (plugin) { 179 | testPlayerVersion(); 180 | } 181 | else { 182 | matchVersions(); 183 | } 184 | } 185 | 186 | /* Detect the Flash Player version for non-Internet Explorer browsers 187 | - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: 188 | a. Both release and build numbers can be detected 189 | b. Avoid wrong descriptions by corrupt installers provided by Adobe 190 | c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports 191 | - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available 192 | */ 193 | function testPlayerVersion() { 194 | var b = doc.getElementsByTagName("body")[0]; 195 | var o = createElement(OBJECT); 196 | o.setAttribute("type", FLASH_MIME_TYPE); 197 | var t = b.appendChild(o); 198 | if (t) { 199 | var counter = 0; 200 | (function(){ 201 | if (typeof t.GetVariable != UNDEF) { 202 | var d = t.GetVariable("$version"); 203 | if (d) { 204 | d = d.split(" ")[1].split(","); 205 | ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; 206 | } 207 | } 208 | else if (counter < 10) { 209 | counter++; 210 | setTimeout(arguments.callee, 10); 211 | return; 212 | } 213 | b.removeChild(o); 214 | t = null; 215 | matchVersions(); 216 | })(); 217 | } 218 | else { 219 | matchVersions(); 220 | } 221 | } 222 | 223 | /* Perform Flash Player and SWF version matching; static publishing only 224 | */ 225 | function matchVersions() { 226 | var rl = regObjArr.length; 227 | if (rl > 0) { 228 | for (var i = 0; i < rl; i++) { // for each registered object element 229 | var id = regObjArr[i].id; 230 | var cb = regObjArr[i].callbackFn; 231 | var cbObj = {success:false, id:id}; 232 | if (ua.pv[0] > 0) { 233 | var obj = getElementById(id); 234 | if (obj) { 235 | if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! 236 | setVisibility(id, true); 237 | if (cb) { 238 | cbObj.success = true; 239 | cbObj.ref = getObjectById(id); 240 | cb(cbObj); 241 | } 242 | } 243 | else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported 244 | var att = {}; 245 | att.data = regObjArr[i].expressInstall; 246 | att.width = obj.getAttribute("width") || "0"; 247 | att.height = obj.getAttribute("height") || "0"; 248 | if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } 249 | if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } 250 | // parse HTML object param element's name-value pairs 251 | var par = {}; 252 | var p = obj.getElementsByTagName("param"); 253 | var pl = p.length; 254 | for (var j = 0; j < pl; j++) { 255 | if (p[j].getAttribute("name").toLowerCase() != "movie") { 256 | par[p[j].getAttribute("name")] = p[j].getAttribute("value"); 257 | } 258 | } 259 | showExpressInstall(att, par, id, cb); 260 | } 261 | else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF 262 | displayAltContent(obj); 263 | if (cb) { cb(cbObj); } 264 | } 265 | } 266 | } 267 | else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) 268 | setVisibility(id, true); 269 | if (cb) { 270 | var o = getObjectById(id); // test whether there is an HTML object element or not 271 | if (o && typeof o.SetVariable != UNDEF) { 272 | cbObj.success = true; 273 | cbObj.ref = o; 274 | } 275 | cb(cbObj); 276 | } 277 | } 278 | } 279 | } 280 | } 281 | 282 | function getObjectById(objectIdStr) { 283 | var r = null; 284 | var o = getElementById(objectIdStr); 285 | if (o && o.nodeName == "OBJECT") { 286 | if (typeof o.SetVariable != UNDEF) { 287 | r = o; 288 | } 289 | else { 290 | var n = o.getElementsByTagName(OBJECT)[0]; 291 | if (n) { 292 | r = n; 293 | } 294 | } 295 | } 296 | return r; 297 | } 298 | 299 | /* Requirements for Adobe Express Install 300 | - only one instance can be active at a time 301 | - fp 6.0.65 or higher 302 | - Win/Mac OS only 303 | - no Webkit engines older than version 312 304 | */ 305 | function canExpressInstall() { 306 | return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); 307 | } 308 | 309 | /* Show the Adobe Express Install dialog 310 | - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 311 | */ 312 | function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { 313 | isExpressInstallActive = true; 314 | storedCallbackFn = callbackFn || null; 315 | storedCallbackObj = {success:false, id:replaceElemIdStr}; 316 | var obj = getElementById(replaceElemIdStr); 317 | if (obj) { 318 | if (obj.nodeName == "OBJECT") { // static publishing 319 | storedAltContent = abstractAltContent(obj); 320 | storedAltContentId = null; 321 | } 322 | else { // dynamic publishing 323 | storedAltContent = obj; 324 | storedAltContentId = replaceElemIdStr; 325 | } 326 | att.id = EXPRESS_INSTALL_ID; 327 | if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } 328 | if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } 329 | doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; 330 | var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", 331 | fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; 332 | if (typeof par.flashvars != UNDEF) { 333 | par.flashvars += "&" + fv; 334 | } 335 | else { 336 | par.flashvars = fv; 337 | } 338 | // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, 339 | // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work 340 | if (ua.ie && ua.win && obj.readyState != 4) { 341 | var newObj = createElement("div"); 342 | replaceElemIdStr += "SWFObjectNew"; 343 | newObj.setAttribute("id", replaceElemIdStr); 344 | obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf 345 | obj.style.display = "none"; 346 | (function(){ 347 | if (obj.readyState == 4) { 348 | obj.parentNode.removeChild(obj); 349 | } 350 | else { 351 | setTimeout(arguments.callee, 10); 352 | } 353 | })(); 354 | } 355 | createSWF(att, par, replaceElemIdStr); 356 | } 357 | } 358 | 359 | /* Functions to abstract and display alternative content 360 | */ 361 | function displayAltContent(obj) { 362 | if (ua.ie && ua.win && obj.readyState != 4) { 363 | // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, 364 | // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work 365 | var el = createElement("div"); 366 | obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content 367 | el.parentNode.replaceChild(abstractAltContent(obj), el); 368 | obj.style.display = "none"; 369 | (function(){ 370 | if (obj.readyState == 4) { 371 | obj.parentNode.removeChild(obj); 372 | } 373 | else { 374 | setTimeout(arguments.callee, 10); 375 | } 376 | })(); 377 | } 378 | else { 379 | obj.parentNode.replaceChild(abstractAltContent(obj), obj); 380 | } 381 | } 382 | 383 | function abstractAltContent(obj) { 384 | var ac = createElement("div"); 385 | if (ua.win && ua.ie) { 386 | ac.innerHTML = obj.innerHTML; 387 | } 388 | else { 389 | var nestedObj = obj.getElementsByTagName(OBJECT)[0]; 390 | if (nestedObj) { 391 | var c = nestedObj.childNodes; 392 | if (c) { 393 | var cl = c.length; 394 | for (var i = 0; i < cl; i++) { 395 | if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { 396 | ac.appendChild(c[i].cloneNode(true)); 397 | } 398 | } 399 | } 400 | } 401 | } 402 | return ac; 403 | } 404 | 405 | /* Cross-browser dynamic SWF creation 406 | */ 407 | function createSWF(attObj, parObj, id) { 408 | var r, el = getElementById(id); 409 | if (ua.wk && ua.wk < 312) { return r; } 410 | if (el) { 411 | if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content 412 | attObj.id = id; 413 | } 414 | if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML 415 | var att = ""; 416 | for (var i in attObj) { 417 | if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries 418 | if (i.toLowerCase() == "data") { 419 | parObj.movie = attObj[i]; 420 | } 421 | else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword 422 | att += ' class="' + attObj[i] + '"'; 423 | } 424 | else if (i.toLowerCase() != "classid") { 425 | att += ' ' + i + '="' + attObj[i] + '"'; 426 | } 427 | } 428 | } 429 | var par = ""; 430 | for (var j in parObj) { 431 | if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries 432 | par += ''; 433 | } 434 | } 435 | el.outerHTML = '' + par + ''; 436 | objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) 437 | r = getElementById(attObj.id); 438 | } 439 | else { // well-behaving browsers 440 | var o = createElement(OBJECT); 441 | o.setAttribute("type", FLASH_MIME_TYPE); 442 | for (var m in attObj) { 443 | if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries 444 | if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword 445 | o.setAttribute("class", attObj[m]); 446 | } 447 | else if (m.toLowerCase() != "classid") { // filter out IE specific attribute 448 | o.setAttribute(m, attObj[m]); 449 | } 450 | } 451 | } 452 | for (var n in parObj) { 453 | if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element 454 | createObjParam(o, n, parObj[n]); 455 | } 456 | } 457 | el.parentNode.replaceChild(o, el); 458 | r = o; 459 | } 460 | } 461 | return r; 462 | } 463 | 464 | function createObjParam(el, pName, pValue) { 465 | var p = createElement("param"); 466 | p.setAttribute("name", pName); 467 | p.setAttribute("value", pValue); 468 | el.appendChild(p); 469 | } 470 | 471 | /* Cross-browser SWF removal 472 | - Especially needed to safely and completely remove a SWF in Internet Explorer 473 | */ 474 | function removeSWF(id) { 475 | var obj = getElementById(id); 476 | if (obj && obj.nodeName == "OBJECT") { 477 | if (ua.ie && ua.win) { 478 | obj.style.display = "none"; 479 | (function(){ 480 | if (obj.readyState == 4) { 481 | removeObjectInIE(id); 482 | } 483 | else { 484 | setTimeout(arguments.callee, 10); 485 | } 486 | })(); 487 | } 488 | else { 489 | obj.parentNode.removeChild(obj); 490 | } 491 | } 492 | } 493 | 494 | function removeObjectInIE(id) { 495 | var obj = getElementById(id); 496 | if (obj) { 497 | for (var i in obj) { 498 | if (typeof obj[i] == "function") { 499 | obj[i] = null; 500 | } 501 | } 502 | obj.parentNode.removeChild(obj); 503 | } 504 | } 505 | 506 | /* Functions to optimize JavaScript compression 507 | */ 508 | function getElementById(id) { 509 | var el = null; 510 | try { 511 | el = doc.getElementById(id); 512 | } 513 | catch (e) {} 514 | return el; 515 | } 516 | 517 | function createElement(el) { 518 | return doc.createElement(el); 519 | } 520 | 521 | /* Updated attachEvent function for Internet Explorer 522 | - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks 523 | */ 524 | function addListener(target, eventType, fn) { 525 | target.attachEvent(eventType, fn); 526 | listenersArr[listenersArr.length] = [target, eventType, fn]; 527 | } 528 | 529 | /* Flash Player and SWF content version matching 530 | */ 531 | function hasPlayerVersion(rv) { 532 | var pv = ua.pv, v = rv.split("."); 533 | v[0] = parseInt(v[0], 10); 534 | v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" 535 | v[2] = parseInt(v[2], 10) || 0; 536 | return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; 537 | } 538 | 539 | /* Cross-browser dynamic CSS creation 540 | - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php 541 | */ 542 | function createCSS(sel, decl, media, newStyle) { 543 | if (ua.ie && ua.mac) { return; } 544 | var h = doc.getElementsByTagName("head")[0]; 545 | if (!h) { return; } // to also support badly authored HTML pages that lack a head element 546 | var m = (media && typeof media == "string") ? media : "screen"; 547 | if (newStyle) { 548 | dynamicStylesheet = null; 549 | dynamicStylesheetMedia = null; 550 | } 551 | if (!dynamicStylesheet || dynamicStylesheetMedia != m) { 552 | // create dynamic stylesheet + get a global reference to it 553 | var s = createElement("style"); 554 | s.setAttribute("type", "text/css"); 555 | s.setAttribute("media", m); 556 | dynamicStylesheet = h.appendChild(s); 557 | if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { 558 | dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; 559 | } 560 | dynamicStylesheetMedia = m; 561 | } 562 | // add style rule 563 | if (ua.ie && ua.win) { 564 | if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { 565 | dynamicStylesheet.addRule(sel, decl); 566 | } 567 | } 568 | else { 569 | if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { 570 | dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); 571 | } 572 | } 573 | } 574 | 575 | function setVisibility(id, isVisible) { 576 | if (!autoHideShow) { return; } 577 | var v = isVisible ? "visible" : "hidden"; 578 | if (isDomLoaded && getElementById(id)) { 579 | getElementById(id).style.visibility = v; 580 | } 581 | else { 582 | createCSS("#" + id, "visibility:" + v); 583 | } 584 | } 585 | 586 | /* Filter to avoid XSS attacks 587 | */ 588 | function urlEncodeIfNecessary(s) { 589 | var regex = /[\\\"<>\.;]/; 590 | var hasBadChars = regex.exec(s) != null; 591 | return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; 592 | } 593 | 594 | /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) 595 | */ 596 | var cleanup = function() { 597 | if (ua.ie && ua.win) { 598 | window.attachEvent("onunload", function() { 599 | // remove listeners to avoid memory leaks 600 | var ll = listenersArr.length; 601 | for (var i = 0; i < ll; i++) { 602 | listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); 603 | } 604 | // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect 605 | var il = objIdArr.length; 606 | for (var j = 0; j < il; j++) { 607 | removeSWF(objIdArr[j]); 608 | } 609 | // cleanup library's main closures to avoid memory leaks 610 | for (var k in ua) { 611 | ua[k] = null; 612 | } 613 | ua = null; 614 | for (var l in swfobject) { 615 | swfobject[l] = null; 616 | } 617 | swfobject = null; 618 | }); 619 | } 620 | }(); 621 | 622 | return { 623 | /* Public API 624 | - Reference: http://code.google.com/p/swfobject/wiki/documentation 625 | */ 626 | registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { 627 | if (ua.w3 && objectIdStr && swfVersionStr) { 628 | var regObj = {}; 629 | regObj.id = objectIdStr; 630 | regObj.swfVersion = swfVersionStr; 631 | regObj.expressInstall = xiSwfUrlStr; 632 | regObj.callbackFn = callbackFn; 633 | regObjArr[regObjArr.length] = regObj; 634 | setVisibility(objectIdStr, false); 635 | } 636 | else if (callbackFn) { 637 | callbackFn({success:false, id:objectIdStr}); 638 | } 639 | }, 640 | 641 | getObjectById: function(objectIdStr) { 642 | if (ua.w3) { 643 | return getObjectById(objectIdStr); 644 | } 645 | }, 646 | 647 | embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { 648 | var callbackObj = {success:false, id:replaceElemIdStr}; 649 | if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { 650 | setVisibility(replaceElemIdStr, false); 651 | addDomLoadEvent(function() { 652 | widthStr += ""; // auto-convert to string 653 | heightStr += ""; 654 | var att = {}; 655 | if (attObj && typeof attObj === OBJECT) { 656 | for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs 657 | att[i] = attObj[i]; 658 | } 659 | } 660 | att.data = swfUrlStr; 661 | att.width = widthStr; 662 | att.height = heightStr; 663 | var par = {}; 664 | if (parObj && typeof parObj === OBJECT) { 665 | for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs 666 | par[j] = parObj[j]; 667 | } 668 | } 669 | if (flashvarsObj && typeof flashvarsObj === OBJECT) { 670 | for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs 671 | if (typeof par.flashvars != UNDEF) { 672 | par.flashvars += "&" + k + "=" + flashvarsObj[k]; 673 | } 674 | else { 675 | par.flashvars = k + "=" + flashvarsObj[k]; 676 | } 677 | } 678 | } 679 | if (hasPlayerVersion(swfVersionStr)) { // create SWF 680 | var obj = createSWF(att, par, replaceElemIdStr); 681 | if (att.id == replaceElemIdStr) { 682 | setVisibility(replaceElemIdStr, true); 683 | } 684 | callbackObj.success = true; 685 | callbackObj.ref = obj; 686 | } 687 | else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install 688 | att.data = xiSwfUrlStr; 689 | showExpressInstall(att, par, replaceElemIdStr, callbackFn); 690 | return; 691 | } 692 | else { // show alternative content 693 | setVisibility(replaceElemIdStr, true); 694 | } 695 | if (callbackFn) { callbackFn(callbackObj); } 696 | }); 697 | } 698 | else if (callbackFn) { callbackFn(callbackObj); } 699 | }, 700 | 701 | switchOffAutoHideShow: function() { 702 | autoHideShow = false; 703 | }, 704 | 705 | ua: ua, 706 | 707 | getFlashPlayerVersion: function() { 708 | return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; 709 | }, 710 | 711 | hasFlashPlayerVersion: hasPlayerVersion, 712 | 713 | createSWF: function(attObj, parObj, replaceElemIdStr) { 714 | if (ua.w3) { 715 | return createSWF(attObj, parObj, replaceElemIdStr); 716 | } 717 | else { 718 | return undefined; 719 | } 720 | }, 721 | 722 | showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { 723 | if (ua.w3 && canExpressInstall()) { 724 | showExpressInstall(att, par, replaceElemIdStr, callbackFn); 725 | } 726 | }, 727 | 728 | removeSWF: function(objElemIdStr) { 729 | if (ua.w3) { 730 | removeSWF(objElemIdStr); 731 | } 732 | }, 733 | 734 | createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { 735 | if (ua.w3) { 736 | createCSS(selStr, declStr, mediaStr, newStyleBoolean); 737 | } 738 | }, 739 | 740 | addDomLoadEvent: addDomLoadEvent, 741 | 742 | addLoadEvent: addLoadEvent, 743 | 744 | getQueryParamValue: function(param) { 745 | var q = doc.location.search || doc.location.hash; 746 | if (q) { 747 | if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark 748 | if (param == null) { 749 | return urlEncodeIfNecessary(q); 750 | } 751 | var pairs = q.split("&"); 752 | for (var i = 0; i < pairs.length; i++) { 753 | if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { 754 | return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); 755 | } 756 | } 757 | } 758 | return ""; 759 | }, 760 | 761 | // For internal usage only 762 | expressInstallCallback: function() { 763 | if (isExpressInstallActive) { 764 | var obj = getElementById(EXPRESS_INSTALL_ID); 765 | if (obj && storedAltContent) { 766 | obj.parentNode.replaceChild(storedAltContent, obj); 767 | if (storedAltContentId) { 768 | setVisibility(storedAltContentId, true); 769 | if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } 770 | } 771 | if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } 772 | } 773 | isExpressInstallActive = false; 774 | } 775 | } 776 | }; 777 | }(); 778 | -------------------------------------------------------------------------------- /src/vendor/ua-parser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * UAParser.js v0.7.10 3 | * Lightweight JavaScript-based User-Agent string parser 4 | * https://github.com/faisalman/ua-parser-js 5 | * 6 | * Copyright © 2012-2015 Faisal Salman 7 | * Dual licensed under GPLv2 & MIT 8 | */ 9 | 10 | (function (window, undefined) { 11 | 12 | 'use strict'; 13 | 14 | ////////////// 15 | // Constants 16 | ///////////// 17 | 18 | 19 | var LIBVERSION = '0.7.10', 20 | EMPTY = '', 21 | UNKNOWN = '?', 22 | FUNC_TYPE = 'function', 23 | UNDEF_TYPE = 'undefined', 24 | OBJ_TYPE = 'object', 25 | STR_TYPE = 'string', 26 | MAJOR = 'major', // deprecated 27 | MODEL = 'model', 28 | NAME = 'name', 29 | TYPE = 'type', 30 | VENDOR = 'vendor', 31 | VERSION = 'version', 32 | ARCHITECTURE= 'architecture', 33 | CONSOLE = 'console', 34 | MOBILE = 'mobile', 35 | TABLET = 'tablet', 36 | SMARTTV = 'smarttv', 37 | WEARABLE = 'wearable', 38 | EMBEDDED = 'embedded'; 39 | 40 | 41 | /////////// 42 | // Helper 43 | ////////// 44 | 45 | 46 | var util = { 47 | extend : function (regexes, extensions) { 48 | for (var i in extensions) { 49 | if ("browser cpu device engine os".indexOf(i) !== -1 && extensions[i].length % 2 === 0) { 50 | regexes[i] = extensions[i].concat(regexes[i]); 51 | } 52 | } 53 | return regexes; 54 | }, 55 | has : function (str1, str2) { 56 | if (typeof str1 === "string") { 57 | return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; 58 | } else { 59 | return false; 60 | } 61 | }, 62 | lowerize : function (str) { 63 | return str.toLowerCase(); 64 | }, 65 | major : function (version) { 66 | return typeof(version) === STR_TYPE ? version.split(".")[0] : undefined; 67 | } 68 | }; 69 | 70 | 71 | /////////////// 72 | // Map helper 73 | ////////////// 74 | 75 | 76 | var mapper = { 77 | 78 | rgx : function () { 79 | 80 | var result, i = 0, j, k, p, q, matches, match, args = arguments; 81 | 82 | // loop through all regexes maps 83 | while (i < args.length && !matches) { 84 | 85 | var regex = args[i], // even sequence (0,2,4,..) 86 | props = args[i + 1]; // odd sequence (1,3,5,..) 87 | 88 | // construct object barebones 89 | if (typeof result === UNDEF_TYPE) { 90 | result = {}; 91 | for (p in props) { 92 | if (props.hasOwnProperty(p)){ 93 | q = props[p]; 94 | if (typeof q === OBJ_TYPE) { 95 | result[q[0]] = undefined; 96 | } else { 97 | result[q] = undefined; 98 | } 99 | } 100 | } 101 | } 102 | 103 | // try matching uastring with regexes 104 | j = k = 0; 105 | while (j < regex.length && !matches) { 106 | matches = regex[j++].exec(this.getUA()); 107 | if (!!matches) { 108 | for (p = 0; p < props.length; p++) { 109 | match = matches[++k]; 110 | q = props[p]; 111 | // check if given property is actually array 112 | if (typeof q === OBJ_TYPE && q.length > 0) { 113 | if (q.length == 2) { 114 | if (typeof q[1] == FUNC_TYPE) { 115 | // assign modified match 116 | result[q[0]] = q[1].call(this, match); 117 | } else { 118 | // assign given value, ignore regex match 119 | result[q[0]] = q[1]; 120 | } 121 | } else if (q.length == 3) { 122 | // check whether function or regex 123 | if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) { 124 | // call function (usually string mapper) 125 | result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; 126 | } else { 127 | // sanitize match using given regex 128 | result[q[0]] = match ? match.replace(q[1], q[2]) : undefined; 129 | } 130 | } else if (q.length == 4) { 131 | result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined; 132 | } 133 | } else { 134 | result[q] = match ? match : undefined; 135 | } 136 | } 137 | } 138 | } 139 | i += 2; 140 | } 141 | return result; 142 | }, 143 | 144 | str : function (str, map) { 145 | 146 | for (var i in map) { 147 | // check if array 148 | if (typeof map[i] === OBJ_TYPE && map[i].length > 0) { 149 | for (var j = 0; j < map[i].length; j++) { 150 | if (util.has(map[i][j], str)) { 151 | return (i === UNKNOWN) ? undefined : i; 152 | } 153 | } 154 | } else if (util.has(map[i], str)) { 155 | return (i === UNKNOWN) ? undefined : i; 156 | } 157 | } 158 | return str; 159 | } 160 | }; 161 | 162 | 163 | /////////////// 164 | // String map 165 | ////////////// 166 | 167 | 168 | var maps = { 169 | 170 | browser : { 171 | oldsafari : { 172 | version : { 173 | '1.0' : '/8', 174 | '1.2' : '/1', 175 | '1.3' : '/3', 176 | '2.0' : '/412', 177 | '2.0.2' : '/416', 178 | '2.0.3' : '/417', 179 | '2.0.4' : '/419', 180 | '?' : '/' 181 | } 182 | } 183 | }, 184 | 185 | device : { 186 | amazon : { 187 | model : { 188 | 'Fire Phone' : ['SD', 'KF'] 189 | } 190 | }, 191 | sprint : { 192 | model : { 193 | 'Evo Shift 4G' : '7373KT' 194 | }, 195 | vendor : { 196 | 'HTC' : 'APA', 197 | 'Sprint' : 'Sprint' 198 | } 199 | } 200 | }, 201 | 202 | os : { 203 | windows : { 204 | version : { 205 | 'ME' : '4.90', 206 | 'NT 3.11' : 'NT3.51', 207 | 'NT 4.0' : 'NT4.0', 208 | '2000' : 'NT 5.0', 209 | 'XP' : ['NT 5.1', 'NT 5.2'], 210 | 'Vista' : 'NT 6.0', 211 | '7' : 'NT 6.1', 212 | '8' : 'NT 6.2', 213 | '8.1' : 'NT 6.3', 214 | '10' : ['NT 6.4', 'NT 10.0'], 215 | 'RT' : 'ARM' 216 | } 217 | } 218 | } 219 | }; 220 | 221 | 222 | ////////////// 223 | // Regex map 224 | ///////////// 225 | 226 | 227 | var regexes = { 228 | 229 | browser : [[ 230 | 231 | // Presto based 232 | /(opera\smini)\/([\w\.-]+)/i, // Opera Mini 233 | /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet 234 | /(opera).+version\/([\w\.]+)/i, // Opera > 9.80 235 | /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80 236 | 237 | ], [NAME, VERSION], [ 238 | 239 | /\s(opr)\/([\w\.]+)/i // Opera Webkit 240 | ], [[NAME, 'Opera'], VERSION], [ 241 | 242 | // Mixed 243 | /(kindle)\/([\w\.]+)/i, // Kindle 244 | /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i, 245 | // Lunascape/Maxthon/Netfront/Jasmine/Blazer 246 | 247 | // Trident based 248 | /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i, 249 | // Avant/IEMobile/SlimBrowser/Baidu 250 | /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer 251 | 252 | // Webkit/KHTML based 253 | /(rekonq)\/([\w\.]+)*/i, // Rekonq 254 | /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs)\/([\w\.-]+)/i 255 | // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS 256 | ], [NAME, VERSION], [ 257 | 258 | /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11 259 | ], [[NAME, 'IE'], VERSION], [ 260 | 261 | /(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge 262 | ], [NAME, VERSION], [ 263 | 264 | /(yabrowser)\/([\w\.]+)/i // Yandex 265 | ], [[NAME, 'Yandex'], VERSION], [ 266 | 267 | /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon 268 | ], [[NAME, /_/g, ' '], VERSION], [ 269 | 270 | /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i, 271 | // Chrome/OmniWeb/Arora/Tizen/Nokia 272 | /(qqbrowser)[\/\s]?([\w\.]+)/i 273 | // QQBrowser 274 | ], [NAME, VERSION], [ 275 | 276 | /(uc\s?browser)[\/\s]?([\w\.]+)/i, 277 | /ucweb.+(ucbrowser)[\/\s]?([\w\.]+)/i, 278 | /JUC.+(ucweb)[\/\s]?([\w\.]+)/i 279 | // UCBrowser 280 | ], [[NAME, 'UCBrowser'], VERSION], [ 281 | 282 | /(dolfin)\/([\w\.]+)/i // Dolphin 283 | ], [[NAME, 'Dolphin'], VERSION], [ 284 | 285 | /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS 286 | ], [[NAME, 'Chrome'], VERSION], [ 287 | 288 | /XiaoMi\/MiuiBrowser\/([\w\.]+)/i // MIUI Browser 289 | ], [VERSION, [NAME, 'MIUI Browser']], [ 290 | 291 | /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser 292 | ], [VERSION, [NAME, 'Android Browser']], [ 293 | 294 | /FBAV\/([\w\.]+);/i // Facebook App for iOS 295 | ], [VERSION, [NAME, 'Facebook']], [ 296 | 297 | /fxios\/([\w\.-]+)/i // Firefox for iOS 298 | ], [VERSION, [NAME, 'Firefox']], [ 299 | 300 | /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari 301 | ], [VERSION, [NAME, 'Mobile Safari']], [ 302 | 303 | /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile 304 | ], [VERSION, NAME], [ 305 | 306 | /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0 307 | ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [ 308 | 309 | /(konqueror)\/([\w\.]+)/i, // Konqueror 310 | /(webkit|khtml)\/([\w\.]+)/i 311 | ], [NAME, VERSION], [ 312 | 313 | // Gecko based 314 | /(navigator|netscape)\/([\w\.-]+)/i // Netscape 315 | ], [[NAME, 'Netscape'], VERSION], [ 316 | /(swiftfox)/i, // Swiftfox 317 | /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, 318 | // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror 319 | /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i, 320 | // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix 321 | /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla 322 | 323 | // Other 324 | /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i, 325 | // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir 326 | /(links)\s\(([\w\.]+)/i, // Links 327 | /(gobrowser)\/?([\w\.]+)*/i, // GoBrowser 328 | /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser 329 | /(mosaic)[\/\s]([\w\.]+)/i // Mosaic 330 | ], [NAME, VERSION] 331 | 332 | /* ///////////////////// 333 | // Media players BEGIN 334 | //////////////////////// 335 | 336 | , [ 337 | 338 | /(apple(?:coremedia|))\/((\d+)[\w\._]+)/i, // Generic Apple CoreMedia 339 | /(coremedia) v((\d+)[\w\._]+)/i 340 | ], [NAME, VERSION], [ 341 | 342 | /(aqualung|lyssna|bsplayer)\/((\d+)?[\w\.-]+)/i // Aqualung/Lyssna/BSPlayer 343 | ], [NAME, VERSION], [ 344 | 345 | /(ares|ossproxy)\s((\d+)[\w\.-]+)/i // Ares/OSSProxy 346 | ], [NAME, VERSION], [ 347 | 348 | /(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/((\d+)[\w\.-]+)/i, 349 | // Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC 350 | // NSPlayer/PSP-InternetRadioPlayer/Videos 351 | /(clementine|music player daemon)\s((\d+)[\w\.-]+)/i, // Clementine/MPD 352 | /(lg player|nexplayer)\s((\d+)[\d\.]+)/i, 353 | /player\/(nexplayer|lg player)\s((\d+)[\w\.-]+)/i // NexPlayer/LG Player 354 | ], [NAME, VERSION], [ 355 | /(nexplayer)\s((\d+)[\w\.-]+)/i // Nexplayer 356 | ], [NAME, VERSION], [ 357 | 358 | /(flrp)\/((\d+)[\w\.-]+)/i // Flip Player 359 | ], [[NAME, 'Flip Player'], VERSION], [ 360 | 361 | /(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i 362 | // FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit 363 | ], [NAME], [ 364 | 365 | /(gstreamer) souphttpsrc (?:\([^\)]+\)){0,1} libsoup\/((\d+)[\w\.-]+)/i 366 | // Gstreamer 367 | ], [NAME, VERSION], [ 368 | 369 | /(htc streaming player)\s[\w_]+\s\/\s((\d+)[\d\.]+)/i, // HTC Streaming Player 370 | /(java|python-urllib|python-requests|wget|libcurl)\/((\d+)[\w\.-_]+)/i, 371 | // Java/urllib/requests/wget/cURL 372 | /(lavf)((\d+)[\d\.]+)/i // Lavf (FFMPEG) 373 | ], [NAME, VERSION], [ 374 | 375 | /(htc_one_s)\/((\d+)[\d\.]+)/i // HTC One S 376 | ], [[NAME, /_/g, ' '], VERSION], [ 377 | 378 | /(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+){0,1})/i 379 | // MPlayer SVN 380 | ], [NAME, VERSION], [ 381 | 382 | /(mplayer)(?:\s|\/|[unkow-]+)((\d+)[\w\.-]+)/i // MPlayer 383 | ], [NAME, VERSION], [ 384 | 385 | /(mplayer)/i, // MPlayer (no other info) 386 | /(yourmuze)/i, // YourMuze 387 | /(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime 388 | ], [NAME], [ 389 | 390 | /(nero (?:home|scout))\/((\d+)[\w\.-]+)/i // Nero Home/Nero Scout 391 | ], [NAME, VERSION], [ 392 | 393 | /(nokia\d+)\/((\d+)[\w\.-]+)/i // Nokia 394 | ], [NAME, VERSION], [ 395 | 396 | /\s(songbird)\/((\d+)[\w\.-]+)/i // Songbird/Philips-Songbird 397 | ], [NAME, VERSION], [ 398 | 399 | /(winamp)3 version ((\d+)[\w\.-]+)/i, // Winamp 400 | /(winamp)\s((\d+)[\w\.-]+)/i, 401 | /(winamp)mpeg\/((\d+)[\w\.-]+)/i 402 | ], [NAME, VERSION], [ 403 | 404 | /(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info) 405 | // inlight radio 406 | ], [NAME], [ 407 | 408 | /(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/((\d+)[\w\.-]+)/i 409 | // QuickTime/RealMedia/RadioApp/RadioClientApplication/ 410 | // SoundTap/Totem/Stagefright/Streamium 411 | ], [NAME, VERSION], [ 412 | 413 | /(smp)((\d+)[\d\.]+)/i // SMP 414 | ], [NAME, VERSION], [ 415 | 416 | /(vlc) media player - version ((\d+)[\w\.]+)/i, // VLC Videolan 417 | /(vlc)\/((\d+)[\w\.-]+)/i, 418 | /(xbmc|gvfs|xine|xmms|irapp)\/((\d+)[\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp 419 | /(foobar2000)\/((\d+)[\d\.]+)/i, // Foobar2000 420 | /(itunes)\/((\d+)[\d\.]+)/i // iTunes 421 | ], [NAME, VERSION], [ 422 | 423 | /(wmplayer)\/((\d+)[\w\.-]+)/i, // Windows Media Player 424 | /(windows-media-player)\/((\d+)[\w\.-]+)/i 425 | ], [[NAME, /-/g, ' '], VERSION], [ 426 | 427 | /windows\/((\d+)[\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i 428 | // Windows Media Server 429 | ], [VERSION, [NAME, 'Windows']], [ 430 | 431 | /(com\.riseupradioalarm)\/((\d+)[\d\.]*)/i // RiseUP Radio Alarm 432 | ], [NAME, VERSION], [ 433 | 434 | /(rad.io)\s((\d+)[\d\.]+)/i, // Rad.io 435 | /(radio.(?:de|at|fr))\s((\d+)[\d\.]+)/i 436 | ], [[NAME, 'rad.io'], VERSION] 437 | 438 | ////////////////////// 439 | // Media players END 440 | ////////////////////*/ 441 | 442 | ], 443 | 444 | cpu : [[ 445 | 446 | /(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64 447 | ], [[ARCHITECTURE, 'amd64']], [ 448 | 449 | /(ia32(?=;))/i // IA32 (quicktime) 450 | ], [[ARCHITECTURE, util.lowerize]], [ 451 | 452 | /((?:i[346]|x)86)[;\)]/i // IA32 453 | ], [[ARCHITECTURE, 'ia32']], [ 454 | 455 | // PocketPC mistakenly identified as PowerPC 456 | /windows\s(ce|mobile);\sppc;/i 457 | ], [[ARCHITECTURE, 'arm']], [ 458 | 459 | /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC 460 | ], [[ARCHITECTURE, /ower/, '', util.lowerize]], [ 461 | 462 | /(sun4\w)[;\)]/i // SPARC 463 | ], [[ARCHITECTURE, 'sparc']], [ 464 | 465 | /((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i 466 | // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC 467 | ], [[ARCHITECTURE, util.lowerize]] 468 | ], 469 | 470 | device : [[ 471 | 472 | /\((ipad|playbook);[\w\s\);-]+(rim|apple)/i // iPad/PlayBook 473 | ], [MODEL, VENDOR, [TYPE, TABLET]], [ 474 | 475 | /applecoremedia\/[\w\.]+ \((ipad)/ // iPad 476 | ], [MODEL, [VENDOR, 'Apple'], [TYPE, TABLET]], [ 477 | 478 | /(apple\s{0,1}tv)/i // Apple TV 479 | ], [[MODEL, 'Apple TV'], [VENDOR, 'Apple']], [ 480 | 481 | /(archos)\s(gamepad2?)/i, // Archos 482 | /(hp).+(touchpad)/i, // HP TouchPad 483 | /(kindle)\/([\w\.]+)/i, // Kindle 484 | /\s(nook)[\w\s]+build\/(\w+)/i, // Nook 485 | /(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak 486 | ], [VENDOR, MODEL, [TYPE, TABLET]], [ 487 | 488 | /(kf[A-z]+)\sbuild\/[\w\.]+.*silk\//i // Kindle Fire HD 489 | ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [ 490 | /(sd|kf)[0349hijorstuw]+\sbuild\/[\w\.]+.*silk\//i // Fire Phone 491 | ], [[MODEL, mapper.str, maps.device.amazon.model], [VENDOR, 'Amazon'], [TYPE, MOBILE]], [ 492 | 493 | /\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone 494 | ], [MODEL, VENDOR, [TYPE, MOBILE]], [ 495 | /\((ip[honed|\s\w*]+);/i // iPod/iPhone 496 | ], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [ 497 | 498 | /(blackberry)[\s-]?(\w+)/i, // BlackBerry 499 | /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola|polytron)[\s_-]?([\w-]+)*/i, 500 | // BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Huawei/Meizu/Motorola/Polytron 501 | /(hp)\s([\w\s]+\w)/i, // HP iPAQ 502 | /(asus)-?(\w+)/i // Asus 503 | ], [VENDOR, MODEL, [TYPE, MOBILE]], [ 504 | /\(bb10;\s(\w+)/i // BlackBerry 10 505 | ], [MODEL, [VENDOR, 'BlackBerry'], [TYPE, MOBILE]], [ 506 | // Asus Tablets 507 | /android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7)/i 508 | ], [MODEL, [VENDOR, 'Asus'], [TYPE, TABLET]], [ 509 | 510 | /(sony)\s(tablet\s[ps])\sbuild\//i, // Sony 511 | /(sony)?(?:sgp.+)\sbuild\//i 512 | ], [[VENDOR, 'Sony'], [MODEL, 'Xperia Tablet'], [TYPE, TABLET]], [ 513 | /(?:sony)?(?:(?:(?:c|d)\d{4})|(?:so[-l].+))\sbuild\//i 514 | ], [[VENDOR, 'Sony'], [MODEL, 'Xperia Phone'], [TYPE, MOBILE]], [ 515 | 516 | /\s(ouya)\s/i, // Ouya 517 | /(nintendo)\s([wids3u]+)/i // Nintendo 518 | ], [VENDOR, MODEL, [TYPE, CONSOLE]], [ 519 | 520 | /android.+;\s(shield)\sbuild/i // Nvidia 521 | ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [ 522 | 523 | /(playstation\s[34portablevi]+)/i // Playstation 524 | ], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [ 525 | 526 | /(sprint\s(\w+))/i // Sprint Phones 527 | ], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [ 528 | 529 | /(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i // Lenovo tablets 530 | ], [VENDOR, MODEL, [TYPE, TABLET]], [ 531 | 532 | /(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC 533 | /(zte)-(\w+)*/i, // ZTE 534 | /(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i 535 | // Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony 536 | ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [ 537 | 538 | /(nexus\s9)/i // HTC Nexus 9 539 | ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [ 540 | 541 | /[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox 542 | ], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [ 543 | /(kin\.[onetw]{3})/i // Microsoft Kin 544 | ], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [ 545 | 546 | // Motorola 547 | /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?)[\w\s]+build\//i, 548 | /mot[\s-]?(\w+)*/i, 549 | /(XT\d{3,4}) build\//i, 550 | /(nexus\s[6])/i 551 | ], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [ 552 | /android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i 553 | ], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [ 554 | 555 | /android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9|nexus 10))/i, 556 | /((SM-T\w+))/i 557 | ], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung 558 | /((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-n900))/i, 559 | /(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i, 560 | /sec-((sgh\w+))/i 561 | ], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [ 562 | /(samsung);smarttv/i 563 | ], [VENDOR, MODEL, [TYPE, SMARTTV]], [ 564 | 565 | /\(dtv[\);].+(aquos)/i // Sharp 566 | ], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [ 567 | /sie-(\w+)*/i // Siemens 568 | ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [ 569 | 570 | /(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia 571 | /(nokia)[\s_-]?([\w-]+)*/i 572 | ], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [ 573 | 574 | /android\s3\.[\s\w;-]{10}(a\d{3})/i // Acer 575 | ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [ 576 | 577 | /android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet 578 | ], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [ 579 | /(lg) netcast\.tv/i // LG SmartTV 580 | ], [VENDOR, MODEL, [TYPE, SMARTTV]], [ 581 | /(nexus\s[45])/i, // LG 582 | /lg[e;\s\/-]+(\w+)*/i 583 | ], [MODEL, [VENDOR, 'LG'], [TYPE, MOBILE]], [ 584 | 585 | /android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo 586 | ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [ 587 | 588 | /linux;.+((jolla));/i // Jolla 589 | ], [VENDOR, MODEL, [TYPE, MOBILE]], [ 590 | 591 | /((pebble))app\/[\d\.]+\s/i // Pebble 592 | ], [VENDOR, MODEL, [TYPE, WEARABLE]], [ 593 | 594 | /android.+;\s(glass)\s\d/i // Google Glass 595 | ], [MODEL, [VENDOR, 'Google'], [TYPE, WEARABLE]], [ 596 | 597 | /android.+(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models 598 | /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi 599 | /android.+(mi[\s\-_]*(?:one|one[\s_]plus)?[\s_]*(?:\d\w)?)\s+build/i // Xiaomi Mi 600 | ], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [ 601 | 602 | /\s(tablet)[;\/\s]/i, // Unidentifiable Tablet 603 | /\s(mobile)[;\/\s]/i // Unidentifiable Mobile 604 | ], [[TYPE, util.lowerize], VENDOR, MODEL] 605 | 606 | /*////////////////////////// 607 | // TODO: move to string map 608 | //////////////////////////// 609 | 610 | /(C6603)/i // Sony Xperia Z C6603 611 | ], [[MODEL, 'Xperia Z C6603'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [ 612 | /(C6903)/i // Sony Xperia Z 1 613 | ], [[MODEL, 'Xperia Z 1'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [ 614 | 615 | /(SM-G900[F|H])/i // Samsung Galaxy S5 616 | ], [[MODEL, 'Galaxy S5'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ 617 | /(SM-G7102)/i // Samsung Galaxy Grand 2 618 | ], [[MODEL, 'Galaxy Grand 2'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ 619 | /(SM-G530H)/i // Samsung Galaxy Grand Prime 620 | ], [[MODEL, 'Galaxy Grand Prime'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ 621 | /(SM-G313HZ)/i // Samsung Galaxy V 622 | ], [[MODEL, 'Galaxy V'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ 623 | /(SM-T805)/i // Samsung Galaxy Tab S 10.5 624 | ], [[MODEL, 'Galaxy Tab S 10.5'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [ 625 | /(SM-G800F)/i // Samsung Galaxy S5 Mini 626 | ], [[MODEL, 'Galaxy S5 Mini'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [ 627 | /(SM-T311)/i // Samsung Galaxy Tab 3 8.0 628 | ], [[MODEL, 'Galaxy Tab 3 8.0'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [ 629 | 630 | /(R1001)/i // Oppo R1001 631 | ], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [ 632 | /(X9006)/i // Oppo Find 7a 633 | ], [[MODEL, 'Find 7a'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [ 634 | /(R2001)/i // Oppo YOYO R2001 635 | ], [[MODEL, 'Yoyo R2001'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [ 636 | /(R815)/i // Oppo Clover R815 637 | ], [[MODEL, 'Clover R815'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [ 638 | /(U707)/i // Oppo Find Way S 639 | ], [[MODEL, 'Find Way S'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [ 640 | 641 | /(T3C)/i // Advan Vandroid T3C 642 | ], [MODEL, [VENDOR, 'Advan'], [TYPE, TABLET]], [ 643 | /(ADVAN T1J\+)/i // Advan Vandroid T1J+ 644 | ], [[MODEL, 'Vandroid T1J+'], [VENDOR, 'Advan'], [TYPE, TABLET]], [ 645 | /(ADVAN S4A)/i // Advan Vandroid S4A 646 | ], [[MODEL, 'Vandroid S4A'], [VENDOR, 'Advan'], [TYPE, MOBILE]], [ 647 | 648 | /(V972M)/i // ZTE V972M 649 | ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [ 650 | 651 | /(i-mobile)\s(IQ\s[\d\.]+)/i // i-mobile IQ 652 | ], [VENDOR, MODEL, [TYPE, MOBILE]], [ 653 | /(IQ6.3)/i // i-mobile IQ IQ 6.3 654 | ], [[MODEL, 'IQ 6.3'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [ 655 | /(i-mobile)\s(i-style\s[\d\.]+)/i // i-mobile i-STYLE 656 | ], [VENDOR, MODEL, [TYPE, MOBILE]], [ 657 | /(i-STYLE2.1)/i // i-mobile i-STYLE 2.1 658 | ], [[MODEL, 'i-STYLE 2.1'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [ 659 | 660 | /(mobiistar touch LAI 512)/i // mobiistar touch LAI 512 661 | ], [[MODEL, 'Touch LAI 512'], [VENDOR, 'mobiistar'], [TYPE, MOBILE]], [ 662 | 663 | ///////////// 664 | // END TODO 665 | ///////////*/ 666 | 667 | ], 668 | 669 | engine : [[ 670 | 671 | /windows.+\sedge\/([\w\.]+)/i // EdgeHTML 672 | ], [VERSION, [NAME, 'EdgeHTML']], [ 673 | 674 | /(presto)\/([\w\.]+)/i, // Presto 675 | /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m 676 | /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links 677 | /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab 678 | ], [NAME, VERSION], [ 679 | 680 | /rv\:([\w\.]+).*(gecko)/i // Gecko 681 | ], [VERSION, NAME] 682 | ], 683 | 684 | os : [[ 685 | 686 | // Windows based 687 | /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes) 688 | ], [NAME, VERSION], [ 689 | /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT 690 | /(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i 691 | ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [ 692 | /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i 693 | ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [ 694 | 695 | // Mobile/Embedded OS 696 | /\((bb)(10);/i // BlackBerry 10 697 | ], [[NAME, 'BlackBerry'], VERSION], [ 698 | /(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry 699 | /(tizen)[\/\s]([\w\.]+)/i, // Tizen 700 | /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i, 701 | // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki 702 | /linux;.+(sailfish);/i // Sailfish OS 703 | ], [NAME, VERSION], [ 704 | /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian 705 | ], [[NAME, 'Symbian'], VERSION], [ 706 | /\((series40);/i // Series 40 707 | ], [NAME], [ 708 | /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS 709 | ], [[NAME, 'Firefox OS'], VERSION], [ 710 | 711 | // Console 712 | /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation 713 | 714 | // GNU/Linux based 715 | /(mint)[\/\s\(]?(\w+)*/i, // Mint 716 | /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux 717 | /(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i, 718 | // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware 719 | // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus 720 | /(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux 721 | /(gnu)\s?([\w\.]+)*/i // GNU 722 | ], [NAME, VERSION], [ 723 | 724 | /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS 725 | ], [[NAME, 'Chromium OS'], VERSION],[ 726 | 727 | // Solaris 728 | /(sunos)\s?([\w\.]+\d)*/i // Solaris 729 | ], [[NAME, 'Solaris'], VERSION], [ 730 | 731 | // BSD based 732 | /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly 733 | ], [NAME, VERSION],[ 734 | 735 | /(ip[honead]+)(?:.*os\s([\w]+)*\slike\smac|;\sopera)/i // iOS 736 | ], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [ 737 | 738 | /(mac\sos\sx)\s?([\w\s\.]+\w)*/i, 739 | /(macintosh|mac(?=_powerpc)\s)/i // Mac OS 740 | ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [ 741 | 742 | // Other 743 | /((?:open)?solaris)[\/\s-]?([\w\.]+)*/i, // Solaris 744 | /(haiku)\s(\w+)/i, // Haiku 745 | /(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX 746 | /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i, 747 | // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS 748 | /(unix)\s?([\w\.]+)*/i // UNIX 749 | ], [NAME, VERSION] 750 | ] 751 | }; 752 | 753 | 754 | ///////////////// 755 | // Constructor 756 | //////////////// 757 | 758 | 759 | var UAParser = function (uastring, extensions) { 760 | 761 | if (!(this instanceof UAParser)) { 762 | return new UAParser(uastring, extensions).getResult(); 763 | } 764 | 765 | var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); 766 | var rgxmap = extensions ? util.extend(regexes, extensions) : regexes; 767 | 768 | this.getBrowser = function () { 769 | var browser = mapper.rgx.apply(this, rgxmap.browser); 770 | browser.major = util.major(browser.version); 771 | return browser; 772 | }; 773 | this.getCPU = function () { 774 | return mapper.rgx.apply(this, rgxmap.cpu); 775 | }; 776 | this.getDevice = function () { 777 | return mapper.rgx.apply(this, rgxmap.device); 778 | }; 779 | this.getEngine = function () { 780 | return mapper.rgx.apply(this, rgxmap.engine); 781 | }; 782 | this.getOS = function () { 783 | return mapper.rgx.apply(this, rgxmap.os); 784 | }; 785 | this.getResult = function() { 786 | return { 787 | ua : this.getUA(), 788 | browser : this.getBrowser(), 789 | engine : this.getEngine(), 790 | os : this.getOS(), 791 | device : this.getDevice(), 792 | cpu : this.getCPU() 793 | }; 794 | }; 795 | this.getUA = function () { 796 | return ua; 797 | }; 798 | this.setUA = function (uastring) { 799 | ua = uastring; 800 | return this; 801 | }; 802 | this.setUA(ua); 803 | return this; 804 | }; 805 | 806 | UAParser.VERSION = LIBVERSION; 807 | UAParser.BROWSER = { 808 | NAME : NAME, 809 | MAJOR : MAJOR, // deprecated 810 | VERSION : VERSION 811 | }; 812 | UAParser.CPU = { 813 | ARCHITECTURE : ARCHITECTURE 814 | }; 815 | UAParser.DEVICE = { 816 | MODEL : MODEL, 817 | VENDOR : VENDOR, 818 | TYPE : TYPE, 819 | CONSOLE : CONSOLE, 820 | MOBILE : MOBILE, 821 | SMARTTV : SMARTTV, 822 | TABLET : TABLET, 823 | WEARABLE: WEARABLE, 824 | EMBEDDED: EMBEDDED 825 | }; 826 | UAParser.ENGINE = { 827 | NAME : NAME, 828 | VERSION : VERSION 829 | }; 830 | UAParser.OS = { 831 | NAME : NAME, 832 | VERSION : VERSION 833 | }; 834 | 835 | 836 | /////////// 837 | // Export 838 | ////////// 839 | 840 | 841 | // check js environment 842 | if (typeof(exports) !== UNDEF_TYPE) { 843 | // nodejs env 844 | if (typeof module !== UNDEF_TYPE && module.exports) { 845 | exports = module.exports = UAParser; 846 | } 847 | exports.UAParser = UAParser; 848 | } else { 849 | // requirejs env (optional) 850 | if (typeof(define) === FUNC_TYPE && define.amd) { 851 | define(function () { 852 | return UAParser; 853 | }); 854 | } else { 855 | // browser env 856 | window.UAParser = UAParser; 857 | } 858 | } 859 | 860 | // jQuery/Zepto specific (optional) 861 | // Note: 862 | // In AMD env the global scope should be kept clean, but jQuery is an exception. 863 | // jQuery always exports to global scope, unless jQuery.noConflict(true) is used, 864 | // and we should catch that. 865 | 866 | var $ = window.jQuery || window.Zepto; 867 | if (typeof $ !== UNDEF_TYPE) { 868 | var parser = new UAParser(); 869 | $.ua = parser.getResult(); 870 | $.ua.get = function() { 871 | return parser.getUA(); 872 | }; 873 | $.ua.set = function (uastring) { 874 | parser.setUA(uastring); 875 | var result = parser.getResult(); 876 | for (var prop in result) { 877 | $.ua[prop] = result[prop]; 878 | } 879 | }; 880 | } 881 | 882 | })(typeof window === 'object' ? window : this); 883 | -------------------------------------------------------------------------------- /dist/client.min.js: -------------------------------------------------------------------------------- 1 | (function(f){var d,e,p=function(){d=(new (window.UAParser||exports.UAParser)).getResult();e=new Detector;return this};p.prototype={getSoftwareVersion:function(){return"0.1.11"},getBrowserData:function(){return d},getFingerprint:function(){var b=d.ua,c=this.getScreenPrint(),a=this.getPlugins(),g=this.getFonts(),n=this.isLocalStorage(),f=this.isSessionStorage(),h=this.getTimeZone(),u=this.getLanguage(),m=this.getSystemLanguage(),e=this.isCookie(),C=this.getCanvasPrint();return murmurhash3_32_gc(b+"|"+ 2 | c+"|"+a+"|"+g+"|"+n+"|"+f+"|"+h+"|"+u+"|"+m+"|"+e+"|"+C,256)},getCustomFingerprint:function(){for(var b="",c=0;c 1.0",2,15);c.fillStyle="rgba(102, 204, 0, 0.7)";c.fillText("ClientJS,org 1.0",4,17);return b.toDataURL()}};"object"=== 13 | typeof module&&"undefined"!==typeof exports&&(module.exports=p);f.ClientJS=p})(window);var deployJava=function(){function f(a){c.debug&&(console.log?console.log(a):alert(a))}function d(a){if(null==a||0==a.length)return"http://java.com/dt-redirect";"&"==a.charAt(0)&&(a=a.substring(1,a.length));return"http://java.com/dt-redirect?"+a}var e=["id","class","title","style"];"classid codebase codetype data type archive declare standby height width usemap name tabindex align border hspace vspace".split(" ").concat(e,["lang","dir"],"onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup".split(" ")); 14 | var p="codebase code name archive object width height alt align hspace vspace".split(" ").concat(e),b;try{b=-1!=document.location.protocol.indexOf("http")?"//java.com/js/webstart.png":"http://java.com/js/webstart.png"}catch(a){b="http://java.com/js/webstart.png"}var c={debug:null,version:"20120801",firefoxJavaVersion:null,myInterval:null,preInstallJREList:null,returnPage:null,brand:null,locale:null,installType:null,EAInstallEnabled:!1,EarlyAccessURL:null,oldMimeType:"application/npruntime-scriptable-plugin;DeploymentToolkit", 15 | mimeType:"application/java-deployment-toolkit",launchButtonPNG:b,browserName:null,browserName2:null,getJREs:function(){var a=[];if(this.isPluginInstalled())for(var g=this.getPlugin().jvms,b=0;b'}d||(c+='');h&&(b+=' code="dummy"');document.write(b+">\n"+c+"\n")},versionCheck:function(a){var g=0,b=a.match("^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$");if(null!=b){for(var c=a=!1,h=[],d=1;dh.length&&(c=!1,a=!0);g=this.getJREs();for(d=0;d':"Netscape Family"==c&&(d='');"undefined"==document.body||null==document.body? 26 | (document.write(d),document.location=b):(a=document.createElement("div"),a.id="div1",a.style.position="relative",a.style.left="-10000px",a.style.margin="0px auto",a.className="dynamicDiv",a.innerHTML=d,document.body.appendChild(a))},createWebStartLaunchButtonEx:function(a,b){null==this.returnPage&&(this.returnPage=a);document.write('')}, 27 | createWebStartLaunchButton:function(a,b){null==this.returnPage&&(this.returnPage=a);document.write('')},launch:function(a){document.location=a;return!0},isPluginInstalled:function(){var a= 28 | this.getPlugin();return a&&a.jvms?!0:!1},isAutoUpdateEnabled:function(){return this.isPluginInstalled()?this.getPlugin().isAutoUpdateEnabled():!1},setAutoUpdateEnabled:function(){return this.isPluginInstalled()?this.getPlugin().setAutoUpdateEnabled():!1},setInstallerType:function(a){this.installType=a;return this.isPluginInstalled()?this.getPlugin().setInstallerType(a):!1},setAdditionalPackages:function(a){return this.isPluginInstalled()?this.getPlugin().setAdditionalPackages(a):!1},setEarlyAccess:function(a){this.EAInstallEnabled= 29 | a},isPlugin2:function(){if(this.isPluginInstalled()&&this.versionCheck("1.6.0_10+"))try{return this.getPlugin().isPlugin2()}catch(a){}return!1},allowPlugin:function(){this.getBrowser();return"Safari"!=this.browserName2&&"Opera"!=this.browserName2},getPlugin:function(){this.refresh();var a=null;this.allowPlugin()&&(a=document.getElementById("deployJavaPlugin"));return a},compareVersionToPattern:function(a,b,c,d){if(void 0==a||void 0==b)return!1;var h=a.match("^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"); 30 | if(null!=h){var f=0;a=[];for(var m=1;mb[m])break}return!0}for(m=0;m "+a);-1!=a.indexOf("msie")&&-1==a.indexOf("opera")?this.browserName2=this.browserName= 31 | "MSIE":-1!=a.indexOf("iphone")?(this.browserName="Netscape Family",this.browserName2="iPhone"):-1!=a.indexOf("firefox")&&-1==a.indexOf("opera")?(this.browserName="Netscape Family",this.browserName2="Firefox"):-1!=a.indexOf("chrome")?(this.browserName="Netscape Family",this.browserName2="Chrome"):-1!=a.indexOf("safari")?(this.browserName="Netscape Family",this.browserName2="Safari"):-1!=a.indexOf("mozilla")&&-1==a.indexOf("opera")?(this.browserName="Netscape Family",this.browserName2="Other"):-1!= 32 | a.indexOf("opera")?(this.browserName="Netscape Family",this.browserName2="Opera"):(this.browserName="?",this.browserName2="unknown");f("[getBrowser()] Detected browser name:"+this.browserName+", "+this.browserName2)}return this.browserName},testUsingActiveX:function(a){a="JavaWebStart.isInstalled."+a+".0";if("undefined"==typeof ActiveXObject||!ActiveXObject)return f("[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?"),!1;try{return null!=new ActiveXObject(a)}catch(b){return!1}}, 33 | testForMSVM:function(){if("undefined"!=typeof oClientCaps){var a=oClientCaps.getComponentVersion("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}","ComponentID");return""==a||"5,0,5000,0"==a?!1:!0}return!1},testUsingMimeTypes:function(a){if(!navigator.mimeTypes)return f("[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?"),!1;for(var b=0;bd[0]?!0:c[0]d[1]?!0:c[1]d[2]?!0:c[2]'):"Netscape Family"==a&&this.allowPlugin()&&this.writeEmbedTag()},refresh:function(){navigator.plugins.refresh(!1);"Netscape Family"==this.getBrowser()&&this.allowPlugin()&&null== 38 | document.getElementById("deployJavaPlugin")&&this.writeEmbedTag()},writeEmbedTag:function(){var a=!1;if(null!=navigator.mimeTypes){for(var b=0;b