I'm building a Firefox Add-On, and I need to a button in the settings page that opens a page with a list of words that the Add-On has stored. What's the best way to do this?
I've come up with this:
function ShowList() {
// We get the array from the local storage.
function createList(item){
var list = [];
// Get the stored list, if there's any.
if (item[0].list){
list = item[0].list;
}
}
function onError(e) {
alert("Error:" + e);
}
browser.storage.local.get("list").then(createList, onError);
// Once we have the list, build an HTML string with its contents
var listhtml = ['<!DOCTYPE html>',
'<html>',
' <head>',
' <meta charset="utf-8">',
' </head>',
' <body>',
' <ul>'].join("\n");
for (var w= 0; w < list.length ; w++) {
listhtml += ' <il>' + list[w][0] + '</il>\n';
}
listhtml += [' </ul>',
' </body>',
'</html>'].join("\n");
var oMyBlob = new Blob([listhtml], {type : 'text/html'}); // the blob
window.open(URL.createObjectURL(oMyBlob));
}
but HTML inside a string looks pretty awful. Any suggestions?