169 lines
6.2 KiB
HTML
169 lines
6.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<title>Peernet Download file</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,900&display=swap" rel="stylesheet">
|
|
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
<link rel="stylesheet" href="/static/css/style.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<section class="ftco-section">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-12 col-lg-10">
|
|
<div class="wrap d-md-flex">
|
|
<div class="text-wrap p-4 p-lg-5 text-center d-flex align-items-center order-md-last">
|
|
<div class="text w-100">
|
|
<video controls crossorigin playsinline poster="" style="width:100%; visibility: hidden" id="video">
|
|
<source src="" id="video-player">
|
|
<!-- Fallback for browsers that don't support the <video> element -->
|
|
<a href="" id="VideoDownload" download>Download</a>
|
|
</video>
|
|
<!-- Display other files in a iframe -->
|
|
<div id="other-files">
|
|
<object data="" style="overflow:auto;width: 100%; height: 40vh;" id="data">
|
|
</object>
|
|
</div>
|
|
<br>
|
|
<h2 class="Peernetblue">Download this file from Peernet</h2>
|
|
<a href="#" style="color:#3ac4e2" id="Download">Download from the browser</a>
|
|
<br>
|
|
<br>
|
|
<a href="https://peernet.org" class="btn btn-white btn-outline-white">Instantly stream it with the Peernet Browser</a>
|
|
</div>
|
|
<!-- Video player code snippet -->
|
|
</div>
|
|
<div class="login-wrap p-4 p-lg-5">
|
|
<div class="d-flex">
|
|
<div class="w-100">
|
|
<h3 class="mb-4">File information</h3>
|
|
</div>
|
|
<div class="w-100">
|
|
|
|
</div>
|
|
</div>
|
|
<form action="#" class="signin-form">
|
|
<div class="form-group mb-3">
|
|
<label class="label" for="name">File Name:</label>
|
|
<p id="FileName"></p>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<label class="label" for="name">File Size:</label>
|
|
<p id="FileSize"></p>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<label class="label" for="name">File Hash:</label>
|
|
<p id="FileHash"></p>
|
|
</div>
|
|
<!-- <div class="form-group mb-3">
|
|
<label class="label" for="password">Password</label>
|
|
<input type="password" class="form-control" placeholder="Password" required>
|
|
</div><div class="form-group mb-3">
|
|
<label class="label" for="name">File Name:</label>
|
|
<p>Test.txt</p>
|
|
</div> -->
|
|
</div>
|
|
<div class="form-group d-md-flex">
|
|
<!-- <div class="w-50 text-left">
|
|
<label class="checkbox-wrap checkbox-primary mb-0">Remember Me
|
|
<input type="checkbox" checked>
|
|
<span class="checkmark"></span>
|
|
</label>
|
|
</div>
|
|
<div class="w-50 text-md-right">
|
|
<a href="#">Forgot Password</a>
|
|
</div> -->
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<script src="/static/js/jquery.min.js"></script>
|
|
<script src="/static/js/popper.js"></script>
|
|
<script src="/static/js/bootstrap.min.js"></script>
|
|
<script src="/static/js/main.js"></script>
|
|
|
|
<script>
|
|
// call a certain api and parse JSON and populate the
|
|
// the data in the HTML page
|
|
|
|
var FileSize = document.getElementById('FileSize');
|
|
var FileHash = document.getElementById('FileHash');
|
|
var Download = document.getElementById('Download');
|
|
var FileName = document.getElementById('FileName');
|
|
var Video = document.getElementById('video');
|
|
var VideoPlayer = document.getElementById('video-player')
|
|
var OtherFiles = document.getElementById('other-files')
|
|
var Data = document.getElementById('data')
|
|
|
|
var promise1 = new Promise(function(resolve, reject) {
|
|
var xhr = new XMLHttpRequest(),
|
|
method = "GET",
|
|
url = window.location + "&metadata=true";
|
|
|
|
xhr.open(method, url, true);
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
console.log(xhr.responseText)
|
|
resolve(JSON.parse(xhr.responseText));
|
|
}
|
|
};
|
|
xhr.send();
|
|
});
|
|
|
|
promise1.then(function(value) {
|
|
// Actions performed once a response is provided
|
|
FileSize.innerText = value.Size + " Bytes";
|
|
FileHash.innerText = value.Hash;
|
|
Download.href = window.location + "&download=true"
|
|
FileName.innerText = value.Name
|
|
|
|
// Get file extension
|
|
var fileExt = value.Name.split('.').pop();
|
|
|
|
// To make sure a file is less than 100 mb to preview and is not a video file.
|
|
if (value.Size > 1000000 && fileExt != "mp4" && fileExt != "mov" && fileExt != "wmv" && fileExt != "webm" && fileExt != "mpeg-2") {
|
|
OtherFiles.remove()
|
|
}
|
|
|
|
if (fileExt === "mp4") {
|
|
// Ensure browser is not Safari
|
|
if(navigator.userAgent.indexOf("Safari") === -1)
|
|
{
|
|
// Play the video if the condition is true
|
|
PlayVideo()
|
|
}
|
|
// Remove the div
|
|
// for displaying other files
|
|
OtherFiles.remove()
|
|
} else {
|
|
Video.remove()
|
|
Data.data = window.location + "&play=true"
|
|
}
|
|
});
|
|
|
|
// This function plays the video on the video plane
|
|
function PlayVideo() {
|
|
// make the video div visible
|
|
Video.style.visibility = 'visible'
|
|
VideoPlayer.src = window.location + "&play=true"
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |