Review Innerpage 2
by mtenschert
HTML
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<div id="ratingInputWrapper">
<!-- Insert Data -->
<input type="hidden" id="ratingShopName" value="Sportlife Brugger TEST">
<input type="hidden" id="ratingShopAddress" value="Dorfstraße 175, Sölden TEST">
<input type="hidden" id="ratingInput" value="9.4">
<input type="hidden" id="ratingTotalInput" value="1235">
<input type="hidden" id="ratingLocationInput" value="9.9">
<!--
<input type="hidden" id="ratingPriceInput" value="8.5">
<input type="hidden" id="ratingSelectionInput" value="3.5">
<input type="hidden" id="ratingDelayInput" value="7">
<input type="hidden" id="ratingFriendlyInput" value="4">
<input type="hidden" id="ratingCleanInput" value="7.8">
<input type="hidden" id="ratingHelpInput" value="2">
-->
<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>
<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="10" data-ratingselectioninput="7.0" data-ratingdelayinput="10.0" data-ratingfriendlyinput="2.5" data-ratingcleaninput="5.4" data-ratinghelpinput="1.5"> </div>
<!--
<div class="ratingWrapperDetail" data-ratinginput="4.7" data-ratingtotalinput="16" data-ratingshopname="JENNEWEIN pure sports" data-ratingshopaddress="Dorfstrasse 2, 6580 St. Anton am Arlberg" data-ratingpriceinput="10"...
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 {
display : block;
overflow-x : overlay;
overflow-y : overlay;
top : 0px;
left : 200px;
position : absolute;
width : 430px;
border-left : 1px solid rgb(211, 216, 219);
z-index : 10000;
}
.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-5 {
height : 18px;
}
.bar-4 {
width : 65%;
height : 18px;
background-color : rgb(33, 150, 243);
}
.bar-3 {
width : 45%;
height : 18px;
background-color : rgb(0, 188, 212);
}
.bar-2 {
width : 40%;
height : 18px;
background-color : rgb(255, 152, 0);
}
.bar-1 {
width : 30%;
height : 18px;
background-color : rgb(244, 67, 54);
}
@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 = "Reviews";
} else if (ratingForRound < 4.2) {
ratingWord = "Good";
} else if (ratingForRound < 4.4) {
ratingWord = "Very Good";
} else if (ratingForRound < 4.8) {
ratingWord = "Superb";
} else if (ratingForRound < 5.10) {
ratingWord = "Exceptional";
}
//
// 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 = $(this).attr("data-ratingselectioninput");
var ratingDelayInput = $(this).attr("data-ratingDelayInput");
var ratingFriendlyInput = $(this).attr("data-ratingfriendlyinput");
var ratingCleanInput = $(this).attr("data-ratingcleaninput");
var ratingHelpInput =...