PageSourceSearch

https://account.pubcoder.com/login/scripts.js

js pubcoder.com collected 2026-10-01 13:13:57 UTC 5,285 bytes, 161 lines download raw bytes

1$(document).ready(function(){
2  $('#formsignin').submit(function(e){ e.preventDefault(); doLogin(); });
3  $('#form-createaccount').click(function(e){ doCreateAccount(); });
4  $('#form-forgotpassword').click(function(e){ requestPasswordReset(); });
5  enableForm();
6});
7
8function disableForm() {
9  $("#form-login").prop('disabled', true);
10  $("#form-createaccount").prop('disabled', true);
11  $("#form-forgotpassword").prop('disabled', true);
12  $("#form-message-dialog").removeClass("in");
13}
14
15function enableForm() {
16  $("#form-forgotpassword").button('reset');
17  $("#form-login").prop('disabled', false);
18  $("#form-forgotpassword").prop('disabled', false);
19  $("#form-createaccount").prop('disabled', false);
20}
21
22function requestPasswordReset() {
23  var uid = $('#form-uid').val();
24
25  if (uid=="") {
26    displayMessage("info", "Please enter your email address and click 'Forgot Password' to request a password reset.<br/>We will send you an email with further instructions.");
27    return;
28  }
29
30  var myLadda = Ladda.create(document.querySelector("#form-forgotpassword"));
31  myLadda.start();
32  disableForm();
33
34  $.ajax({
35    url: '../pubcoderapi/ajaxCall.php',
36    data: JSON.stringify ({"method":"requestPasswordReset", "params":[uid],"id":1} ),
37    dataType: "json",
38    type:"POST"
39  })
40  .done(function(msg) {
41    if (msg["error"] == null) {
42      displayMessage("success", "A request to reset your password was sent successfully.<br/>We have sent you an email with further instructions.");
43    } else {
44      displayMessage("danger", msg["error"])
45    }
46  })
47  .fail(function() {
48    displayMessage("danger", "An unexpected error occurred");
49  })
50  .always(function() {
51    myLadda.stop()
52    enableForm();
53  });
54}
55
56function doLogin() {
57  var myLadda = Ladda.create(document.querySelector("#form-login"));
58  myLadda.start();
59  disableForm();
60
61  var uid = $('#form-uid').val();
62  var passwd = $('#form-password').val();
63  // alert(uid + " " + passwd);
64  // alert(JSON.stringify ({"method":'webLogin', "params":["aaa","bbb"],id:"1"} ));
65  $.ajax({
66    url: '../pubcoderapi/ajaxCall.php',
67    data: JSON.stringify ({"method":"webLogin", "params":[uid,passwd],"id":1} ),
68    dataType: "json",
69    type:"POST"
70  })
71  .done(function(msg) {
72    // alert(JSON.stringify(msg));
73    // alert(msg["error"]);
74    if (msg["error"] == null) {
75      var loginInfo = msg["result"]
76      $.cookie("sessionid", loginInfo["sessionid"], { path: '/'});
77      $.cookie("orgid", loginInfo["identityOrgID"], { path: '/'});
78      $.cookie("uid", uid, { path: '/'});
79      $.cookie("identityOrgID", loginInfo["identityOrgID"], { path: '/'});
80      var destHref = "../dashboard/";
81      if ($.cookie("joinOrgToken") && $.cookie("joinOrgName")) {
82        destHref = "../join-organization/?orgname=" + encodeURIComponent($.cookie("joinOrgName")) + "&token=" + encodeURIComponent($.cookie("joinOrgToken"));
83      } else if (getURLParameters("goto")) {
84        destHref = ".." + getURLParameters("goto");
85      }
86      window.location.href = destHref;
87    } else {
88      displayMessage("danger", msg["error"])
89      enableForm();
90    }
91  })
92  .fail(function(jqXHR, textStatus, errorThrown) {
93    var errorMsg = "An unexpected error occurred";
94    if (jqXHR.status == 429) {
95      errorMsg = "Too many failed login attempts, please retry in a few minutes.";
96    } else if (jqXHR.status != 200) {
97      errorMsg = errorMsg + " (" + jqXHR.status + ")";
98    }
99    displayMessage("danger", errorMsg);
100  })
101  .always(function() {
102    myLadda.stop()
103    enableForm();
104  });
105}
106
107function doCreateAccount() {
108  var destHref = '../create-account/';
109  if (getURLParameters("goto")) {
110    destHref += "?goto=" + getURLParameters("goto");
111    if (getURLParameters("token")) {
112      destHref += "&" + getURLParameters("token");
113    }
114  }
115  //alert(destHref);
116  window.location.href=destHref;
117}
118
119function displayMessage(dialogClass, msg) {
120  if (dialogClass == "danger") msg = "<strong>Error </strong>" + msg;
121  $("#form-message").html(msg);
122  $("#form-message-dialog").css("display", "block");
123  $("#form-message-dialog").removeClass("alert-success");
124  $("#form-message-dialog").removeClass("alert-info");
125  $("#form-message-dialog").removeClass("alert-warning");
126  $("#form-message-dialog").removeClass("alert-danger");
127  $("#form-message-dialog").addClass("alert-" + dialogClass);
128  $("#form-message-dialog").addClass("in");
129}
130
131function getURLParameters(paramName) 
132{
133    var sURL = window.document.URL.toString();  
134    if (sURL.indexOf("?") > 0)
135    {
136       var arrParams = sURL.split("?");         
137       var arrURLParams = arrParams[1].split("&");      
138       var arrParamNames = new Array(arrURLParams.length);
139       var arrParamValues = new Array(arrURLParams.length);     
140       var i = 0;
141       for (i=0;i<arrURLParams.length;i++)
142       {
143        var sParam =  arrURLParams[i].split("=");
144        arrParamNames[i] = sParam[0];
145        if (sParam[1] != "")
146            arrParamValues[i] = unescape(sParam[1]);
147        else
148            arrParamValues[i] = "";
149       }
150
151       for (i=0;i<arrURLParams.length;i++)
152       {
153                if(arrParamNames[i] == paramName){
154            //alert("Param:"+arrParamValues[i]);
155                return arrParamValues[i];
156             }
157       }
158       return "";
159    }
160
161}

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.