A Pen by Joe Crawford on CodePen.
Created
March 9, 2018 22:05
-
-
Save artlung/bc6b87f3137dc69007bad1ddf48591af to your computer and use it in GitHub Desktop.
Shag Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div.container-fluid | |
div.row | |
div.col-md-12 | |
h2 shag calculator | |
div.form-horizontal | |
div.form-group | |
label.col-sm-6[for="b"] average penis length sexual partner (inches) | |
div.col-sm-6.input-group | |
span.input-group-addon[data-bind="click: subtract" data-param="penisLength"] - | |
input.form-control[id="b" data-bind="textInput: penisLength"] | |
span.input-group-addon[data-bind="click: add" data-param="penisLength"] + | |
div.form-group | |
label.col-sm-6[for="d"] thrusts per minute | |
div.col-sm-6.input-group | |
span.input-group-addon[data-bind="click: subtract" data-param="thrustsPerMinute"] - | |
input.form-control[id="d" data-bind="textInput: thrustsPerMinute"] | |
span.input-group-addon[data-bind="click: add" data-param="thrustsPerMinute"] + | |
div.form-group | |
label.col-sm-6[for="e"] intercourse duration (minutes) | |
div.col-sm-6.input-group | |
span.input-group-addon[data-bind="click: subtract" data-param="intercourseDuration"] - | |
input.form-control[id="e" data-bind="textInput: intercourseDuration"] | |
span.input-group-addon[data-bind="click: add" data-param="intercourseDuration"] + | |
div.form-group | |
label.col-sm-6[for="f"] distance per intercourse (inches) | |
div.col-sm-6.output[id="f" data-bind="text: distancePerIntercourse"] | |
div.form-group | |
label.col-sm-6[for="f"] distance per intercourse (feet) | |
div.col-sm-6.output[id="f" data-bind="text: distancePerIntercourseFeet"] | |
div.form-group | |
label.col-sm-6[for="f"] intercourse per year (yearly average) | |
div.col-sm-6.input-group | |
span.input-group-addon[data-bind="click: subtract" data-param="intercoursePerYear"] - | |
input.form-control[id="f" data-bind="textInput: intercoursePerYear"] | |
span.input-group-addon[data-bind="click: add" data-param="intercoursePerYear"] + | |
div.form-group | |
label.col-sm-6[for="g"] years sexually active | |
div.col-sm-6.input-group | |
span.input-group-addon[data-bind="click: subtract" data-param="yearsSexuallyActive"] - | |
input.form-control[id="g" data-bind="textInput: yearsSexuallyActive"] | |
span.input-group-addon[data-bind="click: add" data-param="yearsSexuallyActive"] + | |
div.form-group | |
label.col-sm-6[for="h"] intercourse count (lifetime) | |
div.col-sm-6.output[id="h" data-bind="text: intercourseCountLifetime"] | |
div.form-group | |
label.col-sm-6[for="i"] distance (lifetime / inches) | |
div.output.col-sm-6[id="i" data-bind="text: intercourseDistance"] | |
div.form-group | |
label.col-sm-6[for="j"] distance (lifetime / feet) | |
div.output.col-sm-6[id="j" data-bind="text: intercourseDistanceFeet"] | |
div.form-group | |
label.col-sm-6[for="k"] distance (lifetime / miles) | |
div.output.col-sm-6.output-final[id="k" data-bind="text: intercourseDistanceMiles"] | |
div.form-group | |
label.col-sm-6[for="k"] distance (lifetime / km) | |
div.output.col-sm-6.output-final[id="k" data-bind="text: intercourseDistanceKm"] | |
div.form-group | |
label.col-sm-6[for="m"] zip code | |
div.col-sm-2 | |
input.form-control[id="m" data-bind="textInput: location"] | |
div.col-sm-2 | |
input.form-control[data-bind="value: lat" disabled] | |
div.col-sm-2 | |
input.form-control[data-bind="value: lng" disabled] | |
div.form-group | |
label.col-sm-6[for="x"] new lat lng | |
div.col-sm-3 | |
p[data-bind="text: lat2"] | |
div.col-sm-3 | |
p[data-bind="text: lng2"] | |
<!-- google maps javascript --> | |
<script src="//maps.googleapis.com/maps/api/js?key=AIzaSyB16sGmIekuGIvYOfNoW9T44377IU2d2Es"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geocoder = new google.maps.Geocoder(); | |
var APP = {}; | |
APP.location = ko.observable("92108"); | |
APP.savedResults = {}; | |
APP.lat = ko.observable(); | |
APP.lng = ko.observable(); | |
APP.increment = function(obj, evt, operation) { | |
var param = evt.currentTarget.getAttribute('data-param'); | |
if (APP[param]) { | |
var value = APP[param](); | |
var increment = 1; | |
switch (param) { | |
case "thrustsPerMinute": | |
increment = 10; | |
break; | |
case "penisLength": | |
increment = 0.25; | |
break; | |
case "intercourseDuration": | |
increment = 0.5; | |
break; | |
default: | |
} | |
if (operation && operation === "subtract") { | |
APP[param](value - increment); | |
} else { | |
APP[param](value + increment); | |
} | |
} | |
} | |
APP.add = function(obj, evt) { | |
APP.increment(obj, evt, "add"); | |
}; | |
APP.subtract = function(obj, evt) { | |
APP.increment(obj, evt, "subtract"); | |
}; | |
// http://stackoverflow.com/questions/5585957/get-latlng-from-zip-code-google-maps-api | |
function getGeocode(zipCode) { | |
geocoder.geocode( | |
{ address : zipCode, | |
region: 'no' | |
}, function(results, status){ | |
APP.savedResults[APP.location()] = results; | |
if (APP.savedResults[APP.location()][0].geometry.location.lat()) { | |
APP.lat(APP.savedResults[APP.location()][0].geometry.location.lat()) | |
APP.lng(APP.savedResults[APP.location()][0].geometry.location.lng()) | |
} | |
}); | |
} | |
APP._stashLocation = ko.computed(function() { | |
if (!APP.savedResults.hasOwnProperty(APP.location()) && APP.location().length === 5) { | |
getGeocode(APP.location() + " USA"); | |
} | |
}) | |
APP.penisLength = ko.observable(5.25); | |
APP.max = function (name, value) { | |
if (APP[name]() > value) { | |
APP[name](value); | |
} | |
}; | |
APP.min = function (name, value) { | |
if (APP[name]() < value) { | |
APP[name](value); | |
} | |
}; | |
APP.intercourseCount = ko.observable(100); | |
APP.thrustsPerMinute = ko.observable(120); | |
APP.intercourseDuration = ko.observable(7.5); | |
APP.intercoursePerYear = ko.observable(100); | |
APP.yearsSexuallyActive = ko.observable(12); | |
APP._valuecheck = ko.computed(function () { | |
APP.min("penisLength", 1.0); | |
APP.max("penisLength", 14.0); | |
APP.min("intercourseDuration", 0); | |
APP.min("intercourseCount", 0); | |
APP.min("thrustsPerMinute", 0); | |
APP.min("intercourseDuration", 0); | |
APP.min("intercoursePerYear", 0); | |
APP.min("yearsSexuallyActive", 0); | |
APP.max("yearsSexuallyActive", 100); | |
}); | |
APP.intercourseCountLifetime = ko.computed(function () { | |
return APP.intercoursePerYear() * APP.yearsSexuallyActive(); | |
}); | |
APP.distancePerIntercourse = ko.computed(function () { | |
return APP.penisLength() * APP.thrustsPerMinute() * | |
APP.intercourseDuration(); | |
}); | |
APP.distancePerIntercourseFeet = ko.computed(function () { | |
return APP.distancePerIntercourse() / 12; }); | |
APP.intercourseDistance = ko.computed(function () { | |
return APP.distancePerIntercourse() * APP.intercourseCountLifetime(); | |
}); | |
APP.intercourseDistanceFeet = ko.computed(function () { | |
return APP.intercourseDistance() / 12; | |
}); | |
APP.intercourseDistanceMiles = ko.computed(function () { | |
return Math.round(APP.intercourseDistance() / 5280); | |
}); | |
APP.R = ko.observable(6378.1); | |
//http://stackoverflow.com/questions/7222382/get-lat-long-given-current-point-distance-and-bearing | |
APP.intercourseDistanceKm = ko.computed(function () { | |
return Math.round(APP.intercourseDistanceMiles() / 0.62137); | |
}); | |
APP.lat2 = ko.computed(function () { | |
if (APP.lat()) { | |
var lat1 = APP.lat() * Math.PI / 180; | |
var d = APP.intercourseDistanceKm(); | |
var R = APP.R(); | |
var brng = 1.57; // Bearing is 90 degrees converted to radians. | |
return (Math.asin(Math.sin(lat1) * Math.cos(d / R) + Math.cos(lat1) * Math.sin(d / R) * Math.cos(brng))) * 180 / Math.PI; | |
} | |
}); | |
APP.lng2 = ko.computed(function () { | |
if (APP.lng() && APP.lat()) { | |
var lng1 = APP.lng() * Math.PI / 180; | |
var lat1 = APP.lat(); | |
var lat2 = APP.lat2(); | |
var d = APP.intercourseDistanceKm(); | |
var R = APP.R(); | |
var brng = 1.57; // Bearing is 90 degrees converted to radians. | |
return (lng1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), | |
Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2))) * 180 / Math.PI; | |
} | |
}); | |
/* | |
APP.savedResults["92117"][0].geometry.location.lat() | |
APP.savedResults["92117"][0].geometry.location.lng() | |
*/ | |
ko.applyBindings(APP); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@import "compass/reset"; | |
//@import "compass/css3"; | |
h2 { | |
text-align: right; | |
} | |
.form-group { | |
label { | |
text-align: right; | |
} | |
.input-group-addon { | |
cursor: pointer; | |
} | |
input.form-control { | |
text-align: center; | |
} | |
} | |
div.output { | |
font-weight: bold; | |
text-align: center; | |
&.output-final { | |
color: green; | |
font-size: x-large; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment