You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
3.0 KiB
102 lines
3.0 KiB
|
|
$(document).ready(function(){
|
|
$('.message a').click(function(){
|
|
$('form').animate({height: "toggle", opacity: "toggle"},"slow");
|
|
});
|
|
});
|
|
|
|
async function submitForm(e){
|
|
e.preventDefault();
|
|
|
|
try {
|
|
const response = await fetch('https://mkr.thefeathers.in/register', {
|
|
method: 'POST',
|
|
headers: new Headers({'content-type': 'application/json'}),
|
|
body: JSON.stringify({
|
|
"username": document.getElementById('formName').value,
|
|
"email": document.getElementById('formEmail').value,
|
|
"password": document.getElementById('formPassword').value
|
|
})
|
|
});
|
|
const data = await response.json();
|
|
//Success code goes here
|
|
//window.location = "searchmovies.html";
|
|
alert(JSON.stringify(data));
|
|
$('form').animate({ height: "toggle", opacity: "toggle" }, "slow");
|
|
}
|
|
catch (err) {
|
|
//Failure
|
|
alert('Error');
|
|
}
|
|
}
|
|
|
|
|
|
async function submitForm1(e){
|
|
e.preventDefault();
|
|
|
|
try {
|
|
const response = await fetch('https://mkr.thefeathers.in/login', {
|
|
method: 'POST',
|
|
headers: new Headers({'content-type': 'application/json'}),
|
|
body: JSON.stringify({
|
|
"username" : document.getElementById('formName1').value,
|
|
"password" : document.getElementById('formPassword1').value
|
|
})
|
|
});
|
|
const data1 = await response.json();
|
|
//Success code goes here
|
|
alert(JSON.stringify(data1));
|
|
window.localStorage.setItem('Token', (data1.token));
|
|
window.location = "searchmovies.html";
|
|
}
|
|
catch (err) {
|
|
//Failure
|
|
alert('Error');
|
|
}
|
|
}
|
|
|
|
async function search(e){
|
|
e.preventDefault();
|
|
var searchkey= $('.search-movies').val();
|
|
var Token=window.localStorage.getItem('Token');
|
|
try {
|
|
const response = await fetch('https://mkr.thefeathers.in/search/'+searchkey, {
|
|
method: 'GET',
|
|
headers: new Headers({'content-type': 'application/json', 'Authentication': Token }),
|
|
});
|
|
const data2 = await response.json();
|
|
//Success code goes here
|
|
//window.location = "searchmovies.html";
|
|
alert(JSON.stringify(data2));
|
|
var results =data2.results;
|
|
if(!results) return;
|
|
|
|
var listItems = results.map(myfunction);
|
|
|
|
function myfunction(result){
|
|
var x = document.createElement("li");
|
|
var a = document.createElement("a");
|
|
var t = document.createTextNode(result.title);
|
|
var i = document.createElement("img");
|
|
x.appendChild(i);
|
|
x.appendChild(a);
|
|
a.appendChild(t);
|
|
i.setAttribute("src",result.poster);
|
|
i.width = 300;
|
|
i.height = 300;
|
|
a.setAttribute("href","/moviesPage?movieId=" + result.movieId);
|
|
x.setAttribute("class","list");
|
|
return x;
|
|
|
|
}
|
|
document.getElementById("slideContainer").append(...listItems);
|
|
}
|
|
catch (err) {
|
|
//Failure
|
|
alert('Error');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|