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
ee8d8e3c
Commit
ee8d8e3c
authored
14 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
added date string, made digits smaller, cleaned up old code, pollution FTW
parent
f9acfdba
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/load/clock.js
+128
-52
128 additions, 52 deletions
exec/load/clock.js
with
128 additions
and
52 deletions
exec/load/clock.js
+
128
−
52
View file @
ee8d8e3c
function
DigitalClock
()
{
this
.
x
;
this
.
y
;
this
.
color
;
this
.
columns
=
17
;
this
.
rows
=
5
;
this
.
width
=
17
;
this
.
height
=
6
;
this
.
bg
=
BG_BLACK
;
this
.
fg
=
BLUE
;
this
.
lastupdate
=-
1
;
this
.
digits
=
[];
this
.
hidden
=
false
;
this
.
init
=
function
(
x
,
y
,
color
)
this
.
days
=
[
"
Sun
"
,
"
Mon
"
,
"
Tues
"
,
"
Weds
"
,
"
Thurs
"
,
"
Fri
"
,
"
Sat
"
];
this
.
months
=
[
"
Jan
"
,
"
Feb
"
,
"
Mar
"
,
"
Apr
"
,
"
May
"
,
"
Jun
"
,
"
Jul
"
,
"
Aug
"
,
"
Sept
"
,
"
Oct
"
,
"
Nov
"
,
"
Dec
"
];
this
.
init
=
function
(
x
,
y
,
w
,
fg
,
bg
)
{
this
.
x
=
x
?
x
:
1
;
this
.
y
=
y
?
y
:
1
;
this
.
color
=
color
?
color
:
"
\
1n
\
1h
"
;
if
(
x
)
this
.
x
=
x
;
if
(
y
)
this
.
y
=
y
;
if
(
w
)
this
.
width
=
w
;
if
(
fg
!=
undefined
)
this
.
fg
=
fg
;
if
(
bg
!=
undefined
)
this
.
bg
=
bg
;
this
.
loadDigits
();
this
.
update
(
true
);
}
this
.
hide
=
function
()
{
...
...
@@ -26,60 +50,113 @@ function DigitalClock()
this
.
hidden
=
false
;
this
.
redraw
();
}
this
.
update
=
function
(
forced
)
this
.
update
=
function
()
{
if
(
this
.
hidden
)
return
;
var
date
=
new
Date
();
var
hours
=
date
.
getHours
();
if
(
hours
>
12
)
hours
-=
12
;
if
(
hours
<
10
)
{
hours
=
"
"
+
hours
;
}
var
minutes
=
date
.
getMinutes
();
if
(
minutes
<
10
)
minutes
=
"
0
"
+
minutes
;
var
time
=
hours
.
toString
()
+
"
:
"
+
minutes
.
toString
();
if
(
minutes
>
this
.
lastupdate
||
forced
)
{
this
.
lastupdate
=
minutes
;
this
.
drawClock
(
time
);
if
(
this
.
hidden
)
return
false
;
var
diff
=
(
time
()
-
this
.
lastupdate
);
if
(
diff
>=
1
)
{
return
true
;
}
}
this
.
draw
Clock
=
function
(
tim
e
)
this
.
draw
=
function
(
x
,
y
,
dat
e
)
{
console
.
attributes
=
this
.
color
;
for
(
i
=
0
;
i
<
5
;
i
++
)
if
(
date
==
undefined
)
date
=
new
Date
();
if
(
x
==
undefined
)
x
=
1
;
if
(
y
==
undefined
)
y
=
1
;
var
timestr
=
date
.
toLocaleTimeString
();
console
.
gotoxy
(
x
,
y
);
console
.
pushxy
();
console
.
attributes
=
this
.
bg
+
BLACK
;
console
.
write
(
printPadded
(
""
,
this
.
width
,
"
\
xDF
"
));
console
.
attributes
=
this
.
bg
+
this
.
fg
;
var
gap
=
this
.
width
-
14
;
var
offset
=
parseInt
(
gap
/
2
,
10
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
console
.
gotoxy
(
this
.
x
+
1
,
this
.
y
+
1
+
i
);
for
(
d
=
0
;
d
<
time
.
length
;
d
++
)
console
.
popxy
();
console
.
down
();
console
.
pushxy
();
console
.
write
(
printPadded
(
""
,
offset
));
for
(
d
=
0
;
d
<
timestr
.
length
;
d
++
)
{
var
digit
=
time
.
charAt
(
d
);
if
(
digit
==
"
:
"
)
digit
=
this
.
digits
[
"
colon
"
][
i
]
+
"
"
;
else
if
(
digit
==
"
"
);
else
if
(
digit
==
1
)
digit
=
"
"
+
this
.
digits
[
1
][
i
]
+
"
"
;
else
digit
=
this
.
digits
[
parseInt
(
digit
)][
i
]
+
"
"
;
var
digit
=
timestr
[
d
];
if
(
digit
==
"
:
"
)
{
if
(
i
==
1
)
console
.
write
(
"
"
);
else
console
.
write
(
"
\
xFA
"
);
continue
;
}
digit
=
this
.
digits
[
parseInt
(
digit
)][
i
];
console
.
write
(
digit
);
}
console
.
write
(
printPadded
(
""
,
gap
-
offset
));
}
console
.
popxy
();
console
.
down
();
console
.
pushxy
();
console
.
write
(
splitPadded
(
"
"
+
this
.
days
[
date
.
getDay
()]
+
"
,
"
,
this
.
months
[
date
.
getMonth
()]
+
"
.
"
+
date
.
getDate
()
+
"
"
,
this
.
width
));
console
.
popxy
();
console
.
down
();
console
.
attributes
=
this
.
bg
+
BLACK
;
console
.
write
(
printPadded
(
""
,
this
.
width
,
"
\
xDC
"
));
console
.
attributes
=
ANSI_NORMAL
;
}
this
.
redraw
=
function
()
{
this
.
update
(
true
);
console
.
home
();
this
.
lastupdate
=
""
+
time
();
}
this
.
loadDigits
=
function
()
{
var
zero
=
[
"
\
xDC
\
xDC
\
xDC
"
,
"
\
xDB
\
xDB
"
,
"
\
xDB
\
xDB
"
,
"
\
xDB
\
xDB
"
,
"
\
xDF
\
xDF
\
xDF
"
];
var
one
=
[
"
\
xDC
"
,
"
\
xDB
"
,
"
\
xDB
"
,
"
\
xDB
"
,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,
"
\
xC0
\
xBD
"
];
var
three
=
[
"
\
xDA
\
xB7
"
,
"
\
xB6
"
,
"
\
xC0
\
xBD
"
];
var
four
=
[
"
\
xD6
"
,
"
\
xC0
\
xB6
"
,
"
\
xD0
"
];
var
five
=
[
"
\
xDA
\
xB7
"
,
"
\
xC0
\
xB7
"
,
"
\
xC0
\
xBD
"
];
var
six
=
[
"
\
xDA
\
xB7
"
,
"
\
xC3
\
xB7
"
,
"
\
xC0
\
xBD
"
];
var
seven
=
[
"
\
xDA
\
xB7
"
,
"
\
xBA
"
,
"
\
xD0
"
];
var
eight
=
[
"
\
xDA
\
xB7
"
,
"
\
xC3
\
xB6
"
,
"
\
xC0
\
xBD
"
];
var
nine
=
[
"
\
xDA
\
xB7
"
,
"
\
xC0
\
xB6
"
,
"
\
xC0
\
xBD
"
];
this
.
digits
[
0
]
=
zero
;
this
.
digits
[
1
]
=
one
;
...
...
@@ -91,6 +168,5 @@ function DigitalClock()
this
.
digits
[
7
]
=
seven
;
this
.
digits
[
8
]
=
eight
;
this
.
digits
[
9
]
=
nine
;
this
.
digits
[
"
colon
"
]
=
colon
;
}
}
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