Newer
Older
:: Rules Assistant Options [script]
// rewrite of the rules assistant options page in javascript
// uses an object-oriented widget pattern
// wrapped in a closure so as not to polute the global namespace
// the widgets are generic enough to be reusable; if similar user interfaces are ported to JS, we could move the classes to the global scope
window.rulesAssistantOptions = (function() {
"use strict"
let V
let r = ""
function rulesAssistantOptions() {
V = State.variables
V.nextButton = "Back to Main"
V.nextLink = "Main"
V.returnTo = "Main"
V.showEncyclopedia = 1
V.encyclopedia = "Personal Assistant"
let tmp = document.createElement("div")
tmp.classList.add("passage")
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const root = new Root(tmp)
}
function newRule(root) {
const id = V.defaultRules.length === 0? 1: V.defaultRules[V.defaultRules.length-1].ID + 1
v.defaultRules.push({
ID: id,
name: `Rule ${id}`,
condition: {
function: false,
data: {},
excludeSpecialSlaves: false,
assignment: [],
excludeAssignment: [],
selectedSlaves: [],
excludedSlaves: [],
facility: [],
excludeFacility: [],
},
set: {
releaseRules: "no default setting",
clitSetting: "no default setting",
clitSettingXY: "no default setting",
clitSettingXX: "no default setting",
clitSettingEnergy: "no default setting",
speechRules: "no default setting",
clothes: "no default setting",
collar: "no default setting",
shoes: "no default setting",
virginAccessory: "no default setting",
aVirginAccessory: "no default setting",
vaginalAccessory: "no default setting",
aVirginDickAccessory: "no default setting",
dickAccessory: "no default setting",
bellyAccessory: "no default setting",
aVirginButtplug: "no default setting",
buttplug: "no default setting",
eyeColor: "no default setting",
makeup: "no default setting",
nails: "no default setting",
hColor: "no default setting",
hLength: "no default setting",
hStyle: "no default setting",
pubicHColor: "no default setting",
pubicHStyle: "no default setting",
nipplesPiercing: "no default setting",
areolaePiercing: "no default setting",
clitPiercing: "no default setting",
vaginaLube: "no default setting",
vaginaPiercing: "no default setting",
dickPiercing: "no default setting",
anusPiercing: "no default setting",
lipsPiercing: "no default setting",
tonguePiercing: "no default setting",
earPiercing: "no default setting",
nosePiercing: "no default setting",
eyebrowPiercing: "no default setting",
navelPiercing: "no default setting",
corsetPiercing: "no default setting",
boobsTat: "no default setting",
buttTat: "no default setting",
vaginaTat: "no default setting",
dickTat: "no default setting",
lipsTat: "no default setting",
anusTat: "no default setting",
shouldersTat: "no default setting",
armsTat: "no default setting",
legsTat: "no default setting",
backTat: "no default setting",
stampTat: "no default setting",
curatives: "no default setting",
livingRules: "no default setting",
relationshipRules: "no default setting",
standardPunishment: "no default setting",
standardReward: "no default setting",
diet: "no default setting",
dietCum: "no default setting",
dietMilk: "no default setting",
muscles: "no default setting",
XY: "no default setting",
XX: "no default setting",
gelding: "no default setting",
preg: "no default setting",
growth_boobs: "no default setting",
growth_butt: "no default setting",
growth_lips: "no default setting",
growth_dick: "no default setting",
growth_balls: "no default setting",
aphrodisiacs: "no default setting",
autoSurgery: 0,
autoBrand: 0,
pornFameSpending: "no default setting",
dietGrowthSupport: 0,
eyewear: "no default setting",
setAssignment: "no default setting",
facilityRemove: false,
removalAssignment: "rest",
surgery_eyes: "no default setting",
surgery_lactation: "no default setting",
surgery_prostate: "no default setting",
surgery_cosmetic: "no default setting",
surgery_accent: "no default setting",
surgery_shoulders: "no default setting",
surgery_shouldersImplant: "no default setting",
surgery_boobs: "no default setting",
surgery_hips: "no default setting",
surgery_hipsImplant: "no default setting",
surgery_butt: "no default setting",
surgery_faceShape: "no default setting",
surgery_lips: "no default setting",
surgery_holes: "not default setting",
underArmHColor: "no default setting",
underArmHStyle: "no default setting",
drug: "no default setting",
eyes: "no default setting",
pregSpeed: "no default setting",
bellyImplantVol: -1,
}
})
reload(root)
}
function reload(root) {
root.element.remove()
rulesAssistantOptions()
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
}
// the Element class wraps around a DOM element and adds extra functionality
// this is safer than extending DOM objects directly
// it also turns DOM manipulation into an implementation detail
class Element {
constructor(...args) {
this.parent = null
this.element = this.render(...args)
this.children = []
}
appendChild(child) {
child.parent = this
this.children.push(child)
this.element.appendChild(child.element)
}
// return the first argument to simplify creation of basic container items
render(...args) {
return args[0]
}
}
// list of clickable elements
// has a short explanation (the prefix) and a value display
// value display can optionally be an editable text input field
// it can be "bound" to a variable by setting its "onchange" method
class List extends Element {
constructor(prefix, textinput=false) {
super(prefix, textarea)
this.selectedItem = null
this.value = this.element.querySelector(".rajs-value")
}
render(prefix, textinput) {
const elem = document.createElement("div")
const label = document.createElement("span")
label.innerHTML = prefix
let value
if (textinput) {
value = document.createElement("input")
value.classList.add("rajs-value")
// call the variable binding when the input field is no longer being edited, and when the enter key is pressed
value.onfocusout = () => { this.propagateChange() }
value.onkeypress = (e) => { if (e.keyCode === 13) this.propagateChange() }
} else {
value = document.createElement("strong")
}
value.setAttribute("type", "text")
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
elem.appendChild(value)
elem.classList.add("rajs-list")
return elem
}
selectItem(item) {
if (this.selectedItem) this.selectedItem.deselect()
this.selectedItem = item
setValue(item.setValue)
this.propagateChange()
}
setValue(what) {
if (this.value.tagName === "input")
this.value.value = what
else
this.value.innerHTML = what
}
getValue(what) {
return (this.value.tagName === "input" ? this.parse(this.value.value) : this.value.innerHTML)
}
// customisable input field parser / sanity checker
parse(what) { return what }
propagateChange() {
if (this.onchange instanceof Function)
this.onchange(this.getValue())
}
}
// a clickable item of a list
class ListItem extends Element {
constructor(displayvalue, setvalue) {
super(displayvalue)
this.setvalue = setvalue
this.selected = false
}
render(displayvalue) {
const elem = document.createElement("span")
elem.classList.add("rajs-listitem")
elem.innerHTML = displayvalue
elem.onclick = () => { return this.select() }
return elem
}
select() {
if (this.selected) return false
this.parent.selectItem(this)
this.elem.classList.add("selected")
this.selected = true
}
deselect() {
this.elem.classList.remove("selected")
this.selected = false
}
}
// a way to organise lists with too many elements in subsections
// children are bound to the master list
class ListSubSection extends Element {
render(label) {
elem.innerText = label + ":"
return elem
}
appendChild(child) {
super.appendChild(child)
child.parent = this.parent
}
}
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
class Options extends Element {
constructor(elements=[]) {
elements.forEach(element => { this.appendChild(element) })
}
render() {
const elem = document.createElement("div")
elem.classList.add("rajs-list")
return elem
}
}
class OptionsItem extends Element {
constructor(label, onclick) {
super(label)
this.onclick = onclick
}
render(label, onclick) {
const elem = document.createElement("span")
elem.classList.add("rajs-listitem")
elem.innerHTML = label
elem.onclick = () => { return this.onclick() }
return elem
}
}
class NewRuleField extends Element {
constructor(root) {
super()
this.root = root
}
render() {
const container = document.createElement("div")
const textarea = document.createElmenet("textarea")
textarea.placeholder = "Paste your rule here"
container.appendChild(textarea)
this.textarea = textarea
const button = document.createElement("button")
button.name = "Load"
button.onclick = () => { this.loadNewRule() }
container.appendChild(button)
return container
}
loadNewRule() {
const text = this.textarea.value
try {
const rule = JSON.parse(text)
rule.ID = V.defaultRules.length === 0? rule.ID: V.defaultRules[V.defaultRules.length-1].ID + 1
reload(this.root)
} catch (e) {
alert(e)
}
}
}
class Root extends Element {
render(element) {
const greeting = document.createElement("p")
greeting.innerHTML = `<em>${properTitle()}, I will review your slaves and make changes that will have a beneficial effect. Apologies, ${properTitle()}, but this function is... not fully complete. It may have some serious limitations. Please use the 'no default setting' option to identify areas I should not address.</em>`
element.appendChild(greeting)
if(V.defaultRules.length === 0) {
const paragraph = document.createElement("p")
paragraph.innerHTML = "<strong>No rules</strong>"
element.appendChild(paragraph)
element.appendChild(new NoRules(root))
return element
}
}
}
class NoRules extends Options {
constructor(root) {
super()
this.root = root
const newrule = new OptionsItem("Add a new rule", () => { newRule(this.root) })
this.appendChild(newrule)
const importrule = new OptionsItem("Import a rule", () => { this.root.appendChild(new NewRuleField()) })
this.appendChild(importrule)
}
}