-
-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathstate.js
More file actions
177 lines (150 loc) · 6.65 KB
/
Copy pathstate.js
File metadata and controls
177 lines (150 loc) · 6.65 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
define([
'nbextensions/visualpython/src/pandas/fileNavigation/constData'
], function (constData) {
const { NAVIGATION_DIRECTION_TYPE } = constData;
var FileNavigationState = function() {
this.importPackageThis;
this.fileNavigatiotype;
this.baseDirStr = '';
this.notebookPathStr = '';
this.notebookFolder = '';
this.currentDirStr = '';
this.baseFolderStr = '';
this.currentFolderStr = '';
this.nodebookPathStr = '';
this.relativePathStr = '';
this.dirHistoryStack = [];
this.stackCursor = -1;
this.fileOptionData = {};
this.visualpythonFileName = ``;
this.triggerName = '';
}
/** ---------------------------------------------- 기본 메소드 ---------------------------------------------------- */
FileNavigationState.prototype.setImportPackageThis = function(importPackageThis) {
this.importPackageThis = importPackageThis;
}
FileNavigationState.prototype.getImportPackageThis = function() {
return this.importPackageThis;
}
FileNavigationState.prototype.setFileNavigationtype = function(paramFileNavigatiotype) {
this.fileNavigatiotype = paramFileNavigatiotype;
}
FileNavigationState.prototype.getFileNavigationtype = function() {
return this.fileNavigatiotype;
}
/** ---------------------------------------------- dir string 관련 메소드 ---------------------------------------------------- */
FileNavigationState.prototype.setBaseDir = function(paramBaseDirStr) {
this.baseDirStr = paramBaseDirStr;
}
FileNavigationState.prototype.getBaseDir = function() {
return this.baseDirStr;
}
FileNavigationState.prototype.setBaseFolder = function(paramBaseFolderStr) {
this.baseFolderStr = paramBaseFolderStr;
}
FileNavigationState.prototype.getBaseFolder = function() {
return this.baseFolderStr;
}
FileNavigationState.prototype.setCurrentDir = function(paramCurrentDirStr) {
this.currentDirStr = paramCurrentDirStr;
}
FileNavigationState.prototype.getCurrentDir = function() {
return this.currentDirStr;
}
FileNavigationState.prototype.setCurrentFolder = function(paramCurrentFolderStr) {
this.currentFolderStr = paramCurrentFolderStr;
}
FileNavigationState.prototype.getCurrentFolder = function() {
return this.currentFolderStr;
}
FileNavigationState.prototype.setRelativeDir = function(paramRelativePathStr) {
this.relativePathStr = paramRelativePathStr;
}
FileNavigationState.prototype.getRelativeDir = function() {
return this.relativePathStr;
}
FileNavigationState.prototype.setNotebookDir = function(notebookPathStr) {
this.notebookPathStr = notebookPathStr;
}
FileNavigationState.prototype.getNotebookDir = function() {
return this.notebookPathStr;
}
FileNavigationState.prototype.setVisualPythonFileName = function(visualpythonFileName) {
this.visualpythonFileName = visualpythonFileName;
}
FileNavigationState.prototype.getVisualPythonFileName = function() {
return this.visualpythonFileName;
}
FileNavigationState.prototype.setNotebookFolder = function(notebookFolder) {
this.notebookFolder = notebookFolder;
}
FileNavigationState.prototype.getNotebookFolder = function() {
return this.notebookFolder;
}
/** -------------------------------------------- optionData 관련 메소드 --------------------------------------------- */
/** 페이지의 optionData를 set합니다 */
FileNavigationState.prototype.setFileOptionData = function(fileOptionData) {
this.fileOptionData = fileOptionData;
}
/** 페이지의 optionData를 가져옵니다 */
FileNavigationState.prototype.getFileOptionData = function() {
return this.fileOptionData;
}
/** FIXME: 완료 트리거명 입력 */
FileNavigationState.prototype.setTriggerName = function(triggerName) {
this.triggerName = triggerName;
}
/** FIXME: 완료 트리거명 반환 */
FileNavigationState.prototype.getTriggerName = function() {
return this.triggerName;
}
/** --------------------------------------------- 이전 디렉토리 스택 관련 메소드 ------------------------------------------- */
FileNavigationState.prototype.getDirHistoryStack = function() {
return this.dirHistoryStack;
}
/**
* @param {Object} dirInfo 디렉토리 정보
*/
FileNavigationState.prototype.pushDirHistoryStack = function(dirInfo) {
this.dirHistoryStack = [ ...this.dirHistoryStack.slice(0,this.stackCursor + 1) , dirInfo
, ...this.dirHistoryStack.slice(this.stackCursor + 1, this.dirHistoryStack.length) ];
this.stackCursor++;
}
/** 디렉토리 스택에서
* 현재에서 다음 디렉토리의 정보를 가져옴 */
FileNavigationState.prototype.getNextDirHistoryStack = function() {
return this.dirHistoryStack[this.stackCursor];
}
/** 이전 디렉토리 검색 history stack에 최신 데이터를 pop합니다 */
FileNavigationState.prototype.popDirHistoryStackAndGetPopedData = function() {
var popStack = this.dirHistoryStack[this.stackCursor];
return popStack;
}
/** 이전 디렉토리 검색 history stack을 리셋합니다 */
FileNavigationState.prototype.resetStack = function() {
this.dirHistoryStack = [];
}
/** 현재 이동한 경로를 history stack에 집어 넣고, 절대 경로를 상대 경로로 바꿔 저장한다. */
FileNavigationState.prototype.splitPathStrAndSetStack = function(dirObj, resultInfoArr){
var currentDirStr = resultInfoArr[0].current.split('//').join('/');
var splitedDirStrArr = currentDirStr.split('/');
var rootFolderName = splitedDirStrArr[splitedDirStrArr.length - 1];
var firstIndex = currentDirStr.indexOf( this.getNotebookFolder() );
var currentRelativePathStr = '';
if ( firstIndex === -1 ) {
currentRelativePathStr = currentDirStr.substring(this.getNotebookDir().length + 1, currentDirStr.length);
} else {
currentRelativePathStr = currentDirStr.substring(firstIndex, currentDirStr.length);
}
if ( dirObj.direction === NAVIGATION_DIRECTION_TYPE.TOP
|| dirObj.direction === NAVIGATION_DIRECTION_TYPE.TO ) {
this.pushDirHistoryStack(currentDirStr);
}
return {
currentDirStr,
currentRelativePathStr,
rootFolderName
}
}
return FileNavigationState;
});