Skip to content

Commit

Permalink
1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
heenakwag committed Jul 25, 2019
1 parent 195c251 commit 2a459f7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 53 deletions.
112 changes: 61 additions & 51 deletions dist/tui-code-snippet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* tui-code-snippet.js
* @version 1.5.1
* @version 1.5.2
* @author NHN. FE Development Lab <[email protected]>
* @license MIT
*/
Expand Down Expand Up @@ -1825,65 +1825,75 @@ return /******/ (function(modules) { // webpackBootstrap
version: 0
};

var nav = window.navigator;
var appName = nav.appName.replace(/\s/g, '_');
var userAgent = nav.userAgent;

var rIE = /MSIE\s([0-9]+[.0-9]*)/;
var rIE11 = /Trident.*rv:11\./;
var rEdge = /Edge\/(\d+)\./;
var versionRegex = {
firefox: /Firefox\/(\d+)\./,
chrome: /Chrome\/(\d+)\./,
safari: /Version\/([\d.]+).*Safari\/(\d+)/
};
if (window && window.navigator) {
detectBrowser();
}

var key, tmp;
/**
* Detect the browser.
* @private
*/
function detectBrowser() {
var nav = window.navigator;
var appName = nav.appName.replace(/\s/g, '_');
var userAgent = nav.userAgent;

var rIE = /MSIE\s([0-9]+[.0-9]*)/;
var rIE11 = /Trident.*rv:11\./;
var rEdge = /Edge\/(\d+)\./;
var versionRegex = {
firefox: /Firefox\/(\d+)\./,
chrome: /Chrome\/(\d+)\./,
safari: /Version\/([\d.]+).*Safari\/(\d+)/
};

var detector = {
Microsoft_Internet_Explorer: function() { // eslint-disable-line camelcase
var detectedVersion = userAgent.match(rIE);
var key, tmp;

if (detectedVersion) { // ie8 ~ ie10
browser.msie = true;
browser.version = parseFloat(detectedVersion[1]);
} else { // no version information
browser.others = true;
}
},
Netscape: function() { // eslint-disable-line complexity
var detected = false;

if (rIE11.exec(userAgent)) {
browser.msie = true;
browser.version = 11;
detected = true;
} else if (rEdge.exec(userAgent)) {
browser.edge = true;
browser.version = userAgent.match(rEdge)[1];
detected = true;
} else {
for (key in versionRegex) {
if (versionRegex.hasOwnProperty(key)) {
tmp = userAgent.match(versionRegex[key]);
if (tmp && tmp.length > 1) { // eslint-disable-line max-depth
browser[key] = detected = true;
browser.version = parseFloat(tmp[1] || 0);
break;
var detector = {
Microsoft_Internet_Explorer: function() { // eslint-disable-line camelcase
var detectedVersion = userAgent.match(rIE);

if (detectedVersion) { // ie8 ~ ie10
browser.msie = true;
browser.version = parseFloat(detectedVersion[1]);
} else { // no version information
browser.others = true;
}
},
Netscape: function() { // eslint-disable-line complexity
var detected = false;

if (rIE11.exec(userAgent)) {
browser.msie = true;
browser.version = 11;
detected = true;
} else if (rEdge.exec(userAgent)) {
browser.edge = true;
browser.version = userAgent.match(rEdge)[1];
detected = true;
} else {
for (key in versionRegex) {
if (versionRegex.hasOwnProperty(key)) {
tmp = userAgent.match(versionRegex[key]);
if (tmp && tmp.length > 1) { // eslint-disable-line max-depth
browser[key] = detected = true;
browser.version = parseFloat(tmp[1] || 0);
break;
}
}
}
}
if (!detected) {
browser.others = true;
}
}
if (!detected) {
browser.others = true;
}
}
};
};

var fn = detector[appName];
var fn = detector[appName];

if (fn) {
detector[appName]();
if (fn) {
detector[appName]();
}
}

module.exports = browser;
Expand Down
Loading

0 comments on commit 2a459f7

Please sign in to comment.