-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
34 lines (25 loc) · 895 Bytes
/
script.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
$(document).ready(function () {
$.fn.myFunction = function () {
$.getJSON('data.json', function (name) {
$('#gallery-window').empty()
var arr = [];
while (arr.length < 5) {
var r = Math.floor(Math.random() * 40) + 7;
if (arr.indexOf(r) === -1) arr.push(r);
}
console.log(arr)
let newData = [];
name.map((item) => {
let temp = arr.includes(item.id)
temp && newData.push(item);
})
newData.map((data) => {
$('#gallery-window').append(`<div class="gallery-card">\
<img src=${data.img} alt="01" width="600" height="400" />\
<div class="desc">${data.name}</div>\
<a href=${data.url}>Click here to visit</a>\
</div>`);
})
})
}
});