mirror of
https://github.com/lrsjng/h5ai.git
synced 2024-09-19 20:28:47 -04:00
Splits up type js into js and json.
This commit is contained in:
parent
69ffcc2d32
commit
a8e0c049f2
5 changed files with 12 additions and 28 deletions
BIN
src/_h5ai/client/icons/16x16/json.png
Normal file
BIN
src/_h5ai/client/icons/16x16/json.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 540 B |
BIN
src/_h5ai/client/icons/48x48/json.png
Normal file
BIN
src/_h5ai/client/icons/48x48/json.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
|
@ -1,29 +1,7 @@
|
|||
|
||||
modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry'], function (_, $, settings, Entry) {
|
||||
modulejs.define('parser/generic-json', ['_', '$', 'model/entry'], function (_, $, Entry) {
|
||||
|
||||
var parseJson = function (absHref, json) {
|
||||
|
||||
if (!settings.custom) {
|
||||
settings.custom = {};
|
||||
}
|
||||
if (_.has(json, 'customHeader')) {
|
||||
settings.custom.header = json.customHeader;
|
||||
}
|
||||
if (_.has(json, 'customFooter')) {
|
||||
settings.custom.footer = json.customFooter;
|
||||
}
|
||||
return _.map(json.entries, function (jsonEntry) {
|
||||
|
||||
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content);
|
||||
});
|
||||
},
|
||||
|
||||
parseJsonStr = function (absHref, jsonStr) {
|
||||
|
||||
return parseJson(absHref, JSON.parse($.trim(jsonStr) || '{}'));
|
||||
},
|
||||
|
||||
parse = function (absHref, html) {
|
||||
var parse = function (absHref, html) {
|
||||
|
||||
var id = '#data-generic-json',
|
||||
$html = $(html),
|
||||
|
@ -33,7 +11,11 @@ modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry'
|
|||
$id = $html.find(id);
|
||||
}
|
||||
|
||||
return parseJsonStr(absHref, $id.text());
|
||||
var json = JSON.parse($.trim($id.text()) || '{}');
|
||||
return _.map(json.entries, function (jsonEntry) {
|
||||
|
||||
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content);
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -223,16 +223,17 @@ Options
|
|||
"install": "plain",
|
||||
"log": "plain",
|
||||
"java": "java",
|
||||
"js": "js",
|
||||
"json": "js",
|
||||
"makefile": "xml",
|
||||
"markdown": "plain",
|
||||
/*"php": "php",*/
|
||||
// "php": "php",
|
||||
"python": "python",
|
||||
"readme": "plain",
|
||||
"rb": "ruby",
|
||||
"rtf": "plain",
|
||||
"script": "shell",
|
||||
"text": "plain",
|
||||
"js": "js",
|
||||
"xml": "xml"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -40,7 +40,8 @@ File types mapped to file extensions
|
|||
"install": ["install"],
|
||||
"java": [".java"],
|
||||
"jpg": [".jpg", ".jpeg"],
|
||||
"js": [".js", ".json"],
|
||||
"js": [".js"],
|
||||
"json": [".json"],
|
||||
"log": [".log", "changelog"],
|
||||
"makefile": [".pom", "build.xml", "pom.xml"],
|
||||
"markdown": [".markdown", ".md"],
|
||||
|
|
Loading…
Reference in a new issue