PageSourceSearch

https://heartsbeatback.org/sites/all/themes/aura_sub/js/titleCaps.js

js heartsbeatback.org collected 2026-10-09 01:26:44 UTC 1,403 bytes, 49 lines download raw bytes

1/*
2 * Title Caps
3 * 
4 * Ported to JavaScript By John Resig - http://ejohn.org/ - 21 May 2008
5 * Original by John Gruber - http://daringfireball.net/ - 10 May 2008
6 * License: http://www.opensource.org/licenses/mit-license.php
7 */
8
9(function(){
10	var small = "(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)";
11	var punct = "([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)";
12  
13	this.titleCaps = function(title){
14		var parts = [], split = /[:.;?!] |(?: |^)["Ò]/g, index = 0;
15		
16		while (true) {
17			var m = split.exec(title);
18
19			parts.push( title.substring(index, m ? m.index : title.length)
20				.replace(/\b([A-Za-z][a-z.'Õ]*)\b/g, function(all){
21					return /[A-Za-z]\.[A-Za-z]/.test(all) ? all : upper(all);
22				})
23				.replace(RegExp("\\b" + small + "\\b", "ig"), lower)
24				.replace(RegExp("^" + punct + small + "\\b", "ig"), function(all, punct, word){
25					return punct + upper(word);
26				})
27				.replace(RegExp("\\b" + small + punct + "$", "ig"), upper));
28			
29			index = split.lastIndex;
30			
31			if ( m ) parts.push( m[0] );
32			else break;
33		}
34		
35		return parts.join("").replace(/ V(s?)\. /ig, " v$1. ")
36			.replace(/(['Õ])S\b/ig, "$1s")
37			.replace(/\b(AT&T|Q&A)\b/ig, function(all){
38				return all.toUpperCase();
39			});
40	};
41    
42	function lower(word){
43		return word.toLowerCase();
44	}
45    
46	function upper(word){
47	  return word.substr(0,1).toUpperCase() + word.substr(1);
48	}
49})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.