1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-29 22:26:17 +00:00
TiddlyWiki5/editions/tw2/source/tiddlywiki/js/TW21Loader.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

//--
//-- TW21Loader (inherits from LoaderBase)
//--
function TW21Loader() {}
TW21Loader.prototype = new LoaderBase();
TW21Loader.prototype.getTitle = function(store,node)
{
var title = null;
if(node.getAttribute) {
title = node.getAttribute("title");
if(!title)
title = node.getAttribute("tiddler");
}
if(!title && node.id) {
var lenPrefix = store.idPrefix.length;
if(node.id.substr(0,lenPrefix) == store.idPrefix)
title = node.id.substr(lenPrefix);
}
return title;
};
TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node)
{
var e = node.firstChild;
var text = null;
if(node.getAttribute("tiddler")) {
text = getNodeText(e).unescapeLineBreaks();
} else {
while(e.nodeName!="PRE" && e.nodeName!="pre") {
e = e.nextSibling;
}
text = e.innerHTML.replace(/\r/mg,"").htmlDecode();
}
var creator = node.getAttribute("creator");
var modifier = node.getAttribute("modifier");
var c = node.getAttribute("created");
var m = node.getAttribute("modified");
var created = c ? Date.convertFromYYYYMMDDHHMMSS(c) : version.date;
var modified = m ? Date.convertFromYYYYMMDDHHMMSS(m) : created;
var tags = node.getAttribute("tags");
var fields = {};
var i,attrs = node.attributes;
for(i = attrs.length-1; i >= 0; i--) {
var name = attrs[i].name;
if(attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
fields[name] = attrs[i].value.unescapeLineBreaks();
}
}
tiddler.assign(title,text,modifier,modified,tags,created,fields,creator);
return tiddler;
};