Simple star rating using js and data-uri

Developer
Size
5,795 Kb
Views
20,240

How do I make an simple star rating using js and data-uri?

Awesome XD. What is a simple star rating using js and data-uri? How do you make a simple star rating using js and data-uri? This script and codes were developed by Jack_Quarry on 11 October 2022, Tuesday.

Simple star rating using js and data-uri Previews

Simple star rating using js and data-uri - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>simple star rating using js and data-uri</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="mainWrapX"> <div class="wrap_shadowRoundThis"> <div class="wrapInput"><span class="aboutInput">C'mon rate yourself:</span> <input placeholder="1.0 to 5.0" required="required" title="Be kind to yourself :)"/> </div> <div class="wrapHighlights"><span class="rating">I rate myself :)</span> <div class="OfferHighlights"> <div class="ratingBG_disabled"></div> <div class="ratingBG_active"> </div> </div> </div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Simple star rating using js and data-uri - Script Codes CSS Codes

body { padding: 2em; font-family: 'Roboto', sans-serif; line-height: 1.3; background: #DAE2F8; /* fallback for old browsers */ background: -webkit-linear-gradient(to left, #DAE2F8, #D6A4A4); /* Chrome 10-25, Safari 5.1-6 */ background: linear-gradient(to left, #dae2f8, #d6a4a4); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.contRofl_clr, .wrap_shadowRoundThis, .wrapInput, .wrapHighlights { width: 100%; float: left; overflow: hidden; *zoom: 1;
}
.wrap_shadowRoundThis { -webkit-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.35); -moz-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.35); box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.35); border-radius: 2px;
}
.mainWrapX { max-width: 320px; text-align: center; margin: 2em auto; margin-top: 25vh;
}
.mainWrapX span.aboutInput { font-size: 1em; letter-spacing: 1px; font-weight: 300; padding-top: 1em; display: inline-block;
}
.mainWrapX span.rating { font-size: 0.875em; letter-spacing: 1px; font-weight: 100; padding: 0.6em 0; display: inline-block; font-style: italic;
}
.mainWrapX input { width: 100px; height: 2em; padding: 0.3em; border: 1px solid orange; text-align: center; color: orange; font-weight: bold; letter-spacing: 1px;
}
.wrapInput { padding: 1em; box-sizing: border-box; background: #f2f2f2; border-bottom: 1px dashed #cccccc;
}
.wrapHighlights { padding: 1.6em 0 2em 0; background: #ffffff;
}
.OfferHighlights { position: relative; overflow: hidden; height: 14px; width: 70px; margin: 0 auto;
}
.ratingBG_disabled { position: absolute; z-index: 1; width: 70px; height: 14px; background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAAOCAIAAAAdR/3SAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANRJREFUeNrclusOgyAMhVdwOGXv/6aKcpEdZyYRsrmfxaZBOHw0IW2JFGO8XctEKVnn4f8c5kk2peScxajuzWlQnmSeJdThbB38tCDZkqLIpssm3/POlCTc0pjJh4AJxrwupSQijF33wLIKcs3S+hFUcjCI2Noi1kLSXouztcNoMlT3XatUJjInUy9BUs3h9cCyjMifPDwP1vsfy1rIdCX/3kCTPbWGY7KLeeHyJlMvjWZaQtC63yDowzAKKftPd+7GnExXWpaIRyM7X6NI1/ttfQkwAM75p5MVTRbeAAAAAElFTkSuQmCC);
}
.ratingBG_active { position: absolute; z-index: 2; width: 0px; height: 14px; background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAAOCAIAAAAdR/3SAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNpi/P//P8PwAoyYXvr7fAeQZJb0IKh5cKpkwlT679UBICImPAanSvRY+v/rw88DakAGu8MtRjYBPCYOWpXosfTvxS40Bs5AGqwqQbH05+bEf+9P///z4f+3U+jSXGaMLAJMgqYs6vlA7pBQCYolIMXIKYOpDhS/304BpSAmDhWViLz099Gq3zdy0JSyakxhlgtDL2oGt0pEXgIKMQmFoOQzoRBMEwe/SpQS78cuMTT9HG6vsObOwawSEUv/Xh8FC4iw6i4CIiADIYhW2gxylf9h4NeV5p+nM//9fA/hAhlALlDwPwYY5CoRXvr79QGm/qEoyDj8mq0AAQYAP1zAd5MCM08AAAAASUVORK5CYII=);
}

Simple star rating using js and data-uri - Script Codes JS Codes

function setRating(eleClass, val){ //hard code width value to avoid undue DOMquery var width = 70, thisEle = document.querySelector(eleClass), val_Stringed=val.toString(), vBefore_Dec, vAfter_Dec = 0, varW_div = 0, widthFactor = 0;//test //if val is less than 1 then nothing if(val < 1 || val > 5){ thisEle.style.width = widthFactor+"px"; alert("C'mon rate yourself from 1 to 5..simple?"); return false; } //check if val has decimal if(val_Stringed.indexOf(".") > 0){ vBefore_Dec = parseInt(val_Stringed.split(".")[0]); vAfter_Dec = parseInt(val_Stringed.split(".")[1]); vAfter_Dec = vAfter_Dec/10; varW_div = width; } else { vBefore_Dec = val_Stringed.split(".")[0]; varW_div = 0; } widthFactor = ((((vBefore_Dec/5)*100)/100)* width) + (((vAfter_Dec*100)/100)* 14) ; widthFactor = Math.round(widthFactor * 10 ) / 10; widthFactor= widthFactor.toString(); console.log("widthFactor will be " + vBefore_Dec + "." + vAfter_Dec + " final:" + widthFactor );// thisEle.style.width = widthFactor+"px"; console.log("done"); //giff feedback they sed :) setTimeout(function(){ if(val < 2){ alert("You are better...It all gets better...cheer up!"); } if(val == 2 || val == 3){ alert("Nice..."); } if(val == 4){ alert("Sweet..."); } if(val == 5){ alert("Yes we all know you are awesome..."); } },666); //feedback :) ended
}
//trigger on input change
var input = document.querySelector("input"); input.addEventListener('keyup', function(){ var val = this.value; setRating(".ratingBG_active", val); console.log("changed!!!"); });
Simple star rating using js and data-uri - Script Codes
Simple star rating using js and data-uri - Script Codes
Home Page Home
Developer Jack_Quarry
Username TheEnd
Uploaded October 11, 2022
Rating 3
Size 5,795 Kb
Views 20,240
Do you need developer help for Simple star rating using js and data-uri?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Jack_Quarry (TheEnd) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!