-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (44 loc) · 1.53 KB
/
app.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
'use strict'
$(document).ready(function(){
$('.sidenav').sidenav();
$(".dropdown-trigger").dropdown();
$('.fixed-action-btn').floatingActionButton();
$('.collapsible').collapsible();
});
$('body').click(function(e){
page('/', 'other.html')
e.preventDefault();
});
renderPost();
function renderPost(){
$.get("https://jsonplaceholder.typicode.com/posts", function(data, status){
console.log(data);
var template = '';
data.forEach(element => {
template += ` <div class="row">
<div class="col s12 m7">
<div class="card">
<div class="card-image">
<img src="https://via.placeholder.com/600/92c952" class="responsive-img" style="height:200px;">
</div>
<div class="card-content">
<p>${element.body.substr(0,50)} ...</p>
</div>
<div class="row card-action">
<div class="col s4 center-align"><i class="material-icons">thumb_up</i></div>
<div class="col s4 center-align"><i class="material-icons">comment</i></div>
<div class="col s4 center-align"><i class="material-icons">screen_share</i></div>
</div>
</div>
</div>
</div>`;
});
$('#posts').html(template);
});
}
// <div class="card-action">
// <a href="#">Like</a>
// <a href="#">Comment</a>
// <a href="#">Share</a>
// </div>
// https://jsonplaceholder.typicode.com/photos