-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Hadley
committed
Jul 13, 2024
1 parent
c3324a1
commit baab734
Showing
5 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Carrier Pigeon</title> | ||
|
||
<link rel="stylesheet" href="https://linfindel.github.io/nadircss/nadir.css"> | ||
</head> | ||
<body class="absolute-centre"> | ||
<div class="card column"> | ||
<div class="text-center"> | ||
<h1 style="font-size: 5rem;" class="material-symbols-rounded">raven</h1> | ||
<h1>Carrier Pigeon</h1> | ||
<p id="desc">Send files with plaintext</p> | ||
</div> | ||
|
||
<div class="row-flat"> | ||
<button onclick="location.href = 'send.html'"> | ||
<span class="material-symbols-rounded">send</span> | ||
Send | ||
</button> | ||
|
||
<button onclick="location.href = 'receive.html'"> | ||
<span class="material-symbols-rounded">download</span> | ||
Receive | ||
</button> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Carrier Pigeon</title> | ||
|
||
<link rel="stylesheet" href="https://linfindel.github.io/nadircss/nadir.css"> | ||
</head> | ||
<body class="absolute-centre column-flat"> | ||
<div id="paste-card" class="card-flat-bottom column" style="width: calc(100% - 5rem);"> | ||
<input autocomplete="off" id="paste-input" type="text" placeholder="Paste text here" oninput="decode()"> | ||
</div> | ||
|
||
<div id="download-card" class="card-subtle-flat-top column" style="width: calc(100% - 5rem);"> | ||
<button id="download-button" class="button-subtle" inert> | ||
<span id="download-icon" class="material-symbols-rounded">download</span> | ||
<span id="download-text">Download file</span> | ||
</button> | ||
</div> | ||
|
||
<script src="receive.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function decode() { | ||
const string = document.getElementById("paste-input").value; | ||
|
||
document.getElementById("paste-card").classList.remove("card-flat-bottom"); | ||
document.getElementById("paste-card").classList.add("card-success-flat-bottom"); | ||
|
||
document.getElementById("paste-input").classList.add("input-success"); | ||
|
||
download(string); | ||
} | ||
|
||
function download(string) { | ||
let stringParts = string.split("name://"); | ||
const URI = stringParts[0]; | ||
const fileName = stringParts[1]; | ||
|
||
document.getElementById("download-card").classList.remove("card-subtle-flat-top"); | ||
document.getElementById("download-card").classList.add("card-flat-top"); | ||
|
||
document.getElementById("download-button").classList.remove("button-subtle"); | ||
document.getElementById("download-button").removeAttribute("inert"); | ||
|
||
document.getElementById("download-button").onclick = () => { | ||
const link = document.createElement("a"); | ||
link.download = fileName; | ||
link.href = URI; | ||
link.click(); | ||
|
||
document.getElementById("download-card").classList.remove("card-flat-top"); | ||
document.getElementById("download-card").classList.add("card-warning-flat-top"); | ||
|
||
document.getElementById("download-button").classList.add("button-warning"); | ||
document.getElementById("download-button").inert = "true"; | ||
|
||
document.getElementById("download-icon").innerText = "downloading"; | ||
document.getElementById("download-text").innerText = "Downloading..."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Carrier Pigeon</title> | ||
|
||
<link rel="stylesheet" href="https://linfindel.github.io/nadircss/nadir.css"> | ||
</head> | ||
<body class="absolute-centre column-flat"> | ||
<div id="upload-card" class="card-flat-bottom column" style="width: calc(100% - 5rem);"> | ||
<button id="upload-button" onclick="upload()"> | ||
<span id="upload-icon" class="material-symbols-rounded">upload</span> | ||
<span id="upload-text">Upload file</span> | ||
</button> | ||
</div> | ||
|
||
<div id="copy-card" class="card-subtle-flat-top column" style="width: calc(100% - 5rem);"> | ||
<button id="copy-button" class="button-subtle" inert> | ||
<span id="copy-icon" class="material-symbols-rounded">content_copy</span> | ||
<span id="copy-text">Copy text</span> | ||
</button> | ||
</div> | ||
|
||
<script src="send.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
function upload() { | ||
let input = document.createElement('input'); | ||
input.type = 'file'; | ||
|
||
input.onchange = () => { | ||
const file = input.files[0]; | ||
|
||
const reader = new FileReader(); | ||
reader.onloadend = () => { | ||
const string = `${reader.result}name://${file.name}`; | ||
success(string); | ||
} | ||
reader.readAsDataURL(file); | ||
} | ||
|
||
input.click(); | ||
} | ||
|
||
function success(string) { | ||
document.getElementById("upload-card").classList.remove("card-flat-bottom"); | ||
document.getElementById("upload-card").classList.add("card-success-flat-bottom"); | ||
|
||
document.getElementById("upload-button").classList.add("button-success"); | ||
document.getElementById("upload-button").inert = "true"; | ||
|
||
document.getElementById("upload-icon").innerText = "check"; | ||
document.getElementById("upload-text").innerText = "File uploaded"; | ||
|
||
document.getElementById("copy-card").classList.remove("card-subtle-flat-top"); | ||
document.getElementById("copy-card").classList.add("card-flat-top"); | ||
|
||
document.getElementById("copy-button").classList.remove("button-subtle"); | ||
document.getElementById("copy-button").removeAttribute("inert"); | ||
|
||
document.getElementById("copy-button").onclick = () => { | ||
copy(string); | ||
} | ||
} | ||
|
||
function copy(string) { | ||
navigator.clipboard.writeText(string); | ||
|
||
document.getElementById("copy-card").classList.remove("card-flat-top"); | ||
document.getElementById("copy-card").classList.add("card-success-flat-top"); | ||
|
||
document.getElementById("copy-button").classList.add("button-success"); | ||
document.getElementById("copy-button").inert = "true"; | ||
|
||
document.getElementById("copy-icon").innerText = "check"; | ||
document.getElementById("copy-text").innerText = "Text copied"; | ||
|
||
setTimeout(() => { | ||
location.href = "."; | ||
}, 500); | ||
} |