Post by Cicada on May 5, 2015 23:34:12 GMT -8
I'm trying to add links to members' characters on their mini profiles, and since many of the members have lots of characters I'd like the option of having up to 30 links. However, I'm also trying to allow them to input their own links, character names, and colours in so that it can act as a replacement for their signatures (which are too small). Initially I tried this with a couple of {foreach} loops and it worked fine, but when I tried to get it up to 30 characters it told me there were too many. I've tried a couple of other things, but none of them worked.
This is the one that I got working initially (cut down due to repetitiveness):
I tried a few more between here and there, but this is the one I'm trying to get to work now. Bear with me, I'm mostly working off of my beginner's knowledge of Java, not JS:
Any suggestions?
This is the one that I got working initially (cut down due to repetitiveness):
<span style="
{foreach $[user.mini_custom_field]}
{if $[user.mini_custom_field.name] == "Character 1 Color"}
color: #$[user.mini_custom_field.value]
{/if}
{/foreach}" title="
{foreach $[user.mini_custom_field]}
{if $[user.mini_custom_field.name] == "Character 1 Name"}
$[user.mini_custom_field.value]
{/if}
{/foreach}">
{foreach $[user.mini_custom_field]}
{if $[user.mini_custom_field.name] == "Character 1 Link"}
<a href="$[user.mini_custom_field.value]" style="color: inherit;">[1]</a>
{/if}
{/foreach}</span>
<span style="
{foreach $[user.mini_custom_field]}
{if $[user.mini_custom_field.name] == "Character 2 Color"}
color: #$[user.mini_custom_field.value]
{/if}
{/foreach}" title="
{foreach $[user.mini_custom_field]}
{if $[user.mini_custom_field.name] == "Character 2 Name"}
$[user.mini_custom_field.value]
{/if}
{/foreach}">
{foreach $[user.mini_custom_field]}
{if $[user.mini_custom_field.name] == "Character 2 Link"}
<a href="$[user.mini_custom_field.value]" style="color: inherit;">[2]</a>
{/if}
{/foreach}</span>
I tried a few more between here and there, but this is the one I'm trying to get to work now. Bear with me, I'm mostly working off of my beginner's knowledge of Java, not JS:
<script>
var color = [];
var name = [];
var link = [];
var char = [];
for (i = 0; i < 30; i++){
$[user.mini_custom_field].foreach(){
if ($[user.mini_custom_field.name] == "Character " + i + "Color"){
color[i] = "$[user.mini_custom_field.name]";
}
}
}
for (i = 0; i < 30; i++){
$[user.mini_custom_field].foreach(){
if ($[user.mini_custom_field.name] == "Character " + i + "Name"){
name[i] = "$[user.mini_custom_field.name]";
}
}
}
for (i = 0; i < 30; i++){
$[user.mini_custom_field].foreach(){
if ($[user.mini_custom_field.name] == "Character " + i + "Link"){
if ($[user.mini_custom_field.value] != ""){
link[i] = "$[user.mini_custom_field.name]";
}
}
}
}
for (i = 0; i < link.length; i++;){
char[i] = "<span style=\"color: #" + color[i] + "\" title=\"" + name[i] + "\"><a href=\"" + color[i] + "\" style=\"color: inherit;\">[" + i + "</a></span>";
}
document.getElementById("charbox").innerHTML = char;
</script>
Any suggestions?