Javascript for python fanboys - mrmarkwell/evergreendb GitHub Wiki
Dollar sign ($) is a valid variable/function name character just like underscore (_) is in python. This is valid:
var ca$h_money = "fat stacks";
It has become a standard to make the dollar sign function a shortcut to document.getElementById(). jQuery changes it to be a shortcut for jQuery() function which does similar things or something like that https://stackoverflow.com/questions/4069982/document-getelementbyid-vs-jquery.
function $(id) { return document.getElementById(id); }
Javascript can't import one script in another so instead:
- On the electron render process ("front end") just source in HTML then the next script sourced will have any functions defined in first script.
- On the main electron process ("back end"), it uses node.js a superset of javascript that adds a require() function. First answer here is helpful: https://stackoverflow.com/questions/5797852/in-node-js-how-do-i-include-functions-from-my-other-files
Notes on node.js. npm is pretty nice. It uses a package.json file to do things. Adding libriries to the package.json makes it as simple as npm install
to install all the dependencies (make sure node_modules is in git ignore). install -g package name installs a package globally for example npm install -g electron
installs electron and adds it to $PATH. You can also install locally then use npm <custom_cmd> to run a configured command that can use locally installed node_modules. For example:
in package.json
"scripts": {"start": "electron ."}
then npm install; npm start
would launch the app without needed electron installed globally