PageSourceSearch

https://signin.optionc.com/assets/js/pages/email-username-set-up-f…P1UqFCP0Q-KtLE_HM0BxKbrKTHMgijHxvGePOij73kk

js optionc.com collected 2026-10-03 22:32:37 UTC 12,864 bytes, 292 lines download raw bytes

1/*=========================================================================================
2  File Name: email-username-set-up-function.js
3  Description: Preferred Email Function
4  ----------------------------------------------------------------------------------------
5  Project Name: OptionC Sign In
6  Version: 1.0 
7==========================================================================================*/
8var availableTags;
9var OptionCBaseURL = '';
10var FamilyPortalBaseURL = '';
11$(document).ready(function () {
12    OptionCBaseURL = MySettings.OptionCBaseURL;
13    FamilyPortalBaseURL = MySettings.FamilyPortalBaseURL;
14    availableTags = loaddata();
15    const params = new URLSearchParams(window.location.search)
16    var signinlater = atob(params.get('Signup'));
17    if (signinlater == "Yes") {
18        $("#btnOldLogin").text("Sign in");
19    } else {
20        $("#btnOldLogin").text("set up");
21    }
22});
23$(".btn-ok").click(function () {
24    $("#dvEmailWarningEmailSetup").modal("hide");
25})
26
27function autocompletedata() {
28    loaddata();
29    var availableTags = loaddata();
30    $("#txtSchoolCode").autocomplete({
31        source: availableTags
32    });
33}
34function loaddata() {
35    var BaseUrl = MySettings.APIBaseURL;
36    var SchoolSearchData = [];
37    var SerachDetailsUrl = ($("#txtSchoolCode").val() == "") ? "154" : $("#txtSchoolCode").val();
38    var settings = {
39        "url": BaseUrl + "CLogin/SchoolSearh?prefix=" + SerachDetailsUrl,
40        "method": "GET",
41        "timeout": 0,
42    };
43    $.ajax(settings).done(function (response) {
44        for (var i = 0; i < response.data.length; i++) {
45            SchoolSearchData.push(response.data[i].organizationID + ' - ' + response.data[i].organizationName + " (" + response.data[i].orgCity + ", " + response.data[i].orgState + ")");
46        }
47    });
48    console.log(SchoolSearchData);
49    return SchoolSearchData;
50}
51
52
53$(function () {
54    var NoResultsLabel = "No Results";
55    var results = '';
56    $("#txtSchoolCode").keyup(function () {
57        $("#txtSchoolCode").autocomplete({
58            source: function (request, response) {
59                results = $.ui.autocomplete.filter(availableTags, request.term);
60                if (!results.length) {
61                    results = [NoResultsLabel];
62                    ShowToastr('Please enter valid school ID.', 'Sign In', 'error');
63                }
64
65                response(results);
66            },
67            select: function (event, ui) {
68                if (ui.item.label === NoResultsLabel) {
69                    event.preventDefault();
70                }
71            },
72            focus: function (event, ui) {
73                if (ui.item.label === NoResultsLabel) {
74                    event.preventDefault();
75                }
76            }
77        });
78    });
79});
80
81$("body").on('click', '.show-password-username-setup', function () {
82    $(".show-password-username-setup i").toggleClass("fa-eye-slash fa-eye");
83    var input = $("#PassWord");
84    if (input.attr("type") === "password") {
85        input.attr("type", "text");
86    } else {
87        input.attr("type", "password");
88    }
89
90});
91function CheckSubmitAndValidateInputs() {
92    
93    if ($('#frmEmailSetUp').valid()) {
94        AuthorizeSetUpEmail();
95    }
96    else {
97    }
98}
99
100function isEmail(email) {
101    var EmailRegex = /^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
102    return EmailRegex.test(email);
103}
104var SetupUserID = 0, SetupUserflag = 0, SetupUserName = null;
105function AuthorizeSetUpEmail() {
106    var EmailId = $("#UserName").val();
107    var PassWord = $("#PassWord").val();
108    var data = $('#txtSchoolCode').val();
109    var arr = data.split('-');
110    const params = new URLSearchParams(window.location.search)
111    var signinlater = params.get('Signup');//atob(params.get('Signup'));
112
113
114    EmailId = EmailId.replace(/#/g, '♥');
115    EmailId = EmailId.replace(/\*/g, '♦');
116    EmailId = EmailId.replace(/&/g, '*');
117    EmailId = EmailId.replace(/\+/g, '♠');
118    EmailId = EmailId.replace(/\?/g, '☻');
119
120    PassWord = PassWord.replace(/#/g, '♥');
121    PassWord = PassWord.replace(/\*/g, '♦');
122    PassWord = PassWord.replace(/&/g, '*');
123    PassWord = PassWord.replace(/\+/g, '♠');
124    PassWord = PassWord.replace(/\?/g, '☻');
125
126
127    var isTokenExpected = 0;
128    if (signinlater == "Yes") {
129        isTokenExpected = 1;
130    } else {
131
132        isTokenExpected = 0;
133
134    }
135    if (EmailId != "" && PassWord != "" && data != "") {
136        var BaseUrl = MySettings.OPTIONCAPIBaseURL;
137
138        var url = BaseUrl + "CLogin/Login?EmailId=" + EmailId + "&password=" + PassWord + "&orgid=" + arr[0] + "&isTokenExpected=" + isTokenExpected;
139
140        $.ajax({
141            type: "GET",
142            dataType: 'JSON',
143            url: url,
144            success: function (response) {
145                
146                if (response.result.code == 0 && response.result.message == "Success") {
147
148                    if ((response.data[0].roleId == 3 || response.data[0].userRole == "student") && response.data[0].signInAccess == '0') {
149                        $("#dvEmailWarningEmailSetup").modal("show");
150                        $("#pEmailWarningSetup").text("You do not have sign in access to OptionC.");
151                    } else {
152                        if (signinlater == "Yes") {
153                            if (response.data[0].isFeeAccess == 1) {
154
155                                if (response.data[0].isStripeEnabled == 1) {
156                                    window.location.replace(OptionCBaseURL + "/auto-login?token=" + response.data[0].token);
157                                }
158                                else {
159                                    if (response.data[0].userRole == "parent" || response.data[0].userRole == "student" || response.data[0].userRole == "Relative" || response.data[0].roleId == 3) {
160                                        if (response.data[0].signInAccess == '0') {
161                                            $("#dvEmailWarningEmailSetup").modal("show");
162                                            $("#pEmailWarningSetup").text("You do not have sign in access to OptionC.");
163                                        } else {
164                                            window.location.replace(FamilyPortalBaseURL + "/auto-login?token=" + response.data[0].token)
165                                        }
166                                    }
167                                    else {
168                                        window.location.replace(OptionCBaseURL + "/auto-login?token=" + response.data[0].token);
169                                    }
170
171                                }
172
173                            } else {
174
175                                if (response.data[0].isStripeEnabled == 1) {
176                                    window.location.replace(OptionCBaseURL + "/auto-login?token=" + response.data[0].token);
177                                }
178                                else {
179                                    if (response.data[0].userRole == "parent" || response.data[0].userRole == "student" || response.data[0].userRole == "Relative" || response.data[0].roleId == 3) {
180                                        if (response.data[0].signInAccess == '0') {
181                                            $("#dvEmailWarningEmailSetup").modal("show");
182                                            $("#pEmailWarningSetup").text("You do not have sign in access to OptionC.");
183                                        } else {
184                                            window.location.replace(FamilyPortalBaseURL + "/auto-login?token=" + response.data[0].token)
185                                        }
186                                    }
187                                    else {
188
189                                        window.location.replace(OptionCBaseURL + "/auto-login?token=" + response.data[0].token);
190                                    }
191
192                                }
193                            }
194                        } else {
195                            var Email1 = isEmail(response.data[0].cLoginEmailId);
196                            if (Email1 == true && response.data[0].registered == 0) {
197                                $("#dvEmailWarningEmailSetup").modal("show");
198                                $("#pEmailWarningSetup").text("You have already set up your username as an email address. Please sign in using your email address.");
199                                EmailId = btoa(response.data[0].cLoginEmailId);
200                                setTimeout(function () {
201
202                                   // window.location.replace("/email-signin?Email=" + EmailId)
203                                   // window.location.replace("/email-signin");
204                                    $(".overlay-form").hide();
205                                    $("#frmEmailSetUp").hide();
206                                    $("#frmLogin")[0].reset();
207                                    $("#frmLogin").show();
208                                    $("#frmLogin #txtEmail").val(response.data[0].cLoginEmailId);
209                                }, 3000);
210                            } else {
211
212                                //window.location.replace("/preferred-email?UserID=" + btoa(response.data[0].userID) + "&flag=2&UserName=" + response.data[0].lastName + "," + response.data[0].firstName)
213                                $('#frmEmailSetUp').hide();
214                                $('#frmPreferredEmail').show();
215                                $('.overlay-form').show();
216                                $('#errorEmail').remove();
217                                SetupUserID = btoa(response.data[0].userID), SetupUserflag = 2, SetupUserName = response.data[0].lastName + "," + response.data[0].firstName;
218                            }
219                        }
220                    }
221                    
222                    $("#frmEmailSetUp")[0].reset();
223                } else if (response.result.code == 1 && response.result.message == "Sign In incorrect. Please contact your school.") {
224                    $("#dvEmailWarningEmailSetup").modal("show");
225                    $("#pEmailWarningSetup").text("This username, password combination is not found. Please correct or contact your school administrator.");
226
227                } else if (response.result.code == 2 && response.result.message == "Username Not Available") {
228
229                    $("#dvEmailWarningEmailSetup").modal("show");
230                    $("#pEmailWarningSetup").text("This username, password combination is not found. Please correct or contact your school administrator.");
231                } else {
232
233                    $("#dvEmailWarningEmailSetup").modal("show");
234                    $("#pEmailWarningSetup").text(response.result.message);
235
236
237                }
238            },
239            failure: function (response) {
240                $("#dvEmailWarningEmailSetup").modal("show");
241                $("#pEmailWarningSetup").text("Oops, Something Went Wrong!");
242            },
243            error: function (response) {
244                $("#dvEmailWarningEmailSetup").modal("show");
245                $("#pEmailWarningSetup").text("Sign In incorrect. Contact your School Admin.");
246            }
247        });
248    } else {
249        ShowToastrManual('Sign In incorrect. Please check your sign in credential', 'Sign In', 'error');
250
251    }
252}
253$('#btnOldLogin').prop('disabled', true);
254$('#btnOldLogin').attr('title', 'Please check the box "I am an authorized user" to sign in');
255$('#chkAuthorizedUser2').change(function () {
256    if ($(this).is(":checked")) {
257        $('#btnOldLogin').prop('disabled', false);
258        $('#btnOldLogin').removeAttr('title')
259    } else {
260        $('#btnOldLogin').prop('disabled', true);
261        $('#btnOldLogin').attr('title', 'Please check the box "I am an authorized user" to sign in');
262    }
263
264});
265
266
267$('#termsandcondition').on('mouseenter touchstart', function () {
268    $(".info-sec").show();
269});
270
271$('#termsandcondition').on('mouseleave touchend', function () {
272    $(".info-sec").hide();
273});
274
275$("#btnresetpasswordemailformatsetup").click(function () {
276    $(".overlay-form").show(); 
277    $('#errorEmail').remove();
278    $("#frmEmailSetUp").hide();
279    $("#frmLoginFindSchool").show();
280    $("#txtFindSchoolCode").focus();
281})
282
283$('#txtSchoolCode,#UserName,#PassWord,#chkAuthorizedUser2,#btnOldLogin').keydown(function (e) {
284    if (e.keyCode === 13) {
285        $("#btnOldLogin").trigger("click")
286    }
287});
288
289function retunrnBackLogin() {
290    $(".overlay-form").hide();
291    $("#frmEmailSetUp").hide();
292}

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.