Post by tules on Aug 10, 2015 17:19:36 GMT -8
continuing from this thread
I'm still pretty new to javascript (my knowledge of it pretty much ends at adding and subtracting numbers) so i'm having trouble turning something like this:
into javascript. the best i can think of with my knowledge is to make something like this:
but i keep getting undefines or just nothing at all. i would really appreiciate if someone could point me in the right direction or give me an example of how it's supposed to be done
edit; i realized i would need a loop to sort through all the stuff in the autoform so i wrote something like this but it didn't work:
I'm still pretty new to javascript (my knowledge of it pretty much ends at adding and subtracting numbers) so i'm having trouble turning something like this:
{foreach $[plugin.settings.monster]}
{if $[plugin.settings.monster.area] == lagoon}
{if $[plugin.settings.monster.oddeven] == 1}<tr>{/if} 19
<td>
<div class="meow" style="min-height: 130px;{if $[plugin.settings.monster.oddeven] == 1}margin-right: 10px;{/if} margin-bottom: 10px;">
<h1 style="font-size: 15px;">$[plugin.settings.monster.monster_name]</h1><br />
<h2><img src="$[plugin.settings.monster.monster_image]" style="height: 75px; width: 75px;"></h2>
<table class="beststats">
{if $[plugin.settings.monster.hp]}<tr><td colspan="4">$[plugin.settings.monster.hp] HP</td></tr>{/if}
<tr>
{if $[plugin.settings.monster.atk]}<td>$[plugin.settings.monster.atk] ATK</td>{/if}
{if $[plugin.settings.monster.def]}<td>$[plugin.settings.monster.def] DEF</td>{/if}
{if $[plugin.settings.monster.rec]}<td>$[plugin.settings.monster.rec] REC</td>{/if}
{if $[plugin.settings.monster.spd]}<td>$[plugin.settings.monster.spd] SPD</td>{/if}
</tr>
</table>
<p>$[plugin.settings.monster.monster_description]</p>
</div>
</td>
{if $[plugin.settings.monster.oddeven] == 1}
{if $[plugin.settings.monster.oddeven] == 2}</tr>{/if}
{/if}
{/if}
{/foreach}
{if $[plugin.settings.monster.area] == lagoon}
{if $[plugin.settings.monster.oddeven] == 1}<tr>{/if} 19
<td>
<div class="meow" style="min-height: 130px;{if $[plugin.settings.monster.oddeven] == 1}margin-right: 10px;{/if} margin-bottom: 10px;">
<h1 style="font-size: 15px;">$[plugin.settings.monster.monster_name]</h1><br />
<h2><img src="$[plugin.settings.monster.monster_image]" style="height: 75px; width: 75px;"></h2>
<table class="beststats">
{if $[plugin.settings.monster.hp]}<tr><td colspan="4">$[plugin.settings.monster.hp] HP</td></tr>{/if}
<tr>
{if $[plugin.settings.monster.atk]}<td>$[plugin.settings.monster.atk] ATK</td>{/if}
{if $[plugin.settings.monster.def]}<td>$[plugin.settings.monster.def] DEF</td>{/if}
{if $[plugin.settings.monster.rec]}<td>$[plugin.settings.monster.rec] REC</td>{/if}
{if $[plugin.settings.monster.spd]}<td>$[plugin.settings.monster.spd] SPD</td>{/if}
</tr>
</table>
<p>$[plugin.settings.monster.monster_description]</p>
</div>
</td>
{if $[plugin.settings.monster.oddeven] == 1}
{if $[plugin.settings.monster.oddeven] == 2}</tr>{/if}
{/if}
{/if}
{/foreach}
into javascript. the best i can think of with my knowledge is to make something like this:
if (pb.plugin.get('bestiary').settings.monster.area = lagoon) {
var monster = pb.plugin.get('bestiary').settings.monster.monster_name;
var monicon = pb.plugin.get('bestiary').settings.monster.monster_image;
var mondesc = pb.plugin.get('bestiary').settings.monster.monster_description;
var monhp = pb.plugin.get('bestiary').settings.monster.hp;
var monatk = pb.plugin.get('bestiary').settings.monster.atk;
var mondef = pb.plugin.get('bestiary').settings.monster.def;
var monrec = pb.plugin.get('bestiary').settings.monster.rec;
var monspd = pb.plugin.get('bestiary').settings.monster.spd;
document.getElementById("lagoon-monname").innerHTML = monster;
document.getElementById("lagoon-monicon").src = monicon;
document.getElementById("lagoon-mondesc").innerHTML = mondesc;
document.getElementById("lagoon-monhp").innerHTML = monhp;
document.getElementById("lagoon-monatk").innerHTML = monatk;
document.getElementById("lagoon-mondef").innerHTML = mondef;
document.getElementById("lagoon-monrec").innerHTML = monrec;
document.getElementById("lagoon-monspd").innerHTML = monspd;
}
var monster = pb.plugin.get('bestiary').settings.monster.monster_name;
var monicon = pb.plugin.get('bestiary').settings.monster.monster_image;
var mondesc = pb.plugin.get('bestiary').settings.monster.monster_description;
var monhp = pb.plugin.get('bestiary').settings.monster.hp;
var monatk = pb.plugin.get('bestiary').settings.monster.atk;
var mondef = pb.plugin.get('bestiary').settings.monster.def;
var monrec = pb.plugin.get('bestiary').settings.monster.rec;
var monspd = pb.plugin.get('bestiary').settings.monster.spd;
document.getElementById("lagoon-monname").innerHTML = monster;
document.getElementById("lagoon-monicon").src = monicon;
document.getElementById("lagoon-mondesc").innerHTML = mondesc;
document.getElementById("lagoon-monhp").innerHTML = monhp;
document.getElementById("lagoon-monatk").innerHTML = monatk;
document.getElementById("lagoon-mondef").innerHTML = mondef;
document.getElementById("lagoon-monrec").innerHTML = monrec;
document.getElementById("lagoon-monspd").innerHTML = monspd;
}
but i keep getting undefines or just nothing at all. i would really appreiciate if someone could point me in the right direction or give me an example of how it's supposed to be done
edit; i realized i would need a loop to sort through all the stuff in the autoform so i wrote something like this but it didn't work:
var beast = pb.plugin.get('bestiary').settings.monster
var beastie = {}
for(a = 0; a < pb.monster_id.length;a++) {
beastie = {
monName: beast[a].monster_name,
monImg: beast[a].monster_image,
monDesc: beast[a].monster_description,
monHp: beast[a].hp,
monAtk: beast[a].atk,
monDef: beast[a].def,
monRec: beast[a].rec,
monSpd: beast[a].spd
};
}
document.getElementById(test).innerHTML = beastie;
var beastie = {}
for(a = 0; a < pb.monster_id.length;a++) {
beastie = {
monName: beast[a].monster_name,
monImg: beast[a].monster_image,
monDesc: beast[a].monster_description,
monHp: beast[a].hp,
monAtk: beast[a].atk,
monDef: beast[a].def,
monRec: beast[a].rec,
monSpd: beast[a].spd
};
}
document.getElementById(test).innerHTML = beastie;