mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 08:14:25 +08:00
use for-of statements to replace for and for-in
This commit is contained in:
@@ -59,9 +59,7 @@ export function setExpenseAndIncomeAmountColor(expenseAmountColorType: number, i
|
||||
|
||||
const allPresetAmountColors = PresetAmountColor.values();
|
||||
|
||||
for (let i = 0; i < allPresetAmountColors.length; i++) {
|
||||
const amountColor = allPresetAmountColors[i];
|
||||
|
||||
for (const amountColor of allPresetAmountColors) {
|
||||
if (amountColor.type === expenseAmountColor.type) {
|
||||
if (!htmlElement.classList.contains(amountColor.expenseClassName)) {
|
||||
htmlElement.classList.add(amountColor.expenseClassName);
|
||||
@@ -97,8 +95,8 @@ export function openTextFileContent({ allowedExtensions }: { allowedExtensions:
|
||||
fileInput.onchange = (event) => {
|
||||
const el = event.target as HTMLInputElement;
|
||||
|
||||
if (el.files && el.files.length > 0) {
|
||||
const file = el.files[0];
|
||||
if (el.files && el.files.length > 0 && el.files[0]) {
|
||||
const file = el.files[0] as File;
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = (e) => {
|
||||
@@ -146,8 +144,7 @@ export function clearBrowserCaches(): Promise<void> {
|
||||
window.caches.keys().then(cacheNames => {
|
||||
const promises = [];
|
||||
|
||||
for (let i = 0; i < cacheNames.length; i++) {
|
||||
const cacheName = cacheNames[i];
|
||||
for (const cacheName of cacheNames) {
|
||||
promises.push(window.caches.delete(cacheName).then(success => {
|
||||
if (success) {
|
||||
logger.info(`cache "${cacheName}" cleared successfully`);
|
||||
|
||||
@@ -74,9 +74,7 @@ export function setAppFontSize(type: number): void {
|
||||
const htmlElement = f7.$('html');
|
||||
const allFontSizes = FontSize.values();
|
||||
|
||||
for (let i = 0; i < allFontSizes.length; i++) {
|
||||
const fontSizeType = allFontSizes[i];
|
||||
|
||||
for (const fontSizeType of allFontSizes) {
|
||||
if (fontSizeType.type === type) {
|
||||
if (!htmlElement.hasClass(fontSizeType.className)) {
|
||||
htmlElement.addClass(fontSizeType.className);
|
||||
@@ -90,9 +88,7 @@ export function setAppFontSize(type: number): void {
|
||||
export function getFontSizePreviewClassName(type: number): string {
|
||||
const allFontSizes = FontSize.values();
|
||||
|
||||
for (let i = 0; i < allFontSizes.length; i++) {
|
||||
const fontSizeType = allFontSizes[i];
|
||||
|
||||
for (const fontSizeType of allFontSizes) {
|
||||
if (fontSizeType.type === type) {
|
||||
return FONT_SIZE_PREVIEW_CLASSNAME_PREFIX + fontSizeType.className;
|
||||
}
|
||||
@@ -109,8 +105,7 @@ export function getElementActualHeights(selector: string): Record<string, number
|
||||
return heights;
|
||||
}
|
||||
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
const el = elements[i];
|
||||
for (const el of elements) {
|
||||
const rect = el.getBoundingClientRect();
|
||||
heights[el.id] = rect.height;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user