Обновил оформление

This commit is contained in:
2021-06-26 17:36:46 +03:00
parent f2f77f7179
commit f1430783cb
5 changed files with 62 additions and 34 deletions

View File

@@ -15,7 +15,6 @@
</label> </label>
</div> </div>
<div id="id_list"> <div id="id_list">
<div class="idToHide"></div>
</div> </div>
<script src="popup.js"></script></body> <script src="popup.js"></script></body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
body { body {
min-width: 80px; min-width: 120px;
} }
/* The switch - the box around the slider */ /* The switch - the box around the slider */
.switch { .switch {
@@ -78,21 +78,26 @@ input:checked + .slider:before {
} }
.idToHide { .idToHide {
margin: 10px; padding: 10px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
background-color: #fff;
width: 100vw;
} }
.idToHide:hover { .idToHide:hover {
background-color: white; background-color: #dcdfde;
} }
#id_list { #id_list {
background-color: #dcdfde;
color: black; color: black;
width: 100vw;
position: relative; position: relative;
margin-left: -50vw; margin-left: -50vw;
left: 50%; left: 50%;
margin-top: 10vw; margin-top: 10vw;
padding-top: 5px; }
padding-bottom: 5px;
.del_item {
cursor: pointer;
} }

View File

@@ -15,7 +15,6 @@
</label> </label>
</div> </div>
<div id="id_list"> <div id="id_list">
<div class="idToHide"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -14,7 +14,11 @@ let disableText = "Выкл";
function idBtnHTML(id) { function idBtnHTML(id) {
const element = document.createElement('div'); const element = document.createElement('div');
element.setAttribute('class', 'idToHide'); element.setAttribute('class', 'idToHide');
element.innerHTML = id; element.innerHTML = `
<a href="https://vk.com/id${id}" target="_blank" title="Перейти в профиль">🧑 id${id}</a>
<span class="del_item" title="Удалить">🗑️</span>
`;
element.id = id;
return element; return element;
} }
@@ -36,16 +40,20 @@ chrome.storage.sync.get('idsToHide', function(data) {
idList.appendChild(row); idList.appendChild(row);
} }
for (const element of idsToHideElements) { for (const element of idsToHideElements) {
element.addEventListener('click', function() { for (const child of element.childNodes) {
const index = idsToHide.indexOf(element.innerText) if (child.className === "del_item") {
child.addEventListener('click', function() {
const index = idsToHide.indexOf(element.id)
if (index > -1) { if (index > -1) {
idsToHide.splice(index, 1); idsToHide.splice(index, 1);
} }
chrome.storage.sync.set({idsToHide: idsToHide}, function() { chrome.storage.sync.set({idsToHide: idsToHide}, function() {
element.innerText = ''; element.remove();
console.log('Cleared idsToHide'); console.log('Cleared idsToHide');
}); });
}); });
}
}
}; };
}); });