1
+ /*
2
+ * Project Name : Visual Python
3
+ * Description : GUI-based Python code generator
4
+ * File Name : instance.js
5
+ * Author : Black Logic
6
+ * Note : Instance app
7
+ * License : GNU GPLv3 with Visual Python special exception
8
+ * Date : 2021. 10. 05
9
+ * Change Date :
10
+ */
11
+
1
12
define ( [
2
13
'require'
3
14
, 'jquery'
@@ -80,22 +91,6 @@ define([
80
91
81
92
// 옵션 속성 할당.
82
93
varPackage . setOptionProp ( funcOptProp ) ;
83
-
84
- // load metadata
85
- // if (meta != undefined && meta.options != undefined) {
86
- // try {
87
- // var leftMeta = decodeURIComponent(meta.options[0].value);
88
- // var rightMeta = decodeURIComponent(meta.options[1].value);
89
-
90
- // var leftBlocks = JSON.parse(leftMeta);
91
- // var rightBlocks = JSON.parse(rightMeta);
92
-
93
- // varPackage.state.left.board.loadBoard(leftBlocks);
94
- // varPackage.state.right.board.loadBoard(rightBlocks);
95
- // } catch {
96
- // ;
97
- // }
98
- // }
99
94
100
95
// html 설정.
101
96
varPackage . initHtml ( ) ;
@@ -129,11 +124,6 @@ define([
129
124
subsetEditor : undefined ,
130
125
codeEditor : undefined ,
131
126
stack : [ ]
132
- }
133
- , allocate : {
134
- subsetEditor : undefined ,
135
- codeEditor : undefined ,
136
- stack : [ ]
137
127
} ,
138
128
selectedBox : 'variable'
139
129
}
@@ -189,31 +179,32 @@ define([
189
179
$ ( '.vp-instance-box.variable .CodeMirror' ) . addClass ( 'selected' ) ;
190
180
191
181
// allocate - codemirror
192
- this . state . allocate . codeEditor = CodeMirror . fromTextArea ( $ ( this . wrapSelector ( '#vp_instanceAllocate' ) ) [ 0 ] , this . cmconfig ) ;
193
- this . updateValue ( 'allocate' , '' ) ;
182
+ // this.state.allocate.codeEditor = CodeMirror.fromTextArea($(this.wrapSelector('#vp_instanceAllocate'))[0], this.cmconfig);
183
+ // this.updateValue('allocate', '');
194
184
195
185
// load metadata
196
186
var variable = this . getMetadata ( 'vp_instanceVariable' ) ;
197
187
var allocate = this . getMetadata ( 'vp_instanceAllocate' ) ;
198
188
this . updateValue ( 'variable' , variable ) ;
199
- this . updateValue ( 'allocate' , allocate ) ;
189
+ $ ( this . wrapSelector ( '#vp_instanceAllocate' ) ) . val ( allocate ) ;
190
+ // this.updateValue('allocate', allocate);
200
191
201
192
// vpSubsetEditor
202
193
this . state . variable . subsetEditor = new vpSubsetEditor ( this , "vp_instanceVariable" , true ) ;
203
- this . state . allocate . subsetEditor = new vpSubsetEditor ( this , "vp_instanceAllocate" , true ) ;
194
+ // this.state.allocate.subsetEditor = new vpSubsetEditor(this, "vp_instanceAllocate", true);
204
195
this . state . variable . subsetEditor . disableButton ( ) ;
205
- this . state . allocate . subsetEditor . disableButton ( ) ;
196
+ // this.state.allocate.subsetEditor.disableButton();
206
197
207
198
this . ALLOW_SUBSET_TYPES = that . pointer . subsetEditor . getAllowSubsetTypes ( ) ;
208
199
209
200
// vpInstanceEditor
210
201
this . state . variable . insEditor = new vpInstanceEditor ( this , "vp_instanceVariable" , 'vp_variableInsEditContainer' ) ;
211
202
212
203
// vpInstanceEditor
213
- this . state . allocate . insEditor = new vpInstanceEditor ( this , "vp_instanceAllocate" , 'vp_allocateInsEditContainer' ) ;
204
+ // this.state.allocate.insEditor = new vpInstanceEditor(this, "vp_instanceAllocate", 'vp_allocateInsEditContainer');
214
205
215
206
that . state . variable . insEditor . show ( ) ;
216
- that . state . allocate . insEditor . show ( ) ;
207
+ // that.state.allocate.insEditor.show();
217
208
218
209
// variable load
219
210
that . reloadInsEditor ( ) ;
@@ -253,14 +244,10 @@ define([
253
244
$ ( that . wrapSelector ( '.CodeMirror' ) ) . removeClass ( 'selected' ) ;
254
245
if ( insEditorType == 'variable' ) {
255
246
// variable
256
- // that.state.variable.insEditor.show();
257
- // that.state.allocate.insEditor.hide();
258
247
that . pointer = that . state . variable ;
259
248
$ ( that . wrapSelector ( '.variable .CodeMirror' ) ) . addClass ( 'selected' ) ;
260
249
} else if ( insEditorType == 'allocate' ) {
261
250
// allocate
262
- // that.state.variable.insEditor.hide();
263
- // that.state.allocate.insEditor.show();
264
251
that . pointer = that . state . allocate ;
265
252
$ ( that . wrapSelector ( '.allocate .CodeMirror' ) ) . addClass ( 'selected' ) ;
266
253
} else {
@@ -293,20 +280,14 @@ define([
293
280
294
281
if ( insEditorType == 'variable' ) {
295
282
// variable
296
- // that.state.variable.insEditor.show();
297
- // that.state.allocate.insEditor.hide();
298
283
that . state . selectedBox = 'variable' ;
299
284
that . pointer = that . state . variable ;
300
285
} else if ( insEditorType == 'allocate' ) {
301
286
// allocate
302
- // that.state.variable.insEditor.hide();
303
- // that.state.allocate.insEditor.show();
304
287
that . state . selectedBox = 'allocate' ;
305
288
that . pointer = that . state . allocate ;
306
289
} else {
307
290
that . state . selectedBox = '' ;
308
- // that.state.variable.insEditor.hide();
309
- // that.state.allocate.insEditor.hide();
310
291
}
311
292
} ) ;
312
293
@@ -327,19 +308,6 @@ define([
327
308
that . reloadInsEditor ( 'variable' ) ;
328
309
} ) ;
329
310
330
- // instance_editor_selected - allocate
331
- $ ( document ) . on ( 'instance_editor_selected' , this . wrapSelector ( '#vp_instanceAllocate' ) , function ( event ) {
332
- that . addStack ( ) ;
333
-
334
- var nowCode = that . state . allocate . codeEditor . getValue ( ) ;
335
- if ( nowCode != '' ) {
336
- nowCode += '.'
337
- }
338
- var selectedVariable = event . varName ;
339
- that . updateValue ( 'allocate' , nowCode + selectedVariable ) ;
340
- that . reloadInsEditor ( 'allocate' ) ;
341
- } ) ;
342
-
343
311
// instance_editor_replaced - variable
344
312
$ ( document ) . on ( 'instance_editor_replaced' , this . wrapSelector ( '#vp_instanceVariable' ) , function ( event ) {
345
313
that . addStack ( ) ;
@@ -348,15 +316,6 @@ define([
348
316
that . updateValue ( 'variable' , newCode ) ;
349
317
that . reloadInsEditor ( 'variable' ) ;
350
318
} ) ;
351
-
352
- // instance_editor_replaced - allocate
353
- $ ( document ) . on ( 'instance_editor_replaced' , this . wrapSelector ( '#vp_instanceAllocate' ) , function ( event ) {
354
- that . addStack ( ) ;
355
-
356
- var newCode = event . newCode ;
357
- that . updateValue ( 'allocate' , newCode ) ;
358
- that . reloadInsEditor ( 'allocate' ) ;
359
- } ) ;
360
319
}
361
320
362
321
VariablePackage . prototype . updateValue = function ( type , value ) {
@@ -421,7 +380,8 @@ define([
421
380
var sbCode = new sb . StringBuilder ( ) ;
422
381
423
382
// 변수 내용 조회
424
- var leftCode = this . state . allocate . codeEditor . getValue ( ) ;
383
+ // var leftCode = this.state.allocate.codeEditor.getValue();
384
+ var leftCode = $ ( this . wrapSelector ( '#vp_instanceAllocate' ) ) . val ( ) ;
425
385
var rightCode = this . state . variable . codeEditor . getValue ( ) ;
426
386
if ( leftCode && leftCode != '' ) {
427
387
sbCode . appendFormat ( '{0} = {1}' , leftCode , rightCode ) ;
0 commit comments