1(function ($) { 2 'use strict'; 3 4 /** 5 * All of the code for your admin-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 32 jQuery(document).ready(function ($) { 33 34 jQuery('form[name="sssm_login_form"]').on('submit', function (event) { 35 36 const sssm_login_form = jQuery('form[name="sssm_login_form"]'); 37 const redirectInput = sssm_login_form.find('input[name="redirect_to"]'); 38 const redirectValue = redirectInput.val(); 39 const form_action = sssm_login_form.attr('action'); 40 41 if (form_action == myAjax.ajaxurl) { 42 43 event.preventDefault(); 44 $.ajax({ 45 type: "POST", 46 url: myAjax.ajaxurl, 47 data: $(this).serialize(), 48 success: function (response) { 49 50 if (response.success) { 51 52 var action_url = response.data.action.replace(/regist/ig, "area"); 53 let final_url = action_url; 54 55 // Regexp that match regXXX url 56 const regex = /\/\/reg+[0-9]{1,}/i; 57 // Get regex word 58 const regWord = action_url.match(regex); 59 60 // If found word 61 if (regWord) { 62 // Replace reg by area 63 const replacedArea = regWord.toString().replace(/reg/i, 'area'); 64 65 // Replace final regex by replacedArea 66 final_url = action_url.replace(regex, replacedArea); 67 } 68 // Create a new form 69 const newForm = document.createElement('form'); 70 newForm.setAttribute('method', 'post'); 71 newForm.setAttribute('action', final_url); 72 73 // Create hidden input for uuid 74 const uuidInput = document.createElement('input'); 75 uuidInput.type = 'hidden'; 76 uuidInput.name = 'uuid'; 77 uuidInput.value = response.data.uuid; 78 79 // Create hidden input for action value 80 const actionInput = document.createElement('input'); 81 actionInput.type = 'hidden'; 82 actionInput.name = 'action'; 83 actionInput.value = response.data.value; 84 85 // Append hidden inputs to the form 86 newForm.appendChild(uuidInput); 87 newForm.appendChild(actionInput); 88 89 // Append the form to the body (optional) 90 document.body.appendChild(newForm); 91 92 // Submit the new form 93 newForm.submit(); 94 } else { 95 window.location.href = redirectValue; 96 } 97 } 98 }); 99 100 } 101 }); 102 }); 103 104 105 $(function () { 106 107 const login_form = jQuery('form[name="sssm_login_form"]'); 108 109 if (login_form.length > 0 && login_form.attr('action')) { 110 var action_url = login_form.attr('action').replace(/regist/ig, "area"); 111 let final_url = action_url; 112 113 // Regexp that match regXXX url 114 const regex = /\/\/reg+[0-9]{1,}/i; 115 // Get regex word 116 const regWord = action_url.match(regex); 117 118 // If found word 119 if (regWord) { 120 // Replace reg by area 121 const replacedArea = regWord.toString().replace(/reg/i, 'area'); 122 123 // Replace final regex by replacedArea 124 final_url = action_url.replace(regex, replacedArea); 125 } 126
127 jQuery('form[name="sssm_login_form"]').attr('action', final_url); 128 } 129 }); 130})(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.