From d91c5df4cdaf74fe1acb1a4b7c96036cfeb75d31 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 25 Apr 2016 19:11:53 +0000 Subject: [PATCH 1/2] Done Login page --- dec.css | 36 ++++++++++++++++++++++++++ index.html | 27 +++++++++++++++++++ makecall.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ makecall.js~ | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ tuser.jpg | Bin 0 -> 1380 bytes 5 files changed, 207 insertions(+) create mode 100644 dec.css create mode 100644 index.html create mode 100644 makecall.js create mode 100644 makecall.js~ create mode 100644 tuser.jpg diff --git a/dec.css b/dec.css new file mode 100644 index 0000000..c2857a1 --- /dev/null +++ b/dec.css @@ -0,0 +1,36 @@ +.center_box{ + width: 300px ; + height:350px ; + border-size: 2px; + border-color: green; + border-width: 2px; + border-radius: 15px; + position: absolute; + background-color: #C5CAE9; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: auto; +} + +.iparea{ + border-color: #9FA8DA; + width: 275px; +} + +.u_box{ + margin-top: 20px; +} + +.p_box{ + margin: 5px; +} + +.response{ + font-family: Comic Sans MS; +} + +.heading{ + font-family: = Comic Sans MS; +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..4b0dfb0 --- /dev/null +++ b/index.html @@ -0,0 +1,27 @@ + + + + Login Page + + + + +
+
+ +
+
+
+ +
+ +
+
+ 5 attempts left +
+
+
+ + + + \ No newline at end of file diff --git a/makecall.js b/makecall.js new file mode 100644 index 0000000..3c4a239 --- /dev/null +++ b/makecall.js @@ -0,0 +1,72 @@ +var count = 5; +var waittime = 15; + +function keyHit(){ + if (event.keyCode == 13) document.getElementById("signin").click(); // Check if Enter key (13) is pressed +} + +function myFunction(){ // On Clicking Sign-In Button + + uname = document.getElementById("username").value; // Get username + pass = document.getElementById("password").value; // Get password + + var login_params = "username=" + uname + "&password=" + pass; // Create string to send to API + var signin_button = document.getElementById("signin"); // Get the sign in button in a variable + var response = document.getElementById("status"); // This will be the success/failure notice given to user + var attempt_left = document.getElementById("attempts"); // No of attempts left + + if(uname.toString().trim().length==0 || pass.trim().length == 0){ // Ask user to retry in case of empty strings in username or password + response.innerHTML = "Both values are compulsary"; + return; + } + + var xmlreq = new XMLHttpRequest(); // Create a XMLHttpRequest object + + xmlreq.open("POST", "http://moodshare.herokuapp.com/login", true); // Assign method, url and isAsynchronous property to initialize the object + xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Set required headers + xmlreq.setRequestHeader('Access-Control-Allow-Origin', '*'); + + xmlreq.onreadystatechange = function() { // Run this everytime we see a change in the status/state of the request + + if(xmlreq.readyState == 4 && xmlreq.status == 202){ // 4 = Request completed, response ready. 202 = Accpeted + signin_button.innerHTML = "Signed-In"; // Change button text + attempt_left.innerHTML = ""; // Give response to the user regarding the status + response.innerHTML = "
Successfully signed in."; + signin_button.disabled = true; // Disable the button + } + else if(xmlreq.readyState == 4 && xmlreq.status == 401){ // 4 = Reqeuest completed and response ready 401 = Unauthorized access + + if(count-- <= 1){ // Max number of attempts reached + signin_button.disabled = true; // Disable the button + signin_button.innerHTML = "Sign-In"; + response.innerHTML = "Max attempts exceeded" // Notify the user + + waittimeID = window.setInterval(function(){ // Create a timer which modifies itself each second + attempt_left.innerHTML = "Please wait " + waittime-- + " seconds"; // Ask user to wait 15 seconds + if(waittime == -1) + window.clearInterval(waittimeID); // After 15 seconds kill the timer + },1000); + + window.setTimeout(function(){ // Timeout function to restore values after 15 seconds + count = 5; // Restore number of attempts + waittime = 15; // Restore waiting time + response.innerHTML = ""; + attempt_left.innerHTML = count + " Attempts left"; + signin_button.disabled = false; // Enable the button + },16500); + + return; + } + + signin_button.innerHTML = "Sign-In"; // In case of invalid username and password combination (Under max attempts limit) + signin_button.disabled = false; // Enable the button and notify the user + response.innerHTML = "
Incorrect username or password."; + } + + } + + xmlreq.send(login_params); // This will send the data to the API + signin_button.disabled = true; // Disable the button + signin_button.innerHTML = "Signing-In..."; // And change the button text to signingin until a change in state is found + attempt_left.innerHTML = count - 1 + " Attempts left"; // Reduce number of attempts by one +} diff --git a/makecall.js~ b/makecall.js~ new file mode 100644 index 0000000..3c4a239 --- /dev/null +++ b/makecall.js~ @@ -0,0 +1,72 @@ +var count = 5; +var waittime = 15; + +function keyHit(){ + if (event.keyCode == 13) document.getElementById("signin").click(); // Check if Enter key (13) is pressed +} + +function myFunction(){ // On Clicking Sign-In Button + + uname = document.getElementById("username").value; // Get username + pass = document.getElementById("password").value; // Get password + + var login_params = "username=" + uname + "&password=" + pass; // Create string to send to API + var signin_button = document.getElementById("signin"); // Get the sign in button in a variable + var response = document.getElementById("status"); // This will be the success/failure notice given to user + var attempt_left = document.getElementById("attempts"); // No of attempts left + + if(uname.toString().trim().length==0 || pass.trim().length == 0){ // Ask user to retry in case of empty strings in username or password + response.innerHTML = "Both values are compulsary"; + return; + } + + var xmlreq = new XMLHttpRequest(); // Create a XMLHttpRequest object + + xmlreq.open("POST", "http://moodshare.herokuapp.com/login", true); // Assign method, url and isAsynchronous property to initialize the object + xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Set required headers + xmlreq.setRequestHeader('Access-Control-Allow-Origin', '*'); + + xmlreq.onreadystatechange = function() { // Run this everytime we see a change in the status/state of the request + + if(xmlreq.readyState == 4 && xmlreq.status == 202){ // 4 = Request completed, response ready. 202 = Accpeted + signin_button.innerHTML = "Signed-In"; // Change button text + attempt_left.innerHTML = ""; // Give response to the user regarding the status + response.innerHTML = "
Successfully signed in."; + signin_button.disabled = true; // Disable the button + } + else if(xmlreq.readyState == 4 && xmlreq.status == 401){ // 4 = Reqeuest completed and response ready 401 = Unauthorized access + + if(count-- <= 1){ // Max number of attempts reached + signin_button.disabled = true; // Disable the button + signin_button.innerHTML = "Sign-In"; + response.innerHTML = "Max attempts exceeded" // Notify the user + + waittimeID = window.setInterval(function(){ // Create a timer which modifies itself each second + attempt_left.innerHTML = "Please wait " + waittime-- + " seconds"; // Ask user to wait 15 seconds + if(waittime == -1) + window.clearInterval(waittimeID); // After 15 seconds kill the timer + },1000); + + window.setTimeout(function(){ // Timeout function to restore values after 15 seconds + count = 5; // Restore number of attempts + waittime = 15; // Restore waiting time + response.innerHTML = ""; + attempt_left.innerHTML = count + " Attempts left"; + signin_button.disabled = false; // Enable the button + },16500); + + return; + } + + signin_button.innerHTML = "Sign-In"; // In case of invalid username and password combination (Under max attempts limit) + signin_button.disabled = false; // Enable the button and notify the user + response.innerHTML = "
Incorrect username or password."; + } + + } + + xmlreq.send(login_params); // This will send the data to the API + signin_button.disabled = true; // Disable the button + signin_button.innerHTML = "Signing-In..."; // And change the button text to signingin until a change in state is found + attempt_left.innerHTML = count - 1 + " Attempts left"; // Reduce number of attempts by one +} diff --git a/tuser.jpg b/tuser.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0ebf7a5dcbd3c23a2b7a5db0b01011eb8629ea33 GIT binary patch literal 1380 zcmex=6WnQQ6k>wyem!MAjrXx!jQtusKme|$jB_n`2PrlJOcwGE6}wd2SWiP6Eh1d8#@Ol7dKGB zRsjYkMrLLv7G_pf78aoDTA(}wiy*6zqM;+3a9|?4QlW@Z(iUwW$pkka< z)WpdpCN2T=jhecKrk07RnYo3fm9vYho4bdnS8zyZSa?KaRB}pcT6#uiR&hybS$Rce zRdY*gTYE=m*QCi)rcRqaW9F9X@jO*zpr5PhGlv zugFVCdTN;ZRxIkFTGPO%2Q*C0hCJ*d^Y1RJVE&WU zAh95QuWpbN&@tT{uWO7~*`Ath-F{bzXR+{Ue*Z(eq&}~;D$cFXx3IYN*xv6y!_q1} z!{bZU0s>t{8Z;JlF@Ui4%#WQvb&gf2{`i&rCwtjC=cCiJb?=ldEPTQo&e?`rQu?joM=t{xJf zuKfCLeliLe(u$&dq0lZ z&n=$1@san9{JcfKZ5ki<8cuxWZ+~gys|ig#5BgubDlSvLXmVl_uiY(+1KdwnzPvJV zQoYsoh+SdplfQ9CJlzp8H9(u~@p9RE#;A`cWfqqNDX(8O=Zc6OG$xtXCS_Iq-Mca) z_rR>g>+`4jU*G>Qw8nRpjqf+^axJfCVX_7F?SFoUYd601RTN)e>izocq0AG`e>e~Q z3-#*K0!0jqNT4f&$cp#U?Y*ZAUW7cj6zCvbW~a2fVO30Hq4>&&?T=%9d*AMT6PLn2 zr}n9h=&!ENyJlT_6zzGfLT2&$SGN3Hy`629y4Eg_>3(hTF0k&y&nfb|s=G9K9+rlu xUwJpP&wtk8udAj6hO_`JGDL(MIQ%>t*Dr~?6Mbt+=ZD=Vk3Rr9$Jze>O#nwKFaiJo literal 0 HcmV?d00001 From 05b48fd42e90c7a5139f30f9726e354f4e3e5d81 Mon Sep 17 00:00:00 2001 From: puneet7 Date: Tue, 26 Apr 2016 00:44:13 +0530 Subject: [PATCH 2/2] Delete makecall.js~ --- makecall.js~ | 72 ---------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 makecall.js~ diff --git a/makecall.js~ b/makecall.js~ deleted file mode 100644 index 3c4a239..0000000 --- a/makecall.js~ +++ /dev/null @@ -1,72 +0,0 @@ -var count = 5; -var waittime = 15; - -function keyHit(){ - if (event.keyCode == 13) document.getElementById("signin").click(); // Check if Enter key (13) is pressed -} - -function myFunction(){ // On Clicking Sign-In Button - - uname = document.getElementById("username").value; // Get username - pass = document.getElementById("password").value; // Get password - - var login_params = "username=" + uname + "&password=" + pass; // Create string to send to API - var signin_button = document.getElementById("signin"); // Get the sign in button in a variable - var response = document.getElementById("status"); // This will be the success/failure notice given to user - var attempt_left = document.getElementById("attempts"); // No of attempts left - - if(uname.toString().trim().length==0 || pass.trim().length == 0){ // Ask user to retry in case of empty strings in username or password - response.innerHTML = "Both values are compulsary"; - return; - } - - var xmlreq = new XMLHttpRequest(); // Create a XMLHttpRequest object - - xmlreq.open("POST", "http://moodshare.herokuapp.com/login", true); // Assign method, url and isAsynchronous property to initialize the object - xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Set required headers - xmlreq.setRequestHeader('Access-Control-Allow-Origin', '*'); - - xmlreq.onreadystatechange = function() { // Run this everytime we see a change in the status/state of the request - - if(xmlreq.readyState == 4 && xmlreq.status == 202){ // 4 = Request completed, response ready. 202 = Accpeted - signin_button.innerHTML = "Signed-In"; // Change button text - attempt_left.innerHTML = ""; // Give response to the user regarding the status - response.innerHTML = "
Successfully signed in."; - signin_button.disabled = true; // Disable the button - } - else if(xmlreq.readyState == 4 && xmlreq.status == 401){ // 4 = Reqeuest completed and response ready 401 = Unauthorized access - - if(count-- <= 1){ // Max number of attempts reached - signin_button.disabled = true; // Disable the button - signin_button.innerHTML = "Sign-In"; - response.innerHTML = "Max attempts exceeded" // Notify the user - - waittimeID = window.setInterval(function(){ // Create a timer which modifies itself each second - attempt_left.innerHTML = "Please wait " + waittime-- + " seconds"; // Ask user to wait 15 seconds - if(waittime == -1) - window.clearInterval(waittimeID); // After 15 seconds kill the timer - },1000); - - window.setTimeout(function(){ // Timeout function to restore values after 15 seconds - count = 5; // Restore number of attempts - waittime = 15; // Restore waiting time - response.innerHTML = ""; - attempt_left.innerHTML = count + " Attempts left"; - signin_button.disabled = false; // Enable the button - },16500); - - return; - } - - signin_button.innerHTML = "Sign-In"; // In case of invalid username and password combination (Under max attempts limit) - signin_button.disabled = false; // Enable the button and notify the user - response.innerHTML = "
Incorrect username or password."; - } - - } - - xmlreq.send(login_params); // This will send the data to the API - signin_button.disabled = true; // Disable the button - signin_button.innerHTML = "Signing-In..."; // And change the button text to signingin until a change in state is found - attempt_left.innerHTML = count - 1 + " Attempts left"; // Reduce number of attempts by one -}