file_operation.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <html>
  2. <head>
  3. <title>File Operation</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  7. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  8. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  9. <script type="text/javascript" src="../../script/ao_module.js"></script>
  10. <style>
  11. .banner{
  12. background-color:#4287f5;
  13. height:50px;
  14. padding:12px;
  15. padding-left:20px;
  16. padding-top:16px;
  17. }
  18. #opricon{
  19. position:absolute;
  20. top:0px;
  21. right:0px;
  22. width:80px;
  23. height:80px;
  24. }
  25. .title{
  26. color:white;
  27. font-size:130%;
  28. }
  29. .content{
  30. padding:12px;
  31. }
  32. .info{
  33. margin-top:3px;
  34. white-space: nowrap;
  35. overflow: hidden;
  36. text-overflow: ellipsis;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <div class="banner">
  42. <div class="title">Calculating Operation</div>
  43. <img id="opricon" src="img/loading.png" class="ui image"></img>
  44. </div>
  45. <div class="content">
  46. <div class="info">From: <span id="src"></span></div>
  47. <div class="info">To: <span id="dest"></span></div>
  48. <div class="info">Progress: <span id="progress"> <i class="loading spinner icon"></i> Calculating</span></div>
  49. <div class="ui active small progress" style="margin-top:18px;">
  50. <div id="progressbar" class="bar" style="width:100%; background-color:#4287f5;"></div>
  51. </div>
  52. </div>
  53. <div class="ui modal" id="duplicateAction">
  54. <div class="content">
  55. <div class="description" style="padding: 0px !important;">
  56. <p><i class="big exclamation triangle icon"></i> At least one file has the same filename with another existsing file. <b>Which action should be taken?</b></p><br>
  57. </div>
  58. </div>
  59. <div class="actions">
  60. <div class="ui labeled button" onclick="continueProcess('overwrite');">
  61. Overwrite
  62. </div>
  63. <div class="ui labeled button" onclick="continueProcess('skip');">
  64. Skip
  65. </div>
  66. <div class="ui labeled button" style="color: #2fb55c;" onclick="continueProcess('keep');">
  67. Rename & Keep
  68. </div>
  69. </div>
  70. </div>
  71. <script>
  72. /*
  73. ArOZ Online File Operation Listener
  74. Usage: Pass in the following JSON object as hash with encodeURIComponent after JSON stringify
  75. {
  76. opr: {move / copy / zip / unzip / download / zipAndDown / unzipAndOpen},
  77. src: {filelist, allow multiple files},
  78. dest: {filepath},
  79. //Optional paramters
  80. overwriteMode: {skip / overwrite / keep},
  81. callbackWindowID: {floatWindow ID},
  82. callbackFunction: {target Window Function Name as String}
  83. }
  84. **For download opr, it will first buffer into the browser memory.
  85. It is not recommended for files > 2GB (Firefox Limit)
  86. Example callbackFunction: "refreshList()" (string)
  87. */
  88. var operationConfig = null;
  89. var opr = "";
  90. var maxPathDisplayLength = 40;
  91. var legacyMode = !('WebSocket' in window || 'MozWebSocket' in window); //Use AJAX instead of WebSocket if legacy mode is activated
  92. var enterErrorMode = false;
  93. //Initalized floatWindow events
  94. ao_module_setFixedWindowSize();
  95. ao_module_setWindowSize(400,220);
  96. init();
  97. function init(){
  98. console.log("Checking launch parameters...");
  99. if (window.location.hash.length > 0){
  100. //OK to proceed
  101. try{
  102. operationConfig = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
  103. //Check if there are any missing paratmers
  104. configValid = true;
  105. if (typeof operationConfig.opr == "undefined"){ configValid = false; }
  106. if (typeof operationConfig.src == "undefined"){ configValid = false; }
  107. if (typeof operationConfig.dest == "undefined"){ configValid = false; }
  108. if (!configValid){
  109. console.log("Invalid file operation config. Please see the file_operation.html source code for the correct config json object.")
  110. ao_module_close();
  111. return;
  112. }
  113. //Parse the missing argument if there are any
  114. if (typeof operationConfig.overwriteMode == "undefined"){
  115. operationConfig.overwriteMode = "skip";
  116. }
  117. //Update 17-12-2020, ask the user for overwrite mode if file duplicate exists
  118. if (operationConfig.overwriteMode == "ask"){
  119. //Check if any file duplication before proceeding
  120. console.log(operationConfig.src);
  121. $.ajax({
  122. url: "../../system/file_system/listDir",
  123. data: {dir: operationConfig.dest},
  124. success: function(filelist){
  125. //Check fod duplication
  126. var duplicateFound = false;
  127. mainloop:
  128. for (var i = 0; i < filelist.length; i++){
  129. var desktopFile = filelist[i];
  130. for (var j = 0; j < operationConfig.src.length; j++){
  131. var srcfile = operationConfig.src[j];
  132. var srcFilename = srcfile.split("/").pop();
  133. if (srcFilename == desktopFile.Filename){
  134. duplicateFound = true
  135. break mainloop;
  136. }
  137. }
  138. };
  139. if (duplicateFound){
  140. //Duplication found.
  141. $("#duplicateAction").modal({
  142. closable: false
  143. }).modal("show");
  144. }else{
  145. //Duplication not found. Start the operation with default mode
  146. operationConfig.overwriteMode = "skip";
  147. processOperations(operationConfig);
  148. }
  149. }
  150. })
  151. }else{
  152. //All information are defined. Process it now.
  153. processOperations(operationConfig)
  154. }
  155. }catch(ex){
  156. //Failed
  157. console.log("Argument parse error", ex);
  158. }
  159. }else{
  160. alert("Invalid use of File Operation Listener.")
  161. ao_module_close();
  162. }
  163. }
  164. function continueProcess(duplicateMode){
  165. operationConfig.overwriteMode = duplicateMode;
  166. $("#duplicateAction").modal("hide");
  167. processOperations(operationConfig)
  168. }
  169. function processOperations(operationConfig){
  170. //Update the display information
  171. $("#src").text(operationConfig.src);
  172. $("#dest").text(operationConfig.dest);
  173. opr = operationConfig.opr;
  174. updateTitle(operationConfig.src.length, operationConfig.opr);
  175. //Check which type of the oprs is about. And assign the related functions to start
  176. if (operationConfig.opr == "move"){
  177. $("#opricon").attr("src","img/move.gif");
  178. cut(operationConfig.src, operationConfig.dest, operationConfig.overwriteMode);
  179. }else if (operationConfig.opr == "copy"){
  180. $("#opricon").attr("src","img/copy.gif");
  181. copy(operationConfig.src, operationConfig.dest, operationConfig.overwriteMode);
  182. }else if (operationConfig.opr == "zip"){
  183. $("#opricon").attr("src","img/zip.gif");
  184. zip(operationConfig.src, operationConfig.dest, operationConfig.overwriteMode);
  185. }else if (operationConfig.opr == "unzip"){
  186. $("#opricon").attr("src","img/unzip.gif");
  187. unzip(operationConfig.src, operationConfig.dest, operationConfig.overwriteMode);
  188. }else if (operationConfig.opr == "unzipAndOpen"){
  189. $("#opricon").attr("src","img/unzip.gif");
  190. unzip(operationConfig.src, operationConfig.dest, operationConfig.overwriteMode, function(){
  191. //Open the target directory
  192. });
  193. }
  194. }
  195. //Unzip zip
  196. function unzip(srcList, dest, overwriteMode, callback=undefined){
  197. if (legacyMode){
  198. //Run in legacy mode
  199. requestCSRFToken(function(token){
  200. $.ajax({
  201. type: 'POST',
  202. url: `../../system/file_system/fileOpr`,
  203. data: {opr: "unzip" ,src: JSON.stringify(srcList), dest: dest, csrft: token},
  204. success: function(data){
  205. handleFinish(data);
  206. }
  207. });
  208. });
  209. }else{
  210. //Filter all + sign in the list
  211. var filteredSrcList = [];
  212. srcList.forEach(src => {
  213. filteredSrcList.push(src.split("+").join("{{plug_sign}}"));
  214. });
  215. //Open WebSocket
  216. var endpoint = getWSEndpoint() + `?opr=unzip&src=${encodeURIComponent(JSON.stringify(filteredSrcList))}&dest=${encodeURIComponent(dest)}&existsresp=${overwriteMode}`
  217. console.log(endpoint);
  218. var ws = new WebSocket(endpoint);
  219. ws.onopen = function(){
  220. //Do nothing. Just listen to the progress update
  221. };
  222. ws.onmessage = function (evt) {
  223. var data = evt.data;
  224. var progress = JSON.parse(data);
  225. console.log(progress);
  226. if (progress.Error != ""){
  227. //Something went wrong
  228. $("#progressbar").css("background-color", "#eb3f28");
  229. $("#opricon").attr("src", "img/error.png");
  230. enterErrorMode = true;
  231. alert(progress.Error);
  232. }else{
  233. //Update the progress display
  234. $("#progressbar").css("width", progress.Progress + "%");
  235. var currentSrc = truncate(progress.LatestFile, maxPathDisplayLength);
  236. var filteredDest = operationConfig.dest.trim();
  237. if (filteredDest.substr(filteredDest.length -1, 1) != "/"){
  238. filteredDest += "/"
  239. }
  240. var currentDest = truncate(filteredDest + progress.LatestFile, maxPathDisplayLength);
  241. $("#src").text(currentSrc);
  242. $("#dest").text(currentDest);
  243. $("#progress").text(progress.Progress + "%")
  244. if (progress.Progress == 100){
  245. //Set progress bar to green
  246. $("#progressbar").css("background-color", "#2bba35");
  247. }
  248. }
  249. };
  250. ws.onclose = function() {
  251. if (!enterErrorMode){
  252. $("#progressbar").css("background-color", "#2bba35");
  253. $("#progressbar").css("width", "100%");
  254. $("#progress").text("100%");
  255. $("#opricon").attr("src", "img/done.png")
  256. setTimeout(function(){
  257. if (operationConfig.opr == "unzipAndOpen"){
  258. //If open after unzip is required
  259. ao_module_openPath(operationConfig.dest);
  260. }
  261. ao_module_close();
  262. }, 1000);
  263. }
  264. };
  265. ws.onerror = function(event){
  266. console.error("WebSocket error observed:", event);
  267. legacyMode = true;
  268. console.log("Falling back to Legacy Mode");
  269. unzip(srcList, dest, overwriteMode, callback);
  270. }
  271. }
  272. }
  273. //Create zip
  274. function zip(srcList, dest, overwriteMode){
  275. if (legacyMode){
  276. //Run in legacy mode
  277. requestCSRFToken(function(token){
  278. $.ajax({
  279. type: 'POST',
  280. url: `../../system/file_system/fileOpr`,
  281. data: {opr: "zip" ,src: JSON.stringify(srcList), dest: dest, csrft: token},
  282. success: function(data){
  283. handleFinish(data);
  284. }
  285. });
  286. });
  287. }else{
  288. //Replace all + sign with tag
  289. var filteredSrcList = [];
  290. srcList.forEach(src => {
  291. filteredSrcList.push(src.split("+").join("{{plug_sign}}"));
  292. })
  293. //Start WebSocket connection
  294. var endpoint = getWSEndpoint() + `?opr=zip&src=${encodeURIComponent(JSON.stringify(filteredSrcList))}&dest=${encodeURIComponent(dest)}&existsresp=${overwriteMode}`
  295. console.log(endpoint);
  296. var ws = new WebSocket(endpoint);
  297. var srcZipRoot = "";
  298. ws.onopen = function() {
  299. console.log("File Operation WebSocket opened")
  300. //Emulate the src folder
  301. var srcDir = srcList[0].split("/");
  302. srcDir.pop();
  303. srcDir = srcDir.join("/");
  304. srcZipRoot = srcDir;
  305. var currentSrc = truncate(srcDir, maxPathDisplayLength);
  306. $("#src").text(currentSrc);
  307. //Emulate the dest folder
  308. var destFolderName = dest.substr(0, dest.length - 1).split('/').pop();
  309. destFolderName += ".zip";
  310. var currentDest = truncate(dest + destFolderName, maxPathDisplayLength);
  311. $("#dest").text(currentDest);
  312. };
  313. ws.onmessage = function (evt) {
  314. var data = evt.data;
  315. var progress = JSON.parse(data);
  316. if (progress.Error != ""){
  317. //Something went wrong
  318. $("#progressbar").css("background-color", "#eb3f28");
  319. enterErrorMode = true;
  320. alert(progress.Error);
  321. }else{
  322. //Update the progress display
  323. $("#progressbar").css("width", progress.Progress + "%");
  324. var currentSrc = truncate(srcZipRoot + "/" + progress.LatestFile, maxPathDisplayLength);
  325. var filteredDest = operationConfig.dest.trim();
  326. if (filteredDest.substr(filteredDest.length -1, 1) != "/"){
  327. filteredDest += "/"
  328. }
  329. var currentDest = truncate(filteredDest + progress.LatestFile, maxPathDisplayLength);
  330. $("#src").text(currentSrc);
  331. $("#dest").text(currentDest);
  332. $("#progress").text(progress.Progress + "%")
  333. if (progress.Progress == 100){
  334. //Set progress bar to green
  335. $("#progressbar").css("background-color", "#2bba35");
  336. }
  337. }
  338. };
  339. ws.onclose = function() {
  340. //Transfer finished! Set OK and close in 1 second
  341. if (!enterErrorMode){
  342. $("#progressbar").css("background-color", "#2bba35");
  343. $("#progressbar").css("width", "100%");
  344. $("#progress").text("100%")
  345. handleFinish({});
  346. }
  347. };
  348. ws.onerror = function(event){
  349. console.error("WebSocket error observed:", event);
  350. legacyMode = true;
  351. console.log("Falling back to Legacy Mode");
  352. zip(srcList, dest, overwriteMode);
  353. }
  354. }
  355. }
  356. function cut(srcList, dest, overwriteMode){
  357. if (legacyMode){
  358. console.log("WebSocket not found, Running in legacy mode");
  359. requestCSRFToken(function(token){
  360. $.ajax({
  361. type: 'POST',
  362. url: `../../system/file_system/fileOpr`,
  363. data: {opr: "move" ,src: JSON.stringify(srcList), dest: dest,existsresp: overwriteMode, csrft: token},
  364. success: function(data){
  365. handleFinish(data);
  366. }
  367. });
  368. });
  369. }else{
  370. //Replace all + sign in srclist with {{plus_sign}}
  371. var filteredSrcList = [];
  372. srcList.forEach(src => {
  373. filteredSrcList.push(src.split("+").join("{{plug_sign}}"));
  374. })
  375. //Use Websocket for operation updates
  376. var endpoint = getWSEndpoint() + `?opr=move&src=${encodeURIComponent(JSON.stringify(filteredSrcList))}&dest=${encodeURIComponent(dest)}&existsresp=${overwriteMode}`
  377. console.log(endpoint);
  378. var ws = new WebSocket(endpoint);
  379. ws.onopen = function() {
  380. console.log("File Operation WebSocket opened")
  381. };
  382. ws.onmessage = function (evt) {
  383. var data = evt.data;
  384. var progress = JSON.parse(data);
  385. if (progress.Error != ""){
  386. $("#progressbar").css("background-color", "#eb3f28");
  387. enterErrorMode = true;
  388. alert(progress.Error);
  389. }else{
  390. $("#progressbar").css("width", progress.Progress + "%");
  391. var currentSrc = truncate(operationConfig.src + "/" + progress.LatestFile, maxPathDisplayLength);
  392. var filteredDest = operationConfig.dest.trim();
  393. if (filteredDest.substr(filteredDest.length -1, 1) != "/"){
  394. filteredDest += "/"
  395. }
  396. var currentDest = truncate(filteredDest + progress.LatestFile, maxPathDisplayLength);
  397. $("#src").text(currentSrc);
  398. $("#dest").text(currentDest);
  399. $("#progress").text(progress.Progress + "%")
  400. if (progress.Progress == 100){
  401. //Set progress bar to green
  402. $("#progressbar").css("background-color", "#2bba35");
  403. }
  404. }
  405. };
  406. ws.onclose = function() {
  407. //Transfer finished! Set OK and close in 1 second
  408. if (!enterErrorMode){
  409. $("#progressbar").css("background-color", "#2bba35");
  410. $("#progressbar").css("width", "100%");
  411. $("#progress").text("100%")
  412. handleFinish({});
  413. }
  414. };
  415. ws.onerror = function(event){
  416. console.error("WebSocket error observed:", event);
  417. console.log("Falling back to Legacy Mode")
  418. legacyMode = true;
  419. cut(srcList, dest, overwriteMode)
  420. }
  421. }
  422. }
  423. function copy(srcList, dest, overwriteMode){
  424. if (legacyMode){
  425. //Open operation in legacy mode
  426. console.log("WebSocket not found, Running in legacy mode");
  427. requestCSRFToken(function(token){
  428. $.ajax({
  429. type: 'POST',
  430. url: `../../system/file_system/fileOpr`,
  431. data: {opr: "copy" ,src: JSON.stringify(srcList), dest: dest,existsresp: overwriteMode , csrft: token},
  432. success: function(data){
  433. handleFinish(data);
  434. }
  435. });
  436. });
  437. }else{
  438. var filteredSrcList = [];
  439. srcList.forEach(src => {
  440. filteredSrcList.push(src.split("+").join("{{plug_sign}}"));
  441. })
  442. //Use Websocket for operation updates
  443. var endpoint = getWSEndpoint() + `?opr=copy&src=${JSON.stringify(filteredSrcList)}&dest=${encodeURIComponent(dest)}&existsresp=${overwriteMode}`
  444. var ws = new WebSocket(endpoint);
  445. ws.onopen = function() {
  446. console.log("File Operation WebSocket opened")
  447. };
  448. ws.onmessage = function (evt) {
  449. var data = evt.data;
  450. var progress = JSON.parse(data);
  451. if (progress.Error != ""){
  452. $("#progressbar").css("background-color", "#eb3f28");
  453. enterErrorMode = true;
  454. alert(progress.Error);
  455. }else{
  456. $("#progressbar").css("width", progress.Progress + "%");
  457. var currentSrc = truncate(operationConfig.src + "/" + progress.LatestFile, maxPathDisplayLength);
  458. var filteredDest = operationConfig.dest.trim();
  459. if (filteredDest.substr(filteredDest.length -1, 1) != "/"){
  460. filteredDest += "/"
  461. }
  462. var currentDest = truncate(filteredDest + progress.LatestFile, maxPathDisplayLength);
  463. $("#src").text(currentSrc);
  464. $("#dest").text(currentDest);
  465. $("#progress").text(progress.Progress + "%")
  466. if (progress.Progress == 100){
  467. //Set progress bar to green
  468. $("#progressbar").css("background-color", "#2bba35");
  469. }
  470. }
  471. };
  472. ws.onclose = function() {
  473. //Transfer finished! Set OK and close in 1 second
  474. if (!enterErrorMode){
  475. $("#progressbar").css("background-color", "#2bba35");
  476. $("#progressbar").css("width", "100%");
  477. $("#progress").text("100%");
  478. handleFinish({});
  479. }
  480. };
  481. ws.onerror = function(event){
  482. console.error("WebSocket error observed:", event);
  483. console.log("Falling back to Legacy Mode")
  484. legacyMode = true;
  485. copy(srcList, dest, overwriteMode)
  486. }
  487. }
  488. }
  489. var truncate = function (fullStr, strLen, separator) {
  490. if (fullStr.length <= strLen) return fullStr;
  491. separator = separator || '...';
  492. var sepLen = separator.length,
  493. charsToShow = strLen - sepLen,
  494. frontChars = Math.ceil(charsToShow/2),
  495. backChars = Math.floor(charsToShow/2);
  496. return fullStr.substr(0, frontChars) +
  497. separator +
  498. fullStr.substr(fullStr.length - backChars);
  499. };
  500. function getWSEndpoint(){
  501. //Open opeartion in websocket
  502. let protocol = "wss://";
  503. if (location.protocol !== 'https:') {
  504. protocol = "ws://";
  505. }
  506. var port = window.location.port;
  507. if (window.location.port == ""){
  508. if (location.protocol !== 'https:') {
  509. port = "80";
  510. }else{
  511. port = "443";
  512. }
  513. }
  514. wsControlEndpoint = (protocol + window.location.hostname + ":" + port + "/system/file_system/ws/fileOpr");
  515. return wsControlEndpoint;
  516. }
  517. function updateTitle(fileNumber, opr){
  518. var title = "";
  519. if (opr == "move"){
  520. title = "Moving ";
  521. }else if (opr == "copy"){
  522. title = "Copying ";
  523. }else if (opr == "zip" || opr == "zipAndDownload"){
  524. title = "Zipping ";
  525. }else if (opr == "download"){
  526. title = "Downloading ";
  527. }else if (opr == "unzip" || opr == "unzipAndOpen"){
  528. title = "Unzipping ";
  529. }
  530. title += fileNumber + " ";
  531. if (fileNumber == 1){
  532. title += " File";
  533. }else{
  534. title += " Files";
  535. }
  536. $(".title").text(title);
  537. }
  538. function handleFinish(data){
  539. if (data.error !== undefined){
  540. $("#progressbar").css("background-color","#db2828");
  541. $("#progressbar").parent().removeClass('active');
  542. $(".title").html(`<i class="remove icon"></i>` + data.error);
  543. }else{
  544. $("#progressbar").css("background-color","#21ba45");
  545. $("#progressbar").parent().removeClass('active');
  546. if (opr == "move" || opr == "copy" || opr == "zip" || opr == "unzip"){
  547. //Action completed. close window.
  548. setTimeout(function(){
  549. //Do callback if exists
  550. if (operationConfig.callbackWindowID == "desktop"){
  551. //Special call from desktop
  552. parent.eval(operationConfig.callbackFunction);
  553. }else if (operationConfig.callbackWindowID !== undefined && operationConfig.callbackFunction !== undefined){
  554. var callbackWindowObject = parent.getFloatWindowByID(operationConfig.callbackWindowID)
  555. var windowObject = $(callbackWindowObject).find("iframe")[0];
  556. console.log(windowObject.contentWindow, operationConfig.callbackFunction);
  557. windowObject.contentWindow.eval(operationConfig.callbackFunction);
  558. }
  559. //If the target or src is desktop, refresh desktop as well
  560. if(pathIsOnDesktop(operationConfig.dest) || pathIsOnDesktop(operationConfig.src[0])){
  561. parent.refresh(undefined, true);
  562. }
  563. ao_module_close();
  564. }, 1000);
  565. }else if (opr == "download"){
  566. //Create download from buffer
  567. }else if (opr == "zipAndDown"){
  568. //Download
  569. }else if (opr == "unzipAndOpen"){
  570. //Unzip and open the target directory
  571. setTimeout(function(){
  572. //Open the target directory
  573. ao_module_openPath(operationConfig.dest);
  574. //Close the window
  575. ao_module_close();
  576. }, 1000);
  577. }
  578. }
  579. console.log(data);
  580. }
  581. function pathIsOnDesktop(path){
  582. var filteredDest = path;
  583. if (filteredDest.substr(filteredDest.length - 1) == "/"){
  584. filteredDest = filteredDest.substr(0, filteredDest.length - 1);
  585. }
  586. var dirChunk = filteredDest.split("/");
  587. console.log(dirChunk);
  588. if (dirChunk.length == 2 || dirChunk.length == 3){
  589. if (dirChunk[0].toLowerCase() == "user:" && dirChunk[1].toLowerCase() == "desktop"){
  590. //This is a direct access desktop file
  591. return true;
  592. }
  593. }
  594. return false;
  595. }
  596. function requestCSRFToken(callback){
  597. $.ajax({
  598. url: "../../system/csrf/new",
  599. success: function(token){
  600. callback(token);
  601. }
  602. })
  603. }
  604. </script>
  605. </body>
  606. </html>