wf_node_api 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +66 -0
- data/LICENSE +340 -0
- data/Makefile +19 -0
- data/README.md +78 -0
- data/Rakefile +2 -0
- data/Vagrantfile +102 -0
- data/_docs/api/Api/NodeApi.html +123 -0
- data/_docs/api/Api.html +149 -0
- data/_docs/api/Config/Check.html +331 -0
- data/_docs/api/Config.html +115 -0
- data/_docs/api/ConfigCheck.html +365 -0
- data/_docs/api/ContainerManager.html +1632 -0
- data/_docs/api/ContainerManagerAdapter/Lxc.html +1352 -0
- data/_docs/api/ContainerManagerAdapter/Vserver.html +1358 -0
- data/_docs/api/ContainerManagerAdapter.html +151 -0
- data/_docs/api/Error/NotFound.html +134 -0
- data/_docs/api/Error.html +115 -0
- data/_docs/api/NotFoundError.html +157 -0
- data/_docs/api/OS.html +234 -0
- data/_docs/api/ResourceManager.html +322 -0
- data/_docs/api/ResourceManagerAdapter/Linux.html +326 -0
- data/_docs/api/ResourceManagerAdapter.html +149 -0
- data/_docs/api/WfNodeApi.html +163 -0
- data/_docs/api/_index.html +239 -0
- data/_docs/api/class_list.html +58 -0
- data/_docs/api/css/common.css +1 -0
- data/_docs/api/css/full_list.css +57 -0
- data/_docs/api/css/style.css +339 -0
- data/_docs/api/file.README.html +146 -0
- data/_docs/api/file_list.html +60 -0
- data/_docs/api/frames.html +26 -0
- data/_docs/api/index.html +146 -0
- data/_docs/api/js/app.js +219 -0
- data/_docs/api/js/full_list.js +181 -0
- data/_docs/api/js/jquery.js +4 -0
- data/_docs/api/method_list.html +273 -0
- data/_docs/api/top-level-namespace.html +244 -0
- data/_docs/rest/api_data.js +1 -0
- data/_docs/rest/api_data.json +1 -0
- data/_docs/rest/api_project.js +1 -0
- data/_docs/rest/api_project.json +1 -0
- data/_docs/rest/css/style.css +538 -0
- data/_docs/rest/header.md +3 -0
- data/_docs/rest/img/favicon.ico +0 -0
- data/_docs/rest/img/glyphicons-halflings-white.png +0 -0
- data/_docs/rest/img/glyphicons-halflings.png +0 -0
- data/_docs/rest/index.html +658 -0
- data/_docs/rest/locales/de.js +25 -0
- data/_docs/rest/locales/fr.js +25 -0
- data/_docs/rest/locales/locale.js +43 -0
- data/_docs/rest/locales/nl.js +25 -0
- data/_docs/rest/locales/pl.js +25 -0
- data/_docs/rest/locales/pt_br.js +25 -0
- data/_docs/rest/locales/ru.js +25 -0
- data/_docs/rest/locales/zh.js +25 -0
- data/_docs/rest/main.js +691 -0
- data/_docs/rest/utils/handlebars_helper.js +327 -0
- data/_docs/rest/utils/send_sample_request.js +158 -0
- data/_docs/rest/vendor/bootstrap-responsive.min.css +9 -0
- data/_docs/rest/vendor/bootstrap.min.css +9 -0
- data/_docs/rest/vendor/bootstrap.min.js +6 -0
- data/_docs/rest/vendor/diff_match_patch.min.js +49 -0
- data/_docs/rest/vendor/handlebars.min.js +28 -0
- data/_docs/rest/vendor/jquery.min.js +4 -0
- data/_docs/rest/vendor/lodash.min.js +61 -0
- data/_docs/rest/vendor/path-to-regexp/LICENSE +21 -0
- data/_docs/rest/vendor/path-to-regexp/index.js +205 -0
- data/_docs/rest/vendor/polyfill.js +100 -0
- data/_docs/rest/vendor/prettify/lang-apollo.js +2 -0
- data/_docs/rest/vendor/prettify/lang-basic.js +3 -0
- data/_docs/rest/vendor/prettify/lang-clj.js +18 -0
- data/_docs/rest/vendor/prettify/lang-css.js +2 -0
- data/_docs/rest/vendor/prettify/lang-dart.js +3 -0
- data/_docs/rest/vendor/prettify/lang-erlang.js +2 -0
- data/_docs/rest/vendor/prettify/lang-go.js +1 -0
- data/_docs/rest/vendor/prettify/lang-hs.js +2 -0
- data/_docs/rest/vendor/prettify/lang-lisp.js +3 -0
- data/_docs/rest/vendor/prettify/lang-llvm.js +1 -0
- data/_docs/rest/vendor/prettify/lang-lua.js +2 -0
- data/_docs/rest/vendor/prettify/lang-matlab.js +6 -0
- data/_docs/rest/vendor/prettify/lang-ml.js +2 -0
- data/_docs/rest/vendor/prettify/lang-mumps.js +2 -0
- data/_docs/rest/vendor/prettify/lang-n.js +4 -0
- data/_docs/rest/vendor/prettify/lang-pascal.js +3 -0
- data/_docs/rest/vendor/prettify/lang-proto.js +1 -0
- data/_docs/rest/vendor/prettify/lang-r.js +2 -0
- data/_docs/rest/vendor/prettify/lang-rd.js +1 -0
- data/_docs/rest/vendor/prettify/lang-scala.js +2 -0
- data/_docs/rest/vendor/prettify/lang-sql.js +2 -0
- data/_docs/rest/vendor/prettify/lang-tcl.js +3 -0
- data/_docs/rest/vendor/prettify/lang-tex.js +1 -0
- data/_docs/rest/vendor/prettify/lang-vb.js +2 -0
- data/_docs/rest/vendor/prettify/lang-vhdl.js +3 -0
- data/_docs/rest/vendor/prettify/lang-wiki.js +2 -0
- data/_docs/rest/vendor/prettify/lang-xq.js +3 -0
- data/_docs/rest/vendor/prettify/lang-yaml.js +2 -0
- data/_docs/rest/vendor/prettify/prettify.css +1 -0
- data/_docs/rest/vendor/prettify/prettify.js +30 -0
- data/_docs/rest/vendor/prettify/run_prettify.js +34 -0
- data/_docs/rest/vendor/prettify.css +101 -0
- data/_docs/rest/vendor/require.min.js +36 -0
- data/apidoc.json +23 -0
- data/bin/wf_node_api +80 -0
- data/lib/wf_node_api/api/node_api.rb +360 -0
- data/lib/wf_node_api/config/config_template.erb +50 -0
- data/lib/wf_node_api/config_check.rb +50 -0
- data/lib/wf_node_api/container_manager.rb +286 -0
- data/lib/wf_node_api/container_manager_adapter/lxc.rb +431 -0
- data/lib/wf_node_api/container_manager_adapter/vserver.rb +448 -0
- data/lib/wf_node_api/error/not_found.rb +27 -0
- data/lib/wf_node_api/os.rb +32 -0
- data/lib/wf_node_api/resource_manager.rb +49 -0
- data/lib/wf_node_api/resource_manager_adapter/linux.rb +53 -0
- data/lib/wf_node_api/translations.rb +38 -0
- data/lib/wf_node_api/version.rb +28 -0
- data/lib/wf_node_api.rb +57 -0
- data/manifests/files/dhozac-vserver.repo +4 -0
- data/wf-node-api.gemspec +53 -0
- metadata +221 -0
@@ -0,0 +1,327 @@
|
|
1
|
+
define([
|
2
|
+
'locales',
|
3
|
+
'handlebars',
|
4
|
+
'diffMatchPatch'
|
5
|
+
], function(locale, Handlebars, DiffMatchPatch) {
|
6
|
+
|
7
|
+
/**
|
8
|
+
* start/stop timer for simple performance check.
|
9
|
+
*/
|
10
|
+
var timer;
|
11
|
+
Handlebars.registerHelper('startTimer', function(text) {
|
12
|
+
timer = new Date();
|
13
|
+
return '';
|
14
|
+
});
|
15
|
+
|
16
|
+
Handlebars.registerHelper('stopTimer', function(text) {
|
17
|
+
console.log(new Date() - timer);
|
18
|
+
return '';
|
19
|
+
});
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Return localized Text.
|
23
|
+
* @param string text
|
24
|
+
*/
|
25
|
+
Handlebars.registerHelper('__', function(text) {
|
26
|
+
return locale.__(text);
|
27
|
+
});
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Console log.
|
31
|
+
* @param mixed obj
|
32
|
+
*/
|
33
|
+
Handlebars.registerHelper('cl', function(obj) {
|
34
|
+
console.log(obj);
|
35
|
+
return '';
|
36
|
+
});
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Replace underscore with space.
|
40
|
+
* @param string text
|
41
|
+
*/
|
42
|
+
Handlebars.registerHelper('underscoreToSpace', function(text) {
|
43
|
+
return text.replace(/(_+)/g, ' ');
|
44
|
+
});
|
45
|
+
|
46
|
+
/**
|
47
|
+
*
|
48
|
+
*/
|
49
|
+
Handlebars.registerHelper('assign', function(name) {
|
50
|
+
if(arguments.length > 0) {
|
51
|
+
var type = typeof(arguments[1]);
|
52
|
+
var arg = null;
|
53
|
+
if(type === 'string' || type === 'number' || type === 'boolean') arg = arguments[1];
|
54
|
+
Handlebars.registerHelper(name, function() { return arg; });
|
55
|
+
}
|
56
|
+
return '';
|
57
|
+
});
|
58
|
+
|
59
|
+
/**
|
60
|
+
*
|
61
|
+
*/
|
62
|
+
Handlebars.registerHelper('nl2br', function(text) {
|
63
|
+
return _handlebarsNewlineToBreak(text);
|
64
|
+
});
|
65
|
+
|
66
|
+
/**
|
67
|
+
*
|
68
|
+
*/
|
69
|
+
Handlebars.registerHelper('if_eq', function(context, options) {
|
70
|
+
var compare = context;
|
71
|
+
// Get length if context is an object
|
72
|
+
if (context instanceof Object && ! (options.hash.compare instanceof Object))
|
73
|
+
compare = Object.keys(context).length;
|
74
|
+
|
75
|
+
if (compare === options.hash.compare)
|
76
|
+
return options.fn(this);
|
77
|
+
|
78
|
+
return options.inverse(this);
|
79
|
+
});
|
80
|
+
|
81
|
+
/**
|
82
|
+
*
|
83
|
+
*/
|
84
|
+
Handlebars.registerHelper('if_gt', function(context, options) {
|
85
|
+
var compare = context;
|
86
|
+
// Get length if context is an object
|
87
|
+
if (context instanceof Object && ! (options.hash.compare instanceof Object))
|
88
|
+
compare = Object.keys(context).length;
|
89
|
+
|
90
|
+
if(compare > options.hash.compare)
|
91
|
+
return options.fn(this);
|
92
|
+
|
93
|
+
return options.inverse(this);
|
94
|
+
});
|
95
|
+
|
96
|
+
/**
|
97
|
+
*
|
98
|
+
*/
|
99
|
+
var templateCache = {};
|
100
|
+
Handlebars.registerHelper('subTemplate', function(name, sourceContext) {
|
101
|
+
if ( ! templateCache[name])
|
102
|
+
templateCache[name] = Handlebars.compile($('#template-' + name).html());
|
103
|
+
|
104
|
+
var template = templateCache[name];
|
105
|
+
var templateContext = $.extend({}, this, sourceContext.hash);
|
106
|
+
return new Handlebars.SafeString( template(templateContext) );
|
107
|
+
});
|
108
|
+
|
109
|
+
/**
|
110
|
+
*
|
111
|
+
*/
|
112
|
+
Handlebars.registerHelper('toLowerCase', function(value) {
|
113
|
+
return (value && typeof value === 'string') ? value.toLowerCase() : '';
|
114
|
+
});
|
115
|
+
|
116
|
+
/**
|
117
|
+
*
|
118
|
+
*/
|
119
|
+
Handlebars.registerHelper('splitFill', function(value, splitChar, fillChar) {
|
120
|
+
var splits = value.split(splitChar);
|
121
|
+
return new Array(splits.length).join(fillChar) + splits[splits.length - 1];
|
122
|
+
});
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Convert Newline to HTML-Break (nl2br).
|
126
|
+
*
|
127
|
+
* @param {String} text
|
128
|
+
* @returns {String}
|
129
|
+
*/
|
130
|
+
function _handlebarsNewlineToBreak(text) {
|
131
|
+
return ('' + text).replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '<br>' + '$2');
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
*
|
136
|
+
*/
|
137
|
+
Handlebars.registerHelper('each_compare_list_field', function(source, compare, options) {
|
138
|
+
var fieldName = options.hash.field;
|
139
|
+
var newSource = [];
|
140
|
+
if (source) {
|
141
|
+
source.forEach(function(entry) {
|
142
|
+
var values = entry;
|
143
|
+
values['key'] = entry[fieldName];
|
144
|
+
newSource.push(values);
|
145
|
+
});
|
146
|
+
}
|
147
|
+
|
148
|
+
var newCompare = [];
|
149
|
+
if (compare) {
|
150
|
+
compare.forEach(function(entry) {
|
151
|
+
var values = entry;
|
152
|
+
values['key'] = entry[fieldName];
|
153
|
+
newCompare.push(values);
|
154
|
+
});
|
155
|
+
}
|
156
|
+
return _handlebarsEachCompared('key', newSource, newCompare, options);
|
157
|
+
});
|
158
|
+
|
159
|
+
/**
|
160
|
+
*
|
161
|
+
*/
|
162
|
+
Handlebars.registerHelper('each_compare_keys', function(source, compare, options) {
|
163
|
+
var newSource = [];
|
164
|
+
if (source) {
|
165
|
+
var sourceFields = Object.keys(source);
|
166
|
+
sourceFields.forEach(function(name) {
|
167
|
+
var values = {};
|
168
|
+
values['value'] = source[name];
|
169
|
+
values['key'] = name;
|
170
|
+
newSource.push(values);
|
171
|
+
});
|
172
|
+
}
|
173
|
+
|
174
|
+
var newCompare = [];
|
175
|
+
if (compare) {
|
176
|
+
var compareFields = Object.keys(compare);
|
177
|
+
compareFields.forEach(function(name) {
|
178
|
+
var values = {};
|
179
|
+
values['value'] = compare[name];
|
180
|
+
values['key'] = name;
|
181
|
+
newCompare.push(values);
|
182
|
+
});
|
183
|
+
}
|
184
|
+
return _handlebarsEachCompared('key', newSource, newCompare, options);
|
185
|
+
});
|
186
|
+
|
187
|
+
/**
|
188
|
+
*
|
189
|
+
*/
|
190
|
+
Handlebars.registerHelper('each_compare_field', function(source, compare, options) {
|
191
|
+
return _handlebarsEachCompared('field', source, compare, options);
|
192
|
+
});
|
193
|
+
|
194
|
+
/**
|
195
|
+
*
|
196
|
+
*/
|
197
|
+
Handlebars.registerHelper('each_compare_title', function(source, compare, options) {
|
198
|
+
return _handlebarsEachCompared('title', source, compare, options);
|
199
|
+
});
|
200
|
+
|
201
|
+
/**
|
202
|
+
*
|
203
|
+
*/
|
204
|
+
Handlebars.registerHelper('showDiff', function(source, compare, options) {
|
205
|
+
var ds = '';
|
206
|
+
if(source === compare) {
|
207
|
+
ds = source;
|
208
|
+
} else {
|
209
|
+
if( ! source)
|
210
|
+
return compare;
|
211
|
+
|
212
|
+
if( ! compare)
|
213
|
+
return source;
|
214
|
+
|
215
|
+
var d = diffMatchPatch.diff_main(compare, source);
|
216
|
+
diffMatchPatch.diff_cleanupSemantic(d);
|
217
|
+
ds = diffMatchPatch.diff_prettyHtml(d);
|
218
|
+
ds = ds.replace(/¶/gm, '');
|
219
|
+
}
|
220
|
+
if(options === 'nl2br')
|
221
|
+
ds = _handlebarsNewlineToBreak(ds);
|
222
|
+
|
223
|
+
return ds;
|
224
|
+
});
|
225
|
+
|
226
|
+
/**
|
227
|
+
*
|
228
|
+
*/
|
229
|
+
function _handlebarsEachCompared(fieldname, source, compare, options)
|
230
|
+
{
|
231
|
+
var dataList = [];
|
232
|
+
var index = 0;
|
233
|
+
if(source) {
|
234
|
+
source.forEach(function(sourceEntry) {
|
235
|
+
var found = false;
|
236
|
+
if (compare) {
|
237
|
+
compare.forEach(function(compareEntry) {
|
238
|
+
if(sourceEntry[fieldname] === compareEntry[fieldname]) {
|
239
|
+
var data = {
|
240
|
+
typeSame: true,
|
241
|
+
source: sourceEntry,
|
242
|
+
compare: compareEntry,
|
243
|
+
index: index
|
244
|
+
};
|
245
|
+
dataList.push(data);
|
246
|
+
found = true;
|
247
|
+
index++;
|
248
|
+
}
|
249
|
+
});
|
250
|
+
}
|
251
|
+
if ( ! found) {
|
252
|
+
var data = {
|
253
|
+
typeIns: true,
|
254
|
+
source: sourceEntry,
|
255
|
+
index: index
|
256
|
+
};
|
257
|
+
dataList.push(data);
|
258
|
+
index++;
|
259
|
+
}
|
260
|
+
});
|
261
|
+
}
|
262
|
+
|
263
|
+
if (compare) {
|
264
|
+
compare.forEach(function(compareEntry) {
|
265
|
+
var found = false;
|
266
|
+
if (source) {
|
267
|
+
source.forEach(function(sourceEntry) {
|
268
|
+
if(sourceEntry[fieldname] === compareEntry[fieldname])
|
269
|
+
found = true;
|
270
|
+
});
|
271
|
+
}
|
272
|
+
if ( ! found) {
|
273
|
+
var data = {
|
274
|
+
typeDel: true,
|
275
|
+
compare: compareEntry,
|
276
|
+
index: index
|
277
|
+
};
|
278
|
+
dataList.push(data);
|
279
|
+
index++;
|
280
|
+
}
|
281
|
+
});
|
282
|
+
}
|
283
|
+
|
284
|
+
var ret = '';
|
285
|
+
var length = dataList.length;
|
286
|
+
for (var index in dataList) {
|
287
|
+
if(index == (length - 1))
|
288
|
+
dataList[index]['_last'] = true;
|
289
|
+
ret = ret + options.fn(dataList[index]);
|
290
|
+
}
|
291
|
+
return ret;
|
292
|
+
}
|
293
|
+
|
294
|
+
var diffMatchPatch = new DiffMatchPatch();
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Overwrite Colors
|
298
|
+
*/
|
299
|
+
DiffMatchPatch.prototype.diff_prettyHtml = function(diffs) {
|
300
|
+
var html = [];
|
301
|
+
var pattern_amp = /&/g;
|
302
|
+
var pattern_lt = /</g;
|
303
|
+
var pattern_gt = />/g;
|
304
|
+
var pattern_para = /\n/g;
|
305
|
+
for (var x = 0; x < diffs.length; x++) {
|
306
|
+
var op = diffs[x][0]; // Operation (insert, delete, equal)
|
307
|
+
var data = diffs[x][1]; // Text of change.
|
308
|
+
var text = data.replace(pattern_amp, '&').replace(pattern_lt, '<')
|
309
|
+
.replace(pattern_gt, '>').replace(pattern_para, '¶<br>');
|
310
|
+
switch (op) {
|
311
|
+
case DIFF_INSERT:
|
312
|
+
html[x] = '<ins>' + text + '</ins>';
|
313
|
+
break;
|
314
|
+
case DIFF_DELETE:
|
315
|
+
html[x] = '<del>' + text + '</del>';
|
316
|
+
break;
|
317
|
+
case DIFF_EQUAL:
|
318
|
+
html[x] = '<span>' + text + '</span>';
|
319
|
+
break;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
return html.join('');
|
323
|
+
};
|
324
|
+
|
325
|
+
// Exports
|
326
|
+
return Handlebars;
|
327
|
+
});
|
@@ -0,0 +1,158 @@
|
|
1
|
+
define([
|
2
|
+
'jquery'
|
3
|
+
], function($) {
|
4
|
+
|
5
|
+
var initDynamic = function() {
|
6
|
+
// Button send
|
7
|
+
$(".sample-request-send").off("click");
|
8
|
+
$(".sample-request-send").on("click", function(e) {
|
9
|
+
e.preventDefault();
|
10
|
+
var $root = $(this).parents("article");
|
11
|
+
var group = $root.data("group");
|
12
|
+
var name = $root.data("name");
|
13
|
+
var version = $root.data("version");
|
14
|
+
sendSampleRequest(group, name, version, $(this).data("sample-request-type"));
|
15
|
+
});
|
16
|
+
|
17
|
+
// Button clear
|
18
|
+
$(".sample-request-clear").off("click");
|
19
|
+
$(".sample-request-clear").on("click", function(e) {
|
20
|
+
e.preventDefault();
|
21
|
+
var $root = $(this).parents("article");
|
22
|
+
var group = $root.data("group");
|
23
|
+
var name = $root.data("name");
|
24
|
+
var version = $root.data("version");
|
25
|
+
clearSampleRequest(group, name, version);
|
26
|
+
});
|
27
|
+
}; // initDynamic
|
28
|
+
|
29
|
+
function sendSampleRequest(group, name, version, type)
|
30
|
+
{
|
31
|
+
var $root = $('article[data-group="' + group + '"][data-name="' + name + '"][data-version="' + version + '"]');
|
32
|
+
|
33
|
+
// Optional header
|
34
|
+
var header = {};
|
35
|
+
$root.find(".sample-request-header:checked").each(function(i, element) {
|
36
|
+
var group = $(element).data("sample-request-header-group-id");
|
37
|
+
$root.find("[data-sample-request-header-group=\"" + group + "\"]").each(function(i, element) {
|
38
|
+
var key = $(element).data("sample-request-header-name");
|
39
|
+
var value = element.value;
|
40
|
+
header[key] = $.type(value) === "string" ? escapeHtml(value) : value;
|
41
|
+
});
|
42
|
+
});
|
43
|
+
|
44
|
+
// create JSON dictionary of parameters
|
45
|
+
var param = {};
|
46
|
+
$root.find(".sample-request-param:checked").each(function(i, element) {
|
47
|
+
var group = $(element).data("sample-request-param-group-id");
|
48
|
+
$root.find("[data-sample-request-param-group=\"" + group + "\"]").each(function(i, element) {
|
49
|
+
var key = $(element).data("sample-request-param-name");
|
50
|
+
var value = element.value;
|
51
|
+
param[key] = $.type(value) === "string" ? escapeHtml(value) : value;
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
// grab user-inputted URL
|
56
|
+
var url = $root.find(".sample-request-url").val();
|
57
|
+
|
58
|
+
// Insert url parameter
|
59
|
+
var pattern = pathToRegexp(url, null);
|
60
|
+
var matches = pattern.exec(url);
|
61
|
+
for (var i = 1; i < matches.length; i++) {
|
62
|
+
var key = matches[i].substr(1);
|
63
|
+
if (param[key] !== undefined) {
|
64
|
+
url = url.replace(matches[i], encodeURIComponent(param[key]));
|
65
|
+
|
66
|
+
// remove URL parameters from list
|
67
|
+
delete param[key];
|
68
|
+
}
|
69
|
+
} // for
|
70
|
+
|
71
|
+
// send AJAX request, catch success or error callback
|
72
|
+
$.ajax({
|
73
|
+
url: url,
|
74
|
+
dataType: "json",
|
75
|
+
contentType: "application/json",
|
76
|
+
data: JSON.stringify(param),
|
77
|
+
headers: header,
|
78
|
+
type: type.toUpperCase(),
|
79
|
+
success: displaySuccess,
|
80
|
+
error: displayError
|
81
|
+
});
|
82
|
+
|
83
|
+
function displaySuccess(data) {
|
84
|
+
var jsonResponse;
|
85
|
+
try {
|
86
|
+
jsonResponse = JSON.stringify(data, null, 4);
|
87
|
+
} catch (e) {
|
88
|
+
jsonResponse = data;
|
89
|
+
}
|
90
|
+
$root.find(".sample-request-response").fadeTo(250, 1);
|
91
|
+
$root.find(".sample-request-response-json").html(jsonResponse);
|
92
|
+
refreshScrollSpy();
|
93
|
+
};
|
94
|
+
|
95
|
+
function displayError(jqXHR, textStatus, error) {
|
96
|
+
var message = "Error " + jqXHR.status + ": " + error;
|
97
|
+
var jsonResponse;
|
98
|
+
try {
|
99
|
+
jsonResponse = JSON.parse(jqXHR.responseText);
|
100
|
+
jsonResponse = JSON.stringify(jsonResponse, null, 4);
|
101
|
+
} catch (e) {
|
102
|
+
jsonResponse = jqXHR.responseText;
|
103
|
+
}
|
104
|
+
|
105
|
+
if (jsonResponse)
|
106
|
+
message += "<br>" + jsonResponse;
|
107
|
+
|
108
|
+
// flicker on previous error to make clear that there is a new response
|
109
|
+
if($root.find(".sample-request-response").is(":visible"))
|
110
|
+
$root.find(".sample-request-response").fadeTo(1, 0.1);
|
111
|
+
|
112
|
+
$root.find(".sample-request-response").fadeTo(250, 1);
|
113
|
+
$root.find(".sample-request-response-json").html(message);
|
114
|
+
refreshScrollSpy();
|
115
|
+
};
|
116
|
+
}
|
117
|
+
|
118
|
+
function clearSampleRequest(group, name, version)
|
119
|
+
{
|
120
|
+
var $root = $('article[data-group="' + group + '"][data-name="' + name + '"][data-version="' + version + '"]');
|
121
|
+
|
122
|
+
// hide sample response
|
123
|
+
$root.find(".sample-request-response-json").html("");
|
124
|
+
$root.find(".sample-request-response").hide();
|
125
|
+
|
126
|
+
// reset value of parameters
|
127
|
+
$root.find(".sample-request-param").each(function(i, element) {
|
128
|
+
element.value = "";
|
129
|
+
});
|
130
|
+
|
131
|
+
// restore default URL
|
132
|
+
var $urlElement = $root.find(".sample-request-url");
|
133
|
+
$urlElement.val($urlElement.prop("defaultValue"));
|
134
|
+
|
135
|
+
refreshScrollSpy();
|
136
|
+
}
|
137
|
+
|
138
|
+
function refreshScrollSpy()
|
139
|
+
{
|
140
|
+
$('[data-spy="scroll"]').each(function () {
|
141
|
+
$(this).scrollspy("refresh");
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
function escapeHtml(str) {
|
146
|
+
var div = document.createElement("div");
|
147
|
+
div.appendChild(document.createTextNode(str));
|
148
|
+
return div.innerHTML;
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Exports.
|
153
|
+
*/
|
154
|
+
return {
|
155
|
+
initDynamic: initDynamic
|
156
|
+
};
|
157
|
+
|
158
|
+
});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap Responsive v2.3.2
|
3
|
+
*
|
4
|
+
* Copyright 2013 Twitter, Inc
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
* Designed and built with all the love in the world by @mdo and @fat.
|
9
|
+
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}@-ms-viewport{width:device-width}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}.visible-print{display:none!important}@media print{.visible-print{display:inherit!important}.hidden-print{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.564102564102564%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*margin-left:16.98763411529369%}.row-fluid .offset1{margin-left:11.11111111111111%;*margin-left:11.004728132387708%}.row-fluid .offset1:first-child{margin-left:8.547008547008547%;*margin-left:8.440625568285142%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:30px}input.span12,textarea.span12,.uneditable-input.span12{width:1156px}input.span11,textarea.span11,.uneditable-input.span11{width:1056px}input.span10,textarea.span10,.uneditable-input.span10{width:956px}input.span9,textarea.span9,.uneditable-input.span9{width:856px}input.span8,textarea.span8,.uneditable-input.span8{width:756px}input.span7,textarea.span7,.uneditable-input.span7{width:656px}input.span6,textarea.span6,.uneditable-input.span6{width:556px}input.span5,textarea.span5,.uneditable-input.span5{width:456px}input.span4,textarea.span4,.uneditable-input.span4{width:356px}input.span3,textarea.span3,.uneditable-input.span3{width:256px}input.span2,textarea.span2,.uneditable-input.span2{width:156px}input.span1,textarea.span1,.uneditable-input.span1{width:56px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.7624309392265194%;*margin-left:2.709239449864817%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.7624309392265194%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.43646408839778%;*width:91.38327259903608%}.row-fluid .span10{width:82.87292817679558%;*width:82.81973668743387%}.row-fluid .span9{width:74.30939226519337%;*width:74.25620077583166%}.row-fluid .span8{width:65.74585635359117%;*width:65.69266486422946%}.row-fluid .span7{width:57.18232044198895%;*width:57.12912895262725%}.row-fluid .span6{width:48.61878453038674%;*width:48.56559304102504%}.row-fluid .span5{width:40.05524861878453%;*width:40.00205712942283%}.row-fluid .span4{width:31.491712707182323%;*width:31.43852121782062%}.row-fluid .span3{width:22.92817679558011%;*width:22.87498530621841%}.row-fluid .span2{width:14.3646408839779%;*width:14.311449394616199%}.row-fluid .span1{width:5.801104972375691%;*width:5.747913483013988%}.row-fluid .offset12{margin-left:105.52486187845304%;*margin-left:105.41847889972962%}.row-fluid .offset12:first-child{margin-left:102.76243093922652%;*margin-left:102.6560479605031%}.row-fluid .offset11{margin-left:96.96132596685082%;*margin-left:96.8549429881274%}.row-fluid .offset11:first-child{margin-left:94.1988950276243%;*margin-left:94.09251204890089%}.row-fluid .offset10{margin-left:88.39779005524862%;*margin-left:88.2914070765252%}.row-fluid .offset10:first-child{margin-left:85.6353591160221%;*margin-left:85.52897613729868%}.row-fluid .offset9{margin-left:79.8342541436464%;*margin-left:79.72787116492299%}.row-fluid .offset9:first-child{margin-left:77.07182320441989%;*margin-left:76.96544022569647%}.row-fluid .offset8{margin-left:71.2707182320442%;*margin-left:71.16433525332079%}.row-fluid .offset8:first-child{margin-left:68.50828729281768%;*margin-left:68.40190431409427%}.row-fluid .offset7{margin-left:62.70718232044199%;*margin-left:62.600799341718584%}.row-fluid .offset7:first-child{margin-left:59.94475138121547%;*margin-left:59.838368402492065%}.row-fluid .offset6{margin-left:54.14364640883978%;*margin-left:54.037263430116376%}.row-fluid .offset6:first-child{margin-left:51.38121546961326%;*margin-left:51.27483249088986%}.row-fluid .offset5{margin-left:45.58011049723757%;*margin-left:45.47372751851417%}.row-fluid .offset5:first-child{margin-left:42.81767955801105%;*margin-left:42.71129657928765%}.row-fluid .offset4{margin-left:37.01657458563536%;*margin-left:36.91019160691196%}.row-fluid .offset4:first-child{margin-left:34.25414364640884%;*margin-left:34.14776066768544%}.row-fluid .offset3{margin-left:28.45303867403315%;*margin-left:28.346655695309746%}.row-fluid .offset3:first-child{margin-left:25.69060773480663%;*margin-left:25.584224756083227%}.row-fluid .offset2{margin-left:19.88950276243094%;*margin-left:19.783119783707537%}.row-fluid .offset2:first-child{margin-left:17.12707182320442%;*margin-left:17.02068884448102%}.row-fluid .offset1{margin-left:11.32596685082873%;*margin-left:11.219583872105325%}.row-fluid .offset1:first-child{margin-left:8.56353591160221%;*margin-left:8.457152932878806%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:710px}input.span11,textarea.span11,.uneditable-input.span11{width:648px}input.span10,textarea.span10,.uneditable-input.span10{width:586px}input.span9,textarea.span9,.uneditable-input.span9{width:524px}input.span8,textarea.span8,.uneditable-input.span8{width:462px}input.span7,textarea.span7,.uneditable-input.span7{width:400px}input.span6,textarea.span6,.uneditable-input.span6{width:338px}input.span5,textarea.span5,.uneditable-input.span5{width:276px}input.span4,textarea.span4,.uneditable-input.span4{width:214px}input.span3,textarea.span3,.uneditable-input.span3{width:152px}input.span2,textarea.span2,.uneditable-input.span2{width:90px}input.span1,textarea.span1,.uneditable-input.span1{width:28px}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom,.navbar-static-top{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}.thumbnails>li{float:none;margin-left:0}[class*="span"],.uneditable-input[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:100%;margin-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.span12,.row-fluid .span12{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="offset"]:first-child{margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}.controls-row [class*="span"]+[class*="span"]{margin-left:0}.modal{position:fixed;top:20px;right:20px;left:20px;width:auto;margin:0}.modal.fade{top:-100px}.modal.fade.in{top:20px}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:20px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.media .pull-left,.media .pull-right{display:block;float:none;margin-bottom:10px}.media-object{margin-right:0;margin-left:0}.modal{top:10px;right:10px;left:10px}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top,.navbar-fixed-bottom{position:static}.navbar-fixed-top{margin-bottom:20px}.navbar-fixed-bottom{margin-top:20px}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 10px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#777;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:9px 15px;font-weight:bold;color:#777;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .nav>li>a:focus,.nav-collapse .dropdown-menu a:hover,.nav-collapse .dropdown-menu a:focus{background-color:#f2f2f2}.navbar-inverse .nav-collapse .nav>li>a,.navbar-inverse .nav-collapse .dropdown-menu a{color:#999}.navbar-inverse .nav-collapse .nav>li>a:hover,.navbar-inverse .nav-collapse .nav>li>a:focus,.navbar-inverse .nav-collapse .dropdown-menu a:hover,.navbar-inverse .nav-collapse .dropdown-menu a:focus{background-color:#111}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:none;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .open>.dropdown-menu{display:block}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .nav>li>.dropdown-menu:before,.nav-collapse .nav>li>.dropdown-menu:after{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:10px 15px;margin:10px 0;border-top:1px solid #f2f2f2;border-bottom:1px solid #f2f2f2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar-inverse .nav-collapse .navbar-form,.navbar-inverse .nav-collapse .navbar-search{border-top-color:#111;border-bottom-color:#111}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}}
|