mirror of
https://github.com/xevidos/codiad.git
synced 2025-01-08 22:11:55 +01:00
Fixed some bugs in installation process, Updated cursor tracking, Added the option to show errors when executing sql, Fixed quote issue in system module, Fixed z-index context menu issue.
This commit is contained in:
parent
f4f7140255
commit
9b452b33bd
8 changed files with 142 additions and 11 deletions
|
@ -38,7 +38,7 @@ class Active extends Common {
|
|||
public function ListActive() {
|
||||
|
||||
global $sql;
|
||||
$query = "SELECT path,focused FROM active WHERE username=?";
|
||||
$query = "SELECT path,position,focused FROM active WHERE username=?";
|
||||
$bind_variables = array( $this->username );
|
||||
$result = $sql->query( $query, $bind_variables, array() );
|
||||
$tainted = false;
|
||||
|
@ -191,4 +191,17 @@ class Active extends Common {
|
|||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
|
||||
public function savePosition() {
|
||||
|
||||
global $sql;
|
||||
$query = "UPDATE active SET position=? WHERE path=? AND username=?;";
|
||||
$bind_variables = array( $_POST["position"], $this->path, $this->username );
|
||||
$return = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $return > 0 ) {
|
||||
|
||||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,3 +85,9 @@ if ($_GET['action']=='focused') {
|
|||
$Active->path = $_GET['path'];
|
||||
$Active->MarkFileAsFocused();
|
||||
}
|
||||
|
||||
if ($_GET['action']=='save_position') {
|
||||
$Active->username = $_SESSION['user'];
|
||||
$Active->path = $_POST['path'];
|
||||
$Active->savePosition();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,11 @@
|
|||
|
||||
// History of opened files
|
||||
history: [],
|
||||
|
||||
|
||||
// List of active file positions
|
||||
positions: {},
|
||||
position_timer: null,
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Check if a file is open.
|
||||
|
@ -71,6 +75,7 @@
|
|||
var mode = codiad.editor.selectMode( path );
|
||||
|
||||
var fn = function() {
|
||||
|
||||
//var Mode = require('ace/mode/' + mode)
|
||||
// .Mode;
|
||||
|
||||
|
@ -95,6 +100,12 @@
|
|||
codiad.editor.setSession(session);
|
||||
}
|
||||
_this.add(path, session, focus);
|
||||
|
||||
if( ! ( _this.positions[`${path}`] === undefined ) ) {
|
||||
|
||||
_this.setPosition( _this.positions[`${path}`] );
|
||||
}
|
||||
|
||||
/* Notify listeners. */
|
||||
amplify.publish('active.onOpen', path);
|
||||
};
|
||||
|
@ -265,6 +276,8 @@
|
|||
var listResponse = codiad.jsend.parse(data);
|
||||
if (listResponse !== null) {
|
||||
$.each(listResponse, function(index, data) {
|
||||
|
||||
codiad.active.positions[`${data.path}`] = JSON.parse( data.position );
|
||||
codiad.filemanager.openFile(data.path, data.focused);
|
||||
});
|
||||
}
|
||||
|
@ -978,7 +991,89 @@
|
|||
$('#tab-close').hide();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
savePosition: function() {
|
||||
|
||||
let editor = codiad.editor.getActive();
|
||||
let session = editor.getSession();
|
||||
let path = session.path;
|
||||
let position = this.getPosition( null, true );
|
||||
|
||||
this.positions[path] = position;
|
||||
|
||||
setTimeout( function() {
|
||||
|
||||
if( ( codiad.active.position_timer + 500 ) > Date.now() ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//console.log( codiad.active.position_timer, path, JSON.stringify( position ) );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: codiad.active.controller + '?action=save_position',
|
||||
data: {
|
||||
path: path,
|
||||
position: JSON.stringify( position )
|
||||
},
|
||||
success: function( data ) {
|
||||
|
||||
codiad.active.position_timer = Date.now();
|
||||
//console.log( "called save position: ", data );
|
||||
},
|
||||
});
|
||||
}, 500);
|
||||
},
|
||||
|
||||
getPosition: function( path=null, live=false ) {
|
||||
|
||||
if( path === null ) {
|
||||
|
||||
path = this.getPath();
|
||||
}
|
||||
|
||||
let editor = null;
|
||||
let position = null;
|
||||
let session = codiad.active.sessions[path];
|
||||
|
||||
for( let i = codiad.editor.instances.length;i--; ) {
|
||||
|
||||
//console.log( codiad.editor.instances[i].getSession().path, path, ( codiad.editor.instances[i].getSession().path == path ) );
|
||||
|
||||
if( codiad.editor.instances[i].getSession().path == path ) {
|
||||
|
||||
editor = codiad.editor.instances[i];
|
||||
}
|
||||
}
|
||||
|
||||
if( live ) {
|
||||
|
||||
position = editor.getCursorPosition();
|
||||
} else {
|
||||
|
||||
if( ! this.positions[path] === undefined ) {
|
||||
|
||||
position = this.positions[path].position;
|
||||
}
|
||||
}
|
||||
return position;
|
||||
},
|
||||
|
||||
setPosition: function( cursor=null ) {
|
||||
|
||||
let editor = codiad.editor.getActive();
|
||||
|
||||
if( cursor == null ) {
|
||||
|
||||
cursor = this.getPosition();
|
||||
}
|
||||
|
||||
console.log( "setting position", cursor );
|
||||
|
||||
editor.scrollToLine( cursor.row, true, true, function() {});
|
||||
editor.moveCursorTo( cursor.row, cursor.column );
|
||||
},
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Factory
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -474,7 +474,8 @@
|
|||
this.setSession(session, i);
|
||||
|
||||
this.changeListener(i);
|
||||
this.cursorTracking(i);
|
||||
//this.cursorTracking(i);
|
||||
this.clickListener(i);
|
||||
this.bindKeys(i);
|
||||
|
||||
this.instances.push(i);
|
||||
|
@ -1178,9 +1179,21 @@
|
|||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
changeListener: function(i) {
|
||||
|
||||
var _this = this;
|
||||
i.on('change', function() {
|
||||
|
||||
codiad.active.markChanged(_this.getActive().getSession().path);
|
||||
codiad.active.savePosition();
|
||||
});
|
||||
},
|
||||
|
||||
clickListener: function(i) {
|
||||
|
||||
var _this = this;
|
||||
i.on('click', function() {
|
||||
|
||||
codiad.active.savePosition();
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ define("WSURL", BASE_URL . "/workspace");
|
|||
function create_project() {
|
||||
|
||||
$project_path = $this->project_path;
|
||||
|
||||
|
||||
if ( ! $this->is_abs_path( $project_path ) ) {
|
||||
|
||||
$project_path = str_replace( " ", "_", preg_replace( '/[^\w-\.]/', '', $project_path ) );
|
||||
|
@ -211,8 +211,7 @@ define("WSURL", BASE_URL . "/workspace");
|
|||
|
||||
if ( ! $result === true ) {
|
||||
|
||||
$this->restore();
|
||||
die( '{"message":"Could not tables in database.","error":"' . json_encode( $error ) .'"}' );
|
||||
die( '{"message":"Could not tables in database.","error":"' . json_encode( $result ) .'"}' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +248,7 @@ define("WSURL", BASE_URL . "/workspace");
|
|||
}
|
||||
|
||||
function is_abs_path( $path ) {
|
||||
|
||||
|
||||
return $path[0] === '/';
|
||||
}
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ class sql {
|
|||
//echo var_dump( $query ) . "<br>";
|
||||
}
|
||||
|
||||
public function query( $query, $bind_variables, $default, $action='fetchAll' ) {
|
||||
public function query( $query, $bind_variables, $default, $action='fetchAll', $show_errors=false ) {
|
||||
|
||||
$connection = $this->connect();
|
||||
$statement = $connection->prepare( $query );
|
||||
|
@ -267,6 +267,11 @@ class sql {
|
|||
$return = $default;
|
||||
}
|
||||
|
||||
if( $show_errors ) {
|
||||
|
||||
$return = json_encode( $error );
|
||||
}
|
||||
|
||||
//echo var_dump( $error, $return );
|
||||
|
||||
$this->close();
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
|
||||
let response = codiad.jsend.parse( data );
|
||||
|
||||
if( response.status != error ) {
|
||||
if( response.status != 'error' ) {
|
||||
|
||||
codiad.message.success( i18n( 'Created Default Tables' ) );
|
||||
} else {
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
width: 140px;
|
||||
padding: 0;
|
||||
background: #333;
|
||||
z-index: 10;
|
||||
z-index: 13;
|
||||
background-clip: content-box;
|
||||
border: 3px solid rgba(255, 255, 255, 0.5);
|
||||
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, .9);
|
||||
|
|
Loading…
Reference in a new issue