source: proiecte/swift/trunk/lib/hoard-371/doc/skin/breadcrumbs-optimized.js @ 176

Last change on this file since 176 was 176, checked in by (none), 14 years ago
  • imported repo from "guagal"
File size: 2.8 KB
Line 
1/*
2* Copyright 2002-2004 The Apache Software Foundation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8*     http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16var PREPREND_CRUMBS=new Array();
17var link1="@skinconfig.trail.link1.name@";
18var link2="@skinconfig.trail.link2.name@";
19var link3="@skinconfig.trail.link3.name@";
20if(!(link1=="")&&!link1.indexOf( "@" ) == 0){
21  PREPREND_CRUMBS.push( new Array( link1, @skinconfig.trail.link1.href@ ) ); }
22if(!(link2=="")&&!link2.indexOf( "@" ) == 0){
23  PREPREND_CRUMBS.push( new Array( link2, @skinconfig.trail.link2.href@ ) ); }
24if(!(link3=="")&&!link3.indexOf( "@" ) == 0){
25  PREPREND_CRUMBS.push( new Array( link3, @skinconfig.trail.link3.href@ ) ); }
26var DISPLAY_SEPARATOR=" > ";
27var DISPLAY_PREPREND=" > ";
28var DISPLAY_POSTPREND=":";
29var CSS_CLASS_CRUMB="breadcrumb";
30var CSS_CLASS_TRAIL="breadcrumbTrail";
31var CSS_CLASS_SEPARATOR="crumbSeparator";
32var FILE_EXTENSIONS=new Array( ".html", ".htm", ".jsp", ".php", ".php3", ".php4" );
33var PATH_SEPARATOR="/";
34
35function sc(s) {
36        var l=s.toLowerCase();
37        return l.substr(0,1).toUpperCase()+l.substr(1);
38}
39function getdirs() {
40        var t=document.location.pathname.split(PATH_SEPARATOR);
41        var lc=t[t.length-1];
42        for(var i=0;i < FILE_EXTENSIONS.length;i++)
43        {
44                if(lc.indexOf(FILE_EXTENSIONS[i]))
45                        return t.slice(1,t.length-1); }
46        return t.slice(1,t.length);
47}
48function getcrumbs( d )
49{
50        var pre = "/";
51        var post = "/";
52        var c = new Array();
53        if( d != null )
54        {
55                for(var i=0;i < d.length;i++) {
56                        pre+=d[i]+postfix;
57                        c.push(new Array(d[i],pre)); }
58        }
59        if(PREPREND_CRUMBS.length > 0 )
60                return PREPREND_CRUMBS.concat( c );
61        return c;
62}
63function gettrail( c )
64{
65        var h=DISPLAY_PREPREND;
66        for(var i=0;i < c.length;i++)
67        {
68                h+='<a href="'+c[i][1]+'" >'+sc(c[i][0])+'</a>';
69                if(i!=(c.length-1))
70                        h+=DISPLAY_SEPARATOR; }
71        return h+DISPLAY_POSTPREND;
72}
73
74function gettrailXHTML( c )
75{
76        var h='<span class="'+CSS_CLASS_TRAIL+'">'+DISPLAY_PREPREND;
77        for(var i=0;i < c.length;i++)
78        {
79                h+='<a href="'+c[i][1]+'" class="'+CSS_CLASS_CRUMB+'">'+sc(c[i][0])+'</a>';
80                if(i!=(c.length-1))
81                        h+='<span class="'+CSS_CLASS_SEPARATOR+'">'+DISPLAY_SEPARATOR+'</span>'; }
82        return h+DISPLAY_POSTPREND+'</span>';
83}
84
85if(document.location.href.toLowerCase().indexOf("http://")==-1)
86        document.write(gettrail(getcrumbs()));
87else
88        document.write(gettrail(getcrumbs(getdirs())));
89
Note: See TracBrowser for help on using the repository browser.