-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathbreakpoint.js
More file actions
126 lines (105 loc) · 3.99 KB
/
breakpoint.js
File metadata and controls
126 lines (105 loc) · 3.99 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
define([
'require'
, 'jquery'
, 'nbextensions/visualpython/src/common/vpCommon'
, 'nbextensions/visualpython/src/common/constant'
, 'nbextensions/visualpython/src/common/StringBuilder'
, 'nbextensions/visualpython/src/common/vpFuncJS'
], function (requirejs, $, vpCommon, vpConst, sb, vpFuncJS) {
// 옵션 속성
const funcOptProp = {
funcName : "breakpoint()"
, funcID : "pyBuilt_breakpoint"
}
/**
* html load 콜백. 고유 id 생성하여 부과하며 js 객체 클래스 생성하여 컨테이너로 전달
* @param {function} callback 호출자(컨테이너) 의 콜백함수
* @param {JSON} meta 메타 데이터
*/
var optionLoadCallback = function(callback, meta) {
// document.getElementsByTagName("head")[0].appendChild(link);
// 컨테이너에서 전달된 callback 함수가 존재하면 실행.
if (typeof(callback) === 'function') {
var uuid = vpCommon.getUUID();
// 최대 10회 중복되지 않도록 체크
for (var idx = 0; idx < 10; idx++) {
// 이미 사용중인 uuid 인 경우 다시 생성
if ($(vpConst.VP_CONTAINER_ID).find("." + uuid).length > 0) {
uuid = vpCommon.getUUID();
}
}
$(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM))).find(vpCommon.formatString(".{0}", vpConst.API_OPTION_PAGE)).addClass(uuid);
// 옵션 객체 생성
var osSample = new PythonCommon(uuid);
osSample.metadata = meta;
// 옵션 속성 할당.
osSample.setOptionProp(funcOptProp);
// html 설정.
osSample.initHtml();
// TODO: meta load 처리 방안 검토.
// 방안 1. callback 에서 처리
// 방안 2. initHtml 내에서 meta 존재 시 init과 동시에 처리.
// 방안 3. initHtml 후에 옵션 내에서 load 함수 호출.
callback(osSample); // 객체를 callback 인자로 전달
}
}
/**
* html 로드.
* @param {function} callback 호출자(컨테이너) 의 콜백함수
* @param {JSON} meta 메타 데이터
*/
var initOption = function(callback, meta) {
vpCommon.loadHtml(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM)), "python_common/index.html", optionLoadCallback, callback, meta);
}
/**
* 본 옵션 처리 위한 클래스
* @param {String} uuid 고유 id
*/
var PythonCommon = function(uuid) {
this.uuid = uuid; // Load html 영역의 uuid.
this.state = {
}
this.package = {
input: [
]
}
}
/**
* vpFuncJS 에서 상속
*/
PythonCommon.prototype = Object.create(vpFuncJS.VpFuncJS.prototype);
/**
* 유효성 검사
* @returns 유효성 검사 결과. 적합시 true
*/
PythonCommon.prototype.optionValidation = function() {
return true;
}
/**
* html 내부 binding 처리
*/
PythonCommon.prototype.initHtml = function() {
this.loadCss(Jupyter.notebook.base_url + vpConst.BASE_PATH + vpConst.STYLE_PATH + "python_common/index.css");
var sbPageContent = new sb.StringBuilder();
var sbTagString = new sb.StringBuilder();
this.setPage(sbPageContent.toString());
sbPageContent.clear();
}
/**
* 코드 생성
* @param {boolean} addCell 셀에 추가
* @param {boolean} exec 실행여부
* @returns 생성된 코드
*/
PythonCommon.prototype.generateCode = function(addCell = false, exec = false) {
var code = new sb.StringBuilder();
code.append('breakpoint()');
if (addCell) {
this.cellExecute(code.toString(), exec);
}
return code.toString();
}
return {
initOption: initOption
};
});