Added multiple file import functionality and changed discard setup.

pull/10/head
Maxim Stewart 5 years ago
parent 016984eda9
commit 0a9b1630d9

@ -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)

@ -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": {

@ -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>

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

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

Loading…
Cancel
Save