-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
135 lines (119 loc) · 5.81 KB
/
index.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
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>AliPic Crawler</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
<link rel="stylesheet" href="/plugins/magnificPopup/magnific-popup.css">
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12 text-center header">
<div class="row">
<div class="col-3 title">
<a href="/">Ali<span>P</span>ic</a><sup>beta</sup>
<p>Грабер картинок из отзывов товаров с Aliexpress.</p>
</div>
<div class="col-9">
<form class="col-12 ali-form text-center form-inline">
Ссылка на товар с Али:
<div class="form-group col-11">
<input type="hidden" id="old_url" value=''>
<input type="hidden" id="ali_page" name="page" value="1">
<input class="form-control col-12" type="text" id="ali_url" name="ali_url" value="">
</div>
<input class="btn btn-primary go-btn col-1" type="submit" value="Go!">
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 content-wrapper">
<div class="content gallery">
<div class="tip">
Вставляйте ссылку на товар в поле вверху и жмите Go! <br>
<p>Примеры ссылок: <br>
https://ru.aliexpress.com/item/Anadzhelia-2017-Sexy-Lotus-leaf-Bikinis-Women-Swimsuit-Brazilian-Bikini-Set-Beach-Bathing-Suit-Push-Up/32805747722.html
<br>
https://ru.aliexpress.com/item/2015-Sexy-One-Piece-Swimsuit-Bandage-For-Women-Solid-White-and-Blue-One-shoulder-Cut-Out/32286543788.html
</p>
</div>
</div>
<div class="pages">
</div>
</div>
</div>
<div class="row">
<div class="col-12 footer">
Найденные баги, пожелания по улучшению и другие вопросы можно присылать сюда <a href="mailto:alipicadm@gmail.com">alipicadm@gmail.com</a>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="/plugins/magnificPopup/jquery.magnific-popup.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script>
$(function(){
// When submit ali form
$('.ali-form').submit(function(event){
event.preventDefault();
sendForm();
});
// When click on paginate
$('body').on('click', '.jLnk', function() {
//Set new page
$('#ali_page').val($(this).text());
// Send ajax
sendForm();
});
$('#ali_url').click(function(){
$(this).select();
});
function sendForm() {
// Clear content block and set loading animation
$('.content').empty().prepend('<img src="/img/load.gif" class="load-img" alt="Loading. Pls wait." />');
$('.pages').empty();
if($('#old_url').val() != $('#ali_url').val())
$('#ali_page').val('1');
$.post("/loader.php", $('.ali-form').serialize())
.done(function(data) {
// prepeare given content
content ='';
data.content.forEach(function(value){
content += '<div class="ali-img" style="background-image: url(\'' + value + '\');" data-mfp-src="' + value + '"></div>';
})
// add content
$('.content').empty().prepend(content);
// Init magnific gallery
$('.gallery').magnificPopup({
delegate: 'div',
type: 'image',
gallery: {
enabled: true
}
});
$pagesUl = '<ul class="pagin">';
for(i=1;i<=data.pages;i++){
if(i == data.currentPage)
$pagesUl += '<li class="pag-item"><span class="pag-link">' + i + '</span></li>';
else
$pagesUl += '<li class="pag-item"><a href="javascript:void(0);" class="pag-link jLnk">' + i + '</a></li>';
}
$pagesUl += '</ul>';
$('.pages').empty().prepend($pagesUl);
$('#old_url').val(data.oldUrl);
$('#ali_url').val(data.oldUrl);
})
.fail(function(data) {
$('.content').empty().prepend('Ooops! Some error happened.');
});
}
});
</script>
</body>
</html>