forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.ts
More file actions
52 lines (45 loc) · 1.27 KB
/
util.ts
File metadata and controls
52 lines (45 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {getIntParameter} from '../util';
export class TableCell {
constructor(
public row: number,
public col: number,
public value: string,
) {}
}
let tableCreateCount: number;
let maxRow: number;
let maxCol: number;
let numberData: TableCell[][];
let charData: TableCell[][];
export function initTableUtils() {
maxRow = getIntParameter('rows');
maxCol = getIntParameter('cols');
tableCreateCount = 0;
numberData = [];
charData = [];
for (let r = 0; r <= maxRow; r++) {
const numberRow: TableCell[] = [];
numberData.push(numberRow);
const charRow: TableCell[] = [];
charData.push(charRow);
for (let c = 0; c <= maxCol; c++) {
numberRow.push(new TableCell(r, c, `${c}/${r}`));
charRow.push(new TableCell(r, c, `${charValue(c)}/${charValue(r)}`));
}
}
}
function charValue(i: number): string {
return String.fromCharCode('A'.charCodeAt(0) + (i % 26));
}
export const emptyTable: TableCell[][] = [];
export function buildTable(): TableCell[][] {
tableCreateCount++;
return tableCreateCount % 2 ? numberData : charData;
}