有一项功能我无法直接编辑,因为我使用的软件会自动输出此代码而我无法访问它。我想覆盖代码中的一个变量。我有权在页脚中添加代码。我想将Goal的变量更改为2000,是否可以直接编辑该函数?
var goal = parseCurrency(jQuery('#374ec6b5_thermometer .total-goal-value').text());
如果我可以从另一个div中更改此拉力,或将其设置为可能非常棒的数字2000。如果这不是足够的信息,或者它是不可能的,请告诉我。谢谢!
Y.use("jquery-ui", function(Y) {
jQuery(function() {
var calcThermPercentage = function() {
// calculate the thermometer percentage
var raised = parseCurrency(jQuery('#374ec6b5_thermometer .amount-raised-value').text());
var goal = parseCurrency(jQuery('#374ec6b5_thermometer .total-goal-value').text());
var percent = raised / goal;
if (percent > 1) {
percent = 1;
}
var percentage = percent;
if (isNaN(percentage)) {
percentage = 0;
}
jQuery('#374ec6b5_thermometer .amount-percentage-value').text(Math.floor(percentage * 100) + "%");
// get the width of the outer container;
var outerWidth = jQuery('#374ec6b5_thermometer .thermometer-outer').css('width').slice(0, -2);
var innerWidth = outerWidth * percent;
jQuery('#374ec6b5_thermometer .thermometer-inner').animate({
'width': innerWidth + 'px'
}, 1000);
};
calcThermPercentage();
var waitForFinalEvent = (function() {
var timers = {};
return function(callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "default_unique_id";
}
if (timers[uniqueId]) {
clearTimeout(timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();
jQuery(window).resize(function() {
waitForFinalEvent(calcThermPercentage, 500, "374ec6b5");
});
});
});
function parseCurrency(currency) {
currency = currency.replace(/[^0-9\.]+/g, "");
var val = parseInt(currency);
return val;
}