-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPA-CASE.html
More file actions
541 lines (516 loc) · 24.9 KB
/
GPA-CASE.html
File metadata and controls
541 lines (516 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
<!-- Making Start At 2015-10-09 FRI, Made By Anyang University Department of Computer Science Engineering 201431011 Dongyeong Kim -->
<!-- First Assignment : Implement The game called "Chrong's Catching the files" -->
<!-- Program Changed Named As GPA CASE at 2017-03-13 to be functioned for Touch/Drag/Text Friendly Programming Tool-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>크롱을 잡는 게임(GPA CASE :: Prototype ver 0.0.1)</title>
<!-- Origin Source : http://pororo.jr.naver.com/game/territory/play.nhn?gameId=162&level=2&territory=CR -->
<!-- Flip Reference about Flipping Images in the Canvas(context.scale(scaleHorizontal,scaleVertical); ) : http://jsfiddle.net/yong/ZJQX5/ -->
<!-- PNG File Edited By Pixlr Editor(Web Photo Editor), link : https://pixlr.com/editor/ -->
<!-- Window Closing Function(window.close();) Referenced : http://idongmai.wo.tc/212 -->
</head>
<body>
<canvas width="1024" height="800" id="canvas">CANVAS NOT SUPPORTED</canvas>
<script type="text/javascript" src="module_customobject.js"></script>
<!--<script type="text/javascript" src="CustomObject%20API.js"></script>-->
<script type="text/javascript">
/*MyObject Class (Button Object) Declaration.*/
{
var MyObject = function(name,x,y,width,height,isdraggable){
this.prototype = AddCustomObject(CustomObjectList,CustomObjectList_Wait,x,y,width,height,name,undefined,true,undefined,false);
this.prototype.draw=draw;
// this.prototype.onclick=onclick;
this.prototype.onmousemove=onmove;
this.prototype.onmousedown=onmousedown;
this.prototype.onmouseup=onmouseup;
this.prototype.selected=false;
this.prototype.isdraggable=isdraggable||false;
this.constructor=MyObject;
this.ancestor=undefined;
this.decendent=undefined;
/* Object Drawing Method */
function draw(context,image){
context.beginPath();
context.strokeStyle=this.strokeStyle;
//Draw Content's name.
{
//Drawing Text
if(this.value!==undefined){
var temp_fontSize = (this.width/this.value.toString().length);
temp_fontSize=(temp_fontSize>this.height)?this.height:temp_fontSize;
context.font= temp_fontSize+"px Arial";
context.textAlign="center";
context.textBaseline="middle";
context.fillText(this.value,this.x,this.y);
}
}
//Draw Surrounded Line Rectangle.
context.strokeRect(this.x-this.width/2, this.y-this.height/2, this.width, this.height);
}
function onclick(event){
//this.strokeStyle = (this.strokeStyle == "red" ? "black" : "red");
}
function onmousedown(event){
this.selected=true;
this.strokeStyle="red";
this.eventTransparent=true;
}
function onmove(event){
if(this.isdraggable&&this.selected){
this.x=event.offsetX;
this.y=event.offsetY;
}
}
function onmouseup(event){
this.selected=false;
this.strokeStyle="black";
this.eventTransparent=false;
}
return this.prototype;
}
}
/* Create New Logical Block */
var MyLogicalBlock=function(name,mean,value,x,y,width,height){
this.myobject=new MyObject(name,x,y,width,height);
this.mean=mean;
this.value=value;
}
/* Logic Block (With Dependency) Declaration */
var Dragoon = function(name){
/* Constructor */
this.constructor=Dragoon;
this.name=name;
this.requiredDependencyList=[];
/* Enroll This Object's Required Dependency */
for(var i=1; i<arguments.length;i++){
// Check If Argument's Type is Dragoon.
if(arguments[i].constructor==Dragoon && arguments[i].name != this.name)
this.requiredDependencyList.push(arguments[i]);
}
}
/* Log */
var CyberNeticsCore = function(){
this.enrolledObjects=[];
this.usingObjects=[];
this.sequenceTree = null;
this.focusedSequence = undefined;
var Shuttle = function(name,dragoon){
this.name=name;
this.dragoon=dragoon;
this.prev = undefined;
this.next = undefined;
}
/* Create Dragoon (Action Definition) */
this.createDragoon = function(name){
/* Check List's Unique Constraints */
var isCreatable = true;
for(var i=0;i<this.enrolledObjects.length;i++){
if(name === this.enrolledObjects[i].name){
isCreatable=false;
break;
}
}
/* If name is Unique, Create Dragoon Objects & Enroll it. */
if(isCreatable)
this.enrolledObjects.push(new Dragoon(name));
else
console.log("Creating Dragoon Failed : name \"" + name +"\" is Not Unique." );
}
this.findDragoon = function(name){
for(var i=0 ;i < this.enrolledObjects.length;i++)
if(this.enrolledObjects[i].name === name )return this.enrolledObjects[i];
return undefined;
}
this.addSequence = function(shuttleName, dragoonName){
var targetShuttle = this.focusedSequence; //Remain Concurrency.
var newShuttle = undefined;
var targetDragoon = undefined;
/* Find Target Dragoon */
targetDragoon=this.findDragoon(dragoonName);
/* Check if target Dragoon is Not Found To Alert Attempting to Create Shuttle With no Dragoon. */
if(targetDragoon == undefined){
if(name !== "")
console.log("Not Found : Dragoon Name \"" + name+"\" Not Found.");
console.log("Alert : Attempting to Create Shuttle With undefined Dragoon!");
}
/* Create New Shuttle Object */
newShuttle = new Shuttle(shuttleName,targetDragoon);
if(targetShuttle == undefined){
/* Attach to Master Root. */
this.focusedSequence=newShuttle;
}
else{
targetShuttle.next=newShuttle; //Attach New Shuttle To Target
newShuttle.prev=targetShuttle; //Remember Parent's Shuttle.
}
}
this.parseToString = function(){
var targetShuttle = this.focusedSequence; //current focused Shuttle In this CyberNetics Core.
var resultString = ""; // String(Text) of Returning Value, Real Psuedo-code.
/* Return Empty Text If Shuttle Variable is undefined */
if (targetShuttle == undefined)
return resultString;
/* Find Head Of This Source */
for (; targetShuttle.prev !== undefined; targetShuttle = targetShuttle.prev);
/* Extract Shuttle's Name And Create Source Code */
while (targetShuttle !== undefined) {
console.log("targetShuttle : " + targetShuttle);
if (targetShuttle.constructor == Shuttle) {
resultString += targetShuttle.name;
targetShuttle = targetShuttle.next;
console.log(resultString);
}
/* No Remaining Shuttles Attatched. => Decode Finish */
else
break;
}
/* Source Extract Completed From CyberNetics Core. */
return resultString; //Return Source Code of Text.
}
}
/* Create New Empty Source Tree */
var MySourceTree = function(name){
this.items=new Array();
this.focused = new Array(); //Create New Array
this.onkeyup = function(){};
this.name=(name==undefined?"Untitled Source Code":name);
function myfunctionA(e){
e.targetObject=this;
/* Empty Checking. */
if(this.items.length==0){
var key = e.keyCode;
var temp = new MyLogicalBlock("undefined","block",undefined,10,10);
}
}
}
MySrc=new CustomScreen("canvas");
MySrc.StartLoadScreen();
MySrc.addCustomScreenEventListener();
//Question List Creation Class Definition.
{
var btn_questionList = new Array(); //reserved variable, it will be used and replaced(inserted) as variant questionnaire blocks.
btn_questionList.flush = function(){
for(var a in this)
if(this[a]!=undefined&&this[a].constructor==MyObject)
this[a].remove();
}
btn_questionList.inputQuestion=function(){
this.flush();
this.length=0;
var lastVariable = undefined;
for(var a in arguments){
if(typeof arguments[a] === "string"){
lastVariable = new MyObject("btn_qustionnaireList"+(a).toString(),256,160+64*this.length,512,64);
lastVariable.value =arguments[a];
this.push(lastVariable);
}
else if(typeof arguments[a] === "function" && lastVariable !== undefined ){
lastVariable.onclick = arguments[a];
}
else{
lastVariable = undefined;
}
}
}
btn_questionList.appendQuestion=function() {
var origin_length = this.length;
for (var a in arguments) {
this[a + i] = new MyObject("btn_qustionnaireList" + (a + i).toString(), 256, 160 + 64 * (a + i), 512, 64);
this[a + i].value = arguments[a];
}
}
}
/* Default Initializing Part End*/
Activity_Title();
function Activity_Title(){
/* Activity Initialization */
{
MySrc.resetCustomScreenState();
}
/* Code Entry - Global Variable */
{
//var foo = new MyObject("foo",100,100,120,80,true);
//var bar = new MyObject("bar",100,100,120,80,true);
}
//Title Label Creation
{
var label_ProgramTitle = new MyObject("label_ProgramTitle",375,50,450,50);
label_ProgramTitle.value="Welcome To GPA Coding";
var label_typeCheckInfo = new MyObject("label_typeCheckInfo",375,125,450,40);
label_typeCheckInfo.value="Click Button To Choose Programming Type";
}
//Button Creation
{
var btn_createByOrderEditor = new MyObject("btn_createByOrderEditor",250,250,200,200);
btn_createByOrderEditor.value="Quick Planning";
btn_createByOrderEditor.onclick=function(){
alert("Selected Order Coding Function!");
Activity_OrderEdit();
}
var btn_createByTextEditor = new MyObject("btn_createByTextEditor",500,250,200,200);
btn_createByTextEditor.value="Manual Coding";
btn_createByTextEditor.onclick=function(){
alert("Selected Manual Coding Function!");
Activity_ManualEdit();
}
var mySourceTree = new MySourceTree(); //Create New Empty Source Code;
}
}
function Activity_OrderEdit(){
/* Activity Initialization */
{
MySrc.resetCustomScreenState();
}
/* Code Entry - Global Variable Initialization */
{
var isEdited=false;
}
/* Code Entry - Header */
{
var btn_home=new MyObject("btn_home",32,32,50,50);
btn_home.value="Home";
btn_home.onclick=function(){if(!isEdited||confirm("If You Want to Exit Editor Without Changes?")==true)Activity_Title();}
}
/* Code Entry - Contents */
{
//Question Label
var label_question=new MyObject("label_question",256,64+32,512,50);
label_question.value="What Do You Want To Create?";
//Create Questionnaire List.
btn_questionList.inputQuestion("Empty Program",function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"Hello World! - Console", function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"Calculator - Console",function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"Number Converter - Console",function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"MUD Role-Playing Game",function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"Calculator- Graphic",function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"Piano Player - Graphic",function(e){Activity_OrderEdit_WorkSpace("Empty Program")},
"Simple ERP - Graphic",function(e){Activity_OrderEdit_WorkSpace("Empty Program")});
}
}
function Activity_OrderEdit_WorkSpace(projectName){
/* Activity Initialization */
{
MySrc.resetCustomScreenState();
}
/* Code Entry - Global Variable Initialization */
{
var isEdited=true;
}
/* Code Entry - Header */
{
var btn_home=new MyObject("btn_home",32,32,50,50);
btn_home.value="Home";
btn_home.onclick=function(){if(!isEdited||confirm("If You Want to Exit Editor Without Changes?")==true)Activity_Title();}
}
/* Code Entry - Contents */
{
switch(projectName){
default:
break;
}
var label_question=new MyObject("label_question",256,64+32,512,50);
label_question.value="The Thing That You Can Do Function Right Now.";
btn_questionList.inputQuestion(
"Console Print With Input, Calculating",undefined,
"Graphic Programming",undefined
)
}
}
function Activity_ManualEdit(){
/* Activity Initialization */
MySrc.resetCustomScreenState();
/* Code Entry - Global */
{
var blob = new Blob();
var isEdited= true;
var cyberNeticsCore = new CyberNeticsCore();
cyberNeticsCore.createDragoon("new line");
cyberNeticsCore.createDragoon("condition(if)");
cyberNeticsCore.createDragoon("function(print)");
// Test Code From --> http://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
else {
pom.click();
}
}
}
/* Code Entry - Contents */
{
var textarea_codeField=new MyObject("textarea_codeField",576,256+128,896,512);
textarea_codeField.value="text/block coding area";
var groupblock_codeCollection=new MyObject("groupblock_codeCollection",64,256+128,128,512);
groupblock_codeCollection.value="coding block display area";
}
/* Code Entry - Navigation Field */
{
//Home Button
var btn_home=new MyObject("btn_home",32,32,50,50);
btn_home.value="Home";
btn_home.onclick=function(){if(!isEdited||confirm("If You Want to Exit Editor Without Changes?")==true)Activity_Title();}
//Save Button
var btn_save=new MyObject("btn_save",64+32,32,50,50);
btn_save.value="Save";
btn_save.onclick=function(){isEdited=false;}
//Download Button
var btn_download=new MyObject("btn_download",128+32,32,50,50);
btn_download.value="Download";
btn_download.onclick=function(){
var isDownloaded = false; //Data Download Execution Boolean Variable(Added On 2017-05-11)
if(isEdited)
if(confirm("if You Want To Save Source Code And Download It?"))
btn_save.onclick();
if(!isEdited){
/* If Browser Is Downloadable? */
if (true) {
var sourceCode = cyberNeticsCore.parseToString(); //Get Source Code From CyberNetics Core.
console.log("Test Source Code Recognition : " + sourceCode);
console.log("Trying To Download(Export From Local Web To Local File System) Source File.");
download("new file.txt", sourceCode);// Order Download Source Code. (Local Download);
console.log("Download Complete.");
isDownloaded = true;
}
else{
alert("Download Function is Prohibited By Unknown Reason.");
}
}
return isDownloaded;
}
}
/* Code Entry - Test Carrige Return Block*/
{
var btn_createFunctionBlock=new MyObject("btn_createFunctionBlock",64,128+128,64,32,true);
btn_createFunctionBlock.value="new line";
/*btn_createFunctionBlock.onmousedown=function(e){
this.originX=this.x;
this.originY=this.y;
}*/
btn_createFunctionBlock.onmouseup=function(e){
var targetObject = textarea_codeField;
var x = targetObject.x;
var y = targetObject.y;
var width = targetObject.width;
var height = targetObject.height;
if(!(this.isObjectIn(x,y,width,height))){
this.x=this.originX;
this.y=this.originY;
}
else{
alert("new line Created");
cyberNeticsCore.addSequence("\n","new line");
/* Temporary Added Block Creation And Display Code (Added On 2017-05-11) */
var createdBlock = new MyObject("block_"+this.value,this.x,this.y,this.width,this.height,true);
createdBlock.value = this.value;
this.x=this.originX;
this.y=this.originY;
}
this.selected=false;
}
}
/* Code Entry - Test Variable Block*/
{
var btn_createFunctionBlock=new MyObject("btn_createVariableBlock",64,128+192,64,32,true);
btn_createFunctionBlock.value="Variable";
/*btn_createFunctionBlock.onmousedown=function(e){
this.originX=this.x;
this.originY=this.y;
}*/
btn_createFunctionBlock.onmouseup=function(e){
var targetObject = textarea_codeField;
var x = targetObject.x;
var y = targetObject.y;
var width = targetObject.width;
var height = targetObject.height;
if(!(this.isObjectIn(x,y,width,height))){
this.x=this.originX;
this.y=this.originY;
}
else{
alert("Variable Block Created");
cyberNeticsCore.addSequence("var","variable");
/* Temporary Added Block Creation And Display Code (Added On 2017-05-11) */
var createdBlock = new MyObject("block_"+this.value,this.x,this.y,this.width,this.height,true);
createdBlock.value = this.value;
this.x=this.originX;
this.y=this.originY;
}
this.selected=false;
}
}
/* Code Entry - Test If Block*/
{
var btn_createFunctionBlock=new MyObject("btn_createIfBlock",64,128+376,64,32,true);
btn_createFunctionBlock.value="if";
/*btn_createFunctionBlock.onmousedown=function(e){
this.originX=this.x;
this.originY=this.y;
}*/
btn_createFunctionBlock.onmouseup=function(e){
var targetObject = textarea_codeField;
var x = targetObject.x;
var y = targetObject.y;
var width = targetObject.width;
var height = targetObject.height;
if(!(this.isObjectIn(x,y,width,height))){
this.x=this.originX;
this.y=this.originY;
}
else{
alert("new Condition(if) Block Created");
cyberNeticsCore.addSequence("if","condition(if)");
/* Temporary Added Block Creation And Display Code (Added On 2017-05-11) */
var createdBlock = new MyObject("block_"+this.value,this.x,this.y,this.width,this.height,true);
createdBlock.value = this.value;
this.x=this.originX;
this.y=this.originY;
}
this.selected=false;
}
}
/* Code Entry - Test Print Block*/
{
var btn_createFunctionBlock=new MyObject("btn_createPrintBlock",64,128+512-64,64,32,true);
btn_createFunctionBlock.value="print";
/*btn_createFunctionBlock.onmousedown=function(e){
this.originX=this.x;
this.originY=this.y;
}*/
btn_createFunctionBlock.onmouseup=function(e){
var targetObject = textarea_codeField;
var x = targetObject.x;
var y = targetObject.y;
var width = targetObject.width;
var height = targetObject.height;
if(!(this.isObjectIn(x,y,width,height))){
this.x=this.originX;
this.y=this.originY;
}
else{
alert("new Print Block Created");
cyberNeticsCore.addSequence("print","function(print)");
/* Temporary Added Block Creation And Display Code (Added On 2017-05-11) */
var createdBlock = new MyObject("block_"+this.value,this.x,this.y,this.width,this.height,true);
createdBlock.value = this.value;
this.x=this.originX;
this.y=this.originY;
}
this.selected=false;
}
}
}
var canvas=document.getElementById("canvas");
var context=canvas.getContext("2d");
context.beginPath();
context.fillRect(0,0,100,100);
</script>
</body>
</html>