Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc90c85

Browse files
author
minjk-bl
committed
Variable update
1 parent487803b commitfc90c85

File tree

1 file changed

+39
-59
lines changed

1 file changed

+39
-59
lines changed

‎src/file_io/variables.js‎

Lines changed: 39 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define([
88
,'nbextensions/visualpython/src/pandas/common/commonPandas'
99
,'nbextensions/visualpython/src/pandas/common/pandasGenerator'
1010
],function(requirejs,$,vpCommon,vpConst,sb,vpFuncJS,libPandas,pdGen){
11-
//옵션 속성
11+
//option property
1212
constfuncOptProp={
1313
stepCount :1
1414
,funcName :"Variables"
@@ -17,74 +17,73 @@ define([
1717
}
1818

1919
/**
20-
* html load콜백. 고유 id 생성하여 부과하며 js 객체 클래스 생성하여 컨테이너로 전달
21-
*@param {function} callback호출자(컨테이너) 의 콜백함수
20+
* html loadcallback. 고유 id 생성하여 부과하며 js 객체 클래스 생성하여 컨테이너로 전달
21+
*@param {function} callbackcontainer's callback
2222
*/
2323
varoptionLoadCallback=function(callback,meta){
24-
// document.getElementsByTagName("head")[0].appendChild(link);
25-
// 컨테이너에서 전달된 callback 함수가 존재하면 실행.
24+
// execute callback function if available
2625
if(typeof(callback)==='function'){
2726
varuuid='u'+vpCommon.getUUID();
28-
//최대 10회 중복되지 않도록 체크
27+
//maximum 10 duplication allowed
2928
for(varidx=0;idx<10;idx++){
30-
//이미 사용중인uuid인 경우 다시 생성
29+
// uuidcheck and re-generate
3130
if($(vpConst.VP_CONTAINER_ID).find("."+uuid).length>0){
3231
uuid='u'+vpCommon.getUUID();
3332
}
3433
}
3534
$(vpCommon.wrapSelector(vpCommon.formatString("#{0}",vpConst.OPTION_GREEN_ROOM))).find(vpCommon.formatString(".{0}",vpConst.API_OPTION_PAGE)).addClass(uuid);
3635

37-
//옵션 객체 생성
36+
//create object
3837
varvarPackage=newVariablePackage(uuid);
3938
varPackage.metadata=meta;
4039

41-
//옵션 속성 할당.
40+
//set option property
4241
varPackage.setOptionProp(funcOptProp);
43-
// html설정.
42+
// htmlsetting
4443
varPackage.initHtml();
45-
callback(varPackage);// 공통 객체를 callback 인자로 전달
44+
callback(varPackage);
4645
}
4746
}
4847

4948
/**
50-
*html 로드.
51-
*@param {function} callback호출자(컨테이너) 의 콜백함수
49+
*Load html
50+
*@param {function} callbackcontainer's callback
5251
*/
5352
varinitOption=function(callback,meta){
5453
vpCommon.loadHtml(vpCommon.wrapSelector(vpCommon.formatString("#{0}",vpConst.OPTION_GREEN_ROOM)),"file_io/variables.html",optionLoadCallback,callback,meta);
5554
}
5655

5756
/**
58-
*본 옵션 처리 위한 클래스
59-
*@param {String} uuid고유 id
57+
*Option package
58+
*@param {String} uuidunique id
6059
*/
6160
varVariablePackage=function(uuid){
6261
this.uuid=uuid;// Load html 영역의 uuid.
63-
// pandas함수
62+
// pandasfunction
6463
this.package=libPandas._PANDAS_FUNCTION[funcOptProp.libID];
6564
}
6665

6766

6867

6968
/**
70-
*vpFuncJS 에서 상속
69+
*Extend vpFuncJS
7170
*/
7271
VariablePackage.prototype=Object.create(vpFuncJS.VpFuncJS.prototype);
7372

7473
/**
75-
*유효성 검사
76-
*@returns유효성 검사 결과. 적합시 true
74+
*Validation
75+
*@returnstrue if it's valid
7776
*/
7877
VariablePackage.prototype.optionValidation=function(){
7978
returntrue;
8079

81-
//부모 클래스 유효성 검사 호출.
80+
//parent's validation
8281
// vpFuncJS.VpFuncJS.prototype.optionValidation.apply(this);
8382
}
8483

8584

8685
/**
87-
* html내부 binding 처리
86+
* htmlinner binding
8887
*/
8988
VariablePackage.prototype.initHtml=function(){
9089
this.showFunctionTitle();
@@ -98,7 +97,7 @@ define([
9897
}
9998

10099
/**
101-
*선택한 패키지명 입력
100+
*package title
102101
*/
103102
VariablePackage.prototype.showFunctionTitle=function(){
104103
$(this.wrapSelector('.vp_functionName')).text(funcOptProp.funcName);
@@ -115,43 +114,43 @@ define([
115114
}
116115

117116
/**
118-
*Variables 조회
117+
*Search variables
119118
*/
120119
VariablePackage.prototype.loadVariables=function(){
121120
varthat=this;
122121

123-
//조회가능한 변수 data type 정의 FIXME: 조회 필요한 변수 유형 추가
122+
//Searchable variable types
124123
vartypes=[
125-
// pandas객체
124+
// pandasobject
126125
'DataFrame','Series','Index','Period','GroupBy','Timestamp'
127-
// Index하위 유형
126+
// Indextype object
128127
,'RangeIndex','CategoricalIndex','MultiIndex','IntervalIndex','DatetimeIndex','TimedeltaIndex','PeriodIndex','Int64Index','UInt64Index','Float64Index'
129-
// GroupBy하위 유형
128+
// GroupBytype object
130129
,'DataFrameGroupBy','SeriesGroupBy'
131-
// Plot관련 유형
130+
// Plottype
132131
,'Figure','AxesSubplot'
133132
// Numpy
134133
,'ndarray'
135-
// Python변수
134+
// Pythonvariable
136135
,'str','int','float','bool','dict','list','tuple'
137136
];
138137

139138
vartagTable=this.wrapSelector('#vp_var_variableBox table');
140139

141-
//변수 정보 표시
140+
//variable list table
142141
vartagDetailTable=this.wrapSelector("#vp_varDetailTable");
143142

144143
// initialize tags
145144
$(tagTable).find('tr:not(:first)').remove();
146145
$(tagDetailTable).html('');
147146

148-
// HTML구성
147+
// HTMLrendering
149148
pdGen.vp_searchVarList(types,function(result){
150149
// var jsonVars = result.replace(/'/gi, `"`);
151150
// var varList = JSON.parse(jsonVars);
152151
varvarList=JSON.parse(result);
153152

154-
//table 에 변수목록 추가
153+
//add variable list in table
155154
varList.forEach(varObj=>{
156155
if(types.includes(varObj.varType)&&varObj.varName[0]!=='_'){
157156
vartagTr=document.createElement('tr');
@@ -167,30 +166,12 @@ define([
167166
$(tagTr).append(tagTdName);
168167
$(tagTr).append(tagTdType);
169168

170-
$(tagTdName).attr({
171-
'title':'Click to copy'
172-
});
173-
// 변수이름 클릭 시 클립보드에 복사
174-
$(tagTdName).click(function(){
175-
// // 클립보드 복사 시작
176-
vartempElem=document.createElement('input');
177-
tempElem.value=varObj.varName;
178-
document.body.appendChild(tempElem);
179-
180-
tempElem.select();
181-
document.execCommand("copy");
182-
document.body.removeChild(tempElem);
183-
// 클립보드 복사 완료
184-
vpCommon.renderSuccessMessage('Copied!');
185-
});
186-
187-
// 변수 선택 시 표시
169+
// variable click
188170
$(tagTr).click(function(){
189171
$(this).parent().find('tr').removeClass('selected');
190172
$(this).addClass('selected');
191173

192-
// TEST: 변수 선택 시 변수 정보를 하단에 표시
193-
// vpFuncJS.kernelExecute 에서는 callback에 msg.content["text"]를 전달해주기 때문에 따로 구현함
174+
// show variable information on clicking variable
194175
Jupyter.notebook.kernel.execute(
195176
varObj.varName,
196177
{
@@ -202,14 +183,14 @@ define([
202183

203184
$(tagDetailTable).html('');
204185
if(htmlResult!=undefined){
205-
// 1. HTML태그로 구성되어 반환되는 경우
186+
// 1. HTMLtag
206187
$(tagDetailTable).append(htmlResult);
207188
}elseif(imgResult!=undefined){
208-
// 2.이미지 데이터가 반환되는 경우 (base64)
189+
// 2.Image data (base64)
209190
varimgTag='<img src="data:image/png;base64, '+imgResult+'">';
210191
$(tagDetailTable).append(imgTag);
211192
}elseif(textResult!=undefined){
212-
// 3.텍스트 데이터가 반환되는 경우
193+
// 3.Text data
213194
varpreTag=document.createElement('pre');
214195
$(preTag).text(textResult);
215196
$(tagDetailTable).html(preTag);
@@ -221,7 +202,6 @@ define([
221202
},
222203
{silent:false}
223204
);
224-
// TEST: END
225205
})
226206

227207
$(tagTable).append(tagTr);
@@ -231,14 +211,14 @@ define([
231211
};
232212

233213
/**
234-
*코드 생성
235-
*@param {boolean} exec실행여부
214+
*Generate code
215+
*@param {boolean} execdo execute
236216
*/
237217
VariablePackage.prototype.generateCode=function(addCell,exec){
238218

239219
varsbCode=newsb.StringBuilder();
240220

241-
//TODO: 변수 내용 조회
221+
//show selected variable
242222
varselectedVariable=$(this.wrapSelector('#vp_var_variableBox table tr.selected'));
243223
if(selectedVariable){
244224
varvarName=selectedVariable.attr('data-var-name');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp