Skip to content
Snippets Groups Projects
Commit c2d816c8 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'replace' into 'pregmod-master'

use App.UI.replace()

See merge request pregmodfan/fc-pregmod!5959
parents e87053bc 7fdfa542
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ App.Reminders.add = function(message, week, category = "manual") {
* @param {string} [category]
* @return {string}
*/
App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category = "all"} = {}) {
App.Reminders.list = function list({maxFuture = Number.POSITIVE_INFINITY, category = "all"} = {}) {
if (V.reminders.length === 0) {
return "";
}
......@@ -32,18 +32,25 @@ App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category =
*/
let includedCategory = category === "all" ? () => true : c => c === category;
let replace = () => App.UI.replace("#reminder", list({maxFuture: maxFuture, category: category}));
/**
* @param {{}} entry
*/
let clearEntry = entry => { V.reminders.splice(V.reminders.indexOf(entry), 1); };
function clearEntry(entry) {
V.reminders.splice(V.reminders.indexOf(entry), 1);
replace();
}
// We only want to remove visible entries
function clearOverdue() {
V.reminders = V.reminders.filter(e => e.week >= V.week && (e.week > V.week + maxFuture || !includedCategory(e.category)));
replace();
}
function clearAll() {
V.reminders = V.reminders.filter(e => e.week > V.week + maxFuture || !includedCategory(e.category));
replace();
}
let r = "";
......@@ -68,17 +75,17 @@ App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category =
}
week = `in ${numberWithPluralOne(entry.week - V.week, 'week')}`;
}
r += `<div>${entry.message} <span class="${classes}">${week}</span>. ${App.UI.link("Clear", clearEntry, [entry], passage())}</div>`;
r += `<div>${entry.message} <span class="${classes}">${week}</span>. ${App.UI.link("Clear", clearEntry, [entry])}</div>`;
});
if (overdue > 0) {
r += `<div>${App.UI.link("Clear Overdue", clearOverdue, [], passage())}</div>`;
r += `<div>${App.UI.link("Clear Overdue", clearOverdue, [])}</div>`;
}
if (any) {
r += `<div>${App.UI.link("Clear All", clearAll, [], passage())}</div>`;
r += `<div>${App.UI.link("Clear All", clearAll, [])}</div>`;
}
return r;
return `<span id="reminder">${r}</span>`;
};
App.Reminders.addField = function() {
......
......@@ -47,37 +47,36 @@ App.Desc.limbChange = function() {
*/
function amputate(slave, oldLimbs, returnTo) {
const {his} = getPronouns(slave);
/**
* @param {number} id
*/
function install(id) {
slave.PLimb = id;
surgeryDamage(slave, 10);
App.UI.replace("#amputate", App.Desc.limbChange().prosthetic(slave, oldLimbs, returnTo));
}
function noInstall() {
App.UI.replace("#amputate", App.Desc.limbChange().reaction(slave, oldLimbs, returnTo));
}
let implant = false;
let r = "";
if (slave.PLimb < 1 && isProstheticAvailable(slave, "interfaceP1")) {
implant = true;
r += `<<link "Install basic interface">>` +
`<<set $activeSlave.PLimb = 1>>
<<run surgeryDamage($activeSlave, 10)>>` +
`<<replace "#amputate">><<= App.Desc.limbChange().prosthetic($activeSlave, ${JSON.stringify(oldLimbs)}, "${returnTo}")>><</replace>>` +
`<</link>>`;
r += `<div>${App.UI.link("Install basic interface", install, [1])}</div>`;
}
if (slave.PLimb < 2 && isProstheticAvailable(slave, "interfaceP2")) {
if (implant) {
r += "<br>";
}
implant = true;
r += `<<link "Install advanced interface">>` +
`<<set $activeSlave.PLimb = 2>>
<<run surgeryDamage($activeSlave, 10)>>` +
`<<replace "#amputate">><<= App.Desc.limbChange().prosthetic($activeSlave, ${JSON.stringify(oldLimbs)}, "${returnTo}")>><</replace>>` +
`<</link>>`;
r += `<div>${App.UI.link("Install advanced interface", install, [2])}</div>`;
}
if (implant) {
return "<span id='amputate'>" +
`<div>Since you already have a prosthetic interface prepared for this slave, you can install it during the operation. The procedure will put additional strain on ${his} health but less so than if you were to perform the procedures separately.</div>` +
`${r}
<<link "Do not install">>
<<replace "#amputate">><<= App.Desc.limbChange().reaction($activeSlave, ${JSON.stringify(oldLimbs)}, "${returnTo}")>><</replace>>
<</link>>
</span>`;
`${r}<div>${App.UI.link("Do not install", noInstall())}</div></span>`;
}
if (slave.PLimb > 0) {
......@@ -180,9 +179,7 @@ App.Desc.limbChange = function() {
}
}
r = `<<set _newState = [${state}]>><div class='limb-selector'>${r}</div>${apply()}`;
return r;
return `<<set _newState = [${state}]>><div class='limb-selector'>${r}</div>${apply()}`;
function apply() {
let s;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment