mirror of
https://github.com/lrsjng/h5ai.git
synced 2024-09-20 04:38:51 -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) {
|
var parse = function (absHref, html) {
|
||||||
|
|
||||||
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 id = '#data-generic-json',
|
var id = '#data-generic-json',
|
||||||
$html = $(html),
|
$html = $(html),
|
||||||
|
@ -33,7 +11,11 @@ modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry'
|
||||||
$id = $html.find(id);
|
$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 {
|
return {
|
||||||
|
|
|
@ -223,16 +223,17 @@ Options
|
||||||
"install": "plain",
|
"install": "plain",
|
||||||
"log": "plain",
|
"log": "plain",
|
||||||
"java": "java",
|
"java": "java",
|
||||||
|
"js": "js",
|
||||||
|
"json": "js",
|
||||||
"makefile": "xml",
|
"makefile": "xml",
|
||||||
"markdown": "plain",
|
"markdown": "plain",
|
||||||
/*"php": "php",*/
|
// "php": "php",
|
||||||
"python": "python",
|
"python": "python",
|
||||||
"readme": "plain",
|
"readme": "plain",
|
||||||
"rb": "ruby",
|
"rb": "ruby",
|
||||||
"rtf": "plain",
|
"rtf": "plain",
|
||||||
"script": "shell",
|
"script": "shell",
|
||||||
"text": "plain",
|
"text": "plain",
|
||||||
"js": "js",
|
|
||||||
"xml": "xml"
|
"xml": "xml"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,7 +40,8 @@ File types mapped to file extensions
|
||||||
"install": ["install"],
|
"install": ["install"],
|
||||||
"java": [".java"],
|
"java": [".java"],
|
||||||
"jpg": [".jpg", ".jpeg"],
|
"jpg": [".jpg", ".jpeg"],
|
||||||
"js": [".js", ".json"],
|
"js": [".js"],
|
||||||
|
"json": [".json"],
|
||||||
"log": [".log", "changelog"],
|
"log": [".log", "changelog"],
|
||||||
"makefile": [".pom", "build.xml", "pom.xml"],
|
"makefile": [".pom", "build.xml", "pom.xml"],
|
||||||
"markdown": [".markdown", ".md"],
|
"markdown": [".markdown", ".md"],
|
||||||
|
|
Loading…
Reference in a new issue