Edit now creates new frames
This commit is contained in:
parent
747e753466
commit
17ddda1cd5
@ -38,6 +38,7 @@ var MSG_SENDORNOT ='\1n\1h\1GKEY 1 TO SEND, 2 NOT TO SEND';
|
|||||||
var MSG_LOGON ='\1n\1h\1GKEY 1 TO LOGON, 2 TO RETURN';
|
var MSG_LOGON ='\1n\1h\1GKEY 1 TO LOGON, 2 TO RETURN';
|
||||||
var MSG_SENT ='\1n\1h\1GMESSAGE SENT - KEY # TO CONTINUE';
|
var MSG_SENT ='\1n\1h\1GMESSAGE SENT - KEY # TO CONTINUE';
|
||||||
var MSG_NOTSENT ='\1n\1h\1GMESSAGE NOT SENT - KEY # TO CONTINUE';
|
var MSG_NOTSENT ='\1n\1h\1GMESSAGE NOT SENT - KEY # TO CONTINUE';
|
||||||
|
var ERR_NO_PARENT ='\1n\1h\1RPARENT FRAME DOESNT EXIST';
|
||||||
var ERR_NOT_IMPLEMENTED ='\1n\1h\1RNOT IMPLEMENTED YET?';
|
var ERR_NOT_IMPLEMENTED ='\1n\1h\1RNOT IMPLEMENTED YET?';
|
||||||
var ERR_ROUTE ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
|
var ERR_ROUTE ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
|
||||||
var ERR_METHOD_NOT_EXIST ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
|
var ERR_METHOD_NOT_EXIST ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
|
||||||
@ -89,9 +90,11 @@ function TexFrame() {
|
|||||||
if (user.number || (this.type != FRAME_TYPE_LOGIN && NO_HISTORY_FRAMES.indexOf(this.page) == -1)) {
|
if (user.number || (this.type != FRAME_TYPE_LOGIN && NO_HISTORY_FRAMES.indexOf(this.page) == -1)) {
|
||||||
log(LOG_DEBUG,'- Owner: ['+this.pageowner+']');
|
log(LOG_DEBUG,'- Owner: ['+this.pageowner+']');
|
||||||
|
|
||||||
|
cost = (this.isAccessible ? this.cost+FRAME_COSTUNIT : ' -')
|
||||||
|
|
||||||
header = '\1n'+this.pageownerlogo+' '.repeat(FRAME_HEADER-console.strlen(this.pageownerlogo))+'\1n '+
|
header = '\1n'+this.pageownerlogo+' '.repeat(FRAME_HEADER-console.strlen(this.pageownerlogo))+'\1n '+
|
||||||
'\1W\1H'+this.page+' '.repeat(FRAME_PAGENUM-this.page.length)+' '+
|
(this.isAccessible ? '\1W' : '\1R')+'\1H'+this.page+' '.repeat(FRAME_PAGENUM-this.page.length)+' '+
|
||||||
'\1G\1H'+' '.repeat(FRAME_COST-this.cost.toString().length)+this.cost+FRAME_COSTUNIT+
|
'\1G\1H'+' '.repeat(FRAME_COST-cost.toString().length+1)+cost+'\1n'+
|
||||||
(console.screen_columns > 80 ? '\n\r' : '');
|
(console.screen_columns > 80 ? '\n\r' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +405,7 @@ function TexFrame() {
|
|||||||
(this.isAccessible && this.pageowner == SYSTEM_OWNER && ! this.isPublic) ||
|
(this.isAccessible && this.pageowner == SYSTEM_OWNER && ! this.isPublic) ||
|
||||||
(this.isAccessible && this.isPublic) ||
|
(this.isAccessible && this.isPublic) ||
|
||||||
(this.isAccessible && ! this.isPublic && this.isMember) ||
|
(this.isAccessible && ! this.isPublic && this.isMember) ||
|
||||||
(user.isOwner)
|
(pageEditor(this.frame))
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,11 +38,10 @@ function edit(fo) {
|
|||||||
scrollbar : null
|
scrollbar : null
|
||||||
};
|
};
|
||||||
|
|
||||||
owner = '\1h\1RA\1GN\1BS\1YI\1n\1'+'7\1ktex\1'+'0\1n';
|
log(LOG_DEBUG,' - Owner: '+JSON.stringify(fo.owner));
|
||||||
|
|
||||||
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
|
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
|
||||||
frame.gotoxy(1,1);
|
frame.gotoxy(1,1);
|
||||||
header = '\1n'+owner+' '.repeat(FRAME_HEADER-console.strlen(owner))+'\1n '+
|
header = '\1n'+fo.owner+' '.repeat(FRAME_HEADER-console.strlen(fo.owner))+'\1n '+
|
||||||
'\1W\1H'+fo.page+' '.repeat(FRAME_PAGENUM-fo.page.length)+' '+
|
'\1W\1H'+fo.page+' '.repeat(FRAME_PAGENUM-fo.page.length)+' '+
|
||||||
'\1G\1H'+' Edit';
|
'\1G\1H'+' Edit';
|
||||||
frame.putmsg(header);
|
frame.putmsg(header);
|
||||||
|
@ -193,7 +193,7 @@ function pageOwner(page) {
|
|||||||
if (e !== BreakException) throw e;
|
if (e !== BreakException) throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
//log(LOG_DEBUG,'+ pageOwner: page='+page+', owner: '+JSON.stringify(o));
|
log(LOG_DEBUG,'+ pageOwner: page='+page+', owner: '+JSON.stringify(o));
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ function pageEditor(page) {
|
|||||||
if (e !== BreakException) throw e;
|
if (e !== BreakException) throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
//log(LOG_DEBUG,'+ pageEditor: page='+page+', editor: '+JSON.stringify(pageditor));
|
log(LOG_DEBUG,'+ pageEditor: page='+page+', editor: '+JSON.stringify(pageditor));
|
||||||
return pageditor;
|
return pageditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
main.js
23
main.js
@ -690,22 +690,41 @@ while(bbs.online) {
|
|||||||
|
|
||||||
require('ansitex/load/edit.js','CONTROL_EDIT');
|
require('ansitex/load/edit.js','CONTROL_EDIT');
|
||||||
|
|
||||||
// @todo validate that the user is authorised to edit it.
|
|
||||||
// If we are editing a specific frame, attempt to load it
|
// If we are editing a specific frame, attempt to load it
|
||||||
if (fe) {
|
if (fe) {
|
||||||
current = fo;
|
current = fo;
|
||||||
fo = new TexFrame();
|
fo = new TexFrame();
|
||||||
fo.load(pageStr(fe));
|
fo.load(pageStr(fe));
|
||||||
|
|
||||||
|
// If the frame doesnt exist, check that the parent frame exists in case we are creating a new one
|
||||||
|
if (fo.page == null) {
|
||||||
|
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+fe.index+' ('+String.fromCharCode(fe.index.charCodeAt(0)-1)+')');
|
||||||
|
|
||||||
|
// We can always create an 'a' frame
|
||||||
|
if (fe.index !== 'a') {
|
||||||
|
fo = new TexFrame();
|
||||||
|
fo.load(pageStr({frame: fe.frame, index: String.fromCharCode(fe.index.charCodeAt(0)-1)}));
|
||||||
|
|
||||||
|
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(fo)+' ('+String.fromCharCode(fe.index.charCodeAt(0)-1)+')');
|
||||||
if (fo.page == null) {
|
if (fo.page == null) {
|
||||||
fo = current;
|
fo = current;
|
||||||
// sendbaseline ERR_PAGE
|
// sendbaseline ERR_PAGE
|
||||||
sendBaseline(ERR_ROUTE,false);
|
sendBaseline(ERR_NO_PARENT,false);
|
||||||
mode = action = false;
|
mode = action = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New frame
|
||||||
|
fo = new TexFrame();
|
||||||
|
fo.frame = fe.frame;
|
||||||
|
fo.index = fe.index;
|
||||||
|
fo.cost = 0;
|
||||||
|
fo.owner = base64_decode(pageOwner(pageStr(fe)).logo);
|
||||||
|
fo.content = base64_encode('Start your new page...');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
control.push(new edit(fo));
|
control.push(new edit(fo));
|
||||||
|
|
||||||
mode = false;
|
mode = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user