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
22e6dd50
Commit
22e6dd50
authored
4 years ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
v4_fetch_jsonl for handling JSON-lines responses.
parent
4bb26715
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webv4/root/js/common.js
+32
-1
32 additions, 1 deletion
webv4/root/js/common.js
with
32 additions
and
1 deletion
webv4/root/js/common.js
+
32
−
1
View file @
22e6dd50
...
...
@@ -15,7 +15,7 @@ async function v4_fetch(url, method, body) {
const
data
=
await
response
.
json
();
return
data
;
}
catch
(
err
)
{
console
.
log
(
'
Error on fetch
'
,
url
,
init
);
console
.
error
(
'
Error on fetch
'
,
url
,
init
);
}
}
...
...
@@ -36,6 +36,19 @@ function v4_post(url, data) {
return
v4_fetch
(
url
,
'
POST
'
,
fd
);
}
async
function
v4_fetch_jsonl
(
url
)
{
try
{
const
response
=
await
fetch
(
url
);
const
text
=
await
response
.
text
();
return
text
.
split
(
/
\r\n
/
).
reduce
((
a
,
c
)
=>
{
if
(
c
!==
''
)
a
.
push
(
JSON
.
parse
(
c
));
return
a
;
},
[]);
}
catch
(
err
)
{
console
.
error
(
'
Error on fetch_jsonl
'
,
url
,
err
);
}
}
async
function
login
(
evt
)
{
if
(
$
(
'
#input-username
'
).
val
()
==
''
||
$
(
'
#input-password
'
).
val
()
==
''
)
{
return
;
...
...
@@ -63,6 +76,24 @@ function scrollUp() {
window
.
scrollBy
(
0
,
-
document
.
getElementById
(
'
navbar
'
).
offsetHeight
);
}
// Add a parameter to the query string
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
--
)
{
x
=
kvp
[
i
].
split
(
'
=
'
);
if
(
x
[
0
]
!==
key
)
continue
;
x
[
1
]
=
value
;
kvp
[
i
]
=
x
.
join
(
'
=
'
);
break
;
}
if
(
i
<
0
)
kvp
[
kvp
.
length
]
=
[
key
,
value
].
join
(
'
=
'
);
window
.
location
.
search
=
kvp
.
join
(
'
&
'
);
}
function
sendTelegram
(
alias
)
{
function
send_tg
(
evt
)
{
if
(
typeof
evt
!==
'
undefined
'
)
evt
.
preventDefault
();
...
...
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