-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
100 lines (91 loc) · 2.87 KB
/
main.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
var vm = new Vue({
el:"#wrapper",
data:{
trolldata:[],
section:"lol",
load:true,
next:"",
busy:true,
keyword:"",
host:"//bill.hol.es/project/1cak/", //this belongs your host
},
beforeCompile: function () {
this.load = true;
// this.scrolled();
this.getData();
},
methods:{
search:function(){
this.load = true;
this.$http.get("http:"+this.host+'connect.php?search='+this.keyword).then((response)=>{
console.log(JSON.parse(response.body));
trolldata = JSON.parse(response.body);
page = trolldata.page;
this.next = page.next;
post = trolldata.posts;
for (var i = 0; i < post.length; i++) {
this.$http.get('/connect.php?url='+post[i].url).then((response)=>{
if (response.status==200) {
console.log(response.status);
}
});
}
this.trolldata = post;
this.load = false;
});
},
sortenString:function(data){
return data.substr(0,30);
},
scrolled:function(){
var vm = this;
var lock = true;
var section = this.section;
var next = this.next;
vm.$http.get("http:"+this.host+'connect.php?param='+section+'&next='+next).then((response)=>{
trolldata = JSON.parse(response.body);
page = trolldata.page;
this.next = page.next;
post = trolldata.posts;
for (var i = 0; i < post.length; i++) {
this.$http.get('/connect.php?url='+post[i].url).then((response)=>{
if (response.status==200) {
console.log(response.status);
}
});
}
this.trolldata.push(post);
console.log(this.trolldata);
this.load = false;
});
},
setData:function(data){
this.load = true;
this.section = data;
this.getData();
},
getData:function(){
this.$http.get("http:"+this.host+'connect.php?section='+this.section).then((response)=>{
console.log(JSON.parse(response.body));
trolldata = JSON.parse(response.body);
page = trolldata.page;
this.next = page.next;
post = trolldata.posts;
for (var i = 0; i < post.length; i++) {
this.$http.get('/connect.php?url='+post[i].url).then((response)=>{
if (response.status==200) {
console.log(response.status);
}
});
}
this.trolldata = post;
this.load = false;
});
}
}
});
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height()-$(window).height()){
vm.scrolled();
}
});