Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Detect local file access problems #78

Open
set-soft opened this issue Jan 31, 2024 · 0 comments
Open

[Feature] Detect local file access problems #78

set-soft opened this issue Jan 31, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation embedding Issues with using KiCanvas in other pages feature request New feature or request

Comments

@set-soft
Copy link

Is your feature request related to a problem? Please describe.
When using KiCanvas as an embedding and loading the HTML from a local file system the user will most probably get an empty screen, wondering what was wrong.

Describe the solution you'd like
It would be nice if KiCanvas could just inform the problem.

I'm not a Java Script guru, but here is a probe of concept showing how to inform the problem:

function ready()
{
 try
   {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open('GET', '1.kicad_sch', false);
    xmlhttp.send();
   }
 catch (error)
   {
    if (window.location.protocol === 'file:')
      {
       document.getElementById('no_file_access').style.display = 'block';
      }
    throw(error);
   }
}

window.addEventListener('DOMContentLoaded', ready);

Here '1.kicad_sch' is just one of the sources. Then in the HTML I have:

     <div id="no_file_access" style="display: none; ">
       <span>The browser can't read local files. Enable it to continue. I.e. use <i>--allow-file-access-from-files</i> on Chrome</span>
     </div>

Here is a working example: example.zip

I think a similar mechanism should be inside kicanvas.js, perhaps with an option to disable it, just in case the user wants to make it in a different way.

@set-soft set-soft added the feature request New feature or request label Jan 31, 2024
@theacodes theacodes added documentation Improvements or additions to documentation embedding Issues with using KiCanvas in other pages labels Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation embedding Issues with using KiCanvas in other pages feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants