mirror of
https://github.com/xevidos/codiad.git
synced 2025-03-13 20:18:43 +01:00
Reverted autosave component, Fixed new duplicate function, Started work on delete contents issue and rescan not updating, Added more publish events.
This commit is contained in:
parent
27111047be
commit
5ae4c4c0d9
3 changed files with 63 additions and 31 deletions
|
@ -108,11 +108,21 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
let tabs = document.getElementsByClassName( "tab-item" );
|
let tabs = document.getElementsByClassName( "tab-item" );
|
||||||
let path = codiad.active.getPath();
|
let path = codiad.active.getPath();
|
||||||
let content = codiad.editor.getContent();
|
let content = codiad.editor.getContent();
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
this code caused issues even though it is the proper way to save something.
|
||||||
|
Whenever in collaboration, the server constantly gave a wrong file version error.
|
||||||
|
|
||||||
|
let path = codiad.active.getPath();
|
||||||
|
codiad.active.save( path, false );
|
||||||
|
this.saving = false;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
codiad.active.save;
|
codiad.active.save;
|
||||||
codiad.filemanager.saveFile( path, content, localStorage.removeItem( path ), false );
|
codiad.filemanager.saveFile( path, content, localStorage.removeItem( path ), false );
|
||||||
var session = codiad.active.sessions[path];
|
var session = codiad.active.sessions[path];
|
||||||
|
@ -129,10 +139,7 @@
|
||||||
|
|
||||||
session.tabThumb.removeClass('changed');
|
session.tabThumb.removeClass('changed');
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
let path = codiad.active.getPath();
|
|
||||||
codiad.active.save( path, false );
|
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -112,26 +112,48 @@ class Filemanager extends Common {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if( ( is_file( $this->destination ) || is_dir( $this->destination ) ) ) {
|
if( is_dir( $this->destination ) ) {
|
||||||
|
|
||||||
$this->destination = $get['destination'] . " $i";
|
$this->destination = $get['destination'] . " $i";
|
||||||
|
} elseif( is_file( $this->destination ) ) {
|
||||||
|
|
||||||
|
$path_parts = pathinfo( $this->destination );
|
||||||
|
|
||||||
|
if( isset( $path_parts["extension"] ) ) {
|
||||||
|
|
||||||
|
$this->destination = str_replace( ".{$path_parts["extension"]}", " {$i}.{$path_parts["extension"]}", $get['destination'] );
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$this->destination = $get['destination'] . " $i";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$i++;
|
|
||||||
|
|
||||||
echo var_dump( $this->destination );
|
$i++;
|
||||||
} while( ( is_file( $this->destination ) || is_dir( $this->destination ) ) );
|
} while( ( is_file( $this->destination ) || is_dir( $this->destination ) ) );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$this->destination = $get['destination'];
|
$this->destination = $this->root . $get['destination'];
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if( ( is_file( $this->destination ) || is_dir( $this->destination ) ) ) {
|
if( is_dir( $this->destination ) ) {
|
||||||
|
|
||||||
$this->destination = $this->root . $get['destination'] . " $i";
|
$this->destination = $this->root . $get['destination'] . " $i";
|
||||||
|
} elseif( is_file( $this->destination ) ) {
|
||||||
|
|
||||||
|
$path_parts = pathinfo( $this->destination );
|
||||||
|
|
||||||
|
if( isset( $path_parts["extension"] ) ) {
|
||||||
|
|
||||||
|
$this->destination = str_replace( ".{$path_parts["extension"]}", " {$i}.{$path_parts["extension"]}", $this->root . $get['destination'] );
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$this->destination = $this->root . $get['destination'] . " $i";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
echo var_dump( $this->destination );
|
|
||||||
} while( ( is_file( $this->destination ) || is_dir( $this->destination ) ) );
|
} while( ( is_file( $this->destination ) || is_dir( $this->destination ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,14 +395,11 @@
|
||||||
if (this.rescanCounter === 0) {
|
if (this.rescanCounter === 0) {
|
||||||
// Create array of open directories
|
// Create array of open directories
|
||||||
node = $('#file-manager a[data-path="' + path + '"]');
|
node = $('#file-manager a[data-path="' + path + '"]');
|
||||||
node.parent()
|
node.parent().find('a.open').each(function() {
|
||||||
.find('a.open')
|
_this.rescanChildren.push($(this).attr('data-path'));
|
||||||
.each(function() {
|
});
|
||||||
_this.rescanChildren.push($(this)
|
|
||||||
.attr('data-path'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.index(path, true);
|
this.index(path, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -520,11 +517,11 @@
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// Save file
|
// Save file
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
saveFile: function(path, content, callbacks, save=true) {
|
saveFile: function(path, content, callbacks, save=true) {
|
||||||
this.saveModifications(path, {content: content}, callbacks, save);
|
this.saveModifications(path, {content: content}, callbacks, save);
|
||||||
},
|
},
|
||||||
|
|
||||||
savePatch: function(path, patch, mtime, callbacks, alerts) {
|
savePatch: function(path, patch, mtime, callbacks, alerts) {
|
||||||
if (patch.length > 0)
|
if (patch.length > 0)
|
||||||
this.saveModifications(path, {patch: patch, mtime: mtime}, callbacks, alerts);
|
this.saveModifications(path, {patch: patch, mtime: mtime}, callbacks, alerts);
|
||||||
|
@ -533,11 +530,11 @@
|
||||||
callbacks.success.call(context, mtime);
|
callbacks.success.call(context, mtime);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// Create Object
|
// Create Object
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
createNode: function(path, type) {
|
createNode: function(path, type) {
|
||||||
codiad.modal.load(250, this.dialog, {
|
codiad.modal.load(250, this.dialog, {
|
||||||
action: 'create',
|
action: 'create',
|
||||||
|
@ -613,7 +610,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
processPasteNode: function(path,duplicate) {
|
processPasteNode: function(path,duplicate) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var shortName = this.getShortName(this.clipboard);
|
var shortName = this.getShortName(this.clipboard);
|
||||||
|
@ -631,11 +628,11 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// Rename
|
// Rename
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
renameNode: function(path) {
|
renameNode: function(path) {
|
||||||
var shortName = this.getShortName(path);
|
var shortName = this.getShortName(path);
|
||||||
var type = this.getType(path);
|
var type = this.getType(path);
|
||||||
|
@ -659,6 +656,7 @@
|
||||||
codiad.message.success(type.charAt(0)
|
codiad.message.success(type.charAt(0)
|
||||||
.toUpperCase() + type.slice(1) + ' Renamed');
|
.toUpperCase() + type.slice(1) + ' Renamed');
|
||||||
var node = $('#file-manager a[data-path="' + path + '"]');
|
var node = $('#file-manager a[data-path="' + path + '"]');
|
||||||
|
let parentPath = node.parent().parent().prev().attr('data-path');
|
||||||
// Change pathing and name for node
|
// Change pathing and name for node
|
||||||
node.attr('data-path', newPath)
|
node.attr('data-path', newPath)
|
||||||
.html(newName);
|
.html(newName);
|
||||||
|
@ -674,6 +672,9 @@
|
||||||
// Change any active files
|
// Change any active files
|
||||||
codiad.active.rename(path, newPath);
|
codiad.active.rename(path, newPath);
|
||||||
codiad.modal.unload();
|
codiad.modal.unload();
|
||||||
|
|
||||||
|
/* Notify listeners. */
|
||||||
|
amplify.publish('filemanager.onRename', {path: path, newPath: newPath, parentPath: parentPath });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -710,8 +711,8 @@
|
||||||
var deleteResponse = codiad.jsend.parse(data);
|
var deleteResponse = codiad.jsend.parse(data);
|
||||||
if (deleteResponse != 'error') {
|
if (deleteResponse != 'error') {
|
||||||
var node = $('#file-manager a[data-path="' + path + '"]');
|
var node = $('#file-manager a[data-path="' + path + '"]');
|
||||||
node.parent('li')
|
let parent_path = node.parent().parent().prev().attr('data-path');
|
||||||
.remove();
|
node.parent('li').remove();
|
||||||
// Close any active files
|
// Close any active files
|
||||||
$('#active-files a')
|
$('#active-files a')
|
||||||
.each(function() {
|
.each(function() {
|
||||||
|
@ -721,6 +722,8 @@
|
||||||
codiad.active.remove(curPath);
|
codiad.active.remove(curPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/* Notify listeners. */
|
||||||
|
amplify.publish('filemanager.onDelete', {deletePath: path, path: parent_path });
|
||||||
}
|
}
|
||||||
codiad.modal.unload();
|
codiad.modal.unload();
|
||||||
});
|
});
|
||||||
|
@ -739,10 +742,7 @@
|
||||||
$.get(_this.controller + '?action=deleteInner&path=' + encodeURIComponent(path), function(data) {
|
$.get(_this.controller + '?action=deleteInner&path=' + encodeURIComponent(path), function(data) {
|
||||||
var deleteResponse = codiad.jsend.parse(data);
|
var deleteResponse = codiad.jsend.parse(data);
|
||||||
if (deleteResponse != 'error') {
|
if (deleteResponse != 'error') {
|
||||||
var node = $('#file-manager a[data-path="' + path + '"]');
|
var node = $('#file-manager a[data-path="' + path + '"]').parent('ul').remove();
|
||||||
while(node.firstChild) {
|
|
||||||
node.removeChild(node.firstChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close any active files
|
// Close any active files
|
||||||
$('#active-files a')
|
$('#active-files a')
|
||||||
|
@ -761,6 +761,9 @@
|
||||||
_this.rescanChildren.push($(this)
|
_this.rescanChildren.push($(this)
|
||||||
.attr('data-path'));
|
.attr('data-path'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Notify listeners. */
|
||||||
|
amplify.publish('filemanager.onDelete', {deletePath: path + "/*", path: path });
|
||||||
}
|
}
|
||||||
codiad.modal.unload();
|
codiad.modal.unload();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue