This commit is contained in:
Bnyro 2022-08-02 10:14:03 +02:00
parent 7899b4aea4
commit 5b7f99c9e0
3 changed files with 11 additions and 25 deletions

View File

@ -143,15 +143,6 @@ export default {
});
this.download(data, this.playlist.name + ".txt");
},
download(text, filename) {
var element = document.createElement("a");
element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text));
element.setAttribute("download", filename);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
},
},
};
</script>

View File

@ -97,14 +97,7 @@ export default {
subscriptions: subscriptions,
});
var file = new Blob([json], { type: "application/json" });
const elem = document.createElement("a");
elem.href = URL.createObjectURL(file);
elem.download = "subscriptions.json";
elem.click();
elem.remove();
this.download(json, "subscriptions.json", "application/json");
},
},
};

View File

@ -220,14 +220,16 @@ const mixin = {
const localSubscriptions = this.getLocalSubscriptions();
return localSubscriptions != null ? localSubscriptions.join(",") : "";
},
download(text, filename) {
var element = document.createElement("a");
element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text));
element.setAttribute("download", filename);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
/* generate a temporary file and ask the user to download it */
download(text, filename, type) {
var file = new Blob([text], { type: type });
const elem = document.createElement("a");
elem.href = URL.createObjectURL(file);
elem.download = filename;
elem.click();
elem.remove();
},
},
computed: {