1jQuery.support.cors = true; 2 3// navigation menu 4$('#menu-toggle').on('click', function() { 5 $('#menu').slideToggle(150); 6}) 7 8// make table rows highlight-able. Not ideal to attach listener to `body` 9// but we have some tables that are created by js after page load 10$('body').on('click', 'tr', function(){ 11 $(this).toggleClass('highlight'); 12}) 13 14// attach browser dimensions for help with charts and tables 15window.browserWidth = document.documentElement.clientWidth; 16window.browserHeight = document.documentElement.clientHeight; 17 18// usage: log('inside coolFunc', this, arguments); 19// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ 20window.log = function(){ 21 log.history = log.history || []; // store logs to an array for reference 22 log.history.push(arguments); 23 arguments.callee = arguments.callee.caller; 24 if(this.console) console.log( Array.prototype.slice.call(arguments) ); 25}; 26// make it safe to use console.log always 27(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{}); 28 29// prepare ajax spinners 30$('body').append('<div id="body-spinner"></div>'); 31var spinnerTarget = document.getElementById('body-spinner'), 32 spinner = new Spinner(); 33$(document).ajaxSend(function(event, request, settings) { 34 spinner.spin(spinnerTarget); 35}); 36$(document).ajaxComplete(function(event, request, settings) { 37 spinner.stop(); 38}); 39 40// standard mapping of summary level code to summary level name 41var sumlevMap = { 42 "010": {"name": "nation", "plural": "nations", "sumlev": "010", "size_sort": 1000, 43 "children": ['020','030','040','050','060','140','150','160','250','310','500','610','620','860','950','960','970']}, 44 "020": {"name": "region", "plural": "regions", "sumlev": "020", "size_sort": 950, 45 "children": ['030','040','050','060','140','150','160','250','310','500','610','620','860','950','960','970']}, 46 "030": {"name": "division", "plural": "divisions", "sumlev": "030", "size_sort": 900, 47 "children": ['040','050','060','140','150','160','250','310','500','610','620','860','950','960','970']}, 48 "040": {"name": "state", "plural": "states", "sumlev": "040", "size_sort": 850, 49 "children": ['050','060','140','150','160','250','310','500','610','620','860','950','960','970']}, 50 "050": {"name": "county", "plural": "counties", "sumlev": "050", "size_sort": 800, 51 "children": ['060','140','150','160','500','610','620','860','950','960','970']}, 52 "060": {"name": "county subdivision", "plural": "county subdivisions", "sumlev": "060", "size_sort": 750, 53 "children": ['140','150','160','250','310','500','610','620','860','950','960','970']}, 54 "140": {"name": "census tract", "plural": "census tracts", "sumlev": "140", "size_sort": 100, 55 "children": ['150']}, 56 "150": {"name": "block group", "plural": "block groups", "sumlev": "150", "size_sort": 50, 57 "children": []}, 58 "160": {"name": "place", "plural": "places", "sumlev": "160", "size_sort": 200, 59 "children": ['140','150','860']}, 60 "170": {"name": "consolidated city", "plural": "consolidated cities", "sumlev": "170", "size_sort": 210, 61 "children": []}, 62 "230": {"name": "Alaska native regional corporation", "plural": "Alaska native regional corporations", "sumlev": "230", "size_sort": 300, 63 "children": []}, 64 "250": {"name": "native area", "plural": "native areas", "sumlev": "250", "size_sort": 300, 65 "children": ['140','150','252','254','860']}, 66 "251": {"name": "tribal subdivision", "plural": "tribal subdivisions", "sumlev": "251", "size_sort": 290, 67 "children": []}, 68 "252": {"name": "native area (reservation)", "plural": "native areas (reservation)", "sumlev": "250", "size_sort": 300, 69 "children": []}, 70 "254": {"name": "native area (off-reservation trust land)", "plural": "native areas (off-reservation trust land)", "sumlev": "250", "size_sort": 300, 71 "children": []},
72 "256": {"name": "tribal tract", "plural": "tribal tracts", "sumlev": "256", "size_sort": 101, 73 "children": []}, 74 "310": {"name": "metro area", "plural": "metro areas", "sumlev": "310", "size_sort": 825, 75 "children": ['050','060','140','150','160','860']}, 76 "314": {"name": "metropolitan division", "plural": "metropolitan division", "sumlev": "314", "size_sort": 810, 77 "children": []}, 78 "330": {"name": "combined statistical area", "plural": "combined statistical areas", "sumlev": "330", "size_sort": 845, 79 "children": []}, 80 "335": {"name": "combined NECTA", "plural": "combined NECTAs", "sumlev": "335", "size_sort": 844, 81 "children": []}, 82 "350": {"name": "NECTA", "plural": "NECTAs", "sumlev": "350", "size_sort": 824, 83 "children": []}, 84 "364": {"name": "NECTA division", "plural": "NECTA divisions", "sumlev": "364", "size_sort": 811, 85 "children": []}, 86 "400": {"name": "urban area", "plural": "urban areas", "sumlev": "400", "size_sort": 820, 87 "children": []}, 88 "500": {"name": "congressional district", "plural": "congressional districts", "sumlev": "500", "size_sort": 770, 89 "children": ['050','060','140','150','160','860']}, 90 "610": {"name": "state house (upper)", "plural": "state houses (upper)", "sumlev": "610", "size_sort": 765, 91 "children": ['050','060','140','150','160','860']}, 92 "620": {"name": "state house (lower)", "plural": "state houses (lower)", "sumlev": "620", "size_sort": 760, 93 "children": ['050','060','140','150','160','860']}, 94 "795": {"name": "PUMA", "plural": "PUMAs", "sumlev": "795", "size_sort": 195, 95 "children": []}, 96 "860": {"name": "ZIP code", "plural": "ZIP codes", "sumlev": "860", "size_sort": 125, 97 "children": ['140','150']}, 98 "950": {"name": "school district (elementary)", "plural": "school districts (elementary)", "sumlev": "950", "size_sort": 145, 99 "children": ['060','140','150','160','860']}, 100 "960": {"name": "school district (secondary)", "plural": "school districts (secondary)", "sumlev": "960", "size_sort": 150, 101 "children": ['060','140','150','160','860']}, 102 "970": {"name": "school district (unified)", "plural": "school districts (unified)", "sumlev": "970", "size_sort": 155, 103 "children": ['060','140','150','160','860']} 104}; 105 106var releaseNames = { 107 'acs2024_5yr': {'name': 'ACS 2024 5-year', 'years': '2020-2024'}, 108 'acs2024_1yr': {'name': 'ACS 2024 1-year', 'years': '2024'},
109 'acs2023_5yr': {'name': 'ACS 2023 5-year', 'years': '2019-2023'}, 110 'acs2023_1yr': {'name': 'ACS 2023 1-year', 'years': '2023'}, 111 'acs2022_5yr': {'name': 'ACS 2022 5-year', 'years': '2018-2022'}, 112 'acs2022_1yr': {'name': 'ACS 2022 1-year', 'years': '2022'}, 113 'acs2021_5yr': {'name': 'ACS 2021 5-year', 'years': '2017-2021'}, 114 'acs2021_1yr': {'name': 'ACS 2021 1-year', 'years': '2021'}, 115 'acs2020_5yr': {'name': 'ACS 2020 5-year', 'years': '2016-2020'}, 116 'acs2019_5yr': {'name': 'ACS 2019 5-year', 'years': '2015-2019'}, 117 'acs2019_1yr': {'name': 'ACS 2019 1-year', 'years': '2019'}, 118 'acs2018_5yr': {'name': 'ACS 2018 5-year', 'years': '2014-2018'}, 119 'acs2018_1yr': {'name': 'ACS 2018 1-year', 'years': '2018'}, 120 'acs2017_5yr': {'name': 'ACS 2017 5-year', 'years': '2013-2017'}, 121 'acs2017_1yr': {'name': 'ACS 2017 1-year', 'years': '2017'}, 122 'acs2016_5yr': {'name': 'ACS 2016 5-year', 'years': '2012-2016'}, 123 'acs2016_1yr': {'name': 'ACS 2016 1-year', 'years': '2016'}, 124 'acs2015_5yr': {'name': 'ACS 2015 5-year', 'years': '2011-2015'}, 125 'acs2015_1yr': {'name': 'ACS 2015 1-year', 'years': '2015'}, 126 'acs2014_5yr': {'name': 'ACS 2014 5-year', 'years': '2010-2014'}, 127 'acs2014_1yr': {'name': 'ACS 2014 1-year', 'years': '2014'}, 128 'acs2013_1yr': {'name': 'ACS 2013 1-year', 'years': '2013'}, 129 'acs2013_3yr': {'name': 'ACS 2013 3-year', 'years': '2011-2013'}, 130 'acs2013_5yr': {'name': 'ACS 2013 5-year', 'years': '2009-2013'}, 131 'acs2012_1yr': {'name': 'ACS 2012 1-year', 'years': '2012'}, 132 'acs2012_3yr': {'name': 'ACS 2012 3-year', 'years': '2010-2012'}, 133 'acs2012_5yr': {'name': 'ACS 2012 5-year', 'years': '2008-2012'} 134}; 135 136// formatting utils 137// format percentages and/or dollar signs 138var valFmt = function(value, statType, disablePct) { 139 if (value >= 0 && value !== null) { 140 if (!disablePct && statType == 'percentage') { 141 value += '%'; 142 } else if (statType == 'dollar') { 143 value = '$' + commaFmt(value); 144 } else { 145 value = commaFmt(value); 146 } 147 return value; 148 } 149 return '' 150} 151 152// commas for human-friendly integers 153var commaFmt = d3.format(","); 154 155var capitalize = function(string) { 156 return string.charAt(0).toUpperCase() + string.slice(1); 157} 158 159// underscore.string formatters 160var escapeRegExp = function(str) { 161 if (str == null) return ''; 162 return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); 163} 164 165var defaultToWhiteSpace = function(characters) { 166 if (characters == null) 167 return '\\s'; 168 else if (characters.source) 169 return characters.source; 170 else 171 return '[' + escapeRegExp(characters) + ']'; 172} 173 174var nativeTrim = String.prototype.trim; 175var trim = function(str, characters) { 176 if (str == null) return ''; 177 if (!characters && nativeTrim) return nativeTrim.call(str); 178 characters = defaultToWhiteSpace(characters); 179 return String(str).replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), ''); 180} 181 182var dasherize = function(str) { 183 return trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase(); 184} 185 186var slugify = function(str) { 187 if (str == null) return ''; 188 189 var from = "Ä Ã Ã¡Ã¤Ã¢Ã£Ã¥Ã¦ÄÄÄèéëêìÃïîÅÅòóöôõøÅÈÈùúüûñçżź", 190 to = "aaaaaaaaaceeeeeiiiilnoooooosstuuuunczz", 191 regex = new RegExp(defaultToWhiteSpace(from), 'g'); 192 193 str = String(str).toLowerCase().replace(regex, function(c){ 194 var index = from.indexOf(c); 195 return to.charAt(index) || '-'; 196 }); 197 198 return dasherize(str.replace(/[^\w\s-]/g, '')); 199} 200 201// math utils 202var calcPct = function(numerator, denominator) { 203 if (denominator == 0) { 204 return 0 205 } else if (numerator >= 0 && denominator > 0) { 206 return Math.round(((numerator / denominator) * 100) * 10) / 10 207 } 208 return null 209} 210 211var calcPctMOE = function(numerator, denominator, numerator_moe, denominator_moe) { 212 // From http://www.census.gov/acs/www/Downloads/handbooks/ACSGeneralHandbook.pdf 213 if (denominator == 0) { 214 return 0 215 } else if (numerator >= 0 && denominator >= 0) { 216 var estimated_ratio = (numerator / denominator), 217 to_square_root = Math.pow(numerator_moe, 2) - (Math.pow(estimated_ratio, 2) * Math.pow(denominator_moe, 2)); 218 // "There are rare instances where this formula will failâ 219 // the value under the square root will be negative. If that 220 // happens, use the formula for derived ratios in the next 221 // section which will provide a conservative estimate of 222 // the MOE." 223 if (to_square_root < 0) { 224 to_square_root = Math.pow(numerator_moe, 2) + (Math.pow(estimated_ratio, 2) * Math.pow(denominator_moe, 2)); 225 } 226 moe_ratio = Math.sqrt(to_square_root) / denominator; 227 return Math.round((moe_ratio * 100) * 10) / 10 228 } 229 return null 230} 231
232var roundNumber = function(value, decimals) { 233 var precision = (!!decimals) ? decimals : 0, 234 factor = Math.pow(10, precision), 235 value = Math.round(value * factor) / factor; 236 237 return value; 238} 239 240var numberWithCommas = function(n, decimals) { 241 var parts = roundNumber(n, decimals).toString().split("."); 242 243 return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : ""); 244} 245// parseParams from https://gist.github.com/kares/956897#comment-802666 246;!(function($) { 247 var re = /([^&=]+)=?([^&]*)/g; 248 var decode = function(str) { 249 return decodeURIComponent(str.replace(/\+/g, ' ')); 250 }; 251 $.parseParams = function(query) { 252 var params = {}, e; 253 if (!query) { 254 query = window.location.search; 255 } 256 if (query.substr(0, 1) == '?') { 257 query = query.substr(1); 258 } 259 260 while (e = re.exec(query)) { 261 var k = decode(e[1]); 262 var v = decode(e[2]); 263 if (params[k] !== undefined) { 264 if (!$.isArray(params[k])) { 265 params[k] = [params[k]]; 266 } 267 params[k].push(v); 268 } else { 269 params[k] = v; 270 } 271 } 272 return params; 273 }; 274})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.