Skip to content

Commit 11ab754

Browse files
committed
add campaign name to popup
1 parent e422ed1 commit 11ab754

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

src/popup/popup.css

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
text-align: center;
33
width: 20em;
44
background-color: #fff;
5+
font-family: "IBM Plex Mono", "Courier new", Courier, monospace;
56
}
67

78
.modal-content {
@@ -18,6 +19,10 @@
1819
letter-spacing: -0.03em;
1920
}
2021

22+
.campaigns {
23+
margin-bottom: 20px;
24+
}
25+
2126
form{
2227
margin: 0;
2328
}

src/popup/popup.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<html>
22
<head>
3+
<meta charset="UTF-8">
34
<title>Picket</title>
45
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
56
<link href='./normalize.css' rel='stylesheet'>
@@ -16,7 +17,8 @@
1617
<div class='modal'>
1718
<div class='modal-content'>
1819
<div class="logo">netizens</div>
19-
<form id='policyFileForm' onsubmit="submitForm()">
20+
<div id="campaigns"></div>
21+
<form id="policyFileForm" onsubmit="submitForm()">
2022
<input id='policyFile' name='policyFile' type='text' autocomplete="off" placeholder="Paste campaign policy here..." required>
2123
<button type='submit' value='Update policy'>Join campaign</button>
2224
</form>

src/popup/popup.js

+29-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
import loadPolicy from '../loadPolicy'
22

3+
const showSuccessMessage = () => {
4+
var animateIn = document.getElementById("notification")
5+
animateIn.className = "show"
6+
setTimeout(function(){
7+
animateIn.className = animateIn.className.replace("show", "")
8+
}, 3000)
9+
}
10+
11+
const showJoinedCampaigns = () => {
12+
chrome.storage.sync.get(['policy'], (value) => {
13+
if (value.policy) {
14+
const campaignsEl = document.getElementById('campaigns')
15+
campaignsEl.innerText = `Your campaign: \n${value.policy.name}`
16+
campaignsEl.className = "campaigns"
17+
}
18+
})
19+
}
20+
21+
const submitForm = (ev) => {
22+
ev.preventDefault()
23+
const policyFileUrl = new FormData(policyFileForm).get('policyFile')
24+
loadPolicy(policyFileUrl)
25+
.then(showSuccessMessage)
26+
.then(showJoinedCampaigns)
27+
}
28+
329
document.addEventListener('DOMContentLoaded', () => {
430
const policyFileForm = document.getElementById('policyFileForm')
5-
policyFileForm.addEventListener('submit', (ev) => {
6-
ev.preventDefault();
7-
const policyFileUrl = new FormData(policyFileForm).get('policyFile')
8-
loadPolicy(policyFileUrl)
9-
.then(e => {
10-
var animateIn = document.getElementById("notification");
11-
animateIn.className = "show";
12-
setTimeout(function(){
13-
animateIn.className = animateIn.className.replace("show", "");
14-
}, 3000);
15-
e.preventDefault();
16-
})
17-
})
31+
32+
policyFileForm.addEventListener('submit', submitForm)
33+
showJoinedCampaigns()
1834
})

0 commit comments

Comments
 (0)