aboutsummaryrefslogtreecommitdiff
path: root/foaf-vix.js
blob: 0120e02e57be6b58adc4be5b2c89a0e4ed5a6b1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
   FOAF.Vix foaf-vix.js
   Copyright (C) 2006, 2008 Wojciech Polak

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 3 of the License, or (at your
   option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

function init () {
  var personName = getElementsByClassName (document, 'span', 'person-name');
  personName = personName.length ? personName[0] : null;
  if (personName) {
    document.title = personName.innerHTML.replace (/<\/?[^>]+>/gi, '')
      + ' - FOAF';
  }
  var imageMaxWidth = 350;
  var ownerImage = getElementsByClassName (document, 'img', 'ownerImage');
  ownerImage = ownerImage.length ? ownerImage[0] : null;
  if (ownerImage && ownerImage.complete) {
    if (ownerImage.width > imageMaxWidth)
      ownerImage.width = imageMaxWidth;
  }
  else if (ownerImage) {
    ownerImage.onload = function () {
      if (this.complete) {
	if (this.width > imageMaxWidth)
	  this.width = imageMaxWidth;
      }
    };
  }
}

function getElementsByClassName (obj, strTagName, strClassName) {
  var arr = (strTagName == '*' && document.all) ?
    document.all : obj.getElementsByTagName (strTagName);
  var ret = [];
  strClassName = strClassName.replace (/\-/g, "\\-");
  var regex = new RegExp ("(^|\\s)" + strClassName + "(\\s|$)");
  var el;
  for (var i = 0; i < arr.length; i++) {
    el = arr[i];
    if (regex.test (el.className))
      ret.push (el);
  }
  return ret;
}

if (document.location.hash.length) {
  var r = document.location.toString ();
  r = r.replace (new RegExp (document.location.hash), '');
  r += '&hash=' + document.location.hash.substr (1);
  document.location.replace (r);
}

window.onload = init;

Return to:

Send suggestions and report system problems to the System administrator.