Skip to content

Instantly share code, notes, and snippets.

@ryancatalani
Last active August 29, 2015 14:19
Show Gist options
  • Save ryancatalani/574e77c8b657ceccf752 to your computer and use it in GitHub Desktop.
Save ryancatalani/574e77c8b657ceccf752 to your computer and use it in GitHub Desktop.
Berkeley Beacon snow day calculator
// Twitter
var twt_text = "My canceled classes at @EmersonCollege are worth $" + Math.ceil(total_cost) + ". " + window.location.toString() + " via @BeaconUpdate";
var encoded_twt_text = encodeURIComponent(twt_text);
var twt_link = "https://twitter.com/intent/tweet?&text=" + encoded_twt_text;
// Facebook
var fb_link = "https://www.facebook.com/dialog/feed?" +
"app_id=APP_ID" +
"&display=popup" +
"&caption=See%20how%20much%20your%20canceled%20classes%20at%20Emerson%20are%20worth." +
"&description=An%20interactive%20feature%20by%20The%20Berkeley%20Beacon." +
"&link=http%3A%2F%2Fwww.berkeleybeacon.com%2Fprojects%2Fsnow_calculator" +
"&picture=https%3A%2F%2Fs3.amazonaws.com%2FBerkeleyBeacon%2Fbeacon_uploads%2Fuploads%2F1423126348-Snowstorm_Bushell_01272015_0021.jpg.jpg" +
"&redirect_uri=http://www.berkeleybeacon.com/projects/snow_calculator&name=";
var fb_results = "My canceled classes are worth $" + Math.ceil(total_cost);
var fb_results_encoded = encodeURIComponent(fb_results);
var fb_final_link = fb_link + fb_results_encoded;
var monday_snow_days = 2; // // Days of school canceled on Monday before 4 pm
var monday_after_snow_days = 1; // Days of school canceled on Monday after 4 pm
var tuesday_snow_days = 2;
var wednesday_snow_days = 1;
var credit_cost = 1145.0; // http://www.emerson.edu/admission/graduate-admission/tuition-expenses/tuition-cost
var credit_hours = 15.0; // 1 credit hour per semester is 15 weeks of classroom instruction; http://www.emerson.edu/policy/credit-hour-definition
var credit_cost_per_hour = credit_cost / credit_hours;
// Uses the big.js <http://mikemcl.github.io/big.js/> library, just in case there were large numbers.
var calculate_cost = function(hours) {
var hours_big = new Big(hours);
var rounded = hours_big.times(credit_cost_per_hour_big).round(2, 1).toFixed(2);
update_total_text(rounded);
total_cost = rounded;
update_share_links();
return rounded;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment