|
1 | 1 | console.log("Popup!!")
|
2 |
| -// send a message to the service worker of type "RECORD" |
| 2 | +// // send a message to the service worker of type "RECORD" |
3 | 3 |
|
4 |
| -const startBtn = document.getElementById("start_rec_btn"); |
5 |
| -const statusSpan = document.getElementById("status"); |
6 |
| -// add event listener to the button |
7 |
| -startBtn.addEventListener("click", function () { |
8 |
| - statusSpan.innerText = "Recording..."; |
9 |
| - chrome.runtime.sendMessage({ type: "RECORD" }); |
10 |
| -}) |
| 4 | +// const startBtn = document.getElementById("start_rec_btn"); |
| 5 | +// const statusSpan = document.getElementById("status"); |
| 6 | +// // add event listener to the button |
| 7 | +// startBtn.addEventListener("click", function () { |
| 8 | +// statusSpan.innerText = "Recording..."; |
| 9 | +// chrome.runtime.sendMessage({ type: "RECORD" }); |
| 10 | +// }) |
11 | 11 |
|
12 |
| -// get element of id "btn" |
13 |
| -const btn = document.getElementById("btn"); |
14 |
| -// add event listener to the button |
15 |
| -btn.addEventListener("click", function () { |
16 |
| - statusSpan.innerText = "Awaiting results..."; |
17 |
| - chrome.runtime.sendMessage({ type: "STOP_RECORDING" }); |
18 |
| -}) |
| 12 | +// // get element of id "btn" |
| 13 | +// const btn = document.getElementById("btn"); |
| 14 | +// // add event listener to the button |
| 15 | +// btn.addEventListener("click", function () { |
| 16 | +// statusSpan.innerText = "Awaiting results..."; |
| 17 | +// chrome.runtime.sendMessage({ type: "STOP_RECORDING" }); |
| 18 | +// }) |
19 | 19 |
|
20 | 20 | // listen to message with type "SUGGESTED_CODE"
|
21 | 21 | chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
| 22 | + console.log("Popup received message", request) |
| 23 | + if (request.type === "FULL_CURRENT_CHAT") { |
| 24 | + // iterate through the chat and populate the chatContainer div with divs containing the class youChatInstance and interviewerChatInstance depending on the role, the text content of the div should be the content |
| 25 | + const chatContainer = document.getElementById("chatContainer"); |
| 26 | + console.log("Popup chat: ", request.data.chat) |
| 27 | + // only add a new div if the ticId is not already in the chatContainer |
| 28 | + request.data.chat.forEach(chatInstance => { |
| 29 | + const chatDiv = document.createElement("div"); |
| 30 | + chatDiv.innerText = chatInstance.content; |
| 31 | + if (chatInstance.role.toUpperCase() === "YOU") { |
| 32 | + chatDiv.classList.add("youChatInstance"); |
| 33 | + } else { |
| 34 | + chatDiv.classList.add("interviewerChatInstance"); |
| 35 | + } |
| 36 | + // add an attribute ticId with the value of the ticId |
| 37 | + chatDiv.setAttribute("ticId", chatInstance.ticId); |
| 38 | + console.log("Chat div: ", chatDiv) |
| 39 | + if (document.querySelector(`[ticId="${chatInstance.ticId}"]`) === null) { |
| 40 | + chatContainer.appendChild(chatDiv); |
| 41 | + } |
| 42 | + } |
| 43 | + ); |
| 44 | + |
| 45 | + } |
22 | 46 | if (request.type === "SUGGESTED_CODE") {
|
23 | 47 | // get element of id "code"
|
24 | 48 | statusSpan.innerText = "Idle";
|
|
0 commit comments