traced
This commit is contained in:
parent
d3a252e547
commit
5cbf5843b1
|
@ -78,7 +78,6 @@
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,7 +286,9 @@
|
||||||
name,
|
name,
|
||||||
that.cursor.node.id),
|
that.cursor.node.id),
|
||||||
worldF);
|
worldF);
|
||||||
return eventHandlers.concat([handler]);
|
|
||||||
|
var newHandlers = eventHandlers.concat([handler]);
|
||||||
|
return newHandlers;
|
||||||
},
|
},
|
||||||
function(view) {
|
function(view) {
|
||||||
// HACK: every node that is bound needs to have an id. We
|
// HACK: every node that is bound needs to have an id. We
|
||||||
|
@ -441,7 +442,7 @@
|
||||||
this.focus = this.top;
|
this.focus = this.top;
|
||||||
return new MockView(domToCursor($(this.top).get(0)),
|
return new MockView(domToCursor($(this.top).get(0)),
|
||||||
[],
|
[],
|
||||||
[],
|
this.eventHandlers.slice(0),
|
||||||
nonce);
|
nonce);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -486,7 +487,7 @@
|
||||||
return onSuccess(new View(dom, []));
|
return onSuccess(new View(dom, []));
|
||||||
} else if (isMockView(x)) {
|
} else if (isMockView(x)) {
|
||||||
return onSuccess(new View($(x.cursor.top().node),
|
return onSuccess(new View($(x.cursor.top().node),
|
||||||
x.eventHandlers));
|
x.eventHandlers.slice(0)));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
dom = $(plt.baselib.format.toDomNode(x));
|
dom = $(plt.baselib.format.toDomNode(x));
|
||||||
|
@ -698,15 +699,15 @@
|
||||||
EventSource.prototype.onStop = function() {
|
EventSource.prototype.onStop = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// The default behavior of pause is to cause the event source to stop.
|
// // The default behavior of pause is to cause the event source to stop.
|
||||||
EventSource.prototype.onPause = function() {
|
// EventSource.prototype.onPause = function() {
|
||||||
this.onStop();
|
// this.onStop();
|
||||||
};
|
// };
|
||||||
|
|
||||||
// The default behavior of unpause is to start an event source up again.
|
// // The default behavior of unpause is to start an event source up again.
|
||||||
EventSource.prototype.onUnpause = function(fireEvent) {
|
// EventSource.prototype.onUnpause = function(fireEvent) {
|
||||||
this.onStart(fireEvent);
|
// this.onStart(fireEvent);
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -723,12 +724,14 @@
|
||||||
TickEventSource.prototype = plt.baselib.heir(EventSource.prototype);
|
TickEventSource.prototype = plt.baselib.heir(EventSource.prototype);
|
||||||
|
|
||||||
TickEventSource.prototype.onStart = function(fireEvent) {
|
TickEventSource.prototype.onStart = function(fireEvent) {
|
||||||
this.id = setInterval(
|
if (this.id === undefined) {
|
||||||
function(evt) {
|
this.id = setInterval(
|
||||||
fireEvent(undefined,
|
function(evt) {
|
||||||
objectToEvent(evt));
|
fireEvent(undefined,
|
||||||
},
|
objectToEvent(evt));
|
||||||
this.delay);
|
},
|
||||||
|
this.delay);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TickEventSource.prototype.onStop = function() {
|
TickEventSource.prototype.onStop = function() {
|
||||||
|
@ -748,33 +751,35 @@
|
||||||
};
|
};
|
||||||
MockLocationEventSource.prototype = plt.baselib.heir(EventSource.prototype);
|
MockLocationEventSource.prototype = plt.baselib.heir(EventSource.prototype);
|
||||||
MockLocationEventSource.prototype.onStart = function(fireEvent) {
|
MockLocationEventSource.prototype.onStart = function(fireEvent) {
|
||||||
var mockLocationSetter = document.createElement("div");
|
if (this.elt === undefined) {
|
||||||
|
var mockLocationSetter = document.createElement("div");
|
||||||
|
|
||||||
var latInput = document.createElement("input");
|
var latInput = document.createElement("input");
|
||||||
latInput.type = "text";
|
latInput.type = "text";
|
||||||
|
|
||||||
var latOutput = document.createElement("input");
|
var latOutput = document.createElement("input");
|
||||||
latOutput.type = "text";
|
latOutput.type = "text";
|
||||||
|
|
||||||
var submitButton = document.createElement("input");
|
var submitButton = document.createElement("input");
|
||||||
submitButton.type = "button";
|
submitButton.type = "button";
|
||||||
submitButton.value = "send lat/lng";
|
submitButton.value = "send lat/lng";
|
||||||
submitButton.onclick = function() {
|
submitButton.onclick = function() {
|
||||||
fireEvent(undefined,
|
fireEvent(undefined,
|
||||||
objectToEvent({ latitude: Number(latInput.value),
|
objectToEvent({ latitude: Number(latInput.value),
|
||||||
longitude: Number(latOutput.value)}));
|
longitude: Number(latOutput.value)}));
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mockLocationSetter.style.border = "1pt solid black";
|
mockLocationSetter.style.border = "1pt solid black";
|
||||||
mockLocationSetter.appendChild(
|
mockLocationSetter.appendChild(
|
||||||
document.createTextNode("mock location setter"));
|
document.createTextNode("mock location setter"));
|
||||||
mockLocationSetter.appendChild(latInput);
|
mockLocationSetter.appendChild(latInput);
|
||||||
mockLocationSetter.appendChild(latOutput);
|
mockLocationSetter.appendChild(latOutput);
|
||||||
mockLocationSetter.appendChild(submitButton);
|
mockLocationSetter.appendChild(submitButton);
|
||||||
document.body.appendChild(mockLocationSetter);
|
document.body.appendChild(mockLocationSetter);
|
||||||
|
|
||||||
this.elt = mockLocationSetter;
|
this.elt = mockLocationSetter;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MockLocationEventSource.prototype.onStop = function() {
|
MockLocationEventSource.prototype.onStop = function() {
|
||||||
|
@ -796,21 +801,23 @@
|
||||||
LocationEventSource.prototype = plt.baselib.heir(EventSource.prototype);
|
LocationEventSource.prototype = plt.baselib.heir(EventSource.prototype);
|
||||||
|
|
||||||
LocationEventSource.prototype.onStart = function(fireEvent) {
|
LocationEventSource.prototype.onStart = function(fireEvent) {
|
||||||
var success = function(position) {
|
if (this.id === undefined) {
|
||||||
if (position.hasOwnProperty('coords') &&
|
var success = function(position) {
|
||||||
position.coords.hasOwnProperty('latitude') &&
|
if (position.hasOwnProperty('coords') &&
|
||||||
position.coords.hasOwnProperty('longitude')) {
|
position.coords.hasOwnProperty('latitude') &&
|
||||||
fireEvent(undefined,
|
position.coords.hasOwnProperty('longitude')) {
|
||||||
objectToEvent({ 'latitude' : Number(position.coords.latitude),
|
fireEvent(undefined,
|
||||||
'longitude' : Number(position.coords.longitude) }));
|
objectToEvent({ 'latitude' : Number(position.coords.latitude),
|
||||||
|
'longitude' : Number(position.coords.longitude) }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var fail = function(err) {
|
||||||
|
// Quiet failure
|
||||||
|
};
|
||||||
|
if (!!(navigator.geolocation)) {
|
||||||
|
navigator.geolocation.getCurrentPosition(success, fail);
|
||||||
|
this.id = navigator.geolocation.watchPosition(success, fail);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
var fail = function(err) {
|
|
||||||
// Quiet failure
|
|
||||||
};
|
|
||||||
if (!!(navigator.geolocation)) {
|
|
||||||
navigator.geolocation.getCurrentPosition(success, fail);
|
|
||||||
this.id = navigator.geolocation.watchPosition(success, fail);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -848,16 +855,21 @@
|
||||||
element = document.getElementById(this.elementOrId);
|
element = document.getElementById(this.elementOrId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! element) { return; }
|
||||||
|
if (this.handler !== undefined) {
|
||||||
|
$(element).unbind(this.type, this.handler);
|
||||||
|
this.handler = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
this.handler = function(evt) {
|
this.handler = function(evt) {
|
||||||
if (element !== undefined) {
|
if (element !== undefined) {
|
||||||
fireEvent(element, objectToEvent(evt));
|
fireEvent(element, objectToEvent(evt));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (element !== undefined) {
|
$(element).bind(this.type, this.handler);
|
||||||
$(element).bind(this.type, this.handler);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DomEventSource.prototype.onStop = function() {
|
DomEventSource.prototype.onStop = function() {
|
||||||
var element = this.elementOrId;
|
var element = this.elementOrId;
|
||||||
if (typeof(this.elementOrId) === 'string') {
|
if (typeof(this.elementOrId) === 'string') {
|
||||||
|
@ -929,6 +941,7 @@
|
||||||
|
|
||||||
var eventQueue = new EventQueue();
|
var eventQueue = new EventQueue();
|
||||||
var eventHandlers = filter(handlers, isEventHandler).concat(view.getEventHandlers());
|
var eventHandlers = filter(handlers, isEventHandler).concat(view.getEventHandlers());
|
||||||
|
view.eventHandlers = eventHandlers;
|
||||||
|
|
||||||
MACHINE.params.currentDisplayer(MACHINE, top);
|
MACHINE.params.currentDisplayer(MACHINE, top);
|
||||||
|
|
||||||
|
@ -1066,9 +1079,10 @@
|
||||||
// from the user came from here. If not, we have no hope to do a nice, efficient
|
// from the user came from here. If not, we have no hope to do a nice, efficient
|
||||||
// update, and have to do it from scratch.
|
// update, and have to do it from scratch.
|
||||||
var nonce = Math.random();
|
var nonce = Math.random();
|
||||||
|
var originalMockView = view.getMockAndResetFocus(nonce);
|
||||||
toDraw(MACHINE,
|
toDraw(MACHINE,
|
||||||
world,
|
world,
|
||||||
view.getMockAndResetFocus(nonce),
|
originalMockView,
|
||||||
function(newMockView) {
|
function(newMockView) {
|
||||||
if (newMockView.nonce === nonce) {
|
if (newMockView.nonce === nonce) {
|
||||||
var i;
|
var i;
|
||||||
|
@ -1079,7 +1093,8 @@
|
||||||
} else {
|
} else {
|
||||||
view.top = $(newMockView.cursor.top().node);
|
view.top = $(newMockView.cursor.top().node);
|
||||||
view.initialRender(top);
|
view.initialRender(top);
|
||||||
eventHandlers = newMockView.eventHandlers;
|
eventHandlers = newMockView.eventHandlers.slice(0);
|
||||||
|
view.eventHandlers = eventHandlers;
|
||||||
startEventHandlers();
|
startEventHandlers();
|
||||||
}
|
}
|
||||||
success();
|
success();
|
||||||
|
@ -1116,38 +1131,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // findDomNodeLocation: dom-node dom-node -> arrayof number
|
|
||||||
// // Given a node, returns the child indices we need to follow to reach
|
|
||||||
// // it from the top.
|
|
||||||
// // Assumption: top must be an ancestor of the node. Otherwise, the
|
|
||||||
// // result is partial.
|
|
||||||
// var findDomNodeLocation = function(node, top) {
|
|
||||||
// var locator = [];
|
|
||||||
// var parent, i;
|
|
||||||
// while(node !== top && node.parentNode !== null) {
|
|
||||||
// parent = node.parentNode;
|
|
||||||
// for (i = 0; i < parent.childNodes.length; i++) {
|
|
||||||
// if (parent.childNodes[i] === node) {
|
|
||||||
// locator.push(i);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// node = parent;
|
|
||||||
// }
|
|
||||||
// return locator.reverse();
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var findNodeFromLocation = function(top, location) {
|
|
||||||
// var i = 0;
|
|
||||||
// var node = top;
|
|
||||||
// for (i = 0; i < location.length; i++) {
|
|
||||||
// node = node.childNodes[location[i]];
|
|
||||||
// }
|
|
||||||
// return node;
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var DomElementOutputPort = function(id) {
|
var DomElementOutputPort = function(id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user