Commit 9d806564 by ramdayalmunda

added loader when stopping a recording.

parent 24f82e49
var getUserDetails = null var getUserDetails = null
!function () { !function () {
var origin = "https://begenieus.com" var origin = "http://localhost:3039"
var tutorShotId = null var tutorShotId = null
var imageNumber = 0; var imageNumber = 0;
var recording = false; var recording = false;
var loggedIn = false; var loggedIn = false;
var userDetails = {} var userDetails = {}
var generatingVideo = false;
function setData(key, value, callback) { function setData(key, value, callback) {
...@@ -51,6 +52,10 @@ var getUserDetails = null ...@@ -51,6 +52,10 @@ var getUserDetails = null
} }
}) })
function getStatus(){
return tutorShotId ? (generatingVideo?'generatingVideo':recording ? "recording" : "paused"):"stopped"
}
function createAPI(origin) { function createAPI(origin) {
var baseURL = origin var baseURL = origin
...@@ -191,7 +196,7 @@ var getUserDetails = null ...@@ -191,7 +196,7 @@ var getUserDetails = null
userDetails, userDetails,
tutorShotOid: tutorShotId, tutorShotOid: tutorShotId,
imageNumber: imageNumber, imageNumber: imageNumber,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped", status: getStatus(),
}) })
sendMessageToActiveTab("loggedIn") sendMessageToActiveTab("loggedIn")
...@@ -209,7 +214,7 @@ var getUserDetails = null ...@@ -209,7 +214,7 @@ var getUserDetails = null
recording, recording,
tutorShotOid: tutorShotId, tutorShotOid: tutorShotId,
imageNumber: imageNumber, imageNumber: imageNumber,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped" status: getStatus()
}) })
return return
} }
...@@ -222,7 +227,7 @@ var getUserDetails = null ...@@ -222,7 +227,7 @@ var getUserDetails = null
userDetails, userDetails,
loggedIn, loggedIn,
recording, recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped" status: getStatus()
}); });
sendMessageToActiveTab("recordingStarted") sendMessageToActiveTab("recordingStarted")
setData("recording", true) setData("recording", true)
...@@ -236,7 +241,7 @@ var getUserDetails = null ...@@ -236,7 +241,7 @@ var getUserDetails = null
userDetails, userDetails,
loggedIn, loggedIn,
recording, recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped" status: getStatus()
}); });
sendMessageToActiveTab("recordingPaused") sendMessageToActiveTab("recordingPaused")
setData("recording", false) setData("recording", false)
...@@ -248,22 +253,25 @@ var getUserDetails = null ...@@ -248,22 +253,25 @@ var getUserDetails = null
userDetails, userDetails,
loggedIn, loggedIn,
recording, recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped" status: getStatus()
}); });
sendMessageToActiveTab("recordingResumed") sendMessageToActiveTab("recordingResumed")
setData("recording", true) setData("recording", true)
return return
} }
if (loggedIn && request.action === 'stopRecording') { if (loggedIn && request.action === 'stopRecording') {
await api.post('/tutor-shot/finalize', { _id: tutorShotId }, { headers: { userid: userDetails.uid } }) generatingVideo = true
recording = false; recording = false;
tutorShotId = null
sendResponse({ sendResponse({
userDetails, userDetails,
loggedIn, loggedIn,
recording, recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped" status: getStatus()
}); });
sendMessageToActiveTab("generatingVideo")
await api.post('/tutor-shot/finalize', { _id: tutorShotId }, { headers: { userid: userDetails.uid } })
generatingVideo = false
tutorShotId = null
sendMessageToActiveTab("recordingStopped") sendMessageToActiveTab("recordingStopped")
setData("recording", false) setData("recording", false)
setData("imageNumber", 0) setData("imageNumber", 0)
...@@ -274,6 +282,7 @@ var getUserDetails = null ...@@ -274,6 +282,7 @@ var getUserDetails = null
if (request.action === 'logout') { if (request.action === 'logout') {
loggedIn = false; loggedIn = false;
recording = false; recording = false;
generatingVideo = false;
userDetails = {}; userDetails = {};
tutorShotId = null; tutorShotId = null;
imageNumber = 0; imageNumber = 0;
...@@ -283,13 +292,12 @@ var getUserDetails = null ...@@ -283,13 +292,12 @@ var getUserDetails = null
recording, recording,
status: "stopped" status: "stopped"
}); });
sendMessageToActiveTab("recordingStopped") sendMessageToActiveTab("loggedOut")
setData("recording", false) setData("recording", false)
setData("imageNumber", 0) setData("imageNumber", 0)
setData("tutorShotId", null) setData("tutorShotId", null)
setData("userDetails", {}) setData("userDetails", {})
setData("loggedIn", false) setData("loggedIn", false)
// setData()
return return
} }
if (loggedIn && request.action === 'restartRecording') { if (loggedIn && request.action === 'restartRecording') {
...@@ -298,7 +306,7 @@ var getUserDetails = null ...@@ -298,7 +306,7 @@ var getUserDetails = null
userDetails, userDetails,
loggedIn, loggedIn,
recording, recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped" status: getStatus()
}); });
await api.delete('/tutor-shot/segments', { params: { tutorShotOid: tutorShotId } }) await api.delete('/tutor-shot/segments', { params: { tutorShotOid: tutorShotId } })
sendMessageToActiveTab("recordingRestarted") sendMessageToActiveTab("recordingRestarted")
...@@ -325,7 +333,7 @@ var getUserDetails = null ...@@ -325,7 +333,7 @@ var getUserDetails = null
tutorShotOid: tutorShotId, tutorShotOid: tutorShotId,
action: 'SSCaptured', action: 'SSCaptured',
dataUrl: dataUrl, imageNumber: imageNumber++, dataUrl: dataUrl, imageNumber: imageNumber++,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped", status: getStatus(),
...request.captureInfo ? request.captureInfo : {} ...request.captureInfo ? request.captureInfo : {}
} }
setData("imageNumber", imageNumber) setData("imageNumber", imageNumber)
...@@ -362,10 +370,10 @@ var getUserDetails = null ...@@ -362,10 +370,10 @@ var getUserDetails = null
userDetails, userDetails,
tutorShotOid: tutorShotId, tutorShotOid: tutorShotId,
imageNumber: imageNumber, imageNumber: imageNumber,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped", status: getStatus(),
message: messageObj message: messageObj
} }
chrome.tabs.sendMessage(activeTab.id, message); chrome.tabs.sendMessage(activeTab?.id, message);
} }
}) })
} catch (err) { } catch (err) {
......
...@@ -5,7 +5,7 @@ var loggedIn = false; ...@@ -5,7 +5,7 @@ var loggedIn = false;
var floatingBar = null; var floatingBar = null;
var startingOverlay = null; var startingOverlay = null;
var overlayInterval = null; var overlayInterval = null;
const origin = "https://begenieus.com" const origin = "http://localhost:3039"
var userDetails = {}; var userDetails = {};
var btn = {}; var btn = {};
var tutorShotOid = null; var tutorShotOid = null;
...@@ -86,9 +86,11 @@ var tutorShotOid = null; ...@@ -86,9 +86,11 @@ var tutorShotOid = null;
} }
.tutor-shot .logo .logo-img { .tutor-shot .logo .logo-img {
display: block;
all: unset; all: unset;
margin-top: -4px; margin-top: -4px;
margin-left: -1px; margin-left: -1px;
height: 50px;
} }
.tutor-shot .content { .tutor-shot .content {
...@@ -106,6 +108,7 @@ var tutorShotOid = null; ...@@ -106,6 +108,7 @@ var tutorShotOid = null;
align-items: center; align-items: center;
margin-right: 16px; margin-right: 16px;
transition: 0.3s; transition: 0.3s;
cursor: pointer;
} }
.tutor-shot .content .item .img { .tutor-shot .content .item .img {
...@@ -119,6 +122,10 @@ var tutorShotOid = null; ...@@ -119,6 +122,10 @@ var tutorShotOid = null;
all: unset; all: unset;
padding-top: 2px; padding-top: 2px;
} }
.tutor-shot .content .item.width-100 {
width: 100%;
background: red;
}
` `
styleTag.innerHTML = styleString styleTag.innerHTML = styleString
...@@ -131,7 +138,8 @@ var tutorShotOid = null; ...@@ -131,7 +138,8 @@ var tutorShotOid = null;
<div class="counter-count" tutor-shot="counter" style="display:none;"></div> <div class="counter-count" tutor-shot="counter" style="display:none;"></div>
<div class="logo"> <div class="logo">
<img class="logo-img" src="${origin}/assets/images/tutor-shot-48.png" width="40"> <img tutor-shot="main-logo" class="logo-img" src="${origin}/assets/images/tutor-shot-48.png" width="40">
<img tutor-shot="generating-video" class="logo-img" src="${origin}/assets/images/logo-loader.gif" width="40">
</div> </div>
<div class="content"> <div class="content">
<div class="item" tutor-shot="play-btn"> <div class="item" tutor-shot="play-btn">
...@@ -204,7 +212,8 @@ function reRenderFloatingBar(data) { ...@@ -204,7 +212,8 @@ function reRenderFloatingBar(data) {
if (data.status == 'stopped') { if (data.status == 'stopped') {
floatingBar.remove() floatingBar.remove()
return return
} else if (!document.body.contains(floatingBar)) { }
else if (!document.body.contains(floatingBar)) {
document.body.append(floatingBar) document.body.append(floatingBar)
} }
} }
...@@ -212,6 +221,12 @@ function reRenderFloatingBar(data) { ...@@ -212,6 +221,12 @@ function reRenderFloatingBar(data) {
btn.play = document.querySelector('[tutor-shot="play-btn"]') btn.play = document.querySelector('[tutor-shot="play-btn"]')
btn.play.addEventListener('click', resumeRecording) btn.play.addEventListener('click', resumeRecording)
} }
if (!btn.mainLogo){
btn.mainLogo = document.querySelector('[tutor-shot="main-logo"]')
}
if (!btn.generatingVideo){
btn.generatingVideo = document.querySelector('[tutor-shot="generating-video"]')
}
if (!btn.capture) { if (!btn.capture) {
btn.capture = document.querySelector('[tutor-shot="capture-btn"]') btn.capture = document.querySelector('[tutor-shot="capture-btn"]')
} }
...@@ -244,23 +259,34 @@ function reRenderFloatingBar(data) { ...@@ -244,23 +259,34 @@ function reRenderFloatingBar(data) {
btn.pause.style.display = 'none' btn.pause.style.display = 'none'
btn.stop.style.display = 'flex' btn.stop.style.display = 'flex'
btn.restart.style.display = 'flex' btn.restart.style.display = 'flex'
// btn.capture.style.display = 'flex' btn.generatingVideo.style.display = 'none'
btn.mainLogo.style.display = 'block'
} }
else if (data?.status == 'recording') { else if (data?.status == 'recording') {
btn.play.style.display = 'none' btn.play.style.display = 'none'
btn.pause.style.display = 'flex' btn.pause.style.display = 'flex'
btn.restart.style.display = 'flex' btn.restart.style.display = 'flex'
btn.stop.style.display = 'flex' btn.stop.style.display = 'flex'
btn.generatingVideo.style.display = 'none'
btn.mainLogo.style.display = 'block'
// btn.capture.style.display = 'flex' // btn.capture.style.display = 'flex'
} }
else if ( data?.status == 'generatingVideo' ){
btn.play.style.display = 'none'
btn.pause.style.display = 'none'
btn.stop.style.display = 'none'
btn.restart.style.display = 'none'
btn.generatingVideo.style.display = 'block'
btn.mainLogo.style.display = 'none'
}
else { // stopped else { // stopped
btn.play.style.display = 'flex' btn.play.style.display = 'flex'
btn.pause.style.display = 'none' btn.pause.style.display = 'none'
btn.stop.style.display = 'none' btn.stop.style.display = 'none'
btn.restart.style.display = 'none' btn.restart.style.display = 'none'
// btn.capture.style.display = 'none' btn.generatingVideo.style.display = 'none'
btn.mainLogo.style.display = 'block'
} }
// floatingBar.innerHTML = innerHTML
} }
var recording = false; var recording = false;
...@@ -300,7 +326,6 @@ window.addEventListener('mousedown', async function (e) { ...@@ -300,7 +326,6 @@ window.addEventListener('mousedown', async function (e) {
}) })
// content.js // content.js
chrome.runtime.onMessage.addListener(async function (message, sender, sendResponse) { chrome.runtime.onMessage.addListener(async function (message, sender, sendResponse) {
if (message.action == 'tabChanged') { if (message.action == 'tabChanged') {
// console.log('tabChanged', message) // console.log('tabChanged', message)
} }
...@@ -338,7 +363,10 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon ...@@ -338,7 +363,10 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
} }
} }
if (message.message == 'recordingStopped') { else if (message.message == 'generatingVideo') {
reRenderFloatingBar(data)
}
else if (message.message == 'recordingStopped') {
window.open(`${origin}/tutor-shot-list`) window.open(`${origin}/tutor-shot-list`)
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"name": "Tutor Shot", "name": "Tutor Shot",
"version": "1.0", "version": "1.0",
"description": "Capture web-page screenshots instantly with a single click. They're saved to your account at https://begenieus.com.", "description": "Capture web-page screenshots instantly with a single click. They're saved to your account at http://localhost:3039.",
"permissions": [ "permissions": [
"activeTab", "activeTab",
"storage" "storage"
......
!function () { !function () {
const origin = "https://begenieus.com" const origin = "http://localhost:3039"
const api = axios.create({ const api = axios.create({
baseURL: `${origin}/api`, // the base URL for nodeserver is okay but NGINX is giving error baseURL: `${origin}/api`, // the base URL for nodeserver is okay but NGINX is giving error
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
function domLoadHandler() { function domLoadHandler() {
chrome.runtime.sendMessage({ action: "checkStatus" }, function (response) { chrome.runtime.sendMessage({ action: "checkStatus" }, function (response) {
console.log('response',response)
userDetails = response.userDetails; userDetails = response.userDetails;
loggedIn = response.loggedIn, loggedIn = response.loggedIn,
recording = response.recording recording = response.recording
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment