Skip to content

Commit

Permalink
Fake a command line in the web version
Browse files Browse the repository at this point in the history
Fixes: #100
  • Loading branch information
neuschaefer committed Mar 23, 2024
1 parent 5055e91 commit 867d968
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,62 @@ $('#insert-button').click(addFont);

addFontFileChangeHandlers();

function generate_range(start, end, transpose) {
if (start != transpose) {

Check failure on line 60 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Expected '!==' and instead saw '!='
return start + '-' + end + '=>' + transpose;
} else if (start != end) {

Check failure on line 62 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Expected '!==' and instead saw '!='
return start + '-' + end;
} else {

Check failure on line 64 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Unnecessary 'else' after 'return'
return start;
}
}

function generate_opts_string(args) {
var opts = [];

opts.push("--bpp", args.bpp);

Check failure on line 72 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
opts.push("--size", args.size);

Check failure on line 73 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
if (args.no_compress) {
opts.push("--no-compress");

Check failure on line 75 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
}
if (args.lcd) {
opts.push("--lcd");

Check failure on line 78 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
}
if (args.lcd_v) {
opts.push("--lcd-v");

Check failure on line 81 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
}
if (args.use_color_info) {
opts.push("--use-color-info");

Check failure on line 84 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
}

for (var i = 0; i < args.font.length; i++) {
opts.push("--font", args.font[i].source_path);

Check failure on line 88 in web/index.js

View workflow job for this annotation

GitHub Actions / test (14)

Strings must use singlequote
const r = args.font[i].ranges;

var symbols = '';
var ranges = [];
for (var j = 0; j < r.length; j++) {
if (r[i].symbols) {
symbols += r[i].symbols;
}
for (var k = 0; k < r[i].range.length; k += 3) {
ranges.push(generate_range(r[i].range[k+0], r[i].range[k+1], r[i].range[k+2]));
}
}
if (symbols) {
opts.push('--symbols', symbols);
}
if (ranges) {
opts.push('--range', ranges.join(','));
}
}

opts.push("--format", args.format);
opts.push("-o", args.output + ".c");

return opts.join(' ');
}

document.querySelector('#converterForm').addEventListener('submit', function handleSubmit(e) {
e.preventDefault();

Expand Down Expand Up @@ -115,7 +171,7 @@ document.querySelector('#converterForm').addEventListener('submit', function han
lv_fallback: _fallback
};

args.opts_string = "";
args.opts_string = generate_opts_string(args);

convert(args).then(result => {
const blob = new Blob([ result[_name] ], { type: 'text/plain;charset=utf-8' });
Expand Down

0 comments on commit 867d968

Please sign in to comment.