function friendship_default()
{
- return (array(usersnet_friend_getlabel(1) => "//",
- usersnet_friend_getlabel(2) => "//",
- usersnet_friend_getlabel(3) => "//",
- usersnet_friend_getlabel(4) => "//",
- usersnet_friend_getlabel(5) => "//"));
+ return (array(usersnet_friend_getlabel(1) => "0",
+ usersnet_friend_getlabel(2) => "0",
+ usersnet_friend_getlabel(3) => "0",
+ usersnet_friend_getlabel(4) => "0",
+ usersnet_friend_getlabel(5) => "0"));
}
function usersnet_widefriend($owner, $target)
+function __fieldify_findfirst(objarr, name)
+{
+ for (var i = 0, obj = objarr[i] ; i < objarr.length ; i++) {
+ var item = obj.getElementsByClassName(name + '_id');
+ if (item.length > 0) {
+ return (item);
+ }
+ }
+ return false;
+}
// fieldsdescr = { name: { type: 'typename' }, ... }
-function Fieldify(ancestor, fieldsdescr)
+function Fieldify(ancestors, fieldsdescr)
{
- this.ancestor = ancestor;
-
+ this.ancestors = ancestors;
this.field = new Array();
for (k in fieldsdescr) {
this.field[k] = fieldsdescr[k];
if (this.field[k].type == 'fields') {
- this.field[k].obj = new Fieldify(this.ancestor.getElementsByClassName(k + '_id')[0],
- this.field[k].fields);
+ var item = __fieldify_findfirst(this.ancestors, k);
+ if (item) {
+ this.field[k].obj = new Fieldify(item, this.field[k].fields);
+ }
}
}
}
Fieldify.prototype = {
- ancestor: null,
+ ancestors: null,
field: null,
visible: function(is_visible) {
- this.ancestor.style.visibility = (is_visible ? "visible" : "hidden" );
+ this.ancestors[0].style.visibility = (is_visible ? "visible" : "hidden" );
},
// { 'name': 'value' }
fld_value_set: function(name, value)
{
- this.ancestor.getElementsByClassName(name + '_id')[0].innerHTML = value;
+ var item = __fieldify_findfirst(this.ancestors, name);
+ if (item) {
+ item[0].innerHTML = value;
+ }
},
fld_value_get: function(name)
{
- return this.ancestor.getElementsByClassName(name + '_id')[0].innerHTML;
+ var item = __fieldify_findfirst(this.ancestors, name);
+ if (item) {
+ return (item[0].innerHTML);
+ }
+ return false;
},
fld_radio_set: function(name, value)
{
- var arr = this.ancestor.getElementsByClassName(name + '_id');
-
- for (k in arr) {
- if (arr[k].value == value)
- arr[k].checked = true;
- else
- arr[k].checked = false;
+ var arr = __fieldify_findfirst(this.ancestors, name);
+ if (arr) {
+ for (k in arr) {
+ if (arr[k].value == value)
+ arr[k].checked = true;
+ else
+ arr[k].checked = false;
+ }
}
},
fld_radio_get: function(name)
{
- var arr = this.ancestor.getElementsByClassName(name + '_id');
- ret = null;
-
- for (k in arr) {
- if (arr[k].checked == true) {
- ret = arr[k].value;
- break;
+ var ret = null;
+ var arr = __fieldify_findfirst(this.ancestors, name);
+ if (arr) {
+ for (k in arr) {
+ if (arr[k].checked == true) {
+ ret = arr[k].value;
+ break;
+ }
}
}
return ret;
<tr class="widefriend_id"><td class="le info-opt">Da evitare: <span class="black_id"></span></td>
<td class="le info-opt">In prova: <span class="test_id"></span></td>
<td class="le info-opt">Amico: <span class="friend_id"></span></td>
-<td class="le info-opt">Fidato: <span class="bff_id"></span></td><td></td></tr>
+<td class="le info-opt">Fidato: <span class="bff_id"></span></td></tr>
<!-- <tr class="narrowfriendh_id"><td colspan="3"><b>Cosa ne pensano gli amici fidati:</b></td>
<td class="le info-opt">Bravura: <span class="skill_id"></span></td></tr> -->