Merge pull request #101 from kartik95/history-deleter-panel-bug

Big fix for WebExtensions Panel auto-resize problem
This commit is contained in:
wbamberg
2016-10-13 10:29:00 -07:00
committed by GitHub
3 changed files with 47 additions and 5 deletions

View File

@@ -1,4 +1,32 @@
html, body {
margin: 0.2em;
width: 350px;
margin: 0.3em;
width: auto;
min-width: 250px;
max-width: 500px;
background-color: #f8f8f8;
}
div {
margin-left: 0.5em;
margin-right: 0.5em;
border-bottom: 1px solid grey;
}
#history-title {
font-weight: bold;
margin-left: 0.5em;
margin-right: 0.5em;
}
#history {
display: block;
word-wrap: break-word;
margin: 0.5em;
text-decoration: none;
}
#clear {
text-decoration: none;
margin-left: 0.5em;
margin-right: 0.5em;
}

View File

@@ -7,9 +7,11 @@
</head>
<body>
<p>History for this domain (limited to 5 results):</p>
<p id="history-title">History for <span class="domain"></span> (Last 5 results) :</p>
<div></div>
<p id="history"></p>
<p><a href="#" id="clear">Clear history for this domain</a></p>
<div></div>
<p><a href="#" id="clear">Clear history for <span class="domain"></span></a></p>
<script src="history.js"></script>
</body>

View File

@@ -2,9 +2,17 @@
function get_hostname(url) {
var a = document.createElement('a');
a.href = url;
set_domain(a.hostname);
return a.hostname;
}
function set_domain(domain) {
spans = document.getElementsByClassName('domain');
[].slice.call(spans).forEach(function(span) {
span.textContent = domain;
});
}
function no_history(hostname) {
document.getElementById('history').innerHTML = `No history for ${hostname}.`;
}
@@ -27,8 +35,12 @@ chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for (var k in results) {
var history = results[k];
var li = document.createElement('p');
var a = document.createElement('a');
var url = document.createTextNode(history.url);
li.appendChild(url);
a.href = history.url;
a.target = '_blank';
a.appendChild(url);
li.appendChild(a);
list.appendChild(li);
}
}