diff --git a/TODO.md b/TODO.md index e5071a1..79b5052 100644 --- a/TODO.md +++ b/TODO.md @@ -1,14 +1,10 @@ # List of my TODO items ## NOW -- implement steering direction for distance as well +n/a ## NEXT -- handle multi port Motor blocks -- horizonal block - handle all motor(s) attached to the Hub -- convert RegistryManager for setup_devices_registry -- consider not grouping stacks by type, but use the Y-X ordering, what about messages? +n/a ## LATER -- more jest tests to be added -- radiobroadcast_whenIReceiveRadioSignalHat, collect, unify all handlers and remember last value, add channel to hub setup... +n/a diff --git a/src/github_version.ts b/src/github_version.ts index 39e8ce3..c342108 100644 --- a/src/github_version.ts +++ b/src/github_version.ts @@ -1,2 +1,2 @@ -const GITHUB_VERSION = 'aa'; +const GITHUB_VERSION = ''; export { GITHUB_VERSION }; diff --git a/src/index.ts b/src/index.ts index 79600a8..b3ca9f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,35 +11,57 @@ function handleFileUpload(file: File) { debug: {}, } as PyConverterOptions; - console.log($('#additionalCommentsCheck')); if (options.debug && $('#additionalCommentsCheck').is(':checked')) { options.debug.showExplainingComments = true; } try { const retval = await convertProjectToPython(input, options); + $('#preview-svg').toggleClass('d-none', !retval?.svg); $('#preview-svg').html(retval?.svg ?? ''); - $('#preview-svg-map') - .html(retval?.svg ?? '') - .removeClass('d-none'); + $('#preview-svg-map').html(retval?.svg ?? ''); $('#preview-pycode').html(retval?.pycode ?? ''); $('#preview-pseudocode').html(retval?.plaincode ?? ''); - const slotid = retval.projectInfo?.slotIndex; - const sloturl = `img/cat${slotid}.svg#dsmIcon`; - $('#svg-program-use').attr('href', sloturl).attr('xlink:href', sloturl); + const devtype = `img/devtype${retval.deviceType}.png`; + $('#devtype').removeClass('d-none').attr('src', devtype); + + const isSB3 = retval.deviceType && [1, 2].includes(retval.deviceType); + $('#sb3slot').toggleClass('d-none', !isSB3); + $('#svg-tab').toggleClass('d-none', !isSB3); + + if (isSB3) { + const slotid = retval.projectInfo?.slotIndex; + const sloturl = `img/cat${slotid}.svg#dsmIcon`; + $('#svg-program-use').attr('href', sloturl).attr('xlink:href', sloturl); + } } catch (error) { + console.error('Error converting project to python', error); + $('#devtype').addClass('d-none'); $('#preview-pycode').html(error as string); + $('#svg-tab').addClass('d-none'); + $('#pseudocode-tab').addClass('d-none'); + $('#preview-svg').addClass('d-none'); + $('#preview-svg-map').addClass('d-none'); + $('#sb3slot').addClass('d-none'); + $('#preview-svg-map').html(''); + + $('#toast1 .toast-title').html('Conversion Error'); + $('#toast1 .toast-body').html(error as string); + $('#toast1').addClass('show'); } $('#tab-dummy').addClass('d-none'); $('#tabs-main').removeClass('d-none'); - updateMapVisibility(); + + updateSmallMapVisibility(); }); } -function updateMapVisibility() { - const visible = $("a[data-bs-toggle='tab'].active").attr('id') !== 'svg-tab'; +function updateSmallMapVisibility() { + const visible = + $("a[data-bs-toggle='tab'].active").attr('id') !== 'svg-tab' && + $('#preview-svg-map').html().length > 0; $('#preview-svg-map').toggleClass('d-none', !visible); } @@ -52,7 +74,7 @@ $('.example-content-button').on('click', (event: JQuery.ClickEvent) => { fetch(path) .then(async (data) => { const data2 = await data.blob(); - const file = new File([data2], 'sample.llsp3'); + const file = new File([data2], path.split('/').pop()); const dataTransfer = new DataTransfer(); dataTransfer.items.add(file); @@ -134,7 +156,7 @@ $('.copy-button').on('click', function (event) { }); $("a[data-bs-toggle='tab']").on('shown.bs.tab', (_) => { - updateMapVisibility(); + updateSmallMapVisibility(); }); $('#preview-svg-map').on('click', (_) => { diff --git a/static/css/site.css b/static/css/site.css index 1df39ba..c689dbc 100644 --- a/static/css/site.css +++ b/static/css/site.css @@ -6,7 +6,7 @@ body::after { content: ''; display: block; - height: 50px; + height: 4em; /* Set same as footer's height */ } @@ -18,6 +18,11 @@ footer { padding-top: 1em; width: 100%; height: 60px; + background-color: whitesmoke; +} + +header { + background-color: whitesmoke; } /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification @@ -212,3 +217,7 @@ a { #divOptions > small:last-child { flex: 0 1; } + +.example-content-button { + margin-left: 0.4em; +} diff --git a/static/img/devtype1.png b/static/img/devtype1.png new file mode 100644 index 0000000..b224994 Binary files /dev/null and b/static/img/devtype1.png differ diff --git a/static/img/devtype2.png b/static/img/devtype2.png new file mode 100644 index 0000000..f27545f Binary files /dev/null and b/static/img/devtype2.png differ diff --git a/static/img/devtype3.png b/static/img/devtype3.png new file mode 100644 index 0000000..f393a49 Binary files /dev/null and b/static/img/devtype3.png differ diff --git a/static/index.html b/static/index.html index a238929..8d23273 100644 --- a/static/index.html +++ b/static/index.html @@ -67,6 +67,15 @@ +