sc-docs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +48 -0
  5. data/LICENSE +21 -0
  6. data/README.md +59 -0
  7. data/bin/sc-docs +5 -0
  8. data/lib/sc_docs.rb +3 -0
  9. data/lib/sc_docs/cli.rb +54 -0
  10. data/lib/sc_docs/docs/Buildfile +8 -0
  11. data/lib/sc_docs/docs/README +8 -0
  12. data/lib/sc_docs/docs/apps/docs/Buildfile +15 -0
  13. data/lib/sc_docs/docs/apps/docs/controllers/classes.js +27 -0
  14. data/lib/sc_docs/docs/apps/docs/controllers/search_controller.js +62 -0
  15. data/lib/sc_docs/docs/apps/docs/controllers/selected_class.js +143 -0
  16. data/lib/sc_docs/docs/apps/docs/core.js +148 -0
  17. data/lib/sc_docs/docs/apps/docs/main.js +41 -0
  18. data/lib/sc_docs/docs/apps/docs/models/class.js +63 -0
  19. data/lib/sc_docs/docs/apps/docs/models/entity.js +29 -0
  20. data/lib/sc_docs/docs/apps/docs/models/method.js +79 -0
  21. data/lib/sc_docs/docs/apps/docs/models/property.js +48 -0
  22. data/lib/sc_docs/docs/apps/docs/resources/images/method_icon.png +0 -0
  23. data/lib/sc_docs/docs/apps/docs/resources/images/property_icon.png +0 -0
  24. data/lib/sc_docs/docs/apps/docs/resources/loading.rhtml +9 -0
  25. data/lib/sc_docs/docs/apps/docs/resources/main_page.css +156 -0
  26. data/lib/sc_docs/docs/apps/docs/resources/main_page.js +91 -0
  27. data/lib/sc_docs/docs/apps/docs/resources/templates/details.handlebars +81 -0
  28. data/lib/sc_docs/docs/apps/docs/resources/templates/extensions/signature.js +0 -0
  29. data/lib/sc_docs/docs/apps/docs/system/jquery_ui.js +62 -0
  30. data/lib/sc_docs/docs/apps/docs/system/showdown.js +1297 -0
  31. data/lib/sc_docs/docs/apps/docs/theme.js +29 -0
  32. data/lib/sc_docs/docs/apps/docs/views/detail_list.js +24 -0
  33. data/lib/sc_docs/docs/apps/docs/views/master_list.js +35 -0
  34. data/lib/sc_docs/docs/apps/docs/views/methods_collection.js +80 -0
  35. data/lib/sc_docs/docs/apps/docs/views/properties_collection.js +9 -0
  36. data/lib/sc_docs/generator.rb +145 -0
  37. data/lib/sc_docs/server.rb +21 -0
  38. data/lib/sc_docs/templates/docs.sproutcore.com/allclasses.tmpl +31 -0
  39. data/lib/sc_docs/templates/docs.sproutcore.com/allfiles.tmpl +66 -0
  40. data/lib/sc_docs/templates/docs.sproutcore.com/class.tmpl +437 -0
  41. data/lib/sc_docs/templates/docs.sproutcore.com/index.tmpl +52 -0
  42. data/lib/sc_docs/templates/docs.sproutcore.com/output/css/api.css +619 -0
  43. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.jpg +0 -0
  44. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.png +0 -0
  45. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/clearinput.png +0 -0
  46. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/cross.png +0 -0
  47. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/ddiagonal.png +0 -0
  48. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/diagonal.png +0 -0
  49. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.jpg +0 -0
  50. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.png +0 -0
  51. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/glow.png +0 -0
  52. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/logo.png +0 -0
  53. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/pixels.png +0 -0
  54. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/search.png +0 -0
  55. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/api.js +134 -0
  56. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/jquery-bbq.js +18 -0
  57. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/jquery-1.5.1.min.js +16 -0
  58. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/modernizr-1.7.min.js +2 -0
  59. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/plugin.js +1 -0
  60. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/script.js +5 -0
  61. data/lib/sc_docs/templates/docs.sproutcore.com/publish.js +200 -0
  62. data/lib/sc_docs/templates/docs.sproutcore.com/static/default.css +300 -0
  63. data/lib/sc_docs/templates/docs.sproutcore.com/static/header.html +19 -0
  64. data/lib/sc_docs/templates/docs.sproutcore.com/static/index.html +19 -0
  65. data/lib/sc_docs/templates/docs.sproutcore.com/symbol.tmpl +35 -0
  66. data/lib/sc_docs/templates/sc_fixture/publish.js +632 -0
  67. data/lib/sc_docs/version.rb +4 -0
  68. data/sc_docs.gemspec +27 -0
  69. data/vendor/jsdoc/README.txt +109 -0
  70. data/vendor/jsdoc/app/frame.js +33 -0
  71. data/vendor/jsdoc/app/frame/Chain.js +102 -0
  72. data/vendor/jsdoc/app/frame/Dumper.js +144 -0
  73. data/vendor/jsdoc/app/frame/Hash.js +84 -0
  74. data/vendor/jsdoc/app/frame/Link.js +173 -0
  75. data/vendor/jsdoc/app/frame/Namespace.js +10 -0
  76. data/vendor/jsdoc/app/frame/Opt.js +134 -0
  77. data/vendor/jsdoc/app/frame/Reflection.js +26 -0
  78. data/vendor/jsdoc/app/frame/String.js +93 -0
  79. data/vendor/jsdoc/app/frame/Testrun.js +129 -0
  80. data/vendor/jsdoc/app/handlers/FOODOC.js +26 -0
  81. data/vendor/jsdoc/app/handlers/XMLDOC.js +26 -0
  82. data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  83. data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  84. data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  85. data/vendor/jsdoc/app/lib/JSDOC.js +106 -0
  86. data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +204 -0
  87. data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  88. data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +140 -0
  89. data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +109 -0
  90. data/vendor/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  91. data/vendor/jsdoc/app/lib/JSDOC/Parser.js +146 -0
  92. data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  93. data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +644 -0
  94. data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +243 -0
  95. data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  96. data/vendor/jsdoc/app/lib/JSDOC/Token.js +18 -0
  97. data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +332 -0
  98. data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  99. data/vendor/jsdoc/app/lib/JSDOC/Util.js +32 -0
  100. data/vendor/jsdoc/app/lib/JSDOC/Walker.js +507 -0
  101. data/vendor/jsdoc/app/main.js +111 -0
  102. data/vendor/jsdoc/app/plugins/commentSrcJson.js +20 -0
  103. data/vendor/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  104. data/vendor/jsdoc/app/plugins/functionCall.js +10 -0
  105. data/vendor/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  106. data/vendor/jsdoc/app/plugins/symbolLink.js +10 -0
  107. data/vendor/jsdoc/app/plugins/tagParamConfig.js +31 -0
  108. data/vendor/jsdoc/app/plugins/tagSynonyms.js +43 -0
  109. data/vendor/jsdoc/app/run.js +297 -0
  110. data/vendor/jsdoc/app/t/TestDoc.js +144 -0
  111. data/vendor/jsdoc/app/t/runner.js +13 -0
  112. data/vendor/jsdoc/app/test.js +342 -0
  113. data/vendor/jsdoc/app/test/addon.js +24 -0
  114. data/vendor/jsdoc/app/test/anon_inner.js +14 -0
  115. data/vendor/jsdoc/app/test/augments.js +31 -0
  116. data/vendor/jsdoc/app/test/augments2.js +26 -0
  117. data/vendor/jsdoc/app/test/borrows.js +46 -0
  118. data/vendor/jsdoc/app/test/borrows2.js +23 -0
  119. data/vendor/jsdoc/app/test/config.js +22 -0
  120. data/vendor/jsdoc/app/test/constructs.js +18 -0
  121. data/vendor/jsdoc/app/test/encoding.js +10 -0
  122. data/vendor/jsdoc/app/test/encoding_other.js +12 -0
  123. data/vendor/jsdoc/app/test/event.js +54 -0
  124. data/vendor/jsdoc/app/test/exports.js +14 -0
  125. data/vendor/jsdoc/app/test/functions_anon.js +39 -0
  126. data/vendor/jsdoc/app/test/functions_nested.js +33 -0
  127. data/vendor/jsdoc/app/test/global.js +13 -0
  128. data/vendor/jsdoc/app/test/globals.js +25 -0
  129. data/vendor/jsdoc/app/test/ignore.js +10 -0
  130. data/vendor/jsdoc/app/test/inner.js +16 -0
  131. data/vendor/jsdoc/app/test/jsdoc_test.js +477 -0
  132. data/vendor/jsdoc/app/test/lend.js +33 -0
  133. data/vendor/jsdoc/app/test/memberof.js +19 -0
  134. data/vendor/jsdoc/app/test/memberof2.js +38 -0
  135. data/vendor/jsdoc/app/test/memberof3.js +33 -0
  136. data/vendor/jsdoc/app/test/memberof_constructor.js +17 -0
  137. data/vendor/jsdoc/app/test/module.js +17 -0
  138. data/vendor/jsdoc/app/test/multi_methods.js +25 -0
  139. data/vendor/jsdoc/app/test/name.js +19 -0
  140. data/vendor/jsdoc/app/test/namespace_nested.js +23 -0
  141. data/vendor/jsdoc/app/test/nocode.js +13 -0
  142. data/vendor/jsdoc/app/test/oblit_anon.js +20 -0
  143. data/vendor/jsdoc/app/test/overview.js +20 -0
  144. data/vendor/jsdoc/app/test/param_inline.js +37 -0
  145. data/vendor/jsdoc/app/test/params_optional.js +8 -0
  146. data/vendor/jsdoc/app/test/prototype.js +17 -0
  147. data/vendor/jsdoc/app/test/prototype_nested.js +9 -0
  148. data/vendor/jsdoc/app/test/prototype_oblit.js +13 -0
  149. data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +24 -0
  150. data/vendor/jsdoc/app/test/public.js +10 -0
  151. data/vendor/jsdoc/app/test/scripts/code.js +5 -0
  152. data/vendor/jsdoc/app/test/scripts/notcode.txt +5 -0
  153. data/vendor/jsdoc/app/test/shared.js +42 -0
  154. data/vendor/jsdoc/app/test/shared2.js +2 -0
  155. data/vendor/jsdoc/app/test/shortcuts.js +22 -0
  156. data/vendor/jsdoc/app/test/static_this.js +13 -0
  157. data/vendor/jsdoc/app/test/synonyms.js +31 -0
  158. data/vendor/jsdoc/app/test/tosource.js +23 -0
  159. data/vendor/jsdoc/app/test/variable_redefine.js +14 -0
  160. data/vendor/jsdoc/changes.txt +127 -0
  161. data/vendor/jsdoc/conf/sample.conf +31 -0
  162. metadata +240 -0
@@ -0,0 +1,19 @@
1
+ <header role="banner">
2
+ <div class="container">
3
+ <h1 id="logo">
4
+ <a href="http://www.sproutcore.com"><img src="/img/logo.png" alt="SproutCore" /></a>
5
+ </h1>
6
+
7
+ <nav role="navigation">
8
+ <ul>
9
+ <li><a href="http://www.sproutcore.com/about/">About</a></li>
10
+ <li><a href="http://guides.sproutcore.com">Guides</a></li>
11
+ <li class="active"><a href="/" >Docs</a></li>
12
+ <li><a href="http://www.sproutcore.com/community/">Community</a></li>
13
+ <li><a href="http://blog.sproutcore.com">Blog</a></li>
14
+ </ul>
15
+ </nav>
16
+ </div>
17
+ </header>
18
+
19
+
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <title>Generated Javascript Documentation</title>
7
+ </head>
8
+ <frameset cols="20%,80%">
9
+ <frame src="allclasses-frame.html" name="packageFrame" />
10
+ <frame src="splash.html" name="classFrame" />
11
+ <noframes>
12
+ <body>
13
+ <p>
14
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
15
+ </p>
16
+ </body>
17
+ </noframes>
18
+ </frameset>
19
+ </html>
@@ -0,0 +1,35 @@
1
+ <symbol alias="{+data.alias+}">
2
+ <name>{+data.name+}</name>
3
+ <memberOf>{+data.memberOf+}</memberOf>
4
+ <isStatic>{+data.isStatic+}</isStatic>
5
+ <isa>{+data.isa+}</isa>
6
+ <desc>{+data.desc+}</desc>
7
+ <classDesc>{+data.classDesc+}</classDesc>
8
+
9
+ <methods><for each="method" in="data.methods">
10
+ <method>
11
+ <name>{+method.name+}</name>
12
+ <memberOf>{+method.memberOf+}</memberOf>
13
+ <isStatic>{+method.isStatic+}</isStatic>
14
+ <desc>{+method.desc+}</desc>
15
+ <params><for each="param" in="method.params">
16
+ <param>
17
+ <type>{+param.type+}</type>
18
+ <name>{+param.name+}</name>
19
+ <desc>{+param.desc+}</desc>
20
+ <defaultValue>{+param.defaultValue+}</defaultValue>
21
+ </param></for>
22
+ </params>
23
+ </method></for>
24
+ </methods>
25
+
26
+ <properties><for each="property" in="data.properties">
27
+ <property>
28
+ <name>{+property.name+}</name>
29
+ <memberOf>{+property.memberOf+}</memberOf>
30
+ <isStatic>{+property.isStatic+}</isStatic>
31
+ <desc>{+property.desc+}</desc>
32
+ <type>{+property.type+}</type>
33
+ </property></for>
34
+ </properties>
35
+ </symbol>
@@ -0,0 +1,632 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+
7
+ /** Called automatically by JsDoc Toolkit. */
8
+ function publish(symbolSet) {
9
+
10
+ var output = "";
11
+
12
+ // some ustility filters
13
+ function hasNoParent($) {return ($.memberOf === "");}
14
+ function isaFile($) {return ($.is("FILE"));}
15
+ function isaClass($) {return ($.is("CONSTRUCTOR") || $.isNamespace);}
16
+
17
+ // get an array version of the symbolset, useful for filtering
18
+ var symbols = symbolSet.toArray();
19
+
20
+ // get a list of all the classes in the symbolset
21
+ var classes = symbols.filter(isaClass).sort(makeSortby("alias"));
22
+
23
+ var processedSymbolSet = [];
24
+
25
+ // create each of the class pages
26
+ for (var i = 0, l = classes.length; i < l; i++) {
27
+ var symbol = classes[i];
28
+
29
+ symbol.events = symbol.getEvents(); // 1 order matters
30
+ symbol.methods = symbol.getMethods(); // 2
31
+
32
+ processIndividualClass(processedSymbolSet,symbol);
33
+ }
34
+
35
+ var prefix = "// ==========================================================================\n\
36
+ // Project: Docs.Class Fixtures\n\
37
+ // Copyright: ©2011 My Company, Inc.\n\
38
+ // ==========================================================================\n\
39
+ /*globals Docs */\n\
40
+ \n\
41
+ sc_require('models/class');\n\
42
+ \n\
43
+ "+JSDOC.opt.l+".FIXTURES = ";
44
+ var output = JSON.stringify(processedSymbolSet,undefined,' ');
45
+
46
+ var suffix = ";";
47
+
48
+ var outDir = JSDOC.opt.d || SYS.pwd+"../../docs/apps/docs/fixtures/";
49
+ IO.mkPath(outDir);
50
+ print("IO.saveFile("+outDir+",'"+JSDOC.opt.f+"',output)");
51
+ IO.saveFile(outDir,JSDOC.opt.f,prefix+output+suffix);
52
+
53
+ }
54
+
55
+ function processIndividualClass(processedSymbolSet,symbol) {
56
+
57
+ // The actual object is full of unnecessary crap, filter it out
58
+
59
+ var classObj = {
60
+ guid: symbol.id,
61
+ name: symbol.name,
62
+ displayName: symbol.alias,
63
+ objectType: 'symbol',
64
+ filePath: symbol.srcFile,
65
+
66
+ isNamespace: symbol.isNamespace,
67
+ isPrivate: symbol.isPrivate,
68
+ isStatic: symbol.isStatic,
69
+
70
+ author: symbol.author,
71
+ see: symbol.see,
72
+ since: symbol.since,
73
+ version: symbol.version,
74
+ deprecated: symbol.deprecated,
75
+ augments: symbol.augments,
76
+
77
+ overview: symbol.classDesc,
78
+ methods: [],
79
+ properties: []
80
+ };
81
+
82
+ var methods = symbol.methods;
83
+ for (var i = 0, l = methods.length; i<l; i++) {
84
+
85
+ var method = methods[i];
86
+
87
+ if (method.memberOf !== classObj.name && method.memberOf !== classObj.displayName) {
88
+ //print("Skipping "+method.name+", since it's a member of "+method.memberOf+", not "+classObj.name+" or "+classObj.displayName);
89
+ continue;
90
+ }
91
+
92
+ classObj.methods.push({
93
+ name: method.name,
94
+ displayName: method.alias,
95
+ objectType: 'method',
96
+
97
+ isPrivate: method.isPrivate,
98
+ isStatic: method.isStatic,
99
+
100
+ author: method.author,
101
+ see: method.see,
102
+ since: method.since,
103
+ version: method.version,
104
+ deprecated: method.deprecated,
105
+ augments: [],
106
+
107
+ overview: method.desc,
108
+ exceptions: method.exceptions,
109
+ returns: method.returns,
110
+ params: method.params
111
+
112
+ });
113
+ }
114
+
115
+ var properties = symbol.properties;
116
+ for (var j = 0, len = properties.length; j<len; j++) {
117
+
118
+ var property = properties[j];
119
+
120
+ if (property.memberOf !== classObj.name && property.memberOf !== classObj.displayName) {
121
+ //print("Skipping "+property.name+", since it's a property of "+method.memberOf+", not "+classObj.name+" or "+classObj.displayName);
122
+ continue;
123
+ }
124
+
125
+ classObj.properties.push({
126
+ name: property._name,
127
+ displayName: property.alias,
128
+ objectType: 'property',
129
+
130
+ propertyType: property.type,
131
+ author: property.author,
132
+ see: property.see,
133
+ since: property.since,
134
+ version: property.version,
135
+ deprecated: property.deprecated,
136
+
137
+ memberOf: property.memberOf,
138
+ overview: property.desc,
139
+ defaultValue: property.defaultValue,
140
+ isConstant: property.isConstant,
141
+ isPrivate: property.isPrivate
142
+
143
+ });
144
+ }
145
+
146
+ processedSymbolSet.push(classObj);
147
+ }
148
+
149
+ function explain(class) {
150
+
151
+ print("\n\n==============================\n");
152
+ for (var item in class) {
153
+ print("class["+item+"] = "+class[item]);
154
+ }
155
+ print("\n==============================\n\n");
156
+
157
+ }
158
+
159
+ /** Just the first sentence (up to a full stop). Should not break on dotted variable names. */
160
+ function summarize(desc) {
161
+ if (typeof desc != "undefined")
162
+ return desc.match(/([\w\W]+?\.)[^a-z0-9_$]/i)? RegExp.$1 : desc;
163
+ }
164
+
165
+ /** Make a symbol sorter by some attribute. */
166
+ function makeSortby(attribute) {
167
+ return function(a, b) {
168
+ if (a[attribute] != undefined && b[attribute] != undefined) {
169
+ a = a[attribute].toLowerCase();
170
+ b = b[attribute].toLowerCase();
171
+ if (a < b) return -1;
172
+ if (a > b) return 1;
173
+ return 0;
174
+ }
175
+ }
176
+ }
177
+
178
+ /** Pull in the contents of an external file at the given path. */
179
+ function include(path) {
180
+ var path = publish.conf.templatesDir+path;
181
+ return IO.readFile(path);
182
+ }
183
+
184
+ /** Turn a raw source file into a code-hilited page in the docs. */
185
+ function makeSrcFile(path, srcDir, name) {
186
+ if (JSDOC.opt.s) return;
187
+
188
+ if (!name) {
189
+ name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_");
190
+ name = name.replace(/\:/g, "_");
191
+ }
192
+
193
+ var src = {path: path, name:name, charset: IO.encoding, hilited: ""};
194
+
195
+ if (defined(JSDOC.PluginManager)) {
196
+ JSDOC.PluginManager.run("onPublishSrc", src);
197
+ }
198
+
199
+ if (src.hilited) {
200
+ IO.saveFile(srcDir, name+publish.conf.ext, src.hilited);
201
+ }
202
+ }
203
+
204
+ /** Build output for displaying function parameters. */
205
+ function makeSignature(params) {
206
+ if (!params) return "()";
207
+ var signature = "("
208
+ +
209
+ params.filter(
210
+ function($) {
211
+ return $.name.indexOf(".") == -1; // don't show config params in signature
212
+ }
213
+ ).map(
214
+ function($) {
215
+ return $.name;
216
+ }
217
+ ).join(", ")
218
+ +
219
+ ")";
220
+ return signature;
221
+ }
222
+
223
+ /** Find symbol {@link ...} strings in text and turn into html links */
224
+ function resolveLinks(str, from) {
225
+ str = str.replace(/\{@link ([^} ]+) ?\}/gi,
226
+ function(match, symbolName) {
227
+ return new Link().toSymbol(symbolName);
228
+ }
229
+ );
230
+
231
+ return str;
232
+ }
233
+ /*
234
+ http://www.JSON.org/json2.js
235
+ 2011-02-23
236
+
237
+ Public Domain.
238
+
239
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
240
+
241
+ See http://www.JSON.org/js.html
242
+
243
+
244
+ This code should be minified before deployment.
245
+ See http://javascript.crockford.com/jsmin.html
246
+
247
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
248
+ NOT CONTROL.
249
+
250
+
251
+ This file creates a global JSON object containing two methods: stringify
252
+ and parse.
253
+
254
+ JSON.stringify(value, replacer, space)
255
+ value any JavaScript value, usually an object or array.
256
+
257
+ replacer an optional parameter that determines how object
258
+ values are stringified for objects. It can be a
259
+ function or an array of strings.
260
+
261
+ space an optional parameter that specifies the indentation
262
+ of nested structures. If it is omitted, the text will
263
+ be packed without extra whitespace. If it is a number,
264
+ it will specify the number of spaces to indent at each
265
+ level. If it is a string (such as '\t' or '&nbsp;'),
266
+ it contains the characters used to indent at each level.
267
+
268
+ This method produces a JSON text from a JavaScript value.
269
+
270
+ When an object value is found, if the object contains a toJSON
271
+ method, its toJSON method will be called and the result will be
272
+ stringified. A toJSON method does not serialize: it returns the
273
+ value represented by the name/value pair that should be serialized,
274
+ or undefined if nothing should be serialized. The toJSON method
275
+ will be passed the key associated with the value, and this will be
276
+ bound to the value
277
+
278
+ For example, this would serialize Dates as ISO strings.
279
+
280
+ Date.prototype.toJSON = function (key) {
281
+ function f(n) {
282
+ // Format integers to have at least two digits.
283
+ return n < 10 ? '0' + n : n;
284
+ }
285
+
286
+ return this.getUTCFullYear() + '-' +
287
+ f(this.getUTCMonth() + 1) + '-' +
288
+ f(this.getUTCDate()) + 'T' +
289
+ f(this.getUTCHours()) + ':' +
290
+ f(this.getUTCMinutes()) + ':' +
291
+ f(this.getUTCSeconds()) + 'Z';
292
+ };
293
+
294
+ You can provide an optional replacer method. It will be passed the
295
+ key and value of each member, with this bound to the containing
296
+ object. The value that is returned from your method will be
297
+ serialized. If your method returns undefined, then the member will
298
+ be excluded from the serialization.
299
+
300
+ If the replacer parameter is an array of strings, then it will be
301
+ used to select the members to be serialized. It filters the results
302
+ such that only members with keys listed in the replacer array are
303
+ stringified.
304
+
305
+ Values that do not have JSON representations, such as undefined or
306
+ functions, will not be serialized. Such values in objects will be
307
+ dropped; in arrays they will be replaced with null. You can use
308
+ a replacer function to replace those with JSON values.
309
+ JSON.stringify(undefined) returns undefined.
310
+
311
+ The optional space parameter produces a stringification of the
312
+ value that is filled with line breaks and indentation to make it
313
+ easier to read.
314
+
315
+ If the space parameter is a non-empty string, then that string will
316
+ be used for indentation. If the space parameter is a number, then
317
+ the indentation will be that many spaces.
318
+
319
+ Example:
320
+
321
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
322
+ // text is '["e",{"pluribus":"unum"}]'
323
+
324
+
325
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
326
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
327
+
328
+ text = JSON.stringify([new Date()], function (key, value) {
329
+ return this[key] instanceof Date ?
330
+ 'Date(' + this[key] + ')' : value;
331
+ });
332
+ // text is '["Date(---current time---)"]'
333
+
334
+
335
+ JSON.parse(text, reviver)
336
+ This method parses a JSON text to produce an object or array.
337
+ It can throw a SyntaxError exception.
338
+
339
+ The optional reviver parameter is a function that can filter and
340
+ transform the results. It receives each of the keys and values,
341
+ and its return value is used instead of the original value.
342
+ If it returns what it received, then the structure is not modified.
343
+ If it returns undefined then the member is deleted.
344
+
345
+ Example:
346
+
347
+ // Parse the text. Values that look like ISO date strings will
348
+ // be converted to Date objects.
349
+
350
+ myData = JSON.parse(text, function (key, value) {
351
+ var a;
352
+ if (typeof value === 'string') {
353
+ a =
354
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
355
+ if (a) {
356
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
357
+ +a[5], +a[6]));
358
+ }
359
+ }
360
+ return value;
361
+ });
362
+
363
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
364
+ var d;
365
+ if (typeof value === 'string' &&
366
+ value.slice(0, 5) === 'Date(' &&
367
+ value.slice(-1) === ')') {
368
+ d = new Date(value.slice(5, -1));
369
+ if (d) {
370
+ return d;
371
+ }
372
+ }
373
+ return value;
374
+ });
375
+
376
+
377
+ This is a reference implementation. You are free to copy, modify, or
378
+ redistribute.
379
+ */
380
+
381
+ /*jslint evil: true, strict: false, regexp: false */
382
+
383
+ /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
384
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
385
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
386
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
387
+ test, toJSON, toString, valueOf
388
+ */
389
+
390
+
391
+ // Create a JSON object only if one does not already exist. We create the
392
+ // methods in a closure to avoid creating global variables.
393
+
394
+ var JSON;
395
+ if (!JSON) {
396
+ JSON = {};
397
+ }
398
+
399
+ (function () {
400
+ "use strict";
401
+
402
+ function f(n) {
403
+ // Format integers to have at least two digits.
404
+ return n < 10 ? '0' + n : n;
405
+ }
406
+
407
+ if (typeof Date.prototype.toJSON !== 'function') {
408
+
409
+ Date.prototype.toJSON = function (key) {
410
+
411
+ return isFinite(this.valueOf()) ?
412
+ this.getUTCFullYear() + '-' +
413
+ f(this.getUTCMonth() + 1) + '-' +
414
+ f(this.getUTCDate()) + 'T' +
415
+ f(this.getUTCHours()) + ':' +
416
+ f(this.getUTCMinutes()) + ':' +
417
+ f(this.getUTCSeconds()) + 'Z' : null;
418
+ };
419
+
420
+ String.prototype.toJSON =
421
+ Number.prototype.toJSON =
422
+ Boolean.prototype.toJSON = function (key) {
423
+ return this.valueOf();
424
+ };
425
+ }
426
+
427
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
428
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
429
+ gap,
430
+ indent,
431
+ meta = { // table of character substitutions
432
+ '\b': '\\b',
433
+ '\t': '\\t',
434
+ '\n': '\\n',
435
+ '\f': '\\f',
436
+ '\r': '\\r',
437
+ '"' : '\\"',
438
+ '\\': '\\\\'
439
+ },
440
+ rep;
441
+
442
+
443
+ function quote(string) {
444
+
445
+ // If the string contains no control characters, no quote characters, and no
446
+ // backslash characters, then we can safely slap some quotes around it.
447
+ // Otherwise we must also replace the offending characters with safe escape
448
+ // sequences.
449
+
450
+ escapable.lastIndex = 0;
451
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
452
+ var c = meta[a];
453
+ return typeof c === 'string' ? c :
454
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
455
+ }) + '"' : '"' + string + '"';
456
+ }
457
+
458
+
459
+ function str(key, holder) {
460
+
461
+ // Produce a string from holder[key].
462
+
463
+ var i, // The loop counter.
464
+ k, // The member key.
465
+ v, // The member value.
466
+ length,
467
+ mind = gap,
468
+ partial,
469
+ value = holder[key];
470
+
471
+ // If the value has a toJSON method, call it to obtain a replacement value.
472
+
473
+ if (value && typeof value === 'object' &&
474
+ typeof value.toJSON === 'function') {
475
+ value = value.toJSON(key);
476
+ }
477
+
478
+ // If we were called with a replacer function, then call the replacer to
479
+ // obtain a replacement value.
480
+
481
+ if (typeof rep === 'function') {
482
+ value = rep.call(holder, key, value);
483
+ }
484
+
485
+ // What happens next depends on the value's type.
486
+
487
+ switch (typeof value) {
488
+ case 'string':
489
+ return quote(value);
490
+
491
+ case 'number':
492
+
493
+ // JSON numbers must be finite. Encode non-finite numbers as null.
494
+
495
+ return isFinite(value) ? String(value) : 'null';
496
+
497
+ case 'boolean':
498
+ case 'null':
499
+
500
+ // If the value is a boolean or null, convert it to a string. Note:
501
+ // typeof null does not produce 'null'. The case is included here in
502
+ // the remote chance that this gets fixed someday.
503
+
504
+ return String(value);
505
+
506
+ // If the type is 'object', we might be dealing with an object or an array or
507
+ // null.
508
+
509
+ case 'object':
510
+
511
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
512
+ // so watch out for that case.
513
+
514
+ if (!value) {
515
+ return 'null';
516
+ }
517
+
518
+ // Make an array to hold the partial results of stringifying this object value.
519
+
520
+ gap += indent;
521
+ partial = [];
522
+
523
+ // Is the value an array?
524
+
525
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
526
+
527
+ // The value is an array. Stringify every element. Use null as a placeholder
528
+ // for non-JSON values.
529
+
530
+ length = value.length;
531
+ for (i = 0; i < length; i += 1) {
532
+ partial[i] = str(i, value) || 'null';
533
+ }
534
+
535
+ // Join all of the elements together, separated with commas, and wrap them in
536
+ // brackets.
537
+
538
+ v = partial.length === 0 ? '[]' : gap ?
539
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
540
+ '[' + partial.join(',') + ']';
541
+ gap = mind;
542
+ return v;
543
+ }
544
+
545
+ // If the replacer is an array, use it to select the members to be stringified.
546
+
547
+ if (rep && typeof rep === 'object') {
548
+ length = rep.length;
549
+ for (i = 0; i < length; i += 1) {
550
+ if (typeof rep[i] === 'string') {
551
+ k = rep[i];
552
+ v = str(k, value);
553
+ if (v) {
554
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
555
+ }
556
+ }
557
+ }
558
+ } else {
559
+
560
+ // Otherwise, iterate through all of the keys in the object.
561
+
562
+ for (k in value) {
563
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
564
+ v = str(k, value);
565
+ if (v) {
566
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
567
+ }
568
+ }
569
+ }
570
+ }
571
+
572
+ // Join all of the member texts together, separated with commas,
573
+ // and wrap them in braces.
574
+
575
+ v = partial.length === 0 ? '{}' : gap ?
576
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
577
+ '{' + partial.join(',') + '}';
578
+ gap = mind;
579
+ return v;
580
+ }
581
+ }
582
+
583
+ // If the JSON object does not yet have a stringify method, give it one.
584
+
585
+ if (typeof JSON.stringify !== 'function') {
586
+ JSON.stringify = function (value, replacer, space) {
587
+
588
+ // The stringify method takes a value and an optional replacer, and an optional
589
+ // space parameter, and returns a JSON text. The replacer can be a function
590
+ // that can replace values, or an array of strings that will select the keys.
591
+ // A default replacer method can be provided. Use of the space parameter can
592
+ // produce text that is more easily readable.
593
+
594
+ var i;
595
+ gap = '';
596
+ indent = '';
597
+
598
+ // If the space parameter is a number, make an indent string containing that
599
+ // many spaces.
600
+
601
+ if (typeof space === 'number') {
602
+ for (i = 0; i < space; i += 1) {
603
+ indent += ' ';
604
+ }
605
+
606
+ // If the space parameter is a string, it will be used as the indent string.
607
+
608
+ } else if (typeof space === 'string') {
609
+ indent = space;
610
+ }
611
+
612
+ // If there is a replacer, it must be a function or an array.
613
+ // Otherwise, throw an error.
614
+
615
+ rep = replacer;
616
+ if (replacer && typeof replacer !== 'function' &&
617
+ (typeof replacer !== 'object' ||
618
+ typeof replacer.length !== 'number')) {
619
+ throw new Error('JSON.stringify');
620
+ }
621
+
622
+ // Make a fake root object containing our value under the key of ''.
623
+ // Return the result of stringifying the value.
624
+
625
+ return str('', {'': value});
626
+ };
627
+ }
628
+
629
+
630
+ // If the JSON object does not yet have a parse method, give it one.
631
+
632
+ }());