search.js   search.js 
skipping to change at line 14 skipping to change at line 14
var simbadDelay = 500; var simbadDelay = 500;
var lastXHR; var lastXHR;
var simbadXHR; var simbadXHR;
var listXHR; var listXHR;
var simbadTimeout; var simbadTimeout;
var searchFinished = false; var searchFinished = false;
function selectObjectByName(str) { function selectObjectByName(str, mode) {
rc.postCmd("/api/main/focus", { rc.postCmd("/api/main/focus", {
target: str target: str,
mode: mode
}, undefined, function(data) { }, undefined, function(data) {
console.log("focus change ok: " + data); console.log("focus change ok: " + data);
}); });
} }
function performSimbadSearch(str, callback) { function performSimbadSearch(str, callback) {
//check if the normal search has finished, otherwise we wait longer //check if the normal search has finished, otherwise we wait longer
if (!searchFinished) { if (!searchFinished) {
console.log("defer Simbad search because normal search is not f console.log(
inished"); "defer Simbad search because normal search is not finished"
);
simbadTimeout = setTimeout(function() { simbadTimeout = setTimeout(function() {
performSimbadSearch(str, callback); performSimbadSearch(str, callback);
}, simbadDelay); }, simbadDelay);
return; return;
} }
changeSimbadState(rc.tr("querying")); changeSimbadState(rc.tr("querying"));
simbadXHR = $.ajax({ simbadXHR = $.ajax({
url: "/api/simbad/lookup", url: "/api/simbad/lookup",
data: { data: {
str: str str: str
}, },
success: function(data) { success: function(data) {
if (data.status === "error") { if (data.status === "error") {
changeSimbadState(rc.tr("Error (%1)", data.errorString) changeSimbadState(rc.tr("Error (%1)",
); data.errorString));
} else { } else {
changeSimbadState(data.status_i18n); changeSimbadState(data.status_i18n);
} }
callback(data); callback(data);
}, },
error: function(xhr, status, errorThrown) { error: function(xhr, status, errorThrown) {
if (status !== "abort") { if (status !== "abort") {
console.log("Error performing simbad lookup"); console.log(
"Error performing simbad lookup"
);
console.log("Error: " + errorThrown.message); console.log("Error: " + errorThrown.message);
console.log("Status: " + status); console.log("Status: " + status);
alert(rc.tr("Error performing Simbad lookup")); alert(rc.tr(
"Error performing Simbad lookup"
));
} }
} }
}); });
} }
function cancelSearch() { function cancelSearch() {
searchFinished = false; searchFinished = false;
if (lastXHR) { if (lastXHR) {
lastXHR.abort(); lastXHR.abort();
skipping to change at line 85 skipping to change at line 93
$(publ).trigger("simbadStateChanged", state); $(publ).trigger("simbadStateChanged", state);
} }
//Public stuff //Public stuff
var publ = { var publ = {
loadObjectTypes: function(callback) { loadObjectTypes: function(callback) {
$.ajax({ $.ajax({
url: "/api/objects/listobjecttypes", url: "/api/objects/listobjecttypes",
dataType: "JSON", dataType: "JSON",
success: callback, success: callback,
error: function(xhr, status, errorThrown) { error: function(xhr, status,
errorThrown) {
if (status !== "abort") { if (status !== "abort") {
console.log("Error loading object types"); console.log(
console.log("Error: " + errorThrown.message); "Error loading object types"
console.log("Status: " + status); );
alert(rc.tr("Error loading object types")); console.log("Error: " +
errorThrown.message
);
console.log("Status: " +
status);
alert(rc.tr(
"Error loading object types"
));
} }
} }
}); });
}, },
loadObjectList: function(objectType, useEnglish, callback) { loadObjectList: function(objectType, useEnglish, callback) {
if (listXHR) { if (listXHR) {
listXHR.abort(); listXHR.abort();
listXHR = undefined; listXHR = undefined;
} }
listXHR = $.ajax({ listXHR = $.ajax({
url: "/api/objects/listobjectsbytype", url: "/api/objects/listobjectsbytype",
dataType: "JSON", dataType: "JSON",
data: { data: {
type: objectType, type: objectType,
english: (useEnglish ? 1 : 0) english: (useEnglish ? 1 : 0)
}, },
success: callback, success: callback,
error: function(xhr, status, errorThrown) { error: function(xhr, status,
errorThrown) {
if (status !== "abort") { if (status !== "abort") {
console.log("Error getting object list"); console.log(
console.log("Error: " + errorThrown.message); "Error getting object list"
console.log("Status: " + status); );
alert(rc.tr("Error getting object list")); console.log("Error: " +
errorThrown.message
);
console.log("Status: " +
status);
alert(rc.tr(
"Error getting object list"
));
} }
} }
}); });
}, },
selectObjectByName: selectObjectByName, selectObjectByName: selectObjectByName,
focusPosition: function(pos) { focusPosition: function(pos) {
var posStr = JSON.stringify(pos); var posStr = JSON.stringify(pos);
rc.postCmd("/api/main/focus", { rc.postCmd("/api/main/focus", {
position: posStr position: posStr
skipping to change at line 148 skipping to change at line 172
lastXHR = $.ajax({ lastXHR = $.ajax({
url: "/api/objects/find", url: "/api/objects/find",
data: { data: {
str: str str: str
}, },
success: function(data) { success: function(data) {
resultCallback(data); resultCallback(data);
searchFinished = true; searchFinished = true;
}, },
error: function(xhr, status, errorThrown) { error: function(xhr, status,
errorThrown) {
if (status !== "abort") { if (status !== "abort") {
console.log("Error performing search"); console.log(
console.log("Error: " + errorThrown.message); "Error performing search"
console.log("Status: " + status); );
console.log("Error: " +
errorThrown.message
);
console.log("Status: " +
status);
//cancel a pending simbad search //cancel a pending simbad search
cancelSearch(); cancelSearch();
alert(rc.tr("Error performing search")); alert(rc.tr(
"Error performing search"
));
} }
} }
}); });
//queue simbad search //queue simbad search
simbadTimeout = setTimeout(function() { simbadTimeout = setTimeout(function() {
performSimbadSearch(str, simbadCallback); performSimbadSearch(str,
simbadCallback);
}, simbadDelay); }, simbadDelay);
changeSimbadState(rc.tr("waiting")); changeSimbadState(rc.tr("waiting"));
return true; return true;
} }
} }
}; };
return publ; return publ;
}); });
 End of changes. 14 change blocks. 
24 lines changed or deleted 55 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/