Pure Libs

Developer
Size
2,656 Kb
Views
10,120

How do I make an pure libs?

Like mad libs but with no prompts. Inspired by the horrible sentences you come up with by only clicking smartphone keyboard recommended words.. What is a pure libs? How do you make a pure libs? This script and codes were developed by Sheodox on 26 December 2022, Monday.

Pure Libs Previews

Pure Libs - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pure Libs</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p id=instructions></p>
<div id=simple-question> <label id=simple-prompt for=answer></label> <input id=simple-answer />
</div>
<div id=filler-question> <span id=filler-before></span> <input id=filler-answer /> <span id=filler-after></span>
</div>
<p id=story></p> <script src="js/index.js"></script>
</body>
</html>

Pure Libs - Script Codes CSS Codes

input { text-align: center; font-size: 2rem;
}
body { font-size: 2rem;
}

Pure Libs - Script Codes JS Codes

function q(sel) { return document.querySelector(sel);
}
function resolveOnEnter(resolve, input) { function keydown(e) { if (e.which === 13) { input.removeEventListener("keydown", keydown); resolve(input.value); input.value = ""; } } input.addEventListener("keydown", keydown); input.focus();
}
const instructions = q("#instructions"), simple = { container: q("#simple-question"), prompt: q("#simple-prompt"), answer: q("#simple-answer") }, filler = { container: q("#filler-question"), before: q("#filler-before"), after: q("#filler-after"), answer: q("#filler-answer") };
let groups = [];
function askSimple(prompt) { return function() { return new Promise(res => { simple.container.style.display = ""; filler.container.style.display = "none"; simple.prompt.textContent = prompt; resolveOnEnter(function(word) { groups.push([word]); res(); }, simple.answer); }); };
}
function askFiller(group, index) { return new Promise(res => { filler.container.style.display = ""; simple.container.style.display = "none"; filler.before.textContent = group[index]; filler.after.textContent = group[index + 1] || ""; resolveOnEnter(function(word) { group.splice(index + 1, 0, word); res(); }, filler.answer); });
}
function instruct(instruction) { return function() { instructions.textContent = instruction; };
}
function rng(max) { return Math.floor(Math.random() * max);
}
function fillGroups() { return new Promise(resolve => { function randomInsert() { return new Promise(res => { const group = groups[rng(groups.length)], index = rng(group.length); askFiller(group, index).then(res); }); } let prompts = Promise.resolve(); for (let i = 0; i < 20; i++) { prompts = prompts.then(randomInsert); } prompts.then(resolve); });
}
function spliceFiller(group1, group2) { return new Promise(res => { log(group1); log(group2); filler.before.textContent = group1[group1.length - 1]; filler.after.textContent = group2[0]; resolveOnEnter(res, filler.answer); });
}
function spliceGroups() { return new Promise(res => { function combine(group1, group2) { return function() { return spliceFiller(group1, group2).then(fillWord => { done += " " + group1.join(" ") + " " + fillWord; }); }; } let done = ""; Promise.resolve() .then(combine(groups[0], groups[1])) .then(combine(groups[1], groups[2])) .then(combine(groups[2], groups[3])) .then(combine(groups[3], groups[4])) .then(function() { res(done + " " + groups[4].join(' ')); }); });
}
function storytime(story) { q("#story").textContent = story;
}
function log(m) { console.log(m);
}
Promise.resolve() .then(instruct("Please input some words to start")) .then(askSimple("First word")) .then(askSimple("Second word")) .then(askSimple("Third word")) .then(askSimple("Forth word")) .then(askSimple("Fifth word")) .then(instruct("Enter a word that makes sense given the surrounding words")) .then(fillGroups) .then(spliceGroups) .then(storytime);
Pure Libs - Script Codes
Pure Libs - Script Codes
Home Page Home
Developer Sheodox
Username sheodox
Uploaded December 26, 2022
Rating 3
Size 2,656 Kb
Views 10,120
Do you need developer help for Pure Libs?

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!

Sheodox (sheodox) Script Codes
Create amazing marketing copy 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!