I would like to use AJV in a Firefox addon in order to validate JSON that has been entered by the user. What file(s) of the AJV repository do I have to include in my project folder and how do I import them correctly?
Normally, I'd just use the minified version from https://cdnjs.com/libraries/ajv but Mozilla doesn't allow that.
Thank you!
Related
I am new to dart and I am trying to read data from a file and use the contents to draw something canvas. In doing so I am running into 'The built-in library 'dart:io' is not available on Dartium ' issue.
I understand Dart has limitations as Javascript in that code that is running in a browser cannot natively access the File System of the running client.
At the same time are there any tips on how to read a file and also use the contents to write it to canvas?
Thanks in advance.
What kind of application are you trying to build?
If it runs in the browser the files are usually on the server.
If it is a normal web page you can't access user files. There is a sandboxed space accessible to be used by by the code of a webpage.
If you build something like a Chrome app you have less limitations.
You definitely can't import 'dart:io' when the could should run in the browser.
The APIs available in the browser can be found in 'dart:html'.
If you want to build a Chrome app this package provides access to the extended API http://pub.dartlang.org/packages/chrome
I fixed my problem by prompting the user to choose the file. Similar approach as in
https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications but using DART.
I have an AngularJS project that I am thinking of migrating to Dart. I do not want to migrate the whole project in a big-bang, so I am looking for ways to run the two apps side-by-side.
The dart app will run on the root as index.html. The js app will run on a separate path, say '/jsApp'.
When I build a test project, it seems that the /build directory includes a lot of unnecessary files. Would I need to deploy the complete contents of the /build/web directory?
What is it that actually gets loaded? Do html files still get loaded at runtime or are they bundled into the main file?
Do I need main.dart.js as well as main.dart.precompiled.js? It seems that they are very large files for a trivial app. Is that to be expected?
It is still unclear to me how all these things hang together.
If you want to keep the generated files as small as possible, you should:
Make sure your pubspec.yaml includes the angular transformer, as explained here: Angulardart. Creating your first app
Your pubspec.yaml should look like this:
name: angular_dart_demo
version: 0.0.1
dependencies:
angular: 0.12.0
[...]
transformers:
- angular
html_files:
- web/my_html_template.html
- web/another_html_template.html
Build from the command line with pub build
This way you will get 800KB js, instead of 5MB js ;)
That's because Angular Dart uses mirrors and, as a result, the generated js code can get very big if you don't use the angular transformer.
I think html templates are copied to the build directory and will be requested at runtime.
You will have to merge the contents you get from "pub build" with your existing js application somehow.
I am using AngularJS with Dart controllers mixed in. You do not have to adapt your current project structure to use the pub build. Just use dart2js to compile the individual dart files and include the ".js" files in your page. You do not have to add the native dart script tag or include the dart bootstrap in your code. Just include a script tag for the generated js file (the only file you need) and it will do what you expect. I plan to write up a brief overview of this soon.
Normally the entire build directory needs to be deployed and there are normally no unnecessary files.
The *.precompiled.js files are not generated anymore in recent Dart builds (this was for CSP compliance).
What Dart version are you using?
If you build in debug mode also the source map files are generated in the build directory.
The browser loads the HTML file the user requests and then loads the script files references in <script> tags in this HTML and all other resources (img, css, ...)
I don't know if the build output of an Angular component with an external HTML-template file is inlined in the index.html or if they are copied as they are.
there is some code for changing back to the old look of export buttons even if you're running version 3.0.
It's here:
https://github.com/highslide-software/highcharts.com/blob/master/js/modules/exporting-old-look.src.js
My only question is, how do I include this code into my graph?
You can just copy that javascript into your own project between and tags,
or
you can include it from github in a script tag:
or
You can download it to your own project area and include it in a script tag from your own web server.
The script will load and run when the page loads, so make sure to include it after highcharts.
I have a Firefox addon available for my website. I add the download link of the addon to a simple , but when an user click it, it prompts him to download the .XPI file of the addon - Is there any way so I can pop-up the normal EXTENSION INSTALL window for my addon? Is there any special thing to do that or this is available only in addons.mozilla.org?
You can use the InstallTrigger object. Also, you should be using application/x-xpinstall MIME type for your extension file, this will trigger installation even if InstallTrigger isn't used (e.g. JavaScript disabled).
I am developing a Firefox extension. I would like to install new search plugin to the firefox search bar. I tried 2 ways, but none of them seems to work 100%.
AddSearchEngineProvider works,
but it displays "fail to install
message" if the the search engine
with the same name already exist. I
dont see any API that enables me to
query existing search engines.
In Mozilla Firefox\searchplugins
I see xml files that represent the
actual search plugins. I was able to
add my search engine manually, but I
dont really know how to add the xml
file during the installation. I have
XPI file, which has very limited
abilities to access IO.
Any suggestions? Thanks.
Search engines should be put into the searchplugins/ directory of your extension. They will be added automatically when your extension is installed - and removed again when it is uninstalled. See https://developer.mozilla.org/en/Bundles.