Commit 3d0f3bca by ramdayalmunda

added all events

parent 89279b51
......@@ -32,6 +32,7 @@ var getUserDetails = null
let bodyObj = { ...body }
let headerObj = {
'Content-Type': 'application/json',
'userid': userDetails?.uid,
...headers,
}
fetch(url, {
......@@ -56,6 +57,7 @@ var getUserDetails = null
let bodyObj = { ...body }
let headerObj = {
'Content-Type': 'application/json',
'userid': userDetails?.uid,
...headers,
}
fetch(url, {
......@@ -81,6 +83,7 @@ var getUserDetails = null
return new Promise((res, rej) => {
let headerObj = {
'Content-Type': 'application/json',
'userid': userDetails?.uid,
...obj.headers,
}
fetch(url, {
......@@ -105,6 +108,7 @@ var getUserDetails = null
return new Promise((res, rej) => {
let headerObj = {
'Content-Type': 'application/json',
'userid': userDetails?.uid,
...obj.headers,
}
fetch(url, {
......@@ -132,7 +136,6 @@ var getUserDetails = null
async function onMessage(request, sender, sendResponse) {
if (request.action === 'login') {
console.log('B: to logged in', request.userDetails)
userDetails = request.userDetails
// check if credentials changed.
if (request.userDetails.email != userDetails.email) {
......@@ -200,6 +203,7 @@ var getUserDetails = null
return
}
if (loggedIn && request.action === 'stopRecording') {
await api.post('/tutor-shot/finalize', { _id: tutorShotId }, { headers: { userid: userDetails.uid } })
recording = false;
tutorShotId = null
sendResponse({
......@@ -208,8 +212,6 @@ var getUserDetails = null
recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped"
});
await api.post('/tutor-shot/finalize', { _id: tutorShotId }, { headers: { userid: userDetails.uid } })
sendMessageToActiveTab("recordingStopped")
return
}
......@@ -221,21 +223,19 @@ var getUserDetails = null
recording,
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped"
});
await api.delete('/tutor-shot/segments', { params: { tutorShotOid: tutorShotId } })
sendMessageToActiveTab("recordingRestarted")
return
}
if (request.action === 'captureSS') {
if (!loggedIn) {
console.log('not logged in for SS');
return;
}
if (!recording) {
console.log('recording not started for SS');
return;
}
if (!tutorShotId) {
console.log('how to set not created');
return
}
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
......@@ -252,9 +252,7 @@ var getUserDetails = null
}
// to send message to the content instance of the
chrome.tabs.sendMessage(activeTab.id, message);
console.log('to take screenshot', message)
let data = await api.post('/tutor-shot/screen-shot', message)
console.log('sent SS to server', data)
})
}
})
......@@ -288,7 +286,6 @@ var getUserDetails = null
status: tutorShotId ? (recording ? "recording" : "paused") : "stopped",
message: messageObj
}
console.log('sending message:', message)
chrome.tabs.sendMessage(activeTab.id, message);
}
})
......
......@@ -188,7 +188,6 @@ async function login() {
email: localStorage.getItem('email')
}
if (userDetails?.uid || userDetails?.email) { // can login
console.log('logged in', userDetails)
chrome.runtime.sendMessage({ action: "login", userDetails })
}
}
......@@ -201,7 +200,6 @@ async function getCaptureData() {
}
function reRenderFloatingBar(data) {
console.log('reRenderFloatingBar', data)
if (data) {
if (data.status == 'stopped') {
floatingBar.remove()
......@@ -216,7 +214,6 @@ function reRenderFloatingBar(data) {
}
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) {
......@@ -238,7 +235,6 @@ function reRenderFloatingBar(data) {
if (!btn.counter) btn.counter = document.querySelector('[tutor-shot="counter"]')
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'
......@@ -305,15 +301,12 @@ window.addEventListener('mousedown', async function (e) {
// content.js
chrome.runtime.onMessage.addListener(async function (message, sender, sendResponse) {
console.log('message received', message)
if (message.action == 'tabChanged') {
// console.log('tabChanged', message)
}
if (message.status) {
console.log('got message status', message)
}
if (message.action == 'SSCaptured') {
console.log('to capture SS')
// let data = await api.post("/tutor-shot/screen-shot", message)
}
let data = await getCaptureData()
......@@ -332,7 +325,6 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
startingOverlay.remove()
return
}
console.log('counter', counter)
startingOverlay.innerHTML = `
<div>
Click on the webpage to take screenshot
......@@ -377,8 +369,6 @@ async function resumeRecording() {
async function stopRecording() {
try {
console.log('to stop recording')
// await api.post('/tutor-shot/finalize', { _id: tutorShotOid }, { headers: { userid: userDetails.uid } })
await chrome.runtime.sendMessage({ action: "stopRecording" })
} catch (err) {
console.log(err)
......@@ -387,7 +377,6 @@ async function stopRecording() {
async function restartRecording() {
try {
await api.delete('/tutor-shot/segments', { params: { tutorShotOid: tutorShotOid } })
await chrome.runtime.sendMessage({ action: "restartRecording" })
} catch (err) {
console.log(err)
......
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