mirror of
https://github.com/ipdb/website.git
synced 2024-11-22 01:26:52 +01:00
js linting
This commit is contained in:
parent
aab011c3e3
commit
ce597d5cc5
@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": "ascribe"
|
"extends": "ascribe",
|
||||||
|
"rules": {
|
||||||
|
"no-unused-vars": 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true or false based on whether doNotTack is enabled. It also takes into account the
|
* Returns true or false based on whether doNotTack is enabled. It also takes into account the
|
||||||
* anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles
|
* anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles
|
||||||
@ -10,39 +8,36 @@
|
|||||||
* @returns {boolean} true if enabled else false
|
* @returns {boolean} true if enabled else false
|
||||||
*/
|
*/
|
||||||
function _dntEnabled(dnt, userAgent) {
|
function _dntEnabled(dnt, userAgent) {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// for old version of IE we need to use the msDoNotTrack property of navigator
|
// for old version of IE we need to use the msDoNotTrack property of navigator
|
||||||
// on newer versions, and newer platforms, this is doNotTrack but, on the window object
|
// on newer versions, and newer platforms, this is doNotTrack but, on the window object
|
||||||
// Safari also exposes the property on the window object.
|
// Safari also exposes the property on the window object.
|
||||||
var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
|
let dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack
|
||||||
var ua = userAgent || navigator.userAgent;
|
const ua = userAgent || navigator.userAgent
|
||||||
|
|
||||||
// List of Windows versions known to not implement DNT according to the standard.
|
// List of Windows versions known to not implement DNT according to the standard.
|
||||||
var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3'];
|
const anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3']
|
||||||
|
|
||||||
var fxMatch = ua.match(/Firefox\/(\d+)/);
|
const fxMatch = ua.match(/Firefox\/(\d+)/)
|
||||||
var ieRegEx = /MSIE|Trident/i;
|
const ieRegEx = /MSIE|Trident/i
|
||||||
var isIE = ieRegEx.test(ua);
|
const isIE = ieRegEx.test(ua)
|
||||||
// Matches from Windows up to the first occurance of ; un-greedily
|
// Matches from Windows up to the first occurance of ; un-greedily
|
||||||
// http://www.regexr.com/3c2el
|
// http://www.regexr.com/3c2el
|
||||||
var platform = ua.match(/Windows.+?(?=;)/g);
|
const platform = ua.match(/Windows.+?(?=;)/g)
|
||||||
|
|
||||||
// With old versions of IE, DNT did not exist so we simply return false;
|
// With old versions of IE, DNT did not exist so we simply return false;
|
||||||
if (isIE && typeof Array.prototype.indexOf !== 'function') {
|
if (isIE && typeof Array.prototype.indexOf !== 'function') {
|
||||||
return false;
|
return false
|
||||||
} else if (fxMatch && parseInt(fxMatch[1], 10) < 32) {
|
} else if (fxMatch && parseInt(fxMatch[1], 10) < 32) {
|
||||||
// Can't say for sure if it is 1 or 0, due to Fx bug 887703
|
// Can't say for sure if it is 1 or 0, due to Fx bug 887703
|
||||||
dntStatus = 'Unspecified';
|
dntStatus = 'Unspecified'
|
||||||
} else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) {
|
} else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) {
|
||||||
// default is on, which does not honor the specification
|
// default is on, which does not honor the specification
|
||||||
dntStatus = 'Unspecified';
|
dntStatus = 'Unspecified'
|
||||||
} else {
|
} else {
|
||||||
// sets dntStatus to Disabled or Enabled based on the value returned by the browser.
|
// sets dntStatus to Disabled or Enabled based on the value returned by the browser.
|
||||||
// If dntStatus is undefined, it will be set to Unspecified
|
// If dntStatus is undefined, it will be set to Unspecified
|
||||||
dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified';
|
dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified'
|
||||||
}
|
}
|
||||||
|
|
||||||
return dntStatus === 'Enabled' ? true : false;
|
return dntStatus === 'Enabled'
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* global SmoothScroll */
|
||||||
|
|
||||||
// =include _dnt.js
|
// =include _dnt.js
|
||||||
// =include smooth-scroll/dist/js/smooth-scroll.js
|
// =include smooth-scroll/dist/js/smooth-scroll.js
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user