forked from blockchain/unused-My-Wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallet-index.js
170 lines (133 loc) · 5.05 KB
/
wallet-index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
function numberWithCommas(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
//JQuery Count To
//https://github.com/mhuggins/jquery-countTo
(function($) {
$.fn.countTo = function(options) {
// merge the default plugin settings with the custom options
options = $.extend({}, $.fn.countTo.defaults, options || {});
// how many times to update the value, and how much to increment the value on each update
var loops = Math.ceil(options.speed / options.refreshInterval),
increment = (options.to - options.from) / loops;
var self = this,
loopCount = 0,
value = options.from;
if (self.interval) {
clearInterval(self.interval);
self.interval = null;
}
self.target_value = options.to;
self.interval = setInterval(updateTimer, options.refreshInterval);
function updateTimer() {
value += increment;
loopCount++;
if (isNaN(value)) {
return;
}
self.original_value = value;
$(self).html(formatSymbol(value, symbol_local));
if (typeof(options.onUpdate) == 'function') {
options.onUpdate.call(self, value);
}
if (loopCount >= loops) {
clearInterval(self.interval);
self.interval = null;
value = options.to;
if (typeof(options.onComplete) == 'function') {
options.onComplete.call(self, value);
}
}
}
};
$.fn.countTo.defaults = {
from: 0, // the number the element should start at
to: 100, // the number the element should end at
speed: 1000, // how long it should take to count between the target numbers
refreshInterval: 200, // how often the element should be updated
decimals: 0, // the number of decimal places to show
onUpdate: null, // callback method for every time the element is updated,
onComplete: null // callback method for when the element finishes updating
};
}(jQuery));
$(document).ready(function() {
//Iframe breakout
if (top.location!= self.location) {
top.location = self.location.href
}
try {
$('.slidedeck').slidedeck();
} catch(err) {}
try {
//Popovers!
$("a[rel=popover]")
.popover({
offset: 10
})
.click(function(e) {
e.preventDefault()
});
} catch(err) {}
setInterval(function() {
if ($('#fade1').is(':visible')) {
$('#fade1').hide();
$('#fade2').fadeIn();
} else {
$('#fade1').fadeIn();
$('#fade2').hide();
}
}, 5000);
var transacted = $('.transacted:first-child');
if (transacted.length > 0) {
webSocketConnect(function(ws) {
ws.onmessage = function(e) {
var obj = $.parseJSON(e.data);
symbol = symbol_local;
if (obj.op == 'utx') {
var tx = TransactionFromJSON(obj.x);
var total_received = 0;
for (var i = 0; i < tx.out.length; i++) {
total_received += parseInt(tx.out[i].value);
}
var original_value = parseInt(transacted.original_value);
if (!original_value || isNaN(original_value))
original_value = transacted.find('span').data('c');
var target_val = parseInt(transacted.target_value);
if (!isNaN(target_val) && target_val > original_value)
total_received += target_val - original_value;
var new_value = original_value + total_received;
transacted.countTo({
from: original_value,
to: new_value,
speed: 10000,
refreshInterval: 50
});
}
};
ws.onopen = function() {
ws.send('{"op":"ip_sub", "ip":"127.0.0.1"}');
};
});
}
$('#youtube-preview').click(function() {
$(this).empty().append('<iframe width="100%" height="256" src="https://www.youtube.com/embed/Um63OQz3bjo?autohide=1&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>');
});
setTimeout(function() {
$('#download-instructions-btn').click(function () {
$('#download-instructions').toggle(400);
});
if ($('#slideshow').length > 0) {
var i = 0;
var changeImage = function() {
++i;
if (i == 3)
i = 0;
$('#slideshow img').hide();
$('#slideshow img').eq(i).fadeIn();
};
setInterval(changeImage, 7000);
}
}, 500);
});