Review Innerpage
by mtenschert
HTML
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<div class="ratingWrapper">Hallo</div>
<div class="ratingWrapperDetail" data-ratinginput="4.7" data-ratingtotalinput="46" data-ratingshopname="Ski Republic Magnin Sports" data-ratingshopaddress="Rue des Grandes Alpes, 73450 Valloire" data-ratingpriceinput="8" data-ratingselectioninput="8.0"
data-ratingdelayinput="7.5" data-ratingfriendlyinput="9" data-ratingcleaninput="6.4" data-ratinghelpinput="9.5"></div>
<div class="ratingWrapper">Hallo</div>
<div class="ratingWrapperDetail" data-ratinginput="4.7" data-ratingtotalinput="46" data-ratingshopname="Ski Republic Magnin Sports" data-ratingshopaddress="Rue des Grandes Alpes, 73450 Valloire" data-ratingpriceinput="1" data-ratingselectioninput="1.0"
data-ratingdelayinput="1.5" data-ratingfriendlyinput="10" data-ratingcleaninput="1.4" data-ratinghelpinput="4.5"></div>
CSS
.rating-container {
padding: 10px;
font-family: arial;
background: rgb(241, 241, 243);
min-height: 280px;
line-height: 20px !important;
}
.rating-container p {
margin: 0px;
}
p.rating-adress {
font-style: italic;
}
p.rating-overview {
font-weight: bold;
}
.ratingWrapper:hover {
cursor: help !important;
}
.ratingWrapperDetail {
overflow-x: overlay;
overflow-y: overlay;
opacity: 0;
visibility: hidden;
top: 0px;
left: 200px;
position: absolute;
width: 430px;
border-left: 1px solid rgb(211, 216, 219);
z-index: 10000;
transition: all 0.5s linear;
}
.move {
visibility: visible;
left: 220px;
opacity: 1;
}
.moved {
width: 100% !important;
background-color: green !important;
}
.heading {
font-size: 25px;
}
.rating-container fa {
font-size: 25px;
}
.checked {
color: orange;
}
.side {
float: left;
width: 35%;
margin-top: 8px;
}
.middle {
margin-top: 10px;
float: left;
width: 65%;
}
.right {
text-align: right;
}
.row::after {
content: "";
display: table;
clear: both;
}
.bar-container {
width: 100%;
background-color: rgb(215, 215, 215);
text-align: center;
color: white;
}
.bar {
width: 30%;
height: 18px;
transition: all 0.4s linear;
transition-delay: 0.5s;
}
@media (max-width: 480px) {
.side,
.middle {
width: 100%;
}
.right {
display: none;
}
}
JavaScript
setTimeout(function() {
// Nächster Schritte: Sprache-Variablen,
$("div.ratingWrapperDetail").each(function(index) {
// Convert inputs into variables for Part 1 and 2!
var ratingForRound = $(this).attr("data-ratingInput");
var ratingInput = $(this).attr("data-ratingInput");
var ratingTotalInput = $(this).attr("data-ratingTotalInput");
//
// PART1, generate rating word, rating stars, show ratingTotal, show rating
//
// Less than 5 ratings, dont´t show feature
if (ratingTotalInput > 5.0) {
// Stars: Convert numbers into stars
// Stars: round numbers for stars
ratingForRound = Math.round(ratingForRound * 2) / 2;
let output = [];
// Stars: Append all the filled whole stars
for (var i = ratingForRound; i >= 1; i--)
output.push('<i class="fa fa-star checked"></i>');
// Stars: If there is a half a star, append it
if (i == .5) output.push('<i class="fa fa-star-half-o checked"></i>');
// Stars: Fill the empty stars
for (let i = (5 - ratingForRound); i >= 1; i--)
output.push('<i class="fa fa-star-o checked"></i>');
// Convert numbers into ratingWording
var ratingWord;
if (ratingForRound < 3.8) {
ratingWord = "Beoordeling";
} else if (ratingForRound < 4.2) {
ratingWord = "Goed";
} else if (ratingForRound < 4.4) {
ratingWord = "Heel Goed";
} else if (ratingForRound < 4.8) {
ratingWord = "Super";
} else if (ratingForRound < 5.10) {
ratingWord = "Uitstekend";
}
//
// PART1 END
//
//
// PART2 generate ratingBar-width, ratingBar color for later output
//
// Convert inputs into variables
var ratingShopName = $(this).attr("data-ratingshopname");
var ratingShopAddress = $(this).attr("data-ratingshopaddress");
var ratingPriceInput = $(this).attr("data-ratingpriceinput");
var ratingSelectionInput =...