1$(function () { 2 3 // redirect any http to https 4 if (location.protocol !== "https:") { 5 console.log('redirecting'); 6 location.protocol = "https:"; 7 } 8 9 /** 10 *** .collapsible should have a direct child h3. 11 *** the button will be appended to the h3. 12 *** clicking the button will hide all .collapsible's children 13 *** (except the h3) from display, and hide the entire .collapsible 14 *** from the printer. 15 **/ 16 $('.collapsible').each(function (idx, el) { 17 var hideText = 'hide for printing'; 18 var showText = 'show'; 19 $('<button class="no-print">' + hideText + '</button>') 20 .on('click', function (e) { 21 $button = $(this); 22 $el = $(el); 23 $el.find('> *:not(h3)').slideToggle(function () { 24 $el.toggleClass('collapsed'); 25 $button.text(($el.hasClass('collapsed')) ? showText : hideText); 26 }); 27 }) 28 .appendTo($(el).find('h3')) 29 ; 30 }); 31 32 window.addEventListener('popstate', function (e) { 33 if (e.state && e.state.sketchId && e.state.sketchSize === 'small') { 34 makeSketchSmaller(e.state.sketchId); 35 } 36 }); 37 38 function makeSketchSmaller (id) { 39 var canvas = $('canvas[data-bld_id=' + id + ']')[0]; 40 var button = $('button[data-bld_id=' + id + ']')[0]; 41 canvas.style.width = '300px'; 42 canvas.style.height = '300px'; 43 button.isLarge = false; 44 $(button).text('Enlarge Sketch'); 45 window.history.replaceState({ sketchId: id, sketchSize: 'small' }, document.title, '?') 46 window.render(canvas); 47 window.setTimeout(function () { 48 button.scrollIntoView(); 49 }, 1); 50 } 51 52 // enlarge and shrink a parcel page building sketch 53 $('button.enlarge-sketch').on('click', function () { 54 var button = this; 55 $canvas = $('canvas[data-bld_id=' + button.dataset.bld_id + ']'); 56 if (button.isLarge) { 57 window.history.back(); 58 } else { 59 $canvas[0].style.width = '900px'; 60 $canvas[0].style.height = '900px'; 61 window.render($canvas[0]); 62 button.scrollIntoView(); 63 button.isLarge = true; 64 $(button).text('Make Sketch Smaller'); 65 window.history.replaceState({ sketchId: button.dataset.bld_id, sketchSize: 'small' }, document.title, '?sketchSize=small') 66 window.history.pushState({ sketchId: button.dataset.bld_id, sketchSize: 'large' }, document.title, '?sketchSize=large'); 67 } 68 }); 69 70 // open sketch in a new window 71 $('a.open-sketch').on('click', function (e) { 72 // if possible, open the sketch via javascript so the new window 73 // can have a close button that returns the user to the parcel. 74 e.preventDefault(); 75 window.open(this.href, "_blank"); 76 }); 77 78 // fill any lu table select/option lists 79 $('select[data-fn]').each(function (idx, el) { 80 let $el = $(el), 81 api_url = GSA_BASE_URL + 'api/lu/' + el.dataset.fn, 82 $option, 83 show_fields = el.dataset.show ?? 'cd,dscr'; 84 if (show_fields === 'default') show_fields = 'cd,dscr'; 85 $.get(api_url).done(function (data) { 86 var filler = data.items.map(function (item) { 87 $option = $('<option></option>').val(item.cd); 88 if (item.dscr) { 89 const txt = show_fields.split(',').map((el) => item[el]).join(' - '); 90 // if (show_fields === 'dscr') $option.text(item.dscr); 91 // else $option.text(item.cd + ' - ' + item.dscr); 92 $option.text(txt); 93 } else { 94 $option.text(item.cd); 95 } 96 return $option; 97 }); 98 99 filler.unshift('<option value="">Any</option>') 100 $el.html(filler); 101 $el.attr('size', Math.min($el.attr('size'), data.items.length + 1)) 102 $el.val(function () { 103 return this.dataset.vals.split(','); 104 }); 105 }); 106 }); 107 108 // fill any lu table select/option lists 109 $('select[data-fn2]').each(function (idx, el) { 110 var $el = $(el), 111 api_url = GSA_BASE_URL + 'api/lu2/' + el.dataset.fn2, 112 $option, 113 show_fields = el.dataset.show ?? 'default'; 114 $.get(api_url).done(function (data) { 115 var filler = data.items.map(function (item) { 116 $option = $('<option></option>').val(item.cd); 117 if (item.dscr) { 118 // todo: support other display field. see data-fn above. 119 if (show_fields === 'dscr') $option.text(item.dscr); 120 else $option.text(item.cd + ' - ' + item.dscr); // default 121 } else { 122 $option.text(item.cd); 123 } 124 return $option; 125 }); 126 127 filler.unshift('<option value="">Any</option>') 128 $el.html(filler); 129 $el.val(function () { 130 return this.dataset.vals.split(','); 131 }); 132 }); 133 }); 134 135 // do select-all for select boxes that have this button. 136 window.addEventListener('click', (e) => { 137 // we only care about [data-fn="select-all"] 138 if (!e.target.matches('[data-fn="select-all"]')) return; 139 // only for multi-select select boxes 140 const select = e.target?.closest('label')?.querySelector('select'); 141 if (!select || (select?.type !== 'select-multiple')) return; 142 143 e.preventDefault(); 144 e.stopPropagation(); 145 146 // select all the options. 147 select.querySelectorAll('option').forEach((e) => e.selected = "selected"); 148 }) 149 150 var exportLinkSelector = "a.export-link"; 151 var exportFormSelector = "#export-options"; 152 153 // $('a[href^="/export"]').each(function () { 154 $(exportLinkSelector).each(function () { 155 this.dataset.href = this.href; 156 this.href = exportFormSelector; 157 }).on('click', function (e) { 158 e.preventDefault(); 159 var $form = $(exportFormSelector); 160 var form = $form[0]; 161 162 // set form values. 163 try { 164 this.dataset.href.split('?')[1].split('&').forEach(function (val) { 165 val = val.split('='); 166 form[val[0]].value = decodeURIComponent(val[1]); 167 }); 168 } catch (ex) { 169 } 170 171 $form.find('button').removeAttr('disabled'); 172 173 // scroll to and highlight the form. 174 $form.addClass('attention-on'); 175 setTimeout(function () { 176 $form.removeClass('attention-on'); 177 }, 3000); 178 $form[0].scrollIntoView(); 179 }); 180 181 $('[data-clipboardtarget]').on('click', function (el) { 182 var targ = window.targ = document.getElementById(this.dataset.clipboardtarget); 183 targ.focus(); 184 targ.setSelectionRange(0, targ.value.length); 185 if (document.execCommand("copy")) { 186 var e = document.getElementById(this.dataset.clipboardtarget + '-message'); 187 if (e && this.dataset.successmessage) { 188 e.innerText = this.dataset.successmessage; 189 } 190 } 191 this.focus(); 192 }); 193 194 // $('input[name="query[parcel][book_min]"]').on('change', function (e) { 195 // var x = $('input[name="query[parcel][book_max]"]'); 196 // if (! x.val()) { x.val(e.target.value); } 197 // }); 198 199 // $('input[name="query[parcel][book_max]"]').on('change', function (e) { 200 // var x = $('input[name="query[parcel][book_min]"]'); 201 // if (! x.val()) { x.val(e.target.value); } 202 // }); 203 204 // $('input[name="query[parcel][page_min]"]').on('change', function (e) { 205 // var x = $('input[name="query[parcel][page_max]"]'); 206 // if (! x.val()) { x.val(e.target.value); } 207 // }); 208 209 // $('input[name="query[parcel][page_max]"]').on('change', function (e) { 210 // var x = $('input[name="query[parcel][page_min]"]'); 211 // if (! x.val()) { x.val(e.target.value); } 212 // }); 213 214 // $('[data-sortable]').each(function (idx, el) { 215 // $fld = el.dataset.sortable; 216 // if (!$fld) return; 217 // console.log('sortable', el); 218 // }); 219});
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.