aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee78
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu.js83
-rw-r--r--wqflask/wqflask/static/new/js_external/jquery.cookie.js72
-rw-r--r--wqflask/wqflask/static/new/js_external/json2.js1750
-rw-r--r--wqflask/wqflask/templates/new_index_page.html15
5 files changed, 688 insertions, 1310 deletions
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee b/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee
index c2a9b11d..df891826 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee
@@ -1,8 +1,11 @@
$ ->
+ ## Handle menu changes
+
process_json = (data) ->
window.jdata = data
populate_species()
+ apply_default()
$.ajax '/static/new/javascript/dataset_menu_structure',
dataType: 'json'
@@ -11,42 +14,97 @@ $ ->
populate_species = ->
species_list = @jdata.species
redo_dropdown($('#species'), species_list)
- populate_groups()
+ populate_group()
- populate_groups = ->
+ populate_group = ->
+ console.log("in populate group")
species = $('#species').val()
group_list = @jdata.groups[species]
redo_dropdown($('#group'), group_list)
- populate_types()
+ populate_type()
- populate_types = ->
+ populate_type = ->
species = $('#species').val()
group = $('#group').val()
type_list = @jdata.types[species][group]
redo_dropdown($('#type'), type_list)
- populate_datasets()
+ populate_dataset()
- populate_datasets = ->
+ populate_dataset = ->
species = $('#species').val()
group = $('#group').val()
type = $('#type').val()
+ console.log("sgt:", species, group, type)
dataset_list = @jdata.datasets[species][group][type]
+ console.log("pop_dataset:", dataset_list)
redo_dropdown($('#dataset'), dataset_list)
redo_dropdown = (dropdown, items) ->
+ console.log("in redo:", dropdown, items)
dropdown.empty()
for item in items
dropdown.append($("<option />").val(item[0]).text(item[1]))
-
+
$('#species').change =>
- populate_groups()
+ populate_group()
$('#group').change =>
- populate_types()
+ populate_type()
$('#type').change =>
- populate_datasets()
+ populate_dataset()
+
+ ## Info buttons
+
+ open_window = (url, name) ->
+ options = "menubar=1,toolbar=1,location=1,resizable=1,status=1,scrollbars=1,directories=1,width=900"
+ open(url, name, options).focus()
+
+ group_info = ->
+ species = $('#species').val()
+ group = $('#group').val()
+ url = "/" + species + "Cross.html#" + group
+ open_window(url, "Group Info")
+
+ $('#group_info').click(group_info)
+ dataset_info = ->
+ dataset = $('#dataset').val()
+ url = "/webqtl/main.py?FormID=sharinginfo&InfoPageName=" + dataset
+ open_window(url, "Dataset Info")
+
+ $('#dataset_info').click(dataset_info)
+
+
+ ## Handle setting new default drop downs
+
+ make_default = ->
+ holder = {}
+ for item in ['species', 'group', 'type', 'dataset']
+ holder[item] = $("##{item}").val()
+ jholder = JSON.stringify(holder)
+ $.cookie('search_defaults', jholder,
+ expires: 365)
+
+ apply_default = ->
+ defaults = $.cookie('search_defaults')
+ if not defaults
+ return
+ defaults = $.parseJSON(defaults)
+
+ for item in [['species', 'group']
+ ['group', 'type']
+ ['type', 'dataset'],
+ ['dataset', null]]
+
+ $("##{item[0]}").val(defaults[item[0]])
+ if item[1]
+ window["populate_" + item[1]]
+
+
+
+ $("#make_default").click(make_default)
+
##
##* function: based on different browser use, will have different initial actions;
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js
index 8f684f6a..655aac15 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js
@@ -2,11 +2,12 @@
(function() {
$(function() {
- var populate_datasets, populate_groups, populate_species, populate_types, process_json, redo_dropdown,
+ var apply_default, dataset_info, group_info, make_default, open_window, populate_dataset, populate_group, populate_species, populate_type, process_json, redo_dropdown,
_this = this;
process_json = function(data) {
window.jdata = data;
- return populate_species();
+ populate_species();
+ return apply_default();
};
$.ajax('/static/new/javascript/dataset_menu_structure', {
dataType: 'json',
@@ -16,33 +17,37 @@
var species_list;
species_list = this.jdata.species;
redo_dropdown($('#species'), species_list);
- return populate_groups();
+ return populate_group();
};
- populate_groups = function() {
+ populate_group = function() {
var group_list, species;
+ console.log("in populate group");
species = $('#species').val();
group_list = this.jdata.groups[species];
redo_dropdown($('#group'), group_list);
- return populate_types();
+ return populate_type();
};
- populate_types = function() {
+ populate_type = function() {
var group, species, type_list;
species = $('#species').val();
group = $('#group').val();
type_list = this.jdata.types[species][group];
redo_dropdown($('#type'), type_list);
- return populate_datasets();
+ return populate_dataset();
};
- populate_datasets = function() {
+ populate_dataset = function() {
var dataset_list, group, species, type;
species = $('#species').val();
group = $('#group').val();
type = $('#type').val();
+ console.log("sgt:", species, group, type);
dataset_list = this.jdata.datasets[species][group][type];
+ console.log("pop_dataset:", dataset_list);
return redo_dropdown($('#dataset'), dataset_list);
};
redo_dropdown = function(dropdown, items) {
var item, _i, _len, _results;
+ console.log("in redo:", dropdown, items);
dropdown.empty();
_results = [];
for (_i = 0, _len = items.length; _i < _len; _i++) {
@@ -52,14 +57,68 @@
return _results;
};
$('#species').change(function() {
- return populate_groups();
+ return populate_group();
});
$('#group').change(function() {
- return populate_types();
+ return populate_type();
});
- return $('#type').change(function() {
- return populate_datasets();
+ $('#type').change(function() {
+ return populate_dataset();
});
+ open_window = function(url, name) {
+ var options;
+ options = "menubar=1,toolbar=1,location=1,resizable=1,status=1,scrollbars=1,directories=1,width=900";
+ return open(url, name, options).focus();
+ };
+ group_info = function() {
+ var group, species, url;
+ species = $('#species').val();
+ group = $('#group').val();
+ url = "/" + species + "Cross.html#" + group;
+ return open_window(url, "Group Info");
+ };
+ $('#group_info').click(group_info);
+ dataset_info = function() {
+ var dataset, url;
+ dataset = $('#dataset').val();
+ url = "/webqtl/main.py?FormID=sharinginfo&InfoPageName=" + dataset;
+ return open_window(url, "Dataset Info");
+ };
+ $('#dataset_info').click(dataset_info);
+ make_default = function() {
+ var holder, item, jholder, _i, _len, _ref;
+ holder = {};
+ _ref = ['species', 'group', 'type', 'dataset'];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ holder[item] = $("#" + item).val();
+ }
+ jholder = JSON.stringify(holder);
+ return $.cookie('search_defaults', jholder, {
+ expires: 365
+ });
+ };
+ apply_default = function() {
+ var defaults, item, _i, _len, _ref, _results;
+ defaults = $.cookie('search_defaults');
+ if (!defaults) {
+ return;
+ }
+ defaults = $.parseJSON(defaults);
+ _ref = [['species', 'group'], ['group', 'type'], ['type', 'dataset'], ['dataset', null]];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ $("#" + item[0]).val(defaults[item[0]]);
+ if (item[1]) {
+ _results.push(window["populate_" + item[1]]);
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+ return $("#make_default").click(make_default);
});
}).call(this);
diff --git a/wqflask/wqflask/static/new/js_external/jquery.cookie.js b/wqflask/wqflask/static/new/js_external/jquery.cookie.js
new file mode 100644
index 00000000..2d4c05a8
--- /dev/null
+++ b/wqflask/wqflask/static/new/js_external/jquery.cookie.js
@@ -0,0 +1,72 @@
+/*!
+ * jQuery Cookie Plugin v1.3
+ * https://github.com/carhartl/jquery-cookie
+ *
+ * Copyright 2011, Klaus Hartl
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.opensource.org/licenses/GPL-2.0
+ */
+(function ($, document, undefined) {
+
+ var pluses = /\+/g;
+
+ function raw(s) {
+ return s;
+ }
+
+ function decoded(s) {
+ return decodeURIComponent(s.replace(pluses, ' '));
+ }
+
+ var config = $.cookie = function (key, value, options) {
+
+ // write
+ if (value !== undefined) {
+ options = $.extend({}, config.defaults, options);
+
+ if (value === null) {
+ options.expires = -1;
+ }
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setDate(t.getDate() + days);
+ }
+
+ value = config.json ? JSON.stringify(value) : String(value);
+
+ return (document.cookie = [
+ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
+ }
+
+ // read
+ var decode = config.raw ? raw : decoded;
+ var cookies = document.cookie.split('; ');
+ for (var i = 0, l = cookies.length; i < l; i++) {
+ var parts = cookies[i].split('=');
+ if (decode(parts.shift()) === key) {
+ var cookie = decode(parts.join('='));
+ return config.json ? JSON.parse(cookie) : cookie;
+ }
+ }
+
+ return null;
+ };
+
+ config.defaults = {};
+
+ $.removeCookie = function (key, options) {
+ if ($.cookie(key) !== null) {
+ $.cookie(key, null, options);
+ return true;
+ }
+ return false;
+ };
+
+})(jQuery, document);
diff --git a/wqflask/wqflask/static/new/js_external/json2.js b/wqflask/wqflask/static/new/js_external/json2.js
index 2373c74d..c7745df8 100644
--- a/wqflask/wqflask/static/new/js_external/json2.js
+++ b/wqflask/wqflask/static/new/js_external/json2.js
@@ -1,1298 +1,486 @@
-
+/*
+ json2.js
+ 2012-10-08
+ Public Domain.
-<!DOCTYPE html>
-<html>
- <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# githubog: http://ogp.me/ns/fb/githubog#">
- <meta charset='utf-8'>
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>JSON-js/json2.js at master · douglascrockford/JSON-js · GitHub</title>
- <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub" />
- <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub" />
- <link rel="apple-touch-icon-precomposed" sizes="57x57" href="apple-touch-icon-114.png" />
- <link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114.png" />
- <link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-144.png" />
- <link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144.png" />
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-
-
- <link rel="icon" type="image/x-icon" href="/favicon.ico" />
+ See http://www.JSON.org/js.html
- <meta content="authenticity_token" name="csrf-param" />
-<meta content="YGtVfxTDqeXtY2DUrAKAu+eCBT/gkAh4yV7ysInGO0E=" name="csrf-token" />
- <link href="https://a248.e.akamai.net/assets.github.com/assets/github-03fe491ce51a79a6bbd92168366bd017760f10a3.css" media="screen" rel="stylesheet" type="text/css" />
- <link href="https://a248.e.akamai.net/assets.github.com/assets/github2-f058dd0a2470c893977124d69336e4789671f5db.css" media="screen" rel="stylesheet" type="text/css" />
-
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
- <script src="https://a248.e.akamai.net/assets.github.com/assets/frameworks-974473a941a983b46f11833dc8ffba8414698ff7.js" type="text/javascript"></script>
- <script src="https://a248.e.akamai.net/assets.github.com/assets/github-ed7025e36f89edba560711c67769992ae8b3e362.js" type="text/javascript"></script>
-
- <link rel='permalink' href='/douglascrockford/JSON-js/blob/43d7836c8ec9b31a02a31ae0c400bdae04d3650d/json2.js'>
- <meta property="og:title" content="JSON-js"/>
- <meta property="og:type" content="githubog:gitrepository"/>
- <meta property="og:url" content="https://github.com/douglascrockford/JSON-js"/>
- <meta property="og:image" content="https://a248.e.akamai.net/assets.github.com/images/gravatars/gravatar-user-420.png?1345673562"/>
- <meta property="og:site_name" content="GitHub"/>
- <meta property="og:description" content="JSON in JavaScript. Contribute to JSON-js development by creating an account on GitHub."/>
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
- <meta name="description" content="JSON in JavaScript. Contribute to JSON-js development by creating an account on GitHub." />
- <link href="https://github.com/douglascrockford/JSON-js/commits/master.atom" rel="alternate" title="Recent Commits to JSON-js:master" type="application/atom+xml" />
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
- </head>
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or '&nbsp;'),
+ it contains the characters used to indent at each level.
- <body class="logged_out page-blob vis-public env-production ">
- <div id="wrapper">
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
-
-
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
- <div id="header" class="true clearfix">
- <div class="container clearfix">
- <a class="site-logo " href="https://github.com/">
- <img alt="GitHub" class="github-logo-4x" height="30" src="https://a248.e.akamai.net/assets.github.com/images/modules/header/logov7@4x.png?1338956357" />
- <img alt="GitHub" class="github-logo-4x-hover" height="30" src="https://a248.e.akamai.net/assets.github.com/images/modules/header/logov7@4x-hover.png?1338956357" />
- </a>
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
-
- <!--
- make sure to use fully qualified URLs here since this nav
- is used on error pages on other domains
- -->
- <ul class="top-nav logged_out">
- <li class="pricing"><a href="https://github.com/plans">Signup and Pricing</a></li>
- <li class="explore"><a href="https://github.com/explore">Explore GitHub</a></li>
- <li class="features"><a href="https://github.com/features">Features</a></li>
- <li class="blog"><a href="https://github.com/blog">Blog</a></li>
- <li class="login"><a href="https://github.com/login?return_to=%2Fdouglascrockford%2FJSON-js%2Fblob%2Fmaster%2Fjson2.js">Sign in</a></li>
- </ul>
-
-
-
-
- </div>
- </div>
-
-
-
-
-
-
- <div class="site hfeed" itemscope itemtype="http://schema.org/WebPage">
- <div class="hentry">
-
- <div class="pagehead repohead instapaper_ignore readability-menu">
- <div class="container">
- <div class="title-actions-bar">
-
-
-
- <ul class="pagehead-actions">
-
-
- <li>
- <span class="star-button"><a href="/login?return_to=%2Fdouglascrockford%2FJSON-js" class="minibutton js-toggler-target entice tooltipped leftwards" title="You must be signed in to use this feature" rel="nofollow"><span class="mini-icon mini-icon-star"></span>Star</a><a class="social-count js-social-count" href="/douglascrockford/JSON-js/stargazers">2,519</a></span>
- </li>
- <li>
- <a href="/login?return_to=%2Fdouglascrockford%2FJSON-js" class="minibutton js-toggler-target fork-button entice tooltipped leftwards" title="You must be signed in to fork a repository" rel="nofollow"><span class="mini-icon mini-icon-fork"></span>Fork</a><a href="/douglascrockford/JSON-js/network" class="social-count">624</a>
- </li>
- </ul>
-
- <h1 itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="entry-title public">
- <span class="repo-label"><span>public</span></span>
- <span class="mega-icon mega-icon-public-repo"></span>
- <span class="author vcard">
- <a href="/douglascrockford" class="url fn" itemprop="url" rel="author">
- <span itemprop="title">douglascrockford</span>
- </a></span> /
- <strong><a href="/douglascrockford/JSON-js" class="js-current-repository">JSON-js</a></strong>
- </h1>
- </div>
-
-
-
- <ul class="tabs">
- <li><a href="/douglascrockford/JSON-js" class="selected" highlight="repo_sourcerepo_downloadsrepo_commitsrepo_tagsrepo_branches">Code</a></li>
- <li><a href="/douglascrockford/JSON-js/network" highlight="repo_network">Network</a></li>
- <li><a href="/douglascrockford/JSON-js/pulls" highlight="repo_pulls">Pull Requests <span class='counter'>0</span></a></li>
-
- <li><a href="/douglascrockford/JSON-js/issues" highlight="repo_issues">Issues <span class='counter'>1</span></a></li>
-
-
-
- <li><a href="/douglascrockford/JSON-js/graphs" highlight="repo_graphsrepo_contributors">Graphs</a></li>
-
-
- </ul>
-
-<div class="frame frame-center tree-finder" style="display:none"
- data-tree-list-url="/douglascrockford/JSON-js/tree-list/43d7836c8ec9b31a02a31ae0c400bdae04d3650d"
- data-blob-url-prefix="/douglascrockford/JSON-js/blob/43d7836c8ec9b31a02a31ae0c400bdae04d3650d"
- >
-
- <div class="breadcrumb">
- <span class="bold"><a href="/douglascrockford/JSON-js">JSON-js</a></span> /
- <input class="tree-finder-input js-navigation-enable" type="text" name="query" autocomplete="off" spellcheck="false">
- </div>
-
- <div class="octotip">
- <p>
- <a href="/douglascrockford/JSON-js/dismiss-tree-finder-help" class="dismiss js-dismiss-tree-list-help" title="Hide this notice forever" rel="nofollow">Dismiss</a>
- <span class="bold">Octotip:</span> You've activated the <em>file finder</em>
- by pressing <span class="kbd">t</span> Start typing to filter the
- file list. Use <span class="kbd badmono">↑</span> and
- <span class="kbd badmono">↓</span> to navigate,
- <span class="kbd">enter</span> to view files.
- </p>
- </div>
-
- <table class="tree-browser css-truncate" cellpadding="0" cellspacing="0">
- <tr class="js-header"><th>&nbsp;</th><th>name</th></tr>
- <tr class="js-no-results no-results" style="display: none">
- <th colspan="2">No matching files</th>
- </tr>
- <tbody class="js-results-list js-navigation-container">
- </tbody>
- </table>
-</div>
-
-<div id="jump-to-line" style="display:none">
- <h2>Jump to Line</h2>
- <form accept-charset="UTF-8">
- <input class="textfield" type="text">
- <div class="full-button">
- <button type="submit" class="classy">
- Go
- </button>
- </div>
- </form>
-</div>
-
-
-<div class="tabnav">
-
- <span class="tabnav-right">
- <ul class="tabnav-tabs">
- <li><a href="/douglascrockford/JSON-js/tags" class="tabnav-tab" highlight="repo_tags">Tags <span class="counter blank">0</span></a></li>
- <li><a href="/douglascrockford/JSON-js/downloads" class="tabnav-tab" highlight="repo_downloads">Downloads <span class="counter blank">0</span></a></li>
- </ul>
-
- </span>
-
- <div class="tabnav-widget scope">
-
- <div class="context-menu-container js-menu-container js-context-menu">
- <a href="#"
- class="minibutton bigger switcher js-menu-target js-commitish-button btn-branch repo-tree"
- data-hotkey="w"
- data-master-branch="master"
- data-ref="master">
- <span><em class="mini-icon mini-icon-branch"></em><i>branch:</i> master</span>
- </a>
-
- <div class="context-pane commitish-context js-menu-content">
- <a href="javascript:;" class="close js-menu-close"><span class="mini-icon mini-icon-remove-close"></span></a>
- <div class="context-title">Switch branches/tags</div>
- <div class="context-body pane-selector commitish-selector js-navigation-container">
- <div class="filterbar">
- <input type="text" id="context-commitish-filter-field" class="js-navigation-enable" placeholder="Filter branches/tags" data-filterable />
- <ul class="tabs">
- <li><a href="#" data-filter="branches" class="selected">Branches</a></li>
- <li><a href="#" data-filter="tags">Tags</a></li>
- </ul>
- </div>
-
- <div class="js-filter-tab js-filter-branches" data-filterable-for="context-commitish-filter-field" data-filterable-type=substring>
- <div class="no-results js-not-filterable">Nothing to show</div>
- <div class="commitish-item branch-commitish selector-item js-navigation-item js-navigation-target selected">
- <span class="mini-icon mini-icon-confirm"></span>
- <h4>
- <a href="/douglascrockford/JSON-js/blob/master/json2.js" class="js-navigation-open" data-name="master" rel="nofollow">master</a>
- </h4>
- </div>
- </div>
-
- <div class="js-filter-tab js-filter-tags filter-tab-empty" style="display:none" data-filterable-for="context-commitish-filter-field" data-filterable-type=substring>
- <div class="no-results js-not-filterable">Nothing to show</div>
- </div>
- </div>
- </div><!-- /.commitish-context-context -->
- </div>
- </div> <!-- /.scope -->
-
- <ul class="tabnav-tabs">
- <li><a href="/douglascrockford/JSON-js" class="selected tabnav-tab" highlight="repo_source">Files</a></li>
- <li><a href="/douglascrockford/JSON-js/commits/master" class="tabnav-tab" highlight="repo_commits">Commits</a></li>
- <li><a href="/douglascrockford/JSON-js/branches" class="tabnav-tab" highlight="repo_branches" rel="nofollow">Branches <span class="counter ">1</span></a></li>
- </ul>
-
-</div>
-
-
-
-
-
-
-
- </div>
- </div><!-- /.repohead -->
-
- <div id="js-repo-pjax-container" class="container context-loader-container" data-pjax-container>
-
-
-
-<!-- blob contrib key: blob_contributors:v21:2bd031f6698ac327744343a63670f990 -->
-<!-- blob contrib frag key: views10/v8/blob_contributors:v21:2bd031f6698ac327744343a63670f990 -->
-
-<!-- block_view_fragment_key: views10/v8/blob:v21:c5d1fa5a17b5f9915092ac572e2bf72e -->
-
- <div id="slider">
-
- <div class="breadcrumb" data-path="json2.js/">
- <b itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/douglascrockford/JSON-js/tree/43d7836c8ec9b31a02a31ae0c400bdae04d3650d" class="js-rewrite-sha" itemprop="url"><span itemprop="title">JSON-js</span></a></b> / <strong class="final-path">json2.js</strong> <span class="js-clippy mini-icon mini-icon-clippy " data-clipboard-text="json2.js" data-copied-hint="copied!" data-copy-hint="copy to clipboard"></span>
- </div>
-
-
- <div class="commit file-history-tease js-blob-contributors-content" data-path="json2.js/">
- <img class="main-avatar" height="24" src="https://secure.gravatar.com/avatar/b871de839c31ddb1d9db8e33e0cb88a6?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png" width="24" />
- <span class="author"><a href="/douglascrockford">douglascrockford</a></span>
- <time class="js-relative-date" datetime="2012-10-08T14:40:29-07:00" title="2012-10-08 14:40:29">October 08, 2012</time>
- <div class="commit-title">
- <a href="/douglascrockford/JSON-js/commit/43d7836c8ec9b31a02a31ae0c400bdae04d3650d" class="message">Defense against window.prototype</a>
- </div>
-
- <div class="participation">
- <p class="quickstat"><a href="#blob_contributors_box" rel="facebox"><strong>1</strong> contributor</a></p>
-
- </div>
- <div id="blob_contributors_box" style="display:none">
- <h2>Users on GitHub who have contributed to this file</h2>
- <ul class="facebox-user-list">
- <li>
- <img height="24" src="https://secure.gravatar.com/avatar/b871de839c31ddb1d9db8e33e0cb88a6?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png" width="24" />
- <a href="/douglascrockford">douglascrockford</a>
- </li>
- </ul>
- </div>
- </div>
-
-
- <div class="frames">
- <div class="frame frame-center" data-path="json2.js/" data-permalink-url="/douglascrockford/JSON-js/blob/43d7836c8ec9b31a02a31ae0c400bdae04d3650d/json2.js" data-title="JSON-js/json2.js at master · douglascrockford/JSON-js · GitHub" data-type="blob">
-
- <div id="files" class="bubble">
- <div class="file">
- <div class="meta">
- <div class="info">
- <span class="icon"><b class="mini-icon mini-icon-text-file"></b></span>
- <span class="mode" title="File Mode">file</span>
- <span>487 lines (369 sloc)</span>
- <span>17.53 kb</span>
- </div>
- <ul class="button-group actions">
- <li>
- <a class="grouped-button file-edit-link minibutton bigger lighter js-rewrite-sha" href="/douglascrockford/JSON-js/edit/43d7836c8ec9b31a02a31ae0c400bdae04d3650d/json2.js" data-method="post" rel="nofollow" data-hotkey="e">Edit</a>
- </li>
- <li>
- <a href="/douglascrockford/JSON-js/raw/master/json2.js" class="minibutton grouped-button bigger lighter" id="raw-url">Raw</a>
- </li>
- <li>
- <a href="/douglascrockford/JSON-js/blame/master/json2.js" class="minibutton grouped-button bigger lighter">Blame</a>
- </li>
- <li>
- <a href="/douglascrockford/JSON-js/commits/master/json2.js" class="minibutton grouped-button bigger lighter" rel="nofollow">History</a>
- </li>
- </ul>
- </div>
- <div class="data type-javascript">
- <table cellpadding="0" cellspacing="0" class="lines">
- <tr>
- <td>
- <pre class="line_numbers"><span id="L1" rel="#L1">1</span>
-<span id="L2" rel="#L2">2</span>
-<span id="L3" rel="#L3">3</span>
-<span id="L4" rel="#L4">4</span>
-<span id="L5" rel="#L5">5</span>
-<span id="L6" rel="#L6">6</span>
-<span id="L7" rel="#L7">7</span>
-<span id="L8" rel="#L8">8</span>
-<span id="L9" rel="#L9">9</span>
-<span id="L10" rel="#L10">10</span>
-<span id="L11" rel="#L11">11</span>
-<span id="L12" rel="#L12">12</span>
-<span id="L13" rel="#L13">13</span>
-<span id="L14" rel="#L14">14</span>
-<span id="L15" rel="#L15">15</span>
-<span id="L16" rel="#L16">16</span>
-<span id="L17" rel="#L17">17</span>
-<span id="L18" rel="#L18">18</span>
-<span id="L19" rel="#L19">19</span>
-<span id="L20" rel="#L20">20</span>
-<span id="L21" rel="#L21">21</span>
-<span id="L22" rel="#L22">22</span>
-<span id="L23" rel="#L23">23</span>
-<span id="L24" rel="#L24">24</span>
-<span id="L25" rel="#L25">25</span>
-<span id="L26" rel="#L26">26</span>
-<span id="L27" rel="#L27">27</span>
-<span id="L28" rel="#L28">28</span>
-<span id="L29" rel="#L29">29</span>
-<span id="L30" rel="#L30">30</span>
-<span id="L31" rel="#L31">31</span>
-<span id="L32" rel="#L32">32</span>
-<span id="L33" rel="#L33">33</span>
-<span id="L34" rel="#L34">34</span>
-<span id="L35" rel="#L35">35</span>
-<span id="L36" rel="#L36">36</span>
-<span id="L37" rel="#L37">37</span>
-<span id="L38" rel="#L38">38</span>
-<span id="L39" rel="#L39">39</span>
-<span id="L40" rel="#L40">40</span>
-<span id="L41" rel="#L41">41</span>
-<span id="L42" rel="#L42">42</span>
-<span id="L43" rel="#L43">43</span>
-<span id="L44" rel="#L44">44</span>
-<span id="L45" rel="#L45">45</span>
-<span id="L46" rel="#L46">46</span>
-<span id="L47" rel="#L47">47</span>
-<span id="L48" rel="#L48">48</span>
-<span id="L49" rel="#L49">49</span>
-<span id="L50" rel="#L50">50</span>
-<span id="L51" rel="#L51">51</span>
-<span id="L52" rel="#L52">52</span>
-<span id="L53" rel="#L53">53</span>
-<span id="L54" rel="#L54">54</span>
-<span id="L55" rel="#L55">55</span>
-<span id="L56" rel="#L56">56</span>
-<span id="L57" rel="#L57">57</span>
-<span id="L58" rel="#L58">58</span>
-<span id="L59" rel="#L59">59</span>
-<span id="L60" rel="#L60">60</span>
-<span id="L61" rel="#L61">61</span>
-<span id="L62" rel="#L62">62</span>
-<span id="L63" rel="#L63">63</span>
-<span id="L64" rel="#L64">64</span>
-<span id="L65" rel="#L65">65</span>
-<span id="L66" rel="#L66">66</span>
-<span id="L67" rel="#L67">67</span>
-<span id="L68" rel="#L68">68</span>
-<span id="L69" rel="#L69">69</span>
-<span id="L70" rel="#L70">70</span>
-<span id="L71" rel="#L71">71</span>
-<span id="L72" rel="#L72">72</span>
-<span id="L73" rel="#L73">73</span>
-<span id="L74" rel="#L74">74</span>
-<span id="L75" rel="#L75">75</span>
-<span id="L76" rel="#L76">76</span>
-<span id="L77" rel="#L77">77</span>
-<span id="L78" rel="#L78">78</span>
-<span id="L79" rel="#L79">79</span>
-<span id="L80" rel="#L80">80</span>
-<span id="L81" rel="#L81">81</span>
-<span id="L82" rel="#L82">82</span>
-<span id="L83" rel="#L83">83</span>
-<span id="L84" rel="#L84">84</span>
-<span id="L85" rel="#L85">85</span>
-<span id="L86" rel="#L86">86</span>
-<span id="L87" rel="#L87">87</span>
-<span id="L88" rel="#L88">88</span>
-<span id="L89" rel="#L89">89</span>
-<span id="L90" rel="#L90">90</span>
-<span id="L91" rel="#L91">91</span>
-<span id="L92" rel="#L92">92</span>
-<span id="L93" rel="#L93">93</span>
-<span id="L94" rel="#L94">94</span>
-<span id="L95" rel="#L95">95</span>
-<span id="L96" rel="#L96">96</span>
-<span id="L97" rel="#L97">97</span>
-<span id="L98" rel="#L98">98</span>
-<span id="L99" rel="#L99">99</span>
-<span id="L100" rel="#L100">100</span>
-<span id="L101" rel="#L101">101</span>
-<span id="L102" rel="#L102">102</span>
-<span id="L103" rel="#L103">103</span>
-<span id="L104" rel="#L104">104</span>
-<span id="L105" rel="#L105">105</span>
-<span id="L106" rel="#L106">106</span>
-<span id="L107" rel="#L107">107</span>
-<span id="L108" rel="#L108">108</span>
-<span id="L109" rel="#L109">109</span>
-<span id="L110" rel="#L110">110</span>
-<span id="L111" rel="#L111">111</span>
-<span id="L112" rel="#L112">112</span>
-<span id="L113" rel="#L113">113</span>
-<span id="L114" rel="#L114">114</span>
-<span id="L115" rel="#L115">115</span>
-<span id="L116" rel="#L116">116</span>
-<span id="L117" rel="#L117">117</span>
-<span id="L118" rel="#L118">118</span>
-<span id="L119" rel="#L119">119</span>
-<span id="L120" rel="#L120">120</span>
-<span id="L121" rel="#L121">121</span>
-<span id="L122" rel="#L122">122</span>
-<span id="L123" rel="#L123">123</span>
-<span id="L124" rel="#L124">124</span>
-<span id="L125" rel="#L125">125</span>
-<span id="L126" rel="#L126">126</span>
-<span id="L127" rel="#L127">127</span>
-<span id="L128" rel="#L128">128</span>
-<span id="L129" rel="#L129">129</span>
-<span id="L130" rel="#L130">130</span>
-<span id="L131" rel="#L131">131</span>
-<span id="L132" rel="#L132">132</span>
-<span id="L133" rel="#L133">133</span>
-<span id="L134" rel="#L134">134</span>
-<span id="L135" rel="#L135">135</span>
-<span id="L136" rel="#L136">136</span>
-<span id="L137" rel="#L137">137</span>
-<span id="L138" rel="#L138">138</span>
-<span id="L139" rel="#L139">139</span>
-<span id="L140" rel="#L140">140</span>
-<span id="L141" rel="#L141">141</span>
-<span id="L142" rel="#L142">142</span>
-<span id="L143" rel="#L143">143</span>
-<span id="L144" rel="#L144">144</span>
-<span id="L145" rel="#L145">145</span>
-<span id="L146" rel="#L146">146</span>
-<span id="L147" rel="#L147">147</span>
-<span id="L148" rel="#L148">148</span>
-<span id="L149" rel="#L149">149</span>
-<span id="L150" rel="#L150">150</span>
-<span id="L151" rel="#L151">151</span>
-<span id="L152" rel="#L152">152</span>
-<span id="L153" rel="#L153">153</span>
-<span id="L154" rel="#L154">154</span>
-<span id="L155" rel="#L155">155</span>
-<span id="L156" rel="#L156">156</span>
-<span id="L157" rel="#L157">157</span>
-<span id="L158" rel="#L158">158</span>
-<span id="L159" rel="#L159">159</span>
-<span id="L160" rel="#L160">160</span>
-<span id="L161" rel="#L161">161</span>
-<span id="L162" rel="#L162">162</span>
-<span id="L163" rel="#L163">163</span>
-<span id="L164" rel="#L164">164</span>
-<span id="L165" rel="#L165">165</span>
-<span id="L166" rel="#L166">166</span>
-<span id="L167" rel="#L167">167</span>
-<span id="L168" rel="#L168">168</span>
-<span id="L169" rel="#L169">169</span>
-<span id="L170" rel="#L170">170</span>
-<span id="L171" rel="#L171">171</span>
-<span id="L172" rel="#L172">172</span>
-<span id="L173" rel="#L173">173</span>
-<span id="L174" rel="#L174">174</span>
-<span id="L175" rel="#L175">175</span>
-<span id="L176" rel="#L176">176</span>
-<span id="L177" rel="#L177">177</span>
-<span id="L178" rel="#L178">178</span>
-<span id="L179" rel="#L179">179</span>
-<span id="L180" rel="#L180">180</span>
-<span id="L181" rel="#L181">181</span>
-<span id="L182" rel="#L182">182</span>
-<span id="L183" rel="#L183">183</span>
-<span id="L184" rel="#L184">184</span>
-<span id="L185" rel="#L185">185</span>
-<span id="L186" rel="#L186">186</span>
-<span id="L187" rel="#L187">187</span>
-<span id="L188" rel="#L188">188</span>
-<span id="L189" rel="#L189">189</span>
-<span id="L190" rel="#L190">190</span>
-<span id="L191" rel="#L191">191</span>
-<span id="L192" rel="#L192">192</span>
-<span id="L193" rel="#L193">193</span>
-<span id="L194" rel="#L194">194</span>
-<span id="L195" rel="#L195">195</span>
-<span id="L196" rel="#L196">196</span>
-<span id="L197" rel="#L197">197</span>
-<span id="L198" rel="#L198">198</span>
-<span id="L199" rel="#L199">199</span>
-<span id="L200" rel="#L200">200</span>
-<span id="L201" rel="#L201">201</span>
-<span id="L202" rel="#L202">202</span>
-<span id="L203" rel="#L203">203</span>
-<span id="L204" rel="#L204">204</span>
-<span id="L205" rel="#L205">205</span>
-<span id="L206" rel="#L206">206</span>
-<span id="L207" rel="#L207">207</span>
-<span id="L208" rel="#L208">208</span>
-<span id="L209" rel="#L209">209</span>
-<span id="L210" rel="#L210">210</span>
-<span id="L211" rel="#L211">211</span>
-<span id="L212" rel="#L212">212</span>
-<span id="L213" rel="#L213">213</span>
-<span id="L214" rel="#L214">214</span>
-<span id="L215" rel="#L215">215</span>
-<span id="L216" rel="#L216">216</span>
-<span id="L217" rel="#L217">217</span>
-<span id="L218" rel="#L218">218</span>
-<span id="L219" rel="#L219">219</span>
-<span id="L220" rel="#L220">220</span>
-<span id="L221" rel="#L221">221</span>
-<span id="L222" rel="#L222">222</span>
-<span id="L223" rel="#L223">223</span>
-<span id="L224" rel="#L224">224</span>
-<span id="L225" rel="#L225">225</span>
-<span id="L226" rel="#L226">226</span>
-<span id="L227" rel="#L227">227</span>
-<span id="L228" rel="#L228">228</span>
-<span id="L229" rel="#L229">229</span>
-<span id="L230" rel="#L230">230</span>
-<span id="L231" rel="#L231">231</span>
-<span id="L232" rel="#L232">232</span>
-<span id="L233" rel="#L233">233</span>
-<span id="L234" rel="#L234">234</span>
-<span id="L235" rel="#L235">235</span>
-<span id="L236" rel="#L236">236</span>
-<span id="L237" rel="#L237">237</span>
-<span id="L238" rel="#L238">238</span>
-<span id="L239" rel="#L239">239</span>
-<span id="L240" rel="#L240">240</span>
-<span id="L241" rel="#L241">241</span>
-<span id="L242" rel="#L242">242</span>
-<span id="L243" rel="#L243">243</span>
-<span id="L244" rel="#L244">244</span>
-<span id="L245" rel="#L245">245</span>
-<span id="L246" rel="#L246">246</span>
-<span id="L247" rel="#L247">247</span>
-<span id="L248" rel="#L248">248</span>
-<span id="L249" rel="#L249">249</span>
-<span id="L250" rel="#L250">250</span>
-<span id="L251" rel="#L251">251</span>
-<span id="L252" rel="#L252">252</span>
-<span id="L253" rel="#L253">253</span>
-<span id="L254" rel="#L254">254</span>
-<span id="L255" rel="#L255">255</span>
-<span id="L256" rel="#L256">256</span>
-<span id="L257" rel="#L257">257</span>
-<span id="L258" rel="#L258">258</span>
-<span id="L259" rel="#L259">259</span>
-<span id="L260" rel="#L260">260</span>
-<span id="L261" rel="#L261">261</span>
-<span id="L262" rel="#L262">262</span>
-<span id="L263" rel="#L263">263</span>
-<span id="L264" rel="#L264">264</span>
-<span id="L265" rel="#L265">265</span>
-<span id="L266" rel="#L266">266</span>
-<span id="L267" rel="#L267">267</span>
-<span id="L268" rel="#L268">268</span>
-<span id="L269" rel="#L269">269</span>
-<span id="L270" rel="#L270">270</span>
-<span id="L271" rel="#L271">271</span>
-<span id="L272" rel="#L272">272</span>
-<span id="L273" rel="#L273">273</span>
-<span id="L274" rel="#L274">274</span>
-<span id="L275" rel="#L275">275</span>
-<span id="L276" rel="#L276">276</span>
-<span id="L277" rel="#L277">277</span>
-<span id="L278" rel="#L278">278</span>
-<span id="L279" rel="#L279">279</span>
-<span id="L280" rel="#L280">280</span>
-<span id="L281" rel="#L281">281</span>
-<span id="L282" rel="#L282">282</span>
-<span id="L283" rel="#L283">283</span>
-<span id="L284" rel="#L284">284</span>
-<span id="L285" rel="#L285">285</span>
-<span id="L286" rel="#L286">286</span>
-<span id="L287" rel="#L287">287</span>
-<span id="L288" rel="#L288">288</span>
-<span id="L289" rel="#L289">289</span>
-<span id="L290" rel="#L290">290</span>
-<span id="L291" rel="#L291">291</span>
-<span id="L292" rel="#L292">292</span>
-<span id="L293" rel="#L293">293</span>
-<span id="L294" rel="#L294">294</span>
-<span id="L295" rel="#L295">295</span>
-<span id="L296" rel="#L296">296</span>
-<span id="L297" rel="#L297">297</span>
-<span id="L298" rel="#L298">298</span>
-<span id="L299" rel="#L299">299</span>
-<span id="L300" rel="#L300">300</span>
-<span id="L301" rel="#L301">301</span>
-<span id="L302" rel="#L302">302</span>
-<span id="L303" rel="#L303">303</span>
-<span id="L304" rel="#L304">304</span>
-<span id="L305" rel="#L305">305</span>
-<span id="L306" rel="#L306">306</span>
-<span id="L307" rel="#L307">307</span>
-<span id="L308" rel="#L308">308</span>
-<span id="L309" rel="#L309">309</span>
-<span id="L310" rel="#L310">310</span>
-<span id="L311" rel="#L311">311</span>
-<span id="L312" rel="#L312">312</span>
-<span id="L313" rel="#L313">313</span>
-<span id="L314" rel="#L314">314</span>
-<span id="L315" rel="#L315">315</span>
-<span id="L316" rel="#L316">316</span>
-<span id="L317" rel="#L317">317</span>
-<span id="L318" rel="#L318">318</span>
-<span id="L319" rel="#L319">319</span>
-<span id="L320" rel="#L320">320</span>
-<span id="L321" rel="#L321">321</span>
-<span id="L322" rel="#L322">322</span>
-<span id="L323" rel="#L323">323</span>
-<span id="L324" rel="#L324">324</span>
-<span id="L325" rel="#L325">325</span>
-<span id="L326" rel="#L326">326</span>
-<span id="L327" rel="#L327">327</span>
-<span id="L328" rel="#L328">328</span>
-<span id="L329" rel="#L329">329</span>
-<span id="L330" rel="#L330">330</span>
-<span id="L331" rel="#L331">331</span>
-<span id="L332" rel="#L332">332</span>
-<span id="L333" rel="#L333">333</span>
-<span id="L334" rel="#L334">334</span>
-<span id="L335" rel="#L335">335</span>
-<span id="L336" rel="#L336">336</span>
-<span id="L337" rel="#L337">337</span>
-<span id="L338" rel="#L338">338</span>
-<span id="L339" rel="#L339">339</span>
-<span id="L340" rel="#L340">340</span>
-<span id="L341" rel="#L341">341</span>
-<span id="L342" rel="#L342">342</span>
-<span id="L343" rel="#L343">343</span>
-<span id="L344" rel="#L344">344</span>
-<span id="L345" rel="#L345">345</span>
-<span id="L346" rel="#L346">346</span>
-<span id="L347" rel="#L347">347</span>
-<span id="L348" rel="#L348">348</span>
-<span id="L349" rel="#L349">349</span>
-<span id="L350" rel="#L350">350</span>
-<span id="L351" rel="#L351">351</span>
-<span id="L352" rel="#L352">352</span>
-<span id="L353" rel="#L353">353</span>
-<span id="L354" rel="#L354">354</span>
-<span id="L355" rel="#L355">355</span>
-<span id="L356" rel="#L356">356</span>
-<span id="L357" rel="#L357">357</span>
-<span id="L358" rel="#L358">358</span>
-<span id="L359" rel="#L359">359</span>
-<span id="L360" rel="#L360">360</span>
-<span id="L361" rel="#L361">361</span>
-<span id="L362" rel="#L362">362</span>
-<span id="L363" rel="#L363">363</span>
-<span id="L364" rel="#L364">364</span>
-<span id="L365" rel="#L365">365</span>
-<span id="L366" rel="#L366">366</span>
-<span id="L367" rel="#L367">367</span>
-<span id="L368" rel="#L368">368</span>
-<span id="L369" rel="#L369">369</span>
-<span id="L370" rel="#L370">370</span>
-<span id="L371" rel="#L371">371</span>
-<span id="L372" rel="#L372">372</span>
-<span id="L373" rel="#L373">373</span>
-<span id="L374" rel="#L374">374</span>
-<span id="L375" rel="#L375">375</span>
-<span id="L376" rel="#L376">376</span>
-<span id="L377" rel="#L377">377</span>
-<span id="L378" rel="#L378">378</span>
-<span id="L379" rel="#L379">379</span>
-<span id="L380" rel="#L380">380</span>
-<span id="L381" rel="#L381">381</span>
-<span id="L382" rel="#L382">382</span>
-<span id="L383" rel="#L383">383</span>
-<span id="L384" rel="#L384">384</span>
-<span id="L385" rel="#L385">385</span>
-<span id="L386" rel="#L386">386</span>
-<span id="L387" rel="#L387">387</span>
-<span id="L388" rel="#L388">388</span>
-<span id="L389" rel="#L389">389</span>
-<span id="L390" rel="#L390">390</span>
-<span id="L391" rel="#L391">391</span>
-<span id="L392" rel="#L392">392</span>
-<span id="L393" rel="#L393">393</span>
-<span id="L394" rel="#L394">394</span>
-<span id="L395" rel="#L395">395</span>
-<span id="L396" rel="#L396">396</span>
-<span id="L397" rel="#L397">397</span>
-<span id="L398" rel="#L398">398</span>
-<span id="L399" rel="#L399">399</span>
-<span id="L400" rel="#L400">400</span>
-<span id="L401" rel="#L401">401</span>
-<span id="L402" rel="#L402">402</span>
-<span id="L403" rel="#L403">403</span>
-<span id="L404" rel="#L404">404</span>
-<span id="L405" rel="#L405">405</span>
-<span id="L406" rel="#L406">406</span>
-<span id="L407" rel="#L407">407</span>
-<span id="L408" rel="#L408">408</span>
-<span id="L409" rel="#L409">409</span>
-<span id="L410" rel="#L410">410</span>
-<span id="L411" rel="#L411">411</span>
-<span id="L412" rel="#L412">412</span>
-<span id="L413" rel="#L413">413</span>
-<span id="L414" rel="#L414">414</span>
-<span id="L415" rel="#L415">415</span>
-<span id="L416" rel="#L416">416</span>
-<span id="L417" rel="#L417">417</span>
-<span id="L418" rel="#L418">418</span>
-<span id="L419" rel="#L419">419</span>
-<span id="L420" rel="#L420">420</span>
-<span id="L421" rel="#L421">421</span>
-<span id="L422" rel="#L422">422</span>
-<span id="L423" rel="#L423">423</span>
-<span id="L424" rel="#L424">424</span>
-<span id="L425" rel="#L425">425</span>
-<span id="L426" rel="#L426">426</span>
-<span id="L427" rel="#L427">427</span>
-<span id="L428" rel="#L428">428</span>
-<span id="L429" rel="#L429">429</span>
-<span id="L430" rel="#L430">430</span>
-<span id="L431" rel="#L431">431</span>
-<span id="L432" rel="#L432">432</span>
-<span id="L433" rel="#L433">433</span>
-<span id="L434" rel="#L434">434</span>
-<span id="L435" rel="#L435">435</span>
-<span id="L436" rel="#L436">436</span>
-<span id="L437" rel="#L437">437</span>
-<span id="L438" rel="#L438">438</span>
-<span id="L439" rel="#L439">439</span>
-<span id="L440" rel="#L440">440</span>
-<span id="L441" rel="#L441">441</span>
-<span id="L442" rel="#L442">442</span>
-<span id="L443" rel="#L443">443</span>
-<span id="L444" rel="#L444">444</span>
-<span id="L445" rel="#L445">445</span>
-<span id="L446" rel="#L446">446</span>
-<span id="L447" rel="#L447">447</span>
-<span id="L448" rel="#L448">448</span>
-<span id="L449" rel="#L449">449</span>
-<span id="L450" rel="#L450">450</span>
-<span id="L451" rel="#L451">451</span>
-<span id="L452" rel="#L452">452</span>
-<span id="L453" rel="#L453">453</span>
-<span id="L454" rel="#L454">454</span>
-<span id="L455" rel="#L455">455</span>
-<span id="L456" rel="#L456">456</span>
-<span id="L457" rel="#L457">457</span>
-<span id="L458" rel="#L458">458</span>
-<span id="L459" rel="#L459">459</span>
-<span id="L460" rel="#L460">460</span>
-<span id="L461" rel="#L461">461</span>
-<span id="L462" rel="#L462">462</span>
-<span id="L463" rel="#L463">463</span>
-<span id="L464" rel="#L464">464</span>
-<span id="L465" rel="#L465">465</span>
-<span id="L466" rel="#L466">466</span>
-<span id="L467" rel="#L467">467</span>
-<span id="L468" rel="#L468">468</span>
-<span id="L469" rel="#L469">469</span>
-<span id="L470" rel="#L470">470</span>
-<span id="L471" rel="#L471">471</span>
-<span id="L472" rel="#L472">472</span>
-<span id="L473" rel="#L473">473</span>
-<span id="L474" rel="#L474">474</span>
-<span id="L475" rel="#L475">475</span>
-<span id="L476" rel="#L476">476</span>
-<span id="L477" rel="#L477">477</span>
-<span id="L478" rel="#L478">478</span>
-<span id="L479" rel="#L479">479</span>
-<span id="L480" rel="#L480">480</span>
-<span id="L481" rel="#L481">481</span>
-<span id="L482" rel="#L482">482</span>
-<span id="L483" rel="#L483">483</span>
-<span id="L484" rel="#L484">484</span>
-<span id="L485" rel="#L485">485</span>
-<span id="L486" rel="#L486">486</span>
-</pre>
- </td>
- <td width="100%">
- <div class="highlight"><pre><div class='line' id='LC1'><span class="cm">/*</span></div><div class='line' id='LC2'><span class="cm"> json2.js</span></div><div class='line' id='LC3'><span class="cm"> 2012-10-08</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'><span class="cm"> Public Domain.</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="cm"> NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.</span></div><div class='line' id='LC8'><br/></div><div class='line' id='LC9'><span class="cm"> See http://www.JSON.org/js.html</span></div><div class='line' id='LC10'><br/></div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'><span class="cm"> This code should be minified before deployment.</span></div><div class='line' id='LC13'><span class="cm"> See http://javascript.crockford.com/jsmin.html</span></div><div class='line' id='LC14'><br/></div><div class='line' id='LC15'><span class="cm"> USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO</span></div><div class='line' id='LC16'><span class="cm"> NOT CONTROL.</span></div><div class='line' id='LC17'><br/></div><div class='line' id='LC18'><br/></div><div class='line' id='LC19'><span class="cm"> This file creates a global JSON object containing two methods: stringify</span></div><div class='line' id='LC20'><span class="cm"> and parse.</span></div><div class='line' id='LC21'><br/></div><div class='line' id='LC22'><span class="cm"> JSON.stringify(value, replacer, space)</span></div><div class='line' id='LC23'><span class="cm"> value any JavaScript value, usually an object or array.</span></div><div class='line' id='LC24'><br/></div><div class='line' id='LC25'><span class="cm"> replacer an optional parameter that determines how object</span></div><div class='line' id='LC26'><span class="cm"> values are stringified for objects. It can be a</span></div><div class='line' id='LC27'><span class="cm"> function or an array of strings.</span></div><div class='line' id='LC28'><br/></div><div class='line' id='LC29'><span class="cm"> space an optional parameter that specifies the indentation</span></div><div class='line' id='LC30'><span class="cm"> of nested structures. If it is omitted, the text will</span></div><div class='line' id='LC31'><span class="cm"> be packed without extra whitespace. If it is a number,</span></div><div class='line' id='LC32'><span class="cm"> it will specify the number of spaces to indent at each</span></div><div class='line' id='LC33'><span class="cm"> level. If it is a string (such as &#39;\t&#39; or &#39;&amp;nbsp;&#39;),</span></div><div class='line' id='LC34'><span class="cm"> it contains the characters used to indent at each level.</span></div><div class='line' id='LC35'><br/></div><div class='line' id='LC36'><span class="cm"> This method produces a JSON text from a JavaScript value.</span></div><div class='line' id='LC37'><br/></div><div class='line' id='LC38'><span class="cm"> When an object value is found, if the object contains a toJSON</span></div><div class='line' id='LC39'><span class="cm"> method, its toJSON method will be called and the result will be</span></div><div class='line' id='LC40'><span class="cm"> stringified. A toJSON method does not serialize: it returns the</span></div><div class='line' id='LC41'><span class="cm"> value represented by the name/value pair that should be serialized,</span></div><div class='line' id='LC42'><span class="cm"> or undefined if nothing should be serialized. The toJSON method</span></div><div class='line' id='LC43'><span class="cm"> will be passed the key associated with the value, and this will be</span></div><div class='line' id='LC44'><span class="cm"> bound to the value</span></div><div class='line' id='LC45'><br/></div><div class='line' id='LC46'><span class="cm"> For example, this would serialize Dates as ISO strings.</span></div><div class='line' id='LC47'><br/></div><div class='line' id='LC48'><span class="cm"> Date.prototype.toJSON = function (key) {</span></div><div class='line' id='LC49'><span class="cm"> function f(n) {</span></div><div class='line' id='LC50'><span class="cm"> // Format integers to have at least two digits.</span></div><div class='line' id='LC51'><span class="cm"> return n &lt; 10 ? &#39;0&#39; + n : n;</span></div><div class='line' id='LC52'><span class="cm"> }</span></div><div class='line' id='LC53'><br/></div><div class='line' id='LC54'><span class="cm"> return this.getUTCFullYear() + &#39;-&#39; +</span></div><div class='line' id='LC55'><span class="cm"> f(this.getUTCMonth() + 1) + &#39;-&#39; +</span></div><div class='line' id='LC56'><span class="cm"> f(this.getUTCDate()) + &#39;T&#39; +</span></div><div class='line' id='LC57'><span class="cm"> f(this.getUTCHours()) + &#39;:&#39; +</span></div><div class='line' id='LC58'><span class="cm"> f(this.getUTCMinutes()) + &#39;:&#39; +</span></div><div class='line' id='LC59'><span class="cm"> f(this.getUTCSeconds()) + &#39;Z&#39;;</span></div><div class='line' id='LC60'><span class="cm"> };</span></div><div class='line' id='LC61'><br/></div><div class='line' id='LC62'><span class="cm"> You can provide an optional replacer method. It will be passed the</span></div><div class='line' id='LC63'><span class="cm"> key and value of each member, with this bound to the containing</span></div><div class='line' id='LC64'><span class="cm"> object. The value that is returned from your method will be</span></div><div class='line' id='LC65'><span class="cm"> serialized. If your method returns undefined, then the member will</span></div><div class='line' id='LC66'><span class="cm"> be excluded from the serialization.</span></div><div class='line' id='LC67'><br/></div><div class='line' id='LC68'><span class="cm"> If the replacer parameter is an array of strings, then it will be</span></div><div class='line' id='LC69'><span class="cm"> used to select the members to be serialized. It filters the results</span></div><div class='line' id='LC70'><span class="cm"> such that only members with keys listed in the replacer array are</span></div><div class='line' id='LC71'><span class="cm"> stringified.</span></div><div class='line' id='LC72'><br/></div><div class='line' id='LC73'><span class="cm"> Values that do not have JSON representations, such as undefined or</span></div><div class='line' id='LC74'><span class="cm"> functions, will not be serialized. Such values in objects will be</span></div><div class='line' id='LC75'><span class="cm"> dropped; in arrays they will be replaced with null. You can use</span></div><div class='line' id='LC76'><span class="cm"> a replacer function to replace those with JSON values.</span></div><div class='line' id='LC77'><span class="cm"> JSON.stringify(undefined) returns undefined.</span></div><div class='line' id='LC78'><br/></div><div class='line' id='LC79'><span class="cm"> The optional space parameter produces a stringification of the</span></div><div class='line' id='LC80'><span class="cm"> value that is filled with line breaks and indentation to make it</span></div><div class='line' id='LC81'><span class="cm"> easier to read.</span></div><div class='line' id='LC82'><br/></div><div class='line' id='LC83'><span class="cm"> If the space parameter is a non-empty string, then that string will</span></div><div class='line' id='LC84'><span class="cm"> be used for indentation. If the space parameter is a number, then</span></div><div class='line' id='LC85'><span class="cm"> the indentation will be that many spaces.</span></div><div class='line' id='LC86'><br/></div><div class='line' id='LC87'><span class="cm"> Example:</span></div><div class='line' id='LC88'><br/></div><div class='line' id='LC89'><span class="cm"> text = JSON.stringify([&#39;e&#39;, {pluribus: &#39;unum&#39;}]);</span></div><div class='line' id='LC90'><span class="cm"> // text is &#39;[&quot;e&quot;,{&quot;pluribus&quot;:&quot;unum&quot;}]&#39;</span></div><div class='line' id='LC91'><br/></div><div class='line' id='LC92'><br/></div><div class='line' id='LC93'><span class="cm"> text = JSON.stringify([&#39;e&#39;, {pluribus: &#39;unum&#39;}], null, &#39;\t&#39;);</span></div><div class='line' id='LC94'><span class="cm"> // text is &#39;[\n\t&quot;e&quot;,\n\t{\n\t\t&quot;pluribus&quot;: &quot;unum&quot;\n\t}\n]&#39;</span></div><div class='line' id='LC95'><br/></div><div class='line' id='LC96'><span class="cm"> text = JSON.stringify([new Date()], function (key, value) {</span></div><div class='line' id='LC97'><span class="cm"> return this[key] instanceof Date ?</span></div><div class='line' id='LC98'><span class="cm"> &#39;Date(&#39; + this[key] + &#39;)&#39; : value;</span></div><div class='line' id='LC99'><span class="cm"> });</span></div><div class='line' id='LC100'><span class="cm"> // text is &#39;[&quot;Date(---current time---)&quot;]&#39;</span></div><div class='line' id='LC101'><br/></div><div class='line' id='LC102'><br/></div><div class='line' id='LC103'><span class="cm"> JSON.parse(text, reviver)</span></div><div class='line' id='LC104'><span class="cm"> This method parses a JSON text to produce an object or array.</span></div><div class='line' id='LC105'><span class="cm"> It can throw a SyntaxError exception.</span></div><div class='line' id='LC106'><br/></div><div class='line' id='LC107'><span class="cm"> The optional reviver parameter is a function that can filter and</span></div><div class='line' id='LC108'><span class="cm"> transform the results. It receives each of the keys and values,</span></div><div class='line' id='LC109'><span class="cm"> and its return value is used instead of the original value.</span></div><div class='line' id='LC110'><span class="cm"> If it returns what it received, then the structure is not modified.</span></div><div class='line' id='LC111'><span class="cm"> If it returns undefined then the member is deleted.</span></div><div class='line' id='LC112'><br/></div><div class='line' id='LC113'><span class="cm"> Example:</span></div><div class='line' id='LC114'><br/></div><div class='line' id='LC115'><span class="cm"> // Parse the text. Values that look like ISO date strings will</span></div><div class='line' id='LC116'><span class="cm"> // be converted to Date objects.</span></div><div class='line' id='LC117'><br/></div><div class='line' id='LC118'><span class="cm"> myData = JSON.parse(text, function (key, value) {</span></div><div class='line' id='LC119'><span class="cm"> var a;</span></div><div class='line' id='LC120'><span class="cm"> if (typeof value === &#39;string&#39;) {</span></div><div class='line' id='LC121'><span class="cm"> a =</span></div><div class='line' id='LC122'><span class="cm">/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);</span></div><div class='line' id='LC123'><span class="cm"> if (a) {</span></div><div class='line' id='LC124'><span class="cm"> return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],</span></div><div class='line' id='LC125'><span class="cm"> +a[5], +a[6]));</span></div><div class='line' id='LC126'><span class="cm"> }</span></div><div class='line' id='LC127'><span class="cm"> }</span></div><div class='line' id='LC128'><span class="cm"> return value;</span></div><div class='line' id='LC129'><span class="cm"> });</span></div><div class='line' id='LC130'><br/></div><div class='line' id='LC131'><span class="cm"> myData = JSON.parse(&#39;[&quot;Date(09/09/2001)&quot;]&#39;, function (key, value) {</span></div><div class='line' id='LC132'><span class="cm"> var d;</span></div><div class='line' id='LC133'><span class="cm"> if (typeof value === &#39;string&#39; &amp;&amp;</span></div><div class='line' id='LC134'><span class="cm"> value.slice(0, 5) === &#39;Date(&#39; &amp;&amp;</span></div><div class='line' id='LC135'><span class="cm"> value.slice(-1) === &#39;)&#39;) {</span></div><div class='line' id='LC136'><span class="cm"> d = new Date(value.slice(5, -1));</span></div><div class='line' id='LC137'><span class="cm"> if (d) {</span></div><div class='line' id='LC138'><span class="cm"> return d;</span></div><div class='line' id='LC139'><span class="cm"> }</span></div><div class='line' id='LC140'><span class="cm"> }</span></div><div class='line' id='LC141'><span class="cm"> return value;</span></div><div class='line' id='LC142'><span class="cm"> });</span></div><div class='line' id='LC143'><br/></div><div class='line' id='LC144'><br/></div><div class='line' id='LC145'><span class="cm"> This is a reference implementation. You are free to copy, modify, or</span></div><div class='line' id='LC146'><span class="cm"> redistribute.</span></div><div class='line' id='LC147'><span class="cm">*/</span></div><div class='line' id='LC148'><br/></div><div class='line' id='LC149'><span class="cm">/*jslint evil: true, regexp: true */</span></div><div class='line' id='LC150'><br/></div><div class='line' id='LC151'><span class="cm">/*members &quot;&quot;, &quot;\b&quot;, &quot;\t&quot;, &quot;\n&quot;, &quot;\f&quot;, &quot;\r&quot;, &quot;\&quot;&quot;, JSON, &quot;\\&quot;, apply,</span></div><div class='line' id='LC152'><span class="cm"> call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,</span></div><div class='line' id='LC153'><span class="cm"> getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,</span></div><div class='line' id='LC154'><span class="cm"> lastIndex, length, parse, prototype, push, replace, slice, stringify,</span></div><div class='line' id='LC155'><span class="cm"> test, toJSON, toString, valueOf</span></div><div class='line' id='LC156'><span class="cm">*/</span></div><div class='line' id='LC157'><br/></div><div class='line' id='LC158'><br/></div><div class='line' id='LC159'><span class="c1">// Create a JSON object only if one does not already exist. We create the</span></div><div class='line' id='LC160'><span class="c1">// methods in a closure to avoid creating global variables.</span></div><div class='line' id='LC161'><br/></div><div class='line' id='LC162'><span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">JSON</span> <span class="o">!==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC163'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">JSON</span> <span class="o">=</span> <span class="p">{};</span></div><div class='line' id='LC164'><span class="p">}</span></div><div class='line' id='LC165'><br/></div><div class='line' id='LC166'><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC167'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;use strict&#39;</span><span class="p">;</span></div><div class='line' id='LC168'><br/></div><div class='line' id='LC169'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">function</span> <span class="nx">f</span><span class="p">(</span><span class="nx">n</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC170'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// Format integers to have at least two digits.</span></div><div class='line' id='LC171'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">n</span> <span class="o">&lt;</span> <span class="mi">10</span> <span class="o">?</span> <span class="s1">&#39;0&#39;</span> <span class="o">+</span> <span class="nx">n</span> <span class="o">:</span> <span class="nx">n</span><span class="p">;</span></div><div class='line' id='LC172'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC173'><br/></div><div class='line' id='LC174'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nb">Date</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toJSON</span> <span class="o">!==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC175'><br/></div><div class='line' id='LC176'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">Date</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toJSON</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC177'><br/></div><div class='line' id='LC178'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nb">isFinite</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">valueOf</span><span class="p">())</span></div><div class='line' id='LC179'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="k">this</span><span class="p">.</span><span class="nx">getUTCFullYear</span><span class="p">()</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span></div><div class='line' id='LC180'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">f</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">getUTCMonth</span><span class="p">()</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span></div><div class='line' id='LC181'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">f</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">getUTCDate</span><span class="p">())</span> <span class="o">+</span> <span class="s1">&#39;T&#39;</span> <span class="o">+</span></div><div class='line' id='LC182'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">f</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">getUTCHours</span><span class="p">())</span> <span class="o">+</span> <span class="s1">&#39;:&#39;</span> <span class="o">+</span></div><div class='line' id='LC183'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">f</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">getUTCMinutes</span><span class="p">())</span> <span class="o">+</span> <span class="s1">&#39;:&#39;</span> <span class="o">+</span></div><div class='line' id='LC184'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">f</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">getUTCSeconds</span><span class="p">())</span> <span class="o">+</span> <span class="s1">&#39;Z&#39;</span></div><div class='line' id='LC185'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="kc">null</span><span class="p">;</span></div><div class='line' id='LC186'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">};</span></div><div class='line' id='LC187'><br/></div><div class='line' id='LC188'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">String</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toJSON</span> <span class="o">=</span></div><div class='line' id='LC189'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">Number</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toJSON</span> <span class="o">=</span></div><div class='line' id='LC190'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">Boolean</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toJSON</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC191'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">valueOf</span><span class="p">();</span></div><div class='line' id='LC192'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">};</span></div><div class='line' id='LC193'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC194'><br/></div><div class='line' id='LC195'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">cx</span> <span class="o">=</span> <span class="sr">/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g</span><span class="p">,</span></div><div class='line' id='LC196'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">escapable</span> <span class="o">=</span> <span class="sr">/[\\\&quot;\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g</span><span class="p">,</span></div><div class='line' id='LC197'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">gap</span><span class="p">,</span></div><div class='line' id='LC198'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">indent</span><span class="p">,</span></div><div class='line' id='LC199'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">meta</span> <span class="o">=</span> <span class="p">{</span> <span class="c1">// table of character substitutions</span></div><div class='line' id='LC200'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;\b&#39;</span><span class="o">:</span> <span class="s1">&#39;\\b&#39;</span><span class="p">,</span></div><div class='line' id='LC201'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;\t&#39;</span><span class="o">:</span> <span class="s1">&#39;\\t&#39;</span><span class="p">,</span></div><div class='line' id='LC202'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;\n&#39;</span><span class="o">:</span> <span class="s1">&#39;\\n&#39;</span><span class="p">,</span></div><div class='line' id='LC203'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;\f&#39;</span><span class="o">:</span> <span class="s1">&#39;\\f&#39;</span><span class="p">,</span></div><div class='line' id='LC204'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;\r&#39;</span><span class="o">:</span> <span class="s1">&#39;\\r&#39;</span><span class="p">,</span></div><div class='line' id='LC205'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;&quot;&#39;</span> <span class="o">:</span> <span class="s1">&#39;\\&quot;&#39;</span><span class="p">,</span></div><div class='line' id='LC206'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;\\&#39;</span><span class="o">:</span> <span class="s1">&#39;\\\\&#39;</span></div><div class='line' id='LC207'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">},</span></div><div class='line' id='LC208'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">rep</span><span class="p">;</span></div><div class='line' id='LC209'><br/></div><div class='line' id='LC210'><br/></div><div class='line' id='LC211'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">function</span> <span class="nx">quote</span><span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC212'><br/></div><div class='line' id='LC213'><span class="c1">// If the string contains no control characters, no quote characters, and no</span></div><div class='line' id='LC214'><span class="c1">// backslash characters, then we can safely slap some quotes around it.</span></div><div class='line' id='LC215'><span class="c1">// Otherwise we must also replace the offending characters with safe escape</span></div><div class='line' id='LC216'><span class="c1">// sequences.</span></div><div class='line' id='LC217'><br/></div><div class='line' id='LC218'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">escapable</span><span class="p">.</span><span class="nx">lastIndex</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></div><div class='line' id='LC219'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">escapable</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="o">?</span> <span class="s1">&#39;&quot;&#39;</span> <span class="o">+</span> <span class="nx">string</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">escapable</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">a</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC220'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">meta</span><span class="p">[</span><span class="nx">a</span><span class="p">];</span></div><div class='line' id='LC221'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="k">typeof</span> <span class="nx">c</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span></div><div class='line' id='LC222'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="nx">c</span></div><div class='line' id='LC223'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="s1">&#39;\\u&#39;</span> <span class="o">+</span> <span class="p">(</span><span class="s1">&#39;0000&#39;</span> <span class="o">+</span> <span class="nx">a</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="mi">16</span><span class="p">)).</span><span class="nx">slice</span><span class="p">(</span><span class="o">-</span><span class="mi">4</span><span class="p">);</span></div><div class='line' id='LC224'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">})</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</span> <span class="o">:</span> <span class="s1">&#39;&quot;&#39;</span> <span class="o">+</span> <span class="nx">string</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</span><span class="p">;</span></div><div class='line' id='LC225'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC226'><br/></div><div class='line' id='LC227'><br/></div><div class='line' id='LC228'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">function</span> <span class="nx">str</span><span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">holder</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC229'><br/></div><div class='line' id='LC230'><span class="c1">// Produce a string from holder[key].</span></div><div class='line' id='LC231'><br/></div><div class='line' id='LC232'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="c1">// The loop counter.</span></div><div class='line' id='LC233'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">k</span><span class="p">,</span> <span class="c1">// The member key.</span></div><div class='line' id='LC234'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">v</span><span class="p">,</span> <span class="c1">// The member value.</span></div><div class='line' id='LC235'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">length</span><span class="p">,</span></div><div class='line' id='LC236'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">mind</span> <span class="o">=</span> <span class="nx">gap</span><span class="p">,</span></div><div class='line' id='LC237'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">partial</span><span class="p">,</span></div><div class='line' id='LC238'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">value</span> <span class="o">=</span> <span class="nx">holder</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span></div><div class='line' id='LC239'><br/></div><div class='line' id='LC240'><span class="c1">// If the value has a toJSON method, call it to obtain a replacement value.</span></div><div class='line' id='LC241'><br/></div><div class='line' id='LC242'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">value</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">value</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</span> <span class="o">&amp;&amp;</span></div><div class='line' id='LC243'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">typeof</span> <span class="nx">value</span><span class="p">.</span><span class="nx">toJSON</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC244'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="p">.</span><span class="nx">toJSON</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span></div><div class='line' id='LC245'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC246'><br/></div><div class='line' id='LC247'><span class="c1">// If we were called with a replacer function, then call the replacer to</span></div><div class='line' id='LC248'><span class="c1">// obtain a replacement value.</span></div><div class='line' id='LC249'><br/></div><div class='line' id='LC250'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">rep</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC251'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">value</span> <span class="o">=</span> <span class="nx">rep</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">holder</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span></div><div class='line' id='LC252'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC253'><br/></div><div class='line' id='LC254'><span class="c1">// What happens next depends on the value&#39;s type.</span></div><div class='line' id='LC255'><br/></div><div class='line' id='LC256'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">switch</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC257'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="s1">&#39;string&#39;</span><span class="o">:</span></div><div class='line' id='LC258'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">quote</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span></div><div class='line' id='LC259'><br/></div><div class='line' id='LC260'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="s1">&#39;number&#39;</span><span class="o">:</span></div><div class='line' id='LC261'><br/></div><div class='line' id='LC262'><span class="c1">// JSON numbers must be finite. Encode non-finite numbers as null.</span></div><div class='line' id='LC263'><br/></div><div class='line' id='LC264'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nb">isFinite</span><span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="o">?</span> <span class="nb">String</span><span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="o">:</span> <span class="s1">&#39;null&#39;</span><span class="p">;</span></div><div class='line' id='LC265'><br/></div><div class='line' id='LC266'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="s1">&#39;boolean&#39;</span><span class="o">:</span></div><div class='line' id='LC267'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="s1">&#39;null&#39;</span><span class="o">:</span></div><div class='line' id='LC268'><br/></div><div class='line' id='LC269'><span class="c1">// If the value is a boolean or null, convert it to a string. Note:</span></div><div class='line' id='LC270'><span class="c1">// typeof null does not produce &#39;null&#39;. The case is included here in</span></div><div class='line' id='LC271'><span class="c1">// the remote chance that this gets fixed someday.</span></div><div class='line' id='LC272'><br/></div><div class='line' id='LC273'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nb">String</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span></div><div class='line' id='LC274'><br/></div><div class='line' id='LC275'><span class="c1">// If the type is &#39;object&#39;, we might be dealing with an object or an array or</span></div><div class='line' id='LC276'><span class="c1">// null.</span></div><div class='line' id='LC277'><br/></div><div class='line' id='LC278'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="s1">&#39;object&#39;</span><span class="o">:</span></div><div class='line' id='LC279'><br/></div><div class='line' id='LC280'><span class="c1">// Due to a specification blunder in ECMAScript, typeof null is &#39;object&#39;,</span></div><div class='line' id='LC281'><span class="c1">// so watch out for that case.</span></div><div class='line' id='LC282'><br/></div><div class='line' id='LC283'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">value</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC284'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="s1">&#39;null&#39;</span><span class="p">;</span></div><div class='line' id='LC285'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC286'><br/></div><div class='line' id='LC287'><span class="c1">// Make an array to hold the partial results of stringifying this object value.</span></div><div class='line' id='LC288'><br/></div><div class='line' id='LC289'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">gap</span> <span class="o">+=</span> <span class="nx">indent</span><span class="p">;</span></div><div class='line' id='LC290'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">partial</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC291'><br/></div><div class='line' id='LC292'><span class="c1">// Is the value an array?</span></div><div class='line' id='LC293'><br/></div><div class='line' id='LC294'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toString</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="o">===</span> <span class="s1">&#39;[object Array]&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC295'><br/></div><div class='line' id='LC296'><span class="c1">// The value is an array. Stringify every element. Use null as a placeholder</span></div><div class='line' id='LC297'><span class="c1">// for non-JSON values.</span></div><div class='line' id='LC298'><br/></div><div class='line' id='LC299'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">length</span> <span class="o">=</span> <span class="nx">value</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span></div><div class='line' id='LC300'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC301'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">partial</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="o">||</span> <span class="s1">&#39;null&#39;</span><span class="p">;</span></div><div class='line' id='LC302'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC303'><br/></div><div class='line' id='LC304'><span class="c1">// Join all of the elements together, separated with commas, and wrap them in</span></div><div class='line' id='LC305'><span class="c1">// brackets.</span></div><div class='line' id='LC306'><br/></div><div class='line' id='LC307'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">v</span> <span class="o">=</span> <span class="nx">partial</span><span class="p">.</span><span class="nx">length</span> <span class="o">===</span> <span class="mi">0</span></div><div class='line' id='LC308'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="s1">&#39;[]&#39;</span></div><div class='line' id='LC309'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="nx">gap</span></div><div class='line' id='LC310'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="s1">&#39;[\n&#39;</span> <span class="o">+</span> <span class="nx">gap</span> <span class="o">+</span> <span class="nx">partial</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;,\n&#39;</span> <span class="o">+</span> <span class="nx">gap</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span> <span class="o">+</span> <span class="nx">mind</span> <span class="o">+</span> <span class="s1">&#39;]&#39;</span></div><div class='line' id='LC311'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="s1">&#39;[&#39;</span> <span class="o">+</span> <span class="nx">partial</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;]&#39;</span><span class="p">;</span></div><div class='line' id='LC312'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">gap</span> <span class="o">=</span> <span class="nx">mind</span><span class="p">;</span></div><div class='line' id='LC313'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC314'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC315'><br/></div><div class='line' id='LC316'><span class="c1">// If the replacer is an array, use it to select the members to be stringified.</span></div><div class='line' id='LC317'><br/></div><div class='line' id='LC318'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">rep</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">rep</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC319'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">length</span> <span class="o">=</span> <span class="nx">rep</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span></div><div class='line' id='LC320'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC321'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">rep</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC322'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">k</span> <span class="o">=</span> <span class="nx">rep</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span></div><div class='line' id='LC323'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">v</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span></div><div class='line' id='LC324'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC325'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">partial</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">quote</span><span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="nx">gap</span> <span class="o">?</span> <span class="s1">&#39;: &#39;</span> <span class="o">:</span> <span class="s1">&#39;:&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="nx">v</span><span class="p">);</span></div><div class='line' id='LC326'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC327'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC328'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC329'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC330'><br/></div><div class='line' id='LC331'><span class="c1">// Otherwise, iterate through all of the keys in the object.</span></div><div class='line' id='LC332'><br/></div><div class='line' id='LC333'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">k</span> <span class="k">in</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC334'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">value</span><span class="p">,</span> <span class="nx">k</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC335'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">v</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span></div><div class='line' id='LC336'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC337'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">partial</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">quote</span><span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="nx">gap</span> <span class="o">?</span> <span class="s1">&#39;: &#39;</span> <span class="o">:</span> <span class="s1">&#39;:&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="nx">v</span><span class="p">);</span></div><div class='line' id='LC338'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC339'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC340'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC341'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC342'><br/></div><div class='line' id='LC343'><span class="c1">// Join all of the member texts together, separated with commas,</span></div><div class='line' id='LC344'><span class="c1">// and wrap them in braces.</span></div><div class='line' id='LC345'><br/></div><div class='line' id='LC346'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">v</span> <span class="o">=</span> <span class="nx">partial</span><span class="p">.</span><span class="nx">length</span> <span class="o">===</span> <span class="mi">0</span></div><div class='line' id='LC347'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="s1">&#39;{}&#39;</span></div><div class='line' id='LC348'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="nx">gap</span></div><div class='line' id='LC349'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="s1">&#39;{\n&#39;</span> <span class="o">+</span> <span class="nx">gap</span> <span class="o">+</span> <span class="nx">partial</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;,\n&#39;</span> <span class="o">+</span> <span class="nx">gap</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span> <span class="o">+</span> <span class="nx">mind</span> <span class="o">+</span> <span class="s1">&#39;}&#39;</span></div><div class='line' id='LC350'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="s1">&#39;{&#39;</span> <span class="o">+</span> <span class="nx">partial</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;}&#39;</span><span class="p">;</span></div><div class='line' id='LC351'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">gap</span> <span class="o">=</span> <span class="nx">mind</span><span class="p">;</span></div><div class='line' id='LC352'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC353'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC354'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC355'><br/></div><div class='line' id='LC356'><span class="c1">// If the JSON object does not yet have a stringify method, give it one.</span></div><div class='line' id='LC357'><br/></div><div class='line' id='LC358'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span> <span class="o">!==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC359'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">value</span><span class="p">,</span> <span class="nx">replacer</span><span class="p">,</span> <span class="nx">space</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC360'><br/></div><div class='line' id='LC361'><span class="c1">// The stringify method takes a value and an optional replacer, and an optional</span></div><div class='line' id='LC362'><span class="c1">// space parameter, and returns a JSON text. The replacer can be a function</span></div><div class='line' id='LC363'><span class="c1">// that can replace values, or an array of strings that will select the keys.</span></div><div class='line' id='LC364'><span class="c1">// A default replacer method can be provided. Use of the space parameter can</span></div><div class='line' id='LC365'><span class="c1">// produce text that is more easily readable.</span></div><div class='line' id='LC366'><br/></div><div class='line' id='LC367'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">i</span><span class="p">;</span></div><div class='line' id='LC368'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">gap</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">;</span></div><div class='line' id='LC369'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">indent</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">;</span></div><div class='line' id='LC370'><br/></div><div class='line' id='LC371'><span class="c1">// If the space parameter is a number, make an indent string containing that</span></div><div class='line' id='LC372'><span class="c1">// many spaces.</span></div><div class='line' id='LC373'><br/></div><div class='line' id='LC374'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">space</span> <span class="o">===</span> <span class="s1">&#39;number&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC375'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">space</span><span class="p">;</span> <span class="nx">i</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC376'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">indent</span> <span class="o">+=</span> <span class="s1">&#39; &#39;</span><span class="p">;</span></div><div class='line' id='LC377'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC378'><br/></div><div class='line' id='LC379'><span class="c1">// If the space parameter is a string, it will be used as the indent string.</span></div><div class='line' id='LC380'><br/></div><div class='line' id='LC381'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">space</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC382'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">indent</span> <span class="o">=</span> <span class="nx">space</span><span class="p">;</span></div><div class='line' id='LC383'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC384'><br/></div><div class='line' id='LC385'><span class="c1">// If there is a replacer, it must be a function or an array.</span></div><div class='line' id='LC386'><span class="c1">// Otherwise, throw an error.</span></div><div class='line' id='LC387'><br/></div><div class='line' id='LC388'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">rep</span> <span class="o">=</span> <span class="nx">replacer</span><span class="p">;</span></div><div class='line' id='LC389'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">replacer</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">replacer</span> <span class="o">!==</span> <span class="s1">&#39;function&#39;</span> <span class="o">&amp;&amp;</span></div><div class='line' id='LC390'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">(</span><span class="k">typeof</span> <span class="nx">replacer</span> <span class="o">!==</span> <span class="s1">&#39;object&#39;</span> <span class="o">||</span></div><div class='line' id='LC391'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">typeof</span> <span class="nx">replacer</span><span class="p">.</span><span class="nx">length</span> <span class="o">!==</span> <span class="s1">&#39;number&#39;</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC392'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;JSON.stringify&#39;</span><span class="p">);</span></div><div class='line' id='LC393'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC394'><br/></div><div class='line' id='LC395'><span class="c1">// Make a fake root object containing our value under the key of &#39;&#39;.</span></div><div class='line' id='LC396'><span class="c1">// Return the result of stringifying the value.</span></div><div class='line' id='LC397'><br/></div><div class='line' id='LC398'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">str</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;&#39;</span><span class="o">:</span> <span class="nx">value</span><span class="p">});</span></div><div class='line' id='LC399'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">};</span></div><div class='line' id='LC400'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC401'><br/></div><div class='line' id='LC402'><br/></div><div class='line' id='LC403'><span class="c1">// If the JSON object does not yet have a parse method, give it one.</span></div><div class='line' id='LC404'><br/></div><div class='line' id='LC405'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span> <span class="o">!==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC406'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">text</span><span class="p">,</span> <span class="nx">reviver</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC407'><br/></div><div class='line' id='LC408'><span class="c1">// The parse method takes a text and an optional reviver function, and returns</span></div><div class='line' id='LC409'><span class="c1">// a JavaScript value if the text is a valid JSON text.</span></div><div class='line' id='LC410'><br/></div><div class='line' id='LC411'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">j</span><span class="p">;</span></div><div class='line' id='LC412'><br/></div><div class='line' id='LC413'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">function</span> <span class="nx">walk</span><span class="p">(</span><span class="nx">holder</span><span class="p">,</span> <span class="nx">key</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC414'><br/></div><div class='line' id='LC415'><span class="c1">// The walk method is used to recursively walk the resulting structure so</span></div><div class='line' id='LC416'><span class="c1">// that modifications can be made.</span></div><div class='line' id='LC417'><br/></div><div class='line' id='LC418'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span><span class="p">,</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">holder</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span></div><div class='line' id='LC419'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">value</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">value</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC420'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">k</span> <span class="k">in</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC421'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">value</span><span class="p">,</span> <span class="nx">k</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC422'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">v</span> <span class="o">=</span> <span class="nx">walk</span><span class="p">(</span><span class="nx">value</span><span class="p">,</span> <span class="nx">k</span><span class="p">);</span></div><div class='line' id='LC423'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">v</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC424'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">value</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC425'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC426'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">delete</span> <span class="nx">value</span><span class="p">[</span><span class="nx">k</span><span class="p">];</span></div><div class='line' id='LC427'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC428'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC429'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC430'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC431'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">reviver</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">holder</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span></div><div class='line' id='LC432'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC433'><br/></div><div class='line' id='LC434'><br/></div><div class='line' id='LC435'><span class="c1">// Parsing happens in four stages. In the first stage, we replace certain</span></div><div class='line' id='LC436'><span class="c1">// Unicode characters with escape sequences. JavaScript handles many characters</span></div><div class='line' id='LC437'><span class="c1">// incorrectly, either silently deleting them, or treating them as line endings.</span></div><div class='line' id='LC438'><br/></div><div class='line' id='LC439'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">text</span> <span class="o">=</span> <span class="nb">String</span><span class="p">(</span><span class="nx">text</span><span class="p">);</span></div><div class='line' id='LC440'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">cx</span><span class="p">.</span><span class="nx">lastIndex</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></div><div class='line' id='LC441'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">cx</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">text</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC442'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">text</span> <span class="o">=</span> <span class="nx">text</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">cx</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">a</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC443'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="s1">&#39;\\u&#39;</span> <span class="o">+</span></div><div class='line' id='LC444'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">(</span><span class="s1">&#39;0000&#39;</span> <span class="o">+</span> <span class="nx">a</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="mi">16</span><span class="p">)).</span><span class="nx">slice</span><span class="p">(</span><span class="o">-</span><span class="mi">4</span><span class="p">);</span></div><div class='line' id='LC445'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC446'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC447'><br/></div><div class='line' id='LC448'><span class="c1">// In the second stage, we run the text against regular expressions that look</span></div><div class='line' id='LC449'><span class="c1">// for non-JSON patterns. We are especially concerned with &#39;()&#39; and &#39;new&#39;</span></div><div class='line' id='LC450'><span class="c1">// because they can cause invocation, and &#39;=&#39; because it can cause mutation.</span></div><div class='line' id='LC451'><span class="c1">// But just to be safe, we want to reject all unexpected forms.</span></div><div class='line' id='LC452'><br/></div><div class='line' id='LC453'><span class="c1">// We split the second stage into 4 regexp operations in order to work around</span></div><div class='line' id='LC454'><span class="c1">// crippling inefficiencies in IE&#39;s and Safari&#39;s regexp engines. First we</span></div><div class='line' id='LC455'><span class="c1">// replace the JSON backslash pairs with &#39;@&#39; (a non-JSON character). Second, we</span></div><div class='line' id='LC456'><span class="c1">// replace all simple value tokens with &#39;]&#39; characters. Third, we delete all</span></div><div class='line' id='LC457'><span class="c1">// open brackets that follow a colon or comma or that begin the text. Finally,</span></div><div class='line' id='LC458'><span class="c1">// we look to see that the remaining characters are only whitespace or &#39;]&#39; or</span></div><div class='line' id='LC459'><span class="c1">// &#39;,&#39; or &#39;:&#39; or &#39;{&#39; or &#39;}&#39;. If that is so, then the text is safe for eval.</span></div><div class='line' id='LC460'><br/></div><div class='line' id='LC461'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="sr">/^[\],:{}\s]*$/</span></div><div class='line' id='LC462'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">text</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\\(?:[&quot;\\\/bfnrt]|u[0-9a-fA-F]{4})/g</span><span class="p">,</span> <span class="s1">&#39;@&#39;</span><span class="p">)</span></div><div class='line' id='LC463'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&quot;[^&quot;\\\n\r]*&quot;|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g</span><span class="p">,</span> <span class="s1">&#39;]&#39;</span><span class="p">)</span></div><div class='line' id='LC464'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(?:^|:|,)(?:\s*\[)+/g</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)))</span> <span class="p">{</span></div><div class='line' id='LC465'><br/></div><div class='line' id='LC466'><span class="c1">// In the third stage we use the eval function to compile the text into a</span></div><div class='line' id='LC467'><span class="c1">// JavaScript structure. The &#39;{&#39; operator is subject to a syntactic ambiguity</span></div><div class='line' id='LC468'><span class="c1">// in JavaScript: it can begin a block or an object literal. We wrap the text</span></div><div class='line' id='LC469'><span class="c1">// in parens to eliminate the ambiguity.</span></div><div class='line' id='LC470'><br/></div><div class='line' id='LC471'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">j</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s1">&#39;(&#39;</span> <span class="o">+</span> <span class="nx">text</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</span><span class="p">);</span></div><div class='line' id='LC472'><br/></div><div class='line' id='LC473'><span class="c1">// In the optional fourth stage, we recursively walk the new structure, passing</span></div><div class='line' id='LC474'><span class="c1">// each name/value pair to a reviver function for possible transformation.</span></div><div class='line' id='LC475'><br/></div><div class='line' id='LC476'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="k">typeof</span> <span class="nx">reviver</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span></div><div class='line' id='LC477'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">?</span> <span class="nx">walk</span><span class="p">({</span><span class="s1">&#39;&#39;</span><span class="o">:</span> <span class="nx">j</span><span class="p">},</span> <span class="s1">&#39;&#39;</span><span class="p">)</span></div><div class='line' id='LC478'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">:</span> <span class="nx">j</span><span class="p">;</span></div><div class='line' id='LC479'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC480'><br/></div><div class='line' id='LC481'><span class="c1">// If the text is not JSON parseable, then a SyntaxError is thrown.</span></div><div class='line' id='LC482'><br/></div><div class='line' id='LC483'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">throw</span> <span class="k">new</span> <span class="nx">SyntaxError</span><span class="p">(</span><span class="s1">&#39;JSON.parse&#39;</span><span class="p">);</span></div><div class='line' id='LC484'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">};</span></div><div class='line' id='LC485'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC486'><span class="p">}());</span></div></pre></div>
- </td>
- </tr>
- </table>
- </div>
-
- </div>
- </div>
- </div>
- </div>
-
- </div>
-
-<div class="frame frame-loading large-loading-area" style="display:none;" data-tree-list-url="/douglascrockford/JSON-js/tree-list/43d7836c8ec9b31a02a31ae0c400bdae04d3650d" data-blob-url-prefix="/douglascrockford/JSON-js/blob/43d7836c8ec9b31a02a31ae0c400bdae04d3650d">
- <img src="https://a248.e.akamai.net/assets.github.com/images/spinners/octocat-spinner-128.gif?1347543528" height="64" width="64">
-</div>
-
- </div>
- </div>
- <div class="context-overlay"></div>
- </div>
-
- <div id="footer-push"></div><!-- hack for sticky footer -->
- </div><!-- end of wrapper - hack for sticky footer -->
-
- <!-- footer -->
- <div id="footer" >
-
- <div class="upper_footer">
- <div class="container clearfix">
-
- <!--[if IE]><h4 id="blacktocat_ie">GitHub Links</h4><![endif]-->
- <![if !IE]><h4 id="blacktocat">GitHub Links</h4><![endif]>
-
- <ul class="footer_nav">
- <h4>GitHub</h4>
- <li><a href="https://github.com/about">About</a></li>
- <li><a href="https://github.com/blog">Blog</a></li>
- <li><a href="https://github.com/features">Features</a></li>
- <li><a href="https://github.com/contact">Contact &amp; Support</a></li>
- <li><a href="http://training.github.com/">Training</a></li>
- <li><a href="http://enterprise.github.com/">GitHub Enterprise</a></li>
- <li><a href="http://status.github.com/">Site Status</a></li>
- </ul>
-
- <ul class="footer_nav">
- <h4>Clients</h4>
- <li><a href="http://mac.github.com/">GitHub for Mac</a></li>
- <li><a href="http://windows.github.com/">GitHub for Windows</a></li>
- <li><a href="http://eclipse.github.com/">GitHub for Eclipse</a></li>
- <li><a href="http://mobile.github.com/">GitHub Mobile Apps</a></li>
- </ul>
-
- <ul class="footer_nav">
- <h4>Tools</h4>
- <li><a href="http://get.gaug.es/">Gauges: Web analytics</a></li>
- <li><a href="http://speakerdeck.com">Speaker Deck: Presentations</a></li>
- <li><a href="https://gist.github.com">Gist: Code snippets</a></li>
-
- <h4 class="second">Extras</h4>
- <li><a href="http://jobs.github.com/">Job Board</a></li>
- <li><a href="http://shop.github.com/">GitHub Shop</a></li>
- <li><a href="http://octodex.github.com/">The Octodex</a></li>
- </ul>
-
- <ul class="footer_nav">
- <h4>Documentation</h4>
- <li><a href="http://help.github.com/">GitHub Help</a></li>
- <li><a href="http://developer.github.com/">Developer API</a></li>
- <li><a href="http://github.github.com/github-flavored-markdown/">GitHub Flavored Markdown</a></li>
- <li><a href="http://pages.github.com/">GitHub Pages</a></li>
- </ul>
-
- </div><!-- /.site -->
- </div><!-- /.upper_footer -->
-
-<div class="lower_footer">
- <div class="container clearfix">
- <!--[if IE]><div id="legal_ie"><![endif]-->
- <![if !IE]><div id="legal"><![endif]>
- <ul>
- <li><a href="https://github.com/site/terms">Terms of Service</a></li>
- <li><a href="https://github.com/site/privacy">Privacy</a></li>
- <li><a href="https://github.com/security">Security</a></li>
- </ul>
-
- <p>&copy; 2012 <span title="0.04484s from fe1.rs.github.com">GitHub</span> Inc. All rights reserved.</p>
- </div><!-- /#legal or /#legal_ie-->
-
- </div><!-- /.site -->
-</div><!-- /.lower_footer -->
-
-
- </div><!-- /#footer -->
-
-
-
-<div id="keyboard_shortcuts_pane" class="instapaper_ignore readability-extra" style="display:none">
- <h2>Keyboard Shortcuts <small><a href="#" class="js-see-all-keyboard-shortcuts">(see all)</a></small></h2>
-
- <div class="columns threecols">
- <div class="column first">
- <h3>Site wide shortcuts</h3>
- <dl class="keyboard-mappings">
- <dt>s</dt>
- <dd>Focus command bar</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>?</dt>
- <dd>Bring up this help dialog</dd>
- </dl>
- </div><!-- /.column.first -->
-
- <div class="column middle" style='display:none'>
- <h3>Commit list</h3>
- <dl class="keyboard-mappings">
- <dt>j</dt>
- <dd>Move selection down</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>k</dt>
- <dd>Move selection up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>c <em>or</em> o <em>or</em> enter</dt>
- <dd>Open commit</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>y</dt>
- <dd>Expand URL to its canonical form</dd>
- </dl>
- </div><!-- /.column.first -->
-
- <div class="column last js-hidden-pane" style='display:none'>
- <h3>Pull request list</h3>
- <dl class="keyboard-mappings">
- <dt>j</dt>
- <dd>Move selection down</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>k</dt>
- <dd>Move selection up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>o <em>or</em> enter</dt>
- <dd>Open issue</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="platform-mac">⌘</span><span class="platform-other">ctrl</span> <em>+</em> enter</dt>
- <dd>Submit comment</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="platform-mac">⌘</span><span class="platform-other">ctrl</span> <em>+</em> shift p</dt>
- <dd>Preview comment</dd>
- </dl>
- </div><!-- /.columns.last -->
-
- </div><!-- /.columns.equacols -->
-
- <div class="js-hidden-pane" style='display:none'>
- <div class="rule"></div>
-
- <h3>Issues</h3>
-
- <div class="columns threecols">
- <div class="column first">
- <dl class="keyboard-mappings">
- <dt>j</dt>
- <dd>Move selection down</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>k</dt>
- <dd>Move selection up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>x</dt>
- <dd>Toggle selection</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>o <em>or</em> enter</dt>
- <dd>Open issue</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="platform-mac">⌘</span><span class="platform-other">ctrl</span> <em>+</em> enter</dt>
- <dd>Submit comment</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="platform-mac">⌘</span><span class="platform-other">ctrl</span> <em>+</em> shift p</dt>
- <dd>Preview comment</dd>
- </dl>
- </div><!-- /.column.first -->
- <div class="column last">
- <dl class="keyboard-mappings">
- <dt>c</dt>
- <dd>Create issue</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>l</dt>
- <dd>Create label</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>i</dt>
- <dd>Back to inbox</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>u</dt>
- <dd>Back to issues</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>/</dt>
- <dd>Focus issues search</dd>
- </dl>
- </div>
- </div>
- </div>
-
- <div class="js-hidden-pane" style='display:none'>
- <div class="rule"></div>
-
- <h3>Issues Dashboard</h3>
-
- <div class="columns threecols">
- <div class="column first">
- <dl class="keyboard-mappings">
- <dt>j</dt>
- <dd>Move selection down</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>k</dt>
- <dd>Move selection up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>o <em>or</em> enter</dt>
- <dd>Open issue</dd>
- </dl>
- </div><!-- /.column.first -->
- </div>
- </div>
-
- <div class="js-hidden-pane" style='display:none'>
- <div class="rule"></div>
-
- <h3>Network Graph</h3>
- <div class="columns equacols">
- <div class="column first">
- <dl class="keyboard-mappings">
- <dt><span class="badmono">←</span> <em>or</em> h</dt>
- <dd>Scroll left</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="badmono">→</span> <em>or</em> l</dt>
- <dd>Scroll right</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="badmono">↑</span> <em>or</em> k</dt>
- <dd>Scroll up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt><span class="badmono">↓</span> <em>or</em> j</dt>
- <dd>Scroll down</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>t</dt>
- <dd>Toggle visibility of head labels</dd>
- </dl>
- </div><!-- /.column.first -->
- <div class="column last">
- <dl class="keyboard-mappings">
- <dt>shift <span class="badmono">←</span> <em>or</em> shift h</dt>
- <dd>Scroll all the way left</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>shift <span class="badmono">→</span> <em>or</em> shift l</dt>
- <dd>Scroll all the way right</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>shift <span class="badmono">↑</span> <em>or</em> shift k</dt>
- <dd>Scroll all the way up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>shift <span class="badmono">↓</span> <em>or</em> shift j</dt>
- <dd>Scroll all the way down</dd>
- </dl>
- </div><!-- /.column.last -->
- </div>
- </div>
-
- <div class="js-hidden-pane" >
- <div class="rule"></div>
- <div class="columns threecols">
- <div class="column first js-hidden-pane" >
- <h3>Source Code Browsing</h3>
- <dl class="keyboard-mappings">
- <dt>t</dt>
- <dd>Activates the file finder</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>l</dt>
- <dd>Jump to line</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>w</dt>
- <dd>Switch branch/tag</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>y</dt>
- <dd>Expand URL to its canonical form</dd>
- </dl>
- </div>
- </div>
- </div>
-
- <div class="js-hidden-pane" style='display:none'>
- <div class="rule"></div>
- <div class="columns threecols">
- <div class="column first">
- <h3>Browsing Commits</h3>
- <dl class="keyboard-mappings">
- <dt><span class="platform-mac">⌘</span><span class="platform-other">ctrl</span> <em>+</em> enter</dt>
- <dd>Submit comment</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>escape</dt>
- <dd>Close form</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>p</dt>
- <dd>Parent commit</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>o</dt>
- <dd>Other parent commit</dd>
- </dl>
- </div>
- </div>
- </div>
-
- <div class="js-hidden-pane" style='display:none'>
- <div class="rule"></div>
- <h3>Notifications</h3>
-
- <div class="columns threecols">
- <div class="column first">
- <dl class="keyboard-mappings">
- <dt>j</dt>
- <dd>Move selection down</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>k</dt>
- <dd>Move selection up</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>o <em>or</em> enter</dt>
- <dd>Open notification</dd>
- </dl>
- </div><!-- /.column.first -->
-
- <div class="column second">
- <dl class="keyboard-mappings">
- <dt>e <em>or</em> shift i <em>or</em> y</dt>
- <dd>Mark as read</dd>
- </dl>
- <dl class="keyboard-mappings">
- <dt>shift m</dt>
- <dd>Mute thread</dd>
- </dl>
- </div><!-- /.column.first -->
- </div>
- </div>
-
-</div>
-
- <div id="markdown-help" class="instapaper_ignore readability-extra">
- <h2>Markdown Cheat Sheet</h2>
-
- <div class="cheatsheet-content">
-
- <div class="mod">
- <div class="col">
- <h3>Format Text</h3>
- <p>Headers</p>
- <pre>
-# This is an &lt;h1&gt; tag
-## This is an &lt;h2&gt; tag
-###### This is an &lt;h6&gt; tag</pre>
- <p>Text styles</p>
- <pre>
-*This text will be italic*
-_This will also be italic_
-**This text will be bold**
-__This will also be bold__
-
-*You **can** combine them*
-</pre>
- </div>
- <div class="col">
- <h3>Lists</h3>
- <p>Unordered</p>
- <pre>
-* Item 1
-* Item 2
- * Item 2a
- * Item 2b</pre>
- <p>Ordered</p>
- <pre>
-1. Item 1
-2. Item 2
-3. Item 3
- * Item 3a
- * Item 3b</pre>
- </div>
- <div class="col">
- <h3>Miscellaneous</h3>
- <p>Images</p>
- <pre>
-![GitHub Logo](/images/logo.png)
-Format: ![Alt Text](url)
-</pre>
- <p>Links</p>
- <pre>
-http://github.com - automatic!
-[GitHub](http://github.com)</pre>
-<p>Blockquotes</p>
- <pre>
-As Kanye West said:
-
-> We're living the future so
-> the present is our past.
-</pre>
- </div>
- </div>
- <div class="rule"></div>
-
- <h3>Code Examples in Markdown</h3>
- <div class="col">
- <p>Syntax highlighting with <a href="http://github.github.com/github-flavored-markdown/" title="GitHub Flavored Markdown" target="_blank">GFM</a></p>
- <pre>
-```javascript
-function fancyAlert(arg) {
- if(arg) {
- $.facebox({div:'#foo'})
- }
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, regexp: true */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+if (typeof JSON !== 'object') {
+ JSON = {};
}
-```</pre>
- </div>
- <div class="col">
- <p>Or, indent your code 4 spaces</p>
- <pre>
-Here is a Python code example
-without syntax highlighting:
-
- def foo:
- if not bar:
- return true</pre>
- </div>
- <div class="col">
- <p>Inline code for comments</p>
- <pre>
-I think you should use an
-`&lt;addr&gt;` element here instead.</pre>
- </div>
- </div>
-
- </div>
-</div>
-
-
- <div id="ajax-error-message" class="flash flash-error">
- <span class="mini-icon mini-icon-exclamation"></span>
- Something went wrong with that request. Please try again.
- <a href="#" class="mini-icon mini-icon-remove-close ajax-error-dismiss"></a>
- </div>
-
- <div id="logo-popup">
- <h2>Looking for the GitHub logo?</h2>
- <ul>
- <li>
- <h4>GitHub Logo</h4>
- <a href="http://github-media-downloads.s3.amazonaws.com/GitHub_Logos.zip"><img alt="Github_logo" src="https://a248.e.akamai.net/assets.github.com/images/modules/about_page/github_logo.png?1338956357" /></a>
- <a href="http://github-media-downloads.s3.amazonaws.com/GitHub_Logos.zip" class="minibutton download">Download</a>
- </li>
- <li>
- <h4>The Octocat</h4>
- <a href="http://github-media-downloads.s3.amazonaws.com/Octocats.zip"><img alt="Octocat" src="https://a248.e.akamai.net/assets.github.com/images/modules/about_page/octocat.png?1338956357" /></a>
- <a href="http://github-media-downloads.s3.amazonaws.com/Octocats.zip" class="minibutton download">Download</a>
- </li>
- </ul>
- </div>
-
-
-
- <span id='server_response_time' data-time='0.04627' data-host='fe1'></span>
-
- </body>
-</html>
+(function () {
+ 'use strict';
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf())
+ ? this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z'
+ : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string'
+ ? c
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0
+ ? '[]'
+ : gap
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+ : '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0
+ ? '{}'
+ : gap
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+ : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function'
+ ? walk({'': j}, '')
+ : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
diff --git a/wqflask/wqflask/templates/new_index_page.html b/wqflask/wqflask/templates/new_index_page.html
index 687cf8b2..51d963fc 100644
--- a/wqflask/wqflask/templates/new_index_page.html
+++ b/wqflask/wqflask/templates/new_index_page.html
@@ -96,8 +96,7 @@
<label for="group">Group: </label>
<select name="group" id="group" class="input-xlarge ds_selector"></select>
<!--<i class="icon-question-sign"></i>-->
- <input type="button" class="btn" value="Info" onclick=
- "javascript:crossinfo();" />
+ <input type="button" class="btn" value="Info" id="group_info" />
</div>
@@ -107,7 +106,7 @@
<div class="input-append">
<label for="dataset">Dataset:</label>
<select name="dataset" id="dataset" class="input-xlarge"></select>
- <input type="button" class="btn" value="Info" name="info_dataset ds_selector" />
+ <input type="button" class="btn" value="Info" id="dataset_info" />
</div>
<!-- USER HELP -->
@@ -140,9 +139,8 @@
<input id="btsearch" type="submit"
class="btn btn-primary" value="Search">
- <input type=
- "button" class="btn" value="Make Default" onclick=
- "setDefault(this.form);">
+ <input type="button" class="btn" value="Make Default"
+ id="make_default">
<input type="button" class=
"btn" value="Advanced Search" onclick=
@@ -348,7 +346,8 @@
<A HREF="mailto:acenteno@uthsc.edu" target="_blank">Arthur Centeno</A>.
</p>
<p>
- Designed and coded by Sam Ockman, Xiaodong Zhou, Christian Fernandez,
+ Designed and coded by <a href="http://penguinpython.com">Sam Ockman</a>, Xiaodong Zhou,
+ Christian Fernandez,
Ning Liu, Rudi Alberts, Elissa Chesler, Jintao Wang, Kenneth Manly, Robert W. Williams,
and <A HREF="/credit.html">colleagues</A>.
</p>
@@ -409,6 +408,8 @@
<!--<SCRIPT SRC="/javascript/webqtl.js"></SCRIPT>-->
<!--<script src="/static/new/javascript/dataset_menu_structure.json"></script>-->
<!--<script src="/static/new/javascript/dataset_select_items.js"></script>-->
+ <script src="/static/new/js_external/jquery.cookie.js"></script>
+ <script type="text/javascript" src="/static/new/js_external/json2.js"></script>
<script src="/static/new/javascript/dataset_select_menu.js"></script>
</body>
</html>