Skip to content

Instantly share code, notes, and snippets.

@RubyRonin
Created October 12, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RubyRonin/0ae4785b51ce804ebb3b to your computer and use it in GitHub Desktop.
Save RubyRonin/0ae4785b51ce804ebb3b to your computer and use it in GitHub Desktop.
function LoadDetails() {
mEntity = GetParameterByName('addressforhistory');
var apiurl = "";
if (mEntity.length > 0)
{
$(".mapWidget").hide();
apiurl = "http://services.phila.gov/ULRS311/Data/LIAddressKey/" + encodeURIComponent(mEntity);
LIMapHistoryServiceCall(apiurl, historySearch, null);
}
else if ($("#addressHistorySearchTxt").val().replace(/^\s+|\s+$/g, "").length > 0)
{
apiurl = "http://services.phila.gov/ULRS311/Data/LIAddressKey/" + encodeURIComponent($("#addressHistorySearchTxt").val().replace(/^\s+|\s+$/g, ""));
LIMapHistoryServiceCall(apiurl, historySearch, null);
}}
function GetParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null) {
return "";
}
else {
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
}
function historySearch(eid, cb) {
window.location="/data/Pages/default.aspx?entity=locationhistory&eid="+eid.TopicID;
//window.open("/data/Pages/default.aspx?entity=locationhistory&eid="+eid.TopicID, '_blank');
}
function LIMapHistoryServiceCall(apiurl, successcallback, callback) {
$.ajax({
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
url: apiurl,
async: false,
cache: true,
crossDomain: true,
timeout: 500000,
type: "GET",
xhrFields: { withCredentials: false },
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown + " " + textStatus);
},
statusCode: { 404: function () { alert('ERROR: Could not connect to service.'); } },
success: function (data) {
successcallback(data, callback);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment