Added prettier (#661)

* Added prettier

* Added prettier

* Added prettier
This commit is contained in:
Daniël van Noord
2021-03-14 18:57:07 +01:00
committed by GitHub
parent f3e7964262
commit 932509a877
132 changed files with 7143 additions and 4894 deletions

View File

@@ -1,6 +1,13 @@
import { CMOptions } from '../../Config/VariablesAndData';
import {
ColorTextPre, ColorBorderPre, ColorGray, ColorBlue, ColorRed, ColorYellow, ColorPurple, TooltipType,
ColorTextPre,
ColorBorderPre,
ColorGray,
ColorBlue,
ColorRed,
ColorYellow,
ColorPurple,
TooltipType,
} from '../VariablesAndData';
/** Creates various sections of tooltips */
@@ -10,14 +17,14 @@ import {
* @returns {object} div An object containing the stylized box
*/
export function TooltipCreateTooltipBox() {
l('tooltip').firstChild.style.paddingBottom = '4px'; // Sets padding on base-tooltip
const tooltipBox = document.createElement('div');
tooltipBox.style.border = '1px solid';
tooltipBox.style.padding = '4px';
tooltipBox.style.margin = '0px -4px';
tooltipBox.id = 'CMTooltipBorder';
tooltipBox.className = ColorTextPre + ColorGray;
return tooltipBox;
l('tooltip').firstChild.style.paddingBottom = '4px'; // Sets padding on base-tooltip
const tooltipBox = document.createElement('div');
tooltipBox.style.border = '1px solid';
tooltipBox.style.padding = '4px';
tooltipBox.style.margin = '0px -4px';
tooltipBox.id = 'CMTooltipBorder';
tooltipBox.className = ColorTextPre + ColorGray;
return tooltipBox;
}
/**
@@ -26,12 +33,12 @@ export function TooltipCreateTooltipBox() {
* @returns {object} div An object containing the stylized header
*/
export function TooltipCreateHeader(text) {
const div = document.createElement('div');
div.style.fontWeight = 'bold';
div.id = `${text}Title`;
div.className = ColorTextPre + ColorBlue;
div.textContent = text;
return div;
const div = document.createElement('div');
div.style.fontWeight = 'bold';
div.id = `${text}Title`;
div.className = ColorTextPre + ColorBlue;
div.textContent = text;
return div;
}
/**
@@ -40,51 +47,105 @@ export function TooltipCreateHeader(text) {
* @returns {object} TooltipWarn The Warnings-tooltip object
*/
export function TooltipCreateWarningSection() {
const TooltipWarn = document.createElement('div');
TooltipWarn.style.position = 'absolute';
TooltipWarn.style.display = 'block';
TooltipWarn.style.left = 'auto';
TooltipWarn.style.bottom = 'auto';
TooltipWarn.id = 'CMDispTooltipWarningParent';
const TooltipWarn = document.createElement('div');
TooltipWarn.style.position = 'absolute';
TooltipWarn.style.display = 'block';
TooltipWarn.style.left = 'auto';
TooltipWarn.style.bottom = 'auto';
TooltipWarn.id = 'CMDispTooltipWarningParent';
const create = function (boxId, color, labelTextFront, labelTextBack, deficitId) {
const box = document.createElement('div');
box.id = boxId;
box.style.display = 'none';
box.style.transition = 'opacity 0.1s ease-out';
box.className = ColorBorderPre + color;
box.style.padding = '2px';
box.style.background = '#000 url(img/darkNoise.png)';
const labelDiv = document.createElement('div');
box.appendChild(labelDiv);
const labelSpan = document.createElement('span');
labelSpan.className = ColorTextPre + color;
labelSpan.style.fontWeight = 'bold';
labelSpan.textContent = labelTextFront;
labelDiv.appendChild(labelSpan);
labelDiv.appendChild(document.createTextNode(labelTextBack));
const deficitDiv = document.createElement('div');
box.appendChild(deficitDiv);
const deficitSpan = document.createElement('span');
deficitSpan.id = deficitId;
deficitDiv.appendChild(document.createTextNode('Deficit: '));
deficitDiv.appendChild(deficitSpan);
return box;
};
const create = function (
boxId,
color,
labelTextFront,
labelTextBack,
deficitId,
) {
const box = document.createElement('div');
box.id = boxId;
box.style.display = 'none';
box.style.transition = 'opacity 0.1s ease-out';
box.className = ColorBorderPre + color;
box.style.padding = '2px';
box.style.background = '#000 url(img/darkNoise.png)';
const labelDiv = document.createElement('div');
box.appendChild(labelDiv);
const labelSpan = document.createElement('span');
labelSpan.className = ColorTextPre + color;
labelSpan.style.fontWeight = 'bold';
labelSpan.textContent = labelTextFront;
labelDiv.appendChild(labelSpan);
labelDiv.appendChild(document.createTextNode(labelTextBack));
const deficitDiv = document.createElement('div');
box.appendChild(deficitDiv);
const deficitSpan = document.createElement('span');
deficitSpan.id = deficitId;
deficitDiv.appendChild(document.createTextNode('Deficit: '));
deficitDiv.appendChild(deficitSpan);
return box;
};
TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', ColorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText'));
TooltipWarn.firstChild.style.marginBottom = '4px';
TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', ColorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText'));
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(create('CMDispTooltipWarnConjure', ColorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"', 'CMDispTooltipWarnConjureText'));
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(create('CMDispTooltipWarnConjureFrenzy', ColorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)', 'CMDispTooltipWarnConjureFrenzyText'));
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', ColorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText'));
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(create('CMDispTooltipWarnUser', ColorRed, 'Warning: ', `Purchase of this item will put you under the number of Cookies equal to ${CMOptions.ToolWarnUser} seconds of CPS`, 'CMDispTooltipWarnUserText'));
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnLucky',
ColorRed,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Lucky!"',
'CMDispTooltipWarnLuckyText',
),
);
TooltipWarn.firstChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnLuckyFrenzy',
ColorYellow,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)',
'CMDispTooltipWarnLuckyFrenzyText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnConjure',
ColorPurple,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"',
'CMDispTooltipWarnConjureText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnConjureFrenzy',
ColorPurple,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)',
'CMDispTooltipWarnConjureFrenzyText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnEdifice',
ColorPurple,
'Warning: ',
'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"',
'CMDispTooltipWarnEdificeText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnUser',
ColorRed,
'Warning: ',
`Purchase of this item will put you under the number of Cookies equal to ${CMOptions.ToolWarnUser} seconds of CPS`,
'CMDispTooltipWarnUserText',
),
);
return TooltipWarn;
return TooltipWarn;
}
/**
@@ -93,38 +154,40 @@ export function TooltipCreateWarningSection() {
* @param {object} tooltip Object of a TooltipBox, normally created by a call to CM.Disp.TooltipCreateTooltipBox()
*/
export function TooltipCreateCalculationSection(tooltip) {
tooltip.appendChild(TooltipCreateHeader('Bonus Income'));
const income = document.createElement('div');
income.style.marginBottom = '4px';
income.style.color = 'white';
income.id = 'CMTooltipIncome';
tooltip.appendChild(income);
tooltip.appendChild(TooltipCreateHeader('Bonus Income'));
const income = document.createElement('div');
income.style.marginBottom = '4px';
income.style.color = 'white';
income.id = 'CMTooltipIncome';
tooltip.appendChild(income);
tooltip.appendChild(TooltipCreateHeader('Bonus Cookies per Click'));
tooltip.lastChild.style.display = 'none';
const click = document.createElement('div');
click.style.marginBottom = '4px';
click.style.color = 'white';
click.style.display = 'none';
click.id = 'CMTooltipCookiePerClick';
tooltip.appendChild(click);
tooltip.appendChild(TooltipCreateHeader('Bonus Cookies per Click'));
tooltip.lastChild.style.display = 'none';
const click = document.createElement('div');
click.style.marginBottom = '4px';
click.style.color = 'white';
click.style.display = 'none';
click.id = 'CMTooltipCookiePerClick';
tooltip.appendChild(click);
tooltip.appendChild(TooltipCreateHeader('Payback Period'));
const pp = document.createElement('div');
pp.style.marginBottom = '4px';
pp.id = 'CMTooltipPP';
tooltip.appendChild(pp);
tooltip.appendChild(TooltipCreateHeader('Payback Period'));
const pp = document.createElement('div');
pp.style.marginBottom = '4px';
pp.id = 'CMTooltipPP';
tooltip.appendChild(pp);
tooltip.appendChild(TooltipCreateHeader('Time Left'));
const time = document.createElement('div');
time.id = 'CMTooltipTime';
tooltip.appendChild(time);
tooltip.appendChild(TooltipCreateHeader('Time Left'));
const time = document.createElement('div');
time.id = 'CMTooltipTime';
tooltip.appendChild(time);
if (TooltipType === 'b') {
tooltip.appendChild(TooltipCreateHeader('Production left till next achievement'));
tooltip.lastChild.id = 'CMTooltipProductionHeader'; // Assign a id in order to hid when no achiev's are left
const production = document.createElement('div');
production.id = 'CMTooltipProduction';
tooltip.appendChild(production);
}
if (TooltipType === 'b') {
tooltip.appendChild(
TooltipCreateHeader('Production left till next achievement'),
);
tooltip.lastChild.id = 'CMTooltipProductionHeader'; // Assign a id in order to hid when no achiev's are left
const production = document.createElement('div');
production.id = 'CMTooltipProduction';
tooltip.appendChild(production);
}
}