Created
April 17, 2015 06:02
-
-
Save superp/c5cdd049b7869cb9ef88 to your computer and use it in GitHub Desktop.
Easy foodporn
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
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