Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
	<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:400,800" rel="stylesheet">
</head>

<body>
	<section id="inputs">
		<label for="fyStart">Start of Fiscal Year</label>
		<!--https://stackoverflow.com/questions/58191201/how-can-i-use-input-type-date-to-dynamically-only-allow-for-one-year-from-curren-->
		<input id="fyStart" type="date"></input>
		<table>
			<tr class="header-row">
				<th>Stage</th>
				<th>Created This FY</th>
				<th>Conversion Rate</th>
				<th>Improvement (%)</th>
				<th>New Value</th>
				<th>New Conversion Rate</th>
			</tr>
			<tr>
				<td class="row-header">MQLs</td>
				<td><input id="mqlInput" type="number" value="1000"></td>
				<td><span id="mqlToSalConversionRate">0</span>%</td>
				<td><input id="mqlToSalImprovement" class="percent" type="number" value="5" min="0">%</td>
				<td><span id="mqlResult">0</span></td>
				<td><span id="newMqlToSalConversionRate">0</span>%</td>
			</tr>
			<tr>
				<td class="row-header">Meetings</td>
				<td><input id="salInput" type="number" value="300"></td>
				<td><span id="salToSqlConversionRate">0</span>%</td>
				<td><input id="salToSqlImprovement" class="percent" type="number" value="5" min="0">%</td>
				<td><span id="salResult">0</span></td>
				<td><span id="newSalToSqlConversionRate">0</span>%</td>
			</tr>
			<tr>
				<td class="row-header">SQLs</td>
				<td><input id="sqlInput" type="number" value="150"></td>
				<td><span id="sqlToWonConversionRate">0</span>%</td>
				<td></td>
				<td><span id="sqlResult">0</span></td>
				<td><span id="newSqlToWonConversionRate">0</span>%</td>
			</tr>
		</table>
	</section>
	<div>Total Pipeline Improvement: <span id="totImp">0</span>%</div>
	<section id="results">
		<table>
			<tr class="header-row">
				<th></th>
				<th>Created This FY</th>
				<th>New</th>
				<th>Difference</th>
				<th>Annualized Difference</th>
			</tr>
			<tr>
				<td class="row-header">Total Pipeline ($)</td>
				<td><input id="pipeInput" type="number" min="0" step="0.01" value="7500000"></td>
				<td>$<span id="newPipe">0</span></td>
				<td>$<span id="pipeDiff">0</span></td>
				<td>$<span id="annPipeDiff">0</span></td>
			</tr>
			<tr>
				<td class="row-header">Closed Won Opps</td>
				<td><input id="wonInput" type="number" step="1" value="50"></td>
				<td><span id="newWon">0</span></td>
				<td><span id="wonDiff">0</span></td>
				<td><span id="annWonDiff">0</span></td>
			</tr>
			<tr>
				<td class="row-header">Total Bookings ($)</td>
				<td><input id="bookingsInput" type="number" min="0" step="0.01" value="2500000"></td>
				<td>$<span id="newBookings">0</span></td>
				<td>$<span id="bookingsDiff">0</span></td>
				<td>$<span id="annBookingsDiff">0</span></td>
			</tr>
		</table>
	</section>
</body>
              
            
!

CSS

              
                body {
	font-family: Nunito Sans, Helvetica, Sans Serif;
}
table {
	border: 1px solid black;
	margin: 1em 0;
}

table .header-row {
	background-color: #7d42ff;
	color: #fff;
	text-align: left !important;
}

table .row-header {
	font-weight: bold;
	text-align: left;
}

table td {
	text-align: right;
	width: 180px;
}

table input {
	border: none;
	display: inline;
	background-color: #ccc;
}

table input {
	width: 100%;
	text-align: right;
}

table input.percent {
	width: 89%;
}

              
            
!

JS

              
                function setValue(elementId, value) {
	let el = document.getElementById(elementId);
	el.innerHTML = value;
	//el.style.backgroundColor = "yellow";
}

function roundToTwo(num) {
	return +(Math.round(num + "e+2") + "e-2");
}

function doCalcs() {
	let fyStart = document.getElementById("fyStart").value;
	let numMQL = document.getElementById("mqlInput").value;
	let numSAL = document.getElementById("salInput").value;
	let numSQL = document.getElementById("sqlInput").value;
	let numWon = document.getElementById("wonInput").value;
	let mqlImp = document.getElementById("mqlToSalImprovement").value;
	let salImp = document.getElementById("salToSqlImprovement").value;
	let totPipe = document.getElementById("pipeInput").value;
	let totWon = document.getElementById("wonInput").value;
	let totBookings = document.getElementById("bookingsInput").value;

	//let mqlRate = Math.round((numSAL/numMQL) * 100 * 100)/100;
	let mqlRate = roundToTwo((numSAL / numMQL) * 100);
	let salRate = roundToTwo((numSQL / numSAL) * 100);
	let sqlRate = roundToTwo((numWon / numSQL) * 100);

	let newMqlRate;
	if (mqlImp == 0) {
		newMqlRate = mqlRate;
	} else {
		newMqlRate = roundToTwo(mqlRate + mqlRate * (mqlImp / 100));
	}
	let salResult = Math.round(numMQL * (newMqlRate / 100));

	let newSalRate;
	if (salImp == 0) {
		newSalRate = salRate;
	} else {
		newSalRate = roundToTwo(salRate + salRate * (salImp / 100));
	}
	let sqlResult = Math.round(salResult * (newSalRate / 100));

	let newSqlRate = sqlRate;

	let totImp = roundToTwo((100 * (sqlResult - numSQL)) / numSQL);

	let yearProg =
		Math.floor((new Date() - new Date(fyStart)) / (1000 * 60 * 60 * 24)) / 365;

	let newPipe = Number(totPipe) + totPipe * (totImp / 100);
	let pipeDiff = newPipe - Number(totPipe);
	let annPipeDiff = roundToTwo(pipeDiff / yearProg);

	let newWon = Math.round(Number(totWon) + (totWon * totImp) / 100);
	let wonDiff = newWon - totWon;
	let annWonDiff = Math.round(wonDiff / yearProg);

	let newBookings = Number(totBookings) + (totBookings * totImp) / 100;
	let bookingsDiff = newBookings - Number(totBookings);
	let annBookingsDiff = roundToTwo(bookingsDiff / yearProg);

	setValue("mqlToSalConversionRate", mqlRate);
	setValue("salToSqlConversionRate", salRate);
	setValue("sqlToWonConversionRate", sqlRate);
	setValue("mqlResult", numMQL);
	setValue("newMqlToSalConversionRate", newMqlRate);
	setValue("newSalToSqlConversionRate", newSalRate);
	setValue("salResult", salResult);
	setValue("sqlResult", sqlResult);
	setValue("newSqlToWonConversionRate", newSqlRate);
	setValue("totImp", totImp);
	setValue("newPipe", newPipe);
	setValue("pipeDiff", pipeDiff);
	setValue("annPipeDiff", annPipeDiff);
	setValue("newWon", newWon);
	setValue("wonDiff", wonDiff);
	setValue("annWonDiff", annWonDiff);
	setValue("newBookings", newBookings);
	setValue("bookingsDiff", bookingsDiff);
	setValue("annBookingsDiff", annBookingsDiff);
}

(function () {
	let today = new Date();
	let yearStart = today.getFullYear() + "-01-01";
	let maxStart = today.toISOString().split("T")[0];
	let minStart = new Date(new Date().setFullYear(today.getFullYear() - 1))
		.toISOString()
		.split("T")[0];

	let fyStart = document.getElementById("fyStart");
	fyStart.value = yearStart;
	fyStart.min = minStart;
	fyStart.max = maxStart;

	let inputEls = document.querySelectorAll("input");
	let inputElArray = Array.prototype.slice.call(inputEls);
	inputElArray.forEach(function (el) {
		el.addEventListener("change", doCalcs);
	});

	doCalcs();
})();

              
            
!
999px

Console