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