Skip to content
Snippets Groups Projects
Commit 45ff38cb authored by CobraCommander's avatar CobraCommander Committed by Pregmodder
Browse files

Allow exporting and sharing starting slaves as JSON

parent 7b0c62bd
Branches
Tags
1 merge request!11672Allow exporting and sharing starting slaves as JSON
...@@ -76,6 +76,51 @@ App.StartingGirls.passage = function() { ...@@ -76,6 +76,51 @@ App.StartingGirls.passage = function() {
) )
); );
class SlaveExporterImporter {
constructor(textareaElement) {
this.textareaToExportTo = textareaElement;
}
exportToTextarea(string) {
this.textareaToExportTo.value = string;
}
exportActiveSlave() {
this.textareaToExportTo.value = JSON.stringify(V.activeSlave);
}
importActiveSlave() {
const slave = JSON.parse(this.textareaToExportTo.value);
App.Update.Slave(slave);
App.Entity.Utils.SlaveDataSchemeCleanup(slave);
SlaveDatatypeCleanup(slave);
removeJob(slave, slave.assignment);
V.activeSlave = slave;
}
}
const textareaElement = App.UI.DOM.appendNewElement("textarea", el, JSON.stringify(V.activeSlave, null, 2));
const exporter = new SlaveExporterImporter(textareaElement);
linkArray.push(
App.UI.DOM.link(
"Experimental: Export this slave",
// exporter.exportActiveSlave.bind(exporter),
// If this link reloads the page, like all the other links on this line,
// then we need to set the textarea to V.activeSlave when the page loads
// (because anything it's set to by this link will be overwritten),
// and then there's no actual need for a function call at this link because the page reload will do it.
() => {},
[],
// "Export Slave"
"Starting Girls"
)
);
linkArray.push(
App.UI.DOM.link(
"Experimental: Import this slave",
exporter.importActiveSlave.bind(exporter),
[],
// "Import Slave"
"Starting Girls"
)
);
linkArray.push( linkArray.push(
App.UI.DOM.link( App.UI.DOM.link(
"Start over with a random slave", "Start over with a random slave",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment