1// function previewImage(event) { 2// var input = event.target; 3// var preview = document.getElementById('profile-preview'); 4 5// if (input.files && input.files[0]) { 6// var reader = new FileReader(); 7 8// reader.onload = function (e) { 9// preview.src = e.target.result; 10// } 11 12// reader.readAsDataURL(input.files[0]); 13// } 14// } 15 16$(document).ready(function () { 17 $(".selectBox").each(function () { 18 var $this = $(this), 19 firstVal = $this.find(".selectOption:eq(0)").text(); 20 var selectedOption = getUrlParameter('speaker_theme'); 21 22 // Set the selected option based on the query parameter or current user's taxonomy term 23 if (selectedOption) { 24 setSelectBox(selectedOption); 25 } else { 26 // AJAX request to retrieve user posts 27 $.ajax({ 28 url: ajax_params.ajaxurl, 29 type: 'post', 30 data: { 31 action: 'get_user_posts' 32 }, 33 success: function (response) { 34 var userPosts = JSON.parse(response); 35 if (userPosts.length > 0) { 36 var userPost = userPosts[0]; 37 if (userPost.terms && userPost.terms.length > 0) { 38 var userTerm = userPost.terms[0].name; 39 if (userTerm) { 40 setSelectBox(userTerm); 41 } else { 42 setSelectBox(firstVal); 43 } 44 } else { 45 setSelectBox(firstVal); 46 } 47 } else { 48 setSelectBox(firstVal); 49 } 50 }, 51 error: function (xhr, ajaxOptions, thrownError) { 52 console.log(thrownError); 53 } 54 }); 55 } 56 57 // Set the selected option and update the UI 58 function setSelectBox(val) { 59 // Remove the "selected" class from all options 60 $this.find(".selectOption").removeClass("selected"); 61 62 // Set the "selected" class to the new selected option 63 $this.find(".selectOption").each(function () { 64 if ($(this).text() == val) { 65 $(this).addClass("selected"); 66 } 67 }); 68 69 // Update the selected option variable 70 selectedOption = val; 71 72 // Update the speaker tag links with the selected option 73 $('.speaker-tag').each(function () { 74 var href = $(this).attr('href'); 75 href = href.split('?')[0]; 76 href += (href.indexOf('?') === -1) ? '?' : '&'; 77 href += 'speaker_theme=' + val; 78 $(this).attr('href', href); 79 }); 80 81 // Update the UI 82 $this.find(".selectBoxTop .selected").text(val); 83 84 // Show/hide div based on user's selection 85 if (val == 'Select event') { 86 $('.three-col-img').hide(); 87 } else { 88 $('.three-col-img').show(); 89 } 90 } 91 92 // Show/hide drop down 93 $this.find(".selectBoxTop").bind("click", function () { 94 if (!$(".selectOptions").is(":visible")) { 95 $(".selectOptions").slideDown(100); 96 $('html, body').animate({ scrollTop: '+=150px' }, 800); 97 } else { 98 $(".selectOptions").slideUp(100); 99 $('html, body').animate({ scrollTop: '-=150px' }, 800); 100 } 101 }); 102 103 // Set selected value 104 $this.find(".selectOption").bind("click", function () { 105 var val = $(this).text(); 106 setSelectBox(val); 107 $(".selectOptions").slideUp(); 108 }); 109 }); 110 111 function getUrlParameter(name) { 112 var urlParams = new URLSearchParams(window.location.search); 113 return urlParams.get(name); 114 } 115 116 117 118 119 120}); 121$(document).ready(function () { 122 const inputElement = document.getElementById("profile-pic"); 123 const cropperModal = document.getElementById("cropModal"); 124 const croppedImageElement = document.getElementById("croppedImage"); 125 let cropper = null; 126 127 if (inputElement) { 128 inputElement.addEventListener("change", () => { 129 const file = inputElement.files[0]; 130 const reader = new FileReader(); 131 const allowedExtensions = ['png', 'jpg', 'jpeg']; 132 const fileExtension = file.name.split('.').pop().toLowerCase(); 133 134 $('.error-msg').remove(); 135 $('#profile-pic').removeClass('error'); 136 $('#profile-pic').closest(".input-wrapp").removeClass('input-wrapp-error'); 137 138 139 if (!allowedExtensions.includes(fileExtension)) { 140 $('#profile-pic').addClass('error'); 141 $('#profile-pic').closest(".input-wrapp").addClass('input-wrapp-error'); 142 $('.custom-upload-label').after('<div class="error-msg">Please upload a PNG, JPG, or JPEG file</div>'); 143 inputElement.value = ''; // Reset the file input element 144 return; 145 } 146 147 // Check if file size is less than 1MB 148 if (file.size > 1000000) { 149 $('#profile-pic').addClass('error'); 150 $('#profile-pic').closest(".input-wrapp").addClass('input-wrapp-error'); 151 $('.custom-upload-label').after('<div class="error-msg">Please upload a file under 1MB</div>'); 152 inputElement.value = ''; 153 return false; 154 } 155 156 reader.onload = () => { 157 croppedImageElement.src = reader.result; 158 croppedImageElement.onload = () => { 159 const { width, height } = croppedImageElement; 160 const aspectRatio = (width === 270 && height === 300) ? 1.0 : width / height; 161 162 cropperModal.style.display = "block"; 163 if (cropper !== null) { 164 cropper.destroy(); 165 } 166 cropper = new Cropper(croppedImageElement, { 167 aspectRatio, 168 viewMode: 2, // Set the default view mode to "crop" 169 }); 170 document.getElementById("cropButton").addEventListener("click", (event) => { 171 event.preventDefault(); 172 const canvas = cropper.getCroppedCanvas({ 173 width: 270, 174 height: 300, 175 fillColor: '#fff', 176 }); 177 const croppedUrl = canvas.toDataURL("image/jpeg"); 178 document.getElementById("previewImage").src = croppedUrl; 179 cropperModal.style.display = "none"; 180 }); 181 } 182 };
183 reader.readAsDataURL(file); 184 }); 185 // Close the cropper modal when the user clicks the close button 186 document.getElementsByClassName("close")[0].addEventListener("click", () => { 187 cropperModal.style.display = "none"; 188}); 189 } 190}); 191 192 193 194 195 196// jQuery(document).ready(function($) { 197// $('input[type="radio"]').click(function() { 198// $('html, body').animate({scrollTop:0}, 'slow'); 199// }); 200// }); 201 202 203jQuery(document).on('gform_post_render', function (event, form_id, current_page) { 204 //add gravity form jquery code here 205 // Disable data-scroll-dir-y on radio buttons 206 // jQuery('#choice_7_3_1').on('click', function (e) { 207 // //e.preventDefault(); 208 // jQuery('html').attr('data-scroll-dir-y', '1'); 209 // console.log('Clicked!'); 210 // }); 211 212 jQuery(document).ready(function ($) { 213 214 // $('#gform_fileupload_7_25').on('change', function() { 215 // var files = $(this).prop('files'); 216 // var validFiles = []; 217 // var invalidFiles = []; 218 // for (var i = 0; i < files.length; i++) { 219 // var filename = files[i].name; 220 // if (filename.indexOf('Emirates_ID') === 0) { 221 // validFiles.push(files[i]); 222 // } else { 223 // invalidFiles.push(files[i]); 224 // } 225 // } 226 // if (invalidFiles.length > 0) { 227 // var errorMessage = 'Please ensure all uploaded files have names starting with "Emirates_ID".'; 228 // $('#gform_multifile_upload_7_25').append('<div class="error-message">' + errorMessage + '</div>'); 229 // // remove invalid files from file preview 230 // $(this).val(''); 231 // $('#gform_preview_7_25 .ginput_preview').empty(); 232 // for (var j = 0; j < validFiles.length; j++) { 233 // var file = validFiles[j]; 234 // var fileName = file.name; 235 // var fileExtension = fileName.split('.').pop().toLowerCase(); 236 // $('#gform_preview_7_25 .ginput_preview').append('<div class="ginput_preview"><span class="ginput_file">' + fileName + '</span></div>'); 237 // } 238 // } else { 239 // $('#gform_multifile_upload_7_25 .error-message').remove(); 240 // } 241 // }); 242 243 // $('#gform_submit_button_7').on('click', function(event) { 244 // console.log('submit'); 245 // var filename = $('#input_7_28').val().split('\\').pop(); // Replace "input_7_28" with the ID of your file upload field 246 // console.log('filename:', filename); 247 // console.log(filename.indexOf('Emirates_ID')); 248 // if (filename.indexOf('Emirates_ID') === 0) { 249 // $('.ginput_container_fileupload').find('.error-message').remove(); 250 // } else { 251 // console.log('else'); 252 // var errorMessage = 'Please ensure the uploaded file has a name starting with "Emirates_ID".'; 253 // $('.ginput_container_fileupload').append('<div class="error-message">' + errorMessage + '</div>'); 254 // event.preventDefault(); // prevent form submission 255 // } 256 // }); 257 // function readURL(input) { 258 259 // if (input.files && input.files[0]) { 260 // var reader = new FileReader(); 261 // jQuery(".custom-file-input-wrap .gform-field-label").append('<div id="custom-upload-text"><img src=""></div>'); 262 // reader.onload = function (e) { 263 // jQuery('#custom-upload-text>img').attr('src', e.target.result); 264 // } 265 266 // reader.readAsDataURL(input.files[0]); 267 // } 268 // } 269 // jQuery("input[type=file]").change(function () { 270 271 // readURL(this); 272 // }); 273 274 // image upload 275 // $(".custom-file-input-wrap .gform-field-label").append('<span id="custom-upload-text"></span>'); 276 // $("input[type=file]").change(function (e) { 277 // $(this).parents(".speaker-gf-input").find("#custom-upload-text").text(e.target.files[0].name); 278 // }); 279 $(".ginput_container_fileupload .gform_fileupload_rules").append('<span id="custom-upload-text"></span>'); 280 $("input[type=file]").change(function (e) { 281 $(this).parents(".speaker-gf-input").find("#custom-upload-text").text(e.target.files[0].name); 282 });
283 284 //jQuery('#choice_7_3_0').prop('checked', true); 285 // Get the selected value (if any) and set the first option as default only if no option is selected 286 var selectedValue = $('input[name="input_3"]:checked').val(); 287 if (!selectedValue) { 288 $('input[name="input_3"]:first').prop('checked', true); 289 } 290 291 292 293 // Update the selectedValue variable when the user selects a different option 294 $('input[name="input_3"]').change(function () { 295 selectedValue = $(this).val(); 296 }); 297 298 // Set the selected option as checked after the form is submitted, if there is a validation error 299 if (selectedValue) { 300 $('input[name="input_3"][value="' + selectedValue + '"]').prop('checked', true); 301 } 302 303 }); 304 305}); 306
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.