Removed parameters from screen functions

This commit is contained in:
z0ccc 2021-10-04 23:41:36 -04:00
parent ef0fbf1a12
commit 9a308f287a

View file

@ -1,99 +1,123 @@
const getWidth = (key) => ({ const getWidth = () => {
const name = 'width';
return {
key: 'Width', key: 'Width',
code: `window.screen.${key}`, code: `window.screen.${name}`,
value: window.screen[key], value: window.screen[name],
issues: [ issues: [
checkScreenProperties('width'), checkScreenProperties('width'),
checkScreenValue('width'), checkScreenValue('width'),
checkScreenPrototype('width'), checkScreenPrototype('width'),
checkWidth(), checkWidth(),
], ],
}); };
};
const getAvailWidth = (key) => ({ const getAvailWidth = () => {
const name = 'availWidth';
return {
key: 'Avail width', key: 'Avail width',
code: `window.screen.${key}`, code: `window.screen.${name}`,
value: window.screen[key], value: window.screen[name],
issues: [ issues: [
checkScreenProperties('availWidth'), checkScreenProperties('availWidth'),
checkScreenValue('availWidth'), checkScreenValue('availWidth'),
checkScreenPrototype('availWidth'), checkScreenPrototype('availWidth'),
checkWidth(), checkWidth(),
], ],
}); };
};
const getOuterWidth = (key) => ({ const getOuterWidth = () => {
const name = 'outerWidth';
return {
key: 'Outer width', key: 'Outer width',
code: `window.${key}`, code: `window.${name}`,
value: window[key], value: window[name],
issues: [], issues: [],
}); };
};
const getHeight = (key) => ({ const getHeight = () => {
const name = 'height';
return {
key: 'Height', key: 'Height',
code: `window.screen.${key}`, code: `window.screen.${name}`,
value: window.screen[key], value: window.screen[name],
issues: [ issues: [
checkScreenProperties('height'), checkScreenProperties('height'),
checkScreenValue('height'), checkScreenValue('height'),
checkScreenPrototype('height'), checkScreenPrototype('height'),
], ],
}); };
};
const getAvailHeight = (key) => ({ const getAvailHeight = () => {
const name = 'availHeight';
return {
key: 'Avail height', key: 'Avail height',
code: `window.screen.${key}`, code: `window.screen.${name}`,
value: window.screen[key], value: window.screen[name],
issues: [ issues: [
checkScreenProperties('availHeight'), checkScreenProperties('availHeight'),
checkScreenValue('availHeight'), checkScreenValue('availHeight'),
checkScreenPrototype('availHeight'), checkScreenPrototype('availHeight'),
checkHeight(), checkHeight(),
], ],
}); };
};
const getOuterHeight = (key) => ({ const getOuterHeight = () => {
const name = 'outerHeight';
return {
key: 'Outer height', key: 'Outer height',
code: `window.${key}`, code: `window.${name}`,
value: window[key], value: window[name],
issues: [], issues: [],
}); };
};
const getPixelDepth = (key) => ({ const getPixelDepth = () => {
const name = 'pixelDepth';
return {
key: 'Pixel depth', key: 'Pixel depth',
code: `window.screen.${key}`, code: `window.screen.${name}`,
value: window.screen[key], value: window.screen[name],
issues: [ issues: [
checkScreenProperties('pixelDepth'), checkScreenProperties('pixelDepth'),
checkScreenValue('pixelDepth'), checkScreenValue('pixelDepth'),
checkScreenPrototype('pixelDepth'), checkScreenPrototype('pixelDepth'),
], ],
}); };
};
const getColorDepth = (key) => ({ const getColorDepth = () => {
const name = 'colorDepth';
return {
key: 'Color depth', key: 'Color depth',
code: `window.screen.${key}`, code: `window.screen.${name}`,
value: window.screen[key], value: window.screen[name],
issues: [ issues: [
checkScreenProperties('colorDepth'), checkScreenProperties('colorDepth'),
checkScreenValue('colorDepth'), checkScreenValue('colorDepth'),
checkScreenPrototype('colorDepth'), checkScreenPrototype('colorDepth'),
], ],
}); };
};
const checkScreenValue = (key) => { const checkScreenValue = (name) => {
if ( if (
Object.getOwnPropertyDescriptor(Screen.prototype, key).value !== undefined Object.getOwnPropertyDescriptor(Screen.prototype, name).value !== undefined
) { ) {
return 'Failed descriptor.value undefined'; return 'Failed descriptor.value undefined';
} }
return null; return null;
}; };
const checkScreenPrototype = (key) => { const checkScreenPrototype = (name) => {
try { try {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const check = Screen.prototype[key]; const check = Screen.prototype[name];
return 'Failed Screen.prototype'; return 'Failed Screen.prototype';
} catch (err) { } catch (err) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -116,22 +140,22 @@ const checkHeight = () => {
return null; return null;
}; };
const checkScreenProperties = (key) => { const checkScreenProperties = (name) => {
if (Object.getOwnPropertyDescriptor(window.screen, key) !== undefined) { if (Object.getOwnPropertyDescriptor(window.screen, name) !== undefined) {
return 'Failed undefined properties'; return 'Failed undefined properties';
} }
return null; return null;
}; };
const getScreen = () => [ const getScreen = () => [
getWidth('width'), getWidth(),
getAvailWidth('availWidth'), getAvailWidth(),
getOuterWidth('outerWidth'), getOuterWidth(),
getHeight('height'), getHeight(),
getAvailHeight('availHeight'), getAvailHeight(),
getOuterHeight('outerHeight'), getOuterHeight(),
getPixelDepth('pixelDepth'), getPixelDepth(),
getColorDepth('colorDepth'), getColorDepth(),
]; ];
export default getScreen; export default getScreen;