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
a22364e4
Commit
a22364e4
authored
5 years ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
Allow additional parameters in call to events.ssjs.
Return-style load of web/lib/auth.ssjs.
parent
7c501958
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
web/root/api/events.ssjs
+3
-3
3 additions, 3 deletions
web/root/api/events.ssjs
web/root/js/common.js
+22
-10
22 additions, 10 deletions
web/root/js/common.js
web/sidebar/.examples/001-nodelist.xjs
+3
-3
3 additions, 3 deletions
web/sidebar/.examples/001-nodelist.xjs
with
28 additions
and
16 deletions
web/root/api/events.ssjs
+
3
−
3
View file @
a22364e4
load
(
'
sbbsdefs.js
'
);
load
(
'
sbbsdefs.js
'
);
load
(
'
modopts.js
'
);
load
(
'
modopts.js
'
);
var
settings
=
get_mod_options
(
'
web
'
);
const
settings
=
get_mod_options
(
'
web
'
);
load
(
settings
.
web_directory
+
'
/lib/init.js
'
);
load
(
settings
.
web_directory
+
'
/lib/init.js
'
);
load
(
settings
.
web_lib
+
'
auth.js
'
);
const
auth_lib
=
load
(
{},
settings
.
web_lib
+
'
auth.js
'
);
http_reply
.
header
[
'
Cache-Control
'
]
=
'
no-cache
'
;
http_reply
.
header
[
'
Cache-Control
'
]
=
'
no-cache
'
;
http_reply
.
header
[
'
Content-type
'
]
=
'
text/event-stream
'
;
http_reply
.
header
[
'
Content-type
'
]
=
'
text/event-stream
'
;
...
...
This diff is collapsed.
Click to expand it.
web/root/js/common.js
+
22
−
10
View file @
a22364e4
...
@@ -59,6 +59,17 @@ function sendTelegram(alias) {
...
@@ -59,6 +59,17 @@ function sendTelegram(alias) {
$
(
'
#popUpModal
'
).
modal
(
'
show
'
);
$
(
'
#popUpModal
'
).
modal
(
'
show
'
);
}
}
function
registerEventListener
(
scope
,
callback
,
params
)
{
params
=
Object
.
keys
(
params
||
{}).
reduce
(
function
(
a
,
c
)
{
a
+=
'
&
'
+
c
+
'
=
'
+
params
[
c
];
return
a
;
},
''
);
_sbbs_events
[
scope
]
=
{
qs
:
'
subscribe=
'
+
scope
+
params
,
callback
:
callback
};
}
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
$
(
'
#button-logout
'
).
click
(
logout
);
$
(
'
#button-logout
'
).
click
(
logout
);
...
@@ -79,14 +90,14 @@ window.onload = function () {
...
@@ -79,14 +90,14 @@ window.onload = function () {
if
(
$
(
'
#button-logout
'
).
length
>
0
)
{
if
(
$
(
'
#button-logout
'
).
length
>
0
)
{
_sbbs_events
.
mail
=
function
(
e
)
{
registerEventListener
(
'
mail
'
,
function
(
e
)
{
const
data
=
JSON
.
parse
(
e
.
data
);
const
data
=
JSON
.
parse
(
e
.
data
);
if
(
typeof
data
.
count
!=
'
number
'
)
return
;
if
(
typeof
data
.
count
!=
'
number
'
)
return
;
$
(
'
#badge-unread-mail
'
).
text
(
data
.
count
<
1
?
''
:
data
.
count
);
$
(
'
#badge-unread-mail
'
).
text
(
data
.
count
<
1
?
''
:
data
.
count
);
$
(
'
#badge-unread-mail-inner
'
).
text
(
data
.
count
<
1
?
''
:
data
.
count
);
$
(
'
#badge-unread-mail-inner
'
).
text
(
data
.
count
<
1
?
''
:
data
.
count
);
}
});
_sbbs_events
.
telegram
=
function
(
e
)
{
registerEventListener
(
'
telegram
'
,
function
(
e
)
{
const
tg
=
JSON
.
parse
(
e
.
data
).
replace
(
/
\1
./g
,
''
).
replace
(
const
tg
=
JSON
.
parse
(
e
.
data
).
replace
(
/
\1
./g
,
''
).
replace
(
/
\r?\n
/g
,
'
<br>
'
/
\r?\n
/g
,
'
<br>
'
);
);
...
@@ -94,16 +105,17 @@ window.onload = function () {
...
@@ -94,16 +105,17 @@ window.onload = function () {
$
(
'
#popUpModalBody
'
).
append
(
tg
);
$
(
'
#popUpModalBody
'
).
append
(
tg
);
$
(
'
#popUpModalActionButton
'
).
hide
();
$
(
'
#popUpModalActionButton
'
).
hide
();
$
(
'
#popUpModal
'
).
modal
(
'
show
'
);
$
(
'
#popUpModal
'
).
modal
(
'
show
'
);
}
});
}
}
const
_evtqs
=
Object
.
keys
(
_sbbs_events
).
reduce
(
function
(
a
,
c
,
i
)
{
const
qs
=
Object
.
keys
(
_sbbs_events
).
reduce
(
function
(
a
,
c
,
i
)
{
return
a
+
(
i
==
0
?
'
?
'
:
'
&
'
)
+
'
subscribe=
'
+
c
;
},
''
return
a
+
(
i
==
0
?
'
?
'
:
'
&
'
)
+
_sbbs_events
[
c
].
qs
;
);
},
''
);
const
_es
=
new
EventSource
(
'
/api/events.ssjs
'
+
_evtqs
);
const
es
=
new
EventSource
(
'
/api/events.ssjs
'
+
qs
);
Object
.
keys
(
_sbbs_events
).
forEach
(
function
(
e
)
{
Object
.
keys
(
_sbbs_events
).
forEach
(
function
(
e
)
{
_
es
.
addEventListener
(
e
,
_sbbs_events
[
e
]);
es
.
addEventListener
(
e
,
_sbbs_events
[
e
]
.
callback
);
});
});
}
}
This diff is collapsed.
Click to expand it.
web/sidebar/.examples/001-nodelist.xjs
+
3
−
3
View file @
a22364e4
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
$('#sidebar').find('.sb-nodes-available').text(nll - niu);
$('#sidebar').find('.sb-nodes-available').text(nll - niu);
}
}
_sbbs_events.
nodelist
=
_sb_nodelist;
registerEventListener('
nodelist
',
_sb_nodelist
)
;
<?xjs if (settings.nodelist_ibbs) { ?>
<?xjs if (settings.nodelist_ibbs) { ?>
function _send_ibbs_telegram(sys, host, user) {
function _send_ibbs_telegram(sys, host, user) {
...
@@ -109,7 +109,7 @@
...
@@ -109,7 +109,7 @@
$('#popUpModal').modal('show');
$('#popUpModal').modal('show');
}
}
_sbbs_events.
sbbsimsg
=
function (e) {
registerEventListener('
sbbsimsg
',
function (e) {
const data = JSON.parse(e.data);
const data = JSON.parse(e.data);
var users = 0;
var users = 0;
$('#sbbsimsg-nodelist').addClass('hidden');
$('#sbbsimsg-nodelist').addClass('hidden');
...
@@ -145,7 +145,7 @@
...
@@ -145,7 +145,7 @@
$('#sbbsimsg-nodelist').removeClass('hidden');
$('#sbbsimsg-nodelist').removeClass('hidden');
$('#sbbs-nodelist').parent().removeClass('hidden');
$('#sbbs-nodelist').parent().removeClass('hidden');
}
}
}
}
);
<?xjs } ?>
<?xjs } ?>
</script>
</script>
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