-
Notifications
You must be signed in to change notification settings - Fork 1
/
myposts.html
153 lines (134 loc) · 7.99 KB
/
myposts.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
151
152
153
<html>
<head>
<title>adpt</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="style.css" rel="stylesheet" />
</head>
<body>
<div class="header">
<nav class="navbar navbar-default1"> <!-- navbar navbar-default -->
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed1" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- <a class="navbar-brand" href="#">ADPT</a> -->
<a href="/"><img src="pet.png" style="margin: 2px; background-color: rgba(244, 235, 239, 0.582); border-radius: 200px; width:50px; height: 50px;">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="/mypets.html" id="mypets-btn">Moje zwierzęta</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" id="myposts-btn">Moje posty</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/fav.html" id="myfav-btn">Obserwowani</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Konto<span class="caret"></span></a>
<ul class="dropdown-menu">
<li id="logowanie">
<h6 class="dropdown-header">Zaloguj się</h6>
<div class="form-group">
<input class="form-control" type="email" placeholder="Email..." id="email_field" />
<input class="form-control" type="password" placeholder="Hasło..." id="password_field" />
<button type="submit" class="btn btn-default" onclick="login()">Zaloguj</button>
</div>
</li>
<li class="form-group" id="logout-btn">
<button type="submit" class="btn btn-default" onclick="logout()">Wyloguj</button>
</li>
<li></li>
<h6 class="dropdown-header" id="q">Nie masz konta?</h6>
<li style="display: flex; justify-content: center;">
<button class="btn btn-default" id="signup-btn" onclick="signupview()">Zarejestruj się</button>
</li>
<li role="separator" class="divider"></li>
<li id="mojekonto"><a href="/profile.html">Moje konto</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div><!-- header -->
<div style="width: 100%; background-color:white; height: 5rem; justify-content:center; display: flex; align-items: center;"><h3>Twoje posty</h3></div>
<div class="cards" >
<!-- <button id="showbtn" class="showbtn" onclick="pokazposty()">Pokaż ogłoszenia</button> -->
<div class="container" id="listamoichpostow">
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/4.8.1/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.8.1/firebase-storage.js"></script>
<script>
if (!firebase.apps.length) {
// Initialize Firebase
var config = {
apiKey: "AIzaSyC12TEpObCW-adZWPWo7fwONg99IXnhEo4",
authDomain: "adopt-a-pet2.firebaseapp.com",
databaseURL: "https://adopt-a-pet2-default-rtdb.firebaseio.com/",
projectId: "adopt-a-pet2",
storageBucket: "adopt-a-pet2.appspot.com",
messagingSenderId: "7865506719",
appId: "1:7865506719:web:ecf7682dadb3ea3e74fbaa"
};
// var app = firebase.initializeApp(config);
firebase.initializeApp(config);
}
pokazmojeposty1();
function pokazmojeposty1(){
var lista = document.getElementById('listamoichpostow');
lista.innerHTML="";
firebase.database().ref('/posts/').once('value', function(snapshot) {
snapshot.forEach(function(childSnapshot) {
{
if(firebase.auth().currentUser.uid==childSnapshot.val().uid){
var owner_uid = childSnapshot.val().uid;
var kategoria = childSnapshot.val().type;
var header =childSnapshot.val().header;
var opis=childSnapshot.val().description;
var danewystawiajacego=childSnapshot.val().owner;
var datadodania=childSnapshot.val(). datetime;
var col, im;
var typ=kategoria;
var del_pet_uid = childSnapshot.key;
var pet_uid = childSnapshot.val().petuid;
if(typ == 'psy') {col = 'teal'; im= 'dog.JPG';}
else if(typ == 'koty'){ col = 'purple';im= 'cat.JPG';}
else if(typ =='gryzonie'){ col = 'pink';im= 'hamster.JPG';}
else {col = 'gray'; im='camera.png';};
// lista.innerHTML=lista.innerHTML+"<div class='card'><div class='card-header'><div><button class='btn btn' onclick='usunpost(\""+del_pet_uid+"\",\""+pet_uid+"\")'>Usuń post</button><div><img src="+im+" alt='rover'/></div><div class='card-body'><span class='tag tag-"+col+"'>"+kategoria+"</span><h4>"+header+"</h4><p>"+opis+"</p><div class='user'><img src='https://yt3.ggpht.com/a/AGF-l7-0J1G0Ue0mcZMw-99kMeVuBmRxiPjyvIYONg=s900-c-k-c0xffffffff-no-rj-mo' alt='user' /><div class='user-info'><h5>"+danewystawiajacego+"</h5><small>"+datadodania+"</small></div></div></div></div>";
lista.innerHTML=lista.innerHTML+"<div class='card'><div class='card-header'><button class='btn btn' onclick='usunpost(\""+del_pet_uid+"\",\""+pet_uid+"\")'>Usuń post</button><img src="+im+" alt='rover'/></div><div class='card-body'><span class='tag tag-"+col+"'>"+kategoria+"</span><h4>"+header+"</h4><p>"+opis+"</p><div class='user'><img src='user.png' alt='user' /><div class='user-info'><h5>"+danewystawiajacego+"</h5><small>"+datadodania+"</small></div></div></div></div>";
// console.log("Lista ok");
}
}
}); });
document.getElementById("showbtn").style.display='none';
}
function usunpost(del_pet_uid,pet_uid){
firebase.database().ref('/posts/'+del_pet_uid).remove();
firebase.database().ref('/users/' + firebase.auth().currentUser.uid+'/pets/'+pet_uid).update({
published:"false"
});
location.reload();
}
</script>
<script src="index.js"></script>
</body>
</html>