application each time a user enters the doc-frameset. - function docfiles aren't stored in their own directory each but moved up to the prototype directory, further regex-parsing of the resuting html-code necessary
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
|
|
|
|
function getDocPrototype (obj) {
|
|
var tmp = obj;
|
|
while (tmp!=null && tmp.getType () != this.PROTOTYPE) {
|
|
tmp = tmp.getParentElement ();
|
|
}
|
|
return tmp;
|
|
}
|
|
|
|
function getDir (dir, obj) {
|
|
dir.mkdir ();
|
|
if (obj.getType () == this.APPLICATION) {
|
|
return dir;
|
|
} else {
|
|
var protoObj = this.getDocPrototype (obj);
|
|
var dir = new File (dir, protoObj.getElementName ());
|
|
dir.mkdir ();
|
|
return dir;
|
|
}
|
|
}
|
|
|
|
|
|
function storePage (obj, action, backPath, filename) {
|
|
if (filename==null)
|
|
var filename = action + ".html";
|
|
var str = this.getPage (obj, action, backPath);
|
|
var appObj = this.getParentElement ();
|
|
var dir = new File (appObj.getAppDir ().getAbsolutePath (), ".docs");
|
|
dir = this.getDir (dir, obj);
|
|
var f = new File (dir, filename);
|
|
f.remove ();
|
|
f.open ();
|
|
f.write (str);
|
|
f.close ();
|
|
app.log ("wrote file " + f.toString ());
|
|
}
|
|
|
|
|
|
function getPage (obj, action, backPath) {
|
|
backPath = (backPath==null) ? "" : backPath;
|
|
res.pushStringBuffer ();
|
|
eval ("obj." + action + "_action ();");
|
|
var str = res.popStringBuffer ();
|
|
// get the baseURI out of the url and replace
|
|
// it with the given relative prefix
|
|
var reg = new RegExp ("href=\"" + this.href ("") + "([^\"]+)\"");
|
|
reg.global = true;
|
|
str = str.replace (reg, "href=\"" + backPath + "$1.html\"");
|
|
var reg = new RegExp ("src=\"" + this.href ("") + "([^\"]+)\"");
|
|
reg.global = true;
|
|
str = str.replace (reg, "src=\"" + backPath + "$1.html\"");
|
|
// shorten links, so that function files can move up one directory
|
|
// in the hierarchy
|
|
var reg = new RegExp ("(prototype_[^/]+/[^/]+)/main.html");
|
|
reg.global = true;
|
|
str = str.replace (reg, "$1.html");
|
|
return str;
|
|
}
|
|
|
|
|