Skip to content

Commit

Permalink
eslint.
Browse files Browse the repository at this point in the history
  • Loading branch information
lapo-luchini committed Apr 29, 2024
1 parent 9679f24 commit f20564c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 60 deletions.
58 changes: 29 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,37 +126,37 @@ export function decodeBinaryString(str) {
}
// set up buttons
const butClickHandlers = {
butDecode: () => {
decodeText(area.value);
},
butClear: () => {
area.value = '';
file.value = '';
tree.innerHTML = '';
dump.innerHTML = '';
selectDefs.innerHTML = '';
hash = window.location.hash = '';
},
butExample: () => {
console.log('Loading example:', examples.value);
let request = new XMLHttpRequest();
request.open('GET', 'examples/' + examples.value, true);
request.onreadystatechange = function () {
if (this.readyState !== 4) return;
if (this.status >= 200 && this.status < 400) {
area.value = this.responseText;
decodeText(this.responseText);
} else {
console.log('Error loading example.');
}
};
request.send();
},
butDecode: () => {
decodeText(area.value);
},
butClear: () => {
area.value = '';
file.value = '';
tree.innerHTML = '';
dump.innerHTML = '';
selectDefs.innerHTML = '';
hash = window.location.hash = '';
},
butExample: () => {
console.log('Loading example:', examples.value);
let request = new XMLHttpRequest();
request.open('GET', 'examples/' + examples.value, true);
request.onreadystatechange = function () {
if (this.readyState !== 4) return;
if (this.status >= 200 && this.status < 400) {
area.value = this.responseText;
decodeText(this.responseText);
} else {
console.log('Error loading example.');
}
};
request.send();
},
};
for (const [name, onClick] of Object.entries(butClickHandlers)) {
let elem = id(name);
if (elem)
elem.onclick = onClick;
let elem = id(name);
if (elem)
elem.onclick = onClick;
}
// set dark theme depending on OS settings
function setTheme() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"homepage": "https://lapo.it/asn1js/",
"files": [ "asn1.js", "base64.js", "hex.js", "int10.js", "oids.js" ],
"scripts": {
"lint": "npx eslint asn1.js base64.js hex.js int10.js oids.js tags.js context.js index.js parseRFC.js dumpASN1.js test.js testDefs.js",
"lint": "npx eslint asn1.js base64.js hex.js int10.js oids.js tags.js context.js index.js parseRFC.js dumpASN1.js test.js testDefs.js vite.config.js",
"lint-action": "npx @action-validator/cli .github/workflows/node.js.yml",
"build": "vite build",
"serve": "echo 'Connect to http://localhost:3000/' ; npx statik --port 3000 .",
Expand Down
62 changes: 32 additions & 30 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,42 @@ import pluginDom from 'vite-plugin-dom';
import { DomUtils } from 'htmlparser2';

const preventSVGEmit = () => {
return {
generateBundle(opts, bundle) {
for (const key in bundle)
if (key.endsWith('.svg'))
delete bundle[key];
},
}
}
return {
generateBundle(opts, bundle) {
for (const key in bundle)
if (key.endsWith('.svg'))
delete bundle[key];
},
};
};

const removeNodes = [ 'theme-select', 'rowExamples' ];

export default defineConfig({
plugins: [
preventSVGEmit(),
pluginDom({
applyOnMode: true, // all modes
handler: node => {
if (removeNodes.includes(node.attribs.id))
DomUtils.removeElement(node);
},
}),
viteSingleFile(),
],
build: {
minify: false,
cssMinify: false,
rollupOptions: {
output: {
assetFileNames: function (file) {
return file.name == 'favicon.svg'
? file.name
: `assets/[name]-[hash].[ext]`;
plugins: [
preventSVGEmit(),
pluginDom({
applyOnMode: true, // all modes
handler: node => {
if (removeNodes.includes(node.attribs.id))
DomUtils.removeElement(node);
},
}),
viteSingleFile(),
],
build: {
minify: false,
cssMinify: false,
rollupOptions: {
output: {
assetFileNames: function (file) {
return file.name == 'favicon.svg'
? file.name
: 'assets/[name]-[hash].[ext]';
},
},
},
}
assetsInlineLimit: 1000000,
//assetsInlineLimit: path => { throw new Error('XXX'); console.log(path); return true; },
},
},
});

0 comments on commit f20564c

Please sign in to comment.