PageSourceSearch

https://ddangya.com/assets/js/AppInterface.js

js ddangya.com collected 2026-10-01 14:17:19 UTC 8,468 bytes, 279 lines download raw bytes

1/**
2 * request application function from web
3 */
4
5var AppInterface = function () {
6
7    var self = this;
8    /* check webview */
9    this.isWebView = function () {
10        try {
11            if (appHandler) {
12                return true;
13            }
14            return false;
15        } catch (err) {
16            return false;
17        }
18    }
19
20    /* fallback share for PC */
21    this.sharePC = function (stitle, body, storelink) {
22        if (navigator.share) {
23            navigator.share({
24                title: stitle,
25                url: body
26            }).then(() => {
27            })
28                .catch(console.error);
29        } else {
30            location.href = storelink;
31        }
32    }
33
34    /* Connects app based sharing */
35    this.shareApp = function (title, body, storelink) {
36        try {
37            appHandler.openShareActivity(title, body);
38            return true;
39        }
40        catch (err) {
41            this.sharePC(title, body, storelink);
42        }
43    }
44
45    /* Connects app based sharing for Kakao */
46    this.shareAppWithKakao = function (title, body, storelink) {
47        try {
48            appHandler.openShareKakaoActivity(title, body);
49            return true;
50        }
51        catch (err) {
52            this.sharePC(title, body, storelink);
53        }
54    }
55
56    /* Opens phone-app with given number */
57    this.openCallApp = function (phonenumber) {
58        try {
59            appHandler.openPhoneActivity(phonenumber);
60            return true;
61        }
62        catch (err) {
63            return false;
64        }
65    }
66
67
68    /* Uploads given file */
69    this.uploadImage = function (filename) {
70        try {
71            appHandler.imageUploadToGivenPath(filename);
72            return true;
73        }
74        catch (err) {
75            return false;
76        }
77    }
78
79
80    /* Opens navigation application using given location info */
81    this.openMapApp = function (latitude, longitude) {
82        try {
83            appHandler.openMapActivity(latitude, longitude);
84            return true;
85        }
86        catch (err) {
87            return false;
88        }
89    }
90
91    /* Force reload of the current webview */
92    this.reloadWebview = function () {
93        try {
94            appHandler.webpageReload();
95            return true;
96        }
97        catch (err) {
98            return false;
99        }
100    }
101
102    /* Gets the current user location from app */
103    this.getAppLocation = function () {
104        try {
105
106            appHandler.getLocation();
107            return true;
108
109        } catch (err) {
110
111
112            var startPos;
113            var geoOptions = {
114                enableHighAccuracy: true
115            }
116
117            var geoSuccess = function (position) {
118                startPos = position;
119                window.setLocation(startPos.coords.latitude, startPos.coords.longitude);
120            };
121            var geoError = function (error) {
122                console.log('Error occurred. Error code: ' + error.code);
123            };
124
125            navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions);
126
127            return false;
128        }
129
130    }
131
132    /* Changes application tab index */
133    this.moveTab = function (idx) {
134        try {
135            appHandler.onClicked(idx);
136            return true;
137        }
138        catch (err) {
139            return false;
140        }
141    }
142
143    /* Emits exit signal to application using log message */
144    this.onBeforeExitApp = function () {
145        console.log("beforeExitApp");
146    }
147
148    /* Emits exit signal to application using log message */
149    this.onBeforeExitWeb = function (canback) {
150        console.log("beforeExitWebview canback:" + canback);
151    }
152
153    /* Emits exit signal to application using log message */
154    this.appStatusChanged = function (canback) {
155    }
156
157    /* Checks whethen the app alarm is set or not */
158    this.appHandlerAreNotificationsEnabled = function () {
159        try {
160            appHandler.isNotificationEnabled();
161
162        } catch (err) { }
163    }
164
165    /* Calls the setting page of application so that the user can set the alarm enabling */
166    this.appHandlerOpenSettingApp = function () {
167        try {
168            appHandler.openSettingApp();
169
170        } catch (err) { }
171    }
172
173    this.appHandlerOpenInAppPurchase = function (sku) {
174        try {
175            appHandler.openInAppPurchase(sku);
176
177        }
178        catch (err) {
179            console.log("appHandlerOpenInAppPurchase ERRPR " + sku);
180        }
181    }
182    this.appHandlerGetSubUserStatus = function (sku) {
183        try {
184            appHandler.getSubStatus(sku);
185
186        }
187        catch (err) {
188            console.log("appHandlerGetSubUserStatus ERRPR " + sku);
189        }
190    }
191
192
193    // 사용자 약관 동의 완료 이벤트 전송
194    //
195    // - 사용자 약관 동의 시점을 앱에 알리는데 사용중
196    this.userTermAgreed = function (agreementId) {
197        try {
198            if (window.webkit.messageHandlers && window.webkit.messageHandlers.userTermHandler) {
199                window.webkit.messageHandlers.userTermHandler.postMessage({
200                    agreementId: agreementId || '3252452452',
201                    timestamp: new Date().getTime()
202                });
203                return true;
204            }
205            return false;
206        } catch (error) {
207            console.error('안드로이드 사용자 약관 동의 이벤트 전송 실패:', error);
208            return false;
209        }
210    }
211
212    // =====================================
213    // *** 블랫폼 로그인 관련 이벤트 11/05 추가 ***
214    // =====================================
215
216
217    this.sendDisplayNativeLoginView = function () {
218        try {
219            if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.showNativeLoginViewHandler) {
220                window.webkit.messageHandlers.showNativeLoginViewHandler.postMessage({
221                    action: 'showNativeLoginView'
222                });
223                return true;
224            } else {
225                return false;
226            }
227        } catch (error) {
228            console.error('안드로이드 네이티브 로그인 뷰 띄우기 실패:', error);
229            return false;
230        }
231    }
232
233    // 로그인 완료 이벤트 전송
234    // @param token - JWT 토큰
235    // @param loginType - 로그인 타입 ('blatform', 'kakao', 'apple')
236    // @param uid - 사용자 ID (블랫폼 로그인의 경우 암호화된 사용자 ID)
237    // @param password - 암호화된 비밀번호 (블랫폼 로그인 시에만 전송, 서버에서 네트워크 키로 암호화됨)
238    this.sendLoginCompleteEvent = function (token, loginType, uid, password) {
239        try {
240            if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.loginCompleteHandler) {
241                const message = {
242                    token: token,
243                    loginType: loginType,
244                    uid: uid
245                };
246
247                // password는 옵셔널 (이메일 로그인 시에만 전송, 암호화된 상태)
248                if (password) message.password = password;
249
250                window.webkit.messageHandlers.loginCompleteHandler.postMessage(message);
251                return true;
252            } else {
253                return false;
254            }
255        } catch (error) {
256            return false;
257        }
258    }
259}
260
261// 안드로이드 WebView에서 직접 호출하는 전역 함수
262// 앱 상태 변경 시 호출됨 (예: 화면 회전, 폴더블 기기 접기/펼치기 등)
263function appStatusChanged() {
264    // 현재는 빈 함수이지만, 필요시 여기에 로직 추가 가능
265    console.log('appStatusChanged called');
266}
267
268// 안드로이드 WebView에서 이미지 업로드 완료 시 호출하는 전역 함수
269// Android ImgUploadActivity에서 업로드 성공 후 javascript:imgUploadCompleted('파일명') 실행
270function imgUploadCompleted(pImgName) {
271    console.log('IMG Upload Completed: ' + pImgName);
272
273    // CustomEvent를 발생시켜 upload-image 컴포넌트에 알림
274    const event = new CustomEvent('imageUploadCompleted', {
275        detail: { imageName: pImgName }
276    });
277    window.dispatchEvent(event);
278}
279

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.