Skip to content

Commit

Permalink
Merge pull request #73 from LEDfan/lint_fix
Browse files Browse the repository at this point in the history
Small fixes to please the linter.
  • Loading branch information
LEDfan authored Sep 9, 2017
2 parents eaaf94e + 8cd8e1e commit d258f75
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dialog/dialog_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ window.addEventListener('DOMContentLoaded', function () {
const spl = e.dataset.i18n.split('.');
e.setAttribute(spl[0], browser.i18n.getMessage(spl[1]));
} else { // Replace the content of the element
e.innerHTML = browser.i18n.getMessage(e.dataset.i18n);
e.innerText = browser.i18n.getMessage(e.dataset.i18n);
}
}
});
Expand Down
35 changes: 20 additions & 15 deletions dialog/select_multiple_passwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,41 @@
* along with Keywi. If not, see <http://www.gnu.org/licenses/>.
*/

const generateButtonRow = function (index, name, login) {
return `
<div class="password-container">
<button data-index="${index}" class="password-choose-btn">${login} (${name})</button>
</div>
</div>
`;
const generateButtonRow = function (name, login) {
const div = document.createElement('div');
div.classList.add('password-container');

const button = document.createElement('button');
button.classList.add('password-choose-btn');
button.innerText = `${login} (${name})`;

div.appendChild(button);

return div;
};

window.addEventListener('DOMContentLoaded', function () {
browser.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.type === 'select_mul_pass_data') {
const length = request.data.possibleCredentials.length;
let html = '';
const passwordsEl = document.getElementById('passwords');

for (let i = 0; i < length; i++) {
html += generateButtonRow(i, request.data.possibleCredentials[i].Name, request.data.possibleCredentials[i].Login);
// clear previous entries
while (passwordsEl.hasChildNodes()) {
passwordsEl.removeChild(passwordsEl.lastChild);
}

document.getElementById('passwords').innerHTML = html;
const els = document.getElementsByClassName('password-choose-btn');

for (const el of els) {
for (let i = 0; i < length; i++) {
const el = generateButtonRow(request.data.possibleCredentials[i].Name, request.data.possibleCredentials[i].Login);
el.addEventListener('click', function () {
browser.runtime.sendMessage({
'type': 'select_mul_pass_user_input',
'data': {'selected': this.dataset.index}
'data': {'selected': i}
});
}, false);
passwordsEl.appendChild(el);
}

}
});
});
Expand Down
2 changes: 1 addition & 1 deletion options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ window.addEventListener('DOMContentLoaded', function () {
const spl = e.dataset.i18n.split('.');
e.setAttribute(spl[0], browser.i18n.getMessage(spl[1]));
} else { // Replace the content of the element
e.innerHTML = browser.i18n.getMessage(e.dataset.i18n);
e.innerText = browser.i18n.getMessage(e.dataset.i18n);
}
}
const inputs = document.querySelectorAll('#options input');
Expand Down

0 comments on commit d258f75

Please sign in to comment.