From 8415ae82d72b72345d98ebc108f72b6f8ac148d8 Mon Sep 17 00:00:00 2001 From: Christy Henriksson Date: Mon, 6 Feb 2017 09:20:27 -0800 Subject: [PATCH] Enable strict for Json2Html and remove dead copy (#114) --- .../NuGet.Services.Metadata.Catalog.csproj | 2 - src/Catalog/content/Json2Html.js | 68 ------------------- src/Catalog/content/Json2HtmlStyle.css | 18 ----- .../Console/Json2Html.js | 1 + 4 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 src/Catalog/content/Json2Html.js delete mode 100644 src/Catalog/content/Json2HtmlStyle.css diff --git a/src/Catalog/NuGet.Services.Metadata.Catalog.csproj b/src/Catalog/NuGet.Services.Metadata.Catalog.csproj index b32b7c622..ea3d90320 100644 --- a/src/Catalog/NuGet.Services.Metadata.Catalog.csproj +++ b/src/Catalog/NuGet.Services.Metadata.Catalog.csproj @@ -229,8 +229,6 @@ - - diff --git a/src/Catalog/content/Json2Html.js b/src/Catalog/content/Json2Html.js deleted file mode 100644 index 267f537db..000000000 --- a/src/Catalog/content/Json2Html.js +++ /dev/null @@ -1,68 +0,0 @@ -var json2html = function (obj) { - - var urlregexp = /^http:|^https:/; - - var is_array = function (value) { - return Object.prototype.toString.apply(value) === '[object Array]'; - } - - var displayValue = function (value) { - if (value === null) { - return 'null'; - } else { - if (is_array(value)) { - return displayArray(value); - } else if (typeof value === 'object') { - return displayObject(value); - } else { - switch (typeof value) { - case 'string': - if (urlregexp.test(value)) { - var href = value.replace(/\.json$/, '.html'); - href = href.replace(/\.json#/, '.html#'); - return '"' + value + '"'; - } - else { - return '"' + value + '"'; - } - case 'number': return value.toString(); - case 'boolean': return value.toString(); - default: throw 'unrecognized value type'; - } - } - } - } - - var displayObject = function (obj) { - var html = '{'; - html += '
    '; - for (var prop in obj) { - html += '
  • "' + prop + '" : '; - html += displayValue(obj[prop]); - html += ',
  • '; - } - html = html.slice(0, html.length - 6); - html += '
'; - html += '}'; - return html; - } - - var displayArray = function (array) { - if (array.length === 0) { - return '[]'; - } - var html = '['; - html += '
    '; - for (var i = 0; i < array.length; i += 1) { - html += '
  • '; - html += displayValue(array[i]); - html += ',
  • '; - } - html = html.slice(0, html.length - 1); - html += '
'; - html += ']'; - return html; - } - - return displayValue(obj); -} \ No newline at end of file diff --git a/src/Catalog/content/Json2HtmlStyle.css b/src/Catalog/content/Json2HtmlStyle.css deleted file mode 100644 index 14f59a815..000000000 --- a/src/Catalog/content/Json2HtmlStyle.css +++ /dev/null @@ -1,18 +0,0 @@ -.json-ul -{ - list-style-type: none; - padding: 0px; - margin: 0px; -} -.json-li -{ - padding-left: 28px; - font-family:Consolas; - font-size:small; -} -.json-prop-name { - color: blue; -} -.json-prop-value-string { - color: red; -} \ No newline at end of file diff --git a/src/NuGet.Services.BasicSearch/Console/Json2Html.js b/src/NuGet.Services.BasicSearch/Console/Json2Html.js index e55edc9cc..48ecece1a 100644 --- a/src/NuGet.Services.BasicSearch/Console/Json2Html.js +++ b/src/NuGet.Services.BasicSearch/Console/Json2Html.js @@ -1,4 +1,5 @@ var json2html = function (obj) { + "use strict"; var urlregexp = /^http:|^https:/;