PageSourceSearch

https://apps.dekita.online/app/oauth/js/login.js?20260830

js dekita.online collected 2026-10-04 18:26:46 UTC 15,380 bytes, 406 lines download raw bytes

1/**
2 *  画面ロード時処理
3 *  初期表示
4 */
5$(function () {
6
7    //ローカルストレージ削除
8    clearLocalStrage();
9
10    // 未会員エラー表示
11    if (location.search == "?error=1") {
12        fadeError("会員情報がみつかりません");
13    }
14
15    // 登録済エラー
16    if (location.search == "?error=2") {
17        fadeError("登録済みのアカウントです");
18    }
19
20    // 生徒追加登録(管理者アカウント)
21    if (location.search == "?error=3") {
22        fadeError("管理者・スタッフアカウントです");
23    }
24
25    // スタッフ追加登録(受講者アカウント)
26    if (location.search == "?error=4") {
27        fadeError("受講者アカウントです");
28    }
29
30    // アプリ版
31    if (DEVICE !== "isWeb") {
32        $(".nonweb").css("display", "block");
33        $("#student_regist a.nonweb").css("display", "inline-block");
34    }
35
36    //パラメータ取得
37    var info_uid = getParam("id");
38
39    var uid = "";
40    var code = "";
41    var urlparam = location.search.substring(1);
42    if (urlparam) {
43        if (urlparam !== "openExternalBrowser=1") {
44            var param = urlparam.split('&');
45            var paramArray = [];
46            for (i = 0; i < param.length; i++) {
47                var paramItem = param[i].split('=');
48                paramArray[paramItem[0]] = paramItem[1];
49            }
50            var uid = paramArray.id;
51            var code = paramArray.code;
52        }
53    }
54
55    // LINEログイン
56    $(document).on("click", "#linelogin", function () {
57        var random = Math.random();
58        // ウェブの場合
59        if (!IS_APP) {
60            var lineurl = "https://access.line.me/oauth2/v2.1/authorize?response_type=code&bot_prompt=aggressive&client_id=" + CLIENT_ID + "&redirect_uri=" + APP_DOMAIN + "/ajax/oauth/line.php&state=" + random + "@none_login&scope=profile";
61            window.location.href = lineurl;
62        }
63        // アプリの場合
64        else {
65            // アプリ
66            if (window.cordova && cordova.InAppBrowser) {
67                var lineurl = "https://access.line.me/oauth2/v2.1/authorize?response_type=code&bot_prompt=aggressive&client_id=" + CLIENT_ID + "&redirect_uri=" + APP_DOMAIN + "/ajax/oauth/line.php&state=" + random + "@none_applogin&scope=profile";
68                cordova.InAppBrowser.open(lineurl, '_system', 'location=yes');
69            } else {
70                // 万が一プラグインが無い場合のフォールバック
71                var lineurl = "https://access.line.me/oauth2/v2.1/authorize?response_type=code&bot_prompt=aggressive&client_id=" + CLIENT_ID + "&redirect_uri=" + APP_DOMAIN + "/ajax/oauth/line.php&state=" + random + "@none_login&scope=profile";
72                window.location.href = lineurl;
73            }
74        }
75    });
76
77    // Appleログイン
78    var inAppBrowserRef = null;
79    var appleCallbackUrl = null;
80    var appleLoginError = false;
81    $(document).on("click", "#sign-in-with-apple-button", function () {
82
83        if (IS_APP) {
84            appleCallbackUrl = null;
85            appleLoginError = false;
86            inAppBrowserRef = cordova.InAppBrowser.open(
87                APP_DOMAIN + '/app/oauth/apple.html',
88                '_blank',
89                'location=no,footer=yes'
90            );
91
92            inAppBrowserRef.addEventListener('customscheme', function (event) {
93                if (!event.url) return;
94                // Apple認証は成功したがDEKITAアカウントがない
95                if (event.url.indexOf('appsdekita://apple_login_error') === 0) {
96                    appleLoginError = true;
97                    if (inAppBrowserRef) {
98                        inAppBrowserRef.close();
99                    }
100                    return;
101                }
102
103                // 正常ログイン
104                if (event.url.indexOf('appsdekita://') === 0) {
105                    appleCallbackUrl = event.url;
106                    if (inAppBrowserRef) {
107                        inAppBrowserRef.close();
108                    }
109                }
110            });
111
112            inAppBrowserRef.addEventListener('exit', function () {
113                inAppBrowserRef = null;
114                // Appleアカウント未登録
115                if (appleLoginError) {
116                    appleLoginError = false;
117                    alert(
118                        "このApple Accountに紐づくアカウントが見つかりません。\n" +
119                        "登録済みのログイン方法でログインしてください。"
120                    );
121                    return;
122                }
123
124                // 正常ログイン
125                if (appleCallbackUrl) {
126                    var callbackUrl = appleCallbackUrl;
127                    appleCallbackUrl = null;
128                    setTimeout(function () {
129                        handleOpenURL(callbackUrl);
130                    }, 100);
131                }
132            });
133        }
134        return;
135    });
136
137    // 通知設定クリア
138    $(document).on("click", "#push_clear", function () {
139        // アプリの場合
140        if (IS_APP) {
141            FirebasePlugin.setAutoInitEnabled(false, function () {
142                // alert("通知設定クリア");
143                FirebasePlugin.unregister();
144            });
145        }
146        return;
147    });
148
149    // 新規スクール開設
150    $(document).on("click", "#regist_newschool", function () {
151        // ウェブの場合
152        if (!IS_APP) {
153            window.open(APP_DOMAIN + '/app/onb/signup.html', "_blank");
154        }
155        // アプリの場合
156        else {
157            // アプリ
158            if (window.cordova && cordova.InAppBrowser) {
159                cordova.InAppBrowser.open(APP_DOMAIN + '/app/onb/signup.html', '_system', 'location=yes');
160            } else {
161                // 万が一プラグインが無い場合のフォールバック
162                window.open(APP_DOMAIN + '/app/onb/signup.html', "_blank");
163            }
164        }
165    });
166
167    if (uid !== "") {
168        clearLocalStrage();
169    }
170
171    /**
172     *  管理用ログイン
173     */
174    if (uid && code) {
175        $.ajax({
176            url: APP_DOMAIN + "/ajax/oauth/login.php",
177            type: "POST",
178            data: {
179                id: paramArray.id,
180                code: paramArray.code,
181                type: "manage"
182            },
183            error: function (XMLHttpRequest, textStatus, errorThrown) {
184                fadeError("送信に失敗しました");
185            },
186            success: function (arr) {
187                if (arr == "" || arr == "null") {
188                    fadeError("正しいメールアドレスとパスワードを入力してください");
189                } else {
190                    var data = $.parseJSON(arr);
191                    var kubun = data.user.kubun;
192                    //ローカルデータ更新
193                    setLocalStorage(data);
194                    if (kubun == 1 || kubun == 2) {
195                        window.location.href = "../lesson/mcalendar.html";
196                    } else {
197                        window.location.href = "../lesson/calendar.html";
198                    }
199                }
200            }
201        });
202    }
203    /**
204     *  ローカルストレージからログイン
205     */
206    else if (uid == "" && LOGIN_ID !== "" && TOKEN !== "") {
207        $.ajax({
208            url: APP_DOMAIN + "/ajax/oauth/login.php",
209            type: "POST",
210            data: {
211                school_id: selected_school_id,
212                login_id: LOGIN_ID,
213                localtoken: TOKEN,
214                type: "local"
215            },
216            error: function (XMLHttpRequest, textStatus, errorThrown) {
217                fadeError("送信に失敗しました");
218            },
219            success: function (arr) {
220                if (arr == "") {
221                    fadeError("正しいメールアドレスとパスワードを入力してください(LOCAL)");
222                } else {
223                    var data = $.parseJSON(arr);
224                    var kubun = data.user.kubun;
225                    //ローカルデータ更新
226                    setLocalStorage(data);
227                    //お知らせ詳細へ
228                    if (info_uid !== null) {
229                        var transition = "../info/detail.html?id=" + info_uid;
230                    }
231                    //カレンダーへ
232                    else {
233                        if (kubun == 1 || kubun == 2) {
234                            if (location.search == "?cd=reopen") {
235                                var transition = "../lesson/mcalendar.html?d=reopen";
236                            } else {
237                                var transition = "../lesson/mcalendar.html";
238                            }
239                        } else {
240                            var transition = "../lesson/calendar.html";
241                        }
242                    }
243                    // ウェブの場合
244                    if (!IS_APP) {
245                        window.location.href = transition;
246                    }
247                    // アプリの場合
248                    else {
249                        // アプリ
250                        if (window.cordova && cordova.InAppBrowser) {
251                            setTimeout(function () {
252                                registFirebaseToken(data.user.login_
252id, data.user.kubun, DEVICE, 0)
253                                    .then(() => ssoRedirect(data.user.login_id, data.user.passcode, transition));
254                            }, 1000);
255                        } else {
256                            // 万が一プラグインが無い場合のフォールバック
257                            window.location.href = transition;
258                        }
259                    }
260                }
261            }
262        });
263    }
264
265    var flg = true;
266    $(document).on("click", "button", function () {
267        if (flg) {
268            flg = false;
269            setTimeout(function () {
270                flg = true;
271            }, 5000);
272        }
273    });
274
275    //メールアドレスでログイン
276    var disableFlag = true;
277    $(document).on("click", "#mailadr", function () {
278        if (disableFlag) {
279            disableFlag = false;
280            $("form").show();
281            setTimeout(function () {
282                disableFlag = true;
283            }, 3000);
284        }
285    });
286
287    /**
288     *  ログイン認証
289     */
290    $("form").validate({
291        rules: {
292            email: {
293                required: true,
294                email: true
295            },
296            password: {
297                required: true,
298                pwcheck: true,
299                minlength: 6
300            }
301        },
302        messages: {
303            email: {
304                required: "メールアドレスを入力してください",
305                email: "正しいメールアドレスを入力してください"
306            },
307            password: {
308                required: "パスワードを入力してください",
309                pwcheck: "パスワードは半角英数字で入力してください",
310                minlength: "パスワードは6文字以上入力してください"
311            }
312        },
313        submitHandler: function () {
314
315            //重複登録防止
316            $("input[type='submit']").prop("disabled", true);
317            $("#loading").show();
318
319            var $form = $("form");
320            var data = $form.serialize();
321
322            $.ajax({
323                url: APP_DOMAIN + "/ajax/oauth/login.php",
324                type: "POST",
325                data: data + "&type=form&school_id=" + selected_school_id,
326                error: function (XMLHttpRequest, textStatus, errorThrown) {
327                    //重複登録解除
328                    $("input[type='submit']").prop("disabled", false);
329                    $("#loading").hide();
330                    fadeError("送信に失敗しました");
331                },
332                success: function (arr) {
333                    if (arr == "noexist" || arr == "") {
334                        //重複登録解除
335                        $("input[type='submit']").prop("disabled", false);
336                        $("#loading").hide();
337                        fadeError("正しいメールアドレスとパスワードを入力してください(FORM)");
338                    } else if (arr == "nomember") {
339                        var data = $.parseJSON(arr);
340                        var kubun = data.user.kubun;
341                        //ローカルデータ更新
342                        setLocalStorage(data);
343                        window.location.href = "../lesson/calendar.html";
344                    } else {
345                        var data = $.parseJSON(arr);
346                        var school = data.school;
347                        var kubun = data.user.kubun;
348
349                        //ローカルデータ更新
350                        setLocalStorage(data);
351
352                        if (data.school && data.school.length > 0) {
353                            //お知らせ詳細へ
354                            if (info_uid !== null) {
355                                var transition = "../info/detail.html?id=" + info_uid;
356                            }
357                            //カレンダーへ
358                            else {
359                                if (kubun == 1 || kubun == 2) {
360                                    if (location.search == "?cd=reopen") {
361                                        var transition = "../lesson/mcalendar.html?d=reopen";
362                                    } else {
363                                        var transition = "../lesson/mcalendar.html";
364                                    }
365                                } else {
366                                    var transition = "../lesson/calendar.html";
367                                }
368                            }
369                        }
370                        //所属なし
371                        else {
372                            var transition = "../member/detail.html";
373                        }
374
375                        // ウェブの場合
376                        if (!IS_APP) {
377                            window.location.href = transition;
378                        }
379                        // アプリの場合
380                        else {
381                            // アプリ
382                            if (window.cordova && cordova.InAppBrowser) {
383                                registFirebaseToken(data.user.login_
383id, data.user.kubun, DEVICE, 0)
384                                    .then(() => ssoRedirect(data.user.login_id, data.user.passcode, transition));
385                            } else {
386                                // 万が一プラグインが無い場合のフォールバック
387                                window.location.href = transition;
388                            }
389                        }
390                    }
391                }
392            });
393        }
394    });
395
396    //パスワード確認
397    $.validator.addMethod("pwcheck", function (value, element) {
398        return /^[A-Za-z0-9\d=!\-@._*]+$/.test(value);
399    });
400
401});
402
403function exitCallBack() {
404    clearLocalStrage();
405    window.location.href = "login.html";
406}

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.