Skip to content

Commit

Permalink
handle file drops
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Jul 19, 2022
1 parent d082bf0 commit bd2fd05
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 110 deletions.
4 changes: 4 additions & 0 deletions layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ setTimeout(() => {
</div>
</div>
`);
const newTweet = modal.getElementsByClassName('navbar-new-tweet-container')[0];
const newTweetText = modal.getElementsByClassName('navbar-new-tweet-text')[0];
const newTweetChar = modal.getElementsByClassName('navbar-new-tweet-char')[0];
const newTweetMedia = modal.getElementsByClassName('navbar-new-tweet-media')[0];
Expand Down Expand Up @@ -760,6 +761,9 @@ setTimeout(() => {
updateCharCount(e);
});
let mediaToUpload = [];
newTweet.addEventListener('drop', e => {
handleDrop(e, mediaToUpload, newTweetMediaDiv);
});
newTweetMedia.addEventListener('click', () => {
getMedia(mediaToUpload, newTweetMediaDiv);
});
Expand Down
12 changes: 10 additions & 2 deletions layouts/home/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
tweetInteractReply.classList.remove('tweet-interact-reply-clicked');
});
let replyMedia = [];
tweetReply.addEventListener('drop', e => {
handleDrop(e, replyMedia, tweetReplyMedia);
});
tweetReplyUpload.addEventListener('click', () => {
getMedia(replyMedia, tweetReplyMedia);
});
Expand Down Expand Up @@ -564,6 +567,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
})
});
let quoteMedia = [];
tweetQuote.addEventListener('drop', e => {
handleDrop(e, quoteMedia, tweetQuoteMedia);
});
tweetQuoteUpload.addEventListener('click', () => {
getMedia(quoteMedia, tweetQuoteMedia);
});
Expand Down Expand Up @@ -1051,8 +1057,10 @@ setTimeout(() => {
document.getElementById('new-tweet-text').classList.add('new-tweet-text-focused');
document.getElementById('new-tweet-media-div').classList.add('new-tweet-media-div-focused');
});

document.getElementById('new-tweet-media-div').addEventListener('click', async () => {
document.getElementById('new-tweet').addEventListener('drop', e => {
handleDrop(e, mediaToUpload, document.getElementById('new-tweet-media-c'));
});
document.getElementById('new-tweet-media-div').addEventListener('click', () => {
getMedia(mediaToUpload, document.getElementById('new-tweet-media-c'));
});
let newTweetUserSearch = document.getElementById("new-tweet-user-search");
Expand Down
6 changes: 6 additions & 0 deletions layouts/notifications/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
tweetInteractReply.classList.remove('tweet-interact-reply-clicked');
});
let replyMedia = [];
tweetReply.addEventListener('drop', e => {
handleDrop(e, replyMedia, tweetReplyMedia);
});
tweetReplyUpload.addEventListener('click', () => {
getMedia(replyMedia, tweetReplyMedia);
});
Expand Down Expand Up @@ -432,6 +435,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
})
});
let quoteMedia = [];
tweetQuote.addEventListener('drop', e => {
handleDrop(e, quoteMedia, tweetQuoteMedia);
});
tweetQuoteUpload.addEventListener('click', () => {
getMedia(quoteMedia, tweetQuoteMedia);
});
Expand Down
10 changes: 10 additions & 0 deletions layouts/profile/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ function renderProfile() {
</div>
</div>
`);
const newTweet = modal.getElementsByClassName('navbar-new-tweet-container')[0];
const newTweetText = modal.getElementsByClassName('navbar-new-tweet-text')[0];
const newTweetChar = modal.getElementsByClassName('navbar-new-tweet-char')[0];
const newTweetMedia = modal.getElementsByClassName('navbar-new-tweet-media')[0];
Expand Down Expand Up @@ -547,6 +548,9 @@ function renderProfile() {
updateCharCount(e);
});
let mediaToUpload = [];
newTweet.addEventListener('drop', e => {
handleDrop(e, mediaToUpload, newTweetMediaDiv);
});
newTweetMedia.addEventListener('click', () => {
getMedia(mediaToUpload, newTweetMediaDiv);
});
Expand Down Expand Up @@ -1069,6 +1073,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
tweetInteractReply.classList.remove('tweet-interact-reply-clicked');
});
let replyMedia = [];
tweetReply.addEventListener('drop', e => {
handleDrop(e, replyMedia, tweetReplyMedia);
});
tweetReplyUpload.addEventListener('click', () => {
getMedia(replyMedia, tweetReplyMedia);
});
Expand Down Expand Up @@ -1244,6 +1251,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
})
});
let quoteMedia = [];
tweetQuote.addEventListener('drop', e => {
handleDrop(e, quoteMedia, tweetQuoteMedia);
});
tweetQuoteUpload.addEventListener('click', () => {
getMedia(quoteMedia, tweetQuoteMedia);
});
Expand Down
6 changes: 6 additions & 0 deletions layouts/search/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
tweetInteractReply.classList.remove('tweet-interact-reply-clicked');
});
let replyMedia = [];
tweetReply.addEventListener('drop', e => {
handleDrop(e, replyMedia, tweetReplyMedia);
});
tweetReplyUpload.addEventListener('click', () => {
getMedia(replyMedia, tweetReplyMedia);
});
Expand Down Expand Up @@ -471,6 +474,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
})
});
let quoteMedia = [];
tweetQuote.addEventListener('drop', e => {
handleDrop(e, quoteMedia, tweetQuoteMedia);
});
tweetQuoteUpload.addEventListener('click', () => {
getMedia(quoteMedia, tweetQuoteMedia);
});
Expand Down
9 changes: 9 additions & 0 deletions layouts/tweet/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ async function appendComposeComponent(container, replyTweet) {
document.getElementById('new-tweet-media-div').classList.add('new-tweet-media-div-focused');
});

document.getElementById('new-tweet').addEventListener('drop', e => {
handleDrop(e, mediaToUpload, document.getElementById('new-tweet-media-c'));
});
document.getElementById('new-tweet-media-div').addEventListener('click', async () => {
getMedia(mediaToUpload, document.getElementById('new-tweet-media-c'));
});
Expand Down Expand Up @@ -907,6 +910,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
tweetInteractReply.classList.remove('tweet-interact-reply-clicked');
});
let replyMedia = [];
tweetReply.addEventListener('drop', e => {
handleDrop(e, replyMedia, tweetReplyMedia);
});
tweetReplyUpload.addEventListener('click', () => {
getMedia(replyMedia, tweetReplyMedia);
});
Expand Down Expand Up @@ -1135,6 +1141,9 @@ async function appendTweet(t, timelineContainer, options = {}) {
})
});
let quoteMedia = [];
tweetQuote.addEventListener('drop', e => {
handleDrop(e, quoteMedia, tweetQuoteMedia);
});
tweetQuoteUpload.addEventListener('click', () => {
getMedia(quoteMedia, tweetQuoteMedia);
});
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Old Twitter Layout (2022)",
"description": "A new extension that returns old Twitter's look.",
"version": "1.0.7",
"version": "1.0.8",
"manifest_version": 3,
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
"background": {
Expand Down
Loading

0 comments on commit bd2fd05

Please sign in to comment.