Use fast things, don't send headers so that we don't duplicate requests

This commit is contained in:
Tom MacWright
2012-10-24 12:30:55 -04:00
parent 609f4efa41
commit 987a58c5bb
2 changed files with 12 additions and 23 deletions

View File

@@ -85,14 +85,23 @@ iD.Connection = function(apiURL) {
// summary: Load all data from a given URL.
$.ajax({
url: url,
headers: { "X-Requested-With": null },
success: parse(callback)
});
}
// Private functions to parse DOM created from XML file
function filterNodeName(n) {
return function(item) { return item.nodeName === n; };
}
function getAttribute(obj, name) {
return _.find(obj.attributes, filterNodeName(name)).nodeValue;
}
function parse(callback) {
return function(dom) {
var nodelist = _.compact(_.map(dom.childNodes[0].childNodes, function(obj) {
for (var i = 0; i < dom.childNodes[0].childNodes.length; i++) {
var obj = dom.childNodes[0].childNodes[i];
if (obj.nodeName === 'node') {
var node = new iD.Node(connection,
+getAttribute(obj, 'id'),
@@ -100,7 +109,6 @@ iD.Connection = function(apiURL) {
+getAttribute(obj, 'lon'),
getTags(obj));
assign(node);
return node;
} else if (obj.nodeName === 'way') {
var way = new iD.Way(connection,
getAttribute(obj, 'id'),
@@ -114,18 +122,8 @@ iD.Connection = function(apiURL) {
getTags(obj));
assign(relation);
}
}));
if (callback) { callback(nodelist); }
// Private functions to parse DOM created from XML file
function filterNodeName(n) {
return function(item) { return item.nodeName === n; };
}
function getAttribute(obj, name) {
return _.find(obj.attributes, filterNodeName(name)).nodeValue;
}
if (callback) { callback(); }
function getTags(obj) {
return _(obj.childNodes).chain()
.filter(filterNodeName('tag'))

View File

@@ -6,9 +6,7 @@ iD.Controller = function() {
var controller = {},
state = null;
controller.editorCache = {};
controller.undoStack = new iD.UndoStack();
// controller.stepper = new iD.ui.StepPane();
controller.setState = function(newState) {
// summary: Enter a new ControllerState, firing exitState on the old one, and enterState on the new one.
@@ -19,12 +17,5 @@ iD.Controller = function() {
newState.enterState();
};
controller.entityMouseEvent = function(event, entityUI) {
// summary: Pass a MouseEvent on an EntityUI (e.g. clicking a way) to the current ControllerState.
if (!this.state) { return; }
var newState = this.state.processMouseEvent(event,entityUI);
this.setState(newState);
};
return controller;
};