mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 06:14:44 +00:00
Get tiddler div fields in the right order
This commit is contained in:
parent
7e1013a1f2
commit
c355979ce5
@ -69,14 +69,32 @@ exports["application/x-tiddler-module"] = function(tiddler) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports["application/x-tiddler-html-div"] = function(tiddler) {
|
exports["application/x-tiddler-html-div"] = function(tiddler) {
|
||||||
var result = [],fields = [];
|
var result = [],
|
||||||
|
fields = [],
|
||||||
|
pullField = function(name) {
|
||||||
|
var fieldIndex = fields.indexOf(name);
|
||||||
|
if(fieldIndex !== -1) {
|
||||||
|
fields.splice(fieldIndex,1);
|
||||||
|
fields.unshift(name);
|
||||||
|
}
|
||||||
|
};
|
||||||
result.push("<div");
|
result.push("<div");
|
||||||
|
// Collect the field names in the tiddler
|
||||||
for(var f in tiddler.fields) {
|
for(var f in tiddler.fields) {
|
||||||
if(f !== "text") {
|
if(f !== "text") {
|
||||||
fields.push(f);
|
fields.push(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Sort the fields
|
||||||
fields.sort();
|
fields.sort();
|
||||||
|
// Pull the standard fields up to the top
|
||||||
|
pullField("tags");
|
||||||
|
pullField("modified");
|
||||||
|
pullField("created");
|
||||||
|
pullField("modifier");
|
||||||
|
pullField("creator");
|
||||||
|
pullField("title");
|
||||||
|
// Output the fields
|
||||||
for(f=0; f<fields.length; f++) {
|
for(f=0; f<fields.length; f++) {
|
||||||
result.push(" " + fields[f] + "=\"" + tiddler.getFieldString(fields[f]) + "\"");
|
result.push(" " + fields[f] + "=\"" + tiddler.getFieldString(fields[f]) + "\"");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user