-
Notifications
You must be signed in to change notification settings - Fork 0
/
photos.html
150 lines (114 loc) · 4.92 KB
/
photos.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
<html>
<head>
<body bgcolor="black">
<link rel="stylesheet" href="empi style.css">
<div id="header1">
<a href="homepage.html">
<img src="logo.PNG" class="logo"></a>
<div class="btn-group">
<a href="empi lights.html">
<button class="button buttonn2" class="flex-item"> Profiles </button>
</a>
<a href="posts.html">
<button class="button button3" class="flex-item">Posts</button>
</a>
<a href="viewalbums.html">
<button class="button button4" margin-left="5px"> Albums </button>
</a>
</div>
</a>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript">
</script>
<script src="jquery-3.2.1.js"></script>
<script>
var photos;
var nPhotos = 4999;
$(document).ready(function()
{
var root = 'https://jsonplaceholder.typicode.com';
$.get('https://jsonplaceholder.typicode.com/photos',function(data)
{
photos = data;
});
setTimeout(function()
{
getPhotos();
$(".nextphotos").on("click", function()
{
getPhotos();
});
}, 1000);
});
function getPhotos()
{
if(nPhotos >= 0)
{
for(var i = nPhotos; i >= nPhotos - 13; i--)
{
var photoDiv = document.createElement("div");
$("#albumId").append(photos[i].albumId);
$("#id").append(photos[i].id);
$("#title").append(photos[i].title);
$("#url").append(photos[i].url);
$("#thumbnailUrl").append(photos[i].thumbnailUrl);
$(photoDiv).addClass("photoDiv");
$(photoDiv).attr("style", "background-image: url(\"" + photos[i].thumbnailUrl + "\");");
$(photoDiv).attr("onClick", "fullScreen(" + photos[i].id +")");
$("#photoDisplay").append(photoDiv);
$("#photoDisplay").show();
}
$(".nextphotos").insertAfter(photoDiv);
nPhotos -= 14;
}
else
{
$(".nextphotos").hide();
}
}
function fullScreen(id)
{
id -= 1;
var photoFS = document.createElement("div");
var details = document.createElement("div");
var pTitle = document.createElement("span");
var pAuthor = document.createElement("p");
var pAlbum = document.createElement("p");
$(photoFS).addClass("photoDiv2");
$(photoFS).attr("style", "background-image: url(\"" + photos[id].url + "\");");
$(".fullScreen").append(photoFS);
$(".fullScreen").show();
$(details).addClass("detailsPic");
$(pTitle).addClass("pTitle");
$(pTitle).text("Title: " + photos[id].title);
$(details).append(pTitle);
$(details).append(pAuthor);
$(details).append(pAlbum);
$(".photoFS").append(details);
$(".fullScreen").on("click", function(e){
$(".fullScreen").empty();
$(".fullScreen").hide();
});
$.ajax({
url: root + '/photos?id=' + id,
method: 'GET'
}).then(function(data) {
$("#title").html(photos[id].title);
});
}
</script>
</head>
<body>
<br>
<br>
<div class="fullScreen">
</div>
<div class="containerPhoto">
<span>
<div id="photoDisplay"></div>
</span>
<button class="nextphotos" id="nextpoto">View More Photos </button>
</div>
</body>
</html>