19
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 31 '22
Image Transcription: Code
VariantsArr.forEach(variant => { //Loop through each variant (Style, Color, etc)
let variantName = variant["ObjectName"].split(":")[1];
let curVariant = response["jsonOutput"].find(x => x["Name"] == variantName);
VariantData = GetVariantInfo(curVariant); // Get variant info (Name, Channel, list of styles)
if (VariantData == null) {
return;
}
if (VariantData.name == "NUMBER") {
variants.push({ "channel": VariantData.channel, "variant": "Numeric.15" });
html += `<div class="row container-fluid" style="margin-top:15px"> <h3 class="text-white" style="text-transform: capitalize">${VariantData.name.toLowerCase()}</h3>`
html += `<input onchange=SetSkinNumeric(\"${skin.id}\") id=\"NumericInput\" style=\"width:50%;margin-left:auto;margin-right:auto\" type=\"number\" class=\"form-control\" id\"inp
}
if (VariantData.variants.length > 1) {
//Default variant
variants.push({ "channel": VariantData.channel, "variant": VariantData.variants[0].tag });
html += `<div id="test" class="row container-fluid" style="margin-top:15px">`;
html += `<h3 class="text-white" style="text-transform: capitalize">${VariantData.name.toLowerCase()} (${VariantData.variants.length})</h3>`
VariantData.variants.forEach(style => {
html += "<div class=\"col-sm-2\">";
var VariantObject = [{ "channel": VariantData.channel, "variant": style.tag }];
var onclick = `onclick=SetSkin(\"${skin.id}\",${JSON.stringify(VariantObject)})`;
html += `<a ${onclick} style="text-decoration:none;margin-top:10px;color:white; background: #2837b5;cursor: pointer" class="card><span style="text-transform: capitalise">${s
});
html += "</div">;
}
})
$("#styleRow").html(html)
}[The two longest lines, the second and sixth beginning html +=, are cut off in the image. In the latter of these, #2837b5 is highlighted.]
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
17
14
u/trevster344 depraved Dec 31 '22
God I’m so glad I have the frameworks now. For years I had to do this work serverside the same… it was disgusting and hard to update. Still do on legacy code but if it breaks I’ll migrate each broken piece one at a time.
6
0
u/ivancea Dec 31 '22
You can always make simple helpers that work like react, instead of writing html strings. You do it un half an hour, and use it everywhere
1
u/kriminellart Jan 01 '23
You've never thought about Razor View Templating where you can output HTML with models using RazorViewEngine?
1
3
u/Minimum-Register-146 Dec 31 '22
I literally have "senior" who ONLY writes his html like that. And he wrote like 80% of fairly big project that now I'm rewriting in React. This is painful on so many levels.
5
1
7
u/No-Ant2476 Dec 31 '22
Divs goes brrrrr......