1// Content-Type: application/javascript 2// Define variables 3let eventType, buffet, bar, danceFloor, stage, cocktailTables, djTable, cakeTable, sweetheartTable, giftTable, weatherConsiderations; 4let dimensions = { 5 // Default dimensions (in square feet) (test dimensions) (include buffer for walkways) 6 buffet: 100, 7 bar: 50, 8 danceFloor: 225, // 15x15 9 stage: 150, //15x10 10 cocktailTable: 16, // per table no chairs 11 djTable: 40, 12 cakeTable: 30, 13 sweetheartTable: 25, 14 giftTable: 20, 15 seatingTable: 55, //seatingtable is an 8' rectangle with 10 chairs. 16 chair: 5, // found a person in a chair is usually 2'3" x 2'3" 17}; 18// Get form elements by id 19const numberOfGuests = document.getElementById("guests"); 20const eventTypeInput = document.getElementById("eventType"); 21const TableSizeInput = document.getElementById("table_sizes"); 22const weatherConsiderationsInput = document.getElementById("weather-considerations"); 23const selectElement = document.getElementById("<?php echo $this->get_field_id('items'); ?>"); 24 25 26function extractAreaValues() { 27 if (selectElement) { 28 const options = selectElement.options; 29 for (let i = 0; i < options.length; i++) { 30 const optionsValue = options[i].value; 31 const splitValue = optionsValue.split('-'); 32 if (splitValue.length > 1) { 33 const areaValue = splitValue[1]; 34 console.log(areaValue); 35 } 36 } 37 } 38} 39 40 41// Function to handle the navigation between steps 42function nextStep(step){ 43 44 45 46 // Add conditional input field for tables or chairs 47 48 if (step === 3) { 49 var numberOfGuests = document.getElementById("numberOfGuests"); 50 if (numberOfGuests.value === '' || numberOfGuests.value < 1) { 51 alert("Please enter the number of guests."); 52 return; 53 } 54 addConditionalInput(); 55 } 56 var conditionalInput; 57 if (step === 4) { 58 var eventType = document.getElementById("eventType"); 59 if (eventType.value === "Default") { 60 alert("Please choose an event type."); 61 return; // Stop here and don't proceed to next step 62 } 63 if (eventType.value === "cocktail") { 64 conditionalInput = document.getElementById("numCocktailTables"); 65 } 66 else if (eventType.value === "ceremony") { 67 conditionalInput = document.getElementById("numberChairs"); 68 } 69 else if (eventType.value === "Dinner" || eventType.value === "Dinner") { 70 conditionalInput = document.getElementById("numSeatingTables"); 71 } 72 if (conditionalInput && (conditionalInput.value === '' || conditionalInput.value < 1)) { 73 alert("Please enter a valid number."); 74 return; // Stop here and don't proceed to next step 75 } 76 } 77 78 79 80 81 82 let steps= document.getElementsByClassName("steps"); 83 for (let i = 0; i < steps.length; i++) { 84 steps[i].style.display="none"; 85 } 86 let targetStepElement = document.getElementById("step_" + step); 87 if (targetStepElement){ 88 targetStepElement.style.display = "block"; 89 if (step >=2) { 90 document.getElementById('progressTracker').style.display = 'flex'; 91 updateProgressTracker(step - 1); 92 } else { 93 document.getElementById('progressTracker').style.display = 'none'; // Hide progress tracker 94 } 95 } else { 96 nextStep(step + 1); 97 } 98 99} 100function showSelectedOptions() { 101 $('#checkboxDiv').html(''); // Clear the checkboxDiv area first 102 $('#myDropdown :selected').each(function(i, selected) { 103 // For each selected option, create a corresponding checkbox 104 $('#checkboxDiv').append( 105 '<label><input type="checkbox" value="' + $(selected).val() + '" checked>' + $(selected).text() + '</label><br>' 106 ); 107 }); 108} 109function updateProgressTracker(step) { 110 // Reset all steps 111 for (let i = 1; i <= 6; i++) { // Assuming 3 steps, adjust as needed 112 document.getElementById(`stepProgress${i}`).classList.remove('active'); 113 document.getElementById(`stepProgress${i}`).classList.remove('completed'); 114 } 115 116 // Set previous steps as completed 117 for (let i = 1; i < step; i++) { 118 document.getElementById(`stepProgress${i}`).classList.add('completed'); 119 } 120 121 // Set current step as active 122 document.getElementById(`stepProgress${step}`).classList.add('active'); 123} 124 125// Function to dynamically add an input for tables or chairs based on the event type 126function addConditionalInput() { 127 const eventType = document.getElementById("eventType").value; 128 const step4 = document.getElementById("step_3"); 129 130 // Clear previous conditional input if any 131 const oldConditionalInput = document.getElementById("conditionalInput"); 132 if (oldConditionalInput) { 133 oldConditionalInput.remove(); 134 } 135 136 // Create a new div to hold the conditional input 137 const conditionalInput = document.createElement("div"); 138 conditionalInput.id = "conditionalInput"; 139 140 // Create label and input based on eventType 141 let label = document.createElement("label"); 142 let input = document.createElement("input"); 143 input.type = "number"; 144 input.min = "1"; 145 146 if (eventType === "cocktail") { 147 label.innerHTML = "Tall tables with no chairs<br>Enter the number of cocktail tables:";
148 input.id = "numCocktailTables"; 149 input.name = "numCocktailTables"; 150 } else if (eventType === "ceremony") { 151 label.innerHTML = "Chairs arranged in rows <br>Enter number of chairs for Ceremony seating:"; 152 input.id = "numberChairs"; 153 input.name = "numChairs"; 154 } else if (eventType === "Dinner") { 155 // First ask for number of table size 156 const tableSizeQuestion = document.createElement("div"); 157 tableSizeQuestion.id = "tableSizeQuestion"; 158 let tableSizeDropdownHTML = '<label for="tableSize">Select table size: </label><select id="tableSize"><option value="">Please Select</option>'; 159 // Dynamically add options based on tableOptions 160 for (const [size, area] of Object.entries(table_Sizes)) { 161 tableSizeDropdownHTML += `<option value="${size}">${size} (${area} sq ft)</option>`; 162 } 163 tableSizeDropdownHTML += '</select>'; 164 tableSizeQuestion.innerHTML = tableSizeDropdownHTML; 165 conditionalInput.appendChild(tableSizeQuestion); 166 step4.appendChild(conditionalInput); 167 168 169 document.getElementById("tableSize").addEventListener("change", function() { 170 addNumberOfTablesInput(this.value); 171 }) 172 }else { 173 return; // Do not add any conditional input for other event types 174 } 175 176 // Append elements to div for cocktail and ceremony types 177 if (eventType === "cocktail" || eventType === "ceremony") { 178 conditionalInput.appendChild(label); 179 conditionalInput.appendChild(document.createElement("br")); 180 conditionalInput.appendChild(input); 181 } 182 if (eventType !== "Dinner") { 183 step4.appendChild(conditionalInput); 184 } 185} 186function resetCalculator() { 187 // Reset form values 188 document.getElementById("guest-form").reset(); 189 190 // Hide all steps except the first one 191 let steps = document.getElementsByClassName("steps"); 192 for (let i = 0; i < steps.length; i++) { 193 steps[i].style.display = "none"; 194 } 195 document.getElementById("step_1").style.display = "block"; 196 document.getElementById('progressTracker').style.display = 'none'; 197 // Hide the result display 198 document.getElementById("resultDisplay").style.display = "none"; 199 updateProgressTracker(1); 200} 201 202function addNumberOfTablesInput(tableSize) { 203 const conditionalInput = document.getElementById("conditionalInput"); 204 const oldNumberOfTablesInput = document.getElementById("numberOfTablesInput"); 205 if (oldNumberOfTablesInput) { 206 oldNumberOfTablesInput.remove(); 207 } 208 209 const numberOfTablesDiv = document.createElement("div"); 210 numberOfTablesDiv.id = "numberOfTablesInput"; 211 212 const label = document.createElement("label"); 213 label.innerHTML = `Enter the number of ${tableSize} tables:`; 214 const input = document.createElement("input"); 215 input.type = "number"; 216 input.min = "1"; 217 input.id = "numTables"; 218 input.name = "numTables"; 219 console.log("Input for 'numTables' created with ID:", input.id); 220 221 numberOfTablesDiv.appendChild(label); 222 numberOfTablesDiv.appendChild(document.createElement("br")); 223 numberOfTablesDiv.appendChild(input); 224 225 conditionalInput.appendChild(numberOfTablesDiv); 226} 227function addCocktailTableInput() { 228 const isChecked = document.getElementById("cocktailTables").checked; 229 const step4 = document.getElementById("step_4"); 230 231 // Remove the existing cocktail tables input if present 232 const oldInput = document.getElementById("cocktailTablesInput"); 233 if (oldInput) { 234 oldInput.remove(); 235 } 236 237 if (isChecked) { 238 // Create a new div to hold the input for the number of cocktail tables 239 const cocktailTablesInput = document.createElement("div"); 240 cocktailTablesInput.id = "cocktailTablesInput"; 241 242 // Create a label and input field 243 let label = document.createElement("label"); 244 label.innerText = "Enter the number of cocktail tables:"; 245 246 let input = document.createElement("input"); 247 input.type = "number"; 248 input.min = "1"; 249 input.id = "numCocktailTablesInput"; 250 input.name = "numCocktailTablesInput"; 251 252 // Append elements to div 253 cocktailTablesInput.appendChild(label); 254 cocktailTablesInput.appendChild(document.createElement("br")); 255 cocktailTablesInput.appendChild(input); 256 257 // Append the new input div to step 4 258 step4.appendChild(cocktailTablesInput); 259 } 260} 261 262 263 264// Function to calculate tent size 265function CalculateButton() { 266 // You can call as many functions as you want here 267 var emailValid = verifyEmail(); // assuming verifyEmail returns true if the email is valid 268 269 if(emailValid){ 270 calculateTentSize(); 271 if (TentSubmitURL) { 272 jQuery.ajax({ 273 url : TentSubmitURL, 274 data : {email : document.getElementById("userEmail").value} 275 }) 276 }; 277 } 278} 279function verifyEmail() { 280 var email = document.getElementById("userEmail").value; 281 var regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // Simple regex to validate email 282 if (email.length < 1 || !regex.test(email)) { 283 alert("Please enter a valid email address."); 284 return false; // Invalid email 285 } else { 286 return true; // Valid email 287 } 288} 289 290 291function calculateTentSize() { 292 // Get input values 293 let totalArea = 0; 294 let totalTableArea = 0; 295 let numGuestsElement = document.getElementById("numberOfGuests"); 296 let numGuests = numGuestsElement ? parseInt(numGuestsElement.value) : 0; 297 const checkboxes = document.querySelectorAll('input[type="checkbox"][id^="item_"]'); 298 299 if (isNaN(numGuests)) { 300 alert("Please enter a valid number for the number of guests."); 301 return; // Stop execution if input is not a number 302 } 303 eventType = document.getElementById("eventType").value; 304 weatherConsiderationsElement = document.getElementById("weatherConsiderations"); 305 weatherConsiderations = weatherConsiderationsElement ? weatherConsiderationsElement.checked : false;
306 AdditionalItems = document.querySelectorAll('.item-checkbox'); 307 let cocktailTables = parseInt(document.getElementById("eventType").value) || 0; 308 checkboxes.forEach(function(AdditionalItems) { 309 console.log(AdditionalItems.id + ' is ' + (AdditionalItems.checked ? 'checked' : 'not checked')); 310 if(AdditionalItems.checked) { 311 let area = AdditionalItems.id.split('-')[1]; // Split the id string by '-' and take the second part 312 if(area) { // Check if area exists to avoid adding undefined or NaN 313 totalArea += parseInt(area); // Parse area to integer and add to totalArea 314 } 315 } 316 }); 317 let tentPrices = { 318 "10x10": 50, // $50 per hour 319 "10x20": 70, // $70 per hour 320 "20x20": 100, // $100 per hour 321 "20x30": 130, // $130 per hour 322 "30x30": 160, // $160 per hour 323 }; 324 325 let sidewallPrice = 10; // $10 per hour/day 326 327 // Adding the area occupied by guests (assuming, 10 square feet per guest) 328 totalArea += numGuests * 8; 329 330 let includedItems = []; 331 let numChairs = 0; // Initialize to zero 332 333 // Adding area based on different elements 334 335 336 //console.log(totalArea) 337 if (buffet) { 338 totalArea += dimensions.buffet; 339 includedItems.push("Buffet"); 340 } 341 if (bar) { 342 totalArea += dimensions.bar; 343 includedItems.push("Bar"); 344 } 345 if (danceFloor) { 346 totalArea += dimensions.danceFloor; 347 includedItems.push("Dance Floor"); 348 } 349 if (stage) { 350 totalArea += dimensions.stage; 351 includedItems.push("Stage"); 352 } 353 if (djTable) { 354 totalArea += dimensions.djTable; 355 includedItems.push("DJ Table"); 356 } 357 if (cakeTable) { 358 totalArea += dimensions.cakeTable; 359 includedItems.push("Cake Table"); 360 } 361 if (sweetheartTable) { 362 totalArea += dimensions.sweetheartTable; 363 includedItems.push("Sweetheart Table"); 364 } 365 if (giftTable) { 366 totalArea += dimensions.giftTable; 367 includedItems.push("Gift Table"); 368 } 369 370 // Adding area for cocktail tables, ceremony chairs or dinner tables 371 // depending on the eventType 372 if (eventType === 'cocktail') { 373 totalArea += cocktailTables * dimensions.cocktailTable; 374 includedItems.push("Cocktail Tables"); 375 } else if (eventType === 'ceremony') { 376 // Assuming 'numChairs' exists or defaulting to 0 377 numChairs = parseInt(document.getElementById("numberChairs").value || "0"); 378 totalArea += numChairs * dimensions.chair; 379 includedItems.push("Ceremony Chairs"); 380 } else if (eventType === 'Dinner' || eventType === 'Dinner') { 381 //Does not properly get the total table size correct 382 const tableSizeDropdown = document.getElementById("tableSize"); 383 const numSeatingTablesElement = document.getElementById("numTables"); 384 385 386 if (tableSizeDropdown && numSeatingTablesElement) { 387 const selectedTableSize = tableSizeDropdown.value; // Get selected table size (e.g., "6x2.5") 388 console.log("Selected Table Size:", selectedTableSize); 389 const numSeatingTables = parseInt(numSeatingTablesElement.value || "0"); // Get the number of seating tables 390 console.log("Number of Seating Tables:", numSeatingTables); 391 392 393 // Get the area for the selected table size from `table_Sizes` object 394 const tableArea = table_Sizes[selectedTableSize]; // Ensure `table_Sizes` is correctly populated and available 395 console.log("Area per Table:", tableArea); 396 397 if (tableArea && !isNaN(numSeatingTables)) { 398 // Calculate total area needed for the seating tables 399 totalArea += numSeatingTables * tableArea; 400 includedItems.push("Seating Tables (" + selectedTableSize + ")"); 401 totalTableArea = numSeatingTables * tableArea; 402 403 404 console.log("Selected Table Size:", selectedTableSize); 405 console.log("Number of Seating Tables:", numSeatingTables); 406 console.log("Area per Table:", tableArea); 407 console.log("Total Table Area for 'Dinner':", totalTableArea); 408 } 409 } 410 411 // Assuming 'numSeatingTables' exists or defaulting to 0 412 //let numSeatingTables = parseInt(document.getElementById("numSeatingTables").value || "0"); 413 //totalArea += numSeatingTables * dimensions.seatingTable; 414 //includedItems.push("Seating Tables"); 415 } 416 417 // Determine the tent size based on the total required area 418 if (typeof tent_sizes === 'undefined') { 419 console.error("tent_sizes is not defined!"); 420 return; 421 } 422 const sortedTents = Object.entries(tent_sizes).sort((a, b) =>
422 parseInt(a[1]) - parseInt(b[1])); 423 console.log("Sorted tents from smallest to largest:", sortedTents); 424 425 let tentSize = "Not available"; 426 let largestTentSize = sortedTents[0][0]; 427 let largestTentArea = sortedTents[0][1]; 428 let requiredArea = totalArea; 429 let extraSpaceNeeded = requiredArea - largestTentArea; 430 431 for (let [size, area] of sortedTents) { 432 console.log(`Checking tent size: ${size} with area: ${area} against required area: ${requiredArea}`); 433 434 if (area >= requiredArea) { 435 tentSize = size; 436 extraSpace = area - requiredArea; 437 break; 438 } 439 } 440 console.log(`Selected tent size: ${tentSize}`); 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 let durationType = document.getElementById("duration-type").value; 456 457 458 let dayMultiplier = 1; // This can be adjusted based on business logic. E.g., if 1 day's rent is not equal to 24 hours' rent. 459 460 if (durationType === "days") { 461 dayMultiplier = 24; // Assuming 24 hours in a day. This can be adjusted based on discounts or business rules. 462 } 463 464 465 466 if (weatherConsiderations) { 467 includedItems.push("Sidewalls"); 468 } 469 470 // Display result 471 472 let resultText = `Event Type: ${eventType}\n`; 473 474 if (tentSize === "Not available") { 475 let largestTentSize = sortedTents[sortedTents.length - 1][0]; 476 let largestTentArea = sortedTents[sortedTents.length - 1][1]; 477 let extraSpaceNeeded = requiredArea - largestTentArea; 478 resultText += `The largest available tent size is ${largestTentSize} with an area of ${largestTentArea} sq ft. You will need an extra space of ${extraSpaceNeeded} sq ft.`; 479 } else { 480 resultText += `Recommended tent size: ${tentSize}`; 481 if (extraSpace > 0) { 482 resultText += `\nExtra space in the tent: ${extraSpace} sq ft`; 483 } 484 } 485 486 if (numChairs > 0) { 487 resultText += `\nNumber of chairs: ${numChairs}`; 488 } 489 490 /*if (includedItems.length > 0) { 491 resultText += `\nIncluded items: ${includedItems.join(", ")}`; 492 }*/ 493 494 document.getElementById("resultDisplay").innerText = resultText; 495 document.getElementById("resultDisplay").style.display = "block"; 496}
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.