diff --git a/suchwowx/templates/profile.html b/suchwowx/templates/profile.html index 904df83..a32d5a7 100644 --- a/suchwowx/templates/profile.html +++ b/suchwowx/templates/profile.html @@ -21,40 +21,67 @@

Tipped WOW: ?

From Local Database

-

- Handle: - {% if is_user %} - - Publish AVAX - {% else %} - {{ user.handle }} - {% endif %} -

-

- Wownero Address: - {% if is_user %} - - Publish AVAX - {% else %} - {{ user.wownero_address }} - {% endif %} -

-

- Metadata IPFS Hash: - {% if is_user %} - - Publish AVAX - {% else %} - {{ user.ipfs_hash }} - {% endif %} -

-

Register Date: {{ user.register_date }}

-

Last Login Date: {{ user.last_login_date }}

-

Moderator: {{ user.is_moderator() }}

-

Verified: {{ user.verified }}

-

Memes Posted: {{ user.memes | length }}

+ {# Handle #} + {% if is_user %} +
+ +
+
+ +

The username/handle you want to be referenced by.

+
+ +
+
+ {% else %} +

Handle: {{ user.handle }}

+ {% endif %} + + {# Wownero Address #} + {% if is_user %} +
+ +
+
+ +

The Wownero wallet address you want to receive tips on.

+
+ +
+
+ {% else %} +

Wownero Address: {{ user.wownero_address or '?' }}

+ {% endif %} + + {# Metadata IPFS Hash #} + {% if is_user %} +
+ +
+
+ +

The IPFS hash of your profile metadata.

+
+ +
+
+ {% else %} +

Metadata IPFS Hash: {{ user.ipfs_hash or '' }}

+ {% endif %} + +

Register Date: {{ user.register_date }} ({{ user.register_date | humanize }})

+

Last Login Date: {{ user.last_login_date }} ({{ user.last_login_date | humanize }})

+

Moderator: {{ user.is_moderator() }}

+

Verified: {{ user.verified }}

+

Memes Posted: {{ user.memes | length }}

{% if user.bio %} -

Bio: {{ user.bio }}

+

Bio: {{ user.bio }}

{% endif %} {% if user.website %}

Website: {{ user.website_url }}

@@ -105,23 +132,26 @@ if (userProfile.userHandle){document.getElementById('userHandle').innerHTML = userProfile.userHandle}; if (userProfile.wowneroAddress){document.getElementById('wowneroAddress').innerHTML = userProfile.wowneroAddress}; if (userProfile.metadataIPFSHash){document.getElementById('metadataIPFSHash').innerHTML = userProfile.metadataIPFSHash}; - if (userProfile.tippedAVAX){document.getElementById('tippedAVAX').innerHTML = userProfile.tippedAVAX}; - document.getElementById('tippedWOWX').innerHTML = 0; + if (userProfile.tippedAVAX){document.getElementById('tippedAVAX').innerHTML = w3.utils.fromWei(userProfile.tippedAVAX)}; + if (userProfile.tippedWOWX){document.getElementById('tippedWOWX').innerHTML = w3.utils.fromWei(userProfile.tippedWOWX)}; return } - async function publishHandleAVAX() { + async function publishHandle() { + document.getElementById('publishHandle').classList.add('is-loading'); const handle = document.getElementById('handleInput').value; if (handle == "") { notif('Cannot publish an empty value.', 'warning'); + document.getElementById('publishHandle').classList.remove('is-loading'); + return false; } await addAvalancheNetwork(); - const walletAddress = await getMetamaskAccount(); - const gasPrice = await w3.eth.getGasPrice(); - const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){ - return gas; - }); try { + const walletAddress = await getMetamaskAccount(); + const gasPrice = await w3.eth.getGasPrice(); + const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){ + return gas; + }); notif(`Publishing user handle "${handle}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info'); let res = await contract.methods.setUserHandle(handle).send({ from: walletAddress, @@ -133,21 +163,25 @@ window.location.href = ""; } catch(e) { notif(e.message, 'warning'); + document.getElementById('publishHandle').classList.remove('is-loading'); } } async function publishWowneroAddress() { + document.getElementById('publishWowneroAddress').classList.add('is-loading'); const address = document.getElementById('wowneroAddressInput').value; if (address == "") { notif('Cannot publish an empty value.', 'warning'); + document.getElementById('publishWowneroAddress').classList.remove('is-loading'); + return false; } await addAvalancheNetwork(); - const walletAddress = await getMetamaskAccount(); - const gasPrice = await w3.eth.getGasPrice(); - const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){ - return gas; - }); try { + const walletAddress = await getMetamaskAccount(); + const gasPrice = await w3.eth.getGasPrice(); + const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){ + return gas; + }); notif(`Publishing Wownero address "${address.slice(0, 6)}...${address.slice(-6)}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info'); let res = await contract.methods.setUserWowneroAddress(address).send({ from: walletAddress, @@ -159,22 +193,26 @@ window.location.href = ""; } catch(e) { notif(e.message, 'warning'); + document.getElementById('publishWowneroAddress').classList.remove('is-loading'); } } async function publishMetadataIPFSHash() { + document.getElementById('publishMetadataIPFSHash').classList.add('is-loading'); const _hash = document.getElementById('metadataIPFSHashInput').value; if (_hash == "") { notif('Cannot publish an empty value.', 'warning'); + document.getElementById('publishMetadataIPFSHash').classList.remove('is-loading'); + return false; } await addAvalancheNetwork(); - const walletAddress = await getMetamaskAccount(); - const gasPrice = await w3.eth.getGasPrice(); - const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){ - return gas; - }); try { - notif(`Publishing user profile metadata IPFS hash ${_hash} to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info'); + const walletAddress = await getMetamaskAccount(); + const gasPrice = await w3.eth.getGasPrice(); + const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){ + return gas; + }); + notif(`Publishing user profile metadata IPFS hash "${_hash}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info'); let res = await contract.methods.setUserMetadata(_hash).send({ from: walletAddress, value: 0, @@ -185,6 +223,7 @@ window.location.href = ""; } catch(e) { notif(e.message, 'warning'); + document.getElementById('publishMetadataIPFSHash').classList.remove('is-loading'); } } @@ -193,8 +232,5 @@ }); -