1 dump('entering util/text.js\n');
3 if (typeof util == 'undefined') var util = {};
6 util.text.EXPORT_OK = [
7 'wrap_on_space', 'preserve_string_in_html',
9 util.text.EXPORT_TAGS = { ':all' : util.text.EXPORT_OK };
11 util.text.wrap_on_space = function( text, length ) {
14 if (String(text).length <= length) return [ text, '' ];
16 var truncated_text = String(text).substr(0,length);
18 var pivot_pos = truncated_text.lastIndexOf(' ');
20 return [ text.substr(0,pivot_pos).replace(/\s*$/,''), String(text).substr(pivot_pos+1) ];
23 alert('FIXME: util.text.wrap_on_space( "' + text + '", ' + length + ")");
24 return [ String(text).substr(0,length), String(text).substr(length) ];
28 util.text.preserve_string_in_html = function( text ) {
29 text = text.replace(/&/g,'&');
30 text = text.replace(/"/g,'"');
31 text = text.replace(/'/g,''');
32 text = text.replace(/ /g,' ');
33 text = text.replace(/</g,'<');
34 text = text.replace(/>/g,'>');
38 util.text.reverse_preserve_string_in_html = function( text ) {
39 text = text.replace(/&/g, '&');
40 text = text.replace(/"/g, '"');
41 text = text.replace(/'/g, "'");
42 text = text.replace(/ /g, ' ');
43 text = text.replace(/</g, '<');
44 text = text.replace(/>/g, '>');
48 dump('exiting util/text.js\n');