PageSourceSearch

https://iniwedding.com/h/index.js?_=v102

js iniwedding.com collected 2026-10-07 23:56:44 UTC 10,187 bytes, 269 lines download raw bytes

1let __firstSdkVersion = null;
2const __development = false;
3(function () {
4    $(document).ready(function () {
5        app();
6    });
7
8    function getHostForApp() {
9        if (__development || localStorage.getItem('runtime-dev')) {
10            /* 개발 버전 */
11            return {
12                mainHost: "http://purple.jungli.net/test/fair/ini-integrate/www",
13                /* 개발자별로 지정한 dist 폴더에서 화면 소스를 불러온다. */
14                distHost: localStorage.getItem('runtime-dev-url') || "http://purple.jungli.net/test/fair/ini-integrate/www/dist",
15                sdkHost: "http://purple.jungli.net/test/picktalk/www/dist",
16            }
17        }else {
18            /* 배포 버전 */
19            return {
20                mainHost: "https://iniwedding.com/h",
21                sdkHost: "https://initalk-sdk.iniwedding.com",
22            }
23        }
24    }
25
26    function getHostForWeb() {
27        const host = window.location.host;
28        const hostName = window.location.hostname;
29
30        /* 외부 링크 연동 */
31        var params = getUrlParams();
32        if(params.TID2) {
33            window.TID2 = params.TID2;
34        }
35        if(params.p_name) {
36            window.location.weblinkPageName = params.p_name;
37            
38            /**
39             * 구) 페이지 데이터를 JSON으로 받아서 실행
40             * 노출되는 url이 URL인코딩 되어있어 눈으로 해석하기 함듬
41             */
42            if(params.p_data) {
43                try{
44                    window.location.weblinkPageData = JSON.parse(decodeURIComponent(params.p_data));
45                }catch(e){
46                    console.error('웹링크 데이터가 JSON 폼이 아닙니다');
47                }
48                // delete params.p_data;
49            }
50            /**
51             * 신) 페이지 데이터를 파라미터로 받아서 실행
52             * 페이지 데이터는 파라미터 키에서 prefix가 "d_"로 시작하는 파라미터 키의 데이터를 사용
53             * 예:
54             * - 아이니웨딩 소개 > 아이니뉴스룸 URL : p_name=introduce&d_tabName=newsroom
55             * - 페이지이름: introduce / 페이지데이터: tabName=newsroom
56             */
57            else {
58                let pageData = {};
59                Object.keys(params).filter((key)=>key.indexOf('d_') != -1).forEach((key)=>pageData[key.split('d_')[1]] = params[key]);
60                window.location.weblinkPageData = pageData;
61            }
62        }
63
64        
65        /* 메인 서버 */
66        if(hostName.indexOf('iniwedding.com') != -1) {
67            var customUrlParams = $.extend(params, {});
68            history.pushState(null, null, `?${decodeURIComponent($.param(customUrlParams))}`);
69            return {
70                mainHost: "./",
71                sdkHost: "https://initalk-sdk.iniwedding.com"
72            };
73        } 
74        /* dev 웹 서버 */
75        else if(hostName.indexOf('m-v2-dev.') != -1) {
76            var customUrlParams = $.extend(params, {});
77            history.pushState(null, null, `?${decodeURIComponent($.param(customUrlParams))}`);
78            return {
79                mainHost: "",
80                sdkHost: "https://initalk-sdk.iniwedding.com"
81            };
82        } 
83        /* 테스트 서버 */
84        else {
85            /* 디버그모드 추가 */
86            var customUrlParams = $.extend(params, {
87                mode: "debug",
88            });
89            history.pushState(null, null, `?${decodeURIComponent($.param(customUrlParams))}`);
90
91            /* 과거 스냅샷 */
92            if(params.sdk) {
93                return {
94                    mainHost: `https://file1.iniwedding.com/fair/integrate/sdk/${params.sdk}`,
95                    sdkHost: "http://purple.jungli.net/test/picktalk/www/dist",
96                };
97            }
98
99            /* 내부 테스트 */
100            if(hostName.indexOf("purple") != -1) {
101                return {
102                    mainHost: "http://purple.jungli.net/test/fair/ini-integrate/www",
103                    sdkHost: "http://purple.jungli.net/test/picktalk/www/dist",
104                }
105            }
106
107            /* 도커 테스트 */
108            if(host.indexOf("localhost:9712") != -1) {
109                return {
110                    mainHost: "/ini-integrate/www",
111                    sdkHost: "http://purple.jungli.net/test/picktalk/www/dist",
112                };
113            }
114
115            /* npm 테스트 */
116            if(hostName.indexOf("localhost") != -1 || hostName.indexOf("192.168.22") != -1) {
117                return {
118                    mainHost: "",
119                    sdkHost: "http://purple.jungli.net/test/picktalk/www/dist",
120                };
121            }
122        }
123        
124    }
125
126    function app() {
127        const hostInfo = window.cordova ? getHostForApp() : getHostForWeb();;
128        const host = hostInfo.mainHost;
129        /* 별도 dist 주소가 없으면 기존 호스트 하위의 dist를 사용한다. */
130        const distHost = hostInfo.distHost || `${host}/dist`;
131        const sdkHost = hostInfo.sdkHost;
132
133        const prepareEl = $("#prepare");
134        const dotsEl = prepareEl.find(".dots");
135        const offset = ($(window).height() / 2) - 13;
136        if(window.cordova) {
137            if (cordova.platformId == "android") {
138                dotsEl.css("bottom", `${offset}px`);
139            } else if (cordova.platformId == "ios") {
140                dotsEl.css("top", `${offset}px`);
141            }
142        }else {
143            dotsEl.css("top", `${offset}px`);
144        }
145        dotsEl.css("opacity", "1");
146
147        requestVersion().then(function (versionInfo) {
148            if (!versionInfo) {
149                console.error("서버에서 SDK 버전을 가져올 수 없습니다.");
150            }
151            const sdkVersion = versionInfo ? versionInfo.sdk_version : "000000";
152            __firstSdkVersion = sdkVersion;
153
154            const templateUrl = makeUrl(`${distHost}/app-sdk.template.html`, sdkVersion);
155
156            const sdkJsUrl = makeUrl(`${sdkHost}/picktalk-sdk.min.js`, sdkVersion);
157            const sdkCssUrl = makeUrl(`${sdkHost}/picktalk-sdk.min.css`, sdkVersion);
158
159            const appJsUrl = makeUrl(`${distHost}/app-sdk.min.js`, sdkVersion);
160            const appCssUrl = makeUrl(`${distHost}/app-sdk.min.css`, sdkVersion);
161
162            /* 스타일과 템플릿은 병렬로 받고, 둘 다 준비된 뒤 앱 스크립트를 실행한다. */
163            Promise.all([
164                styleLoader([sdkCssUrl, appCssUrl]),
165                htmlLoader(templateUrl),
166            ])
167                .then(function () {
168                    scriptLoader([sdkJsUrl, appJsUrl])
169                        .then(function () {
170                            $("#app").css("opacity", "1");
171                            setTimeout(function () {
172                                prepareEl.fadeOut(100, function () {});
173                            }, 800);
174                        })
175                        .catch(function (error) {
176                            console.error("error in Script Loader", error);
177                        });
178                })
179                .catch(function (error) {
180                    console.error("error in Resource Loader", error);
181                });
182        });
183    }
184    function styleLoader(cssList) {
185        let promises = [];
186        $.each(cssList, function (i, cssUrl) {
187            promises.push(cssLoader(cssUrl));
188        });
189        return Promise.all(promises);
190    }
191
192    function scriptLoader(jsList) {
193        return jsList.reduce(function (prom, nextUrl) {
194            return prom.then(function () {
195                return jsLoader(nextUrl);
196            });
197        }, Promise.resolve());
198    }
199
200    function htmlLoader(url) {
201        return new Promise(function (res, rej) {
202            $("#app").load(url, function (response, status, xhr) {
203                if (status == "error") {
204                    console.error("html Load : 오류가 있습니다");
205                    rej(response, status, xhr);
206                    return;
207                }
208                res();
209            });
210        });
211    }
212    function makeUrl(url, version) {
213        return url + "?_=" + version;
214    }
215    function jsLoader(url) {
216        return new Promise(function (res, rej) {
217            $.getScript(url).done(res).fail(rej);
218        });
219    }
220    function cssLoader(url) {
221        return new Promise(function (res) {
222            var link = document.createElement("link");
223            link.rel = "stylesheet";
224            link.type = "text/css";
225            link.href = url;
226            link.onload = res;
227            link.onerror = function () {
228                /* 스타일 실패가 앱 전체 실행을 막지 않도록 기존 동작처럼 계속 진행한다. */
229                console.error("error in CSS Loader", url);
230                res();
231            };
232            document.head.appendChild(link);
233        });
234    }
235
236    function requestVersion() {
237        return new Promise(function (res, rej) {
238            $.ajax("https://m-admin.iniwedding.com/api3/integrate/version", {
239                type: "get",
240                dataType: "json",
241                jsonp: "callback",
242                contentType: "application/json; charset=utf-8",
243                cache: false,
244                beforeSend: function (request) {
245                    request.setRequestHeader("Accept", "application/json");
246                    request.setRequestHeader("Content-Type", "application/json");
247                },
248                success: function (oRes, sStatus, oXHR) {
249                    if (oRes.isSuccess) {
250                        res(oRes.data);
251                    } else {
252                        res(null);
253                    }
254                },
255                error: function (xhr, status, error) {
256                    res(null);
257                },
258            });
259        });
260    }
261
262    function getUrlParams() {
263        var params = {};
264        window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (str, key, value) {
265            params[key] = value;
266        });
267        return params;
268    }
269})();

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.