mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-30 01:01:01 -06:00
Second pass at char sheet - ugly but mostly all there
This commit is contained in:
1 parent
73fe1bf0a7
commit
3dc59c774c
1 file changed
+15
-1
@@ -1,13 +1,27 @@
|
|||||||
// TODO These code bits don't really belong here, but this is the only shared bit of js
|
// TODO These code bits don't really belong here, but this is the only shared bit of js
|
||||||
|
|
||||||
|
|
||||||
|
function tabulate(html) {
|
||||||
|
var result = '';
|
||||||
|
$("<table>").html(html).find("tr").each(function () {
|
||||||
|
result += " " + $(this).children().first().text() + ": " +
|
||||||
|
$(this).children().last().text() + "\n";
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function template(id, data) {
|
function template(id, data) {
|
||||||
var tmpl = $("#" + id).html();
|
var tmpl = $("#" + id).html();
|
||||||
var brag = tmpl.replace(/\$([_A-Za-z.]+)/g, function (str, p1) {
|
var brag = tmpl.replace(/\$([_A-Za-z.]+)/g, function (str, p1) {
|
||||||
var dict = data;
|
var dict = data;
|
||||||
$.each(p1.split("."), function (i,v) {
|
$.each(p1.split("."), function (i,v) {
|
||||||
if (!dict) return true;
|
if (!dict) return true;
|
||||||
dict = dict[v];
|
if (v == "___") {
|
||||||
|
dict = tabulate(dict.html);
|
||||||
|
} else {
|
||||||
|
dict = dict[v.replace("_"," ")];
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
return dict || '';
|
return dict || '';
|
||||||
|
|||||||
Reference in new issue
Block a user