aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Sloan2012-10-11 16:56:01 -0500
committerZachary Sloan2012-10-11 16:56:01 -0500
commit8f5a9ab89a77890ee620bed882fcecff63594392 (patch)
treeae6146830f34a8167e4138f05518f4e883567c06
parentaf76cb26cba75684928fb817f9486883fad11eb9 (diff)
downloadgenenetwork2-8f5a9ab89a77890ee620bed882fcecff63594392.tar.gz
Got sample table data from the trait page sent to the export python code
-rw-r--r--wqflask/wqflask/show_trait/export_trait_data.py15
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py243
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.coffee51
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js49
-rw-r--r--wqflask/wqflask/static/new/js_external/json2.js1298
-rw-r--r--wqflask/wqflask/templates/new_index_page.html85
-rw-r--r--wqflask/wqflask/templates/show_trait.html1
-rw-r--r--wqflask/wqflask/views.py14
8 files changed, 1719 insertions, 37 deletions
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py
new file mode 100644
index 00000000..7c77f1c1
--- /dev/null
+++ b/wqflask/wqflask/show_trait/export_trait_data.py
@@ -0,0 +1,15 @@
+from __future__ import print_function, division
+
+import simplejson as json
+
+#import xlwt
+from pprint import pformat as pf
+
+def export_sample_table(targs):
+ #print("* keys0 args is:", targs[0].keys())
+
+ for key, item in targs.iteritems():
+ print("[arrow] key is:", key)
+
+ sample_data = json.loads(targs['json_data'])
+ print("sample_data is:", pf(sample_data)) \ No newline at end of file
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 9b47f658..942ce336 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -146,7 +146,7 @@ class ShowTrait(templatePage):
self.make_sample_lists(fd, variance_data_page, this_trait)
-
+
if fd.allsamplelist:
hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ')
@@ -161,9 +161,7 @@ class ShowTrait(templatePage):
self.sample_group_types['primary_only'] = fd.RISet + " Only"
self.sample_group_types['other_only'] = "Non-" + fd.RISet
self.sample_group_types['all_cases'] = "All Cases"
- sample_lists = []
- for group in self.sample_groups:
- sample_lists.append(group.sample_list)
+ sample_lists = [group.sample_list for group in self.sample_groups]
print("sample_lists is:", pf(sample_lists))
js_data = dict(sample_group_types = self.sample_group_types,
sample_lists = sample_lists,
@@ -182,7 +180,7 @@ class ShowTrait(templatePage):
cell_id = self.fd.get('CellID')
this_trait = webqtlTrait(db=database, name=probe_set_id, cellid=cell_id, cursor=self.cursor)
-
+
##identification, etc.
self.fd.identification = '%s : %s' % (this_trait.db.shortname, probe_set_id)
this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\
@@ -195,12 +193,14 @@ class ShowTrait(templatePage):
this_trait.retrieveInfo()
this_trait.retrieveData()
return this_trait
-
+
def dispTraitInformation(self, fd, title1Body, hddn, this_trait):
_Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet)
+ #tbl = HT.TableLite(cellpadding=2, Class="collap", style="margin-left:20px;", width="840", valign="top", id="target1")
+
#reset=HT.Input(type='Reset',name='',value=' Reset ',Class="button")
#XZ, August 02, 2011: The display of icons is decided by the trait type (if trait exists), along with user log-in status. Note that the new submitted trait might not be trait object.
@@ -800,12 +800,9 @@ class ShowTrait(templatePage):
def dispBasicStatistics(self, fd, this_trait):
- #XZ, June 22, 2011: The definition and usage of primary_samples, other_samples,
- #specialStrains, all_samples are not clear and hard to understand. But since they are
- #only used in this function for draw graph purpose, they will not hurt the business logic
- #outside. As of June 21, 2011, this function seems work fine, so no hurry to clean up.
- #These parameters and code in this function should be cleaned along with fd.f1list,
- #fd.parlist, fd.samplelist later.
+ #XZ, June 22, 2011: The definition and usage of primary_samples, other_samples, specialStrains, all_samples are not clear and hard to understand. But since they are only used in this function for draw graph purpose, they will not hurt the business logic outside. As of June 21, 2011, this function seems work fine, so no hurry to clean up. These parameters and code in this function should be cleaned along with fd.f1list, fd.parlist, fd.samplelist later.
+ #stats_row = HT.TR()
+ #stats_cell = HT.TD()
if fd.genotype.type == "riset":
samplelist = fd.f1list + fd.samplelist
@@ -817,6 +814,7 @@ class ShowTrait(templatePage):
all_samples = []
primary_samples = [] #XZ: sample of primary group, e.g., BXD, LXS
+ #self.MDP_menu = HT.Select(name='stats_mdp', Class='stats_mdp')
self.MDP_menu = [] # We're going to use the same named data structure as in the old version
# but repurpose it for Jinja2 as an array
@@ -827,15 +825,10 @@ class ShowTrait(templatePage):
if sample.find('F1') < 0:
specialStrains.append(sample)
if (this_trait.data[sampleName].value != None) and (sample not in (fd.f1list + fd.parlist)):
- #XZ: at current stage, other_samples doesn't include parent samples and
- #F1 samples of primary group
- other_samples.append(sample)
+ other_samples.append(sample) #XZ: at current stage, other_samples doesn't include parent samples and F1 samples of primary group
else:
if (this_trait.data[sampleName].value != None) and (sample not in (fd.f1list + fd.parlist)):
- #XZ: at current stage, the primary_samples is the same as fd.samplelist
- #ZS: I tried defining primary_samples as fd.samplelist instead, but in some
- #cases it ended up including the parent samples (1436869_at BXD)
- primary_samples.append(sample)
+ primary_samples.append(sample) #XZ: at current stage, the primary_samples is the same as fd.samplelist / ZS: I tried defining primary_samples as fd.samplelist instead, but in some cases it ended up including the parent samples (1436869_at BXD)
if len(other_samples) > 3:
other_samples.sort(key=webqtlUtil.natsort_key)
@@ -843,6 +836,7 @@ class ShowTrait(templatePage):
primary_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_samples #XZ: note that fd.f1list and fd.parlist are added.
all_samples = primary_samples + other_samples
other_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_samples #XZ: note that fd.f1list and fd.parlist are added.
+ print("ac1") # This is the one used for first sall3
self.MDP_menu.append(('All Cases','0'))
self.MDP_menu.append(('%s Only' % fd.RISet, '1'))
self.MDP_menu.append(('Non-%s Only' % fd.RISet, '2'))
@@ -858,6 +852,7 @@ class ShowTrait(templatePage):
all_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + all_samples
primary_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_samples
else:
+ print("ac3")
all_samples = samplelist
other_samples.sort(key=webqtlUtil.natsort_key)
@@ -891,6 +886,13 @@ class ShowTrait(templatePage):
# continue
vals1.append(thisValFull)
+
+
+ #vals1 = [[sampleNameOrig.replace("_2nd_", ""),
+ # this_trait.data[sampleName].val,
+ # this_trait.data[sampleName].var]
+ # for sampleNameOrig in all_samples]]
+ #
#Using just the RISet sample
for sampleNameOrig in primary_samples:
@@ -943,21 +945,29 @@ class ShowTrait(templatePage):
if i == 0 and len(vals) < 4:
stats_container = HT.Div(id="stats_tabs", style="padding:10px;", Class="ui-tabs") #Needed for tabs; notice the "stats_script_text" below referring to this element
stats_container.append(HT.Div(HT.Italic("Fewer than 4 case data were entered. No statistical analysis has been attempted.")))
- stats_script_text = """$(function() { $("#stats_tabs").tabs();});"""
+ #stats_script_text = """$(function() { $("#stats_tabs").tabs();});"""
+ #stats_cell.append(stats_container)
break
elif (i == 1 and len(primary_samples) < 4):
stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs")
- stats_container.append(HT.Div(HT.Italic("Fewer than 4 " + fd.RISet + " case data were entered. No statistical analysis has been attempted.")))
+ #stats_container.append(HT.Div(HT.Italic("Fewer than 4 " + fd.RISet + " case data were entered. No statistical analysis has been attempted.")))
elif (i == 2 and len(other_samples) < 4):
stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs")
stats_container.append(HT.Div(HT.Italic("Fewer than 4 non-" + fd.RISet + " case data were entered. No statistical analysis has been attempted.")))
- stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});"""
+ #stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});"""
else:
- stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});"""
+ continue
if len(vals) > 4:
stats_tab_list = [HT.Href(text="Basic Table", url="#statstabs-1", Class="stats_tab"),HT.Href(text="Probability Plot", url="#statstabs-5", Class="stats_tab"),
HT.Href(text="Bar Graph (by name)", url="#statstabs-3", Class="stats_tab"), HT.Href(text="Bar Graph (by rank)", url="#statstabs-4", Class="stats_tab"),
HT.Href(text="Box Plot", url="#statstabs-2", Class="stats_tab")]
+ #stats_tabs = HT.List(stats_tab_list)
+ #stats_container.append(stats_tabs)
+ #
+ #table_div = HT.Div(id="statstabs-1")
+ #table_container = HT.Paragraph()
+ #
+ #statsTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
if this_trait.db:
if this_trait.cellid:
@@ -967,6 +977,16 @@ class ShowTrait(templatePage):
else:
self.stats_data.append(BasicStatisticsFunctions.basicStatsTable(vals=vals))
+ #statsTable.append(HT.TR(HT.TD(statsTableCell)))
+
+ #table_container.append(statsTable)
+ #table_div.append(table_container)
+ #stats_container.append(table_div)
+ #
+ #normalplot_div = HT.Div(id="statstabs-5")
+ #normalplot_container = HT.Paragraph()
+ #normalplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+
try:
plotTitle = this_trait.symbol
plotTitle += ": "
@@ -983,7 +1003,7 @@ class ShowTrait(templatePage):
#normalplot_container.append(normalplot)
#normalplot_div.append(normalplot_container)
#stats_container.append(normalplot_div)
-
+
#boxplot_div = HT.Div(id="statstabs-2")
#boxplot_container = HT.Paragraph()
#boxplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
@@ -992,8 +1012,8 @@ class ShowTrait(templatePage):
#boxplot_container.append(boxplot)
#boxplot_div.append(boxplot_container)
#stats_container.append(boxplot_div)
-
-
+
+
#barName_div = HT.Div(id="statstabs-3")
#barName_container = HT.Paragraph()
#barName = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
@@ -1011,6 +1031,18 @@ class ShowTrait(templatePage):
#barRank_container.append(barRank)
#barRank_div.append(barRank_container)
#stats_container.append(barRank_div)
+
+ # stats_cell.append(stats_container)
+ #
+ #stats_script.append(stats_script_text)
+ #
+ #submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2")
+ #stats_row.append(stats_cell)
+
+ #submitTable.append(stats_row)
+ #submitTable.append(stats_script)
+
+ #title2Body.append(submitTable)
def build_correlation_tools(self, fd, this_trait):
@@ -1018,13 +1050,23 @@ class ShowTrait(templatePage):
#species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet)
RISetgp = fd.RISet
-
+
# We're checking a string here!
assert isinstance(RISetgp, basestring), "We need a string type thing here"
if RISetgp[:3] == 'BXD':
RISetgp = 'BXD'
if RISetgp:
+ #sample_correlation = HT.Input(type='button',name='sample_corr', value=' Compute ', Class="button sample_corr")
+ #lit_correlation = HT.Input(type='button',name='lit_corr', value=' Compute ', Class="button lit_corr")
+ #tissue_correlation = HT.Input(type='button',name='tiss_corr', value=' Compute ', Class="button tiss_corr")
+ #methodText = HT.Span("Calculate:", Class="ffl fwb fs12")
+ #
+ #databaseText = HT.Span("Database:", Class="ffl fwb fs12")
+ #databaseMenu1 = HT.Select(name='database1')
+ #databaseMenu2 = HT.Select(name='database2')
+ #databaseMenu3 = HT.Select(name='database3')
+
dataset_menu = []
print("[tape4] webqtlConfig.PUBLICTHRESH:", webqtlConfig.PUBLICTHRESH)
print("[tape4] type webqtlConfig.PUBLICTHRESH:", type(webqtlConfig.PUBLICTHRESH))
@@ -1048,24 +1090,164 @@ class ShowTrait(templatePage):
self.cursor.execute('SELECT Id, Name FROM Tissue order by Name')
for item in self.cursor.fetchall():
tissue_id, tissue_name = item
+ #databaseMenuSub = HT.Optgroup(label = '%s ------' % tissue_name)
+ #dataset_sub_menu = []
+ print("phun9")
self.cursor.execute('''SELECT ProbeSetFreeze.FullName,ProbeSetFreeze.Name FROM ProbeSetFreeze, ProbeFreeze,
InbredSet WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeFreeze.TissueId = %s and
ProbeSetFreeze.public > %s and ProbeFreeze.InbredSetId = InbredSet.Id and InbredSet.Name like %s
order by ProbeSetFreeze.CreateTime desc, ProbeSetFreeze.AvgId ''',
(tissue_id, webqtlConfig.PUBLICTHRESH, "%" + RISetgp + "%"))
+ print("phun8")
dataset_sub_menu = [item for item in self.cursor.fetchall() if item]
+ #for item2 in self.cursor.fetchall():
+ # dataset_sub_menu.append(item2)
if dataset_sub_menu:
dataset_menu.append(dict(tissue=tissue_name,
datasets=dataset_sub_menu))
-
+ # ("**heading**", tissue_name))
+ #dataset_menu.append(dataset_sub_menu)
+
dataset_menu_selected = None
if len(dataset_menu):
if this_trait and this_trait.db:
dataset_menu_selected = this_trait.db.name
+ #criteriaText = HT.Span("Return:", Class="ffl fwb fs12")
+
+ #criteriaMenu1 = HT.Select(name='criteria1', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);")
+
return_results_menu = (100, 200, 500, 1000, 2000, 5000, 10000, 15000, 20000)
return_results_menu_selected = 500
+
+ #criteriaMenu1.append(('top 100','100'))
+ #criteriaMenu1.append(('top 200','200'))
+ #criteriaMenu1.append(('top 500','500'))
+ #criteriaMenu1.append(('top 1000','1000'))
+ #criteriaMenu1.append(('top 2000','2000'))
+ #criteriaMenu1.append(('top 5000','5000'))
+ #criteriaMenu1.append(('top 10000','10000'))
+ #criteriaMenu1.append(('top 15000','15000'))
+ #criteriaMenu1.append(('top 20000','20000'))
+
+ #self.MDPRow1 = HT.TR(Class='mdp1')
+ #self.MDPRow2 = HT.TR(Class='mdp2')
+ #self.MDPRow3 = HT.TR(Class='mdp3')
+
+ # correlationMenus1 = HT.TableLite(
+ # HT.TR(HT.TD(databaseText), HT.TD(databaseMenu1, colspan="3")),
+ # HT.TR(HT.TD(criteriaText), HT.TD(criteriaMenu1)),
+ # self.MDPRow1, cellspacing=0, width="619px", cellpadding=2)
+ # correlationMenus1.append(HT.Input(name='orderBy', value='2', type='hidden')) # to replace the orderBy menu
+ # correlationMenus2 = HT.TableLite(
+ # HT.TR(HT.TD(databaseText), HT.TD(databaseMenu2, colspan="3")),
+ # HT.TR(HT.TD(criteriaText), HT.TD(criteriaMenu2)),
+ # self.MDPRow2, cellspacing=0, width="619px", cellpadding=2)
+ # correlationMenus2.append(HT.Input(name='orderBy', value='2', type='hidden'))
+ # correlationMenus3 = HT.TableLite(
+ # HT.TR(HT.TD(databaseText), HT.TD(databaseMenu3, colspan="3")),
+ # HT.TR(HT.TD(criteriaText), HT.TD(criteriaMenu3)),
+ # self.MDPRow3, cellspacing=0, width="619px", cellpadding=2)
+ # correlationMenus3.append(HT.Input(name='orderBy', value='2', type='hidden'))
+ #
+ #else:
+ # correlationMenus = ""
+
+ #corr_row = HT.TR()
+ #corr_container = HT.Div(id="corr_tabs", Class="ui-tabs")
+ #
+ #if (this_trait.db != None and this_trait.db.type =='ProbeSet'):
+ # corr_tab_list = [HT.Href(text='Sample r', url="#corrtabs-1"),
+ # HT.Href(text='Literature r', url="#corrtabs-2"),
+ # HT.Href(text='Tissue r', url="#corrtabs-3")]
+ #else:
+ # corr_tab_list = [HT.Href(text='Sample r', url="#corrtabs-1")]
+ #
+ #corr_tabs = HT.List(corr_tab_list)
+ #corr_container.append(corr_tabs)
+
+ #if correlationMenus1 or correlationMenus2 or correlationMenus3:
+ #sample_div = HT.Div(id="corrtabs-1")
+ #sample_container = HT.Span()
+ #
+ #sample_type = HT.Input(type="radio", name="sample_method", value="1", checked="checked")
+ #sample_type2 = HT.Input(type="radio", name="sample_method", value="2")
+ #
+ #sampleTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+ #sampleTD = HT.TD(correlationMenus1, HT.BR(),
+ # "Pearson", sample_type, "&nbsp;"*3, "Spearman Rank", sample_type2, HT.BR(), HT.BR(),
+ # sample_correlation, HT.BR(), HT.BR())
+ #
+ #sampleTD.append(HT.Span("The ",
+ # HT.Href(url="/correlationAnnotation.html#sample_r", target="_blank",
+ # text="Sample Correlation")," is computed between trait data and",
+ # " any ",HT.BR()," other traits in the sample database selected above. Use ",
+ # HT.Href(url="/glossary.html#Correlations", target="_blank", text="Spearman Rank"),
+ # HT.BR(),"when the sample size is small (<20) or when there are influential \
+ # outliers.", HT.BR(),Class="fs12"))
+
+ #sampleTable.append(sampleTD)
+
+ #sample_container.append(sampleTable)
+ #sample_div.append(sample_container)
+ #corr_container.append(sample_div)
+ #
+ #literature_div = HT.Div(id="corrtabs-2")
+ #literature_container = HT.Span()
+
+ #literatureTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+ #literatureTD = HT.TD(correlationMenus2,HT.BR(),lit_correlation, HT.BR(), HT.BR())
+ #literatureTD.append(HT.Span("The ", HT.Href(url="/correlationAnnotation.html", target="_blank",text="Literature Correlation"), " (Lit r) between this gene and all other genes is computed",HT.BR(),
+ # "using the ", HT.Href(url="https://grits.eecs.utk.edu/sgo/sgo.html", target="_blank", text="Semantic Gene Organizer"),
+ # " and human, rat, and mouse data from PubMed. ", HT.BR(),"Values are ranked by Lit r, \
+ # but Sample r and Tissue r are also displayed.", HT.BR(), HT.BR(),
+ # HT.Href(url="/glossary.html#Literature", target="_blank", text="More on using Lit r"), Class="fs12"))
+ #literatureTable.append(literatureTD)
+ #
+ #literature_container.append(literatureTable)
+ #literature_div.append(literature_container)
+ #
+ #if this_trait.db != None:
+ # if (this_trait.db.type =='ProbeSet'):
+ # corr_container.append(literature_div)
+ #
+ #tissue_div = HT.Div(id="corrtabs-3")
+ #tissue_container = HT.Span()
+ #
+ #tissue_type = HT.Input(type="radio", name="tissue_method", value="4", checked="checked")
+ #tissue_type2 = HT.Input(type="radio", name="tissue_method", value="5")
+ #
+ #tissueTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+ #tissueTD = HT.TD(correlationMenus3,HT.BR(),
+ # "Pearson", tissue_type, "&nbsp;"*3, "Spearman Rank", tissue_type2, HT.BR(), HT.BR(),
+ # tissue_correlation, HT.BR(), HT.BR())
+ #tissueTD.append(HT.Span("The ", HT.Href(url="/webqtl/main.py?FormID=tissueCorrelation", target="_blank", text="Tissue Correlation"),
+ #" (Tissue r) estimates the similarity of expression of two genes",HT.BR()," or \
+ #transcripts across different cells, tissues, or organs (",HT.Href(url="/correlationAnnotation.html#tissue_r", target="_blank", text="glossary"),"). \
+ #Tissue correlations",HT.BR()," are generated by analyzing expression in multiple samples usually taken from \
+ #single cases.",HT.BR(),HT.Bold("Pearson")," and ",HT.Bold("Spearman Rank")," correlations have been computed for all pairs \
+ #of genes",HT.BR()," using data from mouse samples.",
+ #HT.BR(), Class="fs12"))
+ #tissueTable.append(tissueTD)
+ #
+ #tissue_container.append(tissueTable)
+ #tissue_div.append(tissue_container)
+ #if this_trait.db != None:
+ # if (this_trait.db.type =='ProbeSet'):
+ # corr_container.append(tissue_div)
+ #
+ #corr_row.append(HT.TD(corr_container))
+ #
+ #corr_script = HT.Script(language="Javascript")
+ #corr_script_text = """$(function() { $("#corr_tabs").tabs(); });"""
+ #corr_script.append(corr_script_text)
+ #
+ #submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target4")
+ #submitTable.append(corr_row)
+ #submitTable.append(corr_script)
+ #
+ #title3Body.append(submitTable)
self.corr_tools = dict(dataset_menu = dataset_menu,
dataset_menu_selected = dataset_menu_selected,
return_results_menu = return_results_menu,
@@ -1344,7 +1526,7 @@ class ShowTrait(templatePage):
this_trait=this_trait,
sample_group_type='primary',
header="%s Only" % (fd.RISet))
-
+
print("primary_samples.attributes:", pf(primary_samples.attributes))
other_sample_names = []
@@ -1368,7 +1550,7 @@ class ShowTrait(templatePage):
this_trait=this_trait,
sample_group_type='other',
header="Non-%s" % (fd.RISet))
-
+
self.sample_groups = (primary_samples, other_samples)
else:
self.sample_groups = (primary_samples,)
@@ -1376,4 +1558,5 @@ class ShowTrait(templatePage):
#TODO: Figure out why this if statement is written this way - Zach
#if (other_sample_names or (fd.f1list and this_trait.data.has_key(fd.f1list[0]))
# or (fd.f1list and this_trait.data.has_key(fd.f1list[1]))):
+ # print("hjs")
fd.allsamplelist = all_samples_ordered
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee
index a22a3beb..a89b29af 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee
@@ -244,7 +244,7 @@ $ ->
##Hide Sample Rows With No Value (value of 'x') Code
hide_no_value = ->
- $('.value_se').each (index, element) =>
+ $('.value_se').each (_index, element) =>
if $(element).find('.trait_value_input').val() == 'x'
$(element).hide()
@@ -254,7 +254,7 @@ $ ->
##Block Outliers Code
block_outliers = ->
- $('.outlier').each (index, element) =>
+ $('.outlier').each (_index, element) =>
$(element).find('.trait_value_input').val('x')
$('#block_outliers').click(block_outliers)
@@ -263,7 +263,7 @@ $ ->
##Reset Table Values Code
reset_samples_table = ->
- $('.trait_value_input').each (index, element) =>
+ $('.trait_value_input').each (_index, element) =>
console.log("value is:", $(element).val())
$(element).val($(element).data('value'))
console.log("data-value is:", $(element).data('value'))
@@ -272,6 +272,51 @@ $ ->
$('#reset').click(reset_samples_table)
##End Reset Table Values Code
+
+ ##Get Sample Data From Table Code
+
+ get_sample_table_data = ->
+ samples = {}
+ primary_samples = []
+ other_samples = []
+ $('#sortable1').find('.value_se').each (_index, element) =>
+ row_data = {}
+ row_data.name = $.trim($(element).find('.column_name-Sample').text())
+ row_data.value = $(element).find('.edit_sample_value').val()
+ if $(element).find('.edit_sample_se').length != -1
+ row_data.se = $(element).find('.edit_sample_se').val()
+ for own key, attribute_info of js_data.attribute_names
+ row_data[attribute_info.name] = $.trim($(element).find(
+ '.column_name-'+attribute_info.name.replace(" ", "_")).text())
+ console.log("row_data is:", row_data)
+ primary_samples.push(row_data)
+ console.log("primary_samples is:", primary_samples)
+ samples.primary_samples = primary_samples
+ samples.other_samples = other_samples
+ return samples
+
+
+ export_sample_table_data = ->
+ sample_data = get_sample_table_data()
+ console.log("sample_data is:", sample_data)
+ json_sample_data = JSON.stringify(sample_data)
+ console.log("json_sample_data is:", json_sample_data)
+ $.ajax(
+ url: '/export_trait_data'
+ type: 'POST'
+ data: "json_data=" + json_sample_data
+ )
+
+ $('#export').click(export_sample_table_data)
+
+
+
+ ##End Get Sample Data from Table Code
+
+ ##Export Sample Table Data Code
+
+ ##End Export Sample Table Data Code
+
console.log("before registering block_outliers")
$('#block_outliers').click(block_outliers)
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index d6c5226f..e4f477f3 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -11,7 +11,7 @@
};
$(function() {
- var block_by_attribute_value, block_by_index, block_outliers, change_stats_value, create_value_dropdown, edit_data_change, hide_no_value, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, reset_samples_table, show_hide_outliers, stats_mdp_change, update_stat_values;
+ var block_by_attribute_value, block_by_index, block_outliers, change_stats_value, create_value_dropdown, edit_data_change, export_sample_table_data, get_sample_table_data, hide_no_value, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, reset_samples_table, show_hide_outliers, stats_mdp_change, update_stat_values;
hide_tabs = function(start) {
var x, _i, _results;
_results = [];
@@ -281,7 +281,7 @@
$('#block_by_index').click(block_by_index);
hide_no_value = function() {
var _this = this;
- return $('.value_se').each(function(index, element) {
+ return $('.value_se').each(function(_index, element) {
if ($(element).find('.trait_value_input').val() === 'x') {
return $(element).hide();
}
@@ -290,14 +290,14 @@
$('#hide_no_value').click(hide_no_value);
block_outliers = function() {
var _this = this;
- return $('.outlier').each(function(index, element) {
+ return $('.outlier').each(function(_index, element) {
return $(element).find('.trait_value_input').val('x');
});
};
$('#block_outliers').click(block_outliers);
reset_samples_table = function() {
var _this = this;
- return $('.trait_value_input').each(function(index, element) {
+ return $('.trait_value_input').each(function(_index, element) {
console.log("value is:", $(element).val());
$(element).val($(element).data('value'));
console.log("data-value is:", $(element).data('value'));
@@ -305,6 +305,47 @@
});
};
$('#reset').click(reset_samples_table);
+ get_sample_table_data = function() {
+ var other_samples, primary_samples, samples,
+ _this = this;
+ samples = {};
+ primary_samples = [];
+ other_samples = [];
+ $('#sortable1').find('.value_se').each(function(_index, element) {
+ var attribute_info, key, row_data, _ref;
+ row_data = {};
+ row_data.name = $.trim($(element).find('.column_name-Sample').text());
+ row_data.value = $(element).find('.edit_sample_value').val();
+ if ($(element).find('.edit_sample_se').length !== -1) {
+ row_data.se = $(element).find('.edit_sample_se').val();
+ }
+ _ref = js_data.attribute_names;
+ for (key in _ref) {
+ if (!__hasProp.call(_ref, key)) continue;
+ attribute_info = _ref[key];
+ row_data[attribute_info.name] = $.trim($(element).find('.column_name-' + attribute_info.name.replace(" ", "_")).text());
+ }
+ console.log("row_data is:", row_data);
+ return primary_samples.push(row_data);
+ });
+ console.log("primary_samples is:", primary_samples);
+ samples.primary_samples = primary_samples;
+ samples.other_samples = other_samples;
+ return samples;
+ };
+ export_sample_table_data = function() {
+ var json_sample_data, sample_data;
+ sample_data = get_sample_table_data();
+ console.log("sample_data is:", sample_data);
+ json_sample_data = JSON.stringify(sample_data);
+ console.log("json_sample_data is:", json_sample_data);
+ return $.ajax({
+ url: '/export_trait_data',
+ type: 'POST',
+ data: "json_data=" + json_sample_data
+ });
+ };
+ $('#export').click(export_sample_table_data);
console.log("before registering block_outliers");
$('#block_outliers').click(block_outliers);
console.log("after registering block_outliers");
diff --git a/wqflask/wqflask/static/new/js_external/json2.js b/wqflask/wqflask/static/new/js_external/json2.js
new file mode 100644
index 00000000..2373c74d
--- /dev/null
+++ b/wqflask/wqflask/static/new/js_external/json2.js
@@ -0,0 +1,1298 @@
+
+
+
+<!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" />
+
+
+
+ <link rel="icon" type="image/x-icon" href="/favicon.ico" />
+
+ <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" />
+
+
+
+ <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."/>
+
+ <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" />
+
+ </head>
+
+
+ <body class="logged_out page-blob vis-public env-production ">
+ <div id="wrapper">
+
+
+
+
+ <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>
+
+
+ <!--
+ 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'})
+ }
+}
+```</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>
+
diff --git a/wqflask/wqflask/templates/new_index_page.html b/wqflask/wqflask/templates/new_index_page.html
new file mode 100644
index 00000000..46839690
--- /dev/null
+++ b/wqflask/wqflask/templates/new_index_page.html
@@ -0,0 +1,85 @@
+<head>
+
+ <title>GeneNetwork</title>
+
+ <LINK REL="stylesheet" TYPE="text/css" HREF='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css'>
+ <link REL="stylesheet" TYPE="text/css" href="/static/packages/bootstrap/css/bootstrap.min.css" />
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
+ <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
+ <script src="/static/packages/bootstrap/js/bootstrap.min.js"></script>
+</head>
+
+<body>
+ <div class="container">
+ <h2>Select and Search</h2>
+
+ <form method="get" action="/search" class="form-search" name="SEARCHFORM">
+ <fieldset>
+ <label for="species">Species:</label>
+ <select name="species" size="1" id="species" onchange="fillOptions('species');">
+ </select>
+
+
+ <label for="cross">Group:</label>
+ <select name="cross" id="cross" onchange="fillOptions('cross');">
+ </select> <input type="button" class="btn" value="Info" onclick=
+ "javascript:crossinfo();">
+
+ <label for="type">Type:</label>
+ <select name="tissue" id="tissue" onchange=
+ "fillOptions('tissue');">
+
+ <label for"database">Database:</label>
+ <select name="database" id="database">
+ </select>
+
+ <input type="submit" class="btn" value="Info" name="info_database">
+
+ <!-- USER HELP -->
+
+
+ <p class="fs12">Databases marked with <b>**</b>
+ suffix are not public yet.<br>
+ Access requires <a href="/account.html" target=
+ "_blank" class="fs14">user login</a>.</p>
+
+ <!-- GET ANY SEARCH -->
+
+ <label for="tfor">Search:</label>
+
+ <input class="search-query"
+ id="tfor" name="ORkeyword"
+ type="text" maxlength="500">
+
+ <!-- GET ANY HELP -->
+
+ Enter terms, genes, ID numbers in the
+ <b>Search</b> field.<br>
+ Use <b>*</b> or <b>?</b> wildcards (Cyp*a?,
+ synap*).<br>
+ Use <b>quotes</b> for terms such as <i>"tyrosine
+ kinase"</i>.</p>
+
+ <!-- SEARCH, MAKE DEFAULT, ADVANCED SEARCH -->
+
+
+ <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="Advanced Search" onclick=
+ "javascript:window.open('/index3.html', '_self');">
+
+ <input type="hidden" name="FormID" value="searchResult"> <input type=
+ "hidden" name="RISet" value="BXD">
+ </fieldset>
+ </form>
+ </div>
+ <script src="/javascript/selectDatasetMenu.js"
+ type="text/javascript">
+ </script>
+</body>
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index a20017da..1e1d8b8f 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -1378,6 +1378,7 @@
<script type="text/javascript" src="/static/new/javascript/stats.js"></script>
<script type="text/javascript" src="/static/new/javascript/show_trait.js"></script>
+ <script type="text/javascript" src="/static/new/js_external/json2.js"></script>
<script type="text/javascript" src="/static/new/javascript/validation.js"></script>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 82a08c71..7210a1de 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -11,6 +11,7 @@ from flask import render_template, request
from wqflask import search_results
from wqflask.show_trait import show_trait
+from wqflask.show_trait import export_trait_data
from wqflask.correlation import CorrelationPage
from wqflask.dataSharing import SharingInfo, SharingInfoPage
@@ -26,6 +27,11 @@ def index_page():
return render_template("index_page.html")
+@app.route("/new")
+def new_index_page():
+ print("Sending index_page")
+ return render_template("new_index_page.html")
+
@app.route("/data_sharing")
def data_sharing_page():
print("In data_sharing")
@@ -81,6 +87,14 @@ def show_trait_page():
print("show_trait template_vars:", pf(template_vars.__dict__))
return render_template("show_trait.html", **template_vars.__dict__)
+@app.route("/export_trait_data", methods=('POST',))
+def export_sample_table():
+ """CSV file consisting of the sample data from the trait data and analysis page"""
+ print("In export_sample_table")
+ print("request.args:", request.args)
+ print("request.form:", request.form)
+ template_vars = export_trait_data.export_sample_table(request.form)
+
@app.route("/corr_compute", methods=('POST',))
def corr_compute_page():