mirror of
https://github.com/OutCast3k/coinbin.git
synced 2026-05-12 05:22:47 +02:00
Added cookie class
to be able to store information beyond sessions
This commit is contained in:
parent
9a0175e18f
commit
745f32f0e0
44
index.html
44
index.html
@ -37,6 +37,8 @@
|
||||
|
||||
<script type="text/javascript" src="js/coin.js"></script>
|
||||
<script type="text/javascript" src="js/coinbin.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/cookie.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -54,28 +56,28 @@
|
||||
<a href="#home" class="navbar-brand" id="homeBtn"><img src="images/coinbin.gif" style="height:25px;margin-top:-5px"></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-plus"></span> New<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#newAddress" data-toggle="tab">Address</a></li>
|
||||
<li><a href="#newSegWit" data-toggle="tab">SegWit Address</a></li>
|
||||
<li><a href="#newMultiSig" data-toggle="tab">MultiSig Address</a></li>
|
||||
<li><a href="#newTimeLocked" data-toggle="tab">Time Locked Address</a></li>
|
||||
<li><a href="#newHDaddress" data-toggle="tab">HD Address</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#newTransaction" data-toggle="tab">Transaction</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#verify" data-toggle="tab"><span class="glyphicon glyphicon-ok"></span> Verify</a></li>
|
||||
<li><a href="#sign" data-toggle="tab"><span class="glyphicon glyphicon-pencil"></span> Sign</a></li>
|
||||
<li><a href="#broadcast" data-toggle="tab"><span class="glyphicon glyphicon-globe"></span> Broadcast</a></li>
|
||||
<li><a href="#wallet" data-toggle="tab"><span class="glyphicon glyphicon-briefcase"></span> Wallet</a></li>
|
||||
<li><a href="#about" data-toggle="tab"><span class="glyphicon glyphicon-info-sign"></span> About</a></li>
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-plus"></span> New<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#newAddress" data-toggle="tab">Address</a></li>
|
||||
<li><a href="#newSegWit" data-toggle="tab">SegWit Address</a></li>
|
||||
<li><a href="#newMultiSig" data-toggle="tab">MultiSig Address</a></li>
|
||||
<li><a href="#newTimeLocked" data-toggle="tab">Time Locked Address</a></li>
|
||||
<li><a href="#newHDaddress" data-toggle="tab">HD Address</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#newTransaction" data-toggle="tab">Transaction</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#verify" data-toggle="tab"><span class="glyphicon glyphicon-ok"></span> Verify</a></li>
|
||||
<li><a href="#sign" data-toggle="tab"><span class="glyphicon glyphicon-pencil"></span> Sign</a></li>
|
||||
<li><a href="#broadcast" data-toggle="tab"><span class="glyphicon glyphicon-globe"></span> Broadcast</a></li>
|
||||
<li><a href="#wallet" data-toggle="tab"><span class="glyphicon glyphicon-briefcase"></span> Wallet</a></li>
|
||||
<li><a href="#about" data-toggle="tab"><span class="glyphicon glyphicon-info-sign"></span> About</a></li>
|
||||
|
||||
<li class="hidden"><a href="#settings" data-toggle="tab"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
|
||||
<li class="hidden"><a href="#fees" data-toggle="tab"><span class="glyphicon glyphicon-tag"></span> Fees</a></li>
|
||||
</ul>
|
||||
<li class="hidden"><a href="#settings" data-toggle="tab"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
|
||||
<li class="hidden"><a href="#fees" data-toggle="tab"><span class="glyphicon glyphicon-tag"></span> Fees</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1933,32 +1933,37 @@ $(document).ready(function() {
|
||||
|
||||
$("#coinjs_coin").change(function(){
|
||||
|
||||
var o = ($("option:selected",this).attr("rel")).split(";");
|
||||
var optionSeleted = ($("option:selected",this).attr("rel")).split(";");
|
||||
|
||||
let cookieSelectedCoin = new Cookie("coinbin_coin");
|
||||
cookieSelectedCoin.setCookie(optionSeleted)
|
||||
|
||||
console.log(cookieSelectedCoin.cookieValue);
|
||||
|
||||
// deal with broadcasting settings
|
||||
if(o[5]=="false"){
|
||||
if(optionSeleted[5]=="false"){
|
||||
$("#coinjs_broadcast, #rawTransaction, #rawSubmitBtn, #openBtn").attr('disabled',true);
|
||||
$("#coinjs_broadcast").val("coinb.in");
|
||||
} else {
|
||||
$("#coinjs_broadcast").val(o[5]);
|
||||
$("#coinjs_broadcast").val(optionSeleted[5]);
|
||||
$("#coinjs_broadcast, #rawTransaction, #rawSubmitBtn, #openBtn").attr('disabled',false);
|
||||
}
|
||||
|
||||
// deal with unspent output settings
|
||||
if(o[6]=="false"){
|
||||
if(optionSeleted[6]=="false"){
|
||||
$("#coinjs_utxo, #redeemFrom, #redeemFromBtn, #openBtn, .qrcodeScanner").attr('disabled',true);
|
||||
$("#coinjs_utxo").val("coinb.in");
|
||||
} else {
|
||||
$("#coinjs_utxo").val(o[6]);
|
||||
$("#coinjs_utxo").val(optionSeleted[6]);
|
||||
$("#coinjs_utxo, #redeemFrom, #redeemFromBtn, #openBtn, .qrcodeScanner").attr('disabled',false);
|
||||
}
|
||||
|
||||
// deal with the reset
|
||||
$("#coinjs_pub").val(o[0]);
|
||||
$("#coinjs_priv").val(o[1]);
|
||||
$("#coinjs_multisig").val(o[2]);
|
||||
$("#coinjs_hdpub").val(o[3]);
|
||||
$("#coinjs_hdprv").val(o[4]);
|
||||
$("#coinjs_pub").val(optionSeleted[0]);
|
||||
$("#coinjs_priv").val(optionSeleted[1]);
|
||||
$("#coinjs_multisig").val(optionSeleted[2]);
|
||||
$("#coinjs_hdpub").val(optionSeleted[3]);
|
||||
$("#coinjs_hdprv").val(optionSeleted[4]);
|
||||
|
||||
// hide/show custom screen
|
||||
if($("option:selected",this).val()=="custom"){
|
||||
|
||||
43
js/cookie.js
Normal file
43
js/cookie.js
Normal file
@ -0,0 +1,43 @@
|
||||
class Cookie {
|
||||
constructor(name) {
|
||||
this.cookieName = name;
|
||||
|
||||
// read the cookies value (initializes cookieValue)
|
||||
this.readCookie();
|
||||
}
|
||||
|
||||
readCookie() {
|
||||
var allCookies = document.cookie;
|
||||
|
||||
// find the cookie that is currently being looked at.
|
||||
allCookies.split(";").forEach((_, cookie) => {
|
||||
var currentCookieName, currentCookieValue = cookie.split("=");
|
||||
|
||||
if(currentCookieName = this.cookieName)
|
||||
{
|
||||
// set cookieValue to the value of this cookie
|
||||
this.cookieValue = currentCookieValue;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// default to NULL if cookie was not found
|
||||
this.cookieValue = NULL;
|
||||
}
|
||||
|
||||
setCookie(cookieValue) {
|
||||
// update internal record
|
||||
this.cookieValue = currentCookieValue;
|
||||
|
||||
// prepare value for storing
|
||||
cookieValueJSON = JSON.stringify(cookieValue);
|
||||
|
||||
// set cookie with expiry on browser close
|
||||
document.cookie = this.cookieName+"="+cookieValueJSON;
|
||||
}
|
||||
|
||||
getCookieValue() {
|
||||
this.readCookie();
|
||||
return this.cookieValue;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user