● Why did you make that?

Wed Jul 13, 2022 12:09 pm
Clan Leader
Top Dog
Nuke Dev / Coder
2786 Posts
coRpSE
Online
Most Played:
This week: 54.3hrs.
Total Played: 455hrs.


  
Must be a looser...
Reputation: 6987.1
votes: 6
Okay, most of you know me for making stupid things that sometimes turn out to be something that others wanted, or become a mod. I was recently talking to ta friend on Discord, and he asked me how I come up with some of the things that I do, and I just said, I usually need it my self, and if I can't find it, I make it. I had that same philosophy when I worked at the restoration shop restoring old muscle cars, (50s - 70s MOPARs mostly). A great example of this would be a little script I wrote up fast. My sister was up visiting, and had family over, and we love our Pizza. Unfortunately, where I live, so far, all the places I tried are bad in their own ways. It's a sad day when you can honestly say that Dominos or Little Ceases are the best pizza in the area. Well, my family, being the people that they are, (being nice), left it to me to decide. Well, me being very indecisive, I wrote up a script to decide for me. You can see it here:

Please login to see this link
Get registered or Log in


It's very plain and simple, and a challenge for me because I am still learning JavaScript/jQuery. But, that challenge of making it is what made it fun for me. Also, adding the audio touches for the messages was just added in for fun. I am sure there is a better way that I could have accomplished that, but I did what I could and worked perfect for deciding. (It made my sister decide).  lol
I will post the code below for anyone that wants to mess with it or make it better.

Overall, the thing is. When I come up with a script/module/mod/block, I make it for me, some sort of need that I need/want. If someone requests something, and if it's something I could use, I am all for making it, but, if it's something I will never use, then I have to think, how many others are going to use this and how long will it be relevant. If I think others will use it, then I will make it and the post it to the public, but, I have had request for scripts for things like old games that maybe a few would use, and I have turned those projects down.

Now, this has me wondering, have any of you written up something that was just weird, that was just designed for none other reason to see if you could, or just because of a want/need?





Here is the code:

Code: [ Select all ]



<!DOCTYPE html>
<html>
<head>
 ¬†<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 ¬†<title></title>
 ¬†<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 ¬†<meta name="robots" content="noindex, nofollow">
 ¬†<meta name="googlebot" content="noindex, nofollow">
 ¬†<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Lets call upon the jQuery library -->
 ¬†<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Lets add some styling -->
 ¬†<style type="text/css">
 ¬† ¬†body {
 ¬† ¬† ¬† ¬†background-color:#333;
 ¬† ¬† ¬† ¬†color: #FFF;
 ¬† ¬† ¬† ¬†text-align: center;
 ¬† ¬†}
 ¬† ¬†div {
 ¬† ¬† ¬† ¬†font-size: 18px;
 ¬† ¬†}
 ¬† ¬†div.winner {
 ¬† ¬† ¬† ¬†font-size: 48px !important;
 ¬† ¬†}
 ¬† ¬†.button {
 ¬† ¬† ¬† ¬†border: none;
 ¬† ¬† ¬† ¬†padding: 16px 32px;
 ¬† ¬† ¬† ¬†text-align: center;
 ¬† ¬† ¬† ¬†text-decoration: none;
 ¬† ¬† ¬† ¬†display: inline-block;
 ¬† ¬† ¬† ¬†font-size: 16px;
 ¬† ¬† ¬† ¬†margin: 4px 2px;
 ¬† ¬† ¬† ¬†transition-duration: 0.4s;
 ¬† ¬† ¬† ¬†cursor: pointer;
 ¬† ¬†}
 ¬† ¬†.button1, .button1:focus, .button1:active{
 ¬†background-color: #CCC;
 ¬†color: #000;
 ¬†font-weight:600;
 ¬†border: 2px solid #4CAF50;
}

.button1:hover {
 ¬†background-color: #4CAF50;
 ¬†color: white;
}
 ¬†</style>
</head>

<body>
<!-- Lets preload the audio -->
<audio class="audios" id="tada" preload="none">
 ¬† <source src="./files/coRpSE/tada.mp3" type="audio/mpeg">
</audio>
<audio class="audios" id="haha" preload="none">
 ¬† <source src="./files/coRpSE/haha.mp3" type="audio/mpeg">
</audio>

<!-- Lets Design the simple page -->
<h1>Pizza Place Decider</h1>
<h3>Let me decide where to get your pizza.</h3>
 ¬† ¬†<button class="button button1" id="random">Choose Pizza Place</button>
<br /><br />
<div id="pplace">
</div>

<!-- Time for the jQuery -->
<script>
 ¬† ¬†//Setting the vaiable of the pizza shops in the area that I can tolerate.
 ¬† ¬†//Did multiple and randomized them on my own a bit to make the rolling through the name last longer.
 ¬† ¬†var pizzaplaces = [
 ¬† ¬†{ 'Pizza_ID': 0, 'Pizza_Shops': "Dominos" },
 ¬† ¬†{ 'Pizza_ID': 1, 'Pizza_Shops': "Little Ceasers" },
 ¬† ¬†{ 'Pizza_ID': 2, 'Pizza_Shops': "Market Basket" },
 ¬† ¬†{ 'Pizza_ID': 3, 'Pizza_Shops': "Somewhere New" },
 ¬† ¬†{ 'Pizza_ID': 4, 'Pizza_Shops': "Up to the person<br />to my right!" },
 ¬† ¬†{ 'Pizza_ID': 5, 'Pizza_Shops': "Dominos" },
 ¬† ¬†{ 'Pizza_ID': 6, 'Pizza_Shops': "Little Ceasers" },
 ¬† ¬†{ 'Pizza_ID': 7, 'Pizza_Shops': "Dominos" },
 ¬† ¬†{ 'Pizza_ID': 8, 'Pizza_Shops': "Market Basket" },
 ¬† ¬†{ 'Pizza_ID': 9, 'Pizza_Shops': "Market Basket!" },
 ¬† ¬†{ 'Pizza_ID': 10, 'Pizza_Shops': "Dominos" },
 ¬† ¬†{ 'Pizza_ID': 11, 'Pizza_Shops': "Little Ceasers" },
 ¬† ¬†{ 'Pizza_ID': 12, 'Pizza_Shops': "Market Basket" },
 ¬† ¬†{ 'Pizza_ID': 13, 'Pizza_Shops': "Somewhere New" },
 ¬† ¬†{ 'Pizza_ID': 14, 'Pizza_Shops': "Up to the person<br />to the right!" },
];

var $pplace = $("#pplace");
$('#random').click(function(){
 ¬† ¬†var total = pizzaplaces.length,
 ¬† ¬† ¬† ¬†selected = Math.floor( Math.random() * total),
 ¬† ¬† ¬† ¬†i = 0;
 ¬† ¬†console.log( "selected", selected );
 ¬† ¬†$pplace.removeClass( "winner" );

 ¬† ¬†for (i=0; i<total; i++) {
 ¬† ¬† ¬† ¬†console.log( "for", i );
 ¬† ¬† ¬† ¬†setTimeout((function(i){
 ¬† ¬† ¬† ¬† ¬† ¬†return function(){
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†console.log( "timeout", i );
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†$pplace.html( pizzaplaces[i].Pizza_Shops.toUpperCase() );
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†if( i === selected ) {
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†$pplace.addClass( "winner" );
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†var haha_arr = [4,14]; //Array to play the haha sound.
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†if (jQuery.inArray(i, haha_arr) !== -1){
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†$('#haha').trigger('play');
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†} else {
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†$('#tada').trigger('play');
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†}
 ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†}
 ¬† ¬† ¬† ¬† ¬† ¬†};
 ¬† ¬† ¬† ¬†}(i)), i*200); //200ms for it to scroll from 1 name to the other.
 ¬† ¬† ¬† ¬†if( i === selected ) {
 ¬† ¬† ¬† ¬† ¬† ¬†break;
 ¬† ¬† ¬† ¬†}
 ¬† ¬†}
});
</script>
</body>
</html>


The audio files used, (just right click and "Save Link As"):
Please login to see this link
Get registered or Log in
Please login to see this link
Get registered or Log in


Expand
Thu Jul 14, 2022 7:59 am
Spammer
103 Posts
Reputation: 183.1
A man after my own heart, LOL! You go, MAN! Create more and more!  cool  big grin  big grin
Forums ©