├── README.md ├── images ├── beats.webp ├── logo.png ├── nikon.webp ├── sofa.webp ├── Capture.JPG ├── airpods.webp ├── banner-1.jpg ├── dummyimg.jpg ├── favicon.png ├── location.png ├── oneplus.webp ├── ordino.webp ├── fortuner.webp ├── logo-blue.png ├── ninjabmw.webp ├── noresults.png ├── product-1.jpg └── homefinishing.webp ├── sw.js ├── css ├── responsive.css └── style.css ├── 404.html ├── index.html └── js └── app.js /README.md: -------------------------------------------------------------------------------- 1 | # basic-olx-clone 2 | 3 | Visit site: https://olx-app-d4585.firebaseapp.com/ 4 | -------------------------------------------------------------------------------- /images/beats.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/beats.webp -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/logo.png -------------------------------------------------------------------------------- /images/nikon.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/nikon.webp -------------------------------------------------------------------------------- /images/sofa.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/sofa.webp -------------------------------------------------------------------------------- /images/Capture.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/Capture.JPG -------------------------------------------------------------------------------- /images/airpods.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/airpods.webp -------------------------------------------------------------------------------- /images/banner-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/banner-1.jpg -------------------------------------------------------------------------------- /images/dummyimg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/dummyimg.jpg -------------------------------------------------------------------------------- /images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/favicon.png -------------------------------------------------------------------------------- /images/location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/location.png -------------------------------------------------------------------------------- /images/oneplus.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/oneplus.webp -------------------------------------------------------------------------------- /images/ordino.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/ordino.webp -------------------------------------------------------------------------------- /images/fortuner.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/fortuner.webp -------------------------------------------------------------------------------- /images/logo-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/logo-blue.png -------------------------------------------------------------------------------- /images/ninjabmw.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/ninjabmw.webp -------------------------------------------------------------------------------- /images/noresults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/noresults.png -------------------------------------------------------------------------------- /images/product-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/product-1.jpg -------------------------------------------------------------------------------- /images/homefinishing.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubaig54/basic-olx-clone/HEAD/images/homefinishing.webp -------------------------------------------------------------------------------- /sw.js: -------------------------------------------------------------------------------- 1 | let appVersion = '1.0'; 2 | 3 | const files = [ 4 | './', 5 | './css/style.css', 6 | './css/responsive.css', 7 | './js/app.js', 8 | './images/logo.png', 9 | './images/favicon.png', 10 | './images/noresults.png', 11 | './images/banner-1.jpg', 12 | ]; 13 | 14 | self.addEventListener('install', async e => { 15 | const cache = await caches.open(appVersion); 16 | cache.addAll(files); 17 | }) 18 | 19 | self.addEventListener('fetch', e => { 20 | const req = e.request; 21 | const url = new URL(req.url); 22 | if(url.origin === location.origin){ 23 | e.respondWith(cacheFirst(req)); 24 | }else{ 25 | e.respondWith(networkFirst(req)); 26 | } 27 | }) 28 | 29 | async function cacheFirst(req){ 30 | const cachedResponse = await caches.match(req); 31 | return cachedResponse || fetch(req); 32 | } 33 | 34 | async function networkFirst(req){ 35 | const cache = await caches.open('dynamic'); 36 | try{ 37 | const res = await fetch(req); 38 | cache.put(req, res.clone()); 39 | return res; 40 | }catch(error){ 41 | return await cache.match(req); 42 | } 43 | } -------------------------------------------------------------------------------- /css/responsive.css: -------------------------------------------------------------------------------- 1 | @media (max-width: 900px){ 2 | header .top .left { 3 | width: auto; 4 | } 5 | .location{ 6 | display: none; 7 | } 8 | /* #signinBtn{ 9 | display: none; 10 | } */ 11 | header .top .right{ 12 | position: fixed; 13 | bottom: 20px; 14 | width: 89%; 15 | } 16 | .signinBtnDiv .dropdown{ 17 | position: fixed; 18 | top: 77px; 19 | right: 38px; 20 | background: #fff; 21 | } 22 | .signinBtnDiv #signinBtn { 23 | padding: 5px !important; 24 | margin: 0 !important; 25 | } 26 | .sellBtnDiv{ 27 | width: 100%; 28 | float: none; 29 | display: flex; 30 | } 31 | #sellBtn{ 32 | margin: auto; 33 | } 34 | #signinPopupContainer, #signupPopupContainer, #categoryPopupContainer, #sellPopupContainer{ 35 | margin: 200px auto; 36 | } 37 | #signinPopup, #signupPopup, #categoryPopup, #sellPopup{ 38 | overflow-x: hidden; 39 | } 40 | .oneThird, .oneFourth, .oneFifth{ 41 | width: 100%; 42 | float: none; 43 | } 44 | .popularCategories .oneThird{ 45 | border-right: solid 1px #ccc; 46 | } 47 | footer .bottom .left, footer .bottom .right { 48 | float: none; 49 | width: 100%; 50 | text-align: center; 51 | } 52 | footer .bottom .right{ 53 | border-top: solid 1px #ccc; 54 | margin: 10px 0; 55 | padding: 10px 0; 56 | } 57 | 58 | 59 | /* ad.html */ 60 | #adDetailsPopup .left{ 61 | width: 100%; 62 | float: none; 63 | } 64 | #adDetailsPopup .right{ 65 | width: 100%; 66 | float: none; 67 | } 68 | #adDetailsPopupContainer .left #showAdImage img { 69 | width: 100%; 70 | height: auto; 71 | } 72 | } -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Page Not Found 7 | 8 | 23 | 24 | 25 |
26 |

404

27 |

Page Not Found

28 |

The specified file was not found on this website. Please check the URL for mistakes and try again.

29 |

Why am I seeing this?

30 |

This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.

31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | transition: .3s; 3 | box-sizing: border-box; 4 | } 5 | body{ 6 | padding: 0; 7 | margin: 0; 8 | font-family: 'Open Sans', sans-serif; 9 | font-size: small 10 | } 11 | .container{ 12 | max-width: 1250px; 13 | margin: auto; 14 | overflow: hidden; 15 | padding: 0 20px; 16 | } 17 | a{ 18 | color: #333; 19 | text-decoration: none; 20 | text-transform: uppercase; 21 | font-weight: 700; 22 | } 23 | input{ 24 | padding: 12px 25px; 25 | border: none; 26 | background: rgb(228, 228, 228); 27 | border: solid 1px rgb(228, 228, 228); 28 | border-radius: 20px; 29 | width: 100%; 30 | font-family: 'Open Sans', sans-serif; 31 | font-weight: 700; 32 | } 33 | input:focus{ 34 | outline: none; 35 | background: #fff; 36 | border: solid 1px #ccc; 37 | } 38 | ::placeholder, ::-webkit-input-placeholder{ 39 | color: #999; 40 | } 41 | input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { 42 | -webkit-appearance: none; 43 | margin: 0; 44 | } 45 | input[type="number"] { 46 | -moz-appearance: textfield; 47 | } 48 | button{ 49 | padding: 12px 25px; 50 | color: #fff; 51 | border: none; 52 | margin: 12px 5px; 53 | border-radius: 20px; 54 | text-transform: uppercase; 55 | font-family: 'Open Sans', sans-serif; 56 | font-weight: 700; 57 | display: inline-block; 58 | } 59 | button:focus{ 60 | outline: none; 61 | } 62 | hr{ 63 | height: 2px; 64 | background: #333; 65 | border: none; 66 | width: 10%; 67 | } 68 | .oneThird{ 69 | width: 33.33%; 70 | float: left; 71 | } 72 | .oneFourth{ 73 | width: 25%; 74 | float: left; 75 | } 76 | .oneFifth{ 77 | width: 20%; 78 | float: left; 79 | } 80 | #warning, #signinWarning, #signupWarning{ 81 | color: red; 82 | display: none; 83 | } 84 | ::-webkit-scrollbar{ 85 | width:10px; 86 | } 87 | ::-webkit-scrollbar-track 88 | { 89 | background:#d4d3d3; 90 | } 91 | ::-webkit-scrollbar-thumb 92 | { 93 | background:#888; 94 | } 95 | ::-webkit-scrollbar-thumb:hover 96 | { 97 | background:#2A65EA; 98 | } 99 | 100 | 101 | #main{ 102 | width: 100%; 103 | } 104 | header{ 105 | width: 100%; 106 | position: fixed; 107 | background: #fff; 108 | z-index: 2; 109 | } 110 | 111 | /* header top */ 112 | header .top{ 113 | width: 100%; 114 | } 115 | header .top .left{ 116 | width: 75%; 117 | float: left; 118 | } 119 | header .top .right{ 120 | width: 25%; 121 | float: right; 122 | } 123 | .mainLogo, .location, .search{ 124 | float: left; 125 | margin: 12px; 126 | } 127 | .location{ 128 | width: 20%; 129 | display: none; 130 | } 131 | .search{ 132 | width: 50%; 133 | } 134 | .search input{ 135 | width: 100%; 136 | border-top-right-radius: 0; 137 | border-bottom-right-radius: 0; 138 | } 139 | .searchFieldDiv{ 140 | width: 90%; 141 | float: left; 142 | position: relative; 143 | } 144 | .searchBtnDiv{ 145 | width: 10%; 146 | float: left; 147 | } 148 | #searchBtn{ 149 | margin: 0; 150 | background: rgb(228, 228, 228); 151 | color: #555; 152 | border-top-left-radius: 0; 153 | border-bottom-left-radius: 0; 154 | border: solid 1px rgb(228, 228, 228); 155 | } 156 | #searchBtn:hover{ 157 | /* background: rgb(72, 123, 243); */ 158 | cursor: pointer; 159 | } 160 | .mainLogo{ 161 | margin: 18px; 162 | } 163 | .mainLogo img{ 164 | width: 55px; 165 | } 166 | .signinBtnDiv{ 167 | width: 65%; 168 | float: left; 169 | text-align: right; 170 | } 171 | #signinBtn{ 172 | color: #2A65EA; 173 | background: transparent; 174 | } 175 | #signinBtn:hover{ 176 | background: #e4e4e4; 177 | cursor: pointer; 178 | } 179 | #signoutBtnHover{ 180 | display: none; 181 | background-color: #fff; 182 | min-width: 160px; 183 | /* box-shadow: 0px 5px 10px rgba(0,0,0,0.2); */ 184 | padding: 12px 16px; 185 | margin-top: -10px; 186 | margin-right: -20px; 187 | } 188 | #signoutBtnHover a{ 189 | display: block; 190 | padding: 8px; 191 | margin: 5px 0; 192 | border-bottom: solid 1px #ccc; 193 | text-align: left; 194 | } 195 | 196 | 197 | #dropdownContent{ 198 | display: none; 199 | pointer-events: none; 200 | } 201 | .signinBtnDiv .dropdown{ 202 | /* position: relative; */ 203 | display: inline-block; 204 | } 205 | .signinBtnDiv .dropdown .dropdownContent { 206 | display: none; 207 | position: absolute; 208 | background-color: #fff; 209 | min-width: 160px; 210 | box-shadow: 0px 5px 10px rgba(0,0,0,0.2); 211 | padding: 12px 16px; 212 | } 213 | .signinBtnDiv .dropdown:hover .dropdownContent { 214 | display: block; 215 | text-align: left; 216 | } 217 | .signinBtnDiv .dropdown .dropdownContent a{ 218 | display: block; 219 | padding: 8px; 220 | margin: 5px 0; 221 | border-bottom: solid 1px #ccc; 222 | } 223 | .signinBtnDiv .dropdown .dropdownContent a:hover{ 224 | color: #2A65EA; 225 | border-bottom: solid 1px #2A65EA; 226 | } 227 | 228 | 229 | 230 | .sellBtnDiv{ 231 | width: 35%; 232 | float: left; 233 | } 234 | #sellBtn{ 235 | background: #2A65EA; 236 | color: #fff; 237 | } 238 | #sellBtn:hover{ 239 | background: rgb(72, 123, 243); 240 | cursor: pointer; 241 | } 242 | 243 | /* bottom header */ 244 | header .bottom{ 245 | width: 100%; 246 | padding: 10px 0; 247 | border-top: solid 1px #ccc; 248 | border-bottom: solid 1px #ccc; 249 | } 250 | /* header .bottom .container{ 251 | padding: 0 20px; 252 | } */ 253 | header .bottom .dropdown{ 254 | /* position: relative; */ 255 | display: inline-block; 256 | } 257 | header .bottom .dropdown .dropdownContent { 258 | display: none; 259 | position: absolute; 260 | background-color: #fff; 261 | min-width: 160px; 262 | box-shadow: 0px 5px 10px rgba(0,0,0,0.2); 263 | padding: 12px 16px; 264 | } 265 | header .dropdown:hover .dropdownContent { 266 | display: block; 267 | } 268 | header .bottom .dropdown .dropdownContent a{ 269 | display: block; 270 | padding: 8px; 271 | margin: 5px 0; 272 | border-bottom: solid 1px #ccc; 273 | } 274 | header .bottom .dropdown .dropdownContent a:hover{ 275 | color: #2A65EA; 276 | border-bottom: solid 1px #2A65EA; 277 | } 278 | 279 | 280 | 281 | 282 | /* banner */ 283 | .mainBanner img{ 284 | width: 100%; 285 | margin-top: 107px; 286 | } 287 | 288 | 289 | 290 | 291 | /* popular categories */ 292 | .popularCategories .heading{ 293 | text-align: center; 294 | } 295 | .popularCategories .categories .oneThird .top{ 296 | font-size: 16px; 297 | } 298 | .popularCategories .categories .oneThird .top, .popularCategories .categories .oneThird .bottom{ 299 | border: solid 1px #ccc; 300 | padding: 30px; 301 | border-bottom: none; 302 | border-right: none; 303 | } 304 | .popularCategories .categories .oneThird:nth-child(3n+3){ 305 | border-right: solid 1px #ccc; 306 | margin-right: 0; 307 | } 308 | .popularCategories .categories .oneThird:nth-child(n+4){ 309 | border-bottom: solid 1px #ccc; 310 | } 311 | .popularCategories .categories .bottom{ 312 | display: none; 313 | } 314 | .popularCategories .categories .bottom a{ 315 | display: block; 316 | margin: 10px 0; 317 | } 318 | .popularCategories .categories .bottom a:hover{ 319 | text-decoration: underline; 320 | } 321 | 322 | 323 | 324 | 325 | /* popular categories */ 326 | .topPicks .heading{ 327 | text-align: center; 328 | } 329 | .topPicks .picks figure{ 330 | border: solid 1px #ccc; 331 | border-bottom: solid 5px #ccc; 332 | padding: 15px; 333 | margin: 0 5px; 334 | } 335 | .topPicks .picks figure:hover{ 336 | cursor: pointer; 337 | opacity: 0.9; 338 | border-bottom: solid 5px #2A65EA; 339 | } 340 | .topPicks .picks figure .productImage{ 341 | display: flex; 342 | justify-content: center; 343 | align-items: center; 344 | width: 100%; 345 | height: 158px; 346 | } 347 | .topPicks .picks figure img{ 348 | display: block; 349 | max-width:221px; 350 | max-height:158px; 351 | width: auto; 352 | height: auto; 353 | } 354 | .topPicks .picks div{ 355 | padding: 5px 0; 356 | } 357 | .topPicks .picks .first{ 358 | overflow: hidden; 359 | } 360 | .topPicks .picks .first .addToFvrt{ 361 | float: right; 362 | font-size: 20px; 363 | } 364 | .topPicks .picks .first .price{ 365 | font-size: 20px; 366 | font-weight: 700; 367 | color: #333; 368 | } 369 | .topPicks .picks .second .adTitle{ 370 | text-transform: uppercase; 371 | } 372 | .productID{ 373 | display: none; 374 | } 375 | 376 | 377 | 378 | 379 | /* footer */ 380 | footer .top{ 381 | overflow: hidden; 382 | padding: 18px 0; 383 | margin-top: 20px; 384 | background: rgb(235, 235, 235); 385 | opacity: 0.7; 386 | } 387 | footer h3{ 388 | text-transform: uppercase; 389 | } 390 | footer .top a{ 391 | text-transform: capitalize; 392 | font-weight: normal; 393 | line-height: 2; 394 | } 395 | footer .top a:hover{ 396 | text-decoration: underline; 397 | } 398 | footer .footerSocial a{ 399 | font-size: 20px; 400 | display: inline-block; 401 | margin: 0 8px; 402 | } 403 | footer .footerSocial a:hover{ 404 | color: #2A65EA; 405 | } 406 | footer .bottom{ 407 | padding: 15px 0; 408 | background: #333; 409 | color: #fff; 410 | } 411 | footer .bottom .left{ 412 | float: left; 413 | } 414 | footer .bottom .left a{ 415 | color: #fff; 416 | font-weight: normal; 417 | margin: 0 5px; 418 | text-transform: capitalize; 419 | } 420 | footer .bottom .left a:hover{ 421 | text-decoration: underline; 422 | } 423 | footer .bottom .right{ 424 | float: right; 425 | } 426 | 427 | 428 | 429 | 430 | /* signin popup */ 431 | #signinPopup{ 432 | display: none; 433 | justify-content: center; 434 | align-items: center; 435 | position: fixed; 436 | width: 100%; 437 | height: 100vh; 438 | background: rgba(0, 28, 46, 0.6); 439 | z-index: 3; 440 | } 441 | #signinPopup a:hover{ 442 | text-decoration: underline; 443 | } 444 | #signinPopup .headingDiv{ 445 | margin-bottom: 25px; 446 | } 447 | #signinPopup .heading{ 448 | text-transform: uppercase; 449 | font-size: 24px; 450 | font-weight: 700; 451 | color: #333; 452 | } 453 | #signinPopupContainer{ 454 | background: #fff; 455 | padding: 20px; 456 | max-width: 350px; 457 | margin: auto; 458 | border-radius: 5px; 459 | } 460 | #signinPopup input{ 461 | margin: 8px 0; 462 | } 463 | #signinPopup input[type="submit"]{ 464 | background: #2A65EA; 465 | color: #fff; 466 | } 467 | #signinPopup input[type="submit"]:hover{ 468 | cursor: pointer; 469 | background: rgb(72, 123, 243); 470 | } 471 | .closeSigninPopupDiv{ 472 | overflow: hidden; 473 | } 474 | #closeSigninPopup{ 475 | float: right; 476 | font-size: 24px; 477 | line-height: 1; 478 | } 479 | #closeSigninPopup:hover{ 480 | cursor: pointer; 481 | color: red; 482 | } 483 | 484 | 485 | 486 | 487 | /* signup popup */ 488 | #signupPopup{ 489 | display: none; 490 | justify-content: center; 491 | align-items: center; 492 | position: fixed; 493 | width: 100%; 494 | height: 100vh; 495 | background: rgba(0, 28, 46, 0.6); 496 | z-index: 3; 497 | } 498 | #signupPopup a:hover{ 499 | text-decoration: underline; 500 | } 501 | #signupPopup .headingDiv{ 502 | margin-bottom: 25px; 503 | } 504 | #signupPopup .heading{ 505 | text-transform: uppercase; 506 | font-size: 24px; 507 | font-weight: 700; 508 | color: #333; 509 | } 510 | #signupPopupContainer{ 511 | background: #fff; 512 | padding: 20px; 513 | max-width: 350px; 514 | margin: auto; 515 | border-radius: 5px; 516 | } 517 | #signupPopup input{ 518 | margin: 8px 0; 519 | } 520 | #signupPopup input[type="submit"]{ 521 | background: #2A65EA; 522 | color: #fff; 523 | } 524 | #signupPopup input[type="submit"]:hover{ 525 | cursor: pointer; 526 | background: rgb(72, 123, 243); 527 | } 528 | .closeSignupPopupDiv{ 529 | overflow: hidden; 530 | } 531 | #closeSignupPopup{ 532 | float: right; 533 | font-size: 24px; 534 | line-height: 1; 535 | } 536 | #closeSignupPopup:hover{ 537 | cursor: pointer; 538 | color: red; 539 | } 540 | 541 | 542 | 543 | 544 | /* signup popup */ 545 | #sellPopup{ 546 | display: none; 547 | justify-content: center; 548 | align-items: center; 549 | position: fixed; 550 | width: 100%; 551 | height: 100vh; 552 | /* background: rgba(0, 28, 46, 0.6); */ 553 | background: #fff; 554 | z-index: 3; 555 | } 556 | #sellPopup a:hover{ 557 | text-decoration: underline; 558 | } 559 | #sellPopup .headingDiv{ 560 | margin-bottom: 25px; 561 | } 562 | #sellPopup .heading{ 563 | text-transform: uppercase; 564 | font-size: 24px; 565 | font-weight: 700; 566 | color: #333; 567 | } 568 | #sellPopupContainer{ 569 | background: #fff; 570 | padding: 20px; 571 | max-width: 500px; 572 | margin: auto; 573 | height: 100vh; 574 | border-radius: 5px; 575 | } 576 | #sellPopup input{ 577 | margin: 8px 0; 578 | } 579 | #sellPopup input[type="submit"]{ 580 | background: #2A65EA; 581 | color: #fff; 582 | } 583 | #sellPopup input[type="submit"]:hover{ 584 | cursor: pointer; 585 | background: rgb(72, 123, 243); 586 | } 587 | .closeSellPopupDiv{ 588 | overflow: hidden; 589 | margin-bottom: 10px; 590 | } 591 | #closeSellPopup{ 592 | float: right; 593 | font-size: 24px; 594 | line-height: 1; 595 | } 596 | #closeSellPopup:hover{ 597 | cursor: pointer; 598 | color: red; 599 | } 600 | 601 | 602 | 603 | 604 | /* category popup */ 605 | #categoryPopup{ 606 | display: none; 607 | justify-content: center; 608 | align-items: center; 609 | position: fixed; 610 | width: 100%; 611 | height: 100vh; 612 | /* background: rgba(0, 28, 46, 0.6); */ 613 | background: #fff; 614 | z-index: 3; 615 | } 616 | #categoryPopup a:hover{ 617 | text-decoration: underline; 618 | } 619 | #categoryPopup .headingDiv{ 620 | margin-bottom: 25px; 621 | } 622 | #categoryPopup .heading{ 623 | text-transform: uppercase; 624 | font-size: 24px; 625 | font-weight: 700; 626 | color: #333; 627 | } 628 | #categoryPopupContainer{ 629 | background: #fff; 630 | padding: 20px; 631 | width: 400px; 632 | margin: auto; 633 | height: 100vh; 634 | border-radius: 5px; 635 | } 636 | #categoryPopup input{ 637 | margin: 8px 0; 638 | } 639 | #categoryPopup input[type="submit"]{ 640 | background: #2A65EA; 641 | color: #fff; 642 | } 643 | #categoryPopup input[type="submit"]:hover{ 644 | cursor: pointer; 645 | background: rgb(72, 123, 243); 646 | } 647 | #categoryName{ 648 | text-transform: uppercase; 649 | } 650 | .closeCategoryPopupDiv{ 651 | overflow: hidden; 652 | } 653 | #closeCategoryPopup{ 654 | float: right; 655 | font-size: 24px; 656 | line-height: 1; 657 | } 658 | #backCategoryPopup{ 659 | float: left; 660 | font-size: 24px; 661 | line-height: 1; 662 | } 663 | #backCategoryPopup:hover{ 664 | cursor: pointer; 665 | color: #2A65EA; 666 | } 667 | #closeCategoryPopup:hover{ 668 | cursor: pointer; 669 | color: red; 670 | } 671 | .radioContainer { 672 | display: block; 673 | position: relative; 674 | padding: 10px; 675 | padding-left: 35px; 676 | cursor: pointer; 677 | font-size: 16px; 678 | border: solid 1px #ccc; 679 | border-bottom: 0; 680 | } 681 | .radioContainer:last-of-type{ 682 | border-bottom: solid 1px #ccc; 683 | } 684 | .radioContainer input { 685 | position: absolute; 686 | opacity: 0; 687 | cursor: pointer; 688 | } 689 | #categoryForm input[type="submit"]{ 690 | font-weight: 700; 691 | text-transform: uppercase; 692 | margin: 20px 0; 693 | } 694 | .radioCheck { 695 | position: absolute; 696 | top: 15px; 697 | left: 10px; 698 | height: 15px; 699 | width: 15px; 700 | background-color: #eee; 701 | border-radius: 50%; 702 | } 703 | .radioContainer:hover input ~ .radioCheck { 704 | background-color: #ccc; 705 | } 706 | .radioContainer input:checked ~ .radioCheck { 707 | background-color: #2A65EA; 708 | } 709 | .radioCheck:after { 710 | content: ""; 711 | position: absolute; 712 | display: none; 713 | } 714 | .radioContainer input:checked ~ .radioCheck:after { 715 | display: block; 716 | } 717 | .radioContainer .radioCheck:after { 718 | top: 6px; 719 | left: 6px; 720 | width: 4px; 721 | height: 4px; 722 | border-radius: 50%; 723 | background: white; 724 | } 725 | 726 | 727 | 728 | 729 | /* ad details popup */ 730 | #adDetailsPopup{ 731 | display: none; 732 | position: fixed; 733 | width: 100%; 734 | height: 100vh; 735 | /* background: rgba(0, 28, 46, 0.6); */ 736 | background: #fff; 737 | z-index: 3; 738 | overflow: auto; 739 | } 740 | #adDetailsPopupContainer{ 741 | background: #fff; 742 | padding: 20px; 743 | max-width: 1250px; 744 | margin: auto; 745 | /* height: 100vh; */ 746 | border-radius: 5px; 747 | overflow: hidden; 748 | } 749 | .closeAdDetailsPopupDiv{ 750 | overflow: hidden; 751 | margin-bottom: 10px; 752 | } 753 | #closeAdDetailsPopup{ 754 | float: right; 755 | font-size: 24px; 756 | line-height: 1; 757 | } 758 | #closeAdDetailsPopup:hover{ 759 | cursor: pointer; 760 | color: red; 761 | } 762 | 763 | 764 | #adDetailsPopupContainer .inLeft, #adDetailsPopupContainer .inRight #price, #adDetailsPopupContainer .inRight .sellerInfo{ 765 | margin: 10px; 766 | overflow: hidden; 767 | border: solid 1px #ccc; 768 | border-radius: 5px; 769 | padding: 20px; 770 | } 771 | #deleteAdBtn{ 772 | margin: 10px; 773 | color: red; 774 | } 775 | #deleteAdBtn:hover{ 776 | cursor: pointer; 777 | } 778 | #adDetailsPopupContainer .left{ 779 | width: 65%; 780 | float: left; 781 | } 782 | #adDetailsPopupContainer .left #showAdImage{ 783 | width: 100%; 784 | text-align: center; 785 | } 786 | #adDetailsPopupContainer .left #showAdImage img{ 787 | width: auto; 788 | border-radius: 5px; 789 | height: 350px; 790 | } 791 | #adDetailsPopupContainer .right{ 792 | width: 35%; 793 | float: left; 794 | } 795 | #adDetailsPopupContainer .right #price{ 796 | font-size: 44px; 797 | font-weight: 700; 798 | } 799 | #adDetailsPopupContainer .right .sellerInfo{ 800 | font-size: 16px; 801 | line-height: 2; 802 | } 803 | #adDetailsPopupContainer .right .sellerInfo h2{ 804 | margin: 0; 805 | } 806 | #adDetailsPopupContainer .right .sellerInfo button{ 807 | background: #2A65EA; 808 | margin:10px 0; 809 | width: 100%; 810 | } 811 | #adDetailsPopupContainer .right .sellerInfo button:hover{ 812 | cursor: pointer; 813 | background: rgb(72, 123, 243); 814 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | OLX - Buy and sell for free 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 |
27 |
28 | × 29 |
30 |
31 | Sign in 32 |
33 | Buy & sell things easily with OLX. 34 |
35 |
36 |
37 | 38 | 39 | 40 |
41 |

Don't have an account? Sign up

42 |
43 |
44 | 45 | 46 | 47 |
48 |
49 |
50 | × 51 |
52 |
53 | Sign up 54 |
55 | Buy & sell things easily with OLX. 56 |
57 |
58 |
59 | 60 | 61 | 62 | 63 |
64 |

Already have an account? Sign in

65 |
66 |
67 | 68 | 69 | 70 |
71 |
72 |
73 | × 74 |
75 |
76 | Choose Category 77 |
78 |
Please choose a category
79 |
80 | 84 | 88 | 92 | 96 | 100 | 104 | 105 |
106 |
107 |
108 | 109 | 110 | 111 |
112 |
113 |
114 | 115 | × 116 |
117 |
118 | Post Your Ad 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 |

Seller Info

153 |
154 |
155 |
156 | 157 |
158 |
159 |
Delete Ad
160 |
161 |
162 |
163 |
164 | 165 | 166 |
167 | 168 |
169 |
170 |
171 |
172 | 177 |
178 | 179 | 180 |
181 | 189 |
190 |
191 |
192 | 200 |
201 |
202 | 203 |
204 |
205 |
206 |
207 |
208 |
209 | 222 |
223 |
224 |
225 | 226 | 227 | 228 |
229 | banner-image 230 |
231 | 232 | 233 | 234 |
235 |
236 |
237 |

Popular Categories

238 |
239 |

Browse through some of our most popular categories.

240 |
241 |
242 |
243 |
244 | 245 |   Mobiles 246 |
247 |
248 | Tablets 249 | Accessories 250 | Mobile Phones 251 |
252 |
253 |
254 |
255 |   256 | Vehicles 257 |
258 |
259 | Cars 260 | Buses 261 | Spare parts 262 |
263 |
264 |
265 | 269 |
270 | Cars 271 | Buses 272 | Spare parts 273 |
274 |
275 |
276 |
277 |   278 | Bikes 279 |
280 |
281 | Cars 282 | Buses 283 | Spare parts 284 |
285 |
286 |
287 |
288 | 289 |   Services 290 |
291 |
292 | Cars 293 | Buses 294 | Spare parts 295 |
296 |
297 |
298 |
299 |   300 | Furniture 301 |
302 |
303 | Cars 304 | Buses 305 | Spare parts 306 |
307 |
308 |
309 |
310 |
311 | 312 | 313 | 314 |
315 |
316 |
317 |

Recently added

318 |
319 |
320 |
321 | 322 |
323 |
324 |
325 | 326 | 327 | 328 | 384 | 385 |
386 | 387 | 388 | 389 | 401 | 402 | 403 | 404 | 405 | -------------------------------------------------------------------------------- /js/app.js: -------------------------------------------------------------------------------- 1 | var currentUserName; 2 | var currentUserUid; 3 | 4 | window.onload = () => { 5 | firebase.auth().onAuthStateChanged(function (user) { 6 | if (user) { 7 | // show user's name after sign in 8 | firebase.database().ref('/users/' + user.uid).once('value', (success) => { 9 | currentUserUid = success.val().userUid; 10 | currentUserName = success.val().signupName; 11 | if (currentUserUid === user.uid) { 12 | signinBtn.innerHTML = `   ${currentUserName}`; 13 | } 14 | }); 15 | 16 | // User is signed in. 17 | localStorage.setItem('auth', JSON.stringify(user)); 18 | signoutBtn.setAttribute("onclick", "signOutBtn_f()"); 19 | 20 | // for signoutHover 21 | document.getElementById("dropdownContent").removeAttribute('id', 'dropdownContent'); 22 | 23 | //allow to click on sellBtn 24 | sellBtn.addEventListener('click', () => { 25 | signinPopup.style.display = "none"; 26 | signupPopup.style.display = "none"; 27 | sellPopup.style.display = "none"; 28 | categoryPopup.style.display = "flex"; 29 | }) 30 | } else { 31 | // No user is signed in. 32 | signinBtn.setAttribute("onclick", "signinBtn_f()"); 33 | signinBtn.innerText = "Sign In"; 34 | localStorage.clear() 35 | 36 | // for signoutHover 37 | document.getElementsByClassName("dropdownContent")[0].setAttribute('id', 'dropdownContent'); 38 | 39 | //don't allow to click on sellBtn 40 | sellBtn.addEventListener('click', () => { 41 | signinPopup.style.display = "flex"; 42 | signupPopup.style.display = "none"; 43 | sellPopup.style.display = "none"; 44 | categoryPopup.style.display = "none"; 45 | }) 46 | } 47 | }); 48 | } 49 | 50 | // signin popup 51 | var signinBtn = document.getElementById("signinBtn"); 52 | var signinBtn_2 = document.getElementById("signinBtn_2"); 53 | var signinPopup = document.getElementById("signinPopup"); 54 | var closeSigninPopup = document.getElementById("closeSigninPopup"); 55 | 56 | function signinBtn_f() { 57 | signinPopup.style.display = "flex"; 58 | signupPopup.style.display = "none"; 59 | } 60 | signinBtn_2.onclick = () => { 61 | signinPopup.style.display = "flex"; 62 | signupPopup.style.display = "none"; 63 | sellPopup.style.display = "none"; 64 | categoryPopup.style.display = "none"; 65 | } 66 | 67 | // signup popup 68 | var signupBtn = document.getElementById("signupBtn"); 69 | var signupPopup = document.getElementById("signupPopup"); 70 | var closeSignupPopup = document.getElementById("closeSignupPopup"); 71 | 72 | signupBtn.onclick = () => { 73 | signupPopup.style.display = "flex"; 74 | signinPopup.style.display = "none"; 75 | sellPopup.style.display = "none"; 76 | categoryPopup.style.display = "none"; 77 | } 78 | 79 | // category popup 80 | var selectedCategory = ''; 81 | var sellBtn = document.getElementById("sellBtn"); 82 | var categoryPopup = document.getElementById("categoryPopup"); 83 | var closeCategoryPopup = document.getElementById("closeCategoryPopup"); 84 | 85 | sellBtn.onclick = () => { 86 | categoryPopup.style.display = "flex"; 87 | sellPopup.style.display = "none"; 88 | signupPopup.style.display = "none"; 89 | signinPopup.style.display = "none"; 90 | } 91 | 92 | // back category popup 93 | var backCategoryPopup = document.getElementById("backCategoryPopup"); 94 | 95 | backCategoryPopup.onclick = () => { 96 | categoryPopup.style.display = "flex"; 97 | sellPopup.style.display = "none"; 98 | signupPopup.style.display = "none"; 99 | signinPopup.style.display = "none"; 100 | } 101 | 102 | // sell popup 103 | var categoryForm = document.getElementById("categoryForm"); 104 | var categoryName = document.getElementById("categoryName"); 105 | 106 | categoryForm.onsubmit = () => { 107 | selectedCategory = document.querySelector("input[name='category']:checked"); 108 | 109 | if (Boolean(selectedCategory) === true) { 110 | categoryName.innerText = `Category: ${selectedCategory.value}`; 111 | 112 | sellPopup.style.display = "flex"; 113 | signupPopup.style.display = "none"; 114 | signinPopup.style.display = "none"; 115 | categoryPopup.style.display = "none"; 116 | 117 | selectedCategory.checked = false; 118 | 119 | document.getElementById("warning").style.display = "none"; 120 | } else { 121 | document.getElementById("warning").style.display = "block"; 122 | } 123 | return false; 124 | } 125 | 126 | // window onclick 127 | window.onclick = () => { 128 | if (event.target === signinPopup || event.target === closeSigninPopup || event.target === signupPopup || event.target === closeSignupPopup || event.target === closeSellPopup || event.target === closeCategoryPopup || event.target === closeAdDetailsPopup) { 129 | signupPopup.style.display = "none"; 130 | signinPopup.style.display = "none"; 131 | sellPopup.style.display = "none"; 132 | categoryPopup.style.display = "none"; 133 | adDetailsPopup.style.display = "none"; 134 | } 135 | } 136 | 137 | //sellForm 138 | var sellForm = document.getElementById("sellForm"); 139 | 140 | sellForm.onsubmit = (e) => { 141 | e.preventDefault(); 142 | var adTitle = document.getElementById("adTitle"); 143 | var adDescription = document.getElementById("adDescription"); 144 | var adPrice = document.getElementById("adPrice"); 145 | var adPhone = document.getElementById("adPhone"); 146 | var adImage = document.getElementById("adImage"); 147 | 148 | // firebase storage 149 | var file = adImage.files[0]; 150 | console.log(file); 151 | if (file === undefined) { 152 | 153 | let ads = { 154 | title: adTitle.value, 155 | description: adDescription.value, 156 | price: adPrice.value, 157 | phone: adPhone.value, 158 | image: 'https://firebasestorage.googleapis.com/v0/b/olx-app-d4585.appspot.com/o/images%2Fdummyimg.jpg?alt=media&token=b38e6cca-abff-4c59-b728-3bbb8c3018fa', 159 | category: selectedCategory.value, 160 | uid: (JSON.parse(localStorage.getItem('auth')) && JSON.parse(localStorage.getItem('auth')).uid) || '', 161 | sellerName: currentUserName, 162 | } 163 | console.log(ads) 164 | firebase.database().ref('/ads').push(ads) 165 | .then(() => { 166 | // clear all fields and show category modal 167 | adTitle.value = ""; 168 | adDescription.value = ""; 169 | adPrice.value = ""; 170 | adPhone.value = ""; 171 | adImage.value = ""; 172 | }) 173 | .catch(console.log); 174 | } else { 175 | var storageRef = firebase.storage().ref('images/' + file.name); 176 | storageRef.put(file).then((url) => { 177 | url.ref.getDownloadURL().then((imgURL) => { 178 | console.log(imgURL); 179 | 180 | let ads = { 181 | title: adTitle.value, 182 | description: adDescription.value, 183 | price: adPrice.value, 184 | phone: adPhone.value, 185 | image: imgURL, 186 | category: selectedCategory.value, 187 | uid: (JSON.parse(localStorage.getItem('auth')) && JSON.parse(localStorage.getItem('auth')).uid) || '', 188 | sellerName: currentUserName, 189 | } 190 | console.log(ads) 191 | firebase.database().ref('/ads').push(ads) 192 | .then(() => { 193 | // clear all fields and show category modal 194 | adTitle.value = ""; 195 | adDescription.value = ""; 196 | adPrice.value = ""; 197 | adPhone.value = ""; 198 | adImage.value = ""; 199 | }) 200 | .catch(console.log); 201 | }) 202 | }); 203 | } 204 | 205 | sellPopup.style.display = "none"; 206 | } 207 | 208 | // signup with email 209 | var signupName = document.getElementById("signupName"); 210 | var signupEmail = document.getElementById("signupEmail"); 211 | var signupPw = document.getElementById("signupPw"); 212 | var signupForm = document.getElementById("signupForm"); 213 | var signupWarning = document.getElementById("signupWarning"); 214 | 215 | signupForm.onsubmit = (e) => { 216 | e.preventDefault(); 217 | firebase.auth().createUserWithEmailAndPassword(signupEmail.value, signupPw.value).then((success) => { 218 | console.log(success); 219 | console.log("Signed up"); 220 | var user = firebase.auth().currentUser; 221 | var uid; 222 | if (user != null) { 223 | uid = user.uid; 224 | } 225 | var firebaseRef = firebase.database().ref("users"); 226 | var userData = { 227 | signupName: signupName.value, 228 | signupEmail: signupEmail.value, 229 | signupPw: signupPw.value, 230 | userUid: uid, 231 | } 232 | firebaseRef.child(uid).set(userData); 233 | 234 | signupPopup.style.display = "none"; 235 | 236 | }).catch((error) => { 237 | // Handle Errors here. 238 | var errorCode = error.code; 239 | var errorMessage = error.message; 240 | 241 | signupWarning.innerText = errorMessage; 242 | signupWarning.style.display = "block"; 243 | }); 244 | } 245 | 246 | 247 | // signin with email 248 | var signinEmail = document.getElementById("signinEmail"); 249 | var signinPw = document.getElementById("signinPw"); 250 | var signinForm = document.getElementById("signinForm"); 251 | var signinPopupContainer = document.getElementById("signinPopupContainer"); 252 | var signinWarning = document.getElementById("signinWarning"); 253 | 254 | signinForm.onsubmit = (e) => { 255 | e.preventDefault(); 256 | firebase.auth().signInWithEmailAndPassword(signinEmail.value, signinPw.value).then((success) => { 257 | console.log(success); 258 | console.log("Signed in"); 259 | localStorage.setItem('auth', JSON.stringify(success)); 260 | signinPopup.style.display = "none"; 261 | signinEmail.value = ""; 262 | signinPw.value = ""; 263 | 264 | location.reload(); 265 | 266 | }).catch((error) => { 267 | // Handle Errors here. 268 | var errorCode = error.code; 269 | var errorMessage = error.message; 270 | 271 | signinWarning.innerText = errorMessage; 272 | signinWarning.style.display = "block"; 273 | }); 274 | } 275 | 276 | // signout 277 | var signoutBtn = document.getElementById("signoutBtn"); 278 | function signOutBtn_f() { 279 | firebase.auth().signOut().then(function () { 280 | // Sign-out successful. 281 | localStorage.clear(); 282 | signinEmail.value = ""; 283 | signinPw.value = ""; 284 | console.log("Signed out"); 285 | 286 | // set ads to default afer user signed out 287 | location.reload(); 288 | 289 | }).catch(function (error) { 290 | // An error happened. 291 | }); 292 | } 293 | 294 | // fetching all ads 295 | var allAds = []; 296 | var filteredAds = []; 297 | 298 | (function fetchAds() { 299 | firebase.database().ref('/ads').on('child_added', (snapshot) => { 300 | var data = snapshot.val(); 301 | data.key = snapshot.key; 302 | allAds.push(data); 303 | renderAds(data); 304 | }); 305 | })() 306 | 307 | // rendering all products 308 | const picks = document.getElementById('picks'); 309 | var adUid; 310 | 311 | function renderAds(ad) { 312 | picks.innerHTML = ` 313 |
314 |
315 |
316 | 317 |
318 |
319 | ${ad.key} 320 |
321 | Rs. ${ad.price} 322 | 323 |
324 |
325 | ${ad.title} 326 |
327 |
328 | Category: ${ad.category} 329 |
330 |
331 |
332 |
${picks.innerHTML}`; 333 | adUid = ad.key; 334 | } 335 | 336 | // filtering 337 | var searchCategory = 'All'; 338 | var popularCategories = document.getElementById("popularCategories"); 339 | var categoryHeading = document.getElementById("categoryHeading"); 340 | var browseCategories = document.getElementById("browseCategories"); 341 | var mainBanner = document.getElementById("mainBanner"); 342 | var mainBannerImg = document.getElementById("mainBannerImg"); 343 | 344 | function filter(category) { 345 | filteredAds = []; 346 | searchField.value = ''; 347 | browseCategories.innerHTML = ''; 348 | browseCategories.innerHTML = `Browse by Categories   /   ${category}`; 349 | // popularCategories.style.display = "none"; 350 | categoryHeading.innerText = category; 351 | picks.innerHTML = ''; 352 | searchCategory = category; 353 | 354 | if (category === 'All') { 355 | filteredAds = [...allAds]; 356 | allAds.map((ad) => { 357 | renderAds(ad); 358 | }) 359 | 360 | return; 361 | } 362 | 363 | allAds.map((ad) => { 364 | if (ad.category === category) { 365 | filteredAds.push(ad); 366 | renderAds(ad); 367 | } 368 | }); 369 | 370 | if (picks.innerHTML.trim().length === 0) { 371 | picks.innerHTML = `

Oops! There is nothing to show :(

`; 372 | } 373 | } 374 | 375 | // searching ads 376 | var searchField = document.getElementById('searchField'); 377 | var searchBtn = document.getElementById('searchBtn'); 378 | 379 | searchBtn.addEventListener('click', (e) => { 380 | e.preventDefault(); 381 | search(); 382 | }) 383 | 384 | searchField.addEventListener('keyup', () => { 385 | if (searchCategory === 'All') { 386 | filteredAds = [...allAds]; 387 | } 388 | 389 | if (searchField.value === '') { 390 | picks.innerHTML = ''; 391 | filteredAds.map((ad) => { 392 | renderAds(ad); 393 | }) 394 | } 395 | }) 396 | 397 | 398 | function search() { 399 | popularCategories.style.display = "none"; 400 | const textSearched = searchField.value && searchField.value.toLowerCase(); 401 | picks.innerHTML = ''; 402 | 403 | if (searchCategory === 'All') { 404 | filteredAds = [...allAds]; 405 | } 406 | 407 | filteredAds.map((ad) => { 408 | if (ad.title && ad.title.toLowerCase().includes(textSearched)) { 409 | renderAds(ad); 410 | } 411 | }); 412 | 413 | if (picks.innerHTML.trim().length === 0) { 414 | picks.innerHTML = `

Oops! There is nothing to show :(

`; 415 | } 416 | 417 | } 418 | 419 | //my ads 420 | var myAds = document.getElementById("myAds"); 421 | 422 | myAds.addEventListener('click', () => { 423 | // location.href = 'myads.html'; 424 | picks.innerHTML = ''; 425 | categoryHeading.innerText = 'My Ads'; 426 | var currentUserUid = firebase.auth().currentUser.uid; 427 | 428 | allAds.map((ad) => { 429 | if (ad.uid === currentUserUid) { 430 | filteredAds.push(ad); 431 | renderAds(ad); 432 | } 433 | 434 | // if (picks.innerHTML.trim().length === 0) { 435 | // picks.innerHTML = `

Oops! There is nothing to show :(

`; 436 | // } 437 | }); 438 | }) 439 | 440 | // show ad details 441 | var showAdImage = document.getElementById("showAdImage"); 442 | var showAdDescriptionHeading = document.getElementById("showAdDescriptionHeading"); 443 | var showAdDescriptionDesc = document.getElementById("showAdDescriptionDesc"); 444 | var price = document.getElementById("price"); 445 | var sellerName = document.getElementById("sellerName"); 446 | var sellerPhone = document.getElementById("sellerPhone"); 447 | var chatWithSeller = document.getElementById("chatWithSeller"); 448 | var adDetailsPopup = document.getElementById("adDetailsPopup"); 449 | var closeAdDetailsPopup = document.getElementById("closeAdDetailsPopup"); 450 | var adDetailsUid; 451 | 452 | function showAdDetails(figure) { 453 | adDetailsPopup.style.display = "block"; 454 | categoryPopup.style.display = "none"; 455 | sellPopup.style.display = "none"; 456 | signupPopup.style.display = "none"; 457 | signinPopup.style.display = "none"; 458 | 459 | let adUid = figure.childNodes[3].childNodes[1].innerText; 460 | 461 | firebase.database().ref(`/ads/${adUid}`).on('value', (snapshot) => { 462 | let adDetails = snapshot.val(); 463 | 464 | if (adUid === (snapshot.key)) { 465 | showAdImage.innerHTML = ``; 466 | showAdDescriptionHeading.innerHTML = adDetails.title; 467 | showAdDescriptionDesc.innerHTML = adDetails.description; 468 | price.innerHTML = `Rs. ${adDetails.price}`; 469 | sellerName.innerHTML = `Name: ${adDetails.sellerName}`;; 470 | sellerPhone.innerHTML = `Phone: ${adDetails.phone}`; 471 | } else { 472 | console.log("key doesn't matched"); 473 | } 474 | 475 | adDetailsUid = adDetails.uid; 476 | }); 477 | } 478 | 479 | // delete ad 480 | var deleteAdBtn = document.getElementById("deleteAdBtn"); 481 | console.log(adUid); 482 | 483 | deleteAdBtn.onclick = () => { 484 | var figure = document.getElementById("figure"); 485 | console.log(figure); 486 | console.log(figure.childNodes[1].childNodes[3]); 487 | console.log('del'); 488 | let adUid = figure.childNodes[1].childNodes[3].childNodes[1].innerText; 489 | 490 | firebase.database().ref(`/ads/${adUid}`).remove(); 491 | 492 | adDetailsPopup.style.display = "none"; 493 | // location.reload(); 494 | } 495 | 496 | //function favourite(ad){ 497 | //firebase.database().ref(`/users/${localstorage wla codepastekardo}/favouriteAds`).push(ad) 498 | //} 499 | --------------------------------------------------------------------------------