json-formatter-rails 1.3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +21 -0
- data/README.md +73 -0
- data/json-formatter-rails.gemspec +23 -0
- data/lib/json-formatter-rails.rb +1 -0
- data/lib/json-formatter-rails/rails.rb +7 -0
- data/lib/json-formatter-rails/rails/engine.rb +6 -0
- data/lib/json-formatter-rails/rails/version.rb +6 -0
- data/vendor/assets/javascripts/json-formatter.js +965 -0
- data/vendor/assets/javascripts/json-formatter.js.map +1 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 61aad11a4c10137054a83a951431dc215631e9c9
|
4
|
+
data.tar.gz: 36b21d510b0c3242ede0c9febd259d086985719f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ce1a2dfa250b60ec437a4acf29d66521bb6db619a34dc0971065e93e6bcc35ed57f9bb913cf69bb8816f2b03c426d32553764dba3ba1f85470d2337a65fab91
|
7
|
+
data.tar.gz: 8ba275c9fc75820acc169385c2a74d35140bba5dd9dcff812ca9a3cbf50fa960214eb8600cc8ce12016b2bc827eb067c194876aacade4abbae9861b5ab9cff57
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2016 Andre Arko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# json-formatter-rails
|
2
|
+
|
3
|
+
Want a quick way to present a JSON data structure in your browser? I did so
|
4
|
+
I selected [https://github.com/mohsen1/json-formatter-js]. You can see it
|
5
|
+
in action at [http://azimi.me/json-formatter-js/]. This gem makes it easier for you
|
6
|
+
to use it for your projects.
|
7
|
+
|
8
|
+
## Versions
|
9
|
+
|
10
|
+
Starting with v1.3.0, this gem's version will match the version of json-formatter-js
|
11
|
+
that is in the gem. If there is a fix to a specific version then the 4th digit will indicate this (i.e. 1.3.0.1)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
The json-formatter file will be added to the asset pipeline and available for you to use.
|
16
|
+
If they're not already in `app/assets/javascripts/application.js` then add this line:
|
17
|
+
|
18
|
+
```js
|
19
|
+
//= require json-formatter
|
20
|
+
```
|
21
|
+
|
22
|
+
## Example use
|
23
|
+
|
24
|
+
Suppose you want to quickly display a bunch of "status" information. And furthermore you want
|
25
|
+
to use an Ajax request to get the most recent status.
|
26
|
+
|
27
|
+
In your controller make a status method like:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
class InformationController < ApplicationController
|
31
|
+
|
32
|
+
def status
|
33
|
+
respond_to do |format|
|
34
|
+
format.html
|
35
|
+
format.json { render json: MyBigJsonStatus.method }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Add a route to your routes.rb file
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
get '/information/status', to: 'information#status'
|
46
|
+
```
|
47
|
+
|
48
|
+
Create a view file status.html.erb
|
49
|
+
|
50
|
+
```html
|
51
|
+
<div id="status">
|
52
|
+
Status Information:
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<script>
|
56
|
+
$.getJSON( document.location.href, function( data ) {
|
57
|
+
formatter = new JSONFormatter(data);
|
58
|
+
$('#status').append(formatter.render());
|
59
|
+
});
|
60
|
+
</script>
|
61
|
+
```
|
62
|
+
|
63
|
+
In this example opening http://localhost:3000/information/status will produce your
|
64
|
+
HTML file in your browser that will then fetch the status data, as JSON, via an Ajax
|
65
|
+
request. You can then view the json data comfortably in your browser.
|
66
|
+
|
67
|
+
## Contributing to json-formatter-rails
|
68
|
+
|
69
|
+
Send me a pull request or open an issue.
|
70
|
+
|
71
|
+
## License
|
72
|
+
json-formatter-rails is released under the [MIT License](MIT-LICENSE).
|
73
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/json-formatter-rails/rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "json-formatter-rails"
|
6
|
+
s.version = JsonFormatter::Rails::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Jay Lawrence"]
|
9
|
+
s.email = ["jayjlawrence70@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/jayjlawrence/json-formatter-rails.git"
|
11
|
+
s.summary = "A JavaScript-based JSON formatter for your Rails views"
|
12
|
+
s.description = "This gem provides a JavaScript-based JSON viewer for your Rails 4+ application."
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
s.required_ruby_version = ">= 1.9.3"
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_dependency "railties", ">= 4.2.0"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
|
+
s.require_path = 'lib'
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'json-formatter-rails/rails'
|
@@ -0,0 +1,965 @@
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
+
module.exports = factory();
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
5
|
+
define("JSONFormatter", [], factory);
|
6
|
+
else if(typeof exports === 'object')
|
7
|
+
exports["JSONFormatter"] = factory();
|
8
|
+
else
|
9
|
+
root["JSONFormatter"] = factory();
|
10
|
+
})(this, function() {
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
12
|
+
/******/ // The module cache
|
13
|
+
/******/ var installedModules = {};
|
14
|
+
/******/
|
15
|
+
/******/ // The require function
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
17
|
+
/******/
|
18
|
+
/******/ // Check if module is in cache
|
19
|
+
/******/ if(installedModules[moduleId])
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
21
|
+
/******/
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
24
|
+
/******/ exports: {},
|
25
|
+
/******/ id: moduleId,
|
26
|
+
/******/ loaded: false
|
27
|
+
/******/ };
|
28
|
+
/******/
|
29
|
+
/******/ // Execute the module function
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
+
/******/
|
32
|
+
/******/ // Flag the module as loaded
|
33
|
+
/******/ module.loaded = true;
|
34
|
+
/******/
|
35
|
+
/******/ // Return the exports of the module
|
36
|
+
/******/ return module.exports;
|
37
|
+
/******/ }
|
38
|
+
/******/
|
39
|
+
/******/
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
41
|
+
/******/ __webpack_require__.m = modules;
|
42
|
+
/******/
|
43
|
+
/******/ // expose the module cache
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
45
|
+
/******/
|
46
|
+
/******/ // __webpack_public_path__
|
47
|
+
/******/ __webpack_require__.p = "dist";
|
48
|
+
/******/
|
49
|
+
/******/ // Load entry module and return exports
|
50
|
+
/******/ return __webpack_require__(0);
|
51
|
+
/******/ })
|
52
|
+
/************************************************************************/
|
53
|
+
/******/ ([
|
54
|
+
/* 0 */
|
55
|
+
/***/ function(module, exports, __webpack_require__) {
|
56
|
+
|
57
|
+
module.exports = __webpack_require__(1);
|
58
|
+
|
59
|
+
|
60
|
+
/***/ },
|
61
|
+
/* 1 */
|
62
|
+
/***/ function(module, exports, __webpack_require__) {
|
63
|
+
|
64
|
+
"use strict";
|
65
|
+
__webpack_require__(2);
|
66
|
+
var helpers_ts_1 = __webpack_require__(6);
|
67
|
+
var DATE_STRING_REGEX = /(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/;
|
68
|
+
var PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/;
|
69
|
+
var JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
|
70
|
+
// When toggleing, don't animated removal or addition of more than a few items
|
71
|
+
var MAX_ANIMATED_TOGGLE_ITEMS = 10;
|
72
|
+
var requestAnimationFrame = window.requestAnimationFrame || function (cb) { cb(); return 0; };
|
73
|
+
;
|
74
|
+
var _defaultConfig = {
|
75
|
+
hoverPreviewEnabled: false,
|
76
|
+
hoverPreviewArrayCount: 100,
|
77
|
+
hoverPreviewFieldCount: 5,
|
78
|
+
animateOpen: true,
|
79
|
+
animateClose: true,
|
80
|
+
theme: null
|
81
|
+
};
|
82
|
+
module.exports = (function () {
|
83
|
+
/**
|
84
|
+
* @param {object} json The JSON object you want to render. It has to be an
|
85
|
+
* object or array. Do NOT pass raw JSON string.
|
86
|
+
*
|
87
|
+
* @param {number} [open=1] his number indicates up to how many levels the
|
88
|
+
* rendered tree should expand. Set it to `0` to make the whole tree collapsed
|
89
|
+
* or set it to `Infinity` to expand the tree deeply
|
90
|
+
*
|
91
|
+
* @param {object} [config=defaultConfig] -
|
92
|
+
* defaultConfig = {
|
93
|
+
* hoverPreviewEnabled: false,
|
94
|
+
* hoverPreviewArrayCount: 100,
|
95
|
+
* hoverPreviewFieldCount: 5
|
96
|
+
* }
|
97
|
+
*
|
98
|
+
* Available configurations:
|
99
|
+
* #####Hover Preview
|
100
|
+
* * `hoverPreviewEnabled`: enable preview on hover
|
101
|
+
* * `hoverPreviewArrayCount`: number of array items to show in preview Any
|
102
|
+
* array larger than this number will be shown as `Array[XXX]` where `XXX`
|
103
|
+
* is length of the array.
|
104
|
+
* * `hoverPreviewFieldCount`: number of object properties to show for object
|
105
|
+
* preview. Any object with more properties that thin number will be
|
106
|
+
* truncated.
|
107
|
+
*
|
108
|
+
* @param {string} [key=undefined] The key that this object in it's parent
|
109
|
+
* context
|
110
|
+
*/
|
111
|
+
function JSONFormatter(json, open, config, key) {
|
112
|
+
if (open === void 0) { open = 1; }
|
113
|
+
if (config === void 0) { config = _defaultConfig; }
|
114
|
+
this.json = json;
|
115
|
+
this.open = open;
|
116
|
+
this.config = config;
|
117
|
+
this.key = key;
|
118
|
+
// Hold the open state after the toggler is used
|
119
|
+
this._isOpen = null;
|
120
|
+
// Setting default values for config object
|
121
|
+
if (this.config.hoverPreviewEnabled === undefined) {
|
122
|
+
this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled;
|
123
|
+
}
|
124
|
+
if (this.config.hoverPreviewArrayCount === undefined) {
|
125
|
+
this.config.hoverPreviewArrayCount = _defaultConfig.hoverPreviewArrayCount;
|
126
|
+
}
|
127
|
+
if (this.config.hoverPreviewFieldCount === undefined) {
|
128
|
+
this.config.hoverPreviewFieldCount = _defaultConfig.hoverPreviewFieldCount;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
Object.defineProperty(JSONFormatter.prototype, "isOpen", {
|
132
|
+
/*
|
133
|
+
* is formatter open?
|
134
|
+
*/
|
135
|
+
get: function () {
|
136
|
+
if (this._isOpen !== null) {
|
137
|
+
return this._isOpen;
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
return this.open > 0;
|
141
|
+
}
|
142
|
+
},
|
143
|
+
/*
|
144
|
+
* set open state (from toggler)
|
145
|
+
*/
|
146
|
+
set: function (value) {
|
147
|
+
this._isOpen = value;
|
148
|
+
},
|
149
|
+
enumerable: true,
|
150
|
+
configurable: true
|
151
|
+
});
|
152
|
+
Object.defineProperty(JSONFormatter.prototype, "isDate", {
|
153
|
+
/*
|
154
|
+
* is this a date string?
|
155
|
+
*/
|
156
|
+
get: function () {
|
157
|
+
return (this.type === 'string') &&
|
158
|
+
(DATE_STRING_REGEX.test(this.json) ||
|
159
|
+
JSON_DATE_REGEX.test(this.json) ||
|
160
|
+
PARTIAL_DATE_REGEX.test(this.json));
|
161
|
+
},
|
162
|
+
enumerable: true,
|
163
|
+
configurable: true
|
164
|
+
});
|
165
|
+
Object.defineProperty(JSONFormatter.prototype, "isUrl", {
|
166
|
+
/*
|
167
|
+
* is this a URL string?
|
168
|
+
*/
|
169
|
+
get: function () {
|
170
|
+
return this.type === 'string' && (this.json.indexOf('http') === 0);
|
171
|
+
},
|
172
|
+
enumerable: true,
|
173
|
+
configurable: true
|
174
|
+
});
|
175
|
+
Object.defineProperty(JSONFormatter.prototype, "isArray", {
|
176
|
+
/*
|
177
|
+
* is this an array?
|
178
|
+
*/
|
179
|
+
get: function () {
|
180
|
+
return Array.isArray(this.json);
|
181
|
+
},
|
182
|
+
enumerable: true,
|
183
|
+
configurable: true
|
184
|
+
});
|
185
|
+
Object.defineProperty(JSONFormatter.prototype, "isObject", {
|
186
|
+
/*
|
187
|
+
* is this an object?
|
188
|
+
* Note: In this context arrays are object as well
|
189
|
+
*/
|
190
|
+
get: function () {
|
191
|
+
return helpers_ts_1.isObject(this.json);
|
192
|
+
},
|
193
|
+
enumerable: true,
|
194
|
+
configurable: true
|
195
|
+
});
|
196
|
+
Object.defineProperty(JSONFormatter.prototype, "isEmptyObject", {
|
197
|
+
/*
|
198
|
+
* is this an empty object with no properties?
|
199
|
+
*/
|
200
|
+
get: function () {
|
201
|
+
return !this.keys.length && !this.isArray;
|
202
|
+
},
|
203
|
+
enumerable: true,
|
204
|
+
configurable: true
|
205
|
+
});
|
206
|
+
Object.defineProperty(JSONFormatter.prototype, "isEmpty", {
|
207
|
+
/*
|
208
|
+
* is this an empty object or array?
|
209
|
+
*/
|
210
|
+
get: function () {
|
211
|
+
return this.isEmptyObject || (this.keys && !this.keys.length && this.isArray);
|
212
|
+
},
|
213
|
+
enumerable: true,
|
214
|
+
configurable: true
|
215
|
+
});
|
216
|
+
Object.defineProperty(JSONFormatter.prototype, "hasKey", {
|
217
|
+
/*
|
218
|
+
* did we recieve a key argument?
|
219
|
+
* This means that the formatter was called as a sub formatter of a parent formatter
|
220
|
+
*/
|
221
|
+
get: function () {
|
222
|
+
return typeof this.key !== 'undefined';
|
223
|
+
},
|
224
|
+
enumerable: true,
|
225
|
+
configurable: true
|
226
|
+
});
|
227
|
+
Object.defineProperty(JSONFormatter.prototype, "constructorName", {
|
228
|
+
/*
|
229
|
+
* if this is an object, get constructor function name
|
230
|
+
*/
|
231
|
+
get: function () {
|
232
|
+
return helpers_ts_1.getObjectName(this.json);
|
233
|
+
},
|
234
|
+
enumerable: true,
|
235
|
+
configurable: true
|
236
|
+
});
|
237
|
+
Object.defineProperty(JSONFormatter.prototype, "type", {
|
238
|
+
/*
|
239
|
+
* get type of this value
|
240
|
+
* Possible values: all JavaScript primitive types plus "array" and "null"
|
241
|
+
*/
|
242
|
+
get: function () {
|
243
|
+
return helpers_ts_1.getType(this.json);
|
244
|
+
},
|
245
|
+
enumerable: true,
|
246
|
+
configurable: true
|
247
|
+
});
|
248
|
+
Object.defineProperty(JSONFormatter.prototype, "keys", {
|
249
|
+
/*
|
250
|
+
* get object keys
|
251
|
+
* If there is an empty key we pad it wit quotes to make it visible
|
252
|
+
*/
|
253
|
+
get: function () {
|
254
|
+
if (this.isObject) {
|
255
|
+
return Object.keys(this.json).map(function (key) { return key ? key : '""'; });
|
256
|
+
}
|
257
|
+
else {
|
258
|
+
return [];
|
259
|
+
}
|
260
|
+
},
|
261
|
+
enumerable: true,
|
262
|
+
configurable: true
|
263
|
+
});
|
264
|
+
/**
|
265
|
+
* Toggles `isOpen` state
|
266
|
+
*
|
267
|
+
*/
|
268
|
+
JSONFormatter.prototype.toggleOpen = function () {
|
269
|
+
this.isOpen = !this.isOpen;
|
270
|
+
if (this.element) {
|
271
|
+
if (this.isOpen) {
|
272
|
+
this.appendChildren(this.config.animateOpen);
|
273
|
+
}
|
274
|
+
else {
|
275
|
+
this.removeChildren(this.config.animateClose);
|
276
|
+
}
|
277
|
+
this.element.classList.toggle(helpers_ts_1.cssClass('open'));
|
278
|
+
}
|
279
|
+
};
|
280
|
+
/**
|
281
|
+
* Open all children up to a certain depth.
|
282
|
+
* Allows actions such as expand all/collapse all
|
283
|
+
*
|
284
|
+
*/
|
285
|
+
JSONFormatter.prototype.openAtDepth = function (depth) {
|
286
|
+
if (depth === void 0) { depth = 1; }
|
287
|
+
if (depth < 0) {
|
288
|
+
return;
|
289
|
+
}
|
290
|
+
this.open = depth;
|
291
|
+
this.isOpen = (depth !== 0);
|
292
|
+
if (this.element) {
|
293
|
+
this.removeChildren(false);
|
294
|
+
if (depth === 0) {
|
295
|
+
this.element.classList.remove(helpers_ts_1.cssClass('open'));
|
296
|
+
}
|
297
|
+
else {
|
298
|
+
this.appendChildren(this.config.animateOpen);
|
299
|
+
this.element.classList.add(helpers_ts_1.cssClass('open'));
|
300
|
+
}
|
301
|
+
}
|
302
|
+
};
|
303
|
+
/**
|
304
|
+
* Generates inline preview
|
305
|
+
*
|
306
|
+
* @returns {string}
|
307
|
+
*/
|
308
|
+
JSONFormatter.prototype.getInlinepreview = function () {
|
309
|
+
var _this = this;
|
310
|
+
if (this.isArray) {
|
311
|
+
// if array length is greater then 100 it shows "Array[101]"
|
312
|
+
if (this.json.length > this.config.hoverPreviewArrayCount) {
|
313
|
+
return "Array[" + this.json.length + "]";
|
314
|
+
}
|
315
|
+
else {
|
316
|
+
return "[" + this.json.map(helpers_ts_1.getPreview).join(', ') + "]";
|
317
|
+
}
|
318
|
+
}
|
319
|
+
else {
|
320
|
+
var keys = this.keys;
|
321
|
+
// the first five keys (like Chrome Developer Tool)
|
322
|
+
var narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount);
|
323
|
+
// json value schematic information
|
324
|
+
var kvs = narrowKeys.map(function (key) { return (key + ":" + helpers_ts_1.getPreview(_this.json[key])); });
|
325
|
+
// if keys count greater then 5 then show ellipsis
|
326
|
+
var ellipsis = keys.length >= this.config.hoverPreviewFieldCount ? '…' : '';
|
327
|
+
return "{" + kvs.join(', ') + ellipsis + "}";
|
328
|
+
}
|
329
|
+
};
|
330
|
+
/**
|
331
|
+
* Renders an HTML element and installs event listeners
|
332
|
+
*
|
333
|
+
* @returns {HTMLDivElement}
|
334
|
+
*/
|
335
|
+
JSONFormatter.prototype.render = function () {
|
336
|
+
// construct the root element and assign it to this.element
|
337
|
+
this.element = helpers_ts_1.createElement('div', 'row');
|
338
|
+
// construct the toggler link
|
339
|
+
var togglerLink = helpers_ts_1.createElement('a', 'toggler-link');
|
340
|
+
// if this is an object we need a wrapper span (toggler)
|
341
|
+
if (this.isObject) {
|
342
|
+
togglerLink.appendChild(helpers_ts_1.createElement('span', 'toggler'));
|
343
|
+
}
|
344
|
+
// if this is child of a parent formatter we need to append the key
|
345
|
+
if (this.hasKey) {
|
346
|
+
togglerLink.appendChild(helpers_ts_1.createElement('span', 'key', this.key + ":"));
|
347
|
+
}
|
348
|
+
// Value for objects and arrays
|
349
|
+
if (this.isObject) {
|
350
|
+
// construct the value holder element
|
351
|
+
var value = helpers_ts_1.createElement('span', 'value');
|
352
|
+
// we need a wrapper span for objects
|
353
|
+
var objectWrapperSpan = helpers_ts_1.createElement('span');
|
354
|
+
// get constructor name and append it to wrapper span
|
355
|
+
var constructorName = helpers_ts_1.createElement('span', 'constructor-name', this.constructorName);
|
356
|
+
objectWrapperSpan.appendChild(constructorName);
|
357
|
+
// if it's an array append the array specific elements like brackets and length
|
358
|
+
if (this.isArray) {
|
359
|
+
var arrayWrapperSpan = helpers_ts_1.createElement('span');
|
360
|
+
arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'bracket', '['));
|
361
|
+
arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'number', (this.json.length)));
|
362
|
+
arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'bracket', ']'));
|
363
|
+
objectWrapperSpan.appendChild(arrayWrapperSpan);
|
364
|
+
}
|
365
|
+
// append object wrapper span to toggler link
|
366
|
+
value.appendChild(objectWrapperSpan);
|
367
|
+
togglerLink.appendChild(value);
|
368
|
+
}
|
369
|
+
else {
|
370
|
+
// make a value holder element
|
371
|
+
var value = this.isUrl ? helpers_ts_1.createElement('a') : helpers_ts_1.createElement('span');
|
372
|
+
// add type and other type related CSS classes
|
373
|
+
value.classList.add(helpers_ts_1.cssClass(this.type));
|
374
|
+
if (this.isDate) {
|
375
|
+
value.classList.add(helpers_ts_1.cssClass('date'));
|
376
|
+
}
|
377
|
+
if (this.isUrl) {
|
378
|
+
value.classList.add(helpers_ts_1.cssClass('url'));
|
379
|
+
value.setAttribute('href', this.json);
|
380
|
+
}
|
381
|
+
// Append value content to value element
|
382
|
+
var valuePreview = helpers_ts_1.getValuePreview(this.json, this.json);
|
383
|
+
value.appendChild(document.createTextNode(valuePreview));
|
384
|
+
// append the value element to toggler link
|
385
|
+
togglerLink.appendChild(value);
|
386
|
+
}
|
387
|
+
// if hover preview is enabled, append the inline preview element
|
388
|
+
if (this.isObject && this.config.hoverPreviewEnabled) {
|
389
|
+
var preview = helpers_ts_1.createElement('span', 'preview-text');
|
390
|
+
preview.appendChild(document.createTextNode(this.getInlinepreview()));
|
391
|
+
togglerLink.appendChild(preview);
|
392
|
+
}
|
393
|
+
// construct a children element
|
394
|
+
var children = helpers_ts_1.createElement('div', 'children');
|
395
|
+
// set CSS classes for children
|
396
|
+
if (this.isObject) {
|
397
|
+
children.classList.add(helpers_ts_1.cssClass('object'));
|
398
|
+
}
|
399
|
+
if (this.isArray) {
|
400
|
+
children.classList.add(helpers_ts_1.cssClass('array'));
|
401
|
+
}
|
402
|
+
if (this.isEmpty) {
|
403
|
+
children.classList.add(helpers_ts_1.cssClass('empty'));
|
404
|
+
}
|
405
|
+
// set CSS classes for root element
|
406
|
+
if (this.config && this.config.theme) {
|
407
|
+
this.element.classList.add(helpers_ts_1.cssClass(this.config.theme));
|
408
|
+
}
|
409
|
+
if (this.isOpen) {
|
410
|
+
this.element.classList.add(helpers_ts_1.cssClass('open'));
|
411
|
+
}
|
412
|
+
// append toggler and children elements to root element
|
413
|
+
this.element.appendChild(togglerLink);
|
414
|
+
this.element.appendChild(children);
|
415
|
+
// if formatter is set to be open call appendChildren
|
416
|
+
if (this.isObject && this.isOpen) {
|
417
|
+
this.appendChildren();
|
418
|
+
}
|
419
|
+
// add event listener for toggling
|
420
|
+
if (this.isObject) {
|
421
|
+
togglerLink.addEventListener('click', this.toggleOpen.bind(this));
|
422
|
+
}
|
423
|
+
return this.element;
|
424
|
+
};
|
425
|
+
/**
|
426
|
+
* Appends all the children to children element
|
427
|
+
* Animated option is used when user triggers this via a click
|
428
|
+
*/
|
429
|
+
JSONFormatter.prototype.appendChildren = function (animated) {
|
430
|
+
var _this = this;
|
431
|
+
if (animated === void 0) { animated = false; }
|
432
|
+
var children = this.element.querySelector("div." + helpers_ts_1.cssClass('children'));
|
433
|
+
if (!children || this.isEmpty) {
|
434
|
+
return;
|
435
|
+
}
|
436
|
+
if (animated) {
|
437
|
+
var index_1 = 0;
|
438
|
+
var addAChild_1 = function () {
|
439
|
+
var key = _this.keys[index_1];
|
440
|
+
var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
|
441
|
+
children.appendChild(formatter.render());
|
442
|
+
index_1 += 1;
|
443
|
+
if (index_1 < _this.keys.length) {
|
444
|
+
if (index_1 > MAX_ANIMATED_TOGGLE_ITEMS) {
|
445
|
+
addAChild_1();
|
446
|
+
}
|
447
|
+
else {
|
448
|
+
requestAnimationFrame(addAChild_1);
|
449
|
+
}
|
450
|
+
}
|
451
|
+
};
|
452
|
+
requestAnimationFrame(addAChild_1);
|
453
|
+
}
|
454
|
+
else {
|
455
|
+
this.keys.forEach(function (key) {
|
456
|
+
var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
|
457
|
+
children.appendChild(formatter.render());
|
458
|
+
});
|
459
|
+
}
|
460
|
+
};
|
461
|
+
/**
|
462
|
+
* Removes all the children from children element
|
463
|
+
* Animated option is used when user triggers this via a click
|
464
|
+
*/
|
465
|
+
JSONFormatter.prototype.removeChildren = function (animated) {
|
466
|
+
if (animated === void 0) { animated = false; }
|
467
|
+
var childrenElement = this.element.querySelector("div." + helpers_ts_1.cssClass('children'));
|
468
|
+
if (animated) {
|
469
|
+
var childrenRemoved_1 = 0;
|
470
|
+
var removeAChild_1 = function () {
|
471
|
+
if (childrenElement && childrenElement.children.length) {
|
472
|
+
childrenElement.removeChild(childrenElement.children[0]);
|
473
|
+
childrenRemoved_1 += 1;
|
474
|
+
if (childrenRemoved_1 > MAX_ANIMATED_TOGGLE_ITEMS) {
|
475
|
+
removeAChild_1();
|
476
|
+
}
|
477
|
+
else {
|
478
|
+
requestAnimationFrame(removeAChild_1);
|
479
|
+
}
|
480
|
+
}
|
481
|
+
};
|
482
|
+
requestAnimationFrame(removeAChild_1);
|
483
|
+
}
|
484
|
+
else {
|
485
|
+
if (childrenElement) {
|
486
|
+
childrenElement.innerHTML = '';
|
487
|
+
}
|
488
|
+
}
|
489
|
+
};
|
490
|
+
return JSONFormatter;
|
491
|
+
}());
|
492
|
+
|
493
|
+
|
494
|
+
/***/ },
|
495
|
+
/* 2 */
|
496
|
+
/***/ function(module, exports, __webpack_require__) {
|
497
|
+
|
498
|
+
// style-loader: Adds some css to the DOM by adding a <style> tag
|
499
|
+
|
500
|
+
// load the styles
|
501
|
+
var content = __webpack_require__(3);
|
502
|
+
if(typeof content === 'string') content = [[module.id, content, '']];
|
503
|
+
// add the styles to the DOM
|
504
|
+
var update = __webpack_require__(5)(content, {"sourceMap":true});
|
505
|
+
if(content.locals) module.exports = content.locals;
|
506
|
+
// Hot Module Replacement
|
507
|
+
if(false) {
|
508
|
+
// When the styles change, update the <style> tags
|
509
|
+
if(!content.locals) {
|
510
|
+
module.hot.accept("!!./../node_modules/css-loader/index.js?sourceMap!./../node_modules/less-loader/index.js?sourceMap!./style.less", function() {
|
511
|
+
var newContent = require("!!./../node_modules/css-loader/index.js?sourceMap!./../node_modules/less-loader/index.js?sourceMap!./style.less");
|
512
|
+
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
|
513
|
+
update(newContent);
|
514
|
+
});
|
515
|
+
}
|
516
|
+
// When the module is disposed, remove the <style> tags
|
517
|
+
module.hot.dispose(function() { update(); });
|
518
|
+
}
|
519
|
+
|
520
|
+
/***/ },
|
521
|
+
/* 3 */
|
522
|
+
/***/ function(module, exports, __webpack_require__) {
|
523
|
+
|
524
|
+
exports = module.exports = __webpack_require__(4)();
|
525
|
+
// imports
|
526
|
+
|
527
|
+
|
528
|
+
// module
|
529
|
+
exports.push([module.id, ".json-formatter-row {\n font-family: monospace;\n}\n.json-formatter-row,\n.json-formatter-row a,\n.json-formatter-row a:hover {\n color: black;\n text-decoration: none;\n}\n.json-formatter-row .json-formatter-row {\n margin-left: 1rem;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty:after {\n display: none;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-object:after {\n content: \"No properties\";\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-array:after {\n content: \"[]\";\n}\n.json-formatter-row .json-formatter-string {\n color: green;\n white-space: pre;\n word-wrap: break-word;\n}\n.json-formatter-row .json-formatter-number {\n color: blue;\n}\n.json-formatter-row .json-formatter-boolean {\n color: red;\n}\n.json-formatter-row .json-formatter-null {\n color: #855A00;\n}\n.json-formatter-row .json-formatter-undefined {\n color: #ca0b69;\n}\n.json-formatter-row .json-formatter-function {\n color: #FF20ED;\n}\n.json-formatter-row .json-formatter-date {\n background-color: rgba(0, 0, 0, 0.05);\n}\n.json-formatter-row .json-formatter-url {\n text-decoration: underline;\n color: blue;\n cursor: pointer;\n}\n.json-formatter-row .json-formatter-bracket {\n color: blue;\n}\n.json-formatter-row .json-formatter-key {\n color: #00008B;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-row .json-formatter-constructor-name {\n cursor: pointer;\n}\n.json-formatter-row .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: 0.6;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-row .json-formatter-toggler:after {\n display: inline-block;\n transition: transform 100ms ease-in;\n content: \"\\25BA\";\n}\n.json-formatter-row > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity 0.15s ease-in;\n font-style: italic;\n}\n.json-formatter-row:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n}\n.json-formatter-row.json-formatter-open > .json-formatter-toggler-link .json-formatter-toggler:after {\n transform: rotate(90deg);\n}\n.json-formatter-row.json-formatter-open > .json-formatter-children:after {\n display: inline-block;\n}\n.json-formatter-row.json-formatter-open > a > .json-formatter-preview-text {\n display: none;\n}\n.json-formatter-row.json-formatter-open.json-formatter-empty:after {\n display: block;\n}\n.json-formatter-dark.json-formatter-row {\n font-family: monospace;\n}\n.json-formatter-dark.json-formatter-row,\n.json-formatter-dark.json-formatter-row a,\n.json-formatter-dark.json-formatter-row a:hover {\n color: white;\n text-decoration: none;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-row {\n margin-left: 1rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty:after {\n display: none;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-object:after {\n content: \"No properties\";\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-array:after {\n content: \"[]\";\n}\n.json-formatter-dark.json-formatter-row .json-formatter-string {\n color: #31F031;\n white-space: pre;\n word-wrap: break-word;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-number {\n color: #66C2FF;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-boolean {\n color: #EC4242;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-null {\n color: #EEC97D;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-undefined {\n color: #ef8fbe;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-function {\n color: #FD48CB;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-date {\n background-color: rgba(255, 255, 255, 0.05);\n}\n.json-formatter-dark.json-formatter-row .json-formatter-url {\n text-decoration: underline;\n color: #027BFF;\n cursor: pointer;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-bracket {\n color: #9494FF;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-key {\n color: #23A0DB;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-constructor-name {\n cursor: pointer;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: 0.6;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler:after {\n display: inline-block;\n transition: transform 100ms ease-in;\n content: \"\\25BA\";\n}\n.json-formatter-dark.json-formatter-row > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity 0.15s ease-in;\n font-style: italic;\n}\n.json-formatter-dark.json-formatter-row:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > .json-formatter-toggler-link .json-formatter-toggler:after {\n transform: rotate(90deg);\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > .json-formatter-children:after {\n display: inline-block;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > a > .json-formatter-preview-text {\n display: none;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open.json-formatter-empty:after {\n display: block;\n}\n", "", {"version":3,"sources":["/./src/style.less","/./src/style.less"],"names":[],"mappings":"AA0GA;EA3FE,uBAAA;CCbD;ADcC;;;EACE,aAAA;EACA,sBAAA;CCVH;ADkGD;EApFI,kBAAA;CCXH;ADeG;EACE,aAAA;EACA,kBAAA;CCbL;ADeK;EAAU,cAAA;CCZf;ADaK;EAAgC,yBAAA;CCVrC;ADWK;EAA+B,cAAA;CCRpC;ADkFD;EArEI,aAAA;EACA,iBAAA;EACA,sBAAA;CCVH;AD6ED;EAjE2B,YAAA;CCT1B;AD0ED;EAhE4B,WAAA;CCP3B;ADuED;EA/DyB,eAAA;CCLxB;ADoED;EA9D8B,eAAA;CCH7B;ADiED;EA7D6B,eAAA;CCD5B;AD8DD;EA5DyB,sCAAA;CCCxB;AD2DD;EA1DI,2BAAA;EACA,YAAA;EACA,gBAAA;CCEH;ADsDD;EArD4B,YAAA;CCE3B;ADmDD;EAnDI,eAAA;EACA,gBAAA;EACA,sBAAA;CCGH;AD8CD;EA9CI,gBAAA;CCGH;AD2CD;EA1CI,oBAAA;EACA,kBAAA;EACA,uBAAA;EACA,aAAA;EACA,gBAAA;EACA,sBAAA;CCEH;ADAG;EACE,sBAAA;EACA,oCAAA;EACA,iBAAA;CCEL;AD8BD;EA1BI,WAAA;EACA,kCAAA;EACA,mBAAA;CCDH;ADGC;EACE,aAAA;CCDH;ADKC;EAEI,yBAAA;CCJL;ADEC;EAKI,sBAAA;CCJL;ADDC;EAQI,cAAA;CCJL;ADMG;EACE,eAAA;CCJL;ADeD;EAhGE,uBAAA;CCoFD;ADnFC;;;EACE,aAAA;EACA,sBAAA;CCuFH;ADMD;EAzFI,kBAAA;CCsFH;ADlFG;EACE,aAAA;EACA,kBAAA;CCoFL;ADlFK;EAAU,cAAA;CCqFf;ADpFK;EAAgC,yBAAA;CCuFrC;ADtFK;EAA+B,cAAA;CCyFpC;ADVD;EA1EI,eAAA;EACA,iBAAA;EACA,sBAAA;CCuFH;ADfD;EAtE2B,eAAA;CCwF1B;ADlBD;EArE4B,eAAA;CC0F3B;ADrBD;EApEyB,eAAA;CC4FxB;ADxBD;EAnE8B,eAAA;CC8F7B;AD3BD;EAlE6B,eAAA;CCgG5B;AD9BD;EAjEyB,4CAAA;CCkGxB;ADjCD;EA/DI,2BAAA;EACA,eAAA;EACA,gBAAA;CCmGH;ADtCD;EA1D4B,eAAA;CCmG3B;ADzCD;EAxDI,eAAA;EACA,gBAAA;EACA,sBAAA;CCoGH;AD9CD;EAnDI,gBAAA;CCoGH;ADjDD;EA/CI,oBAAA;EACA,kBAAA;EACA,uBAAA;EACA,aAAA;EACA,gBAAA;EACA,sBAAA;CCmGH;ADjGG;EACE,sBAAA;EACA,oCAAA;EACA,iBAAA;CCmGL;AD9DD;EA/BI,WAAA;EACA,kCAAA;EACA,mBAAA;CCgGH;AD9FC;EACE,aAAA;CCgGH;AD5FC;EAEI,yBAAA;CC6FL;AD/FC;EAKI,sBAAA;CC6FL;ADlGC;EAQI,cAAA;CC6FL;AD3FG;EACE,eAAA;CC6FL","file":"style.less","sourcesContent":[".theme(\n @default-color: black,\n @string-color: green,\n @number-color: blue,\n @boolean-color: red,\n @null-color: #855A00,\n @undefined-color: rgb(202, 11, 105),\n @function-color: #FF20ED,\n @rotate-time: 100ms,\n @toggler-opacity: 0.6,\n @toggler-color: #45376F,\n @bracket-color: blue,\n @key-color: #00008B,\n @url-color: blue ){\n\n font-family: monospace;\n &, a, a:hover {\n color: @default-color;\n text-decoration: none;\n }\n\n .json-formatter-row {\n margin-left: 1rem;\n }\n\n .json-formatter-children {\n &.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n\n &:after { display: none; }\n &.json-formatter-object:after { content: \"No properties\"; }\n &.json-formatter-array:after { content: \"[]\"; }\n }\n }\n\n .json-formatter-string {\n color: @string-color;\n white-space: pre;\n word-wrap: break-word;\n }\n .json-formatter-number { color: @number-color; }\n .json-formatter-boolean { color: @boolean-color; }\n .json-formatter-null { color: @null-color; }\n .json-formatter-undefined { color: @undefined-color; }\n .json-formatter-function { color: @function-color; }\n .json-formatter-date { background-color: fade(@default-color, 5%); }\n .json-formatter-url {\n text-decoration: underline;\n color: @url-color;\n cursor: pointer;\n }\n\n .json-formatter-bracket { color: @bracket-color; }\n .json-formatter-key {\n color: @key-color;\n cursor: pointer;\n padding-right: 0.2rem;\n }\n .json-formatter-constructor-name {\n cursor: pointer;\n }\n\n .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: @toggler-opacity;\n cursor: pointer;\n padding-right: 0.2rem;\n\n &:after {\n display: inline-block;\n transition: transform @rotate-time ease-in;\n content: \"►\";\n }\n }\n\n // Inline preview on hover (optional)\n > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity .15s ease-in;\n font-style: italic;\n }\n &:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n }\n\n // Open state\n &.json-formatter-open {\n > .json-formatter-toggler-link .json-formatter-toggler:after{\n transform: rotate(90deg);\n }\n > .json-formatter-children:after {\n display: inline-block;\n }\n > a > .json-formatter-preview-text {\n display: none;\n }\n &.json-formatter-empty:after {\n display: block;\n }\n }\n}\n\n// Default theme\n.json-formatter-row {\n .theme();\n}\n\n// Dark theme\n.json-formatter-dark.json-formatter-row {\n .theme(\n @default-color: white,\n @string-color: #31F031,\n @number-color: #66C2FF,\n @boolean-color: #EC4242,\n @null-color: #EEC97D,\n @undefined-color: rgb(239, 143, 190),\n @function-color: #FD48CB,\n @rotate-time: 100ms,\n @toggler-opacity: 0.6,\n @toggler-color: #45376F,\n @bracket-color: #9494FF,\n @key-color: #23A0DB,\n @url-color: #027BFF);\n}\n",".json-formatter-row {\n font-family: monospace;\n}\n.json-formatter-row,\n.json-formatter-row a,\n.json-formatter-row a:hover {\n color: black;\n text-decoration: none;\n}\n.json-formatter-row .json-formatter-row {\n margin-left: 1rem;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty:after {\n display: none;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-object:after {\n content: \"No properties\";\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-array:after {\n content: \"[]\";\n}\n.json-formatter-row .json-formatter-string {\n color: green;\n white-space: pre;\n word-wrap: break-word;\n}\n.json-formatter-row .json-formatter-number {\n color: blue;\n}\n.json-formatter-row .json-formatter-boolean {\n color: red;\n}\n.json-formatter-row .json-formatter-null {\n color: #855A00;\n}\n.json-formatter-row .json-formatter-undefined {\n color: #ca0b69;\n}\n.json-formatter-row .json-formatter-function {\n color: #FF20ED;\n}\n.json-formatter-row .json-formatter-date {\n background-color: rgba(0, 0, 0, 0.05);\n}\n.json-formatter-row .json-formatter-url {\n text-decoration: underline;\n color: blue;\n cursor: pointer;\n}\n.json-formatter-row .json-formatter-bracket {\n color: blue;\n}\n.json-formatter-row .json-formatter-key {\n color: #00008B;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-row .json-formatter-constructor-name {\n cursor: pointer;\n}\n.json-formatter-row .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: 0.6;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-row .json-formatter-toggler:after {\n display: inline-block;\n transition: transform 100ms ease-in;\n content: \"►\";\n}\n.json-formatter-row > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity 0.15s ease-in;\n font-style: italic;\n}\n.json-formatter-row:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n}\n.json-formatter-row.json-formatter-open > .json-formatter-toggler-link .json-formatter-toggler:after {\n transform: rotate(90deg);\n}\n.json-formatter-row.json-formatter-open > .json-formatter-children:after {\n display: inline-block;\n}\n.json-formatter-row.json-formatter-open > a > .json-formatter-preview-text {\n display: none;\n}\n.json-formatter-row.json-formatter-open.json-formatter-empty:after {\n display: block;\n}\n.json-formatter-dark.json-formatter-row {\n font-family: monospace;\n}\n.json-formatter-dark.json-formatter-row,\n.json-formatter-dark.json-formatter-row a,\n.json-formatter-dark.json-formatter-row a:hover {\n color: white;\n text-decoration: none;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-row {\n margin-left: 1rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty:after {\n display: none;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-object:after {\n content: \"No properties\";\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-array:after {\n content: \"[]\";\n}\n.json-formatter-dark.json-formatter-row .json-formatter-string {\n color: #31F031;\n white-space: pre;\n word-wrap: break-word;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-number {\n color: #66C2FF;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-boolean {\n color: #EC4242;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-null {\n color: #EEC97D;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-undefined {\n color: #ef8fbe;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-function {\n color: #FD48CB;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-date {\n background-color: rgba(255, 255, 255, 0.05);\n}\n.json-formatter-dark.json-formatter-row .json-formatter-url {\n text-decoration: underline;\n color: #027BFF;\n cursor: pointer;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-bracket {\n color: #9494FF;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-key {\n color: #23A0DB;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-constructor-name {\n cursor: pointer;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: 0.6;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler:after {\n display: inline-block;\n transition: transform 100ms ease-in;\n content: \"►\";\n}\n.json-formatter-dark.json-formatter-row > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity 0.15s ease-in;\n font-style: italic;\n}\n.json-formatter-dark.json-formatter-row:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > .json-formatter-toggler-link .json-formatter-toggler:after {\n transform: rotate(90deg);\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > .json-formatter-children:after {\n display: inline-block;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > a > .json-formatter-preview-text {\n display: none;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open.json-formatter-empty:after {\n display: block;\n}\n"],"sourceRoot":"webpack://"}]);
|
530
|
+
|
531
|
+
// exports
|
532
|
+
|
533
|
+
|
534
|
+
/***/ },
|
535
|
+
/* 4 */
|
536
|
+
/***/ function(module, exports) {
|
537
|
+
|
538
|
+
/*
|
539
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
540
|
+
Author Tobias Koppers @sokra
|
541
|
+
*/
|
542
|
+
// css base code, injected by the css-loader
|
543
|
+
module.exports = function() {
|
544
|
+
var list = [];
|
545
|
+
|
546
|
+
// return the list of modules as css string
|
547
|
+
list.toString = function toString() {
|
548
|
+
var result = [];
|
549
|
+
for(var i = 0; i < this.length; i++) {
|
550
|
+
var item = this[i];
|
551
|
+
if(item[2]) {
|
552
|
+
result.push("@media " + item[2] + "{" + item[1] + "}");
|
553
|
+
} else {
|
554
|
+
result.push(item[1]);
|
555
|
+
}
|
556
|
+
}
|
557
|
+
return result.join("");
|
558
|
+
};
|
559
|
+
|
560
|
+
// import a list of modules into the list
|
561
|
+
list.i = function(modules, mediaQuery) {
|
562
|
+
if(typeof modules === "string")
|
563
|
+
modules = [[null, modules, ""]];
|
564
|
+
var alreadyImportedModules = {};
|
565
|
+
for(var i = 0; i < this.length; i++) {
|
566
|
+
var id = this[i][0];
|
567
|
+
if(typeof id === "number")
|
568
|
+
alreadyImportedModules[id] = true;
|
569
|
+
}
|
570
|
+
for(i = 0; i < modules.length; i++) {
|
571
|
+
var item = modules[i];
|
572
|
+
// skip already imported module
|
573
|
+
// this implementation is not 100% perfect for weird media query combinations
|
574
|
+
// when a module is imported multiple times with different media queries.
|
575
|
+
// I hope this will never occur (Hey this way we have smaller bundles)
|
576
|
+
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
|
577
|
+
if(mediaQuery && !item[2]) {
|
578
|
+
item[2] = mediaQuery;
|
579
|
+
} else if(mediaQuery) {
|
580
|
+
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
|
581
|
+
}
|
582
|
+
list.push(item);
|
583
|
+
}
|
584
|
+
}
|
585
|
+
};
|
586
|
+
return list;
|
587
|
+
};
|
588
|
+
|
589
|
+
|
590
|
+
/***/ },
|
591
|
+
/* 5 */
|
592
|
+
/***/ function(module, exports, __webpack_require__) {
|
593
|
+
|
594
|
+
/*
|
595
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
596
|
+
Author Tobias Koppers @sokra
|
597
|
+
*/
|
598
|
+
var stylesInDom = {},
|
599
|
+
memoize = function(fn) {
|
600
|
+
var memo;
|
601
|
+
return function () {
|
602
|
+
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
|
603
|
+
return memo;
|
604
|
+
};
|
605
|
+
},
|
606
|
+
isOldIE = memoize(function() {
|
607
|
+
return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
|
608
|
+
}),
|
609
|
+
getHeadElement = memoize(function () {
|
610
|
+
return document.head || document.getElementsByTagName("head")[0];
|
611
|
+
}),
|
612
|
+
singletonElement = null,
|
613
|
+
singletonCounter = 0,
|
614
|
+
styleElementsInsertedAtTop = [];
|
615
|
+
|
616
|
+
module.exports = function(list, options) {
|
617
|
+
if(false) {
|
618
|
+
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
|
619
|
+
}
|
620
|
+
|
621
|
+
options = options || {};
|
622
|
+
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
|
623
|
+
// tags it will allow on a page
|
624
|
+
if (typeof options.singleton === "undefined") options.singleton = isOldIE();
|
625
|
+
|
626
|
+
// By default, add <style> tags to the bottom of <head>.
|
627
|
+
if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
|
628
|
+
|
629
|
+
var styles = listToStyles(list);
|
630
|
+
addStylesToDom(styles, options);
|
631
|
+
|
632
|
+
return function update(newList) {
|
633
|
+
var mayRemove = [];
|
634
|
+
for(var i = 0; i < styles.length; i++) {
|
635
|
+
var item = styles[i];
|
636
|
+
var domStyle = stylesInDom[item.id];
|
637
|
+
domStyle.refs--;
|
638
|
+
mayRemove.push(domStyle);
|
639
|
+
}
|
640
|
+
if(newList) {
|
641
|
+
var newStyles = listToStyles(newList);
|
642
|
+
addStylesToDom(newStyles, options);
|
643
|
+
}
|
644
|
+
for(var i = 0; i < mayRemove.length; i++) {
|
645
|
+
var domStyle = mayRemove[i];
|
646
|
+
if(domStyle.refs === 0) {
|
647
|
+
for(var j = 0; j < domStyle.parts.length; j++)
|
648
|
+
domStyle.parts[j]();
|
649
|
+
delete stylesInDom[domStyle.id];
|
650
|
+
}
|
651
|
+
}
|
652
|
+
};
|
653
|
+
}
|
654
|
+
|
655
|
+
function addStylesToDom(styles, options) {
|
656
|
+
for(var i = 0; i < styles.length; i++) {
|
657
|
+
var item = styles[i];
|
658
|
+
var domStyle = stylesInDom[item.id];
|
659
|
+
if(domStyle) {
|
660
|
+
domStyle.refs++;
|
661
|
+
for(var j = 0; j < domStyle.parts.length; j++) {
|
662
|
+
domStyle.parts[j](item.parts[j]);
|
663
|
+
}
|
664
|
+
for(; j < item.parts.length; j++) {
|
665
|
+
domStyle.parts.push(addStyle(item.parts[j], options));
|
666
|
+
}
|
667
|
+
} else {
|
668
|
+
var parts = [];
|
669
|
+
for(var j = 0; j < item.parts.length; j++) {
|
670
|
+
parts.push(addStyle(item.parts[j], options));
|
671
|
+
}
|
672
|
+
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
|
673
|
+
}
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
function listToStyles(list) {
|
678
|
+
var styles = [];
|
679
|
+
var newStyles = {};
|
680
|
+
for(var i = 0; i < list.length; i++) {
|
681
|
+
var item = list[i];
|
682
|
+
var id = item[0];
|
683
|
+
var css = item[1];
|
684
|
+
var media = item[2];
|
685
|
+
var sourceMap = item[3];
|
686
|
+
var part = {css: css, media: media, sourceMap: sourceMap};
|
687
|
+
if(!newStyles[id])
|
688
|
+
styles.push(newStyles[id] = {id: id, parts: [part]});
|
689
|
+
else
|
690
|
+
newStyles[id].parts.push(part);
|
691
|
+
}
|
692
|
+
return styles;
|
693
|
+
}
|
694
|
+
|
695
|
+
function insertStyleElement(options, styleElement) {
|
696
|
+
var head = getHeadElement();
|
697
|
+
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
|
698
|
+
if (options.insertAt === "top") {
|
699
|
+
if(!lastStyleElementInsertedAtTop) {
|
700
|
+
head.insertBefore(styleElement, head.firstChild);
|
701
|
+
} else if(lastStyleElementInsertedAtTop.nextSibling) {
|
702
|
+
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
|
703
|
+
} else {
|
704
|
+
head.appendChild(styleElement);
|
705
|
+
}
|
706
|
+
styleElementsInsertedAtTop.push(styleElement);
|
707
|
+
} else if (options.insertAt === "bottom") {
|
708
|
+
head.appendChild(styleElement);
|
709
|
+
} else {
|
710
|
+
throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
|
711
|
+
}
|
712
|
+
}
|
713
|
+
|
714
|
+
function removeStyleElement(styleElement) {
|
715
|
+
styleElement.parentNode.removeChild(styleElement);
|
716
|
+
var idx = styleElementsInsertedAtTop.indexOf(styleElement);
|
717
|
+
if(idx >= 0) {
|
718
|
+
styleElementsInsertedAtTop.splice(idx, 1);
|
719
|
+
}
|
720
|
+
}
|
721
|
+
|
722
|
+
function createStyleElement(options) {
|
723
|
+
var styleElement = document.createElement("style");
|
724
|
+
styleElement.type = "text/css";
|
725
|
+
insertStyleElement(options, styleElement);
|
726
|
+
return styleElement;
|
727
|
+
}
|
728
|
+
|
729
|
+
function createLinkElement(options) {
|
730
|
+
var linkElement = document.createElement("link");
|
731
|
+
linkElement.rel = "stylesheet";
|
732
|
+
insertStyleElement(options, linkElement);
|
733
|
+
return linkElement;
|
734
|
+
}
|
735
|
+
|
736
|
+
function addStyle(obj, options) {
|
737
|
+
var styleElement, update, remove;
|
738
|
+
|
739
|
+
if (options.singleton) {
|
740
|
+
var styleIndex = singletonCounter++;
|
741
|
+
styleElement = singletonElement || (singletonElement = createStyleElement(options));
|
742
|
+
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
|
743
|
+
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
|
744
|
+
} else if(obj.sourceMap &&
|
745
|
+
typeof URL === "function" &&
|
746
|
+
typeof URL.createObjectURL === "function" &&
|
747
|
+
typeof URL.revokeObjectURL === "function" &&
|
748
|
+
typeof Blob === "function" &&
|
749
|
+
typeof btoa === "function") {
|
750
|
+
styleElement = createLinkElement(options);
|
751
|
+
update = updateLink.bind(null, styleElement);
|
752
|
+
remove = function() {
|
753
|
+
removeStyleElement(styleElement);
|
754
|
+
if(styleElement.href)
|
755
|
+
URL.revokeObjectURL(styleElement.href);
|
756
|
+
};
|
757
|
+
} else {
|
758
|
+
styleElement = createStyleElement(options);
|
759
|
+
update = applyToTag.bind(null, styleElement);
|
760
|
+
remove = function() {
|
761
|
+
removeStyleElement(styleElement);
|
762
|
+
};
|
763
|
+
}
|
764
|
+
|
765
|
+
update(obj);
|
766
|
+
|
767
|
+
return function updateStyle(newObj) {
|
768
|
+
if(newObj) {
|
769
|
+
if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
|
770
|
+
return;
|
771
|
+
update(obj = newObj);
|
772
|
+
} else {
|
773
|
+
remove();
|
774
|
+
}
|
775
|
+
};
|
776
|
+
}
|
777
|
+
|
778
|
+
var replaceText = (function () {
|
779
|
+
var textStore = [];
|
780
|
+
|
781
|
+
return function (index, replacement) {
|
782
|
+
textStore[index] = replacement;
|
783
|
+
return textStore.filter(Boolean).join('\n');
|
784
|
+
};
|
785
|
+
})();
|
786
|
+
|
787
|
+
function applyToSingletonTag(styleElement, index, remove, obj) {
|
788
|
+
var css = remove ? "" : obj.css;
|
789
|
+
|
790
|
+
if (styleElement.styleSheet) {
|
791
|
+
styleElement.styleSheet.cssText = replaceText(index, css);
|
792
|
+
} else {
|
793
|
+
var cssNode = document.createTextNode(css);
|
794
|
+
var childNodes = styleElement.childNodes;
|
795
|
+
if (childNodes[index]) styleElement.removeChild(childNodes[index]);
|
796
|
+
if (childNodes.length) {
|
797
|
+
styleElement.insertBefore(cssNode, childNodes[index]);
|
798
|
+
} else {
|
799
|
+
styleElement.appendChild(cssNode);
|
800
|
+
}
|
801
|
+
}
|
802
|
+
}
|
803
|
+
|
804
|
+
function applyToTag(styleElement, obj) {
|
805
|
+
var css = obj.css;
|
806
|
+
var media = obj.media;
|
807
|
+
|
808
|
+
if(media) {
|
809
|
+
styleElement.setAttribute("media", media)
|
810
|
+
}
|
811
|
+
|
812
|
+
if(styleElement.styleSheet) {
|
813
|
+
styleElement.styleSheet.cssText = css;
|
814
|
+
} else {
|
815
|
+
while(styleElement.firstChild) {
|
816
|
+
styleElement.removeChild(styleElement.firstChild);
|
817
|
+
}
|
818
|
+
styleElement.appendChild(document.createTextNode(css));
|
819
|
+
}
|
820
|
+
}
|
821
|
+
|
822
|
+
function updateLink(linkElement, obj) {
|
823
|
+
var css = obj.css;
|
824
|
+
var sourceMap = obj.sourceMap;
|
825
|
+
|
826
|
+
if(sourceMap) {
|
827
|
+
// http://stackoverflow.com/a/26603875
|
828
|
+
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
|
829
|
+
}
|
830
|
+
|
831
|
+
var blob = new Blob([css], { type: "text/css" });
|
832
|
+
|
833
|
+
var oldSrc = linkElement.href;
|
834
|
+
|
835
|
+
linkElement.href = URL.createObjectURL(blob);
|
836
|
+
|
837
|
+
if(oldSrc)
|
838
|
+
URL.revokeObjectURL(oldSrc);
|
839
|
+
}
|
840
|
+
|
841
|
+
|
842
|
+
/***/ },
|
843
|
+
/* 6 */
|
844
|
+
/***/ function(module, exports) {
|
845
|
+
|
846
|
+
"use strict";
|
847
|
+
/*
|
848
|
+
* Escapes `"` charachters from string
|
849
|
+
*/
|
850
|
+
function escapeString(str) {
|
851
|
+
return str.replace('"', '\"');
|
852
|
+
}
|
853
|
+
/*
|
854
|
+
* Determines if a value is an object
|
855
|
+
*/
|
856
|
+
function isObject(value) {
|
857
|
+
var type = typeof value;
|
858
|
+
return !!value && (type == 'object');
|
859
|
+
}
|
860
|
+
exports.isObject = isObject;
|
861
|
+
/*
|
862
|
+
* Gets constructor name of an object.
|
863
|
+
* From http://stackoverflow.com/a/332429
|
864
|
+
*
|
865
|
+
*/
|
866
|
+
function getObjectName(object) {
|
867
|
+
if (object === undefined) {
|
868
|
+
return '';
|
869
|
+
}
|
870
|
+
if (object === null) {
|
871
|
+
return 'Object';
|
872
|
+
}
|
873
|
+
if (typeof object === 'object' && !object.constructor) {
|
874
|
+
return 'Object';
|
875
|
+
}
|
876
|
+
var funcNameRegex = /function ([^(]*)/;
|
877
|
+
var results = (funcNameRegex).exec((object).constructor.toString());
|
878
|
+
if (results && results.length > 1) {
|
879
|
+
return results[1];
|
880
|
+
}
|
881
|
+
else {
|
882
|
+
return '';
|
883
|
+
}
|
884
|
+
}
|
885
|
+
exports.getObjectName = getObjectName;
|
886
|
+
/*
|
887
|
+
* Gets type of an object. Returns "null" for null objects
|
888
|
+
*/
|
889
|
+
function getType(object) {
|
890
|
+
if (object === null) {
|
891
|
+
return 'null';
|
892
|
+
}
|
893
|
+
return typeof object;
|
894
|
+
}
|
895
|
+
exports.getType = getType;
|
896
|
+
/*
|
897
|
+
* Generates inline preview for a JavaScript object based on a value
|
898
|
+
*/
|
899
|
+
function getValuePreview(object, value) {
|
900
|
+
var type = getType(object);
|
901
|
+
if (type === 'null' || type === 'undefined') {
|
902
|
+
return type;
|
903
|
+
}
|
904
|
+
if (type === 'string') {
|
905
|
+
value = '"' + escapeString(value) + '"';
|
906
|
+
}
|
907
|
+
if (type === 'function') {
|
908
|
+
// Remove content of the function
|
909
|
+
return object.toString()
|
910
|
+
.replace(/[\r\n]/g, '')
|
911
|
+
.replace(/\{.*\}/, '') + '{…}';
|
912
|
+
}
|
913
|
+
return value;
|
914
|
+
}
|
915
|
+
exports.getValuePreview = getValuePreview;
|
916
|
+
/*
|
917
|
+
* Generates inline preview for a JavaScript object
|
918
|
+
*/
|
919
|
+
function getPreview(object) {
|
920
|
+
var value = '';
|
921
|
+
if (isObject(object)) {
|
922
|
+
value = getObjectName(object);
|
923
|
+
if (Array.isArray(object))
|
924
|
+
value += '[' + object.length + ']';
|
925
|
+
}
|
926
|
+
else {
|
927
|
+
value = getValuePreview(object, object);
|
928
|
+
}
|
929
|
+
return value;
|
930
|
+
}
|
931
|
+
exports.getPreview = getPreview;
|
932
|
+
/*
|
933
|
+
* Generates a prefixed CSS class name
|
934
|
+
*/
|
935
|
+
function cssClass(className) {
|
936
|
+
return "json-formatter-" + className;
|
937
|
+
}
|
938
|
+
exports.cssClass = cssClass;
|
939
|
+
/*
|
940
|
+
* Creates a new DOM element wiht given type and class
|
941
|
+
* TODO: move me to helpers
|
942
|
+
*/
|
943
|
+
function createElement(type, className, content) {
|
944
|
+
var el = document.createElement(type);
|
945
|
+
if (className) {
|
946
|
+
el.classList.add(cssClass(className));
|
947
|
+
}
|
948
|
+
if (content !== undefined) {
|
949
|
+
if (content instanceof Node) {
|
950
|
+
el.appendChild(content);
|
951
|
+
}
|
952
|
+
else {
|
953
|
+
el.appendChild(document.createTextNode(String(content)));
|
954
|
+
}
|
955
|
+
}
|
956
|
+
return el;
|
957
|
+
}
|
958
|
+
exports.createElement = createElement;
|
959
|
+
|
960
|
+
|
961
|
+
/***/ }
|
962
|
+
/******/ ])
|
963
|
+
});
|
964
|
+
;
|
965
|
+
//# sourceMappingURL=json-formatter.js.map
|