Index: chrome/common/extensions/docs/static/samples.html |
diff --git a/chrome/common/extensions/docs/static/samples.html b/chrome/common/extensions/docs/static/samples.html |
index 5e0df08e876fa0ea8c7b9054a3d00fb77e76b02c..380db00097000861777aebbe4759be878587c285 100644 |
--- a/chrome/common/extensions/docs/static/samples.html |
+++ b/chrome/common/extensions/docs/static/samples.html |
@@ -56,10 +56,30 @@ |
} |
}); |
+ function stringifyFlatObjectsReadably(obj) { |
+ if (typeof(obj) === "object") { |
+ var temp = []; |
+ for (key in obj) { |
+ if (obj.hasOwnProperty(key)) { |
+ if (typeof(key) === "string" && typeof(obj[key]) === "string") { |
+ temp.push(" " + JSON.stringify(key) + ": " + |
+ JSON.stringify(obj[key])); |
+ } else { |
Pam (message me for reviews)
2011/08/09 11:52:06
I'm not a JS expert, but should this be out one le
Use mkwst_at_chromium.org plz.
2011/08/09 11:57:32
If it's a property that the object doesn't itself
|
+ // We hit something strange; it's not a flat object: abort! |
+ return JSON.stringify(obj); |
+ } |
+ } |
+ } |
+ return "{\n" + temp.join(",\n") + "}"; |
+ } else { |
+ return JSON.stringify(obj); |
+ } |
+ } |
+ |
// The search data should be injected as executable JavaScript, so assign |
// a template value which will store the data as a page global. |
pageData.search_data = "var search_data = " + |
- JSON.stringify(search_data); + ";"; |
+ stringifyFlatObjectsReadably(search_data) + ";\n"; |
</script> |
<div id="controls"> |