Skip to content

Instantly share code, notes, and snippets.

@superp
Created April 17, 2015 06:02
Show Gist options
  • Save superp/c5cdd049b7869cb9ef88 to your computer and use it in GitHub Desktop.
Save superp/c5cdd049b7869cb9ef88 to your computer and use it in GitHub Desktop.
Easy foodporn
if (!window.jQuery) {
script = document.createElement('script');
script.type = "text/javascript";
script.src = "//code.jquery.com/jquery-1.10.2.js";
document.getElementsByTagName('head')[0].appendChild(script);
}
setTimeout(function() {
jQuery(".ss-form-question .ss-choice-item input").unbind("change").change(function(){
var sum = 0;
var parent = jQuery(this).parents(".ss-form-question")
var title = parent.find(".ss-q-title");
var checkSum = title.find(".checkSum");
parent.find(".ss-choice-item input:checked").each(function(){
sum += Number(/\d+$/.exec(this.value)[0]);
});
if (checkSum.length == 0) {
checkSum = jQuery("<div/>").addClass("checkSum").css("font-size", "20px").css("color", "brown");
title.append(checkSum);
}
checkSum.text("Total: " + sum + ", left: " + (50 - sum));
});
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment