Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor-pro/addons/auth/assets/js/change-email.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + (()=>{"use strict";var t={};/************************************************************************/// The module cache
2 + var r={};// The require function
3 + function e(o){// Check if module is in cache
4 + var a=r[o];if(a!==undefined){return a.exports}// Create a new module (and put it into the cache)
5 + var n=r[o]={exports:{}};// Execute the module function
6 + t[o](n,n.exports,e);// Return the exports of the module
7 + return n.exports}/************************************************************************/// webpack/runtime/rspack_version
8 + (()=>{e.rv=()=>"1.5.7"})();// webpack/runtime/rspack_unique_id
9 + (()=>{e.ruid="bundler=rspack@1.5.7"})();/************************************************************************/;// CONCATENATED MODULE: ./node_modules/@swc/helpers/esm/_async_to_generator.js
10 + function o(t,r,e,o,a,n,i){try{var u=t[n](i);var s=u.value}catch(t){e(t);return}if(u.done)r(s);else Promise.resolve(s).then(o,a)}function a(t){return function(){var r=this,e=arguments;return new Promise(function(a,n){var i=t.apply(r,e);function u(t){o(i,a,n,u,s,"next",t)}function s(t){o(i,a,n,u,s,"throw",t)}u(undefined)})}};// CONCATENATED MODULE: ./assets/react/lib/ajax-handler.js
11 + function n(t){return a(function*(){try{var r=yield fetch(window._tutorobject.ajaxurl,{method:"POST",body:t});return r}catch(t){tutor_toast(__("Operation failed","tutor-pro"),t,"error")}})()};// CONCATENATED MODULE: ./assets/react/utils.js
12 + /**
13 + * Converts a local date to GMT (Greenwich Mean Time).
14 + *
15 + * @param {Date} date - The local date to convert to GMT
16 + * @param {string} [dateFormat='yyyy-MM-dd HH:mm:ss'] - The format string for the output date
17 + * @returns {string} The formatted GMT date string
18 + *
19 + * @since v3.8.0
20 + */var i=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"yyyy-MM-dd HH:mm:ss";var e=t.getTimezoneOffset();var o=addMinutes(t,e);return format(o,r)};/**
21 + * Converts a GMT date to local date based on the user's timezone.
22 + *
23 + * @param {string|Date} date - The GMT date to convert to local time
24 + * @returns {Date} The converted local date object
25 + *
26 + * @since v3.8.0
27 + */var u=t=>{var r=new Date(t);var e=r.getTimezoneOffset();return addMinutes(r,-e)};/**
28 + * Validates if a string is a valid email address format.
29 + *
30 + * @param {string} email - The email string to validate
31 + * @returns {boolean} True if the email format is valid, false otherwise
32 + *
33 + * @since v3.8.1
34 + */var s=t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);/**
35 + * Creates a FormData object from a data object and automatically adds security nonce.
36 + *
37 + * @param {Object} [data={}] - The data object to convert to FormData
38 + * @returns {FormData} A FormData object with the provided data and security nonce
39 + *
40 + * @example
41 + * const formData = tutorFormData({
42 + * action: 'save_lesson_note',
43 + * lesson_id: 123,
44 + * note_text: 'My note content'
45 + * });
46 + *
47 + * @since v3.9.0
48 + */function d(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var r=new FormData;Object.keys(t).forEach(e=>r.set(e,t[e]));r.set(window.tutor_get_nonce_data(true).key,window.tutor_get_nonce_data(true).value);return r}/**
49 + * Handles AJAX requests to the WordPress admin-ajax.php endpoint.
50 + *
51 + * @param {FormData} formData - The FormData object containing the request data
52 + * @returns {Promise<Response|undefined>} The fetch Response object, or undefined if an error occurs
53 + *
54 + * @example
55 + * const formData = tutorFormData({ action: 'get_lesson_data', lesson_id: 123 });
56 + * const response = await ajaxHandler(formData);
57 + * const data = await response.json();
58 + *
59 + * @since v3.9.0
60 + */function c(t){return _async_to_generator(function*(){try{var r=yield fetch(window._tutorobject.ajaxurl,{method:"POST",body:t});return r}catch(t){tutor_toast(__("Operation failed","tutor-pro"),t,"error")}})()};// CONCATENATED MODULE: ./addons/auth/assets/react/change-email.js
61 + /**
62 + * Handle email change request from frontend dashboard.
63 + *
64 + * @since 3.8.2
65 + */var l=document.getElementById("tutor-change-email-modal");if(l){l.addEventListener("submit",t=>a(function*(){var{__}=wp.i18n;t.preventDefault();var r=l.querySelector('button[type="submit"]');var e=new FormData(t.target);var o=e.get("new_email");var a=e.get("new_email_confirmation");if(!s(o)){tutor_toast(__("Sorry","tutor-pro"),__("Please enter a valid email","tutor-pro"),"error");return}if(o!==a){tutor_toast(__("Sorry","tutor-pro"),__("New email and confirm new email do not match","tutor-pro"),"error");return}r.disabled=true;r.classList.add("is-loading");try{var i=yield n(e);var u=yield i.json();if(i.ok){tutor_toast(__("Success","tutor-pro"),u.message,"success");setTimeout(()=>window.location.reload(true),1e3)}else{tutor_toast(__("Failed","tutor-pro"),u.message,"error")}}catch(t){tutor_toast(__("Failed","tutor-pro"),t.message,"error")}finally{r.disabled=false;r.classList.remove("is-loading")}})())}})();