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
0b2a0778
Commit
0b2a0778
authored
9 years ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
20ce2df0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
web/root/js/common.js
+2
-2
2 additions, 2 deletions
web/root/js/common.js
web/root/js/forum.js
+98
-83
98 additions, 83 deletions
web/root/js/forum.js
with
100 additions
and
85 deletions
web/root/js/common.js
+
2
−
2
View file @
0b2a0778
...
...
@@ -12,8 +12,8 @@ function login(evt) {
{
'
url
'
:
'
./api/auth.ssjs
'
,
'
method
'
:
'
POST
'
,
'
data
'
:
{
'
username
'
:
$
(
'
#input-username
'
).
val
(),
'
password
'
:
$
(
'
#input-password
'
).
val
()
username
:
$
(
'
#input-username
'
).
val
(),
password
:
$
(
'
#input-password
'
).
val
()
}
}
).
done
(
...
...
This diff is collapsed.
Click to expand it.
web/root/js/forum.js
+
98
−
83
View file @
0b2a0778
// Add a parameter to the query string
var
insertParam
=
function
(
key
,
value
)
{
function
insertParam
(
key
,
value
)
{
key
=
encodeURIComponent
(
key
);
value
=
encodeURIComponent
(
value
);
var
kvp
=
window
.
location
.
search
.
substr
(
1
).
split
(
'
&
'
);
var
i
=
kvp
.
length
,
x
;
while
(
i
--
)
{
while
(
i
--
)
{
x
=
kvp
[
i
].
split
(
'
=
'
);
if
(
x
[
0
]
==
key
)
{
if
(
x
[
0
]
==
key
)
{
x
[
1
]
=
value
;
kvp
[
i
]
=
x
.
join
(
'
=
'
);
break
;
}
}
if
(
i
<
0
)
kvp
[
kvp
.
length
]
=
[
key
,
value
].
join
(
'
=
'
);
if
(
i
<
0
)
kvp
[
kvp
.
length
]
=
[
key
,
value
].
join
(
'
=
'
);
window
.
location
.
search
=
kvp
.
join
(
'
&
'
);
}
// For now we'll just remove nested quotes from the parent post
var
quotify
=
function
(
id
)
{
$
(
'
#quote-
'
+
id
).
attr
(
"
disabled
"
,
true
);
function
quotify
(
id
)
{
$
(
'
#quote-
'
+
id
).
attr
(
'
disabled
'
,
true
);
var
html
=
$
(
'
#message-
'
+
id
).
clone
();
html
.
find
(
'
blockquote
'
).
remove
();
$
(
'
#replytext-
'
+
id
).
val
(
html
.
text
().
replace
(
/
\n\s
*
\n\s
*
\n
/g
,
'
\n\n
'
).
split
(
/
\r?\n
/
).
map
(
function
(
line
)
{
return
(
"
>
"
+
line
);
}
).
join
(
"
\n
"
)
+
function
(
line
)
{
return
(
"
>
"
+
line
);
}
).
join
(
'
\n
'
)
+
$
(
'
#replytext-
'
+
id
).
val
()
);
}
// (Try to) post a new message to 'sub' via the web API
var
postNew
=
function
(
sub
)
{
$
(
'
#newmessage-button
'
).
attr
(
"
disabled
"
,
true
);
function
postNew
(
sub
)
{
$
(
'
#newmessage-button
'
).
attr
(
'
disabled
'
,
true
);
var
to
=
$
(
'
#newmessage-to
'
).
val
();
var
subject
=
$
(
'
#newmessage-subject
'
).
val
();
var
body
=
$
(
'
#newmessage-body
'
).
val
();
$
.
ajax
(
{
'
url
'
:
"
./api/forum.ssjs
"
,
'
method
'
:
"
POST
"
,
'
data
'
:
{
'
call
'
:
"
post
"
,
'
sub
'
:
sub
,
'
to
'
:
to
,
'
subject
'
:
subject
,
'
body
'
:
body
{
url
:
'
./api/forum.ssjs
'
,
method
:
'
POST
'
,
data
:
{
call
:
'
post
'
,
sub
:
sub
,
to
:
to
,
subject
:
subject
,
body
:
body
}
}
).
done
(
function
(
data
)
{
if
(
data
.
success
)
{
function
(
data
)
{
if
(
data
.
success
)
{
$
(
'
#newmessage
'
).
remove
();
insertParam
(
"
notice
"
,
"
Your message has been posted.
"
);
insertParam
(
'
notice
'
,
'
Your message has been posted.
'
);
}
$
(
'
#newmessage-button
'
).
attr
(
"
disabled
"
,
false
);
$
(
'
#newmessage-button
'
).
attr
(
'
disabled
'
,
false
);
}
);
}
// (Try to) post a reply to message number 'id' of 'sub' via the web API
var
postReply
=
function
(
sub
,
id
)
{
$
(
'
#reply-button-
'
+
id
).
attr
(
"
disabled
"
,
true
);
function
postReply
(
sub
,
id
)
{
$
(
'
#reply-button-
'
+
id
).
attr
(
'
disabled
'
,
true
);
var
body
=
$
(
'
#replytext-
'
+
id
).
val
();
$
.
ajax
(
{
'
url
'
:
"
./api/forum.ssjs
"
,
'
method
'
:
"
POST
"
,
'
data
'
:
{
'
call
'
:
"
post-reply
"
,
'
sub
'
:
sub
,
'
body
'
:
$
(
'
#replytext-
'
+
id
).
val
(),
'
pid
'
:
id
{
url
:
'
./api/forum.ssjs
'
,
method
:
'
POST
'
,
data
:
{
call
:
'
post-reply
'
,
sub
:
sub
,
body
:
$
(
'
#replytext-
'
+
id
).
val
(),
pid
:
id
}
}
).
done
(
function
(
data
)
{
if
(
data
.
success
)
{
$
(
'
#quote-
'
+
id
).
attr
(
"
disabled
"
,
false
);
function
(
data
)
{
if
(
data
.
success
)
{
$
(
'
#quote-
'
+
id
).
attr
(
'
disabled
'
,
false
);
$
(
'
#replybox-
'
+
id
).
remove
();
insertParam
(
"
notice
"
,
"
Your message has been posted.
"
);
insertParam
(
'
notice
'
,
'
Your message has been posted.
'
);
}
else
{
$
(
'
#reply-button-
'
+
id
).
attr
(
"
disabled
"
,
false
);
$
(
'
#reply-button-
'
+
id
).
attr
(
'
disabled
'
,
false
);
}
}
);
}
// (Try to) delete a message via the web API
var
deleteMessage
=
function
(
sub
,
id
)
{
function
deleteMessage
(
sub
,
id
)
{
$
.
getJSON
(
'
./api/forum.ssjs?call=delete-message&sub=
'
+
sub
+
'
&number=
'
+
id
,
function
(
data
)
{
function
(
data
)
{
console
.
log
(
data
);
if
(
data
.
success
)
{
if
(
data
.
success
)
{
$
(
'
#li-
'
+
id
).
remove
();
insertParam
(
"
notice
"
,
"
Message deleted.
"
);
insertParam
(
'
notice
'
,
'
Message deleted.
'
);
}
}
);
}
// Add a new message input form to the element with id 'forum-list-container' for sub 'sub'
var
addNew
=
function
(
sub
)
{
if
(
$
(
'
#newmessage
'
).
length
>
0
)
return
;
function
addNew
(
sub
)
{
if
(
$
(
'
#newmessage
'
).
length
>
0
)
return
;
$
(
'
#forum-list-container
'
).
append
(
'
<li id="newmessage" class="list-group-item">
'
+
'
<input id="newmessage-to" class="form-control" type="text" placeholder="To"><br>
'
+
...
...
@@ -113,17 +111,18 @@ var addNew = function(sub) {
);
$
.
getJSON
(
'
./api/forum.ssjs?call=get-signature
'
,
function
(
data
)
{
$
(
'
#newmessage-body
'
).
val
(
$
(
'
#newmessage-body
'
).
val
()
+
"
\r\n
"
+
data
.
signature
);
function
(
data
)
{
$
(
'
#newmessage-body
'
).
val
(
$
(
'
#newmessage-body
'
).
val
()
+
'
\r\n
'
+
data
.
signature
);
}
);
window
.
location
.
hash
=
"
#newmessage
"
;
window
.
location
.
hash
=
'
#newmessage
'
;
}
// Add a reply input form to the page for message with number 'id' in sub 'sub'
var
addReply
=
function
(
sub
,
id
)
{
if
(
$
(
'
#replybox-
'
+
id
).
length
>
0
)
return
;
function
addReply
(
sub
,
id
)
{
if
(
$
(
'
#replybox-
'
+
id
).
length
>
0
)
return
;
$
(
'
#li-
'
+
id
).
append
(
'
<div class="reply" id="replybox-
'
+
id
+
'
">
'
+
'
<strong>Reply</strong>
'
+
...
...
@@ -134,37 +133,48 @@ var addReply = function(sub, id) {
);
$
.
getJSON
(
'
./api/forum.ssjs?call=get-signature
'
,
function
(
data
)
{
$
(
'
#replytext-
'
+
id
).
val
(
$
(
'
#replytext-
'
+
id
).
val
()
+
"
\r\n
"
+
data
.
signature
);
function
(
data
)
{
$
(
'
#replytext-
'
+
id
).
val
(
$
(
'
#replytext-
'
+
id
).
val
()
+
'
\r\n
'
+
data
.
signature
);
}
);
}
// 'sub' can be a single sub code, or a string of <sub1>&sub=<sub2>&sub=<sub3>...
var
getSubUnreadCount
=
function
(
sub
)
{
function
getSubUnreadCount
(
sub
)
{
$
.
getJSON
(
"
./api/forum.ssjs?call=get-sub-unread-count&sub=
"
+
sub
,
'
./api/forum.ssjs?call=get-sub-unread-count&sub=
'
+
sub
,
function
(
data
)
{
for
(
sub
in
data
)
{
if
(
data
[
sub
].
scanned
>
0
)
for
(
sub
in
data
)
{
if
(
data
[
sub
].
scanned
>
0
)
{
$
(
'
#badge-
'
+
sub
).
text
(
data
[
sub
].
total
);
else
if
(
data
[
sub
].
total
>
0
)
}
else
if
(
data
[
sub
].
total
>
0
)
{
$
(
'
#badge-
'
+
sub
).
text
(
data
[
sub
].
total
);
else
$
(
'
#badge-
'
+
sub
).
text
(
""
);
}
else
{
$
(
'
#badge-
'
+
sub
).
text
(
''
);
}
}
}
);
}
// 'group' can be a single group index, or a string of 0&group=1&group=2...
var
getGroupUnreadCount
=
function
(
group
)
{
function
getGroupUnreadCount
(
group
)
{
$
.
getJSON
(
"
./api/forum.ssjs?call=get-group-unread-count&group=
"
+
group
,
function
(
data
)
{
for
(
group
in
data
)
{
$
(
'
#badge-scanned-
'
+
group
).
text
((
data
[
group
].
scanned
==
0
?
""
:
data
[
group
].
scanned
));
$
(
'
#badge-ignored-
'
+
group
).
text
((
data
[
group
].
total
==
0
||
data
[
group
].
total
==
data
[
group
].
scanned
?
""
:
(
data
[
group
].
total
-
data
[
group
].
scanned
)));
'
./api/forum.ssjs?call=get-group-unread-count&group=
'
+
group
,
function
(
data
)
{
for
(
group
in
data
)
{
$
(
'
#badge-scanned-
'
+
group
).
text
(
(
data
[
group
].
scanned
==
0
?
""
:
data
[
group
].
scanned
)
);
$
(
'
#badge-ignored-
'
+
group
).
text
(
(
data
[
group
].
total
==
0
||
data
[
group
].
total
==
data
[
group
].
scanned
?
''
:
(
data
[
group
].
total
-
data
[
group
].
scanned
)
)
);
}
}
);
...
...
@@ -172,20 +182,26 @@ var getGroupUnreadCount = function(group) {
/* Fetch a private mail message's body (with links to attachments) where 'id'
is the message number. Output it to an element with id 'message-<id>'. */
var
getMailBody
=
function
(
id
)
{
if
(
!
$
(
'
#message-
'
+
id
).
attr
(
'
hidden
'
))
{
function
getMailBody
(
id
)
{
if
(
!
$
(
'
#message-
'
+
id
).
attr
(
'
hidden
'
))
{
$
(
'
#message-
'
+
id
).
attr
(
'
hidden
'
,
true
);
}
else
if
(
$
(
'
#message-
'
+
id
).
html
()
!=
""
)
{
}
else
if
(
$
(
'
#message-
'
+
id
).
html
()
!=
''
)
{
$
(
'
#message-
'
+
id
).
attr
(
'
hidden
'
,
false
);
}
else
{
$
.
getJSON
(
"
./api/forum.ssjs?call=get-mail-body&number=
"
+
id
,
function
(
data
)
{
'
./api/forum.ssjs?call=get-mail-body&number=
'
+
id
,
function
(
data
)
{
var
str
=
data
.
body
;
if
(
data
.
inlines
.
length
>
0
)
str
+=
"
<br>Inline attachments:
"
+
data
.
inlines
.
join
(
"
<br>
"
)
+
"
<br>
"
;
if
(
data
.
attachments
.
length
>
0
)
str
+=
"
<br>Attachments:
"
+
data
.
attachments
.
join
(
"
<br>
"
)
+
"
<br>
"
;
if
(
data
.
inlines
.
length
>
0
)
{
str
+=
'
<br>Inline attachments:
'
+
data
.
inlines
.
join
(
'
<br>
'
)
+
'
<br>
'
;
}
if
(
data
.
attachments
.
length
>
0
)
{
str
+=
'
<br>Attachments:
'
+
data
.
attachments
.
join
(
'
<br>
'
)
+
'
<br>
'
;
}
str
+=
'
<button class="btn btn-default icon"
'
+
'
aria-label="Reply to this message"
'
+
...
...
@@ -205,19 +221,18 @@ var getMailBody = function(id) {
}
}
var
setScanCfg
=
function
(
sub
,
cfg
)
{
function
setScanCfg
(
sub
,
cfg
)
{
var
opts
=
[
"
scan-cfg-off
"
,
"
scan-cfg-new
"
,
"
scan-cfg-youonly
"
'
scan-cfg-off
'
,
'
scan-cfg-new
'
,
'
scan-cfg-youonly
'
];
$
.
getJSON
(
"
./api/forum.ssjs?call=set-scan-cfg&sub=
"
+
sub
+
"
&cfg=
"
+
cfg
,
function
(
data
)
{
if
(
!
data
.
success
)
return
;
'
./api/forum.ssjs?call=set-scan-cfg&sub=
'
+
sub
+
'
&cfg=
'
+
cfg
,
function
(
data
)
{
if
(
!
data
.
success
)
return
;
opts
.
forEach
(
function
(
opt
,
index
)
{
function
(
opt
,
index
)
{
$
(
'
#
'
+
opt
).
toggleClass
(
'
btn-primary
'
,
(
cfg
==
index
));
$
(
'
#
'
+
opt
).
toggleClass
(
'
btn-default
'
,
(
cfg
!=
index
));
}
...
...
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