fork download
  1. DomController.prototype._setEvents = function() {
  2. var that = this;
  3. this._domView.addLeftMouseDownToFieldListener(function() {
  4. that._domView.setFaceType("danger-face")
  5. });
  6. this._domView.addLeftMouseUpToFieldListener(function(x, y) {
  7. that.open(x, y);
  8. that._domView.setFaceType("cool-face");
  9. });
  10. this._domView.addRightMouseDownToFieldListener(this.toggleFlag.bind(this));
  11. this._domView.addClickToFaceListener(this.reset.bind(this));
  12. this._domView.preventContextMenuOnField();
  13. };
  14.  
  15. DomView.prototype.setFaceType = function(type) {
  16. if (!this._face) {
  17. throw new DomViewException("Нет ссылки на элемент.");
  18. } else if (this._getFaceType()) {
  19. this.removeFaceType();
  20. }
  21. this._face.classList.add(type);
  22. };
  23.  
  24. DomView.prototype.addLeftMouseUpToFieldListener = function(func) {
  25. this._field.addEventListener("mouseup", function(event) {
  26. var target = event.target;
  27. if (event.which == 1) {
  28. func(+target.dataset.x, +target.dataset.y);
  29. }
  30. });
  31. };
  32.  
  33. //Поменять смайлик как в классическом сапере
  34. DomView.prototype.addLeftMouseDownToFieldListener = function(func) {
  35. this._field.addEventListener("mousedown", function(event) {
  36. var target = event.target;
  37. if (event.which == 1) {
  38. func(+target.dataset.x, +target.dataset.y);
  39. }
  40. });
  41. };
  42.  
  43. //Установка флажков
  44. DomView.prototype.addRightMouseDownToFieldListener = function(func) {
  45. this._field.addEventListener("mousedown", function(event) {
  46. var target = event.target;
  47. if (event.which == 3) {
  48. func(+target.dataset.x, +target.dataset.y);
  49. }
  50. });
  51. };
  52.  
  53. DomView.prototype.addClickToFaceListener = function(func) {
  54. this._face.addEventListener("click", function(event) {
  55. func();
  56. });
  57. };
Runtime error #stdin #stdout #stderr 0.02s 589312KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
/home/WkjUKn/prog.js:1
(function (exports, require, module, __filename, __dirname) { DomController.prototype._setEvents = function() {
                                                              ^

ReferenceError: DomController is not defined
    at Object.<anonymous> (/home/WkjUKn/prog.js:1:63)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3