<p>Total %: <span% <span id="confiReport"></span></p>
<script type="application/javascript">
function totalPercent(ta, td) {
return Math.round((td / ta) * 100);
}
AJS.toInit(function() {
var isPageEdit = AJS.$('#content').hasClass('page edit');
if (!isPageEdit) {
var url = 'https://wiki.vertuna.com/ajax/confiforms/rest/filter.action?pageId=52626406&f=AmountTracking&q=';
var xhr = AJS.$.ajax({
url: url,
timeout: 10000, // 10 sec
success: function (data) {
var ta = 0;
var td = 0;
var rows = data.list.entry;
for (i=0;i<rows.length;i++) {
ta = ta + rows[i].fields.TotalAmount;
td = td + rows[i].fields.Deductible;
}
AJS.$('#confiReport').append(totalPercent(ta, td));
},
error: function (jqXHR, textStatus, errorThrown) {
console.log('request to get data from ConfiForms has failed... ' + textStatus);
}
});
}
});
</script>
|