Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rishz committed Mar 9, 2017
1 parent d0c0809 commit 19e2c22
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 9 deletions.
28 changes: 19 additions & 9 deletions shortner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,35 @@ module.exports = {
hash = hash.replace('+','_');
// let hashInt = parseInt(hash,16)
// conv = atob(hashInt);

hashMap[hash] = url;
writeUserData(r.from64(hash),hash);
writeUserData(url,r.from64(hash),hash);

return hash;

},
expand: function (shortcode) {
return firebase.database().ref('shortcode/'+shortcode).once().then(function(snapshot) {
var username = snapshot.val().url;
console.log(username);
// return firebase.database().ref('shortcode/'+shortcode).then(function(snapshot) {
// var username = snapshot.val().url;
// console.log(username);
// });

var ref = firebase.database().ref('/'+shortcode);

ref.once('child_added').then(function(snapshot) {
let username = snapshot.val().url;

console.log("converted value = "+username);
return console.log(hashMap[shortcode]);
// ref.once('value').off();
//return username;

});
// return hashMap[shortcode];
}

};

function writeUserData(url,shortcode) {
firebase.database().ref('shortcode/'+shortcode).set({
function writeUserData(url,shortcode,code) {
firebase.database().ref('/'+shortcode).set({
code:code,
url:url
});
}
3 changes: 3 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</head>
<body>

<div class="center">
<h1 align="center"> URL Shortener</h1>
</div>
<input id="url" type="text" placeholder="Enter URL" name="url">
<br>
<input id="submit" type="submit" class="btn">
Expand Down
54 changes: 54 additions & 0 deletions static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
*{
align: center;
}
#url{
align: center;
size: 100px;
height: 50px;
width: 600px;
font-family: Arial;
font-size: 25px;
margin-top: 2%;
margin-left: 25%;
}
.btn {
background: #ffd324;
background-image: -webkit-linear-gradient(top, #ffd324, #fab120);
background-image: -moz-linear-gradient(top, #ffd324, #fab120);
background-image: -ms-linear-gradient(top, #ffd324, #fab120);
background-image: -o-linear-gradient(top, #ffd324, #fab120);
background-image: linear-gradient(to bottom, #ffd324, #fab120);
border-radius: 15px;
font-family: sans-serif;
color: #ffffff;
font-size: 29px;
padding: 10px 20px 10px 20px;
text-decoration: black;
margin-top: 2%;
margin-left: 43%;
}

.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}

.mydiv{
align-self: center;
align-items: center;
font-family: "American Typewriter";
font-size:30px;
font-style: inherit;
margin-top: 3%;
margin-left: 25%;

}
.center{
font-family: "American Typewriter";
font-size: 40px;
}

0 comments on commit 19e2c22

Please sign in to comment.