From 5c77f21bd069363fabe45b89e44d26db04b29d39 Mon Sep 17 00:00:00 2001 From: Habibi <muhhabibih@gmail.com> Date: Wed, 24 Oct 2018 12:38:54 +0700 Subject: [PATCH] Add book detail on revie page --- config/devel.php | 2 +- public/static/css/review.css | 40 +++++++++++++++++++++++++++++++++- public/static/html/review.html | 29 ++++++++++++++++++++++-- public/static/js/review.js | 19 +++++++++++++++- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/config/devel.php b/config/devel.php index ad2af67..7a9949e 100644 --- a/config/devel.php +++ b/config/devel.php @@ -3,7 +3,7 @@ "db" => array( "host" => "localhost", "user" => "root", - "password" => "rahasiailahi", + "password" => "06071998", "db_name" => "tayo_book_store" ), "base_url" => "http://localhost:4000/", diff --git a/public/static/css/review.css b/public/static/css/review.css index ea04f23..68dff7d 100644 --- a/public/static/css/review.css +++ b/public/static/css/review.css @@ -25,4 +25,42 @@ margin-left: 5px; margin-right: 5px; -} \ No newline at end of file +} + +.review-comment { + width: 100%; +} + +.review-back { + margin-top: 40px; + margin-bottom: 20px; + background-color: white; + border: 3px solid; + border-color: #d9534f; + border-radius: 10px; + + width: 150px; + height: 60px; +} + +.review-back span { + font-size: 30px; + color: #d9534f; +} + +.review-submit { + margin-top: 40px; + margin-bottom: 20px; + background-color: #0094cc; + border: 3px solid; + border-color: #0094cc; + border-radius: 10px; + + width: 150px; + height: 60px; +} + +.review-submit span { + font-size: 30px; + color: white; +} diff --git a/public/static/html/review.html b/public/static/html/review.html index daf349a..5954f49 100644 --- a/public/static/html/review.html +++ b/public/static/html/review.html @@ -4,9 +4,9 @@ <div class="row justify-content-between"> <div class="review-title"> <div class="title"> - <h1>Nota Hidup</h1> + <h1 id="review-title">Nota Hidup</h1> </div> - <h2>Light R.D.B</h2> + <h2 id="review-author">Light R.D.B</h2> </div> <img src="/static/img/contoh_buku.png" @@ -45,6 +45,31 @@ <div class="review-header"> <h1>Add Comment</h1> </div> + <textarea + name="comment" + id="review-comment" + rows="10" + class="review-comment" + > + </textarea> + <div class="justify-content-between"> + <a href="/history/"> + <button + class='review-back' + id='review-back' + > + <span>Back</span> + </button> + </a> + + <button + class='review-submit' + id='review-submit' + > + <span>Submit</span> + </button> + </div> + </div> <script src="/static/js/review.js"></script> \ No newline at end of file diff --git a/public/static/js/review.js b/public/static/js/review.js index 57c8839..e86741b 100644 --- a/public/static/js/review.js +++ b/public/static/js/review.js @@ -6,11 +6,26 @@ for(i = 0; i < 5; i++) { stars.push(star); } +const getBookContent = function() { + let url_string = window.location.href; + let url = new URL(url_string); + var book_id = url.searchParams.get("book_id"); + + let book_title = document.getElementById("review-title"); + let book_author = document.getElementById("review-author"); + + doAjax(`/api/book/${book_id}/`, "GET", null, function(response) { + const book = response.data[0]; + + book_title.innerHTML = book.title; + book_author.innerHTML = book.author; + }); +} + const onRatingMouseOver = function() { const key = this.getAttribute("key") for(i = 0; i < parseInt(key) + 1; i++) { - console.log(i); stars[i].src="/static/img/full_star.png"; } for(i = parseInt(key) + 1; i< 5; i++) { @@ -36,6 +51,8 @@ const onRatingClick = function() { } window.onload = function() { + getBookContent(); + for (i = 0; i < 5; i++) { stars[i].onmouseover = onRatingMouseOver; stars[i].onmouseout = onRatingMouseOut; -- GitLab