AppJet
My Apps
App Directory
Docs
Forum
Help
sign in
App:
shoutbox.appjet.net
(by
appjet
)
Overview
Source
Docs
Comments (0)
Clone This App
view as plaintext
/* appjet:version 0.1 */
import
(
"
storage
"
)
;
var
historySize
=
20
;
if
(
!
storage
.
msgs
)
{
storage
.
msgs
=
new
StorableObject
(
)
;
storage
.
start
=
0
;
// first msg
storage
.
end
=
0
;
// index after last msg
}
if
(
request
.
isPost
)
{
var
newText
=
request
.
params
.
newText
;
if
(
acceptable
(
newText
)
)
{
storage
.
msgs
[
storage
.
end
+
+
]
=
request
.
params
.
newText
;
while
(
storage
.
end
-
storage
.
start
>
historySize
)
{
delete
storage
.
msgs
[
storage
.
start
+
+
]
;
}
}
response
.
redirect
(
"
/
"
)
;
}
else
{
print
(
FORM
(
{
id
:
"
shoutform
"
,
action
:
"
/
"
,
method
:
"
post
"
}
,
INPUT
(
{
type
:
"
text
"
,
name
:
"
newText
"
,
size
:
40
}
)
,
INPUT
(
{
type
:
"
submit
"
,
value
:
"
shout!
"
}
)
)
)
;
var
messageDiv
=
DIV
(
{
id
:
"
msgs
"
}
)
;
for
(
var
i
=
storage
.
end
-
1
;
i
>
=
storage
.
start
;
i
-
-
)
{
messageDiv
.
push
(
P
(
storage
.
msgs
[
i
]
)
)
;
}
print
(
messageDiv
)
;
}
// TEMP: anti-spam tactics added to block annoying techcrunch spam.
// We limit each IP address's posts.
function
acceptable
(
txt
)
{
if
(
!
storage
.
ips
)
{
storage
.
ips
=
new
StorableObject
(
)
;
}
if
(
!
storage
.
ips
[
request
.
clientAddr
]
)
{
storage
.
ips
[
request
.
clientAddr
]
=
0
;
}
storage
.
ips
[
request
.
clientAddr
]
+
+
;
return
(
storage
.
ips
[
request
.
clientAddr
]
<
=
40
|
|
request
.
clientAddr
=
=
storage
.
ajtc
)
;
}
/* appjet:css */
#shoutform
{
margin
:
10px
;
}
#msgs
{
height
:
200px
;
overflow
:
auto
;
border
:
1px
solid
#666
;
margin
:
10px
;
padding-left
:
10px
;
}
#msgs
p
{
margin-top
:
0.6em
;
margin-bottom
:
0.6em
;
}
body
{
margin
:
8px
;
padding
:
0
;
margin-top
:
6px
;
}
© Copyright 2007-2008 AppJet Inc.