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
ae81e498
Commit
ae81e498
authored
15 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
added functions: debug, testSocket, strlen, shuffle(array)
parent
7f3a536a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/funclib.js
+35
-2
35 additions, 2 deletions
exec/load/funclib.js
with
35 additions
and
2 deletions
exec/load/funclib.js
+
35
−
2
View file @
ae81e498
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
function
getColor
(
color
)
function
getColor
(
color
)
{
{
if
(
!
color
)
return
false
;
switch
(
color
.
toUpperCase
())
switch
(
color
.
toUpperCase
())
{
{
case
"
BLACK
"
:
case
"
BLACK
"
:
...
@@ -123,16 +124,27 @@ function centerString(string,length,padding)
...
@@ -123,16 +124,27 @@ function centerString(string,length,padding)
}
}
return
newstring
;
return
newstring
;
}
}
function
shuffle
(
array
)
{
for
(
var
j
,
x
,
i
=
array
.
length
;
i
;
j
=
parseInt
(
Math
.
random
()
*
i
),
x
=
array
[
--
i
],
array
[
i
]
=
array
[
j
],
array
[
j
]
=
x
);
return
array
;
}
function
strlen
(
str
)
{
return
console
.
strlen
(
removeSpaces
(
str
));
}
function
drawLine
(
x
,
y
,
length
,
color
)
function
drawLine
(
x
,
y
,
length
,
color
)
{
{
if
(
x
&&
y
)
if
(
x
&&
y
)
{
{
console
.
gotoxy
(
x
,
y
);
console
.
gotoxy
(
x
,
y
);
if
(
y
==
24
)
while
(
x
+
length
>
80
)
length
-=
1
;
if
(
y
==
24
&&
x
+
length
>
80
)
length
-=
(
length
-
80
)
;
}
}
for
(
i
=
0
;
i
<
length
;
i
++
)
for
(
i
=
0
;
i
<
length
;
i
++
)
{
{
console
.
putmsg
((
color
?
color
:
""
)
+
"
\
xc4
"
,
P_SAVEATR
);
if
(
color
)
console
.
attributes
=
color
;
console
.
putmsg
(
"
\
xc4
"
,
P_SAVEATR
);
}
}
}
}
function
clearBlock
(
x
,
y
,
w
,
h
,
bg
)
function
clearBlock
(
x
,
y
,
w
,
h
,
bg
)
...
@@ -150,3 +162,24 @@ function clearLine(length,x,y,bg)
...
@@ -150,3 +162,24 @@ function clearLine(length,x,y,bg)
if
(
length
)
console
.
putmsg
(
format
(
"
%*s
"
,
length
,
""
),
P_SAVEATR
);
if
(
length
)
console
.
putmsg
(
format
(
"
%*s
"
,
length
,
""
),
P_SAVEATR
);
else
console
.
cleartoeol
();
else
console
.
cleartoeol
();
}
}
function
debug
(
data
,
LOG_LEVEL
)
{
LOG_LEVEL
=
LOG_LEVEL
?
LOG_LEVEL
:
LOG_INFO
;
if
(
typeof
data
==
"
object
"
)
{
for
(
p
in
data
)
{
debug
(
p
+
"
=
"
+
data
[
p
],
LOG_LEVEL
);
}
}
else
log
(
LOG_LEVEL
,
data
);
}
function
testSocket
(
socket
)
{
if
(
socket
.
is_connected
)
return
true
;
else
{
if
(
socket
.
error
)
{
debug
(
"
SOCKET ERROR:
"
+
socket
.
error
,
LOG_WARNING
);
debug
(
socket
,
LOG_WARNING
);
}
else
debug
(
"
socket disconnected
"
,
LOG_DEBUG
);
return
false
;
}
}
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