gbu-accessibility-package 3.8.0 ā 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README-vi.md +16 -10
- package/README.md +3 -0
- package/bin/fix.js +140 -0
- package/bin/test.js +71 -0
- package/cli.js +23 -1
- package/lib/fixer.js +504 -104
- package/package.json +4 -5
- package/ENHANCED_ALT_FEATURES.md +0 -230
- package/PACKAGE_SUMMARY.md +0 -191
- package/demo/1mb-jpg-example-file.jpg +0 -0
- package/demo/advanced-test.html +0 -44
- package/demo/aria-label-test.html +0 -32
- package/demo/broken-links-test.html +0 -41
- package/demo/comprehensive-test.html +0 -21
- package/demo/dead-code-test.css +0 -68
- package/demo/dead-code-test.html +0 -36
- package/demo/dead-code-test.js +0 -77
- package/demo/demo.js +0 -73
- package/demo/duplicate-roles.html +0 -45
- package/demo/enhanced-alt-test.html +0 -150
- package/demo/form-labels-test.html +0 -87
- package/demo/heading-structure-test.html +0 -60
- package/demo/heading-structure-test.html.backup +0 -60
- package/demo/large-file-demo.css +0 -213
- package/demo/nested-controls-test.html +0 -92
- package/demo/sample.html +0 -47
- package/demo/test-external-links.html +0 -26
- package/demo/unused-files-test.html +0 -31
- package/demo/unused-image.png +0 -1
- package/demo/unused-page.html +0 -11
- package/demo/unused-script.js +0 -12
- package/demo/unused-style.css +0 -10
- package/demo/very-large-file.js +0 -2
- package/example.js +0 -121
package/example.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example usage of Accessibility Fixer
|
|
3
|
-
* Demonstrates different ways to use the tool
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const AccessibilityFixer = require('./lib/fixer.js');
|
|
7
|
-
const chalk = require('chalk');
|
|
8
|
-
|
|
9
|
-
async function example1_BasicUsage() {
|
|
10
|
-
console.log(chalk.blue('\nš Example 1: Basic Usage'));
|
|
11
|
-
|
|
12
|
-
const fixer = new AccessibilityFixer({
|
|
13
|
-
language: 'ja',
|
|
14
|
-
backupFiles: true,
|
|
15
|
-
dryRun: true // Preview mode
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Fix all accessibility issues
|
|
19
|
-
await fixer.fixHtmlLang('./demo');
|
|
20
|
-
await fixer.fixEmptyAltAttributes('./demo');
|
|
21
|
-
await fixer.fixRoleAttributes('./demo');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function example2_EnglishProject() {
|
|
25
|
-
console.log(chalk.blue('\nš Example 2: English Project'));
|
|
26
|
-
|
|
27
|
-
const fixer = new AccessibilityFixer({
|
|
28
|
-
language: 'en',
|
|
29
|
-
backupFiles: false,
|
|
30
|
-
dryRun: false
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const results = await fixer.fixRoleAttributes('./demo');
|
|
34
|
-
console.log(`Fixed ${results.filter(r => r.status === 'fixed').length} files`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function example3_StepByStep() {
|
|
38
|
-
console.log(chalk.blue('\nš Example 3: Step by Step'));
|
|
39
|
-
|
|
40
|
-
const fixer = new AccessibilityFixer({
|
|
41
|
-
language: 'vi',
|
|
42
|
-
backupFiles: true,
|
|
43
|
-
dryRun: false
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Step 1: Fix lang attributes first
|
|
47
|
-
console.log('Step 1: Lang attributes...');
|
|
48
|
-
await fixer.fixHtmlLang('./demo');
|
|
49
|
-
|
|
50
|
-
// Step 2: Fix alt attributes
|
|
51
|
-
console.log('Step 2: Alt attributes...');
|
|
52
|
-
await fixer.fixEmptyAltAttributes('./demo');
|
|
53
|
-
|
|
54
|
-
// Step 3: Fix role attributes
|
|
55
|
-
console.log('Step 3: Role attributes...');
|
|
56
|
-
await fixer.fixRoleAttributes('./demo');
|
|
57
|
-
|
|
58
|
-
console.log('ā
All done!');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function example4_CustomConfig() {
|
|
62
|
-
console.log(chalk.blue('\nš Example 4: Custom Configuration'));
|
|
63
|
-
|
|
64
|
-
// Custom configuration for specific needs
|
|
65
|
-
const fixer = new AccessibilityFixer({
|
|
66
|
-
language: 'zh',
|
|
67
|
-
backupFiles: true,
|
|
68
|
-
dryRun: true
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Only fix specific issues
|
|
72
|
-
const altResults = await fixer.fixEmptyAltAttributes('./demo');
|
|
73
|
-
|
|
74
|
-
// Analyze results
|
|
75
|
-
const fixedFiles = altResults.filter(r => r.status === 'fixed');
|
|
76
|
-
const totalIssues = altResults.reduce((sum, r) => sum + (r.issues || 0), 0);
|
|
77
|
-
|
|
78
|
-
console.log(`Found ${totalIssues} alt attribute issues in ${fixedFiles.length} files`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function example5_ErrorHandling() {
|
|
82
|
-
console.log(chalk.blue('\nš Example 5: Error Handling'));
|
|
83
|
-
|
|
84
|
-
const fixer = new AccessibilityFixer({
|
|
85
|
-
language: 'ja',
|
|
86
|
-
backupFiles: true,
|
|
87
|
-
dryRun: false
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
const results = await fixer.fixRoleAttributes('./nonexistent-directory');
|
|
92
|
-
console.log('Results:', results);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.error(chalk.red('Error occurred:'), error.message);
|
|
95
|
-
// Handle error appropriately
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Run examples
|
|
100
|
-
async function runExamples() {
|
|
101
|
-
console.log(chalk.green('š Accessibility Fixer Examples\n'));
|
|
102
|
-
|
|
103
|
-
await example1_BasicUsage();
|
|
104
|
-
await example2_EnglishProject();
|
|
105
|
-
await example3_StepByStep();
|
|
106
|
-
await example4_CustomConfig();
|
|
107
|
-
await example5_ErrorHandling();
|
|
108
|
-
|
|
109
|
-
console.log(chalk.green('\nā
All examples completed!'));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Uncomment to run examples
|
|
113
|
-
// runExamples();
|
|
114
|
-
|
|
115
|
-
module.exports = {
|
|
116
|
-
example1_BasicUsage,
|
|
117
|
-
example2_EnglishProject,
|
|
118
|
-
example3_StepByStep,
|
|
119
|
-
example4_CustomConfig,
|
|
120
|
-
example5_ErrorHandling
|
|
121
|
-
};
|