1// eslint-disable-next-line @typescript-eslint/no-unused-vars 2function initIlluminResearchQuestion() { 3 /*************** Illumin definitions ***************/ 4 //let hostName = window.location.hostname; // acdevwww.ushmm.org, www.ushmm.org 5 let illuminServer = ""; 6 //if (hostName.toLowerCase().indexOf('devwww.ushmm.org') >= 0) { 7 // illuminServer = 'test'; 8 //} else { 9 illuminServer = "production"; 10 //} 11 const illuminAPIPostScript = "https://www.ushmm.org/api/illumin-research-question-post.php"; 12 /*************** Illumin definitions ***************/ 13 14 const clientCodes = [ 15 { id: 1, text: "Collection Donor or Family" }, 16 { id: 2, text: "Family of Survivor or Victim" }, 17 { id: 3, text: "Genealogy" }, 18 { id: 4, text: "HS or below - Student" }, 19 { id: 5, text: "Museum Staff" }, 20 { id: 6, text: "Scholarly Researcher" }, 21 { id: 7, text: "Survivor" }, 22 { id: 8, text: "Teacher" }, 23 { id: 9, text: "Undergrad - Student" }, 24 { id: 10, text: "Other" }, 25 ]; 26 27 const types = [ 28 { id: 1, text: "Donation Offer to the Museum" }, 29 { id: 2, text: "Information Request" }, 30 { id: 3, text: "Patron Planning Visit" }, 31 ]; 32 33 const reasons = [ 34 { id: 1, text: "School Paper" }, 35 { id: 2, text: "Research Paper or Other Academic Publication" }, 36 { id: 3, text: "Upcoming Research Visit to the Museum" }, 37 { id: 4, text: "Documentation on a Specific Survivor or Victim" }, 38 { id: 5, text: "Family History" }, 39 { id: 6, text: "Personal Interest" }, 40 { id: 7, text: "Photographs" }, 41 { id: 8, text: "Film Footage" }, 42 { id: 9, text: "Lesson Planning or Curriculum Development" }, 43 { id: 10, text: "Donating Items to the Museum" }, 44 { id: 11, text: "Other" }, 45 ]; 46 47 const educations = [ 48 { id: 1, text: "Intermediate/Middle School" }, 49 { id: 2, text: "Secondary/High School" }, 50 { id: 3, text: "Undergraduate" }, 51 { id: 4, text: "Graduate School/Postgraduate" }, 52 { id: 5, text: "Other" }, 53 ]; 54 55 window.formIsValid = function (step) { 56 step = parseInt(step); 57 if (isNaN(parseFloat(step)) || !isFinite(step)) { 58 step = 1; 59 } 60 61 let isValid = true; 62 63 if (step == 1) { 64 validateContactInfo(); 65 66 // validate Core_clientCode select2 67 if (!$(".container #inputFormPage1 #Core_clientCode").val()) { 68 $(".container #inputFormPage1 #Core_clientCode") 69 .closest(".form-group") 70 .removeClass("no-error") 71 .addClass("has-error"); 72 } else { 73 $(".container #inputFormPage1 #Core_clientCode") 74 .closest(".form-group") 75 .removeClass("has-error") 76 .addClass("no-error"); 77 } 78 } else if (step == 2) { 79 // validate Reason select2 80 if (!$(".container #inputFormPage2 #Reason").val()) { 81 $(".container #inputFormPage2 #Reason").closest(".form-group").removeClass("no-error").addClass("has-error"); 82 } else { 83 $(".container #inputFormPage2 #Reason").closest(".form-group").removeClass("has-error").addClass("no-error"); 84 } 85 86 // validate Other_Reason 87 if ($(".container #inputFormPage2 #otherReasonInfo").hasClass("show")) { 88 if (!$(".container #inputFormPage2 input[name=Other_Reason]").val().trim()) { 89 $(".container #inputFormPage2 input[name=Other_Reason]").addClass("is-invalid"); 90 isValid = false; 91 } 92 } 93 94 // validate Other_Education_Level 95 if ($(".container #inputFormPage2 #otherEducationInfo").hasClass("show")) { 96 if (!$(".container #inputFormPage2 input[name=Other_Education_Level]").val().trim()) { 97 $(".container #inputFormPage2 input[name=Other_Education_Level]").addClass("is-invalid"); 98 isValid = false; 99 } 100 } 101 } 102 103 return isValid; 104 }; 105 106 window.submitForm = function () { 107 // submit form 108 109 if (!submitFormPreRequisite()) { 110 return false; 111 } 112 113 rollbarLog(`User submitting the Research Question form at ${Date.now()}`); 114 let data = collectAllFieldValues("RQuestion"); 115 if (data.length == 0) { 116 $(".container #errorMsg").html("<p>Unable to collect information.</p>").addClass("show"); 117 submitFormAfter(); 118 return false;
119 } 120 121 // all new request will have these values 122 123 // assign Core fields: channel, requestForm, priority, assignedTo 124 data.push({ name: "Core_channel", value: "Form" }); 125 data.push({ name: "Core_requestForm", value: "Research Question" }); 126 data.push({ name: "Core_priority", value: "Standard (two weeks)" }); 127 data.push({ name: "Core_assignedTo", value: "queue:Reference_queue" }); 128 129 // assign Core field: type 130 let typeField = ".container #inputFormPage1 #Core_type"; 131 let typeValue = ""; 132 let typeValueText = ""; 133 if ($(typeField).length > 0 && $(typeField).val()) { 134 typeValue = $(typeField).val(); 135 typeValueText = $(typeField).select2("data")[0].text.trim(); 136 } else { 137 typeValueText = "Information Request"; 138 } 139 data.push({ name: "Core_type", value: typeValue }); 140 141 // assign Core field question : Submit a Research Question - Information Request - datetime 142 let question = "Submit a research question - " + typeValueText; 143 data.push({ name: "Core_question", value: question }); 144 145 // set API keys to Illumin server 146 data.push({ name: "APIserver", value: illuminServer }); 147 148 //console.log(data); 149 150 postFormAjax(illuminAPIPostScript, data); 151 152 return false; 153 }; 154 155 $(document).ready(function () { 156 // test for illumin connectivity 157 illuminTest(illuminServer, illuminAPIPostScript); 158 159 // update email description 160 $(".container #inputFormPage1 .email-desc").text( 161 "(E-mail is the main way we will share the results with you, so please ensure it is accurate.)" 162 ); 163 164 $("#reviewOther_Reason").hide(); 165 $("#reviewOther_Education_Level").hide(); 166 167 activateTab(1); 168 169 // closing required Core_clientCode select2 170 $(".container #inputFormPage1 #Core_clientCode").on("select2:closing", function () { 171 $(this).closest("div").addClass("was-validated"); 172 if (!$(this).val()) { 173 $(this).closest(".form-group").removeClass("no-error").addClass("has-error"); 174 } else { 175 $(this).closest(".form-group").removeClass("has-error").addClass("no-error"); 176 } 177 }); 178 179 // closing required Reason select2 180 $(".container #inputFormPage2 #Reason").on("select2:closing", function () { 181 $(this).closest("div").addClass("was-validated"); 182 if (!$(this).val()) { 183 $(this).closest(".form-group").removeClass("no-error").addClass("has-error"); 184 } else { 185 $(this).closest(".form-group").removeClass("has-error").addClass("no-error"); 186 } 187 }); 188 189 $(".container #inputFormPage2 #Reason").on("select2:select select2:unselecting", function () { 190 if ($(this).select2("data")[0].text.toLowerCase() == "other") { 191 $("#otherReasonInfo").addClass("show").removeClass("collapse"); 192 $("#reviewOther_Reason").show(); 193 194 $(".container input[name='Other_Reason']").prop("required", true).focus(); 195 } else { 196 $("#otherReasonInfo").removeClass("show").addClass("collapse"); 197 $("#reviewOther_Reason").hide(); 198 199 $(".container input[name='Other_Reason']").val("").removeAttr("required"); 200 $(".container input[name='Other_Reason']").closest("div").removeClass("was-validated"); 201 } 202 }); 203 204 $(".container #inputFormPage2 #Education_Level").on("select2:select select2:unselecting", function () { 205 if ($(this).select2("data")[0].text.toLowerCase() == "other") { 206 $("#otherEducationInfo").addClass("show").removeClass("collapse"); 207 $("#reviewOther_Education_Level").show(); 208 209 $(".container input[name='Other_Education_Level']").prop("required", true).focus(); 210 } else { 211 $("#otherEducationInfo").removeClass("show").addClass("collapse"); 212 $("#reviewOther_Education_Level").hide(); 213 214 $(".container input[name='Other_Education_Level']").val("").removeAttr("required"); 215 $(".container input[name='Other_Education_Level']").closest("div").removeClass("was-validated"); 216 } 217 }); 218 219 $.fn.select2.amd.require(["select2/compat/matcher"], function (oldMatcher) { 220 // match from start, Core_clientCode 221 $(".container #inputFormPage1 #Core_clientCode").select2({ 222 width: "100%", 223 placeholder: "Select a patron type", 224 allowClear: true, 225 data: clientCodes, 226 dropdownPosition: "below", 227 matcher: oldMatcher(select2MatchStart), 228 language: { 229 noResults: function () { 230 return '<span class="invalid-feedback show">Patron type not found.</span>'; 231 }, 232 }, 233 escapeMarkup: function (markup) { 234 return markup; 235 }, 236 }); 237 238 // match from start, Core_type 239 $(".container #inputFormPage1 #Core_type").select2({ 240 width: "100%", 241 placeholder: "Select a request type", 242 allowClear: true, 243 data: types, 244 dropdownPosition: "below", 245 matcher: oldMatcher(select2MatchStart), 246 language: { 247 noResults: function () { 248 return '<span class="invalid-feedback show">Request type not found.</span>'; 249 }, 250 }, 251 escapeMarkup: function (markup) { 252 return markup; 253 }, 254 }); 255 256 // match from start, Reason 257 $(".container #inputFormPage2 #Reason").select2({ 258 width: "100%", 259 placeholder: "Select a reason for your request", 260 allowClear: true, 261 data: reasons, 262 dropdownPosition: "below", 263 matcher: oldMatcher(select2MatchStart), 264 language: { 265 noResults: function () { 266 return '<span class="invalid-feedback show">Reason not found.</span>'; 267 }, 268 }, 269 escapeMarkup: function (markup) { 270 return markup; 271 }, 272 }); 273 274 // match from start, Education_Level 275 $(".container #inputFormPage2 #Education_Level").select2({ 276 width: "100%", 277 placeholder: "Select your education level", 278 allowClear: true, 279 data: educations, 280 dropdownPosition: "below", 281 matcher: oldMatcher(select2MatchStart), 282 language: { 283 noResults: function () { 284 return '<span class="invalid-feedback show">Education Level not found.</span>'; 285 }, 286 }, 287 escapeMarkup: function (markup) { 288 return markup; 289 }, 290 }); 291 }); 292 }); 293}
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.