Thread:Jens Ingels/@comment-24416108-20141128155015/@comment-24416108-20141129205249

I must admit the Java-script for this parts are quite a bit more elegant than the template logic I've got online now. I've put the Java above in the Common.js, and it works pretty nice. I renamed your div class to humancavalry, so that I can easily expand it without having to type to much.

is there a way to give js some pre-defined values at page load? The current function you gave takes current health as base health, so it just keeps on adding. My thoughts were going to maybe, for health, called: humancavalrybasehp = 55; humancavalrytier = 2; humancavalryinitialrank = 0; humancavalrycurrentrank = (value); (Since rank is uniform across the unit, this would still work on multiple variables I assume)

Would that work? (Or is that more work than needed?) this would make all HealthCalc functions for the Human Cavalry something like: On pageload:

on value change: Am I still showing some understanding so far?

I assume since it references the div class=humancavalry, it can only affect the span tags within? (I think so, but just to be sure..I don't want any interference between templates)

I think I'm starting to understand it a little. I've made a template called TestUnit(div class named testunit), which we can use freely (and where I can screw up freely) without troubling other people. I've transcluded it on our Unit Template Sandbox, so that should work.