1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-27 10:30:28 +00:00

Rearranged definitions

So that we don't get complaints about things being used before they're
defined
This commit is contained in:
Jeremy Ruston 2012-04-13 13:26:49 +01:00
parent fd10f3bd66
commit 119f11f651

View File

@ -132,35 +132,6 @@ Tiddler.standardFields = {
text: { type: "string"} text: { type: "string"}
}; };
Tiddler.isStandardField = function(name) {
return name in Tiddler.standardFields;
};
Tiddler.compareTiddlerFields = function(a,b,sortField) {
var aa = a[sortField] || 0,
bb = b[sortField] || 0;
if(aa < bb) {
return -1;
} else {
if(aa > bb) {
return 1;
} else {
return 0;
}
}
};
Tiddler.parseTiddlerField = function(name,value) {
var type = Tiddler.specialTiddlerFields[name];
if(type) {
return Tiddler.specialTiddlerFieldParsers[type](value);
} else if (typeof value === "string") {
return value;
} else {
return null;
}
};
// These are the non-string fields // These are the non-string fields
Tiddler.specialTiddlerFields = { Tiddler.specialTiddlerFields = {
"created": "date", "created": "date",
@ -168,6 +139,10 @@ Tiddler.specialTiddlerFields = {
"tags": "array" "tags": "array"
}; };
Tiddler.isStandardField = function(name) {
return name in Tiddler.standardFields;
};
Tiddler.specialTiddlerFieldParsers = { Tiddler.specialTiddlerFieldParsers = {
date: function(value) { date: function(value) {
if(typeof value === "string") { if(typeof value === "string") {
@ -196,6 +171,31 @@ Tiddler.specialTiddlerFieldParsers = {
} }
}; };
Tiddler.compareTiddlerFields = function(a,b,sortField) {
var aa = a[sortField] || 0,
bb = b[sortField] || 0;
if(aa < bb) {
return -1;
} else {
if(aa > bb) {
return 1;
} else {
return 0;
}
}
};
Tiddler.parseTiddlerField = function(name,value) {
var type = Tiddler.specialTiddlerFields[name];
if(type) {
return Tiddler.specialTiddlerFieldParsers[type](value);
} else if (typeof value === "string") {
return value;
} else {
return null;
}
};
exports.Tiddler = Tiddler; exports.Tiddler = Tiddler;
})(); })();