main.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Imports
  2. import {createVariable} from './modules/variables/variables';
  3. import {createOperation} from './modules/operations/operations';
  4. import {runCode} from "./compiler";
  5. // Imports
  6. // Html references
  7. export const htmlOlCommandsVariables = document.getElementById('htmlOlCommandsVariablesVariables');
  8. export const htmlOlCommandsOperations = document.getElementById('htmlOlCommandsVariablesOperations');
  9. export const terminal = document.getElementById('terminal');
  10. // ***********************************************************************
  11. // Init Accessible UI
  12. // ***********************************************************************
  13. // Accessible UI buttons references
  14. const createVariableButton = document.getElementById('createVariableButton');
  15. const assignVariableButton = document.getElementById('assignVariableButton');
  16. const runCodeButton = document.getElementById('runCodeButton');
  17. export function initAccessibleUI() {
  18. // Initializing dropdown menus
  19. $(".dropdown-submenu a.test").on("click", function (e) {
  20. $(this).next("ul").toggle();
  21. e.stopPropagation();
  22. e.preventDefault();
  23. });
  24. // Adding listeners
  25. createVariableButton.addEventListener('click', ev => {
  26. createVariable();
  27. });
  28. assignVariableButton.addEventListener('click', ev => {
  29. createOperation();
  30. });
  31. runCodeButton.addEventListener('click', ev => {
  32. runCode();
  33. });
  34. }
  35. // ***********************************************************************
  36. // Reference: https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid
  37. export function generateUUID() {
  38. return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
  39. (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
  40. );
  41. }
  42. // ***********************************************************************