{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
AJAX Source Viewer
Slideshow of method source in a particular class. Choose a class from the Namespaces, Classes, or Methods menu item above.
Slideshow for Class 'String'
Previous Method:

None


Current Method:

_toFormattedString(useLocale, args)
Next Method:

format(format, args)
Method '_toFormattedString(useLocale, args)'
Method: _toFormattedString(useLocale, args)
Method Full Name:     String$_toFormattedString(useLocale, args)
Class: String
Namespace: Global (MicrosoftAjax.debug.js)
Source File: MicrosoftAjax.debug.js
1   String._toFormattedString = function String$_toFormattedString(useLocale, args) {
2     var result = '';
3     var format = args[0];
4     for (var i=0;;) {
5       var open = format.indexOf('{', i);
6         var close = format.indexOf('}', i);
7       if ((open < 0) && (close < 0)) {
8         result += format.slice(i);
9         break;
10      }
11      if ((close > 0) && ((close < open) || (open < 0))) {
12        if (format.charAt(close + 1) !== '}') {
13        throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
14      }
15      result += format.slice(i, close + 1);
16      i = close + 2;
17      continue;
18    }
19    result += format.slice(i, open);
20    i = open + 1;
21    if (format.charAt(i) === '{') {
22      result += '{';
23        i++;
24        continue;
25      }
26      if (close < 0) throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
27      var brace = format.substring(i, close);
28      var colonIndex = brace.indexOf(':');
29      var argNumber = parseInt((colonIndex < 0)? brace : brace.substring(0, colonIndex), 10) + 1;
30      if (isNaN(argNumber)) throw Error.argument('format', Sys.Res.stringFormatInvalid);
31      var argFormat = (colonIndex < 0)? '' : brace.substring(colonIndex + 1);
32      var arg = args[argNumber];
33      if (typeof(arg) === "undefined" || arg === null) {
34        arg = '';
35      }
36      if (arg.toFormattedString) {
37        result += arg.toFormattedString(argFormat);
38      }
39      else if (useLocale && arg.localeFormat) {
40        result += arg.localeFormat(argFormat);
41      }
42      else if (arg.format) {
43        result += arg.format(argFormat);
44      }
45      else
46      result += arg.toString();
47      i = close + 1;
48    }
49    return result;
50  }
This is the JavaScript source for method _toFormattedString(useLocale, args) from ASP.NET AJAX Library. Full name for this method is String$_toFormattedString(useLocale, args). It belongs to the class String, which is in Global (MicrosoftAjax.debug.js) namespace. This source is in MicrosoftAjax.debug.js file.
Bookmark and Share This
About  Contact  Privacy Policy  Site Map