The site contains movies data.
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.

92 lines
2.6 KiB

var searchkey;
4 years ago
$(document).ready(function(){
$('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"},"slow");
});
$('.search-btn').click(function() {
searchkey= $('.search-movies').val();
});
});
async function submitForm(e){
4 years ago
e.preventDefault();
try {
const response = await fetch('https://mkr.thefeathers.in/register', {
method: 'POST',
headers: new Headers({'content-type': 'application/json'}),
4 years ago
body: JSON.stringify({
"username": document.getElementById('formName').value,
"email": document.getElementById('formEmail').value,
"password": document.getElementById('formPassword').value
4 years ago
})
});
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){
4 years ago
e.preventDefault();
try {
const response = await fetch('https://mkr.thefeathers.in/login', {
method: 'POST',
headers: new Headers({'content-type': 'application/json'}),
4 years ago
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));
4 years ago
window.localStorage.setItem('Token', (data1.token));
4 years ago
window.location = "searchmovies.html";
}
catch (err) {
//Failure
alert('Error');
}
}
async function search(e){
e.preventDefault();
4 years ago
var Token=window.localStorage.getItem('Token');
try {
const response = await fetch('https://mkr.thefeathers.in/search/'+searchkey, {
method: 'GET',
4 years ago
headers: new Headers({'content-type': 'application/json', 'Authentication': Token }),
});
4 years ago
const data2 = await response.json();
//Success code goes here
//window.location = "searchmovies.html";
4 years ago
alert(JSON.stringify(data2));
var str = '<ul>'
var result = data2.results;
result.forEach(myfunction);
function myfunction(slide){
str += '<li>'+ slide + '</li>';
}
str += '</ul>';
document.getElementById("slideContainer").innerHTML = str;
}
catch (err) {
//Failure
alert('Error');
}
}
4 years ago