From 7af3f14e9ad22e62ea6c91e13c52dff24f369faf Mon Sep 17 00:00:00 2001 From: rajashree-n Date: Sun, 1 May 2016 18:21:58 +0530 Subject: [PATCH 1/2] adding files --- index.html | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 30 ++++++++++++++++++++++++++++++ main.css | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 index.html create mode 100644 index.js create mode 100644 main.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..ff3ce74 --- /dev/null +++ b/index.html @@ -0,0 +1,49 @@ + + +Log-In + + + + + +
+
+

project.lumos Log-In

FORM

+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
Successfully logged-in :)
×
+
+ +
+
Sorry log-in failed :(
× +
+ +
+
+ + + + + + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..1c94512 --- /dev/null +++ b/index.js @@ -0,0 +1,30 @@ + +function login(){ + +var username = document.getElementById("usernameid").value; +var password = document.getElementById("passwordid").value; + +if(username === "" || password === ""){ +document.getElementById("loginfail").style.display="block"; +return false; +} + +var xmlReq = new XMLHttpRequest(); + +xmlReq.open("POST", "https://moodshare.herokuapp.com/login", true); +xmlReq.setRequestHeader("Access-Control-Allow-Origin", "*"); +xmlReq.setRequestHeader("Content-type","application/x-www-form-urlencoded"); +xmlReq.send("username="+username+"&password="+password); + + +xmlReq.onreadystatechange = function(){ +if(xmlReq.readyState == 4 && xmlReq.status == 202){ +document.getElementById("loginresult").style.display="block"; +} +else if(xmlReq.readyState == 4 && xmlReq.status == 401){ +document.getElementById("loginfail").style.display="block"; +document.getElementById("passwordid").value = ""; +} +}; + +} diff --git a/main.css b/main.css new file mode 100644 index 0000000..c79eab5 --- /dev/null +++ b/main.css @@ -0,0 +1,48 @@ +body { + background-image: url(back.jpeg); + background-size:cover; +} +#loginresult +{ + display:none; +} + +#loginfail +{ + display:none; +} + +.form { + margin-top:15%; + margin-left:30%; + margin-right:30%; +} +h1 +{ + color:#fff; +} + +.insert { + border:1px solid #AED0EA; + border-radius:8px; + box-shadow:0 0 10px #D7EBF9; +} +#Btn { padding-left:40px; + padding-right:40px; + +} +@media only screen and (min-width: 150px) and (max-width:600px) +{ +body +{ + font-size: 90%; +} +.form +{ + margin:5px; +} +#Btn { padding-left:20px; + padding-right:20px; + +} +} From f1e41d2098a8a8441586d30e3b3f80b12c5819c5 Mon Sep 17 00:00:00 2001 From: rajashree-n Date: Sun, 1 May 2016 18:24:49 +0530 Subject: [PATCH 2/2] adding comments --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1c94512..353a0ac 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,16 @@ function login(){ - +//taking i/p var username = document.getElementById("usernameid").value; var password = document.getElementById("passwordid").value; +//checking for null values if(username === "" || password === ""){ document.getElementById("loginfail").style.display="block"; return false; } +//request-xml var xmlReq = new XMLHttpRequest(); xmlReq.open("POST", "https://moodshare.herokuapp.com/login", true); @@ -16,7 +18,7 @@ xmlReq.setRequestHeader("Access-Control-Allow-Origin", "*"); xmlReq.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlReq.send("username="+username+"&password="+password); - +//result of req xmlReq.onreadystatechange = function(){ if(xmlReq.readyState == 4 && xmlReq.status == 202){ document.getElementById("loginresult").style.display="block";