1const ajax = { 2 request(url, params = {}, options = {}) { 3 if (loadingBar) { 4 loadingBar.show(); // ë¡ë©ë° íì 5 } 6 7 const method = (options.method || "GET").toLowerCase(); 8 const csrfToken = document 9 .querySelector('meta[name="_csrf"]') 10 ?.getAttribute("content"); 11 const csrfHeader = document 12 .querySelector('meta[name="_csrf_header"]') 13 ?.getAttribute("content"); 14 15 const headers = { 16 "Content-Type": "application/json;charset=UTF-8", 17 "X-Requested-With": "XMLHttpRequest", 18 "X-AJAX-REQUEST": "T", 19 ...options.headers, 20 }; 21 22 if (csrfToken && csrfHeader) { 23 headers[csrfHeader] = csrfToken; 24 } 25 26 const axiosConfig = { 27 url, 28 method, 29 headers, 30 }; 31 32 if (method === "get") { 33 // GET ìì² - URLì 쿼리ì¤í¸ë§ ì¶ê° 34 const queryString = new URLSearchParams(params).toString(); 35 axiosConfig.url = queryString ? `${url}?${queryString}` : url; 36 } else if ( 37 method === "post" && 38 headers["Content-Type"] === "application/x-www-form-urlencoded" 39 ) { 40 // FORM ìì² - x-www-form-urlencoded ë°ì´í° ì²ë¦¬ 41 const formData = new URLSearchParams(params).toString(); 42 axiosConfig.data = formData; 43 } else if ( 44 method === "post" && 45 headers["Content-Type"] === "multipart/form-data" 46 ) { 47 // FILE ìì² - multipart/form-data ì²ë¦¬ 48 axiosConfig.data = params; // FormData ê°ì²´ ì ë¬ 49 } else { 50 // 기í ìì² - JSON ë°ì´í° ì²ë¦¬ 51 axiosConfig.data = params; 52 } 53 54 return axios(axiosConfig) 55 .then((response) => response.data) // ìëµ ë°ì´í°ë¥¼ ë°í 56 .catch((error) => { 57 //451 penta ìë¬ ì²ë¦¬ 58 if (error?.response?.status === 451 && error?.response?.data?.message) { 59 pentaError(error?.response?.data?.message); 60 } else if (error?.response?.status === 401) { 61 pentaAwaitAlert("ì¸ê°ëì§ ìì ìì²ì ëë¤.").then((res) => { 62 top.location.href = "/admin/login"; 63 }); 64 } else if (error?.response?.status === 403) { 65 pentaAwaitAlert("ì¸ì¦ëì§ ìì ìì²ì ëë¤.").then((res) => { 66 top.location.href = "/admin/login"; 67 }); 68 } else { 69 // ìë¬ ë©ìì§ê° ì¡´ì¬íë¤ë©´ ì¶ë ¥ 70 if (error?.response?.data?.message) { 71 // pentaError(error?.response.data.message); // ì¶ë ¥ì ê±° 72 pentaError( 73 "ìê¸°ì¹ ëª»í ì¤ë¥ê° ë°ìíìµëë¤.\nì ì í ë¤ì ìëí´ ì£¼ì¸ì.", 74 ); 75 } else { 76 let errorMessage = error.response 77 ? `HTTP Error: ${error.response.status}` 78 : "Network request failed."; 79 if (error?.message) { 80 errorMessage = errorMessage + " - " + error?.message; 81 } 82 // console.error(errorMessage); 83 // pentaError(errorMessage); 84 pentaError( 85 "ìê¸°ì¹ ëª»í ì¤ë¥ê° ë°ìíìµëë¤.\nì ì í ë¤ì ìëí´ ì£¼ì¸ì.", 86 ); 87 } 88 } 89 90 throw error; 91 }) 92 .finally(() => { 93 if (loadingBar) { 94 loadingBar.hide(); // ë¡ë©ë° ì¨ê¹ 95 } 96 }); 97 }, 98 99 // GET ìì² 100 get(url, params = {}, headers = {}) { 101 return this.request(url, params, { 102 method: "GET", 103 headers, 104 }); 105 }, 106 107 // POST ìì² 108 post(url, params = {}, headers = {}) { 109 return this.request(url, params, { 110 method: "POST", 111 headers, 112 }); 113 }, 114 115 // PUT ìì² 116 put(url, params = {}, headers = {}) { 117 return this.request(url, params, { 118 method: "PUT", 119 headers, 120 }); 121 }, 122 123 // DELETE ìì² 124 delete(url, params = {}, headers = {}) { 125 return this.request(url, params, { 126 method: "DELETE", 127 headers, 128 }); 129 }, 130 131 // FORM ìì² (x-www-form-urlencoded) 132 form(url, params = {}, headers = {}) { 133 const formHeaders = { 134 ...headers, 135 "Content-Type": "application/x-www-form-urlencoded", 136 }; 137 return this.request(url, params, { 138 method: "POST", 139 headers: formHeaders, 140 }); 141 }, 142 143 // MULTIPART ìì² 144 multipart(url, formData, headers = {}) { 145 const formHeaders = { 146 ...headers, 147 "Content-Type": "multipart/form-data", 148 }; 149 150 return this.request(url, formData, { 151 method: "POST", 152 headers: formHeaders, 153 }); 154 }, 155};
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.