-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_works.php
More file actions
143 lines (124 loc) · 3.48 KB
/
my_works.php
File metadata and controls
143 lines (124 loc) · 3.48 KB
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
<!DOCTYPE html>
<html>
<head>
<title>My works</title>
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<style type="text/css">
#search_string
{
width:70%;
}
.pic
{
border-radius: 5px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.15);
width: 20%;
height: 20%;
}
.pic_a
{
padding: 1%;
}
</style>
<link href="css/loader.css" rel="stylesheet">
</head>
<body onload="getMyWorks(true,'date')">
<?php
require "db/auth_header.php";
?>
<div id="sort_buttons"></div>
<br>
<div id="result_of_search"></div>
<div id="loader"></div>
<script type="text/javascript">
var search_offset;
var show_end;
var loading_in_process;
function getMyWorks(isFirstCall,sort)
{
if(isFirstCall)
{
search_offset = 0;
document.getElementById("result_of_search").innerHTML = "";
$("#result_of_search").fadeOut();
}
document.getElementById("loader").classList.add('loader');
loading_in_process = true;
document.getElementById("sort_buttons").innerHTML = "<button id='sort_by_date'>Sort by date</button>"+"<button id='sort_by_rating'>Sort by likes</button>";
if(sort == "rating")
{
document.getElementById('sort_by_rating').disabled = true;
document.getElementById('sort_by_date').addEventListener("click", function(){getMyWorks(true,"date");});
}
else
{
document.getElementById('sort_by_date').disabled = true;
document.getElementById('sort_by_rating').addEventListener("click", function(){getMyWorks(true,"rating");});
}
$.ajax({
url:"db/get_my_works.php",
type: "GET",
data: {"sort": sort,"offset":search_offset},
success: function(data){
pics = JSON.parse(data);
html_pics = "";
document.getElementById("loader").classList.remove('loader');
loading_in_process = false;
$("#result_of_search").fadeIn("slow");
if(Object.keys(pics).length)
{
for(var i=0;i<Object.keys(pics).length;i++)
{
html_pics = html_pics + "<a href = 'img_page.php?id="+pics[i]["id"]+"' class = 'pic_a'><img src='db/"+pics[i]["filename"]+"' class = 'pic'></a>" + ((i+1)%4==0?"<br>":"");
}
if(isFirstCall)
{
document.getElementById("result_of_search").innerHTML = html_pics;
if(Object.keys(pics).length<40)
{
show_end = false;
document.getElementById("result_of_search").innerHTML += "<br><h3>[END]</h3>";
}
else
{
show_end = true;
window.onscroll = function(){
if(getScrollPercent()>80 && !loading_in_process)
{
search_offset+=40;
search(false,sort);
}
}
}
}
else
document.getElementById("result_of_search").innerHTML += html_pics;
}
else
{
if(isFirstCall)
document.getElementById("result_of_search").innerHTML = "<h3>Nothing here but fake mirrors</h3>";
else
{
if(show_end)
{
show_end = false;
window.onscroll = function(){};
document.getElementById("result_of_search").innerHTML += "<br><h3>[END]</h3>";
}
}
}
},
error: function()
{
alert("error during getting works");
}
});
}
</script>
</body>
</html>