action-manager.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { xor } from "lodash";
  2. import { browser } from "../../../application/browser";
  3. export class ActionManager {
  4. constructor() {
  5. this.actions = [];
  6. }
  7. push(action) {
  8. this.actions.push(action);
  9. }
  10. remove(genericObject) {
  11. const action = this.actions.find(action => action.genericObject == genericObject);
  12. const index = this.actions.indexOf(action);
  13. this.actions.splice(index, 1);
  14. }
  15. pop() {
  16. throw "Not implemented";
  17. }
  18. clear() {
  19. this.actions = [];
  20. }
  21. load(actions) {
  22. this.actions = actions;
  23. }
  24. save() {
  25. const LINES = [
  26. `# igeom: http://www.matematica.br!
  27. [ .: iGeom : Geometria Interativa na Internet :. ]!
  28. [ versao: 1.0.0 ]!
  29. [ PC = ${browser.appName}; DD = 0 ]!
  30. [[${new Date()}; ${browser.osName}]]!
  31. [0:1.1, 1:3, - iGeom versao 1.0.0]!\n`
  32. ];
  33. this.actions.forEach(action => {
  34. action.rehydrate();
  35. LINES.push(action.toString());
  36. });
  37. let file = new Blob([...LINES], {
  38. type: "text/plain;charset=utf-8"
  39. });
  40. return file;
  41. }
  42. }