netflix2/js/function.js
2022-10-10 01:20:00 +02:00

285 lines
7.9 KiB
JavaScript

var duree_movie;
function ShowSagas(data) {
var nosaga = $('<a />', {
id: 0,
class: 'saga button box nosaga',
href: '.?saga=0',
});
nosaga.append('No Saga');
nosaga.appendTo('#sagas');
$.each(data, function(key, value) {
var saga = $('<a />', {
id: value['id'],
class: 'saga button box container',
href: '.?saga='+value['id'],
});
//saga.append('<br>' + value['name']);
saga.appendTo('#sagas');
var text = $('<div />', {
html: value['name'],
class: 'centered title',
});
text.prependTo(saga);
var image = $('<img />', {
src: value['poster_path'],
class: 'thumbnail',
});
image.prependTo(saga);
});
};
function ShowMovies(data) {
$('#movies').append('<h3 style="margin: 10px 10px; padding: 0;">' + saga_name + '</h3>');
$.each(data, function(key, value) {
var movie = $('<a />', {
id: value['id'],
class: 'movie button box container',
href: '.?movie='+value['id'],
});
//movie.append('<br>' + value['title']);
movie.appendTo('#movies');
var title = $('<div />', {
html: value['title'],
class: 'centered title',
});
title.appendTo(movie);
var original_title = $('<div />', {
html: value['original_title'],
class: 'original_title',
});
original_title.appendTo(movie);
original_title.hide();
var image = $('<img />', {
src: value['poster_path'],
class: 'thumbnail',
});
image.prependTo(movie);
});
};
function MovieDetails(data) {
$('#movieTitle').html(data.title);
var description = $('#movieDetails #spec p');
description.empty();
description.append('<span id="release_date">Date de sortie : ' + data.release_date + '<br></span>');
description.append('<span id="viewOverview" class="toggle"><i class="fa fa-chevron-right" aria-hidden="true"></i> Résumé</span><br><span class="overview" style="display: none">' + data.overview + '<br></span>');
description.append('<span id="original_language">Langue original : ' + data.original_language + '<br></span>');
description.append('<span id="original_title">Titre original : ' + data.original_title + '<br></span>');
description.append('<span id="file_name">Nom du fichier : ' + data.file_name + '<br></span>');
description.append('<span id="tmdbMovie">More details here : <a target="_blank" href="https://www.themoviedb.org/movie/' + data.id + '?language=fr-FR">TMDB</a><br></span>');
if (data.sagaID != 0)
description.append('<span id="tmdbSaga">Saga details : <a target="_blank" href="https://www.themoviedb.org/collection/' + data.sagaID + '?language=fr-FR">TMDB</a><br></span>');
description.append('<span id="dl">Download : <a target="_blank" href="php/download.php?file=' + data.id + '">File</a>\
<i class="fas fa-clipboard-list" aria-hidden="true" title="Copy to clipboard"></i></span><br>');
$('#cover img').attr('src', data.poster_path);
$('#viewOverview').click(function() {
$('.overview').slideToggle(200);
$(this).find(".fa").toggleClass('active');
});
$('#showDetail').click(function() {
$('#movieDetails').slideToggle(200);
$(this).find(".fa").toggleClass('active');
});
};
function ShowSearch(sc_saga, sc_movie) {
$('#sagas').hide();
$('#movies').hide();
$('#movieContent').hide();
$('#research').empty();
$.each(sc_saga, function(key, value) {
var saga = $('<a />', {
id: value['id'],
class: 'saga line',
href: '.?saga='+value['id'],
});
saga.appendTo('#research');
var title = $('<div />', {
html: value['name'],
class: 'title',
});
title.appendTo(saga);
var image = $('<img />', {
src: value['poster_path'],
class: 'thumbnail',
});
image.prependTo(saga);
});
$.each(sc_movie, function(key, value) {
var movie = $('<a />', {
id: value['id'],
class: 'movie line',
href: '.?movie='+value['id'],
});
movie.appendTo('#research');
var title = $('<div />', {
html: value['title'],
class: 'title',
});
title.appendTo(movie);
var original_title = $('<div />', {
html: value['original_title'],
class: 'original_title',
});
original_title.appendTo(movie);
var image = $('<img />', {
src: value['poster_path'],
class: 'thumbnail',
});
image.prependTo(movie);
});
//$('#research').html(data.toString());
}
function FileInfo(data) {
duree_movie = parseInt(data.format.duration)*1000;
$('#movieDetails #spec p > span#release_date').after('<span id="duration">Durée : ' + data.format.duration.toHHMMSS() + '</span><br>');
$('#movieDetails #spec p > span#original_title').after('<span id="title">Titre du media : ' + data.format.title + '</span><br>');
var selection = $('#selection');
var AV = $('#AV');
var subtitle_list = $('#subtitle_list');
AV.append('Choose Video(s) :<br>');
$.each(data.video, function(key, video) {
var title, language, label;
if('title' in video)
title = video.title;
else
title = 'No title';
if('language' in video)
language = video.language;
else
language = 'und';
label = title + ' [' + language + '] ' + video.codec_name + ' ' + video.display_aspect_ratio + ' ' + video.width + 'x' + video.height;
if(video.forced == 1)
label = label + ' [forced]';
if(video.default == 1)
label = label + ' [def]';
AV.append('<input id="' + key + '" type="checkbox"><label for="' + key + '">' + label + '</label><br>');
});
AV.append('<br>Choose Audio(s) :<br>');
$.each(data.audio, function(key, audio) {
var title, language, label;
if('title' in audio)
title = audio.title;
else
title = 'No title';
if('language' in audio)
language = audio.language;
else
language = 'und';
label = title + ' [' + language + '] ' + audio.codec_name + ' ' + audio.channel_layout;
if(audio.forced == 1)
label = label + ' [forced]';
if(audio.default == 1)
label = label + ' [def]';
AV.append('<input id="' + key + '" type="checkbox"><label for="' + key + '">' + label + '</label><br>');
});
AV.append('<br><input id="convert" type="submit" name="convert">');
if (data.hasOwnProperty("subtitle")) {
subtitle_list.append('Liste Subtitle :<br>');
$.each(data.subtitle, function(key, subtitle) {
var title, language, label;
if('title' in subtitle)
title = subtitle.title;
else
title = 'No title';
if('language' in subtitle)
language = subtitle.language;
else
language = 'und';
label = title + ' [' + language + '] ' + subtitle.codec_name;
if(subtitle.forced == 1)
label = label + ' [forced]';
if(subtitle.default == 1)
label = label + ' [def]';
subtitle_list.append(label + '<br>');
});
}
};
function Horloge() {
var laDate = new Date();
if (typeof duree_movie !== 'undefined') {
var seg = laDate.getTime();
var heure_fin = seg + duree_movie;
heure_fin = new Date(heure_fin);
heure_fin = heure_fin.getHours() + ":" + ("0" + heure_fin.getMinutes()).slice(-2);
}
//var h = laDate.getHours() + ":" + ("0" + laDate.getMinutes()).slice(-2) + ":" + ("0" + laDate.getSeconds()).slice(-2);
var h = laDate.getHours() + ":" + ("0" + laDate.getMinutes()).slice(-2);
var temps = 'Heure : ' + h + ' Heure de Fin : ' + heure_fin;
$('#heure').text(temps);
};
function goBack() {
if (document.referrer.split('/')[2] == location.host)
window.history.back();
};
String.prototype.toHHMMSS = function () {
var sec_num = parseInt(this, 10); // don't forget the second param
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
var total = '';
if (hours > 0) {
total = hours + " Heure"
if (hours > 1)
total = total + 's'
}
if (minutes > 0) {
total = total + ' ' + minutes + " Minute"
if (minutes > 1)
total = total + 's'
}
if (seconds > 0) {
total = total + ' ' + seconds + " Seconde"
if (seconds > 1)
total = total + 's'
}
return total;
}