Skip to content

Commit

Permalink
newbie add gas
Browse files Browse the repository at this point in the history
  • Loading branch information
hmisty committed Jan 11, 2024
1 parent 13b1731 commit b1aca8f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
34 changes: 31 additions & 3 deletions scripts/controllers/addressInfoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,44 @@ angular.module('ethExplorer')
$('#dialog-unwrap-wjoule-confirm').modal('show');
}

// 新手加油
$scope.wjUnwrapToNewbie = function () {
$scope.chainId = window.ethereum ? window.ethereum.chainId : '';
$scope.account = window.ethereum ? window.ethereum.selectedAddress : '';

if ($scope.account) { // if having connected account
const from = $scope.account;
const to = $scope.addressId;
const amt = '0.005';
console.log('wjUnwrapTo', from, amt, to);

$('#wj-unwrap-amount').val(amt); // set value, instead of innerText
$('#wj-unwrap-to').val(to);
$('#wj-unwrap-save-info').prop('checked', false);
$('#wj-unwrap-check-balance').prop('checked', false); // don't check newbie's WJ balance

$('#confirm-unwrap-wj-from').text(from); // set innerText for human reading
$('#confirm-unwrap-wj-amount').text(amt ? amt : '0');
$('#confirm-unwrap-wj-amount2').text(amt ? amt : '0');
$('#confirm-unwrap-wj-to').text(to);

$('#dialog-unwrap-wjoule-confirm').modal({keyboard:false, backdrop:'static'});
$('#dialog-unwrap-wjoule-confirm').modal('show');
}
}

$scope.wjUnwrapTo = function () {
const DIALOG_TITLE = 'Unwrap wJ';
const amt = $('#wj-unwrap-amount')[0].value;
const to = $('#wj-unwrap-to')[0].value;
const save_info = $('#wj-unwrap-save-info')[0].checked;
console.log('wjUnwrapTo', amt, to, save_info);
const check_balance = $('#wj-unwrap-check-balance')[0].checked;
console.log('wjUnwrapTo', amt, to, save_info, check_balance);

if (amt && !isNaN(amt)) { // isNaN works, nice.
if (!(amt > 0)) {
dialogShowTxt(DIALOG_TITLE, "错误:wJ数量必须大于0");
} else if (!(parseFloat(amt) < parseFloat($scope.wjBalanceInJoule))) {
} else if (check_balance && !(parseFloat(amt) < parseFloat($scope.wjBalanceInJoule))) {
dialogShowTxt(DIALOG_TITLE, "错误:wJ数量 " + amt + " 不能超过持有量 " + $scope.wjBalanceInJoule);
} else if (window.ethereum && window.ethereum.isConnected()) {
web3.setProvider(window.ethereum);
Expand Down Expand Up @@ -200,6 +227,7 @@ angular.module('ethExplorer')

};


//////////////////////////////////////////////////////////////////////////////
// read functionalities in page scope //
//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -468,7 +496,7 @@ angular.module('ethExplorer')
else
tokenInfo.rarity = 'normal';

console.log(token_id, tokenInfo.rarity);
//console.log(token_id, tokenInfo.rarity);

}

Expand Down
19 changes: 14 additions & 5 deletions views/addressInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ <h1>
链地址
<small>查看链地址信息</small>
</span>
<span class="zoom" ng-style="{ 'display': balance == 0 ? 'inline-block' : 'none' }">
<!--span class="zoom" ng-style="{ 'display': balance == 0 ? 'inline-block' : 'none' }">
<button ng-click="airdrop()">🎁</button>
</span>
</span-->
</h1>

<span style="color:#999"><p style="word-break:break-all;">{{airdrop_hexdata}}</p></span>
Expand All @@ -30,7 +30,7 @@ <h1>
<tbody>
<tr>
<td><b>能量余额:</b></td>
<td>{{balanceInEther || "-"}} J (焦耳),即 {{balance || "-"}} e (能量单位)</td>
<td>{{balanceInEther || "-"}} Joule (焦耳),即 {{balance || "-"}} energy (能量)</td>
</tr>
<tr>
<td><b>数字资产:</b></td>
Expand Down Expand Up @@ -80,7 +80,12 @@ <h1>
</tr>
<tr data-ng-repeat="i2 in allJTI">
<td>{{i2.tag}}</td>
<td><image height="24px" src="{{i2.tokenInfo.image}}" style="filter:invert(5%) sepia(75%) saturate(7378%) hue-rotate(45deg) brightness(114%) contrast(112%);"></image></td>
<td>
<image height="24px" src="{{i2.tokenInfo.image}}" style="filter:invert(5%) sepia(75%) saturate(7378%) hue-rotate(45deg) brightness(114%) contrast(112%);"></image>
<span ng-style="{ 'display': balance == 0 && account ? 'inline-block' : 'none' }">
<button ng-click="wjUnwrapToNewbie()"><font style="color:#ae4c4c">新手加油 0.005 J</font></button>
</span>
</td>
</tr>
<tr data-ng-if="countCryptoJunks > 0">
<td><a href="/#/cryptojunks">CryptoJunks</a></td>
Expand Down Expand Up @@ -117,7 +122,7 @@ <h1>
</tr>
</tbody>
</table>
<small>* 注:J(焦耳)是能量单位。定义 1 J = 1 Ee(E能量)= 10^9 Ge(G能量)= 10^18 e,即 1,000,000,000,000,000,000 e(能量)。</small>
<small>* 注:J, Joule(焦耳)是能量单位。定义 1 J = 1 Ee(E能量)= 10^9 Ge(G能量)= 10^18 e,即 1,000,000,000,000,000,000 energy(能量)。</small>
</div>

<!-- dialog for input to unwrap wJoule -->
Expand All @@ -144,6 +149,10 @@ <h4 class="modal-title"><span id="">Unwrap wJ</span></h4>
<div style="float:right;margin-top:10px;">
<input type="checkbox" checked id="wj-unwrap-save-info"><font color="black">点击确定后不清空输入框</font></input>
</div>
<div style="display:none">
<!-- hidden. used for not checking WJ balance (of this address) when 新手加油-->
<input type="checkbox" checked id="wj-unwrap-check-balance"></input>
</div>
</div>
</code>
</div>
Expand Down

0 comments on commit b1aca8f

Please sign in to comment.