Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript breadcrumbs 1

Status
Not open for further replies.

DarrenPower

IS-IT--Management
Nov 1, 2001
56
GB
Hi,

I have a script which takes the file path and builds a breadcrumb, capitalising the first letter of each word in the path. I'm actually looking to capitalise the first letter of the first word in each directory/filename, rather than every word. Could anyone shed any light on how I may be able to go about this at all please?

i.e.

Current - /about-us/what-we-do becomes About Us > What We Do

Desired - /about-us/what-we-do becomes About us > What we do
 
Hi

I would add a new option for that :
Code:
[COLOR=gray silver]   7 [/color][b]var[/b] changeCaps [teal]=[/teal] [purple][highlight]4[/highlight][/purple][teal];[/teal]                             [gray]// 0 = no change, 1 = Initial Caps, 2 = All Upper, 3 = All Lower[highlight], 4 = Only First Caps[/highlight][/gray]
Code:
[COLOR=gray silver] 111 [/color][gray]// determine changes in capitalization...[/gray]
[COLOR=gray silver] 112 [/color][b]function[/b] [COLOR=darkgoldenrod]MPBCFixCaps[/color][teal]([/teal]thisString[teal],[/teal] changeCaps[teal])[/teal] [teal]{[/teal]
[COLOR=gray silver] 113 [/color][b]if[/b] [teal]([/teal]changeCaps [teal]==[/teal] [purple]1[/purple][teal])[/teal] thisString [teal]=[/teal] [COLOR=darkgoldenrod]MPBCUCWords[/color][teal]([/teal]thisString[teal]);[/teal]
[COLOR=gray silver] 114 [/color]        [b]else[/b] [b]if[/b] [teal]([/teal]changeCaps [teal]==[/teal] [purple]2[/purple][teal])[/teal] thisString [teal]=[/teal] thisString[teal].[/teal][COLOR=darkgoldenrod]toUpperCase[/color][teal]();[/teal]
[COLOR=gray silver] 115 [/color]        [b]else[/b] [b]if[/b] [teal]([/teal]changeCaps [teal]==[/teal] [purple]3[/purple][teal])[/teal] thisString [teal]=[/teal] thisString[teal].[/teal][COLOR=darkgoldenrod]toLowerCase[/color][teal]();[/teal]
[COLOR=gray silver] 116 [/color]        [highlight][b]else[/b] [b]if[/b] [teal]([/teal]changeCaps [teal]==[/teal] [purple]4[/purple][teal])[/teal] thisString [teal]=[/teal] thisString[teal].[/teal][COLOR=darkgoldenrod]substr[/color][teal]([/teal][purple]0[/purple][teal],[/teal][purple]1[/purple][teal]).[/teal][COLOR=darkgoldenrod]toUpperCase[/color][teal]()+[/teal]thisString[teal].[/teal][COLOR=darkgoldenrod]substr[/color][teal]([/teal][purple]1[/purple][teal]);[/teal][/highlight]
[COLOR=gray silver] 117 [/color]
[COLOR=gray silver] 118 [/color][b]return[/b] thisString[teal];[/teal]
[COLOR=gray silver] 119 [/color][teal]}[/teal]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top