mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-26 01:50: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:
parent
fd10f3bd66
commit
119f11f651
@ -132,35 +132,6 @@ Tiddler.standardFields = {
|
||||
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
|
||||
Tiddler.specialTiddlerFields = {
|
||||
"created": "date",
|
||||
@ -168,6 +139,10 @@ Tiddler.specialTiddlerFields = {
|
||||
"tags": "array"
|
||||
};
|
||||
|
||||
Tiddler.isStandardField = function(name) {
|
||||
return name in Tiddler.standardFields;
|
||||
};
|
||||
|
||||
Tiddler.specialTiddlerFieldParsers = {
|
||||
date: function(value) {
|
||||
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;
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user