-
Notifications
You must be signed in to change notification settings - Fork 14
/
demo-doge.php
executable file
·170 lines (143 loc) · 5.14 KB
/
demo-doge.php
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
<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
require_once("models/ajax_calls.php");
?>
<div class='container container_12'>
<div class="currency">
<img src="images/dogecoin.png">
<p class="supplemental">Converted Amount</p>
<p class="converted">Ɖ <span class="doge"></span></p>
</div>
<div class="amount">
<form method="post">
<label for="dollars" class="symbol">$</label>
<input type="number" name="dollars" id="dollars" class="dollars">
<div class="calc">
<div class="key">1</div>
<div class="key">2</div>
<div class="key">3</div>
<div class="key">4</div>
<div class="key">5</div>
<div class="key">6</div>
<div class="key">7</div>
<div class="key">8</div>
<div class="key">9</div>
<div class="btnkey">del</div>
<div class="key">0</div>
<div class="key">.</div>
</div>
<input type="submit" id="submit" >
</form>
</div>
<div class="transaction_container grid_10 push_1">
<div class="instructions">Please send <span class="green"><span class="conversion"></span> DOGE</span> to the address below:</div>
<div class="box">
<div class="textaddress"></div><br>
<div class="addressqr"></div>
</div>
<div class="preloader"><img src="images/ajax-loader.gif"></div>
<div class="verified offscreenbottom"></div>
<a href="/demo-pos.php" class="new"><i class="fa fa-plus-circle"></i></a>
</div>
</div>
</div>
</div>
<div id='bottom'></div>
</div>
<?php include("footer.php");?>
<script type="text/javascript">
jQuery(document).ready(function(){
var address;
//get address for this transaction
var getaddress = $.ajax( '/models/get_address.php' + '?user=' + 2 + '&type=doge' );
getaddress.done(function(data) {
address = getAddress2(data);
//clear any stacked payments
var clear = $.ajax( '/models/verify.php' + '?address=' + address + '&user=' + 2 );
clear.done(function(data){
//alert('/models/verify.php' + '?address=' + address + '&user=' + <?php echo $loggedInUser->user_id; ?>);
});
});
<?php if (isMobile()) {?>
jQuery('#dollars').focus();
<?php } ?>
//number pad jquery stuff
$('.key').click(function(event){
var numBox = jQuery('#dollars');
if(this.innerHTML == '0'){
if (numBox.val().length > 0) {
numBox.val(numBox.val() + this.innerHTML);
}
}
else {
numBox.val(numBox.val() + this.innerHTML);
}
jQuery('#dollars').trigger("keyup");
event.stopPropagation();
});
$('.btnkey').click(function(event){
if(this.innerHTML == 'del'){
var numBox = jQuery('#dollars');
if(numBox.val().length > 0){
numBox.val( numBox.val().substring(0, numBox.val().length - 1));
}
}
else{
document.getElementById('numBox').innerHTML = '';
}
jQuery('#dollars').trigger("keyup");
event.stopPropagation();
});
jQuery('#dollars').keyup(function(){
amount = jQuery(this).val();
var tempconversion = $.ajax( '/models/get_doge_conversion.php' + '?amount=' + amount + '¤cy=USD')
.done(function(data) {
doge = getConversion2(data);
jQuery('.converted .doge').text(doge);
});
});
jQuery('#submit').click(function(event){ //fetch search results whenever a key is pressed
var amount;
event.preventDefault();
jQuery(".amount").addClass('offscreenright').fadeOut(600);
jQuery(".currency").addClass('offscreenleft').fadeOut(600);
jQuery("#dollars").blur();
amount = jQuery('#dollars').val();
//fire first ajax call for conversion
var conversion = $.ajax( '/models/get_doge_conversion.php' + '?amount=' + amount + '¤cy=USD' )
.done(function(data) {
//when it returns done, process it...
doge = getConversion2(data);
jQuery('.transaction_container').fadeIn(500);
//and start checking...
autoUpdate();
})
.fail(function() {
alert( "error" );
})
function autoUpdate(){
//update every 5 seconds
var payment = $.ajax( '/models/verify.php' + '?address=' + address + '&user=' + 2 );
payment.done(function(data){
if (data >= doge){
jQuery ('.verified').text("Payment Verified: " + data + "DOGE").fadeIn(100).removeClass('offscreenbottom');
clearTimeout(timeoutId);
jQuery('.preloader').fadeOut(100);
} else if (data < doge && data > 0){
more = doge - data;
jQuery ('.verified').text("Insufficient Payment: " + data + "DOGE (need " + more + " more)").fadeIn(100).removeClass('offscreenbottom').addClass("insufficient");
jQuery('.preloader').fadeOut(100);
clearTimeout(timeoutId);
}
});
var timeoutId = setTimeout(autoUpdate, 5000);
}
});
});
</script>