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