Added multiple file import functionality and changed discard setup.

This commit is contained in:
Maxim Stewart 2018-11-23 15:08:24 -06:00
parent 016984eda9
commit 0a9b1630d9
5 changed files with 26 additions and 17 deletions

View File

@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or
# Download
https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/
# Version: 0.0.3
Set tabs to auto discard but the currently active one.
# Version: 0.0.4
Added multiple file import functionality and changed discard setup.
# Images
![1 Default interface with no sessions. ](images/pic1.png)

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": " Easy Session Manager",
"version": "0.0.3",
"version": "0.0.4",
"description": " Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.",
"applications": {

View File

@ -22,7 +22,7 @@ body, html {
<div class="container" name="import">
<h1 id="lableTag">Select File</h1>
<input id="inputId" type="file" accept="application/json"/>
<input id="inputId" type="file" enctype='multipart/form-data' multiple accept="application/json"/>
</div>

View File

@ -1,16 +1,26 @@
document.getElementById("inputId").onchange = (e) => {
var reader = new FileReader();
reader.onloadend = function(obj){
let processor = (obj, name) => {
let data = obj.target.result;
let enteryName = prompt("What is this session's name?", "" + new Date().toLocaleString()
.split(',')[0]);
let enteryName = prompt("What is this session's name?", "" + name);
console.log(name);
if (enteryName) {
browser.storage.local.set({[enteryName]: data});
}
};
if (e.target.files[0].type == "application/json")
reader.readAsText(e.target.files[0], {encoding: "string"});
document.getElementById("inputId").onchange = (e) => {
let size = e.target.files.length;
let fileArry = e.target.files;
for (var i = 0; i < size; i++) {
let reader = new FileReader();
let name = fileArry[i].name;
name = name.split(".")[0];
reader.onloadend = (obj) => { processor(obj, name); };
if (fileArry[i].type == "application/json")
reader.readAsText(fileArry[i], {encoding: "string"});
}
};

View File

@ -113,7 +113,6 @@ const loadSession = (id = null) => {
}
windowSys.create({ url: urls });
browser.tabs.discard(urls);
});
// Finalize clear out windows