Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated bacon etch file and made the reaction feature #3691

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions BACON/bacon-etch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ mode: separate-outputs
etching:
rune: BLT.BACON.TOKENS
turbo: true
divisibility: 8
premine: 1000000
supply: 1000000
divisibility: 0
premine: 1000000000000
supply: 1000000000000
symbol: 🥓

inscriptions:
- file: /blockchain/bacon.png
- file: /blockchain/bacon-images/bacon-24kb.jpeg
110 changes: 110 additions & 0 deletions website/templates/join_room.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ <h1 class="text-3xl font-bold text-gray-900">{{ room.name }}</h1>
</div>
</div>
<div class="mt-1">{{ message.content }}</div>
<!-- React button (always visible on hover) -->
<button class="react-button absolute top-4 right-0 mt-1 mr-1 text-gray-500 hover:text-gray-700 p-1 rounded-full bg-gray-200"
onclick="toggleEmojiList('{{ message.id }}')">➕</button>
<!-- Emoji list (hidden by default) -->
<div id="emoji-list-{{ message.id }}"
class="emoji-list hidden absolute top-8 right-0 mt-1 mr-1 bg-white shadow-md rounded-md p-2 w-32 z-10">
<button onclick="sendReaction('{{ message.id }}', '❤️')">❤️</button>
<button onclick="sendReaction('{{ message.id }}', '😂')">😂</button>
<button onclick="sendReaction('{{ message.id }}', '👍')">👍</button>
<button onclick="sendReaction('{{ message.id }}', '😢')">😢</button>
<button onclick="sendReaction('{{ message.id }}', '🙏')">🙏</button>
<button onclick="sendReaction('{{ message.id }}', '😊')">😊</button>
</div>
<!-- Reactions display (hidden by default) -->
<div id="reactions-{{ message.id }}"
class="reactions hidden absolute top-4 right-0 mt-1 mr-1 bg-white shadow-md rounded-md p-2 w-32 z-10">
<!-- Reactions will be dynamically added here -->
</div>
</div>
{% endfor %}
</div>
Expand Down Expand Up @@ -170,6 +188,35 @@ <h1 class="text-3xl font-bold text-gray-900">{{ room.name }}</h1>
newMessage.appendChild(header);
newMessage.appendChild(contentElement);

// React button
const reactButton = document.createElement('button');
reactButton.classList.add('react-button', 'absolute', 'top-4', 'right-0', 'mt-1', 'mr-1', 'text-gray-500', 'hover:text-gray-700', 'p-1', 'rounded-full', 'bg-gray-200');
reactButton.innerHTML = "➕";
reactButton.onclick = function() {
toggleEmojiList(data.message_id);
};
newMessage.appendChild(reactButton);

// Emoji list
const emojiList = document.createElement('div');
emojiList.id = `emoji-list-${data.message_id}`;
emojiList.classList.add('emoji-list', 'hidden', 'absolute', 'top-8', 'right-0', 'mt-1', 'mr-1', 'bg-white', 'shadow-md', 'rounded-md', 'p-2', 'w-32', 'z-10');
emojiList.innerHTML = `
<button onclick="sendReaction('${data.message_id}', '❤️')">❤️</button>
<button onclick="sendReaction('${data.message_id}', '😂')">😂</button>
<button onclick="sendReaction('${data.message_id}', '👍')">👍</button>
<button onclick="sendReaction('${data.message_id}', '😢')">😢</button>
<button onclick="sendReaction('${data.message_id}', '🙏')">🙏</button>
<button onclick="sendReaction('${data.message_id}', '😊')">😊</button>
`;
newMessage.appendChild(emojiList);

// Reactions display
const reactionsDiv = document.createElement('div');
reactionsDiv.id = `reactions-${data.message_id}`;
reactionsDiv.classList.add('reactions', 'hidden', 'absolute', 'top-4', 'right-0', 'mt-1', 'mr-1', 'bg-white', 'shadow-md', 'rounded-md', 'p-2', 'w-32', 'z-10');
newMessage.appendChild(reactionsDiv);

if (data.username === username) {
const menuContainer = document.createElement('div');
menuContainer.classList.add('relative');
Expand Down Expand Up @@ -334,6 +381,52 @@ <h1 class="text-3xl font-bold text-gray-900">{{ room.name }}</h1>
}
}

function toggleEmojiList(messageId) {
const emojiList = document.getElementById(`emoji-list-${messageId}`);
emojiList.classList.toggle('hidden');
}

function sendReaction(messageId, emoji) {
if (socket && socket.readyState === WebSocket.OPEN) {
const data = {
'type': 'reaction',
'messageId': messageId,
'emoji': emoji,
'username': username
};
socket.send(JSON.stringify(data));
updateReactionButton(messageId, emoji);
hideEmojiList(messageId);
}
}

function hideEmojiList(messageId) {
const emojiList = document.getElementById(`emoji-list-${messageId}`);
emojiList.classList.add('hidden');
}

function updateReactionButton(messageId, emoji) {
const reactButton = document.querySelector(`#message-${messageId} .react-button`);
reactButton.innerHTML = emoji;
reactButton.onclick = function() {
showReactions(messageId);
};
}

function showReactions(messageId) {
fetch(`/api/reactions/${messageId}/`)
.then(response => response.json())
.then(data => {
const reactionsDiv = document.getElementById(`reactions-${messageId}`);
reactionsDiv.innerHTML = '';
data.reactions.forEach(reaction => {
const reactionElement = document.createElement('div');
reactionElement.textContent = `${reaction.emoji} ${reaction.username}`;
reactionsDiv.appendChild(reactionElement);
});
reactionsDiv.classList.toggle('hidden');
});
}

// Function to remove a message from the UI
function removeMessageFromUI(messageId) {
Expand All @@ -354,6 +447,23 @@ <h1 class="text-3xl font-bold text-gray-900">{{ room.name }}</h1>
}
});

document.addEventListener("mouseover", function(event) {
if (event.target.closest(".group")) {
const reactButton = event.target.closest(".group").querySelector(".react-button");
if (reactButton) {
reactButton.classList.remove("hidden");
}
}
});

document.addEventListener("mouseout", function(event) {
if (event.target.closest(".group")) {
const reactButton = event.target.closest(".group").querySelector(".react-button");
if (reactButton) {
reactButton.classList.add("hidden");
}
}
});

sendButton.addEventListener('click', sendMessage);

Expand Down