Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
f70093c1
Commit
f70093c1
authored
15 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
changed note layout, fixed screen width issue for certain clients
updated code
parent
e6b4df71
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/postit.js
+57
-64
57 additions, 64 deletions
exec/postit.js
with
57 additions
and
64 deletions
exec/postit.js
+
57
−
64
View file @
f70093c1
...
...
@@ -26,7 +26,7 @@
17: Place Drop File In Node Directory
18: Time Options...
`
Please note that the program takes two arguments which determine the minimum
Please note that the program takes two arguments which determine the minimum
minimum security level to add notes and also the root file name for data storage.
while this file has been uploaded to the \sbbs\exec\ repository, it may be advisable
...
...
@@ -38,23 +38,25 @@
4: Command Line *..\xtrn\postit\postit.js <root filename> <minimum security level>
*/
load
(
"
sbbsdefs.js
"
);
load
(
"
funclib.js
"
);
load
(
"
logging.js
"
);
var
security_required
=
argv
[
1
];
//SECOND PASSED ARGUMENT FOR SECURITY LEVEL REQUIRED TO POST
var
root_name
=
argv
[
0
];
//ROOT DATAFILE NAME, USED TO SEPARATE INSTANCES OF THE PROGRAM
var
root_dir
;
try
{
barfitty
.
barf
(
barf
);
}
catch
(
e
)
{
root_dir
=
e
.
fileName
;
}
root_dir
=
root_dir
.
replace
(
/
[^\/\\]
*$/
,
''
);
var
logger
=
new
Logger
(
root_dir
,
root_name
);
var
current
=
new
MessageList
(
root_dir
,
root_name
,
"
.dat
"
);
var
history
=
new
MessageList
(
root_dir
,
root_name
,
"
.his
"
);
var
max_msg_length
=
3
;
//MAXIMUM MESSAGE LENGTH FOR
var
line_width
=
console
.
screen_columns
-
1
;
var
default_msg_color
=
"
\
1g
\
1h
"
;
//DEFAULT MESSAGE COLOR
var
sysop_mode
=
false
;
bbs
.
sys_status
|=
SS_PAUSEOFF
;
js
.
on_exit
(
bbs
.
sys_status
&=~
SS_PAUSEOFF
);
function
main
()
{
...
...
@@ -62,23 +64,25 @@ function main()
{
sysop_mode
=
true
;
max_msg_length
=
20
;
Log
(
"
Sysop mode enabled
"
);
}
var
can_add
=
(
user
.
security
.
level
>=
security_required
);
if
(
!
current
.
L
oad
())
return
false
;
if
(
!
current
.
l
oad
())
return
false
;
while
(
1
)
{
current
.
D
isplay
();
current
.
d
isplay
();
console
.
putmsg
(
format
(
"
\r\n\
1n
\
1c%s[
\
1hH
\
1n
\
1c]istory, or [
\
1hEnter
\
1n
\
1c] to [
\
1hQ
\
1n
\
1c]uit:
"
,
can_add
?
"
[
\
1hA
\
1n
\
1c]dd,
"
:
""
),
P_SAVEATR
);
var
cmd
=
console
.
getkey
(
K_NOECHO
|
K_NOSPIN
);
switch
(
cmd
.
toUpperCase
())
{
case
'
H
'
:
ShowHistory
(
history
);
showHistory
(
history
);
break
;
case
'
D
'
:
deleteNote
();
break
;
case
'
A
'
:
if
(
user
.
security
.
level
>=
security_required
)
A
ddNote
();
a
ddNote
();
break
;
case
'
Q
'
:
case
'
\r
'
:
...
...
@@ -88,7 +92,11 @@ function main()
}
}
}
function
AddNote
()
function
deleteNote
()
{
}
function
addNote
()
{
var
msg
=
[];
var
add_to_msg
=
true
;
...
...
@@ -151,17 +159,17 @@ function AddNote()
var
buffer_length
=
console
.
strlen
(
strip_ctrl
(
buffer
));
if
(
buffer_length
>
0
)
{
if
(
buffer_length
==
79
&&
if
(
buffer_length
==
line_width
&&
buffer
.
lastIndexOf
(
"
"
)
<
buffer
.
length
&&
buffer
.
lastIndexOf
(
"
"
)
>
0
)
{
msg
.
push
(
R
emoveSpaces
(
buffer
.
substr
(
0
,
buffer
.
lastIndexOf
(
"
"
))));
msg
.
push
(
r
emoveSpaces
(
buffer
.
substr
(
0
,
buffer
.
lastIndexOf
(
"
"
))));
console
.
up
();
print
(
"
\r
"
);
console
.
putmsg
(
msg
[
msg
.
length
-
1
],
P_SAVEATR
);
console
.
cleartoeol
();
console
.
crlf
();
buffer
=
G
etLastWord
(
buffer
);
buffer
=
g
etLastWord
(
buffer
);
}
else
{
...
...
@@ -170,16 +178,15 @@ function AddNote()
}
}
}
if
(
msg
.
length
&&
console
.
yesno
(
"
\
1n
\
1cSave this message?
"
))
current
.
A
ddPost
(
msg
);
U
pdateHistory
(
current
.
T
runcate
());
if
(
msg
.
length
&&
console
.
yesno
(
"
\
1n
\
1cSave this message?
"
))
current
.
a
ddPost
(
msg
);
u
pdateHistory
(
current
.
t
runcate
());
}
function
S
howHistory
(
list
)
function
s
howHistory
(
list
)
{
if
(
!
list
.
L
oad
())
return
false
;
if
(
!
list
.
l
oad
())
return
false
;
var
temp_list
=
list
.
array
.
slice
();
Log
(
"
number of messages:
"
+
temp_list
.
length
);
var
pages
=
S
etPageBreaks
(
temp_list
);
var
pages
=
s
etPageBreaks
(
temp_list
);
var
start
=
0
;
while
(
1
)
...
...
@@ -188,7 +195,7 @@ function ShowHistory(list)
var
index
=
pages
[
start
].
start
;
while
(
index
<=
pages
[
start
].
end
)
{
temp_list
[
index
].
D
isplay
();
temp_list
[
index
].
d
isplay
();
index
++
;
}
console
.
putmsg
(
"
\r\n\
1n
\
1c[
\
1hR
\
1n
\
1c]everse, [
\
1h
\
1n
\
1c/
\
1h
\
1n
\
1c], [
\
1hQ
\
1n
\
1c]uit, or [
\
1hEnter
\
1n
\
1c] to continue:
"
);
...
...
@@ -200,7 +207,7 @@ function ShowHistory(list)
case
'
R
'
:
temp_list
=
temp_list
.
reverse
();
start
=
0
;
pages
=
S
etPageBreaks
(
temp_list
);
pages
=
s
etPageBreaks
(
temp_list
);
break
;
case
KEY_UP
:
if
(
start
>
0
)
start
--
;
...
...
@@ -214,21 +221,20 @@ function ShowHistory(list)
}
}
}
function
S
etPageBreaks
(
list
)
function
s
etPageBreaks
(
list
)
{
var
pages
=
[];
var
start
=
0
;
var
end
=
0
;
while
(
start
<
list
.
length
)
{
end
=
CountSegment
(
start
,
list
);
logger
.
Log
(
"
setting page break:
"
+
end
);
end
=
countSegment
(
start
,
list
);
pages
.
push
({
start
:
start
,
end
:
end
});
start
=
end
+
1
;
}
return
pages
;
}
function
C
ountSegment
(
index
,
array
)
function
c
ountSegment
(
index
,
array
)
{
var
lines
=
0
;
while
(
lines
<
console
.
screen_rows
-
2
)
...
...
@@ -241,17 +247,17 @@ function CountSegment(index,array)
}
return
index
;
}
function
F
ormatDate
(
date
)
function
f
ormatDate
(
date
)
{
return
strftime
(
"
\
1n%m
\
1y
\
1h/
\
1n%d
\
1y
\
1h/
\
1n%y
\
1k
\
1h[
\
1n%H
\
1y
\
1h:
\
1n%M
\
1y
\
1h:
\
1n%S
\
1k
\
1h]
"
,
date
);
return
strftime
(
"
\
1k
\
1h[
\
1n%H
\
1y
\
1h:
\
1n%M
\
1y
\
1h:
\
1n%S
\
1k
\
1h]
\
1n%m
\
1y
\
1h/
\
1n%d
\
1y
\
1h/
\
1n%y
"
,
date
);
}
function
U
pdateHistory
(
array
)
function
u
pdateHistory
(
array
)
{
for
(
msg
in
array
)
{
history
.
array
.
push
(
array
[
msg
]);
}
history
.
F
ileOut
(
'
a+
'
,
array
);
history
.
f
ileOut
(
'
a+
'
,
array
);
}
//MESSAGE LIST OBJECT
...
...
@@ -262,27 +268,29 @@ function MessageList(root,name,ext)
this
.
name
=
name
;
this
.
file
=
new
File
(
this
.
root
+
this
.
name
+
ext
);
this
.
T
runcate
=
function
()
this
.
t
runcate
=
function
()
{
var
truncated
=
[];
var
total_lines
=
this
.
C
ountLines
();
var
total_lines
=
this
.
c
ountLines
();
var
trim
=
total_lines
-
(
console
.
screen_rows
-
2
);
while
(
trim
>
0
)
{
Log
(
"
truncating message:
"
+
this
.
array
[
0
].
message
);
trim
-=
this
.
array
[
0
].
message
.
length
+
1
;
truncated
.
push
(
this
.
array
.
shift
());
}
this
.
F
ileOut
(
'
w+
'
,
this
.
array
);
this
.
f
ileOut
(
'
w+
'
,
this
.
array
);
return
truncated
;
}
this
.
AddPost
=
function
(
msg
)
this
.
remove
=
function
(
index
)
{
this
.
array
.
splice
(
index
,
1
);
}
this
.
addPost
=
function
(
msg
)
{
Log
(
"
adding post:
"
+
msg
);
this
.
Load
();
//UPDATE POSTS FROM FILE BEFORE ADDING NEW POST TO MAINTAIN ORDER & CURRENCY
this
.
load
();
//UPDATE POSTS FROM FILE BEFORE ADDING NEW POST TO MAINTAIN ORDER & CURRENCY
this
.
array
.
push
(
new
Post
(
user
.
alias
,
time
(),
msg
));
}
this
.
L
oad
=
function
()
this
.
l
oad
=
function
()
{
this
.
array
=
[];
this
.
file
.
open
(
file_exists
(
this
.
file
.
name
)
?
'
a+
'
:
'
w+
'
);
...
...
@@ -308,7 +316,7 @@ function MessageList(root,name,ext)
}
return
false
;
}
this
.
C
ountLines
=
function
()
this
.
c
ountLines
=
function
()
{
var
count
=
0
;
for
(
msg
in
this
.
array
)
...
...
@@ -317,15 +325,15 @@ function MessageList(root,name,ext)
}
return
count
;
}
this
.
D
isplay
=
function
()
this
.
d
isplay
=
function
()
{
console
.
clear
();
for
(
post
in
this
.
array
)
for
(
post
=
0
;
post
<
this
.
array
.
length
;
post
++
)
{
this
.
array
[
post
].
D
isplay
();
this
.
array
[
post
].
d
isplay
();
}
}
this
.
F
ileOut
=
function
(
mode
,
array
)
this
.
f
ileOut
=
function
(
mode
,
array
)
{
this
.
file
.
open
(
mode
);
for
(
msg
in
array
)
...
...
@@ -347,9 +355,12 @@ function Post(author,date,message)
this
.
date
=
date
;
this
.
message
=
message
;
this
.
header
;
this
.
D
isplay
=
function
()
this
.
d
isplay
=
function
()
{
console
.
pushxy
();
console
.
putmsg
(
this
.
header
+
default_msg_color
,
P_SAVEATR
);
console
.
popxy
();
console
.
down
();
for
(
msg
in
this
.
message
)
{
console
.
putmsg
(
this
.
message
[
msg
],
P_SAVEATR
);
...
...
@@ -357,9 +368,9 @@ function Post(author,date,message)
}
console
.
putmsg
(
"
\
1n
"
,
P_SAVEATR
);
}
this
.
C
reateHeader
Old
=
function
()
this
.
c
reateHeader
=
function
()
{
var
head_txt
=
"
\
1k
\
1h
\
xB4
\
1
w
"
+
this
.
author
+
"
\
1k[
\
1y
\
1k]
"
+
FormatDate
(
this
.
date
)
;
var
head_txt
=
"
\
1k
\
1h
\
xC4
\
xC4
\
xB4
\
1
y
"
+
formatDate
(
this
.
date
)
+
"
\
1w
\
1h
"
+
this
.
author
+
"
\
1k
\
1h
\
xC3
"
;
var
head_len
=
console
.
strlen
(
head_txt
);
var
leader_len
=
console
.
screen_columns
-
head_len
;
var
leader
=
"
\
1n
\
1h
\
1k
"
;
...
...
@@ -367,27 +378,9 @@ function Post(author,date,message)
{
leader
+=
"
\
xC4
"
;
}
this
.
header
=
leader
+
head_txt
;
}
this
.
CreateHeader
=
function
()
{
var
head_txt
=
"
\
1k
\
1h
\
xC4
\
xC4
\
xB4
\
1n
"
+
this
.
author
+
"
\
1h
\
1k
\
1y
\
1k
\
xC3
"
;
var
date_txt
=
"
\
xB4
"
+
FormatDate
(
this
.
date
);
var
head_len
=
console
.
strlen
(
head_txt
+
date_txt
);
var
leader_len
=
console
.
screen_columns
-
head_len
;
var
leader
=
"
\
1n
\
1h
\
1k
"
;
for
(
lead
=
0
;
lead
<
leader_len
;
lead
++
)
{
leader
+=
"
\
xC4
"
;
}
this
.
header
=
head_txt
+
leader
+
date_txt
;
this
.
header
=
head_txt
+
leader
;
}
this
.
CreateHeader
();
}
function
Log
(
msg
)
{
logger
.
Log
(
msg
);
this
.
createHeader
();
}
main
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment