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

Save Network in a cookie #223

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<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>
<li><a href="#settings" data-toggle="tab"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
<li><a href="#fees" data-toggle="tab"><span class="glyphicon glyphicon-tag"></span> Fees</a></li>
</ul>
</div>
</div>
Expand Down
36 changes: 26 additions & 10 deletions js/coinbin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ $(document).ready(function() {

var wallet_timer = false;

var LOCALSTORAGE_COIN_KEY = "coinjs_coin_option"

$("#openBtn").click(function(){
var email = $("#openEmail").val().toLowerCase();
if(email.match(/[\s\w\d]+@[\s\w\d]+/g)){
Expand Down Expand Up @@ -1932,33 +1934,35 @@ $(document).ready(function() {
});

$("#coinjs_coin").change(function(){
// set localStorage for use after page (re)load
localStorage.setItem(LOCALSTORAGE_COIN_KEY, $(this).val());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the custom attributes?


var o = ($("option:selected",this).attr("rel")).split(";");
optionSeleted = ($("option:selected",this).attr("rel")).split(";");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no var ?

Also, s/optionSeleted/optionSelected/


// 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"){
Expand Down Expand Up @@ -2285,4 +2289,16 @@ $(document).ready(function() {
return true;
};

/* set network from localStorage on page load */

function setNetwork () {
var storageItem = localStorage.getItem(LOCALSTORAGE_COIN_KEY);
if(storageItem)
{
$("#coinjs_coin").val(storageItem)
$("#coinjs_coin").trigger("change")
}
}
setNetwork()

});