Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
on("sheet:opened change:repeating_attrmodkon remove:repeating_attrmodkon",function() {
TAS.repeating("attrmodkon")
.attrs("kon_mod") //< getting the attributes for the totals
.fields('value','active') //< specifying the fields we care about
.reduce(function(m,r){
var active = r.active;
if(active == "on"){
m += parseInt(r.I.value); //< Generate a running cost
}
return m;
},0,function(m,r,a){
a.kon_mod = m; //< take the final sum and set it on the total attribute
})
.execute(); //< begin executing the above operations
TAS.repeating("attrmodkon")
.attrs("kon_mod_tooltip") //< getting the attributes for the totals
.fields('name','value','active') //< specifying the fields we care about
.reduce(function(m,r){
var row = "";
if(r.active=="on"){
row = "<tr><td>"+r.name+"</td><td>"+r.value+"</td></tr>";
}else{
row = "<tr><td>"+r.name+" (disabled)</td><td>"+r.value+"</td></tr>";
}
m.desc.push(row);
return m;
},{desc: []},function(m,r,a){
if(m.desc.length>0){
a.kon_mod_tooltip = "<div class=\"sheet-chat-tooltip\"><table>"+m.desc.join('')+"</table></div>";
}else{
a.kon_mod_tooltip = "";
}
})
.execute();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment