aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/ScriptManager.ts2
-rw-r--r--src/client/util/Scripting.ts42
-rw-r--r--src/client/views/nodes/ScriptingBox.tsx46
3 files changed, 44 insertions, 46 deletions
diff --git a/src/client/util/ScriptManager.ts b/src/client/util/ScriptManager.ts
index d9a5f21ed..65869d2ad 100644
--- a/src/client/util/ScriptManager.ts
+++ b/src/client/util/ScriptManager.ts
@@ -77,7 +77,7 @@ scriptList.forEach((scriptDoc: Doc) => {
});
if (parameters === "(") {
- Scripting.addGlobal(f, StrCast(scriptDoc.description), StrCast(scriptDoc.funcName));
+ Scripting.addGlobal(f, StrCast(scriptDoc.description), "", StrCast(scriptDoc.funcName));
} else {
Scripting.addGlobal(f, StrCast(scriptDoc.description), parameters, StrCast(scriptDoc.funcName));
}
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index 16012eb5a..237027c03 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -50,36 +50,36 @@ export namespace Scripting {
export function addGlobal(global: { name: string }): void;
export function addGlobal(name: string, global: any): void;
- export function addGlobal(global: { name: string }, decription?: string, params?: any): void;
- export function addGlobal(global: { name: string }, decription?: string, params?: any, name?: any): void;
+ export function addGlobal(global: { name: string }, decription?: string, params?: string): void;
+ export function addGlobal(global: { name: string }, decription?: string, params?: string, name?: string): void;
- export function addGlobal(nameOrGlobal: any, global?: any, params?: any, name?: any) {
+ export function addGlobal(first: any, second?: any, third?: string, fourth?: string) {
let n: any;
let obj: any;
- if (global !== undefined) {
- if (typeof nameOrGlobal === "string") {
- n = nameOrGlobal;
- obj = global;
+ if (second !== undefined) {
+ if (typeof first === "string") {
+ n = first;
+ obj = second;
} else {
- obj = [nameOrGlobal];
- obj.push(global);
- if (params) {
- if (params.indexOf("(") > 0) {
- obj.push(params);
- } else {
- n = params;
- }
+ obj = [first];
+ obj.push(second);
+ if (third) {
+ //if (third.indexOf("(") > 0) {
+ obj.push(third);
+ //} else {
+ //n = third;
+ //}
}
- if (name) {
- n = name;
+ if (fourth) {
+ n = fourth;
} else {
- n = nameOrGlobal.name;
+ n = first.name;
}
}
- } else if (nameOrGlobal && typeof nameOrGlobal.name === "string") {
- n = nameOrGlobal.name;
- obj = nameOrGlobal;
+ } else if (first && typeof first.name === "string") {
+ n = first.name;
+ obj = first;
} else {
throw new Error("Must either register an object with a name, or give a name and an object");
}
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx
index 07c156742..e07704c19 100644
--- a/src/client/views/nodes/ScriptingBox.tsx
+++ b/src/client/views/nodes/ScriptingBox.tsx
@@ -60,15 +60,18 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@observable private _scriptSuggestedParams: any = "";
@observable private _scriptParamsText: any = "";
- @observable private _functionName: any = "";
- @observable private _functionDescription: any = "";
-
// vars included in fields that store parameters types and names and the script itself
@computed({ keepAlive: true }) get paramsNames() { return this.compileParams.map(p => p.split(":")[0].trim()); }
@computed({ keepAlive: true }) get paramsTypes() { return this.compileParams.map(p => p.split(":")[1].trim()); }
@computed({ keepAlive: true }) get rawScript() { return StrCast(this.dataDoc[this.props.fieldKey + "-rawScript"], ""); }
+ @computed({ keepAlive: true }) get functionName() { return StrCast(this.dataDoc[this.props.fieldKey + "-functionName"], ""); }
+ @computed({ keepAlive: true }) get functionDescription() { return StrCast(this.dataDoc[this.props.fieldKey + "-functionDescription"], ""); }
@computed({ keepAlive: true }) get compileParams() { return Cast(this.dataDoc[this.props.fieldKey + "-params"], listSpec("string"), []); }
+
set rawScript(value) { this.dataDoc[this.props.fieldKey + "-rawScript"] = value; }
+ set functionName(value) { this.dataDoc[this.props.fieldKey + "-functionName"] = value; }
+ set functionDescription(value) { this.dataDoc[this.props.fieldKey + "-functionDescription"] = value; }
+
set compileParams(value) { this.dataDoc[this.props.fieldKey + "-params"] = new List<string>(value); }
// WORK ON THIS
@@ -236,24 +239,20 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@action
onCreate = () => {
- if (this._functionName.length === 0) {
+ if (this.functionName.length === 0) {
this._errorMessage = "Must enter a function name";
return false;
}
- if (this._functionName.indexOf(" ") > 0) {
+ if (this.functionName.indexOf(" ") > 0) {
this._errorMessage = "Name can not include spaces";
return false;
}
- this.dataDoc.funcName = this._functionName;
- this.dataDoc.descripition = this._functionDescription;
+ this.dataDoc.funcName = this.functionName;
+ this.dataDoc.descripition = this.functionDescription;
ScriptingBox.DeleteScript?.(this.dataDoc);
-
- this.dataDoc.funcName = "testingTitle";
- this.dataDoc.descripition = "description test";
-
ScriptingBox.AddScript?.(this.dataDoc);
console.log("created");
@@ -302,32 +301,31 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
!existingOptions && ContextMenu.Instance.addItem({ description: "Options...", subitems: options, icon: "hand-point-right" });
}
- @action
renderFunctionInputs() {
-
const descriptionInput =
<textarea
- onChange={e => this._functionDescription = e.target.value}
+ className="scriptingBox-textarea"
+ onChange={e => this.functionDescription = e.target.value}
placeholder="enter description here"
- value={this._functionDescription}
- style={{ height: "40%", width: "100%" }}
+ value={this.functionDescription}
+ style={{ maxWidth: "100%", height: "40%", width: "100%", resize: "none" }}
/>;
-
const nameInput =
<textarea
- onChange={e => this._functionName = e.target.value}
+ className="scriptingBox-textarea"
+ onChange={e => this.functionName = e.target.value}
placeholder="enter name here"
- value={this._functionName}
- style={{ height: "40%", width: "100%" }}
+ value={this.functionName}
+ style={{ maxWidth: "100%", height: "40%", width: "100%", resize: "none" }}
/>;
return <div className="scriptingBox-inputDiv" onPointerDown={e => this.props.isSelected() && e.stopPropagation()} >
<div className="scriptingBox-wrapper">
<div className="container">
- <div className="child" style={{ textAlign: "center", display: "inline-block" }}> Enter a name for this function: </div>
- <div className="child">{nameInput}</div>
- <div className="child" style={{ textAlign: "center", display: "inline-block" }}> Enter a description of this function: </div>
- <div className="child">{descriptionInput}</div>
+ <div style={{ textAlign: "center", display: "inline-block" }}> Enter a name for this function: </div>
+ <div> {nameInput}</div>
+ <div style={{ textAlign: "center", display: "inline-block" }}> Enter a description of this function: </div>
+ <div>{descriptionInput}</div>
</div>
</div>
{this.renderErrorMessage()}