"); //need to display theApp in case showError is called before startup $(ANOKCO.theApp).css("display", "block"); $(ANOKCO.theMessage).css("display", "block"); $(ANOKCO.theSearch).css("display", "none"); $(ANOKCO.theList).css("display", "none"); $(ANOKCO.theDetails).css("display", "none"); $(ANOKCO.theLoader).css("display", "none"); ANOKCO.VIEW.styleApp(); ANOKCO.VIEW.scrollApp(); return; } ANOKCO.VIEW.showSearchInmates = function () { $(ANOKCO.theMessage).empty(); $(ANOKCO.theSearch).empty(); $(ANOKCO.theList).empty(); $(ANOKCO.theDetails).empty(); //add current refresh message $(ANOKCO.theMessage).append("
Information current as of " + ANOKCO.DATA.INMATES.LastUpdate + " Central Time.
"); //v2 - not clear why the line is commented out and then re-entered //$(ANOKCO.theMessage).append("
Check For Updates
"); $(ANOKCO.theMessage).append("
Check For Updates
"); $(ANOKCO.theMessage).append("
"); //add search input box $(ANOKCO.theSearch).append("
Search by typing the person's first or last name.
"); $(ANOKCO.theSearch).append("
"); $(ANOKCO.theSearch).append("
"); //v2 - added radio buttons //Define radio button group and set 'checked' to last value selected $("#anokcoSearchType").append("
"); $("#anokcoSearchType").append("
"); $("#anokcoSearchType").append("
"); $("#anokcoSearchType").append("
"); switch (ANOKCO.DATA["SEARCHTYPE"]) { case "InCustody": $("#anokcoInCustody").prop("checked", true); break; case "Released": $("#anokcoReleased").prop("checked", true); break; case "Both": $("#anokcoBoth").prop("checked", true); break; default: break; } $(ANOKCO.theSearch).append("
"); $(ANOKCO.theSearch).append("
"); //add the list of first letter links $(ANOKCO.theList).append("
Search by selecting the first letter of the person's last name.
"); $(ANOKCO.theList).append("
"); var numberInmates = ANOKCO.DATA.INMATES.inmates.length; var stringFirstLetter = ""; for (var i = 0; i < numberInmates; i++) { if (stringFirstLetter != ANOKCO.DATA.INMATES.inmates[i][0].charAt(0).toUpperCase()) { stringFirstLetter = ANOKCO.DATA.INMATES.inmates[i][0].charAt(0).toUpperCase(); //append a div for the letter to the list $("#anokcoList").append("
" + stringFirstLetter + "
"); } } //add a link for all $("#anokcoList").append("
Show All
"); $(ANOKCO.theList).append("
"); //attach events to search box ANOKCO.VIEW.typeAheadSearch(); //style the app $(ANOKCO.theMessage).css("display", "block"); //v2 - remove the extra semicolon //$(ANOKCO.theSearch).css("display", "block"); ; $(ANOKCO.theSearch).css("display", "block"); $(ANOKCO.theList).css("display", "block"); $(ANOKCO.theDetails).css("display", "none"); $(ANOKCO.theLoader).css("display", "none"); ANOKCO.VIEW.styleApp(); if (ANOKCO.VIEW.showSearchInmates.timesUsed == undefined) { ANOKCO.VIEW.showSearchInmates.timesUsed = 1; } else { ANOKCO.VIEW.scrollApp(); } return; } //v2- if there is a value in the search box, re-search after changing type of search, such as incustody to both ANOKCO.VIEW.InCustody_Click = function (InCustodyValue) { //document.getElementsByName(ANOKCO.VIEW.hdnSearchType).value = InCustodyValue; //console.log(InCustodyValue); ANOKCO.DATA["SEARCHTYPE"] = InCustodyValue; if ($('#anokcoSearchBox').val().toUpperCase() != "") { ANOKCO.VIEW.showSuggestions(); } return; } ANOKCO.VIEW.showInmatesList = function (letter) { $(ANOKCO.theMessage).empty(); $(ANOKCO.theSearch).empty(); $(ANOKCO.theList).empty(); $(ANOKCO.theDetails).empty(); //append a heading with the first letter and a link to go back $(ANOKCO.theList).append("
Go Back To Search
"); $(ANOKCO.theList).append("
Click name for details
"); //$(ANOKCO.theList).append("
"); //var numberInmates = ANOKCO.DATA.INMATES.inmates.length; //v2 - change to accomodate type of search //if (letter == "*") { // //append all inmates // for (var i = 0; i < ANOKCO.DATA.INMATES.inmates.length; i++) { // $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + "
"); // } //} else { // //append all inmates with that first letter // for (var i = 0; i < ANOKCO.DATA.INMATES.inmates.length; i++) { // if (letter.toUpperCase() == ANOKCO.DATA.INMATES.inmates[i][0].charAt(0).toUpperCase()) { // $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + "
"); // } // } //} //v2 - append only the inmates who match the current type of search if (letter == "*") { //append all inmates for (var i = 0; i < ANOKCO.DATA.INMATES.inmates.length; i++) { if (ANOKCO.DATA["SEARCHTYPE"] == "Released") { if (ANOKCO.DATA.INMATES.inmates[i][4] == "False") // InJail is False { $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + " " + ANOKCO.DATA.INMATES.inmates[i][5] + " " + ANOKCO.DATA.INMATES.inmates[i][6] + "
"); } } else { if (ANOKCO.DATA["SEARCHTYPE"] == "Both") { $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + " " + ANOKCO.DATA.INMATES.inmates[i][5] + " " + ANOKCO.DATA.INMATES.inmates[i][6] + "
"); } else { if (ANOKCO.DATA.INMATES.inmates[i][4] == "True") // InJail is True { $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + "
"); } } } } } else { //append all inmates with that first letter for (var i = 0; i < ANOKCO.DATA.INMATES.inmates.length; i++) { if (letter.toUpperCase() == ANOKCO.DATA.INMATES.inmates[i][0].charAt(0).toUpperCase()) { if (ANOKCO.DATA["SEARCHTYPE"] == "Released") { if (ANOKCO.DATA.INMATES.inmates[i][4] == "False") // InJail is False { $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + " " + ANOKCO.DATA.INMATES.inmates[i][5] + " " + ANOKCO.DATA.INMATES.inmates[i][6] + "
"); } } else { if (ANOKCO.DATA["SEARCHTYPE"] == "Both") { $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + " " + ANOKCO.DATA.INMATES.inmates[i][5] + " " + ANOKCO.DATA.INMATES.inmates[i][6] + "
"); } else { if (ANOKCO.DATA.INMATES.inmates[i][4] == "True") { $(ANOKCO.theList).append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + "
"); } } } } } } // end v2 change $(ANOKCO.theMessage).css("display", "none"); //v2 - remove the extra semicolon //$(ANOKCO.theSearch).css("display", "none");; $(ANOKCO.theSearch).css("display", "none"); $(ANOKCO.theList).css("display", "block"); $(ANOKCO.theDetails).css("display", "none"); $(ANOKCO.theLoader).css("display", "none"); ANOKCO.VIEW.styleApp(); ANOKCO.VIEW.scrollApp(); return; } ANOKCO.VIEW.typeAheadSearch = function () { //current versions of Android browser do not handle keypress events, so attach focus and blur handlers and use a set interval to look for typed inputs to search box var timerId = 0; $('#anokcoSearchBox').focus(function () { if (timerId) { clearInterval(timerId); } timerId = setInterval(function () { ANOKCO.VIEW.checkSearch(); }, 250); //check for inputs 4 times a second }); $('#anokcoSearchBox').blur(function () { clearInterval(timerId); }); return; } ANOKCO.VIEW.checkSearch = function () { if (ANOKCO.theSearchString == $('#anokcoSearchBox').val().toUpperCase()) { //do nothing because the search input has not changed } else { ANOKCO.theSearchString = $('#anokcoSearchBox').val().toUpperCase(); ANOKCO.VIEW.showSuggestions(); } return; } ANOKCO.VIEW.showSuggestions = function () { $(ANOKCO.theMessage).empty(); $(ANOKCO.theList).empty(); var search = $('#anokcoSearchBox').val().toUpperCase(); $("#anokcoSearchResults").empty(); //v2 - change of class, look into why //$("#anokcoSearchResults").append("
Go Back To Search
"); $("#anokcoSearchResults").append("
Go Back To Search
"); $("#anokcoSearchResults").append("
Click name for details
"); // loop through the array of array of names and display all matches $("#anokcoSearchResults").append("
"); if (search.length >= 2) { var j = 0; for (i = 0; i < ANOKCO.DATA.INMATES.inmates.length; i++) { if ((ANOKCO.DATA.INMATES.inmates[i][0].indexOf(search) == 0) || (ANOKCO.DATA.INMATES.inmates[i][1].indexOf(search) == 0) || (ANOKCO.DATA.INMATES.inmates[i][2].indexOf(search) == 0)) { //v2 - change to show only selected kind of search //$("#anokcoSearchResultsList").append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + "
"); if (ANOKCO.DATA["SEARCHTYPE"] == "Released") { if (ANOKCO.DATA.INMATES.inmates[i][4] == "False") // InJail is False { $("#anokcoSearchResultsList").append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + " " + ANOKCO.DATA.INMATES.inmates[i][5] + " " + ANOKCO.DATA.INMATES.inmates[i][6] + "
"); } } else { if (ANOKCO.DATA["SEARCHTYPE"] == "Both") { $("#anokcoSearchResultsList").append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + " " + ANOKCO.DATA.INMATES.inmates[i][5] + " " + ANOKCO.DATA.INMATES.inmates[i][6] + "
"); } else { if (ANOKCO.DATA.INMATES.inmates[i][4] == "True") { $("#anokcoSearchResultsList").append("
" + ANOKCO.DATA.INMATES.inmates[i][0] + ", " + ANOKCO.DATA.INMATES.inmates[i][1] + " " + ANOKCO.DATA.INMATES.inmates[i][2] + "
"); } } } //end v2 change j++; } } if (j == 0) { $("#anokcoSearchResults").append("
No match. Change your search.
"); } } else { $("#anokcoSearchResults").append("
Type at least 2 letters to see choices.
"); } ANOKCO.VIEW.styleApp(); //do not scroll to top of app after every keystroke return; } ANOKCO.VIEW.showDetail = function () { $(ANOKCO.theMessage).empty(); $(ANOKCO.theSearch).empty(); $(ANOKCO.theList).empty(); $(ANOKCO.theDetails).empty(); $(ANOKCO.theDetails).append("
"); $(ANOKCO.theDetails).append("
"); $(ANOKCO.theDetails).append("
"); $(ANOKCO.theDetails).append("
"); if (ANOKCO.DATA.INMATE.Booking.length > 0) { var goback = ""; if (ANOKCO.DATA.INMATE.FROM.length > 1) { //it came from search goback = "Go Back to Search for \"" + ANOKCO.DATA.INMATE.FROM + "\""; } else { if (ANOKCO.DATA.INMATE.FROM == "*") { //it came from the all list goback = "Go Back to ALL List" } else { //it came from the first letter goback = "Go Back to " + ANOKCO.DATA.INMATE.FROM + " List" } } $("#anokcoName").append("
" + goback + "
"); $("#anokcoName").append("
" + ANOKCO.DATA.INMATE.Booking[0].LName + ", " + ANOKCO.DATA.INMATE.Booking[0].FName + " " + ANOKCO.DATA.INMATE.Booking[0].MName + "
"); //v2 add released date //$("#anokcoAbout").append("
Housing Agency: " + ANOKCO.DATA.INMATE.Booking[0].Housing_Agency + "
Arrest Date: " + ANOKCO.DATA.INMATE.Booking[0].Arrest_Date + "
Incarceration Date: " + ANOKCO.DATA.INMATE.Booking[0].Incarceration_Date + "
Scheduled Release Date: " + ANOKCO.DATA.INMATE.Booking[0].Scheduled_Release_Date + "
"); // $("#anokcoAbout").append("
Housing Agency: " + ANOKCO.DATA.INMATE.Booking[0].Housing_Agency + "
Arrest Date: " + ANOKCO.DATA.INMATE.Booking[0].Arrest_Date + "
Incarceration Date: " + ANOKCO.DATA.INMATE.Booking[0].Incarceration_Date + "
Scheduled Release Date: " + ANOKCO.DATA.INMATE.Booking[0].Scheduled_Release_Date + "
Actual Release Date: " + ANOKCO.DATA.INMATE.Booking[0].Release_Date + "
Jacket ID: " + ANOKCO.DATA.INMATE.Booking[0].JacketID + "
");// v4 add booking number $("#anokcoAbout").append("
Housing Agency: " + ANOKCO.DATA.INMATE.Booking[0].Housing_Agency + "
Arrest Date: " + ANOKCO.DATA.INMATE.Booking[0].Arrest_Date + "
Incarceration Date: " + ANOKCO.DATA.INMATE.Booking[0].Incarceration_Date + "
Scheduled Release Date: " + ANOKCO.DATA.INMATE.Booking[0].Scheduled_Release_Date + "
Actual Release Date: " + ANOKCO.DATA.INMATE.Booking[0].Release_Date + "
Jacket ID: " + ANOKCO.DATA.INMATE.Booking[0].JacketID + "
Booking Number: " + ANOKCO.DATA.INMATE.Booking[0].Booking_Number + "
"); //end changes //add charges var charges = "Charges:
- " if (ANOKCO.DATA.INMATE.Charges.length > 0) { for (i = 0; i < ANOKCO.DATA.INMATE.Charges.length; i++) { charges += "
- " + ANOKCO.DATA.INMATE.Charges[i].ChargeDescription + " "; } } else { charges += "
- Charges not listed. "; } charges += "
"; $("#anokcoAbout").append("
" + charges + "
"); //add bail amounts var bail = "Bail Amounts:
- " if (ANOKCO.DATA.INMATE.BookingBails.length > 0) { for (i = 0; i < ANOKCO.DATA.INMATE.BookingBails.length; i++) { bail += "
- " + ANOKCO.DATA.INMATE.BookingBails[i].Court_Number + " - $" + ANOKCO.DATA.INMATE.BookingBails[i].Bail_Amount + " "; } } else { bail += "
- No bail amounts available. "; } bail += "
"; $("#anokcoAbout").append("
" + bail + "
"); //add photos if (ANOKCO.DATA.INMATE.Photos.length > 0) { var photos = ""; for (i = 0; i < ANOKCO.DATA.INMATE.Photos.length; i++) { //put in width and height to make the div the correct size before images have loaded photos += ""; } } else { photos = "No photos available."; } $("#anokcoPhotos").html(photos); } else { $("#anokcoName").html("Booking information not available - inmate may have been recently released."); } $(ANOKCO.theMessage).css("display", "none"); $(ANOKCO.theSearch).css("display", "none"); $(ANOKCO.theList).css("display", "none"); $(ANOKCO.theDetails).css("display", "block"); $(ANOKCO.theLoader).css("display", "none"); ANOKCO.VIEW.styleApp(); ANOKCO.VIEW.scrollApp(); return; } ANOKCO.VIEW.styleApp = function () { $(".anokcoInstructions").css({ "font-weight": "bold", "font-size": "larger" }); $(".anokcoBreak").css({ "clear": "both" }); $("#anokcoSearchBox").css({ "font-size": "larger", "width": "250px", "height": "40px", "padding": "1px", "margin": "5px", "margin-bottom": "10px", "background-color": "#F9F9F4" }); $(".anokcoNoTouch").css({ "height": "45px", "min-width": "45px", "margin": "5px", "padding": "5px", "margin-bottom": "10px", "margin-left": "0px", "padding-left": "0px", "display": "table" }); $(".anokcoNoTouch > span").css({ "display": "table-cell", "vertical-align": "middle", }); //v2 added attribute vertical-align $(".anokcoTouchTarget").css({ "height": "45px", "min-width": "45px", "margin": "5px", "padding": "5px", "margin-bottom": "10px", "background-color": "#F6F5EC", "border": "1px solid #E5E3CE", "border-radius": "3px", "vertical-align": "middle", "text-align": "center", "display": "table" }); $(".anokcoTouchTarget > a").css({ "display": "table-cell", "vertical-align": "middle", "font-size": "larger", "text-decoration": "none" }); $(".anokcoFloatLeft").css({ "float": "left" }); $(".anokcoAboutText").css({ "width": "280px", "margin-right": "10px" }); //v2 added styles $(".anokcoRadioButton").css({ "height": "30px", "vertical-align": "middle", "min-width": "145px", "margin": "5px", "padding": "5px", "margin-bottom": "15px", "background-color": "#F6F5EC", "border": "1px solid #E5E3CE", "border-radius": "3px", "text-align": "left", "color": "#0066cc", "display": "inline" }); //$(".anokcoRadioButton > a").css({ // "display": "table-cell", // "font-size": "larger", // "text-decoration": "none" //}); $(".anokcoTouchTargetSmall").css({ "height": "30px", "min-width": "45px", "margin": "5px", "padding": "5px", "margin-bottom": "10px", "background-color": "#F6F5EC", "border": "1px solid #E5E3CE", "border-radius": "3px", "vertical-align": "middle", "text-align": "center", "display": "table" }); $(".anokcoTouchTargetSmall > a").css({ "display": "table-cell", "vertical-align": "middle", "font-size": "larger", "text-decoration": "none" }); //end added styles $(ANOKCO.theApp).css({ "padding-bottom": "10px", "border-bottom": "2px solid #E5E3CE" }); //this function is called to reset the height of specific divs in the CivicPlus template to allow the change in height of the app ANOKCO.VIEW.doneLoading(ANOKCO.VIEW.dynamicStretch); return; } ANOKCO.VIEW.scrollApp = function () { //following code scrolls so that top of app is visible var el = document.getElementById(ANOKCO.theAppTop); el.scrollIntoView(true); return; } ANOKCO.VIEW.dynamicStretch = function () { //called after JavaScript app on CivicPlus page changes height of app content //first, set height of div that contains the InfoAdvanced widget to the height of #theApp //this also updates the computed height of the #structuralContainer2 div var padding2 = $(ANOKCO.theApp).closest("div[style*='height']").outerHeight(true) - $(ANOKCO.theApp).closest("div[style*='height']").height(); $(ANOKCO.theApp).closest("div[style*='height']").height($(ANOKCO.theApp).outerHeight(true) + padding2); //then get padding on #structuralContainer1, to add when stretching the containers var padding = $("#structuralContainer1").outerHeight(true) - $("#structuralContainer1").height(); var leftMenu = $("#structuralContainer3").outerHeight(true); //get height of left menu in #structuralContainer3 var midContent = $("#structuralContainer2").outerHeight(true); //get height of breadcrumb, title, content in #structuralContainer2 //get height of #featureColumn if visible var rightFeature = 0; if ($("#featureColumn").is(":visible")) { rightFeature = $("#featureColumn").outerHeight(true) } var isMobileView = $("body").hasClass("narrow"); //body element has class "narrow" when page is in mobile view //reset the #structuralContainer12 and #structuralContainer1 divs so that content does not go into footer or leave gap above footer var theHeight = 0; //catch CSS3 media query, see https://www.sitepoint.com/javascript-media-queries/ var mq = window.matchMedia("(min-width: 53em)"); //applies to #structuralContainer2 .contentWrap if (mq.matches) { //the page is in widest view, with feature column floating right of content //set #structuralContainer1 and #structuralContainer12 to maximum of leftMenu, midContent, rightFeature theHeight = Math.max(leftMenu, midContent, rightFeature) + padding; $("#structuralContainer12").height(theHeight).css("minHeight", theHeight); $("#structuralContainer1").height(theHeight).css("minHeight", theHeight); } else { if (isMobileView) { //page is in mobile view, with midContent, rightFeature, and leftMenu stacked //set #structuralContainer12 to total of midContent, rightFeature $("#structuralContainer12").height(midContent + rightFeature + padding).css("minHeight", midContent + rightFeature + padding); //set #structuralContainer1 to total of leftMenu, midContent, rightFeature $("#structuralContainer1").height(leftMenu + midContent + rightFeature + padding).css("minHeight", leftMenu + midContent + rightFeature + padding); } else { //page is in narrow view, with leftMenu and midContent over rightFeature //set #structuralContainer1 and #structuralContainer12 to maximum of leftMenu and midContent plus rightFeature theHeight = Math.max(leftMenu, midContent + rightFeature) + padding; $("#structuralContainer12").height(theHeight).css("minHeight", theHeight); $("#structuralContainer1").height(theHeight).css("minHeight", theHeight); } } return; } ANOKCO.VIEW.doneLoading = function (callBack) { //the dynamicStretch function checks the list of classes in body but that is not set right away //this function keeps checking the list of functions until "doneLoading" appears //then it callsback to dynamicStretch var myBody = document.getElementsByTagName("body").item(0); var id = setInterval(checkBody, 10); function checkBody() { if (myBody.classList.contains("doneLoading")) { clearInterval(id); callBack(); } } } //start the app when the document has loaded //jsonp based on http://www.sitepoint.com/jsonp-examples/ $(document).ready(function () { if ($("#liveEditTabs").length) { //when Live Edit is on just show a message ANOKCO.VIEW.showError("This widget contains a JavaScript app. Do not delete."); } else { $.ajax({ type: "GET", url: ANOKCO.theInmatesURL, async: false, jsonpCallback: "jsonpInmates", contentType: "application/json", dataType: "jsonp", beforeSend: function () { ANOKCO.VIEW.startUp(); }, success: function (data, textStatus, xhr) { ANOKCO.DATA.INMATES = data; ANOKCO.VIEW.showSearchInmates(); }, error: function (xhr, textStatus, errorThrown) { ANOKCO.VIEW.showError(errorThrown); } }); } });