Core Docs | Additional Modules Docs
@Description: This string prototype allow you to easily convert any string to md5
@File: String/prototype/md5.js
@Example:'hello world'.md5(); //return the md5 of the string 'hello world'
@Description: Used to match strings to common patterns
@File: String/prototype/regex.js
@Example:alert('01/22/1977'.match(String.prototype.regex('mm/dd/yyyy'));
@Description: Converts a string of HTML code to a sb.element for dom manipulation
@File: String/prototype/toElement.js
@Param: String parentNodeType The nodetype of the parent element returned if there is not already a single parent element for all elements contained in the html string - see example two - defaults to span if it is not given
@Example://would return div as the element with all its children
sb.dom.HTMLToElement('<div id="joe"><p class="test">hey there</p></div>');
//would return all elements grouped under a span because they have no comment parent
sb.dom.HTMLToElement('<p class="test">hey there</p><p class="test2">hey there2</p>');
@Description: transfers the contents of a string to an external file. Passes the string as POST data with a key name of data. The data is escaped. Make sure the external file referenced in the url property of the params object has permissions set to writeable. There is an example file server side file log.php in the surebert extras folder. It writes to log.txt in the same folder.
@File: String/prototype/toFile.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Param: Object params Parameters defining the data transfer
url - The url of the file to send the string to. Must be a local file because of security in xmlHTTP object
onPass - Function The function that fires if the file the data is sent to returns the number 1. You should set you server side file to print the number 1 if the data arrives.
onFail - Function The optional function that fires anytime the server side file returns a 0.
debug - Boolean If set to 1 then the process is debugged to the sb.consol if sb.developer.js is included in your source.
@Example:var myString = 'Here is a string';
myString.toFile({
url : '../extras/log.php',
onPass : function(){
alert('you');
},
onFail : function(){
alert('bad');
},
debug :1
});
@Description: Fixes common typos in a string
@File: String/prototype/typoFix.js
@Author: Paul Visco
@Version: 1.0
@Example://should alert teh Teh didn't
alert('teh Teh didn;t'.typoFix());
@Description: encodes and decodes UTF8
@File: String/prototype/UTF8Decode.js
@Author: Paul Visco - Adapted/Taken from http://www.webtoolkit.info/
@Version: 1.0 02/09/09
@Return: String
@Example:var newString = myString.UTF8Decode();
@Description: encodes and decodes UTF8
@File: String/prototype/UTF8Encode.js
@Author: Paul Visco - Adapted/Taken from http://www.webtoolkit.info/
@Version: 1.0 02/09/09
@Return: String
@Example:var myString = 'hello world';
var newString = myString.UTF8Encode();
@Description: decodes base64 strings
@File: String/prototype/base64Decode.js
@Author: Paul Visco - Adapted/Taken from http://www.webtoolkit.info/
@Version: 1.0 02/09/09
@Return: String
@Example:var myString = 'aGVsbG8gd29ybGQ=';
var newString = myString.base64Decode();
@Description: encodes strings into base64
@File: String/prototype/base64Encode.js
@Author: Paul Visco - Adapted/Taken from http://www.webtoolkit.info/
@Version: 1.0 02/09/09
@Return: String
@Example:var myString = 'hello world';
var newString = myString.base64Encode();
@Description: Grabs the basename from a url
@File: String/prototype/basename.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The filename part of the original string
@Example:var myString = 'http://www.google.com/logo.gif';
var newString = myString.basename();
//newString = 'logo.gif';
@Description: Converts HTML line breaks "<br />" to new lines "\n"
@File: String/prototype/br2nl.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original string but replaces breaks with actual new lines
@Example:var myString = 'hello<br />there';
var newString = myString.br2nl();
//newString = "hello\nthere";
@Description: Cleans a filename up making it safe for upload, removes spaces, swicthes to camelStyle and strips extraneos punctuation
@File: String/prototype/cleanFileName.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original string but replaces breaks with actual new lines
@Example:var myString = 'hello there,, file . jpg';
var newString = myString.cleanFileName();
//newString = 'helloThereFile.jpg'
@Description: Checks to see if a string is empty or not
@File: String/prototype/escapeHTML.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: Boolean Returns true if the string is empty, false otherwise
@Example:var str = '<p>hello</p>';
var newString = str.escapeHTML();
//newString = '<p>hello</p>'
@Description: Hilites a string within a text block
@File: String/prototype/hilite.js
@Author: Paul Visco
@Version: 1.1 05/29/07
@Param: String needle The text to find
@Param: String className The className to use for hiliting overrides default yellow background style
@Return: String witht he needle underlied and hilited
@Example:var myString = 'There was a dog on earth';
var newString = myString.hilite('dog');
//newString = 'There was a <u style="backgroundColor:yellow;">dog</u> on earth';
@Description: Checks to see if a string is numeric (a float or number)
@File: String/prototype/isNumeric.js
@Author: Paul Visco
@Version: 1.1 11/27/07
@Return: Boolean True if the the string represnts numeric data, false otherwise
@Example:var str = '12';
var answer = str.isNumeric();
//answer = true
@Description: Converts all URLs in a text block into actual html links
@File: String/prototype/linkify.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Param: String target The target to open the links in, defaults to blank
@Return: String The original text withe links converted to HTML
@Example:var myString = 'Here http://www.surebert.com is a great javascript toolkit';
var newString = myString.linkify();
//newString = 'Here <a href="http://www.surebert.com" target="_blank">::link::</a> is a great javascript toolkit';
@Description: Trims all white space off the left side of a string
@File: String/prototype/ltrim.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original text with whitespace removed from the left
@Example:var myString = ' hello';
var newString = myString.ltrim();
//newString = 'hello';
//or
String.prototype.ltrim.call(myString);
@Description: Trims all white space off the right side of a string
@File: String/prototype/rtrim.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original text with whitespace removed from the right
@Example:var myString = 'hello ';
var newString = myString.rtrim();
//newString = 'hello';
@Description: Replaces all new line "\n" with HTML break returns "<br />"
@File: String/prototype/nl2br.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original text with lines returns converted to HTML line breaks
@Example:var myString = "hello\nworld";
var newString = myString.nl2br();
//newString = 'hello<br />world';
@Description: Pads all numbers under 9 with a zero on the left
@File: String/prototype/numpad.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original number padded to left with zero
@Example:var myString = 9;
var newString = myString.numpad();
//newString = '09'
@Description: Takes an rgb string and converts it to hex color rgb(255,255,255) -> #FFFFFF
@File: String/prototype/rgb2hex.js
@Author: Paul Visco
@Version: 1.01 12/20/07
@Param: Number asArray If set to 1 then it returns the values as an array
@Return: Array A hex color array ['FF', 'FF', 'FF']
@Example:var myString = 'rgb(255,255,255)';
var newString = myString.rgb2hex();
//newString = '#FFFFFF'
@Description: Removes all HTML tags from a string
@File: String/prototype/stripHTML.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original string without any HTML markup
@Example:var myString = 'hello <p>world</p> on earth';
var newString = myString.stripHTML();
//newString = 'hello world on earth'
@Description: Removes all whitespace from a string
@File: String/prototype/stripWhitespace.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original string without any whitespace
@Example:var myString = 'hello world on earth';
var newString = myString.stripWhitespace();
//newString = 'helloworldonearth'
@Description: Returns true if the substring is found in the string
@File: String/prototype/strstr.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Param: String needle The substring to search for within the string
@Return: Boolean True if the string is found and false if it isn't
@Example:var myString = 'hello world on earth';
var answer = myString.strstr('world');
//answer = true;
@Description: Returns the numbers of times a substring is found in a string
@File: String/prototype/substrCount.js
@Author: Paul Visco
@Version: 1.1 11/19/07 09/18/08
@Param: String needle The substring to search for within the string
@Return: Number The number of times the substring is found in the original string
@Example:var myString = 'hello world on earth';
var answer = myString.substrCount('world');
//answer = 1;
@Description: Mimics php substrReplace replacing part of the string with another string from an index to a length
@File: String/prototype/substrReplace.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Param: String replaceWith The string to replace with
@Param: Integer start The index to start at
@Param: Integer start The length to replace
@Return: String The string with the replacement
@Example:var myString = 'hello world';
var answer = myString.substrReplace('girl', 0, 4);
answer = 'girlo world';
@Description: Converts a numeric string into an integer or float
@File: String/prototype/toNumber.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: Number If the original value is an interger, an integer value is returned
@Example:var myString = '12';
var num = myString.toNumber() +2;
//num = 14 //without running toNumber it would return '122'
var myString = '12.4';
var num = myString.toNumber() +2;
//num = 14.4 //without running toNumber it would return '12.42'
@Description: trims whitespace from both left and right side of a string
@File: String/prototype/trim.js
@Return: String The original string with whitespace removed from left and right side
@Example:var str = ' hello world ';
var newString = str.trim();
//newString = 'hello world'
@Description: Converts all first letters of words in a string to uppercase. Great for titles.
@File: String/prototype/ucwords.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: String The original string with all first letters of words converted to uppercase.
@Example:var myString = 'hello world';
var newString = myString.ucwords();
//newString = 'Hello World'
@Description: Converts a string into a unqiue, md5 one way hash
@File: String/prototype/md5.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Return: The md5'd string
@Example:var myString = 'hello world';
var md5String = String.prototype.md5.hex.call(myString);