-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (63 loc) · 2.67 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="theme-color" content="#ffffff">
<title>Cordova WooCommerce Oauth</title>
<script src="js/jquery-2.2.4.min.js"></script>
<script src="cordova.js"></script>
<script src="js/oauth/sjcl.js"></script>
<script src="js/oauth/hmac-sha256.js"></script>
<script src="js/oauth/enc-base64-min.js"></script>
<script src="js/oauth/oauth-signature.js"></script>
<script src="js/oauth.js"></script>
<style type="text/css">
*, html, body {margin:0;}
#app {padding:20px;}
.products ul {list-style: none; margin:0; padding: 0}
.products ul:after {content: ''; clear: both; display: table;}
.products ul li {float: left; width: 50%;}
.products ul li span {width: 100%; height: 100px; display: block; position: relative; margin:0; padding:0; background:#ccc;}
.products ul li img {position: absolute; left:0; top:0; right:0; bottom:0; margin:auto; border:0; max-width: 100%; max-height: 100%; display: block}
</style>
</head>
<body>
<div id="app">
<h1>WooCommerce products</h1>
<div class="products"></div>
</div>
<script type="text/javascript">
// getting products from woocommerce
// more in WooCommerce REST API
var url = generateQuery('GET', '/products/', CONFIG);
$.ajax({
type: 'GET',
url: url,
timeout: CONFIG.request_timeout,
success: function(result) {
console.log(result)
var html = '<ul>';
$.each(result, function(i, data){
html += '<li data-id="'+data.id+'">'+
'<span><img src="'+data.images[0].src+'" alt="" /></span>'+
'<p><a href="'+data.permalink+'" target="_blank">'+data.name+'</a></p>'+
'<small>Price: '+data.price+'</small>'+
'</li>';
});
html += '</ul>';
$('.products').append(html);
},
error: function(error) {
console.log(error)
}
});
</script>
</body>
</html>