1- 'use strict' ;
2-
31/* global DOM */
42/* global CloudCmd */
5- const createElement = require ( '@cloudcmd/create-element' ) ;
6- const { encode, decode} = require ( '../../common/entity' ) ;
7- const { getTitle, FS } = require ( '../../common/cloudfunc.mjs' ) ;
3+ import createElement from '@cloudcmd/create-element' ;
4+ import { encode , decode } from '../../common/entity.js' ;
5+ import { getTitle , FS } from '../../common/cloudfunc.mjs' ;
86
97let Title ;
108
119const CURRENT_FILE = 'current-file' ;
1210const encodeNBSP = ( a ) => a ?. replace ( '\xa0' , ' ' ) ;
1311const decodeNBSP = ( a ) => a ?. replace ( ' ' , '\xa0' ) ;
1412
15- module . exports . _CURRENT_FILE = CURRENT_FILE ;
13+ export const _CURRENT_FILE = CURRENT_FILE ;
14+
1615/**
1716 * set name from current (or param) file
1817 *
1918 * @param name
2019 * @param current
2120 */
22- module . exports . setCurrentName = ( name , current ) => {
21+ export const setCurrentName = ( name , current ) => {
2322 const Info = DOM . CurrentInfo ;
2423 const { link} = Info ;
2524 const { prefix} = CloudCmd ;
@@ -41,7 +40,7 @@ module.exports.setCurrentName = (name, current) => {
4140 *
4241 * @param currentFile
4342 */
44- module . exports . getCurrentName = ( currentFile ) => {
43+ export const getCurrentName = ( currentFile ) => {
4544 const current = currentFile || DOM . getCurrentFile ( ) ;
4645
4746 if ( ! current )
@@ -68,18 +67,19 @@ const parseNameAttribute = (attribute) => {
6867 return decodeNBSP ( decodeURI ( atob ( attribute ) ) ) ;
6968} ;
7069
71- module . exports . _parseNameAttribute = parseNameAttribute ;
70+ export const _parseNameAttribute = parseNameAttribute ;
7271
7372const parseHrefAttribute = ( prefix , attribute ) => {
7473 attribute = attribute . replace ( RegExp ( '^' + prefix + FS ) , '' ) ;
7574 return decode ( decodeNBSP ( attribute ) ) ;
7675} ;
7776
78- module . exports . _parseHrefAttribute = parseHrefAttribute ;
77+ export const _parseHrefAttribute = parseHrefAttribute ;
78+
7979/**
8080 * get current direcotory path
8181 */
82- module . exports . getCurrentDirPath = ( panel = DOM . getPanel ( ) ) => {
82+ export const getCurrentDirPath = ( panel = DOM . getPanel ( ) ) => {
8383 const path = DOM . getByDataName ( 'js-path' , panel ) ;
8484 return path . textContent ;
8585} ;
@@ -89,7 +89,7 @@ module.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {
8989 *
9090 * @param currentFile - current file by default
9191 */
92- module . exports . getCurrentPath = ( currentFile ) => {
92+ export const getCurrentPath = ( currentFile ) => {
9393 const current = currentFile || DOM . getCurrentFile ( ) ;
9494 const [ element ] = DOM . getByTag ( 'a' , current ) ;
9595 const { prefix} = CloudCmd ;
@@ -100,7 +100,7 @@ module.exports.getCurrentPath = (currentFile) => {
100100/**
101101 * get current direcotory name
102102 */
103- module . exports . getCurrentDirName = ( ) => {
103+ export const getCurrentDirName = ( ) => {
104104 const href = DOM
105105 . getCurrentDirPath ( )
106106 . replace ( / \/ $ / , '' ) ;
@@ -113,7 +113,7 @@ module.exports.getCurrentDirName = () => {
113113/**
114114 * get current direcotory path
115115 */
116- module . exports . getParentDirPath = ( panel ) => {
116+ export const getParentDirPath = ( panel ) => {
117117 const path = DOM . getCurrentDirPath ( panel ) ;
118118 const dirName = DOM . getCurrentDirName ( ) + '/' ;
119119 const index = path . lastIndexOf ( dirName ) ;
@@ -127,7 +127,7 @@ module.exports.getParentDirPath = (panel) => {
127127/**
128128 * get not current direcotory path
129129 */
130- module . exports . getNotCurrentDirPath = ( ) => {
130+ export const getNotCurrentDirPath = ( ) => {
131131 const panel = DOM . getPanel ( {
132132 active : false ,
133133 } ) ;
@@ -140,14 +140,14 @@ module.exports.getNotCurrentDirPath = () => {
140140 *
141141 * @currentFile
142142 */
143- module . exports . getCurrentFile = ( ) => {
143+ export const getCurrentFile = ( ) => {
144144 return DOM . getByClass ( CURRENT_FILE ) ;
145145} ;
146146
147147/**
148148 * get current file by name
149149 */
150- module . exports . getCurrentByName = ( name , panel = DOM . CurrentInfo . panel ) => {
150+ export const getCurrentByName = ( name , panel = DOM . CurrentInfo . panel ) => {
151151 const dataName = 'js-file-' + btoa ( encodeURI ( encodeNBSP ( name ) ) ) ;
152152 return DOM . getByDataName ( dataName , panel ) ;
153153} ;
@@ -169,7 +169,7 @@ function unsetCurrentFile(currentFile) {
169169/**
170170 * unified way to set current file
171171 */
172- module . exports . setCurrentFile = ( currentFile , options ) => {
172+ export const setCurrentFile = ( currentFile , options ) => {
173173 const o = options ;
174174 const currentFileWas = DOM . getCurrentFile ( ) ;
175175
@@ -216,7 +216,7 @@ module.exports.setCurrentFile = (currentFile, options) => {
216216 return DOM ;
217217} ;
218218
219- this . setCurrentByName = ( name ) => {
219+ export const setCurrentByName = ( name ) => {
220220 const current = DOM . getCurrentByName ( name ) ;
221221 return DOM . setCurrentFile ( current ) ;
222222} ;
@@ -227,7 +227,7 @@ this.setCurrentByName = (name) => {
227227 * @param layer - element
228228 * @param - position {x, y}
229229 */
230- module . exports . getCurrentByPosition = ( { x, y} ) => {
230+ export const getCurrentByPosition = ( { x, y} ) => {
231231 const element = document . elementFromPoint ( x , y ) ;
232232
233233 const getEl = ( el ) => {
@@ -259,7 +259,7 @@ module.exports.getCurrentByPosition = ({x, y}) => {
259259 *
260260 * @param currentFile
261261 */
262- module . exports . isCurrentFile = ( currentFile ) => {
262+ export const isCurrentFile = ( currentFile ) => {
263263 if ( ! currentFile )
264264 return false ;
265265
@@ -271,7 +271,7 @@ module.exports.isCurrentFile = (currentFile) => {
271271 *
272272 * @param name
273273 */
274- module . exports . setTitle = ( name ) => {
274+ export const setTitle = ( name ) => {
275275 if ( ! Title )
276276 Title = DOM . getByTag ( 'title' ) [ 0 ] || createElement ( 'title' , {
277277 innerHTML : name ,
@@ -288,7 +288,7 @@ module.exports.setTitle = (name) => {
288288 *
289289 * @param currentFile
290290 */
291- module . exports . isCurrentIsDir = ( currentFile ) => {
291+ export const isCurrentIsDir = ( currentFile ) => {
292292 const current = currentFile || DOM . getCurrentFile ( ) ;
293293 const path = DOM . getCurrentPath ( current ) ;
294294 const fileType = DOM . getCurrentType ( current ) ;
@@ -299,7 +299,7 @@ module.exports.isCurrentIsDir = (currentFile) => {
299299 return isDir || isZip ;
300300} ;
301301
302- module . exports . getCurrentType = ( currentFile ) => {
302+ export const getCurrentType = ( currentFile ) => {
303303 const current = currentFile || DOM . getCurrentFile ( ) ;
304304 const el = DOM . getByDataName ( 'js-type' , current ) ;
305305 const type = el . className
0 commit comments