Commit 69f0af17 by Pragati Upadhyay

change branch

parent 1b29ea7b
var getUserDetails = null
!function () {
var origin = "https://begenieus.online"
var origin = "http://localhost:3003"
var tutorShotId = null
var imageNumber = 0;
var recording = false;
......@@ -37,22 +37,22 @@ var getUserDetails = null
})
}
getData('userDetails', async (data)=>{
if (data){
getData('userDetails', async (data) => {
if (data) {
let tso = await getData('tutorShotId')
tutorShotId = tso?tso:null
tutorShotId = tso ? tso : null
let imgNum = await getData('imageNumber')
imageNumber = imgNum?imgNum:0
imageNumber = imgNum ? imgNum : 0
let rec = await getData('recording')
recording = rec?rec:false
recording = rec ? rec : false
userDetails = data
loggedIn = (userDetails.email || userDetails.uid)?true:false;
loggedIn = (userDetails.email || userDetails.uid) ? true : false;
}
})
function getStatus(){
return tutorShotId ? (recording ? "recording" : "paused"):"stopped"
function getStatus() {
return tutorShotId ? (recording ? "recording" : "paused") : "stopped"
}
......@@ -261,20 +261,33 @@ var getUserDetails = null
if (loggedIn && request.action === 'stopRecording') {
recording = false;
let generatingOid = tutorShotId
tutorShotId = null
sendResponse({
userDetails,
loggedIn,
recording,
status: "generatingVideo"
});
sendMessageToActiveTab("generatingVideo")
await api.post('/tutor-shot/finalize', { _id: generatingOid }, { headers: { userid: userDetails.uid } })
setData("recording", false)
setData("imageNumber", 0)
setData("tutorShotId", null)
imageNumber = 0;
return
if (imageNumber < 1) {
let { data } = await api.delete("tutor-shot", {
params: { _id: tutorShotId },
headers: { userid: userDetails.uid }
})
tutorShotId = null
sendMessageToActiveTab("showRestartProcess")
setData("recording", false)
setData("tutorShotId", null)
return
}
else {
tutorShotId = null
sendResponse({
userDetails,
loggedIn,
recording,
status: "generatingVideo"
});
sendMessageToActiveTab("generatingVideo")
await api.post('/tutor-shot/finalize', { _id: generatingOid }, { headers: { userid: userDetails.uid } })
setData("recording", false)
setData("imageNumber", 0)
setData("tutorShotId", null)
imageNumber = 0;
return
}
}
if (request.action === 'logout') {
loggedIn = false;
......@@ -369,9 +382,9 @@ var getUserDetails = null
status: getStatus(),
message: messageObj
}
try{
try {
chrome.tabs.sendMessage(activeTab?.id, message);
}catch(err){
} catch (err) {
console.log('error while sending data', activeTab, message)
console.log(err)
}
......
......@@ -6,7 +6,7 @@ var floatingBar = null;
var startingOverlay = null;
var finalizingOverlay = null;
var overlayInterval = null;
const origin = "https://begenieus.online"
const origin = "http://localhost:3003"
var userDetails = {};
var btn = {};
var tutorShotOid = null;
......@@ -335,7 +335,6 @@ window.addEventListener('mousedown', async function (e) {
}
let newLineBreakIndex = captureInfo.text.search('\n')
if (newLineBreakIndex != -1) captureInfo.text = captureInfo.text.slice(0, newLineBreakIndex)
// console.log('sending capture info', captureInfo)
chrome.runtime.sendMessage({ action: "captureSS", captureInfo })
let data = await getCaptureData()
reRenderFloatingBar(data)
......@@ -382,6 +381,27 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
}
}
else if (message.message == 'showRestartProcess') {
finalizingOverlay = document.createElement('div')
finalizingOverlay.setAttribute('class', 'tutor-shot-overlay')
finalizingOverlay.setAttribute('style', `all: unset; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color: #000000a0; pointer-events: inherit; z-index: 101; display: flex; color: white; justify-content: center; align-items: center; font-size: 28px;`)
document.body.append(finalizingOverlay)
finalizingOverlay.innerHTML = `
<div>
No Image found.
</div>
`
setTimeout(() => {
finalizingOverlay.remove()
if (window.location.href == `${origin}/tutor-shot-list`) {
window.location.reload()
} else {
window.open(`${origin}/tutor-shot-list`)
}
reRenderFloatingBar(data)
}, 2000)
reRenderFloatingBar(data)
}
else if (message.message == 'generatingVideo') {
finalizingOverlay = document.createElement('div')
finalizingOverlay.setAttribute('class', 'tutor-shot-overlay')
......@@ -411,10 +431,13 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
async function startRecording() {
try {
await getCaptureData();
if(imageNumber>=1){
let { data } = await api.post('/tutor-shot', { title: "No Title" }, { headers: { userId: userDetails.uid } })
if (data.success) {
await chrome.runtime.sendMessage({ action: "startRecording", tutorShotId: data.tutorShot._id })
}
}
else return
} catch (err) {
console.log('error while starting to record', err)
inProgress = false
......
......@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Tutor Shot",
"version": "1.10",
"description": "Capture web-page screenshots instantly with a single click. They're saved to your account at https://begenieus.online.",
"description": "Capture web-page screenshots instantly with a single click. They're saved to your account at http://localhost:3003.",
"permissions": [
"activeTab",
"storage"
......
!function () {
const origin = "https://begenieus.online"
const origin = "http://localhost:3003"
const api = axios.create({
baseURL: `${origin}/api`, // the base URL for nodeserver is okay but NGINX is giving error
......
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