Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
cf33fdc3
Commit
cf33fdc3
authored
Mar 13, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate version-data to TypeScript
parent
2e1a3939
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
18 deletions
+26
-18
version-data.ts
src/sidebar/helpers/version-data.ts
+26
-18
No files found.
src/sidebar/helpers/version-data.
j
s
→
src/sidebar/helpers/version-data.
t
s
View file @
cf33fdc3
/**
import
type
{
SegmentInfo
}
from
'../../types/annotator'
;
* @typedef {import('../../types/annotator').SegmentInfo} SegmentInfo
import
type
{
Frame
}
from
'../store/modules/frames'
;
* @typedef {import('../store/modules/frames').Frame} Frame
*/
/**
type
UserDetails
=
{
* @typedef UserDetails
userid
?:
string
|
null
;
* @prop {string|null} [userid]
displayName
?:
string
;
* @prop {string} [displayName]
};
*/
export
class
VersionData
{
export
class
VersionData
{
public
version
:
string
;
public
userAgent
:
string
;
public
urls
:
string
;
public
fingerprint
:
string
;
public
account
:
string
;
public
timestamp
:
string
;
public
segment
:
string
|
undefined
;
/**
/**
* @param {UserDetails} userInfo
* @param documentFrames - Metadata for connected frames.
* @param {Frame[]} documentFrames - Metadata for connected frames.
* If there are multiple frames, the "main" one should be listed first.
* If there are multiple frames, the "main" one should be listed first.
* @param
{Window}
window_ - test seam
* @param window_ - test seam
*/
*/
constructor
(
userInfo
,
documentFrames
,
window_
=
window
)
{
constructor
(
userInfo
:
UserDetails
,
documentFrames
:
Frame
[],
window_
:
Window
=
window
)
{
const
noValueString
=
'N/A'
;
const
noValueString
=
'N/A'
;
let
accountString
=
noValueString
;
let
accountString
=
noValueString
;
...
@@ -38,7 +46,7 @@ export class VersionData {
...
@@ -38,7 +46,7 @@ export class VersionData {
this
.
account
=
accountString
;
this
.
account
=
accountString
;
this
.
timestamp
=
new
Date
().
toString
();
this
.
timestamp
=
new
Date
().
toString
();
const
segmentInfo
=
documentFrames
[
0
]?.
segment
;
const
segmentInfo
:
SegmentInfo
|
undefined
=
documentFrames
[
0
]?.
segment
;
if
(
segmentInfo
)
{
if
(
segmentInfo
)
{
const
segmentFields
=
[];
const
segmentFields
=
[];
if
(
segmentInfo
.
cfi
)
{
if
(
segmentInfo
.
cfi
)
{
...
@@ -58,9 +66,9 @@ export class VersionData {
...
@@ -58,9 +66,9 @@ export class VersionData {
* Return a single formatted string representing version data, suitable for
* Return a single formatted string representing version data, suitable for
* copying to the clipboard.
* copying to the clipboard.
*
*
* @return
{string} -
Single, multiline string representing current version data
* @return Single, multiline string representing current version data
*/
*/
asFormattedString
()
{
asFormattedString
()
:
string
{
return
`Version:
${
this
.
version
}
return
`Version:
${
this
.
version
}
User Agent:
${
this
.
userAgent
}
User Agent:
${
this
.
userAgent
}
URL:
${
this
.
urls
}
URL:
${
this
.
urls
}
...
@@ -74,9 +82,9 @@ Date: ${this.timestamp}
...
@@ -74,9 +82,9 @@ Date: ${this.timestamp}
* Return a single, encoded URL string of version data suitable for use in
* Return a single, encoded URL string of version data suitable for use in
* a querystring (as the value of a single parameter)
* a querystring (as the value of a single parameter)
*
*
* @return
{string} -
URI-encoded string
* @return URI-encoded string
*/
*/
asEncodedURLString
()
{
asEncodedURLString
()
:
string
{
return
encodeURIComponent
(
this
.
asFormattedString
());
return
encodeURIComponent
(
this
.
asFormattedString
());
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment