-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEXAMPLE-CODE.html
266 lines (213 loc) · 11.1 KB
/
EXAMPLE-CODE.html
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name = "format-detection" content = "telephone=no"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>FORTHEKREW MAGAZINE</title>
<script src="js/cordova-2.0.0.js" type="text/javascript" ></script>
<script src="js/InAppPurchaseManager.js" type="text/javascript" ></script>
<script src="js/applicationPreferences.js" type="text/javascript" ></script>
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener('deviceready', function() {
// Product ftk50
window.plugins.inAppPurchaseManager.requestProductData("FTKMAG50", function(productId, title, description, price) {
console.log("productId: " + productId + " title: " + title + " description: " + description + " price: " + price);
// verify product has already been purchases and unlock
var productIds1 = ["FTKMAG50"];
for (var i = 0; i < productIds1.length; i++) {
var productId = productIds1[i];
window.plugins.applicationPreferences.get(productId, function(result) {
if (result) {
unlockProduct(productId);
console.log("restart unlocked: " + productId);
}
});
}
},
function(id) {
console.log("Invalid product id: " + id);
});
// Product ftk49
window.plugins.inAppPurchaseManager.requestProductData("FTKMAG49", function(productId, title, description, price) {
console.log("productId: " + productId + " title: " + title + " description: " + description + " price: " + price);
// verify product has already been purchases and unlock
var productIds1 = ["FTKMAG49"];
for (var i = 0; i < productIds1.length; i++) {
var productId = productIds1[i];
window.plugins.applicationPreferences.get(productId, function(result) {
if (result) {
unlockProduct(productId);
console.log("restart unlocked: " + productId);
}
});
}
},
function(id) {
console.log("Invalid product id: " + id);
});
// unlock product
function unlockProduct(productId) {
var a = "FTKMAG50",
b = "FTKMAG49";
if(productId == a) {
$('.ftk50 .button-background div:nth-child(1n)').hide();
$('.ftk50 .button-background').addClass('highlight-color');
$('.ftk50 .button-background div:nth-child(2n)').fadeIn();
}
if(productId == b) {
$('.ftk49 .button-background div:nth-child(1n)').hide();
$('.ftk49 .button-background').addClass('highlight-color');
$('.ftk49 .button-background div:nth-child(2n)').fadeIn();
}
console.log('unlocked: ' + productId);
}
// unlock product
window.plugins.inAppPurchaseManager.onPurchased = function(transactionIdentifier, productId, transactionReceipt) {
console.log('purchased: ' + productId);
window.plugins.applicationPreferences.set(productId, true, function() {
unlockProduct(productId);
});
}
// restore products
window.plugins.inAppPurchaseManager.onRestored = function(transactionIdentifier, productId, originalTransactionReceipt) {
window.plugins.applicationPreferences.set(productId, true, function() {
unlockProduct(productId);
// $('#popupPadded h2').removeClass('loader');
$('.restore-purchases-btn').hide();
$('.restore-purchases-btn-complete').fadeIn();
$('.purchase-message').hide();
$('.purchase-message-complete').show();
});
console.log('restored: ' + productId);
}
// onFailed
window.plugins.inAppPurchaseManager.onFailed = function(errno, errtext) {
console.log('failed: ' + errtext);
}
}); // on device ready close
// process the confirmation dialog result
function onConfirm(button) {
if(button == 2) {
window.plugins.inAppPurchaseManager.restoreCompletedTransactions();
// $('#popupPadded h2').addClass('loader');
}
}
// Show a custom confirmation dialog
function showConfirm() {
navigator.notification.confirm(
'Restore All Purchases?', // message
onConfirm, // callback to invoke with index of button pressed
'FTK Magazine', // title
'Cancel, OK' // buttonLabels
);
}
</script>
<link href="css/jquery.mobile-1.2.0.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/bartender.css" type="text/css" rel="stylesheet" />
<link href="css/jquery-mobile.css" type="text/css" rel="stylesheet" />
<link href="css/jquery.mobile.iscrollview.css" media="screen" rel="stylesheet" type="text/css" />
<script src="js/jquery.mobile-1.2.0.js" type="text/javascript"></script>
<script src="js/iscroll.js" type="text/javascript"></script>
<script src="js/jquery.mobile.iscrollview.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" data-theme="a" id="page1">
<div data-role="header" data-position="fixed" data-tap-toggle="false" class="animated-icons"> <a href="#" data-icon="home" id="home" data-iconpos="notext">Home</a> <a data-icon="gear" data-iconpos="notext" href="#popupPadded" data-rel="popup" data-transition="fade" data-position-to="window" id="settings-home">Settings</a>
<h1>FORTHEKREW LIBRARY</h1>
</div>
<!-- /header -->
<div id="results"></div>
<div data-role="content" data-iscroll="">
<ul data-inset="true" data-role="listview" data-theme="a" id="ftk-list">
<li> <a href="#"><img src="img/50-icon2.jpg" class="my-test" />
<h3>Issue#50</h3>
<p>September-October 2012<br/>
Cover: Gary Bolos</p>
<div class="description-long">Trick tip with Dan Plunkett. Interviews with Gary Bolos and John DiLorenzo. Scene check out Naples, Florida. Coming up with Caleb Des Cognets. Shoplifter with Relief Skate Supply.</div>
<h4>$1.99</h4>
<div class="ftk-btn-wrap ftk50">
<div class="glow-hover-effect"></div>
<div class="button-background">
<input type="button" value="Buy Now" data-ajax="false" id="ftk50" />
<input type="button" onClick="window.open('ftk50.html','_self');" value="View Magazine" data-ajax="false" id="ftk50-view" />
</div>
</div>
</a> <a href="#" data-theme="a"></a> </li>
<li><a href="#"><img src="img/49-icon.png" />
<h3>Issue#49</h3>
<p>July-August 2012<br/>
Cover: Josh Weathers</p>
<div class="description-long">Trick tip with Andrew Edge. Interviews with Nate Greenwood and Josh Weathers. Scene check out Jacksonville, Florida. Hemming Plaza. Go Skateboarding Day. Coming ups, Chris Lesh & more.</div>
<h4>$1.99</h4>
<div class="ftk-btn-wrap ftk49">
<div class="glow-hover-effect"></div>
<div class="button-background">
<input type="button" value="Buy Now" data-ajax="false" id="ftk49" />
<input type="button" onClick="window.open('ftk49.html','_self');" value="View Magazine" data-ajax="false" id="ftk49-view" />
</div>
</div>
</a> <a href="#" data-theme="a"></a> </li>
</ul>
</div>
<!--/content-->
<div data-role="footer" data-id="mainFooter" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar" data-grid="b" id="slick-footer">
<ul class="apple-navbar-ui comboSprite" id="footer-animate">
<li class"settings-page"><a href="#popupPadded" data-rel="popup" data-transition="fade" data-position-to="window" data-icon="features" id="more-page">Settings</a></li>
<li class"library-page-active"><a data-icon="brands" class="ui-btn-active ui-state-persist ui-btn-active-stay">Library</a></li>
<li><a href="https://www.facebook.com/ftkmagazine" target="_blank" data-icon="contact">Facebook</a></li>
</ul>
</div>
</div>
<div id="popupPadded" data-role="popup" data-theme="a" data-overlay-theme="a">
<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right close-btn">Close</a>
<h2>Settings</h2>
<p class="purchase-message">If you have previously purchased magazines that are not in your library, and would like to restore them please click below.</p>
<p class="purchase-message-complete">Your download(s) are now complete. Thanks for keeping up with our mag. More good things to come, stay tuned!</p>
<div id="restore-purchases"> <a href="#" data-role="button" onclick="showConfirm(); return false;" id="restore-purchases-btn" class="restore-purchases-btn">Restore All Purchases</a> <a href="#page1" data-role="button" class="restore-purchases-btn-complete ui-btn-active ui-state-persist" style="display:none" data-transition="fade">Restore Complete</a>
</div>
</div><!--#popupPadded-->
</div>
<!--/page-->
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('.close-btn').click(function () {
$('.library-page-active a').addClass('ui-btn-active');
})
$('#ftk-list img').fadeIn(1000);
setTimeout (function(){ $('.apple-navbar-ui li').fadeIn(500); },1000);
$('#ftk-list li a input').buttonMarkup({ corners: true, theme: "a" });
$('#ftk50').bind('touchstart', function() {
$('.ftk50 .glow-hover-effect').fadeIn();
window.plugins.inAppPurchaseManager.makePurchase('FTKMAG50', 1);
});
$('#ftk50').bind('touchend', function() {
$('.ftk50 .glow-hover-effect').fadeOut();
});
$('#ftk50-view').bind('touchstart', function() {
$('.ftk50 .glow-hover-effect').fadeIn();
});
$('#ftk50-view').bind('touchend', function() {
$('.ftk50 .glow-hover-effect').fadeOut();
});
$('#ftk49').bind('touchstart', function() {
$('.ftk49 .glow-hover-effect').fadeIn();
window.plugins.inAppPurchaseManager.makePurchase('FTKMAG49', 1);
});
$('#ftk49').bind('touchend', function() {
$('.ftk49 .glow-hover-effect').fadeOut();
});
$('#ftk49-view').bind('touchstart', function() {
$('.ftk49 .glow-hover-effect').fadeIn();
});
$('#ftk49-view').bind('touchend', function() {
$('.ftk49 .glow-hover-effect').fadeOut();
});
});
</script>
</body>
</html>