Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tutor-shot-extension
Overview
Overview
Details
Activity
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
Ramdayal Munda
tutor-shot-extension
Commits
f86b8529
Commit
f86b8529
authored
Nov 14, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restart recording feature added
parent
6a3f96aa
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
35 deletions
+72
-35
background.js
background.js
+11
-0
content.js
content.js
+61
-35
calibri-regular.ttf
fonts/calibri-regular.ttf
+0
-0
No files found.
background.js
View file @
f86b8529
...
...
@@ -92,6 +92,17 @@ var getUserDetails = null
sendMessageToActiveTab
(
"recordingStopped"
)
return
}
if
(
loggedIn
&&
request
.
action
===
'restartRecording'
)
{
imageNumber
=
0
;
sendResponse
({
userDetails
,
loggedIn
,
recording
,
status
:
tutorShotId
?(
recording
?
"recording"
:
"paused"
):
"stopped"
});
sendMessageToActiveTab
(
"recordingRestarted"
)
return
}
if
(
request
.
action
===
'captureSS'
)
{
if
(
!
loggedIn
)
{
...
...
content.js
View file @
f86b8529
...
...
@@ -10,11 +10,7 @@ var userDetails = {};
var
btn
=
{}
!
(
async
function
()
{
// this is load custom font
let
customFont
=
new
FontFace
(
'tutor-shot-calibri'
,
`url(
${
origin
}
/assets/fonts/calibri-regular.ttf) format("truetype")`
)
customFont
.
load
().
then
(
function
(
font
)
{
document
.
fonts
.
add
(
font
);
})
loadFont
(
'tutor-shot-calibri'
,
`
${
origin
}
/assets/fonts/calibri-regular.ttf`
,
'truetype'
)
if
(
window
.
origin
==
origin
)
login
()
...
...
@@ -50,7 +46,8 @@ var btn = {}
box-shadow: 0px 0px 20px #cccccc;
display: flex;
align-items: center;
font-family: 'tutor-shot-calibri';
/* font-family: 'tutor-shot-calibri'; */
font-family: 'sans serif';
transition: 0.3s;
}
...
...
@@ -200,42 +197,42 @@ async function getCaptureData() {
function
reRenderFloatingBar
(
data
)
{
console
.
log
(
'reRenderFloatingBar'
,
data
)
if
(
data
){
if
(
data
.
status
==
'stopped'
)
{
if
(
data
)
{
if
(
data
.
status
==
'stopped'
)
{
floatingBar
.
remove
()
return
}
else
if
(
!
document
.
body
.
contains
(
floatingBar
))
{
}
else
if
(
!
document
.
body
.
contains
(
floatingBar
))
{
document
.
body
.
append
(
floatingBar
)
}
}
if
(
!
btn
.
play
){
if
(
!
btn
.
play
)
{
btn
.
play
=
document
.
querySelector
(
'[tutor-shot="play-btn"]'
)
btn
.
play
.
addEventListener
(
'click'
,
resumeRecording
)
}
if
(
!
btn
.
capture
){
if
(
!
btn
.
capture
)
{
btn
.
capture
=
document
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
console
.
log
(
'take screen shot'
)
}
if
(
!
btn
.
playText
)
btn
.
playText
=
document
.
querySelector
(
'[tutor-shot="play-text"]'
)
if
(
!
btn
.
pause
){
if
(
!
btn
.
pause
)
{
btn
.
pause
=
document
.
querySelector
(
'[tutor-shot="pause-btn"]'
)
btn
.
pause
.
addEventListener
(
'click'
,
pauseRecording
)
}
if
(
!
btn
.
stop
){
if
(
!
btn
.
stop
)
{
btn
.
stop
=
document
.
querySelector
(
'[tutor-shot="stop-btn"]'
)
btn
.
stop
.
addEventListener
(
'click'
,
stopRecording
)
}
if
(
!
btn
.
restart
){
if
(
!
btn
.
restart
)
{
btn
.
restart
=
document
.
querySelector
(
'[tutor-shot="restart-btn"]'
)
btn
.
restart
.
addEventListener
(
'click'
,
restartRecording
)
}
if
(
!
btn
.
counter
)
btn
.
counter
=
document
.
querySelector
(
'[tutor-shot="counter"]'
)
if
(
data
?.
hasOwnProperty
(
'imageNumber'
)){
if
(
data
?.
hasOwnProperty
(
'imageNumber'
))
{
console
.
log
(
'set'
,
data
.
imageNumber
,
btn
.
counter
.
innerHTML
)
btn
.
counter
.
innerHTML
=
`
${
data
.
imageNumber
}
`
if
(
data
.
imageNumber
<=
0
)
btn
.
counter
.
style
.
display
=
'none'
else
btn
.
counter
.
style
.
display
=
'flex'
if
(
data
.
imageNumber
<=
0
)
btn
.
counter
.
style
.
display
=
'none'
else
btn
.
counter
.
style
.
display
=
'flex'
}
if
(
data
?.
state
==
'paused'
)
{
btn
.
play
.
style
.
display
=
'flex'
...
...
@@ -273,7 +270,7 @@ const api = axios.create({
window
.
addEventListener
(
'mousedown'
,
async
function
(
e
)
{
// to prevent the event when clicking inside the floating bar
if
(
floatingBar
?.
contains
(
e
.
target
)
||
startingOverlay
?.
contains
(
e
.
target
)){
if
(
floatingBar
?.
contains
(
e
.
target
)
||
startingOverlay
?.
contains
(
e
.
target
))
{
return
}
if
(
e
.
button
===
0
)
{
// only left click allowed
...
...
@@ -303,21 +300,21 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
if
(
message
.
action
==
'tabChanged'
)
{
// console.log('tabChanged', message)
}
if
(
message
.
status
){
if
(
message
.
status
)
{
console
.
log
(
'got message status'
,
message
)
}
let
data
=
await
getCaptureData
()
reRenderFloatingBar
(
data
)
if
(
message
.
message
==
'recordingStarted'
){
if
(
floatingBar
){
if
(
!
startingOverlay
)
{
if
(
message
.
message
==
'recordingStarted'
)
{
if
(
floatingBar
)
{
if
(
!
startingOverlay
)
{
clearInterval
(
overlayInterval
)
let
counter
=
5
startingOverlay
=
document
.
createElement
(
'div'
)
startingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
document
.
body
.
append
(
startingOverlay
)
function
changeText
(){
if
(
counter
<=
0
)
{
function
changeText
()
{
if
(
counter
<=
0
)
{
clearInterval
(
overlayInterval
)
startingOverlay
.
remove
()
return
...
...
@@ -332,12 +329,15 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
`
}
changeText
()
overlayInterval
=
setInterval
(
changeText
,
1000
)
overlayInterval
=
setInterval
(
changeText
,
1000
)
}
}
}
if
(
message
.
message
==
'recordingStopped'
)
{
window
.
open
(
`
${
origin
}
/tutor-shot-list`
)
}
});
...
...
@@ -356,19 +356,44 @@ async function startRecording() {
}
}
async
function
pauseRecording
(){
console
.
log
(
'to pause recording'
)
await
chrome
.
runtime
.
sendMessage
({
action
:
"pauseRecording"
})
async
function
pauseRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"pauseRecording"
})
}
async
function
resumeRecording
(){
await
chrome
.
runtime
.
sendMessage
({
action
:
"resumeRecording"
})
async
function
resumeRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"resumeRecording"
})
}
async
function
stopRecording
(){
console
.
log
(
'stop recording'
)
await
chrome
.
runtime
.
sendMessage
({
action
:
"stopRecording"
})
async
function
stopRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"stopRecording"
})
}
async
function
restartRecording
(){
console
.
log
(
'remove all the screenshot in current recording'
)
async
function
restartRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"restartRecording"
})
try
{
let
captureData
=
await
getCaptureData
()
await
api
.
delete
(
'/tutor-shot/segments'
,
{
params
:
{
tutorShotOid
:
captureData
.
tutorShotOid
}
})
}
catch
(
err
){
console
.
log
(
err
)
}
}
async
function
checkFont
(
fontName
)
{
// Use FontFace API to check if the font is available
try
{
await
document
.
fonts
.
load
(
'1em '
+
fontName
);
// Attempt to load the font
return
true
;
// Font successfully loaded
}
catch
(
error
)
{
return
false
;
// Font couldn't be loaded
}
}
async
function
loadFont
(
name
,
url
,
type
=
'true'
){
return
new
Promise
(
(
res
,
rej
)
=>
{
// this is load custom font
let
customFont
=
new
FontFace
(
name
,
`url(
${
url
}
) format("
${
type
}
")`
)
customFont
.
load
().
then
(
function
(
font
)
{
document
.
fonts
.
add
(
font
);
res
(
true
)
})
}
)
}
\ No newline at end of file
fonts/calibri-regular.ttf
0 → 100644
View file @
f86b8529
File added
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