More refactoring
diff --git a/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js b/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js
index 6d63399..ac7e26c 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js
+++ b/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js
@@ -286,28 +286,38 @@
if (data["status"] == 200 && data["responseText"] == "") {
success_fn(data);
} else {
- // TODO more graceful errors
alert("[Ajax Error]\n" + JSON.stringify(data));
}
}
});
+
} else {
- alert("no jquery");
+
+ // First, we encode the parameters of the query to create a new url.
+ api_endpoint = endpoint_url + "?" + Object.keys(json).map(function(k) {
+ return encodeURIComponent(k) + '=' + encodeURIComponent(json[k])
+ }).join('&');
+
+ // Now, create an XMLHttp object to carry our request. We will call the
+ // UI callback function on ready.
var xmlhttp;
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("GET", endpoint_url, true);
+ xmlhttp.send(null);
+
+ xmlhttp.onreadystatechange = function(){
+ if (xmlhttp.readyState == 4) {
+ if (xmlhttp.status === 200) {
+ alert(xmlhttp.responseText);
+ //success.call(null, xmlHttp.responseText);
+ } else {
+ //error.call(null, xmlHttp.responseText);
+ }
+ } else {
+ // Still processing
+ }
+ };
}
- // XML Http Request
- /*var xmlhttp;
-
- xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function(){
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
- alert(xmlhttp.responseText);
- //callback(xmlhttp.responseText);
- }
- }
- xmlhttp.open("GET", endpoint_url, true);
- xmlhttp.send();*/
-
return this;
};
@@ -679,8 +689,6 @@
//
// @param let_variable [String]
// @param expression [AExpression]
-//
-// TODO Vigorous error checking
function LetClause(let_variable, expression) {
AQLClause.call(this);
diff --git a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
index 52ddadf..fb8ba0d 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
+++ b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
@@ -180,13 +180,13 @@
end_dp.val(dateOptions.defaultDate);
// Explore Mode: Toggle Selection/Location Search
- $('#selection-button').on('click', function (e) {
+ $('#selection-button').on('change', function (e) {
$("#location-text-box").attr("disabled", "disabled");
if (selectionRect) {
selectionRect.setMap(map);
}
});
- $('#location-button').on('click', function (e) {
+ $('#location-button').on('change', function (e) {
$("#location-text-box").removeAttr("disabled");
if (selectionRect) {
selectionRect.setMap(null);
@@ -229,7 +229,9 @@
var bounds;
if ($('#selection-button').hasClass("active") && selectionRect) {
bounds = selectionRect.getBounds();
+ alert("using rectangle");
} else {
+ alert("Using map");
bounds = map.getBounds();
}
@@ -270,7 +272,6 @@
// Clears selection rectangle on query execution, rather than waiting for another clear call.
if (selectionRect) {
selectionRect.setMap(null);
- selectionRect = null;
}
});
}
@@ -1081,7 +1082,6 @@
if (selectionRect) {
selectionRect.setMap(null);
- selectionRect = null;
}
mapWidgetClearMap();
@@ -1183,4 +1183,4 @@
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
return d;
-};
\ No newline at end of file
+};