From 48b5ad1ad4b2e4a69ee326d89251d46070add917 Mon Sep 17 00:00:00 2001 From: syranide Date: Tue, 6 Oct 2015 13:30:38 +0200 Subject: [PATCH] Improved isSupported() implementation --- README.md | 4 ++-- bower.json | 2 +- npm-swf-player-version/README.md | 4 ++-- npm-swf-player-version/package.json | 2 +- npm-swf-player-version/swf-player-version.js | 12 ++++++------ package.json | 2 +- swf-player-version.js | 12 ++++++------ swf-player-version.min.js | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 73362b8..f8b5729 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ if (SWFPlayerVersion.isSupported('10.0')) { ``` get() - returns {?string} 'X.Y.Z' or null. + returns {?string} '#.#.#' or null. Get available SWF Player version. Result is cached. ``` ``` isSupported(requiredString) - requiredString {string} 'X.Y.Z', 'X.Y' or 'X'. + requiredString {string} '#.#.#', '#.#', '#' or ''. returns {boolean} true if supported. Determine if available SWF Player meets version requirement. diff --git a/bower.json b/bower.json index f42691f..b244c11 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "swf-player-version", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "description": "Shockwave Flash Player version utility", "authors": ["Andreas Svensson "], diff --git a/npm-swf-player-version/README.md b/npm-swf-player-version/README.md index f169eb1..2e063dc 100644 --- a/npm-swf-player-version/README.md +++ b/npm-swf-player-version/README.md @@ -13,13 +13,13 @@ if (SWFPlayerVersion.isSupported('10.0')) { ``` get() - returns {?string} 'X.Y.Z' or null. + returns {?string} '#.#.#' or null. Get available SWF Player version. Result is cached. ``` ``` isSupported(requiredString) - requiredString {string} 'X.Y.Z', 'X.Y' or 'X'. + requiredString {string} '#.#.#', '#.#', '#' or ''. returns {boolean} true if supported. Determine if available SWF Player meets version requirement. diff --git a/npm-swf-player-version/package.json b/npm-swf-player-version/package.json index c02f125..9544cdd 100644 --- a/npm-swf-player-version/package.json +++ b/npm-swf-player-version/package.json @@ -1,6 +1,6 @@ { "name": "swf-player-version", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "description": "Shockwave Flash Player version utility", "author": "Andreas Svensson ", diff --git a/npm-swf-player-version/swf-player-version.js b/npm-swf-player-version/swf-player-version.js index 2e91618..93c0c37 100644 --- a/npm-swf-player-version/swf-player-version.js +++ b/npm-swf-player-version/swf-player-version.js @@ -1,4 +1,4 @@ -/*! swf-player-version v1.1.0 | @syranide | MIT license */ +/*! swf-player-version v1.1.1 | @syranide | MIT license */ 'use strict'; @@ -48,7 +48,7 @@ function detectAvailableVersion() { /** * Get available SWF Player version. Result is cached. * - * @return {?string} 'X.Y.Z' or null. + * @return {?string} '#.#.#' or null. */ function getVersion() { if (detectedVersion === undefined) { @@ -61,7 +61,7 @@ function getVersion() { /** * Determine if available SWF Player meets version requirement. * - * @param {string} requiredString 'X.Y.Z', 'X.Y' or 'X'. + * @param {string} requiredString '#.#.#', '#.#', '#' or ''. * @return {boolean} true if supported. */ function isVersionSupported(requiredString) { @@ -74,9 +74,9 @@ function isVersionSupported(requiredString) { var availableFields = availableString.split('.'); var requiredFields = requiredString.split('.'); - for (var i = 0; i < 3; i++) { - var availableField = availableFields[i]; - var requiredField = requiredFields[i] || '0'; + for (var i = 0; i < requiredFields.length; i++) { + var availableField = availableFields[i] || '0'; + var requiredField = requiredFields[i]; if (availableField !== requiredField) { return +availableField > +requiredField; diff --git a/package.json b/package.json index c02f125..9544cdd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swf-player-version", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "description": "Shockwave Flash Player version utility", "author": "Andreas Svensson ", diff --git a/swf-player-version.js b/swf-player-version.js index 100271b..d7d8b12 100644 --- a/swf-player-version.js +++ b/swf-player-version.js @@ -1,4 +1,4 @@ -/*! swf-player-version v1.1.0 | @syranide | MIT license */ +/*! swf-player-version v1.1.1 | @syranide | MIT license */ (function(root, factory) { if (typeof define === 'function' && define.amd) { @@ -57,7 +57,7 @@ /** * Get available SWF Player version. Result is cached. * - * @return {?string} 'X.Y.Z' or null. + * @return {?string} '#.#.#' or null. */ function getVersion() { if (detectedVersion === undefined) { @@ -70,7 +70,7 @@ /** * Determine if available SWF Player meets version requirement. * - * @param {string} requiredString 'X.Y.Z', 'X.Y' or 'X'. + * @param {string} requiredString '#.#.#', '#.#', '#' or ''. * @return {boolean} true if supported. */ function isVersionSupported(requiredString) { @@ -83,9 +83,9 @@ var availableFields = availableString.split('.'); var requiredFields = requiredString.split('.'); - for (var i = 0; i < 3; i++) { - var availableField = availableFields[i]; - var requiredField = requiredFields[i] || '0'; + for (var i = 0; i < requiredFields.length; i++) { + var availableField = availableFields[i] || '0'; + var requiredField = requiredFields[i]; if (availableField !== requiredField) { return +availableField > +requiredField; diff --git a/swf-player-version.min.js b/swf-player-version.min.js index 66c4e3e..4705560 100644 --- a/swf-player-version.min.js +++ b/swf-player-version.min.js @@ -1,2 +1,2 @@ -/*! swf-player-version v1.1.0 | @syranide | MIT license */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.SWFPlayerVersion=t()}(this,function(){"use strict";function e(e){return e.match(/\d+/g).slice(0,3).join(".")}function t(){if("object"==typeof navigator&&navigator.mimeTypes){var t=navigator.mimeTypes["application/x-shockwave-flash"];if(t){var i=t.enabledPlugin;if(i)return void(r=e(i.description))}}if("function"==typeof ActiveXObject){var n;try{n=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}if(n)return void(r=e(n.GetVariable("$version")))}r=null}function i(){return void 0===r&&t(),r}function n(e){var t=i();if(null==t)return!1;for(var n=t.split("."),r=e.split("."),o=0;3>o;o++){var a=n[o],c=r[o]||"0";if(a!==c)return+a>+c}return!0}var r,o={get:i,isSupported:n};return o}); +/*! swf-player-version v1.1.1 | @syranide | MIT license */ +!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.SWFPlayerVersion=t()}(this,function(){"use strict";function e(e){return e.match(/\d+/g).slice(0,3).join(".")}function t(){if("object"==typeof navigator&&navigator.mimeTypes){var t=navigator.mimeTypes["application/x-shockwave-flash"];if(t){var i=t.enabledPlugin;if(i)return void(r=e(i.description))}}if("function"==typeof ActiveXObject){var n;try{n=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}if(n)return void(r=e(n.GetVariable("$version")))}r=null}function i(){return void 0===r&&t(),r}function n(e){var t=i();if(null==t)return!1;for(var n=t.split("."),r=e.split("."),o=0;o+c}return!0}var r,o={get:i,isSupported:n};return o});