ohm.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //"use strict";
  2. /*
  3. The MIT License (MIT)
  4. Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  5. */
  6. // VWF & Ohm view driver
  7. import {Fabric} from '/core/vwf/fabric.js';
  8. class OhmViewDriver extends Fabric {
  9. constructor(module) {
  10. console.log("OhmViewDriver constructor");
  11. super(module, 'View');
  12. }
  13. factory() {
  14. let _self_ = this;
  15. return this.load(this.module,
  16. {
  17. // == Module Definition ====================================================================
  18. initialize: function (options) {
  19. let self = this;
  20. this.fabric = _self_;
  21. this.nodes = {};
  22. },
  23. // initializedNode: function( nodeID, childID ) {
  24. // },
  25. createdProperty: function (nodeId, propertyName, propertyValue) {
  26. return this.satProperty(nodeId, propertyName, propertyValue);
  27. },
  28. initializedProperty: function (nodeId, propertyName, propertyValue) {
  29. return this.satProperty(nodeId, propertyName, propertyValue);
  30. },
  31. satMethod: function (nodeId, methodName) {
  32. let self = this;
  33. var node = this.state.nodes[ nodeId ];
  34. if ( !( node && node.lang) ) {
  35. return;
  36. }
  37. if (methodName.indexOf("Operation") > -1) {
  38. //self.kernel.callMethod (nodeId, methodName);
  39. self.kernel.setProperty(nodeId, 'ohmLang', node.lang.source);
  40. console.log("set new lang properties");
  41. }
  42. },
  43. // createdMethod: function( nodeId, methodName, methodParameters, methodBody) {
  44. // var self = this;
  45. // var node = this.state.nodes[ nodeId ];
  46. // if ( !( node && node.lang) ) {
  47. // return;
  48. // }
  49. // if (methodName.indexOf("Operation") > -1) {
  50. // console.log("add semantic operations");
  51. // self.kernel.callMethod (nodeId, methodName);
  52. // }
  53. // },
  54. satProperty: function (nodeId, propertyName, propertyValue) {
  55. let self = this;
  56. var node = this.state.nodes[ nodeId ];
  57. if ( !( node && node.lang) ) {
  58. return;
  59. }
  60. var lang = node.lang;
  61. switch (propertyName) {
  62. case "ohmLang":
  63. if (propertyValue) {
  64. self.kernel.callMethod (nodeId, 'initLang');
  65. }
  66. break;
  67. }
  68. },
  69. // firedEvent: function (nodeID, eventName, eventParameters) {
  70. // },
  71. // ticked: function (vwfTime) {
  72. // }
  73. });
  74. }
  75. }
  76. export { OhmViewDriver as default }