№2782
why isn't this server side code php can just read folder contents and choose a random image that way
№2788
handmade craftsmanship gem
№2790
>>2781Simple but effective, peak Russia engineering.
№2791
>>2781the greastest python schoolar tries xyr hand at the sharty codebase
№2792
is this real
№2803
Lol what the fuck is this real
№2804
>make most efficient and malleable code possible to hold the banners
>WHERE IS THE HECKIN WEIRD ITERATOR THAT ONLY TAKES 1 LINE AND LOOKS LIKE BLACK VOODOO MAGIC
№2805
>>2804Shut the fuck up you coder tranny faggot
№2817
>>2810
kek
№2819
>>2804It's not 'efficient', it's not even performant necessarily (implementation detail of JS engine). Please learn the dinstinction between the 2 terms, I'd show you where I learned it from myself but I can't seem to find the source right now. Efficient would be simply throwing a file (ambiguous) in a directory and then the JS picking a random entry from it. There's no need to give the image a number especially if you're not doing any sort of automatization (although using said numbers would still be poor/misguided). The problem here is very much so overcomplicated, not the other way around as you seem to imply.
№2822
>>2810
Oh LMAO I remember that banner now it makes sense
№2833
>>2782Because that would require some chud who has at least finished the "Beginners PHP" tutorial, which is far beyond the resources of this place.
№2836
dunning kruger thread
№2838
>>2837
we checked the (((source))) and that was precisely why we thought he implemented datamining kys nigger
№2852
⛓️
№2853
%%te⛓️%%
№2973
[code]
// Total banner count - this is the only variable that has to be defined
const count = 45;
// This function will return whether the banner is a .png or .gif by checking if the image exists on the server by creating a JavaScript Image() object and getting it's height
function pngOrGif(url)
{
var img = new Image();
img.src = url;
return img.height != 0;
}
function getRandomImage(count) {
// Selects a random whole number from 0 to the total banner count
var number = Math.floor(Math.random() * count);
// Get the banner URL
var randomImageURL = "
https://soyjak.party/static/banner/" + number;
var fileType = ".png";
if( !pngOrGif( randomImageURL + fileType ) ) {
fileType = ".gif";
}
randomImageURL = randomImageURL + fileType;
var imgHTML = "<img border='1' src='" + randomImageURL + "' style='max-width: 300px;'/>";
document.write(imgHTML);
}
[/code]
№3653
up
№3672
javascript in ohio ?
№3673
>>2782Why would it be server side, the server doesn't care which banner it shows you..
№4826
we go up
№4854
the only thing that's wrong with this is that you have to update it every time a new banner is added, imo there should be a route on the server like /static/banner/random to return a random image, and the server implementation wouldnt have this manual sh£$ since it could just read from the directory
also idk why he's doing the randomImage[x] = "..." bullshit on every line instead of just var randomImage = [urls here]
also it should be a const not a var
this isnt a case of "muh readability muh dunning kruger" its actually just bad code
№5418
uppy
№5477
>>3673because the server can actually read a directory and see all of the banners available instead of having a huge ass array of all of them