-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented basic popup and emotion thermometer
- Loading branch information
1 parent
a36ff8e
commit b82eae4
Showing
12 changed files
with
2,964 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
body { | ||
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif; | ||
font-size: 100%; | ||
padding: 0 10px 0 10px; | ||
width: 300px; | ||
} | ||
h3, | ||
h4, | ||
h5 { | ||
text-align: center; | ||
} | ||
section#keepcalm-content { | ||
display: flex; | ||
} | ||
section#keepcalm-content .green { | ||
color: #419900; | ||
} | ||
section#keepcalm-content .red { | ||
color: #CF0B00; | ||
} | ||
section#keepcalm-content .gray { | ||
color: #ACACAC; | ||
} | ||
section#keepcalm-content .thermometer { | ||
display: block; | ||
padding: 5px; | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
} | ||
section#keepcalm-content .thermometer i { | ||
font-size: 55pt; | ||
} | ||
section#keepcalm-content .info { | ||
display: block; | ||
padding: 5px; | ||
} | ||
section#keepcalm-content .info h4 { | ||
font-weight: 200; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//Variables | ||
@theme-green: #419900; | ||
@theme-gray: #ACACAC; | ||
@theme-red: #CF0B00; | ||
|
||
body { | ||
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif; | ||
font-size: 100%; | ||
padding: 0 10px 0 10px; | ||
width: 300px; | ||
} | ||
|
||
h3, h4, h5 { | ||
text-align: center; | ||
} | ||
|
||
section#keepcalm-content { | ||
display: flex; | ||
.green { | ||
color: @theme-green; | ||
} | ||
|
||
.red { | ||
color: @theme-red; | ||
} | ||
|
||
.gray { | ||
color: @theme-gray; | ||
} | ||
|
||
.thermometer { | ||
display: block; | ||
padding: 5px; | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
i { | ||
font-size: 55pt; | ||
} | ||
} | ||
|
||
.info { | ||
display: block; | ||
padding: 5px; | ||
|
||
h4 { | ||
font-weight: 200; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,52 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
let imageResult = document.getElementById('image-result'); | ||
let img = document.createElement("img"); | ||
img.setAttribute("src", "http://lorempixel.com/400/400/cats/"); | ||
// Explicitly set the width/height to minimize the number of reflows. For | ||
// a single image, this does not matter, but if you're going to embed | ||
// multiple external images in your page, then the absence of width/height | ||
// attributes causes the popup to resize multiple times. | ||
imageResult.appendChild(img); | ||
//gets the atual results of classifications | ||
chrome.runtime.sendMessage({'method': 'getResults'}, function (response) { | ||
console.log(response); | ||
|
||
let keepcalmSection = document.getElementById("keepcalm-content"), | ||
statusIcon = keepcalmSection.querySelector(".thermometer i"), | ||
infoContainer = keepcalmSection.querySelector(".info"); | ||
|
||
console.log(infoContainer); | ||
|
||
if (response) { | ||
let titleElement = document.createElement('div'); | ||
titleElement.innerHTML = `O texto <b> "${response.text}"</b> foi classificado como:"`; | ||
let resultComponent = document.createElement('h3'); | ||
resultComponent.innerText = response.effectiveResult; | ||
|
||
if (response.effectiveResult === "Agressivo") { | ||
clearClassList(statusIcon); | ||
statusIcon.classList.add("fas", "fa-thermometer-full", "red"); | ||
} | ||
else if (response.effectiveResult === "Não Agressivo") { | ||
clearClassList(statusIcon); | ||
statusIcon.classList.add("fas", "fa-thermometer-empty", "green"); | ||
} | ||
|
||
infoContainer.innerHTML = ""; | ||
infoContainer.appendChild(titleElement); | ||
infoContainer.appendChild(resultComponent); | ||
|
||
} | ||
else { | ||
clearClassList(statusIcon); | ||
statusIcon.classList.add("fas", "fa-thermometer-empty", "gray"); | ||
|
||
let titleElement = document.createElement('h4'); | ||
titleElement.innerText = "KeepCalm é um detector de conteúdo agressivo que monitora o que você digita na internet."; | ||
|
||
infoContainer.innerHTML = ""; | ||
infoContainer.appendChild(titleElement) | ||
|
||
} | ||
}); | ||
}); | ||
|
||
/** | ||
* Clear all classes of a Html Element | ||
* @param element to be cleared | ||
*/ | ||
function clearClassList(element) { | ||
element.className = ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.