Skip to content

Commit

Permalink
trying wetransfer page
Browse files Browse the repository at this point in the history
  • Loading branch information
aviiciii committed Mar 18, 2023
1 parent 98a5793 commit 11cd3cc
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 1 deletion.
2 changes: 1 addition & 1 deletion edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
load_dotenv()

url = "https://api.short.io/links/lnk_2MDV_9dCPkouhKSC"
url = "https://api.short.io/links/lnk_2MDV_9dCPkoujKaJ"

import json

Expand Down
79 changes: 79 additions & 0 deletions script-we.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

// wait for submit button to be clicked
document.getElementById("myinput").onclick = function () {
// get the link from the input
var link = document.getElementById("linkinput").value;

let api_url="https://api.short.io/links/lnk_2MDV_9dCPkoujKaJ";


// data to be sent to the API
var data = {
domain: "link.laavesh.ml",
originalURL: link,
allowDuplicates: false,
};


// send the data to the API
fetch(api_url, {
method: "post",
headers: {
accept: "application/json",
"Content-Type": "application/json",
authorization: "sk_oNHGE7VRdKp0DWJc",
},
body: JSON.stringify(data),
})
// get the response from the API
.then(function (response) {
return response.json();
})
// display the shortened link
.then(function (data) {
if (data.error) {
throw data.error;
}
// get shortened link
let url = String(data.shortURL);
// remove https://
url =url.replace("https://", "");
// display shortened link
console.log(url);
document.getElementById("message").innerHTML = url;
})
// display error if any
.catch(function (error) {
console.log(error);
document.getElementById("message").innerHTML = error;
});

// clear the input fields
document.getElementById("linkinput").value = "";
};


// Copy the link to the clipboard
document.getElementById("copy").onclick = function () {
// Get the text field
var message = document.getElementById("message");

// get the link
url = message.innerHTML;


// Copy link to clipboard
navigator.clipboard.writeText(url);

// Alert copied to clipboard
message.innerHTML = "Copied!";
console.log("Copied!");

// Change back to link after 800ms
setTimeout(function () {
message.innerHTML = url;
}, 800);



}
3 changes: 3 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ document.getElementById("myinput").onclick = function () {
if (data.error) {
throw data.error;
}
// get shortened link
let url = String(data.shortURL);
// remove https://
url =url.replace("https://", "");
// display shortened link
console.log(url);
document.getElementById("message").innerHTML = url;
})
Expand Down
52 changes: 52 additions & 0 deletions wetransfer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shorten! from aviiciii</title>
<link rel="stylesheet" href="styles.css" />
<link rel="icon" href="favicon.png" />
</head>

<body>

<!-- form -->
<div class="login-box">
<form>

<!-- long url -->
<div class="user-box">
<input type="text" name="text" value id="linkinput" required="" />
<label>Url</label>
</div>


<!-- button -->
<a href="#" id="myinput" value="Shorten">
<span></span>
<span></span>
<span></span>
<span></span>
Shorten
</a>
</form>

<br>

<!-- shortened url box -->
<div class="msg row">
<div class="column left">
<p id="message">link.laavesh.ml/we </p>
</div>
<div class="column right">
<button name="copy" id="copy"><img src="copy.png" width="30px" alt="copy" /></button>
</div>
</div>
</div>

<!-- link script -->
<script src="script-we.js"></script>

</body>
</html>

0 comments on commit 11cd3cc

Please sign in to comment.