Updated copyright info and ajax responses
This commit is contained in:
parent
3ab8739809
commit
3886a749fb
|
@ -54,17 +54,17 @@ if(isset($_SESSION[$sessionname])){
|
||||||
// Force save?
|
// Force save?
|
||||||
if($force){
|
if($force){
|
||||||
do_save($path, $filecontents);
|
do_save($path, $filecontents);
|
||||||
echo '1';
|
OC_JSON::success();
|
||||||
} else {
|
} else {
|
||||||
// No force
|
// No force
|
||||||
// Show error
|
// Show error
|
||||||
echo '2';
|
OC_JSON::faliure();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No body has edited it whilst you were, so save the file
|
// No body has edited it whilst you were, so save the file
|
||||||
// Update the session hash.
|
// Update the session hash.
|
||||||
do_save($path,$filecontents);
|
do_save($path,$filecontents);
|
||||||
echo '1';
|
OC_JSON::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,8 +72,5 @@ if(isset($_SESSION[$sessionname])){
|
||||||
} else {
|
} else {
|
||||||
// No session value set for soem reason, just save the file.
|
// No session value set for soem reason, just save the file.
|
||||||
do_save($path,$filecontents);
|
do_save($path,$filecontents);
|
||||||
echo '1';
|
OC_JSON::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//OC_JSON::success(array('data' => array( 'success' => 'true' )));
|
|
|
@ -2,8 +2,8 @@
|
||||||
/**
|
/**
|
||||||
* ownCloud - Addressbook
|
* ownCloud - Addressbook
|
||||||
*
|
*
|
||||||
* @author Jakob Sack
|
* @author Tom Needham
|
||||||
* @copyright 2011 Jakob Sack mail@jakobsack.de
|
* @copyright 2011 Tom Needham contact@tomneedham.com
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
@ -33,11 +33,12 @@ $file = $_GET['file'];
|
||||||
$dir = $_GET['dir'];
|
$dir = $_GET['dir'];
|
||||||
$path = $dir.'/'.$file;
|
$path = $dir.'/'.$file;
|
||||||
|
|
||||||
|
// Add scripts
|
||||||
OC_UTIL::addStyle('editor', 'styles');
|
OC_UTIL::addStyle('editor', 'styles');
|
||||||
OC_UTIL::addScript('editor','editor');
|
OC_UTIL::addScript('editor','editor');
|
||||||
OC_UTIL::addScript('editor','aceeditor/ace');
|
OC_UTIL::addScript('editor','aceeditor/ace');
|
||||||
|
|
||||||
//Get file type
|
// Get file type
|
||||||
if(substr_count($file,'.')!=0){
|
if(substr_count($file,'.')!=0){
|
||||||
// Find extension
|
// Find extension
|
||||||
$parts = explode(".",$file);
|
$parts = explode(".",$file);
|
||||||
|
@ -56,11 +57,11 @@ if(substr_count($file,'.')!=0){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add theme
|
||||||
OC_UTIL::addScript('editor','aceeditor/theme-cobalt');
|
OC_UTIL::addScript('editor','aceeditor/theme-cobalt');
|
||||||
|
|
||||||
OC_App::setActiveNavigationEntry( 'editor_index' );
|
OC_App::setActiveNavigationEntry( 'editor_index' );
|
||||||
|
|
||||||
|
|
||||||
// Save a hash of the file for later
|
// Save a hash of the file for later
|
||||||
$sessionname = md5('oc_file_hash_'.$path);
|
$sessionname = md5('oc_file_hash_'.$path);
|
||||||
$_SESSION[$sessionname] = $filehash;
|
$_SESSION[$sessionname] = $filehash;
|
||||||
|
|
|
@ -23,27 +23,33 @@ $(document).ready(function(){
|
||||||
var filecontents = window.aceEditor.getSession().getValue();
|
var filecontents = window.aceEditor.getSession().getValue();
|
||||||
var dir = $('#editor').attr('data-dir');
|
var dir = $('#editor').attr('data-dir');
|
||||||
var file = $('#editor').attr('data-file');
|
var file = $('#editor').attr('data-file');
|
||||||
$.post('ajax/savefile.php',{ filecontents: filecontents, file: file, dir: dir },function(data){
|
$.post('ajax/savefile.php',{ filecontents: filecontents, file: file, dir: dir },function(jsondata){
|
||||||
if(data=='2'){
|
if(jsondata.satus == 'failure'){
|
||||||
var answer = confirm('The file has been modified after you opened it. Do you want to overwrite the file with your changes?');
|
var answer = confirm('The file has been modified after you opened it. Do you want to overwrite the file with your changes?');
|
||||||
if(answer){
|
if(answer){
|
||||||
$.post('ajax/savefile.php',{ filecontents: filecontents, file: file, dir: dir, force: 'true' },function(data){
|
$.post('ajax/savefile.php',{ filecontents: filecontents, file: file, dir: dir, force: 'true' },function(jsondata){
|
||||||
if(data=='1'){
|
if(jsondata.status =='success'){
|
||||||
$('#editor_save').val('Save');
|
$('#editor_save').val('Save');
|
||||||
$('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000);
|
$('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000);
|
||||||
}
|
}
|
||||||
});
|
else {
|
||||||
} else {
|
// Save error
|
||||||
// Don't save!
|
alert('Error saving the file. Please report this!');
|
||||||
$('#editor_save').effect("highlight", {color:'#FF5757'}, 3000);
|
}
|
||||||
$('#editor_save').val('Save');
|
}, 'json');
|
||||||
}
|
}
|
||||||
} else if(data=='1'){
|
else {
|
||||||
|
// Don't save!
|
||||||
|
$('#editor_save').effect("highlight", {color:'#FF5757'}, 3000);
|
||||||
|
$('#editor_save').val('Save');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(jsondata.status == 'success'){
|
||||||
// Success
|
// Success
|
||||||
$('#editor_save').val('Save');
|
$('#editor_save').val('Save');
|
||||||
$('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000);
|
$('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000);
|
||||||
}
|
}
|
||||||
});
|
}, 'json');
|
||||||
// TODO give focus back to the editor
|
// TODO give focus back to the editor
|
||||||
// window.aceEditor.focus();
|
// window.aceEditor.focus();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue