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 = () => {
key: 'Width', const name = 'width';
code: `window.screen.${key}`, return {
value: window.screen[key], key: 'Width',
issues: [ code: `window.screen.${name}`,
checkScreenProperties('width'), value: window.screen[name],
checkScreenValue('width'), issues: [
checkScreenPrototype('width'), checkScreenProperties('width'),
checkWidth(), checkScreenValue('width'),
], checkScreenPrototype('width'),
}); checkWidth(),
],
};
};
const getAvailWidth = (key) => ({ const getAvailWidth = () => {
key: 'Avail width', const name = 'availWidth';
code: `window.screen.${key}`, return {
value: window.screen[key], key: 'Avail width',
issues: [ code: `window.screen.${name}`,
checkScreenProperties('availWidth'), value: window.screen[name],
checkScreenValue('availWidth'), issues: [
checkScreenPrototype('availWidth'), checkScreenProperties('availWidth'),
checkWidth(), checkScreenValue('availWidth'),
], checkScreenPrototype('availWidth'),
}); checkWidth(),
],
};
};
const getOuterWidth = (key) => ({ const getOuterWidth = () => {
key: 'Outer width', const name = 'outerWidth';
code: `window.${key}`, return {
value: window[key], key: 'Outer width',
issues: [], code: `window.${name}`,
}); value: window[name],
issues: [],
};
};
const getHeight = (key) => ({ const getHeight = () => {
key: 'Height', const name = 'height';
code: `window.screen.${key}`, return {
value: window.screen[key], key: 'Height',
issues: [ code: `window.screen.${name}`,
checkScreenProperties('height'), value: window.screen[name],
checkScreenValue('height'), issues: [
checkScreenPrototype('height'), checkScreenProperties('height'),
], checkScreenValue('height'),
}); checkScreenPrototype('height'),
],
};
};
const getAvailHeight = (key) => ({ const getAvailHeight = () => {
key: 'Avail height', const name = 'availHeight';
code: `window.screen.${key}`, return {
value: window.screen[key], key: 'Avail height',
issues: [ code: `window.screen.${name}`,
checkScreenProperties('availHeight'), value: window.screen[name],
checkScreenValue('availHeight'), issues: [
checkScreenPrototype('availHeight'), checkScreenProperties('availHeight'),
checkHeight(), checkScreenValue('availHeight'),
], checkScreenPrototype('availHeight'),
}); checkHeight(),
],
};
};
const getOuterHeight = (key) => ({ const getOuterHeight = () => {
key: 'Outer height', const name = 'outerHeight';
code: `window.${key}`, return {
value: window[key], key: 'Outer height',
issues: [], code: `window.${name}`,
}); value: window[name],
issues: [],
};
};
const getPixelDepth = (key) => ({ const getPixelDepth = () => {
key: 'Pixel depth', const name = 'pixelDepth';
code: `window.screen.${key}`, return {
value: window.screen[key], key: 'Pixel depth',
issues: [ code: `window.screen.${name}`,
checkScreenProperties('pixelDepth'), value: window.screen[name],
checkScreenValue('pixelDepth'), issues: [
checkScreenPrototype('pixelDepth'), checkScreenProperties('pixelDepth'),
], checkScreenValue('pixelDepth'),
}); checkScreenPrototype('pixelDepth'),
],
};
};
const getColorDepth = (key) => ({ const getColorDepth = () => {
key: 'Color depth', const name = 'colorDepth';
code: `window.screen.${key}`, return {
value: window.screen[key], key: 'Color depth',
issues: [ code: `window.screen.${name}`,
checkScreenProperties('colorDepth'), value: window.screen[name],
checkScreenValue('colorDepth'), issues: [
checkScreenPrototype('colorDepth'), checkScreenProperties('colorDepth'),
], checkScreenValue('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;