vendor: 111 bytes, lines 1-5
1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ var __webpack_modules__ = ({ 4 5/***/ "./
5assets/src/js/api.js": 6/*!******************************!*\ 7 !*** ./assets/src/js/api.js ***! 8 \******************************/ 9/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 10 11__webpack_require__.r(__webpack_exports__); 12/* harmony export */ __webpack_require__.d(__webpack_exports__, { 13/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) 14/* harmony export */ }); 15/** 16 * List API on backend 17 */ 18 19const lplistAPI = {}; 20if ('undefined' !== typeof lpDataAdmin) { 21 lplistAPI.admin = { 22 apiAdminNotice: lpDataAdmin.lp_rest_url + 'lp/v1/admin/tools/admin-notices', 23 apiAdminOrderStatic: lpDataAdmin.lp_rest_url + 'lp/v1/orders/statistic', 24 apiAddons: lpDataAdmin.lp_rest_url + 'lp/v1/addon/all', 25 apiAddonAction: lpDataAdmin.lp_rest_url + 'lp/v1/addon/action', 26 apiAddonsPurchase: lpDataAdmin.lp_rest_url + 'lp/v1/addon/info-addons-purchase', 27 apiSearchCourses: lpDataAdmin.lp_rest_url + 'lp/v1/admin/tools/search-course', 28 apiSearchUsers: lpDataAdmin.lp_rest_url + 'lp/v1/admin/tools/search-user', 29 apiAssignUserCourse: lpDataAdmin.lp_rest_url + 'lp/v1/admin/tools/assign-user-course', 30 apiUnAssignUserCourse: lpDataAdmin.lp_rest_url + 'lp/v1/admin/tools/unassign-user-course' 31 }; 32} 33if ('undefined' !== typeof lpData) { 34 lplistAPI.frontend = { 35 apiWidgets: lpData.lp_rest_url + 'lp/v1/widgets/api', 36 apiCourses: lpData.lp_rest_url + 'lp/v1/courses/archive-course', 37 apiAJAX: lpData.lp_rest_url + 'lp/v1/load_content_via_ajax/' 38 }; 39} 40/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI); 41 42/***/ }), 43
44/***/ "./assets/src/js/utils.js": 45/*!********************************!*\ 46 !*** ./assets/src/js/utils.js ***! 47 \********************************/ 48/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 49 50__webpack_require__.r(__webpack_exports__); 51/* harmony export */ __webpack_require__.d(__webpack_exports__, { 52/* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), 53/* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), 54/* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs), 55/* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI), 56/* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam) 57/* harmony export */ }); 58/** 59 * Fetch API. 60 * 61 * @param url 62 * @param data 63 * @param functions 64 * @since 4.2.5.1 65 */ 66const lpFetchAPI = (url, data = {}, functions = {}) => { 67 if ('function' === typeof functions.before) { 68 functions.before(); 69 } 70 fetch(url, { 71 method: 'GET', 72 ...data 73 }).then(response => response.json()).then(response => { 74 if ('function' === typeof functions.success) { 75 functions.success(response); 76 } 77 }).catch(err => { 78 if ('function' === typeof functions.error) { 79 functions.error(err); 80 } 81 }).finally(() => { 82 if ('function' === typeof functions.completed) { 83 functions.completed(); 84 } 85 }); 86}; 87 88/** 89 * Get current URL without params. 90 * 91 * @since 4.2.5.1 92 */ 93const lpGetCurrentURLNoParam = () => { 94 let currentUrl = window.location.href; 95 const hasParams = currentUrl.includes('?'); 96 if (hasParams) { 97 currentUrl = currentUrl.split('?')[0]; 98 } 99 return currentUrl; 100}; 101const lpAddQueryArgs = (endpoint, args) => { 102 const url = new URL(endpoint); 103 Object.keys(args).forEach(arg => { 104 url.searchParams.set(arg, args[arg]); 105 }); 106 return url; 107}; 108 109/** 110 * Listen element viewed. 111 * 112 * @param el 113 * @param callback 114 * @since 4.2.5.8 115 */ 116const listenElementViewed = (el, callback) => { 117 const observerSeeItem = new IntersectionObserver(function (entries) { 118 for (const entry of entries) { 119 if (entry.isIntersecting) { 120 callback(entry); 121 } 122 } 123 }); 124 observerSeeItem.observe(el); 125}; 126 127/** 128 * Listen element created. 129 * 130 * @param callback 131 * @since 4.2.5.8 132 */ 133const listenElementCreated = callback => { 134 const observerCreateItem = new MutationObserver(function (mutations) { 135 mutations.forEach(function (mutation) { 136 if (mutation.addedNodes) { 137 mutation.addedNodes.forEach(function (node) { 138 if (node.nodeType === 1) { 139 callback(node); 140 } 141 }); 142 } 143 }); 144 }); 145 observerCreateItem.observe(document, { 146 childList: true, 147 subtree: true 148 }); 149 // End. 150}; 151 152 153/***/ })
vendor: 3,542 bytes, lines 153-249
153 154 155/******/ }); 156/************************************************************************/ 157/******/ // The module cache 158/******/ var __webpack_module_cache__ = {}; 159/******/ 160/******/ // The require function 161/******/ function __webpack_require__(moduleId) { 162/******/ // Check if module is in cache 163/******/ var cachedModule = __webpack_module_cache__[moduleId]; 164/******/ if (cachedModule !== undefined) { 165/******/ return cachedModule.exports; 166/******/ } 167/******/ // Create a new module (and put it into the cache) 168/******/ var module = __webpack_module_cache__[moduleId] = { 169/******/ // no module.id needed 170/******/ // no module.loaded needed 171/******/ exports: {} 172/******/ }; 173/******/ 174/******/ // Execute the module function 175/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 176/******/ 177/******/ // Return the exports of the module 178/******/ return module.exports; 179/******/ } 180/******/ 181/************************************************************************/ 182/******/ /* webpack/runtime/define property getters */ 183/******/ (() => { 184/******/ // define getter functions for harmony exports 185/******/ __webpack_require__.d = (exports, definition) => { 186/******/ for(var key in definition) { 187/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 188/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 189/******/ } 190/******/ } 191/******/ }; 192/******/ })(); 193/******/ 194/******/ /* webpack/runtime/hasOwnProperty shorthand */ 195/******/ (() => { 196/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 197/******/ })(); 198/******/ 199/******/ /* webpack/runtime/make namespace object */ 200/******/ (() => { 201/******/ // define __esModule on exports 202/******/ __webpack_require__.r = (exports) => { 203/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 204/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 205/******/ } 206/******/ Object.defineProperty(exports, '__esModule', { value: true }); 207/******/ }; 208/******/ })(); 209/******/ 210/************************************************************************/ 211var __webpack_exports__ = {}; 212// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 213(() => { 214/*!***********************************!*\ 215 !*** ./assets/src/js/loadAJAX.js ***! 216 \***********************************/ 217__webpack_require__.r(__webpack_exports__); 218/* harmony export */ __webpack_require__.d(__webpack_exports__, { 219/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) 220/* harmony export */ }); 221/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./assets/src/js/utils.js"); 222/* harmony import */ var _api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./api */ "./assets/src/js/api.js"); 223/** 224 * Load all you need via AJAX 225 * 226 * @since 4.2.5.7 227 * @version 1.0.1 228 */ 229 230 231 232const lpAJAX = () => { 233 return { 234 autoLoadAPIs: () => { 235 console.log('autoLoadAPIs'); 236 }, 237 fetchAPI: (url, params, callBack) => { 238 const option = { 239 headers: {} 240 }; 241 if (0 !== parseInt(lpData.user_id)) { 242 option.headers['X-WP-Nonce'] = lpData.nonce; 243 } 244 if ('undefined' !== typeof params.args.method_request) { 245 option.method = params.args.method_request; 246 } else { 247 option.method = 'POST'; 248 } 249
250 //params.args = { ...params.args, ...lpData.urlParams }; 251 252 if ('POST' === option.method) { 253 option.body = JSON.stringify(params); 254 option.headers['Content-Type'] = 'application/json'; 255 } else { 256 params.args = JSON.stringify(params.args); 257 params.callback = JSON.stringify(params.callback); 258 url = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(url, params); 259 } 260 (0,_utils__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI)(url, option, callBack); 261 }, 262 getElements: () => { 263 //console.log( 'getElements' ); 264 // Finds all elements with the class '.lp-load-ajax-element' 265 const elements = document.querySelectorAll('.lp-load-ajax-element:not(.loaded)'); 266 if (elements.length) { 267 elements.forEach(element => { 268 //console.log( 'Element handing', element ); 269 element.classList.add('loaded'); 270 let url = _api__WEBPACK_IMPORTED_MODULE_1__["default"].frontend.apiAJAX; 271 if (lpData.urlParams.hasOwnProperty('lang')) { 272 url = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(url, {
273 lang: lpData.urlParams.lang 274 }); 275 } 276 const elTarget = element.querySelector('.lp-target'); 277 const dataObj = JSON.parse(elTarget.dataset.send); 278 const dataSend = { 279 ...dataObj 280 }; 281 const elLoadingFirst = element.querySelector('.loading-first'); 282 const callBack = { 283 success: response => { 284 const { 285 status, 286 message, 287 data 288 } = response; 289 if ('success' === status) { 290 elTarget.innerHTML = data.content; 291 } else if ('error' === status) { 292 elTarget.innerHTML = message; 293 } 294 }, 295 error: error => { 296 console.log(error); 297 }, 298 completed: () => { 299 //console.log( 'completed' ); 300 if (elLoadingFirst) { 301 elLoadingFirst.remove(); 302 } 303 } 304 }; 305 window.lpAJAXG.fetchAPI(url, dataSend, callBack); 306 }); 307 } 308 } 309 }; 310}; 311 312// Case 1: file JS loaded, find all elements with the class '.lp-load-ajax-element' not have class 'loaded' 313if ('undefined' === typeof window.lpAJAXG) { 314 window.lpAJAXG = lpAJAX(); 315 window.lpAJAXG.getElements(); 316} 317 318// Case 2: readystatechange, find all elements with the class '.lp-load-ajax-element' not have class 'loaded' 319document.addEventListener('readystatechange', event => { 320 //console.log( 'readystatechange' ); 321 window.lpAJAXG.getElements(); 322}); 323 324// Case 3: DOMContentLoaded, find all elements with the class '.lp-load-ajax-element' not have class 'loaded' 325document.addEventListener('DOMContentLoaded', () => { 326 window.lpAJAXG.getElements(); 327}); 328/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpAJAX); 329})(); 330 331/******/ })() 332; 333//# sourceMappingURL=loadAJAX.js.map
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.