forked from laantungir/super_ball
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5152bb6e5e | ||
| 9285f8e583 | |||
| c5ec067a79 | |||
| 387f5d4725 |
49
Trash/trash.json
Normal file
49
Trash/trash.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
Reply to a post from Primal
|
||||||
|
|
||||||
|
{
|
||||||
|
"kind": 1,
|
||||||
|
"created_at": 1763420960,
|
||||||
|
"content": "From Primal.",
|
||||||
|
"pubkey": "8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e",
|
||||||
|
"id": "555c77e419c6f34d1d36b6baf36489c5eb17d829645c940fc996d90c26df59a1",
|
||||||
|
"tags": [
|
||||||
|
[
|
||||||
|
"e",
|
||||||
|
"ac50dd87901863590d577fb9080ab294b8dd1b6b10563e9733d5bad817c735db",
|
||||||
|
"wss://nos.lol",
|
||||||
|
"root"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"p",
|
||||||
|
"8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"r",
|
||||||
|
"wss://nostr.mom/"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"r",
|
||||||
|
"wss://relay.laantungir.net/"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"sig": "5ab8f7b43e972e2089ebc95f68c49cace183832a3f867801a85c689ce6797eaa52a60ba07847212019fc2361ffca276c74f9cd69402095c6c783faac2c827bde"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reply to post from proposed superball builder change.
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "56e6dadc32afe11f13e83fcf8107ea8a819e4a96232d64eacafd10370224e685",
|
||||||
|
"sig": "3766102783acfc7654f134b1dc5fd716e89e154fc81a96c7f60d20a867e5b52919cdfa7a01151550880e4e8a2945ef05feb43c022bbd7761724ded8308254b1d",
|
||||||
|
"kind": 1,
|
||||||
|
"tags": [
|
||||||
|
[
|
||||||
|
"e",
|
||||||
|
"ac50dd87901863590d577fb9080ab294b8dd1b6b10563e9733d5bad817c735db",
|
||||||
|
"root"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"pubkey": "8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e",
|
||||||
|
"content": "Yeah, it is a great night.",
|
||||||
|
"created_at": 1763420892
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<div class="tab active" data-tab="tab1">Post</div>
|
<div class="tab active" data-tab="tab1">Post</div>
|
||||||
<div class="tab" data-tab="tab2">Reply</div>
|
<div class="tab" data-tab="tab2">Reply</div>
|
||||||
<div class="tab" data-tab="tab3">Create Profile</div>
|
<div class="tab" data-tab="tab3">Create/Edit Profile</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-content active" id="tab1">
|
<div class="tab-content active" id="tab1">
|
||||||
<h3>Post</h3>
|
<h3>Post</h3>
|
||||||
@@ -42,17 +42,30 @@
|
|||||||
|
|
||||||
<div class="tab-content" id="tab2">
|
<div class="tab-content" id="tab2">
|
||||||
<h3>Reply</h3>
|
<h3>Reply</h3>
|
||||||
<label for="reply-id">Replying To:</label>
|
<label for="nevent">Nevent:</label>
|
||||||
<textarea id="reply-id" placeholder="Enter the eventId..."></textarea>
|
<textarea id="nevent" placeholder="Enter the nevent for the note..."></textarea>
|
||||||
|
|
||||||
<label for="reply-content">Message Content:</label>
|
<label for="reply-content">Message Content:</label>
|
||||||
<textarea id="reply-content" rows="3" placeholder="Enter your message content..."></textarea>
|
<textarea id="reply-content" rows="3" placeholder="Enter your message content..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab-content" id="tab3">
|
<div class="tab-content" id="tab3">
|
||||||
<h3>Create Profile</h3>
|
<h3>Create/Edit Profile</h3>
|
||||||
<label for="name">Name:</label>
|
<label for="name">Name:</label>
|
||||||
<textarea id="name" placeholder="Enter your name..."></textarea>
|
<textarea id="name" placeholder="Enter your name..."></textarea>
|
||||||
|
<label for="about">About:</label>
|
||||||
|
<textarea id="about" rows="2" placeholder="A short bio..."></textarea>
|
||||||
|
<label for="profile-pic">Profile Picture:</label>
|
||||||
|
<textarea id="profile-pic" placeholder="URL of your profile pic..."></textarea>
|
||||||
|
<label for="display-name">Display Name:</label>
|
||||||
|
<textarea id="display-name" placeholder="Enter your display name..."></textarea>
|
||||||
|
<label for="website">Website:</label>
|
||||||
|
<textarea id="website" placeholder="Web URL..."></textarea>
|
||||||
|
<label for="banner">Banner:</label>
|
||||||
|
<textarea id="banner" placeholder="Enter your bannerm a (~1024x768) wide picture url..."></textarea>
|
||||||
|
<label for="nip05">NIP05:</label>
|
||||||
|
<textarea id="nip05" placeholder="Enter your nip05 in the format username@domain.com..."></textarea>
|
||||||
|
<label for="lud16">Lightning Address:</label>
|
||||||
|
<textarea id="lud16" placeholder="Enter your lightning address..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button onclick="createFinalEvent()">Create Event That Will Be Published Publicly</button>
|
<button onclick="createFinalEvent()">Create Event That Will Be Published Publicly</button>
|
||||||
@@ -119,6 +132,11 @@
|
|||||||
// Show corresponding content
|
// Show corresponding content
|
||||||
const tabId = tab.getAttribute('data-tab');
|
const tabId = tab.getAttribute('data-tab');
|
||||||
document.getElementById(tabId).classList.add('active');
|
document.getElementById(tabId).classList.add('active');
|
||||||
|
|
||||||
|
// If tab3 (Create/Edit Profile) is activated, populate form with existing profile data
|
||||||
|
if (tabId === 'tab3' && userProfileData) {
|
||||||
|
populateProfileForm(userProfileData);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -131,6 +149,7 @@
|
|||||||
let bounceCounter = 0;
|
let bounceCounter = 0;
|
||||||
let discoveredThrowers = [];
|
let discoveredThrowers = [];
|
||||||
let userRelays = [];
|
let userRelays = [];
|
||||||
|
let userProfileData = null; // Store loaded profile data
|
||||||
|
|
||||||
// Initialize NOSTR_LOGIN_LITE
|
// Initialize NOSTR_LOGIN_LITE
|
||||||
async function initializeApp() {
|
async function initializeApp() {
|
||||||
@@ -216,6 +235,7 @@
|
|||||||
if (events.length > 0) {
|
if (events.length > 0) {
|
||||||
console.log('SUCCESS', 'Profile event received');
|
console.log('SUCCESS', 'Profile event received');
|
||||||
const profile = JSON.parse(events[0].content);
|
const profile = JSON.parse(events[0].content);
|
||||||
|
userProfileData = profile; // Store profile data globally
|
||||||
displayProfile(profile);
|
displayProfile(profile);
|
||||||
} else {
|
} else {
|
||||||
console.log('INFO', 'No profile found');
|
console.log('INFO', 'No profile found');
|
||||||
@@ -243,6 +263,23 @@
|
|||||||
console.log('SUCCESS', `Profile displayed: ${name}`);
|
console.log('SUCCESS', `Profile displayed: ${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate profile form with existing profile data
|
||||||
|
function populateProfileForm(profile) {
|
||||||
|
if (!profile) return;
|
||||||
|
|
||||||
|
// Populate each field with existing data if available
|
||||||
|
document.getElementById('name').value = profile.name || '';
|
||||||
|
document.getElementById('about').value = profile.about || '';
|
||||||
|
document.getElementById('profile-pic').value = profile.picture || '';
|
||||||
|
document.getElementById('display-name').value = profile.display_name || profile.displayName || '';
|
||||||
|
document.getElementById('website').value = profile.website || '';
|
||||||
|
document.getElementById('banner').value = profile.banner || '';
|
||||||
|
document.getElementById('nip05').value = profile.nip05 || '';
|
||||||
|
document.getElementById('lud16').value = profile.lud16 || '';
|
||||||
|
|
||||||
|
console.log('INFO', 'Profile form populated with existing data');
|
||||||
|
}
|
||||||
|
|
||||||
// Load user's NIP-65 relay list
|
// Load user's NIP-65 relay list
|
||||||
async function loadUserRelayList() {
|
async function loadUserRelayList() {
|
||||||
if (!userPubkey) return [];
|
if (!userPubkey) return [];
|
||||||
@@ -764,8 +801,16 @@
|
|||||||
|
|
||||||
// Get content based on active tab
|
// Get content based on active tab
|
||||||
let content = '';
|
let content = '';
|
||||||
let eventId = '';
|
let nevent = '';
|
||||||
|
let neventData;
|
||||||
let name = '';
|
let name = '';
|
||||||
|
let about = '';
|
||||||
|
let profilePic = '';
|
||||||
|
let displayName = '';
|
||||||
|
let website = '';
|
||||||
|
let banner = '';
|
||||||
|
let nip05 = '';
|
||||||
|
let lud16 = '';
|
||||||
|
|
||||||
switch(activeTab) {
|
switch(activeTab) {
|
||||||
case 'tab1': // Post
|
case 'tab1': // Post
|
||||||
@@ -773,19 +818,41 @@
|
|||||||
break;
|
break;
|
||||||
case 'tab2': // Reply
|
case 'tab2': // Reply
|
||||||
content = document.getElementById('reply-content').value.trim();
|
content = document.getElementById('reply-content').value.trim();
|
||||||
eventId = document.getElementById('reply-id').value.trim();
|
nevent = document.getElementById('nevent').value.trim();
|
||||||
break;
|
break;
|
||||||
case 'tab3': // Create Profile
|
case 'tab3': // Create Profile
|
||||||
name = document.getElementById('name').value.trim();
|
name = document.getElementById('name').value.trim();
|
||||||
|
about = document.getElementById('about').value.trim();
|
||||||
|
profilePic = document.getElementById('profile-pic').value.trim();
|
||||||
|
displayName = document.getElementById('display-name').value.trim();
|
||||||
|
website = document.getElementById('website').value.trim();
|
||||||
|
banner = document.getElementById('banner').value.trim();
|
||||||
|
nip05 = document.getElementById('nip05').value.trim();
|
||||||
|
lud16 = document.getElementById('lud16').value.trim();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate content based on tab
|
// Validate content based on tab
|
||||||
if (activeTab === 'tab1' || activeTab === 'tab2') {
|
if (activeTab === 'tab1') {
|
||||||
if (!content) {
|
if (!content) {
|
||||||
alert('Please enter message content');
|
alert('Please enter message content');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (activeTab === 'tab2') {
|
||||||
|
if (!content) {
|
||||||
|
alert('Please enter message content');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!nevent.startsWith('nevent')) {
|
||||||
|
alert('Please enter a valid nevent');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
neventData = window.NostrTools.nip19.decode(nevent).data;
|
||||||
|
} catch (error) {
|
||||||
|
alert('Error decoding nevent string', error.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else if (activeTab === 'tab3') {
|
} else if (activeTab === 'tab3') {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
alert('Please enter your name');
|
alert('Please enter your name');
|
||||||
@@ -810,16 +877,26 @@
|
|||||||
eventTemplate = {
|
eventTemplate = {
|
||||||
kind: 1,
|
kind: 1,
|
||||||
content: content,
|
content: content,
|
||||||
tags: [['e', eventId, 'root']],
|
tags: [['e', neventData.id, neventData.relays[0], 'root'], ['p', neventData.author]],
|
||||||
created_at: Math.floor(Date.now() / 1000)
|
created_at: Math.floor(Date.now() / 1000)
|
||||||
};
|
};
|
||||||
|
neventData.relays.slice(1).forEach(relay => {
|
||||||
|
eventTemplate.tags.push(['r', relay]);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tab3': // Create Profile
|
case 'tab3': // Create Profile
|
||||||
eventTemplate = {
|
eventTemplate = {
|
||||||
kind: 0,
|
kind: 0,
|
||||||
content: JSON.stringify({
|
content: JSON.stringify({
|
||||||
name: name
|
name: name,
|
||||||
|
about: about,
|
||||||
|
picture: profilePic,
|
||||||
|
display_name: displayName,
|
||||||
|
website: website,
|
||||||
|
banner: banner,
|
||||||
|
nip05: nip05,
|
||||||
|
lud16: lud16
|
||||||
}),
|
}),
|
||||||
tags: [],
|
tags: [],
|
||||||
created_at: Math.floor(Date.now() / 1000)
|
created_at: Math.floor(Date.now() / 1000)
|
||||||
@@ -830,6 +907,7 @@
|
|||||||
// Your existing event publishing logic here
|
// Your existing event publishing logic here
|
||||||
console.log('Event to publish:', eventTemplate);
|
console.log('Event to publish:', eventTemplate);
|
||||||
// ... rest of your publishing code
|
// ... rest of your publishing code
|
||||||
|
|
||||||
// Sign the event using window.nostr (NIP-07)
|
// Sign the event using window.nostr (NIP-07)
|
||||||
finalEvent = await window.nostr.signEvent(eventTemplate);
|
finalEvent = await window.nostr.signEvent(eventTemplate);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user