Commit 532e22c0 by ramdayalmunda

styling done

parent fd89e144
...@@ -25,7 +25,12 @@ var getUserDetails = null ...@@ -25,7 +25,12 @@ var getUserDetails = null
} }
if (request.action === 'checkStatus') { if (request.action === 'checkStatus') {
sendResponse({ userDetails, loggedIn, recording }) sendResponse({
userDetails,
loggedIn,
recording,
status: tutorShotId?(recording?"recording":"paused"):"stopped"
})
return return
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
* This file can access the DOM elements and also trigger DOM events * This file can access the DOM elements and also trigger DOM events
*/ */
var loggedIn = false; var loggedIn = false;
var floatingBar = null var floatingBar = null;
!(function () { const origin = "http://localhost:3039"
let origin = "http://localhost:3039" var btn = {}
!(async function () {
// this is load custom font // this is load custom font
let customFont = new FontFace('tutor-shot-calibri', "http://localhost:3039/assets/fonts/calibri-regular.ttf") let customFont = new FontFace('tutor-shot-calibri', `url(${origin}/assets/fonts/calibri-regular.ttf) format("truetype")`)
customFont.load().then(function (font) { customFont.load().then(function (font) {
document.fonts.add(font); document.fonts.add(font);
}) })
...@@ -16,7 +17,7 @@ var floatingBar = null ...@@ -16,7 +17,7 @@ var floatingBar = null
let styleTag = document.createElement('style') let styleTag = document.createElement('style')
styleTag.setAttribute('tutor-shot-style', '') styleTag.setAttribute('tutor-shot-style', '')
styleString = ` styleString = /*css*/`
.tutor-shot { .tutor-shot {
all: unset; all: unset;
...@@ -31,7 +32,7 @@ var floatingBar = null ...@@ -31,7 +32,7 @@ var floatingBar = null
box-shadow: 0px 0px 20px #cccccc; box-shadow: 0px 0px 20px #cccccc;
display: flex; display: flex;
align-items: center; align-items: center;
font-family: 'calibri'; font-family: 'tutor-shot-calibri';
transition: 0.3s; transition: 0.3s;
} }
...@@ -103,6 +104,7 @@ var floatingBar = null ...@@ -103,6 +104,7 @@ var floatingBar = null
.tutor-shot .content .item .item-text { .tutor-shot .content .item .item-text {
all: unset; all: unset;
} }
` `
styleTag.innerHTML = styleString styleTag.innerHTML = styleString
document.body.append(styleTag) document.body.append(styleTag)
...@@ -112,44 +114,51 @@ var floatingBar = null ...@@ -112,44 +114,51 @@ var floatingBar = null
document.body.append(floatingBar) document.body.append(floatingBar)
let innerHTML = /*html*/` let innerHTML = /*html*/`
<div class="counter-count">1</div> <div class="counter-count" tutor-shot="counter">1</div>
<div class="logo"> <div class="logo">
<img class="logo-img" src="${origin}/assets/images/tutor-shot-48.png" width="40"> <img class="logo-img" src="${origin}/assets/images/tutor-shot-48.png" width="40">
</div> </div>
<div class="content"> <div class="content">
<div class="item"> <div class="item" tutor-shot="play-btn">
<img class="img" src="${origin}/assets/icons/play.svg" width="20">
<span class="item-text" tutor-shot="play-text">CONTINUE</span>
</div>
<div class="item" tutor-shot="pause-btn">
<img class="img" src="${origin}/assets/icons/pause.svg" width="20"> <img class="img" src="${origin}/assets/icons/pause.svg" width="20">
<span class="item-text">PAUSE</span> <span class="item-text">PAUSE</span>
</div> </div>
<div class="item"> <div class="item" tutor-shot="stop-btn">
<img class="img" src="${origin}/assets/icons/stop-circle.svg" width="20"> <img class="img" src="${origin}/assets/icons/stop-circle.svg" width="20">
<span class="item-text">STOP</span> <span class="item-text">STOP</span>
</div> </div>
<div class="item"> <div class="item" tutor-shot="restart-btn">
<img class="img" src="${origin}/assets/icons/redo.svg" width="20"> <img class="img" src="${origin}/assets/icons/redo.svg" width="20">
<span class="item-text">RESTART</span> <span class="item-text">RESTART</span>
</div> </div>
<div class="item"> <div class="item" tutor-shot="capture-btn">
<img class="img" src="${origin}/assets/icons/capture.svg" width="20"> <img class="img" src="${origin}/assets/icons/capture.svg" width="20">
<span class="item-text">CAPTURE</span> <span class="item-text">CAPTURE</span>
</div> </div>
<div class="item" tutor-shot="capture-btn">
<img class="img" src="${origin}/assets/icons/left-arrow-to-left.svg" width="20">
</div>
</div> </div>
` `
floatingBar.innerHTML = innerHTML floatingBar.innerHTML = innerHTML
document.addEventListener("visibilitychange", function () { document.addEventListener("visibilitychange", async function () {
if (document.visibilityState === 'visible') { if (document.visibilityState === 'visible') {
let data = getCaptureData() let data = await getCaptureData()
reRenderFloatingBar(data.SSTaken, data.state) reRenderFloatingBar(data)
} }
}) })
let data = getCaptureData() let data = await getCaptureData()
reRenderFloatingBar(data.SSTaken, data.state) reRenderFloatingBar(data)
})() })()
function login() { async function login() {
let userDetails = { let userDetails = {
uid: localStorage.getItem('userId'), uid: localStorage.getItem('userId'),
...@@ -162,29 +171,48 @@ function login() { ...@@ -162,29 +171,48 @@ function login() {
} }
} }
function getCaptureData() { async function getCaptureData() {
return { let statusData = await chrome.runtime.sendMessage({ action: "checkStatus" })
SSTaken: 28, return statusData
state: "paused"
}
} }
function reRenderFloatingBar(ssTaken, state) { function reRenderFloatingBar(data) {
console.log('reset floting bar data') console.log('reset floting bar data', data)
if (!btn.play) btn.play = document.querySelector('[tutor-shot="play-btn"]')
if (!btn.playText) btn.playText = document.querySelector('[tutor-shot="play-text"]')
if (!btn.pause) btn.pause = document.querySelector('[tutor-shot="pause-btn"]')
if (!btn.stop) btn.stop = document.querySelector('[tutor-shot="stop-btn"]')
if (!btn.restart) btn.restart = document.querySelector('[tutor-shot="restart-btn"]')
if (data?.state=='paused'){
btn.play.style.display = 'flex'
btn.pause.style.display = 'none'
btn.stop.style.display = 'flex'
btn.playText.innerHTML = 'CONTINUE'
}
else if (data?.status=='recording'){
btn.play.style.display = 'none'
btn.pause.style.display = 'flex'
btn.stop.style.display = 'flex'
}
else{ // stopped
btn.play.style.display = 'flex'
btn.pause.style.display = 'none'
btn.stop.style.display = 'none'
btn.playText.innerHTML = 'START'
}
// floatingBar.innerHTML = innerHTML // floatingBar.innerHTML = innerHTML
} }
var recording = false; var recording = false;
const api = axios.create({ const api = axios.create({
baseURL: "http://localhost:3039/api", baseURL: `${origin}/api`,
headers: { headers: {
'Access-Control-Allow-Origin': '*', // Replace '*' with the origin you need 'Access-Control-Allow-Origin': '*', // Replace '*' with the origin you need
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
}); });
window.addEventListener('mousedown', function (e) { window.addEventListener('mousedown', async function (e) {
if (e.button === 0) { // only left click allowed if (e.button === 0) { // only left click allowed
console.log('click received') console.log('click received')
...@@ -201,23 +229,27 @@ window.addEventListener('mousedown', function (e) { ...@@ -201,23 +229,27 @@ window.addEventListener('mousedown', function (e) {
origin: location.origin, origin: location.origin,
} }
chrome.runtime.sendMessage({ action: "captureSS", captureInfo }) chrome.runtime.sendMessage({ action: "captureSS", captureInfo })
let data = await getCaptureData()
reRenderFloatingBar(data)
} }
}) })
// content.js // content.js
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { chrome.runtime.onMessage.addListener(async function (message, sender, sendResponse) {
if (message.action == 'SSCaptured') { if (message.action == 'SSCaptured') {
console.log('SSCaptured', message) console.log('SSCaptured', message)
api.post("/tutor-shot/screen-shot", message).then(res => { // api.post("/tutor-shot/screen-shot", message).then(res => {
console.log('response', res) // console.log('response', res)
}).catch(err => { // }).catch(err => {
console.log('err', err) // console.log('err', err)
}) // })
} }
if (message.action == 'tabChanged') { if (message.action == 'tabChanged') {
console.log('tabChanged', message) // console.log('tabChanged', message)
} }
let data = await getCaptureData()
reRenderFloatingBar(data)
}); });
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